Bookmarks [2012/09/18] JavaScript library for 3D graphics Easy to use Efficient Nice feature set

Talks at PyCon India 2012

PyCon is back to Bangalore for the 4th edition. I've been to all the previous three editions, and I'm looking forward to this one.

I haven't spoken at any of the previous editions, and hadn't even really considered speaking at the previous editions. But, this time, I proposed a couple of talks, and both of them have been accepted! Woot! Lots of work ahead of me, but I'm really looking forward to give good talks. I'll be talking about Enaml, and showing a brief demo of all the wonderful things it makes possible. In the other talk, I'll give a brief overview of the latest happenings in the SciPy community and the projects to look forward to and contribute to. Pankaj and I will be talking together on this.

Also, Kenneth (lawgon) will be deeply missed at this edition of PyCon.

Sadly, John Hunter, the lead author of matplotlib, also passed away last week. RIP. :(

Browsing the streets with Firefox

I bought a new bike, about a month ago, and today was the first longish ride on it. Well, longish compared to my ~1.5km rides to the office.

At 19:45, I just set out to get some fresh air. After sitting for two days, inside the house, by the evening on Sunday, I tend to get stuffy. I started riding westward and the fresh air got to my head, I ended up pedaling too far away to get back, without going to the beach. It was fun, having adrenaline pumping all over. But, there was much more traffic than I would've liked. Anyway, one shower on the way up, and one puncture on the way back (thankfully, close enough to my house), it was a fun ride on the whole.

I didn't time myself, but I roughly covered about 25 kms in say about ~2 hours. Hoping to start riding more frequently and going on longer rides.

Bookmarks [2012/08/28]

  • Stack Exchange Machine Learning Contest « Blog – Stack Exchange

    tags: machine_learning, programming

    The idea is simple: we’ve prepared a dataset with all the questions on Stack Overflow, including everything we knew about them right before they were posted, and whether they finally ended up closed or not.  You grab the data, build your brilliant classifier, run it against some leaderboard data and submit your results.  Rinse and repeat until the contest ends, when we’ll grab the most promising classifiers and run them against fresh data to choose winners.

  • First employee or co-founder? - Jacques Mattheij

    tags: job, startup, advice

    think twice before you join a company as a first (or very early) employee, and if you do decide to join negotiate for as large a chunk of stock as you think your position/commitment/drop in pay justifies and be prepared to walk if that is not possible.

A git-diff tip

One of the things with git that you can mess-up, if you are not used to, is git diff. A friend of mine was trying to add a couple of new files, and changes to existing files. But, he was on the wrong branch, and wanted to change to a different branch, before committing. Being new to git, he wanted to take a patch. Reset the changes, apply the patch back.

This is what he did

git add new_file.txt
git add old_file1.txt old_file2.txt # don't add old_file3.txt

Oh, damn, I want to change the branch.

git diff > a.patch
git reset --hard
git checkout other-branch

Let me commit my changes…

git apply a.patch
git commit -m
git show

Oh crap! Where are my new files? They aren't commited! Lemme add them.

ls new_file.txt
ls: cannot access new_file.txt: No such file or directory

Dammit! Where are my changes gone?

The problem was with git diff. It gives only the only the un-staged changes. --cached option has to specified, to get the staged changes in the diff output. git diff HEAD shows diff output with both staged and un-staged changes.

But the whole workflow above is a beginners workflow. A user comfortable with git would've committed and then moved the commit around using cherry-pick or the like.

git add <all-files>
git commit -m "My awesome changes."  #committed on branch1
git checkout other-branch
git cherry-pick branch1

An import gotcha in Python

Pankaj and I were stuck with this weird bug recently. We had a class A and a subclass B and an instance of B, b, was returning False for isinstance(b, A).

After some debugging, we found that it was a problem with imports, and the same module was being imported twice, using two different names – bar and

Here's a cooked-up example to demonstrate the "bug". We create a package baz, as shown below.

$ tree baz

We have our two classes, A and B defined in the bar module.

class A(object):

class B(A):

We run and scratch our heads for a while, before figuring out what's wrong…

# We add the directory containing out package 'baz' to sys.path to be
# able to import using the package name.
import sys
sys.path.insert(1, '/tmp')

# We import A from bar module present in the same directory as foo
from bar import A
# We import B from bar, but refer to it, as a submodule of baz
from import B

a = A()
b = B()

print "isinstance(b, A) -->", isinstance(b, A)

for cls in (A, B):
    print "%s -->" %cls, cls

for module in sys.modules:
    if 'bar' in module:
	print module, sys.modules[module]
isinstance(b, A) --> False
<class 'bar.A'> --> <class 'bar.A'>
<class ''> --> <class ''> <module '' from '/tmp/baz/bar.pyc'>
bar <module 'bar' from 'bar.pyc'>

Bookmarks [2012/07/15]

  • Jerry Seinfeld's Productivity Secret

    tags: life, productivity, advice

    He said for each day that I do my task of writing, I get to put a big red X over that day. "After a few days you'll have a chain. Just keep at it and the chain will grow longer every day. You'll like seeing that chain, especially when you get a few weeks under your belt. Your only job next is to not break the chain."

Bookmarks [2012/05/12]

  • My Doctor's Office Asked me to Lie :


    The substance of the issue probably doesn't matter much. There is no real confidentiality of medical records in the US, since the police can get them under very easy conditions. Nonetheless, it is a dishonest proceeding, systematically asking patients to accept policies they have not seen and then make false statements.