Happy Birthday, Laptop

This XPS M1330 has been modified to have an aftermarket Vostro 1210 keyboard.

This XPS M1330 has been modified to have an aftermarket Vostro 1210 keyboard. It has also lost its palm rest.

Six years ago, almost to the day, I received my Dell XPS M1330. Except for the fact that its motherboard had to be replaced 3 times (all under warranty, fortunately) because the Nvidia graphics chip had trouble with heat, this has been a fine laptop. It had almost perfect Linux compatibility from the first day I had it, though later Linux releases had regressions in the iwl4965 driver for the Wi-Fi chip. That’s been fixed recently, though, so it’s back to being pretty functional.

It wasn’t all smooth, though. For a long while, the laptop would overheat rapidly and throttle the processors resulting in very poor performance shortly after running anything intensive. I switched out the thermal paste and checked the vents and fan, but completely forgot to check the heat sink fins (which are hidden underneath the fan) for dust. These were packed, and after cleaning out the heat sink and applying the famous copper mod, everything runs really well under Linux. It still sometimes shuts off under Windows 8 if I play Civilisation, though.

The keyboard was destroyed in an unfortunate accident shortly after I first arrived in Raleigh, but replacing it also allowed me to ‘fix’ the webcam (the ribbon cable had come loose) which I’d figured was lost. I always wanted a black keyboard for this laptop, so I replaced it with one from a Vostro 1210. The only problem is that in the process of doing this, the palm rest (damaged years ago when I dropped the laptop off the side of a desk) has come free. Now the whole thing looks rather funny, what with the Wi-Fi chip and card reader PCB visible through the front. I was actually hoping to replace the optical drive with a second hard drive, but I stripped the last screw I had on the motherboard so it’s practically impossible to do that now. Pity, that would have been nice.

Still, I’d given up on this laptop some time ago so I’m really pleased to see that it’s functioning great now. Six years is a long time.

Total cost? About 65000 INR all fixes and upgrades included. Not bad.

Jenkins CI with Python and Github

This installation of Jenkins has Nosetests and Pylint with the Github and Git Plugins

This installation of Jenkins has Nosetests and Pylint with the Github and Git Plugins

NC State has a Github Enterprise installation that’s great for working on class projects, especially because it’s possible that some of your team-mates may be students studying remotely. It’s probably a good idea to use a server that will pull the latest changes from your master branches, run tests, and perform linting so that you know how well you’re progressing. Fortunately, all the tools for these are easily accessible. We used:

Installing software

  1. To start with, set up an organization in Github Enterprise for each course team we have and add your team-mates to it.

  2. Create a repository in Github Enterprise.

  3. Install Jenkins on your server.

  4. Install the Git Plugin for Jenkins. Optionally install the Github plugin as well. I didn’t use this for the CI features.

  5. Install the Violations plugin for Jenkins so we can report linting results.

  6. Create an SSH key-pair on your Jenkins server and set up the public key as a deploy key in the settings for your repository.

  7. Set up a web hook on Github Enterprise by going to the Service Hooks tab in the settings for your repository and picking the “Jenkins (Git Plugin)” option. Remember to set the URL to the base URL of your Jenkins installation.

  8. Add the deploy key to Jenkins credentials.

Jenkins Project Settings

  1. Under Source Code Management, select Git and specify the repository URL as specified on the Git Plugin page. This is currently the same URL you’d get if you selected the SSH option on the Github page for your project.

  2. Set the credentials to the key you’ll be using.

  3. In the Build Triggers section, pick the “Build when a change is pushed to Github” and “Poll SCM” options. Set the “Poll SCM” schedule to infrequent (it uses the same format as your crontab).

  4. For your build steps add the following for linting: (the echo command is to account for pylint returning non-zero unless you’re absolutely clean)

    find -iname "*.py" | xargs pylint --rcfile=.pylint -f parseable > pylint.xml || echo "pylint violations"

    and for testing, add:

    nosetests src/path/to/test/ --with-xunit
  5. Add a post-build option to “Publish JUnit Test Report” and specify **/nosetests.xml as the path.

  6. Add a post-build option to “Report Violations” and specify **/pylint.xml as the path.

  7. Add the Github Project URL if you want Github links.

