Download large file in chunks with Python using urllib2 to a temporary directory


No Comments

List directories by date using PHP


I struggled for an elegant way to list directories and files by date with PHP.  Here is the fruit of much Google-Fu.  This will list directories and files from newest to oldest.

1 Comment

Install Python Imaging Library (PIL) on OS X 10.6 (Snow Leopard)


I look a bit painful to do this at first, but here is a very simple solution.

  1. Install brew
  2. run ‘brew instal PIL’
  3. Brew install PIL at /usr/local/Cellar/pil/1.1.7/lib/python2.6/site-packages
  4. Symlink the PIL site-packages to your Python site-packages in /Library/Python/2.6/site-packages

    ln -s /usr/local/Cellar/pil/1.1.7/lib/python2.6/site-packages/PIL /Library/Python/2.6/site-packages/PIL


Install node.js and npm from source on OS X


You will need git, and all the xcode goodies. This is the easiest way to copy and paste your way to a working node.js and npm setup with OS X 10.6. Live on the bleeding edge!

No Comments

Create a thumbnail or resize an image with Imagemagick in PHP


This is the most elegant way I could find to create an thumbnail for an image I want to resize with PHP and Imagemagick. The function will return a filename.

To install imagemagick using Ubuntu, just run

sudo aptitude install php5-imagick

No Comments

Serve .json as content type application/json with Apache on Ubuntu


If you are using Ubuntu 10.04 or Debian and you serve .json files through Apache, you might want to serve the files with the correct content type. I am doing this primarily because I want to use the Firefox extension JSONView

The Apache module mod_mine will help to do this easily. However, with Ubuntu you need to edit the file /etc/mime.types and add the line

application/json json

Then restart Apache

sudo /etc/init.d/apache2 restart


How to set a default font (AKA guifont) in your .gvimrc


From : How to set default macvim or gvim font size

A tip on editing your .gvimrc options file, for gvim or macvim… if you want to set a guifont, but the name contains spaces, you’ll need to escape the spaces to get the font to work.

For example, normally (at least on macvim), if you wanted to use, say, Monaco size 12 as a GUI font, you would add a line to your gvimrc saying

set guifont=Monaco:h12

(Naturally, you could also :set this from within vim.)

If you wanted to use Bitstream Vera Sans Mono instead, you would escape the spaces with a backslash, thusly:

set guifont=Bitstream\ Vera\ Sans\ Mono:h12

1 Comment

The Singularity Summit 2010


—not ready for others to read, but making public anyway —

A collection of the faithful gathered in one large room. Among the believers were those seeking healing. They did not reach out the touch the robe of Kurtzweil, not only because he only appeared over the net, but they instead sought the empowerment provided by the most far out boundaries of what is know.

The good news is that frontiers are being forged, primarily the brain sciences. The search for AI seemed to have morphed into a quest to reverse engineer the brain. To learn from Biology. However, the quest seeks to enhance what biology has to offer.

No advances in AI, or even close to it seem to have been presented. Only a uniformed concession that the old way of thinking as is a dead end.

No Comments

massif-visualizer Ubuntu Install Notes


Here are the partial instructions for Ubuntu 10.04 with branch 8f84a30 from July 29, 2010

Get the depends:
#sudo aptitude install kdelibs
#sudo aptitude install cmake
#sudo aptitude install kdelibs4-dev
#sudo aptitude install kdebase
#sudo apt-get install libphonon-dev build-essential
#sudo aptitude install kde-devel

get kgraphviewer:

#sudo aptitude install graphviz-dev graphviz
#sudo aptitude install kdepimlibs5-dev
#sudo aptitude install boost-build libboost-all-dev

#mkdir kgraphviewer
#cd kgraphviewer/

#svn co svn:// .

Then follow their README and install

Then Get git:
#sudo aptitude install git-core

get the Massif-Visualizer from

#git clone git://

Then you can follow the massif-visualizer readme

See images at :


Simple Graphical Python Profiling with RunSnakeRun


sudo aptitude install python-wxtools

sudo easy_install runsnakerun

sudo aptitude install python-profiler

(If you are using Debian check this out :

run with:

python -m cProfile -o barbazzr.profile

Check out the output with:
runsnake name.profilepython -m cProfile -o barbazzr.profile

No Comments