Gamaya logo

Python-Flask app for Gamaya user rergistrations

Recently, I wrote a web application for handling student registrations of Gamaya 2014, the tech fest conducted at my college. It was made with Python-Flask, and the source can be found here at github. It let users create an account and register for interested events. The event managers could then see the details of those who had registered for their event.

In all its essence, it is a basic CRUD application, but making it was quite an experience and I learned a few things the hard way along the way, since it was my first web app.

Templates were built using bootstrap which later proved to be quite useful for its inbuilt responsive design. Many of the users were using the website from mobile phones and bootstrap provided a nice responsive page for them.

I had originally intended to run it on Heroku, but one of the dependencies, Flask-WeasyPrint, could not be installed in Heroku due to a missing package in the underlying OS. Flask-WeasyPrint was required to generate PDFs, so I hosted the app in Red Hat’s OpenShift platform, and it performed well there.

The site had 1000+ user registrations and 1600+ event registrations. It was indeed a rewarding experience to watch the logs as the traffic flowed to the site 😀

Simple single letter spell checker in bash

Here’s a small bash script. It checks if the given word is in dictionary and if not, assuming that it contains only a single character error, gives suggestions.

#!/bin/bash
word=$1
grep -i "^$word$" /usr/share/dict/words > /dev/null
if [ $? -eq 0 ]; then
   echo "Word in dictionary";
else
    echo "Word not in dictionary. Suggestions:"
    l=${#word}
    for i in $(seq 1 $l);
    do
        regw=`echo $word | sed s/././$i`
        grep -i "^$regw$" /usr/share/dict/words
    done
fi

This was actually a question i had  in Tux of War, a shell scripting competition organized as a part of tathva at NIT Calicut. I got the sed expression from stackoveflow. It replaces just one letter of the word with ‘.’ in order in aloop, so that it would be a valid regex in grep to find the word suggestions.

I’m happy that my attempt works and I’m also sure there must be an efficient and easy method to do this! 😀

Setting Up Archlinux using chroot: The lazy way

Setting up Archlinux is fun. For an interested beginner, it’s an enlightening experience. You get to know what package are needed to build and run your system, step by step, and it also gives this good feeling of being in power. So recently, I tried to do a fresh Archlinux install. This was on the laptop, in which I already had a perfectly working Ubuntu already installed. Usually, on PC, connecting internet in the minimal environment of arch is as simple as connecting the Ethernet cable and forgetting it. But this time, I had only wireless to rely on. Since the mere thought of taking out the eth cable from those unimaginable knots behind the desktop is enough to give me the shivers, and since I had no previous experience setting up wireless in Arch, I was facing some  troubles. I left the task after a few vain attempts in which I realised I should have taken care to select and install the necessary packages for wireless during installation of Archlinux core.

But leaving a task undone is annoying. Every time I boot up, the Archlinux entry in grub seemed to be looking at me hopefully, awaiting its turn to be a ready to use installation. So eventually this thought occurred to me: Why not use chroot in Ubuntu to fix all issues and get Archlinux working?

The little previous experience I had with chrooting into Archlinux was when I tried to remake the kernel image after update in the desktop. I was then positively amused by the fact that an internet connection set up in Ubuntu could well serve Archlinux and help it fetch the packages even in that environment. If it could fetch then, why not now? Let the hacking begin! (Bit too enthusiastic, I know 😀 )

As always, I looked  up the Archlinux wiki on Changing Root and followed the instructions:

mkdir /mnt/arch
mount /dev/<device-or-partition-name> /mnt/arch
cd /mnt/arch
mount -t proc proc proc/
mount -t sysfs sys sys/
mount -o bind /dev dev/
mount -t devpts pts dev/pts/
chroot . /bin/bash

With these, I was able to run a pacman -Syu and get the packages. I could also install wireless_tools and wpa_supplicant, the two packages which I should have selected during the installation for configuring wireless. Even then, configuring wireless was yet another adventure. Linux continues to be fun!