Using the VCL XML-RPC interface with Python

Apache VCL is a cloud computing platform that NC State uses to provide on-demand access to specific software or environments. It’s neat because you can quickly and easily get a virtual machine to try things out with, or a cluster to experiment with networking. The remote API for VCL is provided via an XML-RPC interface. Python has a nice XML-RPC library called xmlrpclib that makes building clients comically easy.

For instance, here’s a short example, with in-line comments explaining the four lines that need any explanation:

import xmlrpclib
import getpass

# We're connecting over SSL so subclass SafeTransport
class AuthenticatedTransport(xmlrpclib.SafeTransport): 

    def __init__(self, username, password):
        self.password = password
        self.username = username

    def send_content(self, connection, request_body):
        # X- headers are user-defined in HTTP
        # These next few are used by VCL
        connection.putheader("X-User", self.username)
        connection.putheader("X-Pass", self.password)
        connection.putheader("X-APIVERSION: 2")
        # That's the end of the VCL-specific headers

        xmlrpclib.SafeTransport.send_content(self, connection, request_body)

username = raw_input("Username: ")
password = getpass.getpass("Password: ")

auth_transport = AuthenticatedTransport(username, password)
server = xmlrpclib.Server("https://vcl.ncsu.edu/scheduling/index.php?mode=xmlrpccall", transport=auth_transport)

    result = server.XMLRPCtest("foo")
except xmlrpclib.ProtocolError as e:
    print "URL: {}".format(e.url)
    print "Headers: {}".format(e.headers)
    print "Error code: {}".format(e.errcode)
    print "Error message: {}".format(e.errmsg)
except xmlrpclib.Fault as f:
    print "Fault Code: {}".format(f.faultCode)
    print "Fault: {}".format(f.faultString)
    print "Args: {}".format(f.args)
    print "Message: {}".format(f.message)
    print result

If all goes well, then you should receive a response of the form:

{'status': 'success', 'message': 'RPC call worked successfully', 'string': 'foo'}

Then you can use the API reference to construct a program that will, for instance, spin up a small cluster of instances, run a student’s code, and then grade it.

Mounting NCSU AFS locations locally on Elementary OS Luna (Ubuntu 12.04)

NC State uses AFS to store student files, course submission lockers, and the course web page. A friend of mine wrote a blog post with instructions on how to mount these locations on Windows. Using that and the MIT CSAIL page on using OpenAFS on Ubuntu, it’s possible to have the your AFS directories show up locally. I am on NCSU’s ResNet internet service, but this should work even from outside.

Installing the required software

First, add the openafs PPA for Ubuntu 12.04 and update your package cache

sudo add-apt-repository ppa:openafs/stable && sudo apt-get update

Then install the packages required

sudo apt-get install openafs-krb5 openafs-client krb5-user module-assistant openafs-modules-dkms

Answer the questions as follows:

Question Answer
AFS Cell this workstation belongs to EOS.NCSU.EDU
Size of AFS Cache in KB 512000

The first answer is then populated to /etc/openafs/ThisCell and the second to /etc/openafs/cacheinfo, in case you want to look it up.

Configuring Kerberos

By default, you won’t be asked to set up the Kerberos realm and other such things and so you’ll have to reconfigure the packages:

sudo dpkg-reconfigure krb5-config openafs-client

Here, answer:

Question Answer
Default Kerberos version 5 Realm EOS.NCSU.EDU

Installing the kernel module

Try to load the openafs kernel module:

sudo modprobe openafs

Restart the OpenAFS client:

sudo service openafs-client restart

Logging in

Authenticate against the Kerberos 5 Realm to receive a ticket-granting ticket:

kinit unityID

Confirm that you have received tickets:


Expect output like:

Ticket cache: FILE:/tmp/krb5cc_105195
Default principal: unityID@EOS.NCSU.EDU

Valid starting    Expires           Service principal
11/02/2013 17:44  11/02/2013 00:24  krbtgt/EOS.NCSU.EDU@EOS.NCSU.EDU

