Author: nigelb

  • Weird IE8 error. Nginx to the rescue!

    As a server side developer, I don’t run into IE-specific errors very often. Last month, I ran into a very specific error, which is spectacular by itself. IE8 does not like downloads with cache control headers. The client has plenty of IE8 users and preferred we serve over HTTP for IE8 so that the site worked for sure.

    Nginx has a very handy module called ngx_http_browser_module to help! All that I needed to do was less than 10 lines of Nginx config.

    location / {     # every browser is to be considered modern     modern_browser unlisted;     # these particular browsers are ancient     ancient_browser "MSIE 6.0" "MSIE 7.0" "MSIE 8.0";     # redirect to HTTP if ancient     if ($ancient_browser) {         return 301 http://$server_name$request_uri;     }     # handle requests that are not redirected     proxy_pass http://127.0.0.1:8080;     proxy_set_header X-Forwarded-For $remote_addr;     proxy_set_header Host $host;     proxy_set_header X-Forwarded-Proto $scheme; } 
    It's Magic GIF

    Yet another day I’m surprised by Nginx 🙂

  • It’s been 2 years!

    I can’t believe it’s been 2 years since I started working for Open Knowledge. I vaguely remember my first day on Oct 2, 2012. The strongest memory of the day is that it was a public holiday in India and my first day at work. I’ve looked through the commit history to figure out what I did that day. It seems I was setting up PyBossa and I fixed a bug in it on my first day! The project looks gorgeous these days thanks to Daniel’s amazing work!

    Team Picture in January 2014

    In the last two years, I’ve written lots of code; traveled to UK, Kenya, Tanzania, and Germany; managed servers and documentation for the systems team; and finally moved into a new role where I’m Senior Systems Administrator and Developer at the same time. It’s been a fabulous 2 years and I’m proud to work with my fantastic colleagues.

    Looking forward to more fun!

  • Goodbye Bangalore

    It’s done. On September 13th, I said good bye to Bangalore after about 7.5 years of calling it my home. It’s the city where I’ve lived the longest in one stretch. I’ll miss home.

    Bangalore airport

    Hello Delhi! I hope I don’t burn from your heat.

    Image Credit: Henry Lawford on Flickr. CC-BY.

  • The long run – Delhi

    The idea was born out of a picture from Reddit that I tweeted during the week. On Sunday morning, I found myself wearing my running gear, all set for a 13K run with Souvik, Bhavya, and Sumit . I’ve been doing the C25K since early this year and still haven’t finished it for various reasons. I’ve done two 5K races in Bangalore since then and this was my first really long run.

    I stepped out of the house at 0545 and headed towards the Hauz Khaz metro station. The plan was to start from there head to Central Secretariat, towards India gate, and then towards Lodi Gardens. I did a warm walk + run to the metro station and we started the “official” run from there (Part 1 and Part 2). I finished a 10K when we reached Central Secretariat because I started my warm up earlier. I didn’t run the whole way, clearly don’t have enough stamina for that, but hell, I got there. Alive. After a few minutes of rest while we waited for Bhavya to catch up, we went on Rajpath towards India gate, turned off, went towards Lodi garden, and ended the run at India Habitat Centre.

    Along the route

    The run on Rajpath towards India Gate was hell because of the sun. I ran about as fast as I could to get out of the direct sunlight. I had to stop running a little after that because my feet hurt too much. Eventually, when I reached American Diner, I’d finished 15K, a personal best. We spent a few hours at American Diner eating breakfast and re-hydrating and headed home elated.

    This run has given me a huge motivation boost. Running isn’t easy and every step of the way, you have to talk yourself into not giving up. My goal this year was to set a habit of running, I haven’t achieved a habit yet, but I’m finding running enjoyable rather than a chore and that is a victory.

  • Deploying automatically with webhooks

    Recently, we had a project deliverable to setup a repository that would auto-deploy to the staging server. I spent a bit of time getting this right, so I figured it’d be useful for someone else who had to do this.

    Code

    I wrote cloaked-spice, a tiny Flask app to do the job here. Flask documentation has a pretty neat example for doing request checksums. I’ve just modified it to work with HMAC and SHA1. It sounds simple, but thanks to silly mistakes, it took a few days to get it working 🙂

    Server Setup

    The Flask app is extremely limited in what it can do on the server. It is run as a user called deploy and a group called deploy. All the files that the app can update are owned by the group deploy and editable by the group. Thanks to sudo’s flexibility, it can only run one sudo command. Here’s the line in sudoers file:

    deploy ALL=(ALL) NOPASSWD: /usr/bin/service apache2 * 

    Serving cloaked-spice

    I’m using gunicorn and Nginx to serve the app and supervisor to manage the gunicorn process. I’m sure other wsgi servers would be up-to the job just as easily.

    Credits to Github for suggesting a name for this that sounds less boring that deploy.