Monthly Archive for December, 2008

A short week at Microsoft Research

Due to a logic-baffling stroke of luck and having met some awesome people a few months ago, I was given the opportunity to work with Microsoft Research for a little more than a week. Don’t get this confused with regular Microsoft development centers, these guys work on technology that you won’t even hear about for five years.

I have a clinical phobia of equations and theory in general. I have a fair amount of knowledge on development but absolute zero when it comes to computer science, leading me to feel very apprehensive about working there.

But the people I worked with were absolutely incredible, and were some of the nicest people I’d ever met, and made me feel that there is a place and role for me in their ecosystem. Rest assured I spent a productive few days listening, throwing an idea in when it seemed fit, and generally having a whale of a time.

While I can’t talk about what exactly I did there (partially because of the NDA but mostly because it’s not really that interesting), I can assure you that the final incarnation of the tool will be quite useful for everyone.

If programming languages were metal bands

I’ve been seeing a lot of these “If programming languages were .” (If you realized that was  a regular expression, this post is for you.)

This list is among the stuff I usually listen to and have tried my hand at.

C – Black Sabbath.
Rough, unpolished and what most people consider too old for this day and age. Yet some people worship Sabbath and claim they’re the greatest thing in existance.

C++ – Dream Theater
A little complex when you start out with it, doesen’t make perfect sense unless you understand it. You consider it brilliance if you do.

Java – Metallica
Was a great concept once upon a time. Now everyone seems to hate it, though people still cling to it, who are rather disliked by others in the programming world.

C# – Megadeth
Competes with Java, though you can’t deny some things about it are very impressive. Also, the frontman/controlling company is considered a real prick.

Python – Iron Maiden
Everybody who tries it falls in love the first time. You’ll never meet a single chap who’s tried python/Iron Maiden and not liked it. You don’t understand why they do some of the things in the latest releases though.

Perl – Dragonforce
You have no idea what’s going on and is incredibly complicated. If you don’t pay attention to it, it sounds kindof nice.

PHP – Opeth
Pretty inconsistent, a little confusing, though fun to try once in a while. *way
too overrated.

LOLCODE – Spinal Tap
‘Nuff said.

Ruby – Nine Inch Nails
Everyone keeps talking about it, but you can’t really make out what the fuss all about.

Haskell – Dethklok
Brutally fast and extremely popular with specific people, with almost cult status. Any haskell/dethklok fans will bond almost instantly.

Visual Basic – Linkin Park
Only 14 year olds think that’s a programming language/metal band.

Wow! They actually won.

It’s been two week since the attack on Mumbai, and all but one terrorists were killed, but I’m starting to feel that they actually won.

As far as I’ve heard, malls and grand restaurants, the kind where the attacks took place, are now almost empty and are forced to drop their prices and ruin their profit margins. I even got a couple of messages on my phone from people who haven’t spoken to me for years saying

“Do not go to malls or theaters in december due to terrorist threat. This is from reliable sources from the military and intelligence”.

I could recognize this as a hoax as any dickhead can send a message and the sheeple(hi reddit) would be scared nutless.

The trouble with predicting these kind of attacks is that you can’t. These are more or less random and useless to predict, and it certainly won’t be repeated again. Nevertheless, the Indian public is now in uproar, with the usual bullshit statements like we must take action, politicians are at fault, etc, etc.

People fail to see that the issue was largely due to poor and late response. If such a threat was in the US or Europe, fully armed response would be there within a few minutes. The crisis took several hours to resolve in Mumbai, and their guns locked up and weren’t powerful enough.

Good domestic intelligence, and fast response is, in my opinion, the best we can do.

Whenever I go through security checks at the airport (and nowadays even at temples), I make it a point to ask how many people have been caught trying to sneak in with weapons, the answer to which is always none. Political policies, cooperation from religious heads, and a stricter United Nations would do more good than a good frisking ever will.

But now nobody trusts anyone else. Everybody are always a little concerned to step outside, and fear reigns supreme.

A week with nbpython

I’ve spent the past week writing a considerable amount of python code. While I started out with Vim, I decide to give Netbeans’ new python plugin a try.

After spending a week and writing about six hundred lines over three modules, I can say that the IDE is very promising, though it has a few quirks.

Firstly, the netbeans IDE has been around for ten years. It was originally made by Sun for java development, and was designed to be a good personal IDE rather than exceptionally enterprise.

Pros:
Good source code completions and tools. Very tight integration with python and pylint. Finds bugs beforehand and common syntax errors. Integration with python documentation and docstrings. Excellent support for source control including hg, svn, git and perforce.

Cons:
The biggest bug is that it has issues with relative python file paths.
I use a directory structure src/util, with a module “nethelper” in util. If I want to use another module, “dbhelper” in the same directory, python expects me to use “import dbhelper”, while netbeans stubbornly refuse to do the code completion unless I use “import src.util.dbhelper”, which quite frankly is wrong and gives an error.

Apart from that, the font rendering looks like bat guano. The default font looked really bad and after tweaking ~/.fonts.conf and replacing the monospace fonts, it looks more bearable. Also, it doesen’t work on the Awesome Window Manager

Screenshot:

Knight's Tour

Some bloke on slashdot linked to his solution to the knight’s tour problem.

I had a different approach with dynamic programming and a seemingly simpler solution. I used python tuples for coordinates, and the magical “in” keyword (if target in visited: continue :)

Knight's tour

def get_legal_moves(coord): # Legal move means that the knight won't leave the board. # Doesen't take visited into consideration to save memory x, y = coord legal_moves = [] for delx, dely in ((-2,1),(-1,2),(1,2),(2,1),(2,-1),(1,-2),(-1,-2),(-2,-1)): if (x + delx < 0 or x + delx > 7) or (y + dely < 0 or y + dely > 7): continue legal_moves.append((x+delx,y+dely)) return legal_moves

def solve_tour(start, visited): legal_moves = get_legal_moves(start) visited.append(start) if(len(visited) == 64): print "Finished" print visited for move in legal_moves: if move not in visited: solve_tour(move,visited)

for x in xrange(0,7): for y in xrange(0,7): solve_tour((x,y),[])

This gives almost 15 solutions and is more or less brute force, so I don’t see how it’s worse off than the fancy solution which the slashdotted article proposes. And does it in 22 lines, compared to the 60 on the slashdot article.

either that or i’m doing something really wrong here.