At this point, you should be able to access /afs/eos.ncsu.edu and look at the parts that don’t require authentication. If you want to access your EOS home folder or course submission folders or any other place that you would imagine you require authentication to access, you first have to acquire a Kerberos token by running:

aklog -c unity.ncsu.edu -k EOS.NCSU.EDU

aklog -c eos.ncsu.edu -k EOS.NCSU.EDU

And that’s pretty much it. Your home folder is /afs/unity.ncsu.edu/users/firstLetterOfUnityID/unityID.

Naturally, I didn’t want to have to login each time and I wanted to try out some Python things, so here’s a small script to do the job.


  1. If kinit complains that it “Cannot parse principal ‘username'”, then try specifying the fully-qualified username: unityID@EOS.NCSU.EDU. Remember that capital letters are significant.

  2. If you have lots of possible cells that you don’t want to connect to in /afs, try blanking out or commenting lines in /etc/openafs/CellServDB.

  3. You can set up cell aliases, so that it’s easier to navigate to cells you frequently visit. Edit /etc/openafs/CellAlias to do so. Here’s the format:

    cell alias
    eos.ncsu.edu eos
    unity.ncsu.edu unity
    bp.ncsu.edu bp

  4. If you don’t have the openafs kernel module, then you may need to build it. From the CSAIL page, this is easy using module-assistant:

    sudo m-a prepare
    sudo m-a auto-install openafs
    sudo modprobe openafs

Intelligence ∝ Wheels

Most two-wheeler motorists are poor drivers. This is something that’s easy to ascertain from the disproportionate number of deaths that involve a two-wheeler with something other than a heavy vehicle or a car. This is also the reason that whenever I hear about a young man not wearing a helmet who got killed by a car, I know who’s responsible. Not wearing a helmet is just one symptom of the typical illusion that two-wheeler motorists live in.

Driving a car badly is harder than driving a motorcycle badly, for the following reasons:

  • A car is automatically limited by the space available — meaning no swerving between other vehicles, and in between bumpers to gain 0.7 of a second.
  • When the vehicle in front of you stops, if you’re a car driver, you stop. If you’re a motorcyclist, you turn your front wheel in one direction (usually right) and try switching lanes, stopping only when a car driver frantically brakes and honks.
  • If a car ever collides with anything, it’s the drivers fault. If a two-wheeler ever collides with anything, it’s usually blamed on what the two-wheeler collides with. Except for the one situation where the two-wheeler slams right bang between the two tail-lights, splitting your licence plate in two.
  • You need to have a certain amount of money to buy a car, either through your parents or by your own work. While this does not preclude the possibility of a boorish rich driver, those are less likely to exist than the college going imbecile
  • Cars corner better than motorcycles.
  • Cars are more easily damaged by minor incidents than motorcycles — a car and a bike scrape, and the bike gets off with no damage nearly

Now, I have never claimed to be an exceptional driver myself, but I have never driven in a manner that is likely to kill myself or another. And besides, going “Tu Quoque” isn’t accepted any more. To illustrate, I have created a colourful drawing for you all to see the difference between the way a car driver takes a corner and the way a motorcyclist does so. The legend for the yellow line should be ‘lane marker’, but I forgot and I’m not going to change it because I can’t make it fit now anyway.

An illustration of the difference between the way cars and two-wheelers are driven. With intelligence on the y-axis and year (ending in 2008) on the x-axis, the upper red line, and the green dotted line also represent the average IQ of the drivers of the vehicles.

