Nikunj Handa

Entrepreneur, Software Engineer. Previously @MESTghana. Bitcoins, Africa, Freeletics.

Read this first

Token Authentication with Django and AngularJS

For the past month, I have been building all my new apps in a fully decoupled fashion. I build my backend using Django which acts like a RESTful API server and I build my frontend using AngularJS which consumes that RESTful API. The biggest hurdle I faced while learning how to build this was how to tackle authentication.

When you build a RESTful service, it is recommended that you avoid using session cookies. It is easier to deal with API keys or tokens on clients than it is to deal with cookies. Anyone who has built an Android or an iOS app should agree with this. Moving away from sessions can be a little complicated for someone who has never built anything without sessions before. This post helps with that and talks about how to use tokens in replacement of sessions cookies to authenticate users and preserve state.

Disclaimer: This post uses a bare-bones and very basic setup that

Continue reading →

A python developer’s guide to hacking on an airplane

After spending 18 hours on planes and airport lounges commuting between Singapore and MEST in Accra, I grew extremely frustrated by the fact that I could not create virtualenvs and install packages in them using pip without internet access.

The first thing I thought of was to configure pip to create a local cache. This was very simple to do. To configure pip to use a cache, either add

export PIP_DOWNLOAD_CACHE=$HOME/Library/Caches/pip-downloads

to your .bash_profile or .bashrc OR create, if it doesn’t already exists, a pip.conf file in your ~/.pip directory and add:

download_cache = ~/Library/Caches/pip-downloads

This is pretty cool and caches all the packages you download so that you do not have to wait for 2 minutes each time you run pip install django-toolbelt. However, it is still not network independent.

pip still checks with the PyPI servers to see if the cached

Continue reading →