Category Archives: Programming

OpenCV + Python 2.6 (on OS X)

So, I was trying to get OpenCV and NumPy to work together on my Mac (10.6). Problem was, NumPy wanted to live on Python 2.6, and OpenCV wanted to live on Python 2.7. Much misery was had. Solution I found (finally!) was: Install NumPy. (I can’t quite remember how to do this. Just do what [...]

solving the “Rubin problem”

In “GOTO Considered Harmful” Considered Harmful (a response to Dijkstra’s famous letter), Frank Rubin gives an example of a very simple problem which he claims is best solved with the judicious use of a GOTO statement (*gasp*): Let X be an N×N matrix of integers. Write a program that will print the number of the [...]

epiphany of the day

A tree is just a graph of a stack over time. Completely unrelatedly, here‘s Joel on Software on ‘People who are Smart but don’t Get Things Done’: These kind of people can be identified because they love to point out the theoretical similarity between two widely divergent concepts. For example, they will say, “Spreadsheets are [...]

a quine in Python

import re q=’"’ s=’\\’ nl=’\n’ x="import re\"+nl+\"q=’\"+q+\"’\"+nl+\"s=’\"+s+s+\"’\"+nl+\"nl=’\"+s+\"n’\"+nl+\"x=\"+q+re.sub(‘\"’,s+’\"’,x)+q+nl+\"print \"+q+x" print "import re"+nl+"q=’"+q+"’"+nl+"s=’"+s+s+"’"+nl+"nl=’"+s+"n’"+nl+"x="+q+re.sub(‘"’,s+’"’,x)+q+nl+"print "+q+x Hey, I didn’t say it was pretty. Note how the syntax highlighter completely throws in the towel by line 3. :(