Are you a motorcyclist? To find out if you, too, are an idiot, answer these questions — if you answer yes, add those points to your score:

  • Do you have a helmet? (-3 points)
  • Have you removed your rear-view mirrors? (6 points)
  • Do you put your foot on another vehicle to be pulled along? (6 points)
  • Do you use your signal lights? (-6 points)
  • Do you take great pride in travelling 50+ km/h in rush-hour traffic? (9 points)
  • Have you been involved in motorcycle accidents with another motorcycle or in accidents where you were violating a law? (6 points)
  • Do you ever use the pavement when the roads are jammed? (6 points)
  • Is your licence invalid? (9 points)
  • Do you have insurance (-3 points)
  • You are in the left most lane. The car in the lane to your right is slowly moving forward to close the gap between it and the stationary vehicle in front of it. Do you accelerate and switch to that lane? (9 points)
  • You are in the left most lane, right behind an auto-rickshaw. Traffic is moving at a steady 30 km/h. The auto-rickshaw stops. Do you turn your front wheel to the right and try to poke into the lane to your right? (12 points) Do you stop your vehicle in the same lane and look at your mirrors before making your next move? (-6 points)
  • The light is red. There doesn’t seem to be anyone coming anywhere near the intersection in the direction that it is green for. Do you go ahead? (3 points)
  • Do you drive on the wrong side of the road, near the pavement? (6 points)
  • After overtaking a vehicle so that you’re in front of it, do you slam on the brakes? (6 points)
  • Do you frequently stop your motorcycle just before the median begins, in the right-most lane, so that when the signal changes you can squeeze past the last car before the median? (3 points)
  • Do you put on your helmet while driving? (3 points)
  • Do you follow mirror, signal, manoeuvre? (-12 points)
  • Do you brag to your friends about how you managed to squeeze between something and something else, and you could almost have died except you were so damn good a driver that it didn’t happen? (12 points)

Now if you scored more than 0, you’re an idiot. The degree of your stupidity is your score divided by 6. If you’re an Urban Boor, you are automatically an idiot of the greatest degree, because it is nearly assured that you have the highest score possible.

PS: Title applies only to vehicles owned by a person or family for the use of that person or family.

Book Meme

He had just finished, and had put the packet in his pocket, when in the court below resounded the cry:…Crime and PunishmentFyodor Dostoevsky.
I’ve been reading this book for a while now, and it is depressing. I don’t think I’m going to finish it. How did it all start? Well, one day I told myself, “I shall no longer be ignorant of English literature, I shall read The Classics”. Well here I am, with a Classic, and it’s goddamn depressing.

Saw this on the blog of Jono Bacon of Jokosher fame. Because it’s so cool, I’m going to share:

  • Grab the nearest book.
  • Open it to page 56.
  • Find the fifth sentence.
  • Post the text of the sentence in your journal along with these instructions.
  • Pick the closest book, not your favourite. C. & P. was nearly edged out by my cousin’s Engineering Mathematics. Close one.

As revenge for previous acts, and just because I want to hate on some people, I demand that everyone do this.

Ubuntu on my Dell XPS M1330 – Booted with the MediaDirect button

So when my motherboard was replaced, MediaDirect stopped starting up, so there was no Media to be had from the button, Direct or otherwise and the button itself booted Vista and then started the MediaDirect application. Thinking I had a brilliant idea, I set out to see if I could boot Ubuntu using the MediaDirect button and Vista using the Power button, only to find that hundreds of other people have done that before to.

However none of those guides worked because I simply couldn’t manage to install GRUB to the extended partition due to many many errors. Finally, I deleted MediaDirect, installed Ubuntu in a couple of logical partitions and went back to using Windows. Then today, I decided to finish the job, and with LiveCD in hand proceeded to fight the demons of distro installation under esoteric conditions. GRUB kept failing trying to find stage1 and stage2 files, and no matter how many tricks I tried, none of them worked. Until I discovered this lovely parameter to grub-install.

So with GRUB already installed on the logical partition (as part of the Ubuntu installation process), I just had to point grub-install to the right place to get all the files from:
sudo grub-install --root-directory=/media/disk-1/ /dev/sda4
and boom! I had a bootloader on the extended partition.

The best part is that I’d already installed the Dell bootloader (the one that handles the difference between MediaDirect and Power) configured to look at the third and fourth partitions and so I shut down and hit the MediaDirect button and then much happiness ensued. At least until I saw how fonts looked in Firefox :)

The command to run from the Dell MediaDirect disc is:
rmbr.exe dell 3 4
Remember to start cmd.exe with Administrator permissions (right click, Run as Administrator). The only problem is that ‘Restart’ always means ‘Restart into Windows’.

