deploying rails on nginx and thin

I have been busy lately doing my Final Year Project which comprises of building a web based service for processing analysis jobs on patient data.

I have developed the web service API using [Rails][rails] with MySQL being the backend database.

For deployment purposes I had no idea which of the web servers to run as such I naturally googled online and found people talking about [Capistrano][caps], a great way to have deployment scripts being run on the server.

I needed something simple, I had seen the advantages of using SVN and [Nginx][nginx] as a means to deploy by SSH-ing to the server. This keeps things simple and lends us as much control as we need. So I explored.


singleton in python

In my current Final Year Project (FYP) for my undergraduate degree I needed to spawn processes and be able to store their state in the memory so that they can be started/re-started or stopped. I had previously gone about doing the same kind of operation in Java with a Singleton ProcessManager Class so I was pretty sure that such a pattern would exist in Python as well. Turns out, it is a [bad practice][link1] to do so.

Anyways, I could not figure out a better way to do this, so I stuck with Singletons. Moreover it got me the job done.


django dynamic forms

Here is an example of how to do a dynamic form in Django. I am loving this framework, it’s so simple class ServiceStartForm(forms.Form): serviceList = service.models.Service.objects.all() print serviceList.count() b = {} for aService in serviceList: b[aService.id] = aService.name c = b.items() print "Within the form, ", serviceList.count() serviceChoice = forms.ChoiceField(choices=c, widget=forms.Select()) input_directory = forms.CharField(max_length=200) output_directory = forms.CharField(max_length=200) def __init__(self, *args, **kwargs): super(ServiceStartForm, self).__init__(*args, **kwargs) serviceList = service.models.Service.objects.all() b = {}

django and travis

A sample .travis file to allow you to run and test on the Travis CI. language: python python: # - "2.6" - "2.7" services: mysql env: # - DJANGO=1.2.7 # - DJANGO=1.3.1 - DJANGO=1.4.3 DJANGO_SETTINGS_MODULE="mysite.travis_settings" install: - pip install -q Django==$DJANGO --use-mirrors - pip install pep8 --use-mirrors - pip install mysql-python --use-mirrors # - pip install https://github.com/dcramer/pyflakes/tarball/master # - pip install -q -e . --use-mirrors before_script: # - "pep8 --exclude=migrations

django fun

Here’s how to install python on your web server :) ###Log in using SSH access This process may change from different kind of hosts to different machines so find out first. ###Install Python 2.7.2 mkdir ~/python cd ~/python wget http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tgz tar zxfv Python-2.7.2.tgz rm -rf Python-2.7.2.tgz find ~/python -type d | xargs chmod 0755 cd Python-2.7.2 ./configure --prefix=$HOME/python make make install cd .. rm -rf Python-2.7.2 ###Modify ~/.bashrc vim ~/.bashrc # Press i and enter the following: export PATH=$HOME/python/bin:$PATH # press <escape>:wq<enter> source ~/.bashrc # Whenever you want to work using Python 2.7 in the # console you will need to enter this Test your Python install python -V # This should output "Python 2.7.2" ###Install setuptools wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz tar xzvf setuptools-0.6c11.tar.gz rm setuptools-0.6c11.tar.gz cd setuptools-0.6c11 python setup.py install cd ..

essential mozilla command line

This is a reference of some of the very important mozilla commands that I use in daily Terminal Life ###Requirements Set up Hg, Autoconf using Brew. Look up the instructions at the official website. ###Setting up of Source Directory Mozilla Code can be checked out from http://hg.mozilla.org. To set up a Thunderbird and Calendar clone on your local machine checkout the source code as bash$ hg clone http://hg.mozilla.org/comm-central This will create a comm-central directory in your local machine Now comm-central depends on a number of submodules which can be fetched by the following commands bash$ cd comm-central bash$ python client.py checkout This will fetch the submodules.

creating an api with net mvc4

##Gist Recently while working on a vacation assigment I had to create an API in ASP .NET MVC. This was in order to create a booking system on top of the Google Calendar Event storage. Google provides 50000 calls per day free of chrage for the API so we thought this might work. But it also required some form of authentication to prevent the API facade from being misused. ##OpenId Well when you can’t store the authentication result you need to think of some third party based authentication mechanism and OpenId is one those means.

a home called india

And now some random philosphical thoughts on what I think of India: my home I am an Indian from India. For most of us, the buck stop right there. I grew up just like the rest of the kids in my colony: I thought we as a Nation are huge, the best in the world. Buoyed by my sense of patriotism I even wrote a story about an army related incursion in Kashmir which got published in Champak.I knew I had a passion for writing.

design patterns in javascript widget based design

One of the most important things people learn after doing/learning a new language or as-these-days a framework is to be able to apply one of the most sought after industrial practices in the form of design patterns. The current semester I had a course involving hefty use of Design Patterns. The course CS3213-Software Design revolved in using design patterns and applying them to the world of software in extreme detail, which I never in my dreams would have imagined.

a web service for multi factor authentication

One of the projects done by me this semester was making Multi-Factor Authentication available for use by other websites. This required hosting our MFA web service over the internet.