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.

Recollection of Harmony

There was a time when Metallica was cool. Everyone and their dad flashed the heavy metal salute while listening to _the_ band of the time. Then things changed, Metallica went after Napster, they went after their fans, some people who celebrated them. Things changed quickly, Metallica is now Public Enemy No. 1. But sometimes I look through my cassette tapes, go over Motorhead, Styx, Soul Asylum, Uriah Heep, and wait with anticipation as the tape hiss segues into Metallica. I know how it’s going to start, years of listening to these cassettes has my mind primed for the next note that comes through.

Listening to those tapes brings with it all the memories of a time when we were all younger: you can almost feel all the teenage angst, all the anger and pain, the childishness and the stupidity. Often you can remember happy times, and the people you knew, and who knew you. Nostalgia comes in waves, not in drops. I’m sure everyone strongly associates music with memories.

Take this rendition of Nothing Else Matters. Tell me it doesn’t remind you of anything.

PS: An RSS aggregator is a nice thing to have. Also, I can’t stop listening to the last thirty seconds of Around the World

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.

Veni, vidi, reveni

I am back, bad Latin translations and all, to the city where I was born. Bombay is one hell of a city, count me impressed. Madras is an okay place, an overgrown town perhaps, but there’s nothing like having everything just the way you want: from cabs that you can register by email to drinks with your dinner just about anywhere. In Bombay, things get done…except if you’re Vodafone. I’ve had them for a month and a half now and I don’t think I’ve ever spoken to a human customer care rep. and they don’t honour their own DND lists.

There’s nothing like taking a train into the south end of the city and being faced by tranquility along long sidewalks, overhung by trees. I got my tickets to concerts sent to me by SMS, my wine delivered to my door, my local train pass in 40 seconds. I’ve walked by crazed BJP activists, stared in apprehension at TV sets on my bus fizzing with police warnings while the MNS‘s riots were stopped short by the police, and anxiously stood silent as a truck loaded with Hindutva nutcases waving flags careens around the corner in front of me. Excitement and wonder are cheap. I’ve lost myself on paved streets, wandered into cricket matches and bazaars alike, and stood on the edge of a mosque’s sea-wall staring into the sea. It was bright where I was, the people had changed.

Things happen in Bombay. You open the papers to find someone or the other shot, to find someone caught for shooting someone else, or the best of all, to find that the cop who shot all those people was a mob hitman, extortionist, and land-grabber. Posters called for alertness, plainclothesmen played terrorists to catch sleeping guards. Getting to work is an adventure, the lines ferry as many people as there are in all of Chennai. Everything is faster, bigger, more complex. Everything was nicer.

I was happy.

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

Answer these questions

Chitra is the reason for this. Blame her. Also, yes, I am aware that non-committal answers are completely useless.

1. If your lover betrayed you, what will your reaction be?
Karma’s a bitch, but in the meantime, there’s my impotent rage to deal with.

2. If you can have a dream come true, what would it be?
Realistically, to have a nice small family, a job that pays enough and gives me enough time for me to take two weeks off at least each year to visit a foreign country. Not so realistically, I want to be Bov Ine – the fire-breathing god of doom who rides a cow whose hooves strike lightning and whose horns are a portal to Discworld.

3. Whose butt would you like to kick?
Guns, I believe in peace.

4. What would you do with a billion dollars?
Buy a stake in AIG (ha ha).

5. Will you fall in love with your best friend?
I don’t swing that way.

6. Which is more blessed: loving someone or being loved by someone?
Can’t I have both? I don’t know otherwise. Think hard, and you probably won’t either.

7. How long do you intend to wait for someone you love?
If they love me…forever. If not, not at all.

8. If the person you secretly like is attached, what will you do?
Depends on what they’re attached to. I generally stay clear of people attached to cows, for instance.

9. If you could root for one social cause, what would it be?
Universal education. This is very important. Secondly, the mandatory death sentence for harassment.

10. What takes you down the fastest?
Ha ha! Like I’d tell you my only weakness!

11. Where do you see yourself in 10 years time?
Exactly? In bed.

12. What’s your fear?

13. What kind of person do you think the person who tagged you is?
A very cunning character.

14. Would you rather be single and rich or married and poor?
Once I would have chosen the latter, but it makes little sense, so I’d choose the former.

15. What’s the first thing you do wen you wake up?
Hit the snooze button. Yes yes, I know everyone was thinking the same thing, and then we all go back to sleep. And you won’t believe it, it was just five minutes but when we woke up it was 3 hours.

16. If you fall in love with two people simultaneously who will you pick?
Henry Hill (the guy from Goodfellas) said it best, “If you can’t love two people at once, there’s something wrong with you”. No, not really.

17. Would you give all in a relationship?
I try. I would love to.

18. Would you forgive and forget someone no matter how horrible a thing he has done?
No, I’m the exact other end of the spectrum. I nurse grudges on tiny matters. I still don’t forgive Bikram for spilling lime juice on my sandals two and a half years ago.

19. Do you prefer being single or in a relationship?
The latter, but it does give you a little freedom to not be.

20. List of 6 people to tag:
Marc – Because he won’t do anything about it.
Isha – Because she’ll laugh at me and call me … a very bad name.
Volunteers please – I don’t get that many comments, you see.

When I was a kid I decided to write a chain letter, it didn’t get very long. But I sent it anyway, and I cheated, I used carbon paper. So take that, suckers. I was a young spammer. Sadly, now that’s all coming back to me.