To get proper instructions on how to do this instead of this garbled mess, here are the links I found most useful:
Using the Media Direct button to boot Ubuntu
Another thread for that
The thread where I found out about --root-directory

The day the Earth didn’t stand still for me

It all started when I decided to go to Victoria Terminus, now Chatrapati Shivaji Terminus, to catch my train to Madras. I have a tendency to be paranoid about trains and missing them so I left an hour before the departure time. Granted this would only give me fifteen minutes at the station but hey, I’m a seasoned passenger. I’ve travelled on more trains than most fifth graders can count. I don’t need more than that. Well, turns out I did. And that explains just what I’m doing here at the airport, trying to get the so-called wifi to work.

The damn flight’s been delayed too. Have you ever wondered about that? Why are the things you’d rather get done fast usually the one’s delayed? I could have settled for ten minutes more in the morning. Coming back to that, this thing applies there too. A very helpful suburban local came fifteen minutes late and reluctantly bore me to the station. Too late, apparently. I listened, calmly incredulous, as the lady explained to me “1041? Wo gaya”. Not a trace of emotion on her face, not a flicker of embarrassment for having flagged off a train while its most important passenger was still biting his nails on a crippled local that was happily trundling its way through Dockyard Road.

One day, I shall find the people who did this to me. I will travel from village to town to city, the smell of guilt strong in my nostrils. I shall wander across deserts and hills…and rivers, or what passes for those here, and I will reach a city of great splendour. With the memory of this railway betrayal fresh in my mind I will roam the streets, my eyes scouring the signs for the place I want. And I’ll know it when I see it, and I’ll barge in, smashing the door down, all rage and fury. And then, just as I draw myself up, just as I scream out, “I am become revenge, destroyer of rails.” in impassioned anger I’ll realise that I’m looking at a mirror.

The wifi doesn’t work either.

The Gardener: A Dream

I had the wildest dream last night. It had a whole lot of characters, but sadly because I was doing other stuff till now, I’ve forgotten most of it. The parts I remember was this time when two kids were stuck in the rain and they decided to shelter in a garage of this big house. So while they’re in this garage, this creepy old woman opens a door from inside the house to the garage and she looks at them and says, “Come to stay here, that’s really nice.” and she closes the door. Then the younger kid opens another door wondering what’s behind it, and this woman opens her door again saying, “Oh yes, you’ll find that interesting.” and then the door slams shut behind the kid. When he opens the door again, he’s somewhere completely different, and this keeps happening with him opening doors and finding himself looking into some different place altogether. The final bit is when he opens the door and a big dog-lion thing jumps out, but he manages to dodge it once. After that, it switched to a completely different thing.

I was in the same house, and this really fat friend of mine (completely fictional) was right there next to me. And just as we started to talk, I noticed a really old withered man coming down from the hill. He had a scythe in his hand, and I recognized him as the gardener. To play with my friend, I said, “Oh shit!” and started running away from the house and along a path towards a marsh. The terrain was rolling, so if you went over the crest of the path you wouldn’t be able to see along the back again. All the while when I was running I kept yelling, “It’s the GAAAAAARRRRRDENNNNNNERRR!” and after a while this friend of mine was also running alongside me yelling that. It was like some sort of Indian warcry except that it wasn’t because I was starting to believe in this whole thing myself and getting pretty scared. The marsh is like a field, at this point of my dream and set in a rough square with a path down the center and other such grid-like stuff. The path we were running along met the field at the point where the road down the center was, but we decided to take a right and then a left to run parallel to that. At this point we met another withered old man who was driving a caravan train with nothing inside the caravans. I managed to run fast enough to catch up with the last caravan and hop on. The driver was off the train now and just yelling at whatever was pulling the caravans (couldn’t see it) and cracking his whip, and he laughed maniacally as he made the caravan turn down that center road and back up the path to the mansion. Then suddenly, the fat friend (and I mean really fat, he was huge!) came around the bend and thundered down on the caravans at an immense speed. While the old man cackled, my friend managed to lunge for the last caravan and get on. I nearly fell down trying to get out of his way as he boarded, the old man softened at this and told me to watch out. He then yelled, “The GAAAAAARRRDENNNERRR!” and I saw the gardener coming down the path headed straight for the first caravan moving at him.

I now remember the first dream, I wanted to explore this desert called the Red Desert. The sand there was like it was on the surface of Mars or something, completely red. And it wasn’t sand as much as it was loose rocks mixed with some sand. What I was looking for was this thing called the Black Hole which is in a lake somewhere in this desert. There were two lakes, one with the Black Hole and one without. By the time I found the first lake, I was really thirsty, but the liquid in the lake didn’t look like water at all. It was black or maybe a very dark shade of green. So I soldiered on towards the Black Hole Lake which I could see not too far away. When I got there I saw why it was called that, there was this giant whirlpool in the center of the lake and while the edges were a dark (almost black) shade of blue the center was absolutely black and the water was swirling around this whole all the time, but there was no more coming from anywhere, so it mustn’t have been going into the whirlpool as much as just spinning. There was no wind, just the sun and the red sand.

Just when I thought I was going to really start needing something to drink or I’d die, I saw a bunch of horsemen come up over the top of a ridge and in front of them, running as fast, was my younger brother. When I looked where he was running I saw that this whole Black Hole Lake thing had been made a tourist attraction, and people were coming here just to look at this place on organized tours. It was like a big circus town, and there was food and drink and even an Indian Bank ATM. I tried to get money from the ATM but it kept getting jammed with my card and not doing anything so I just settled for what I had. Then my brother came along with a camel and asked me to get on. I got on, and we went around the circus tent town and my brother and the camel looked under the roof of one of those tents to watch the tricks inside but I couldn’t see because I was sitting at the back, I remember I got quite angry at that. Then that faded out and the rest began.

A new city, a new home

In the interest of those awaiting the next episode in Roshan’s life, I present: Life in Bombay.

I moved to Bombay in the first week of August after fate noticed my true desire and delayed my flight a few days, at first, and then a few weeks from the original date of mid-July. Everything came intact, so I’m now a big fan of Indigo, though I recognise it’s a sad state of affairs when that’s commendable. As for the city itself, I love it. While I’d still rather be in Madras today, I love Mumbai, it’s a goddamned metropolis. Everything here moves! There’s action! Things are getting done! Or so it seems, unless everyone enjoys riding the trains up and down all day. Unlike sleepy Chennai, where even on Mount Road, life goes along at a gentle 20km/h (if you’re lucky), in Bombay people are flying from home to work to home to bar to outside home having forgotten their keys at an incredible 100km/h. The trains are fast, the people are in a hurry, and it rains all the bloody time.

It’s been three weeks and I still haven’t seen the city fully yet. As a matter of fact, I’ve seen very little. One thing I’ve noticed about Bombay is that class discrimination is very clear here. If you’re poor you live on one side of the tracks, if you aren’t you live on the other side. Allow me to demonstrate with a photograph:

Observe, my friends, a lightly loaded Harbour Line local. Notice how it demarcates the poor man's lands.

With that in mind, I am deeply grateful that I’m on this side of the rails. And the trains themselves, beautiful things, I’m told some routes average 100km/h. Now that’s transport my friends, in style. No traffic to worry about, no two-wheelers and autos switching into your lane without warning, just a nice, uncomfortable, 7-per-square-metre standing all the way ride. Sometimes I even get a seat.

I’d tell you more, but I’m bored of typing. So I’ll give you another two photographs, the views out the living room window from the 20th floor apartment where I live:

  1. The view from out front, near the hill is Bhabha Atomic Research Centre, the nuke plant is on the other side. The sea like region out there is Vashi creek.
  2. This is the same place, except darker so you can see that there are buildings on the other side. That's New Bombay. It has its own story, the government made sure there are no slums there by pushing everyone to this side of the creek. So all the workers travel to that side every day. Clever, no?
  3. This is my room. Here's a detailed description just because some people hate that: In the background is the rest of the 'Daffodil' block, that's my bed and my pillowcase. The rest is also mine. The box between the bed and the desk is my motherboard-in-a-box from Dell, and the rest of the photo is obvious. Oh yeah, that's the chair in the foreground right.