Skip to main content


Showing posts from 2010

Cleaning a fancy, metal candle holder

Candle wax softens and melts below the boiling point of waterHeat up water in a kettle, heat a cup of water in a cup, or if your kitchen water is properly hot, use the kitchen faucetUsing gloves to manipulate the holder flush the holder with boiling waterUse a spoon (preferably plastic) to scrape away the softening waxRun the faucet into hard to get at nooks and cranniesThis will do less damage to the holder than scraping it with a hard object like a knife or scissor


"Eddie is a programmers editor for MacOSX and Gnome Linux. Inspired by the Macintosh Programmers Workshop, Eddie brings some of it's powerful features into a modern lightweight and capable programmer's editor. Eddie is ideal for C/C++ development using makefiles and shell tools but can also be used with XCode projects. The Worksheet in Eddie is a full-featured shell that combines the power of bash and the ease of editing in a normal text window-like mode. Eddie is equally capable at editing HTML, JavaScript, Python, Ruby, Lua and many other languages.
Originally written for BeOS, it is currently actively developed for MacOSX and Gnome Linux."


Split screen in word

Strange crash with pyglet, wxwindows and multiprocessing

The following code will crash. Commenting out the wx import (note that wx is never used) will work as expected.
import multiprocessing as mp import wx def run(): import pyglet w = pyglet.window.Window(resizable=True) while not w.has_exit: w.dispatch_events() w.close() p = mp.Process(target=run) p.start() p.join()

This may be related to the shadow window bug, but setting shadow window to False does not help.

Svn revision numbers

From here:

"Subversion's revision numbers apply to entire trees, not individual files. Each revision number selects an entire tree, a particular state of the repository after some committed change. Another way to think about it is that revision N represents the state of the repository filesystem after the Nth commit. When a Subversion user talks about “revision 5 of foo.c”, they really mean “foo.c as it appears in revision 5.” Notice that in general, revisions N and M of a file do not necessarily differ!"

Reverting code checked into svn

Problem: Someone has checked in code into svn that needs to be reverted back to an older version


svn revert * #To remove all local edits to your working directory
svn merge -r HEAD:XX svn://path/to/repository/trunk/modulename #add the clean revision's code to your working directory as changes. XX is the clean revision.
svn -ci -m"Reverted back to XX" #commit all the 'changes' to the repo

Installing HDF5

HDF5 is a data file format specification with some opensource libraries. Matlab version 7.3 and above are supposed to store data in this format. You can load these files into Python using the h5py library.

Due to an incompatibility with HDF5 1.8.5 h5py tests (and operation) will fail. Using 1.8.4 or earlier should resolve the issue. (issue 124)When installing h5py  change to super user account (su) rather than sudo because you need some environment variables to be set during the installation Install HDF5 on your machine

Following instructions from

grab the bz2 file hdf5-1.8.4-patch1.tar.bz2 tar -xvf hdf5-1.8.4-patch1cd hdf5-1.8.4-patch1./configure --prefix=/usr/local/hdf5makemake checksudo make installmake check-install Install h5py

suexport HDF5_DIR=/usr/local/hdf5/export HDF5_API=18easy_install h5py How t…

Mac Word: Save As Screen Too Big

Problem: The "save as" dialog box is too big for your screen and some of the options (such as new folder) and the resize corner are off screen, making things very, very, annoying.

Solution: Hit the 'shrink' button (up arrow) to see the abbreviated version of the "save as" menu. Then press that button again (now the 'expand' button). The dialog box now will fit the screen and you drag the corner to resize the dialog to a sensible size, which it will store.

From here.

Mass Effect: volume issues

Problem: The ambient sounds in Mass Effect are very loud compared to the dialog, even when set to low values
Solution: Switch to "software sound" from "hardware sound". Now the volume sliders work and you can adjust the different sound components as you desire.

Time Machine over a network

Open a terminal window and type
defaults write TMShowUnsupportedNetworkVolumes 1Mount the relevant volume using FinderThe backup volume will now show up on Time Machine and can be used for a backup.

Verizon is blocking port 25 - check your email clients

Verizon is blocking outgoing port 25 (often used as default for smpt outgoing email).

This will manifest as a strange problem of Thunderbird or other email client being unable to send messages but receiving them just fine when you are at home, and showing no symptoms when you are at work (if they don't have Verizon at work).

To rectify this simply change the port on the outgoing server to 587.

Of course, what happens when spammers start to use port 587?

Further reading here.

Rules of amateur (i.e. for pleasure) photography

Find an interesting subject - and the lens and the camera and the grain and the noise just don't matter, is the photo fun to look at? The only thing that can get annoying is bad focus and camera shake.All subjects are interesting - when looked at in your unique way. Find what you like and bring that into all the photos. It will take all your life and will change as you change, which is why art is such a good hobby.You can always crop more - people have fleeting expressions, you need to shoot NOW. Don't worry about exact framing, just make sure you get all you want in the frame, crop out the bad parts later.Someone somewhere has taken a better photograph of that - just look through flickr. Concentrate on having fun. And make sure you experiment and come up with your own way of looking at things.

Sometimes the tax-man giveth: Schedule M

We have a good relationship with the IRS. We overpay them over the year and they give back the interest free loan to us in May (calling it a 'refund'). Usually there is no correspondence, especially since the electronic stuff. The last time I got a letter from the IRS it was to tell me I had screwed up and we were owed a smaller refund. So, natch, when I saw this next letter from the IRS I started to grumble about socialism and how all this medical reform was going to reform our bank accounts, and why should we pay those fat cats in Washington. I opened it up and - they want to give us MORE money. Apparently we are eligible for a 'making work pay' credit that I missed! It almost quadrupled our refund! So folks, for all those skin-flints like me who do their own taxes, don't forget schedule M - if you earn less than $150000 (jointly) - which means most of us dorky lower middle class postdocs - you could get $800 back!

Polling loops vs blocking calls to Queue

This short code demonstrates how blocking calls to a Queue, while consuming less CPU, are limited in their response time by the minimum time slice the OS is willing to allocate (typically 10ms for Mac OS X and Linux). Non-blocking calls to Pipe, using poll() to check if there is data, on the other hand, give us millisecond or less response times, though they consume more CPU. In this respect doing a blocking call to a CPU is no different than adding sleep(.01) statements to a polling loop. In a way, if you execute a sleep(.01) only when you have no events in your poll you will be more efficient than if you had a blocking call pull events off your Queue one by one - because each call to Queue.get() consumes a time-slice, whereas the sleep(.01) only occurs once.

The 10ms OS pre-emption interval and sleep()

Linux and Mac OS X have a 10ms preemption (scheduling) interval. This means that the python time.sleep command (often introduced in a polling loop to prevent the thread hogging the CPU) has a floor at 10ms i.e time.sleep(1), time.sleep(.5) and time.sleep(.01) will all work as expected, giving 1s, 500ms and 10ms delays. But time.sleep(.001) will give us a 10ms delay, not a 1ms delay.

There is a hack for linux systems using nanosleep, but the cleanest thing to do is to use Queues from the multiprocessing module, instead of polling loops. You can also use select, but that gets more messy.

Prevent polling loops from hogging CPU

A python polling loop (that continuously runs in order to check for events to happen, often in other threads) can hog the CPU (100% CPU). To prevent this and allow other processes to share the CPU put in a time.sleep(x) command, where x is a small number say 0.1 ms. This is sufficient to prevent the thread/loop from grabbing 100% CPU and setting off all your fans and heating up your cores.

Note that this is a bad way to do things in general, not least because sleep has a 10ms floor.

Deus Ex: Invisible War Crashing: Fix

Symptom: Deus Ex:Invisible War (DEIW) runs fine initially but then becomes 'sped-up'. When you move your character the movement is extremely fast. Other characters move extremely fast. Menu items flash fast, tooltips appear and disappear to quickly. In short it looks like time has sped up. Eventually IW will crash.

Solution (from a tip here): Go to the AMD website and search for "Dual-core optimizer". Install this software.

For other platforms look at the three other suggestions on the linked page.

Endnote X bug for years 2010 and later

No you aren't crazy. Endnote does really screwup when the citation date is 2010 or later. There is a fix here.

Among the new "features" added in this "enhancement" is:
Can import records properly from a wider range of years than ever before, including 2010 and later

Someone overdid it in marketing school.

Vista anti-malware

A computer got infected with this. It pretends that your computer is infected with x amount of spyware/malware and you have to get the registered version to remove the (fake) malware. From the page here the steps to getting rid of this annoyance are:

Type Ctrl/Shift/Escape to bring up the task manager (or right click on the task bar).Kill the ave.exe process. The popups will disappear. Leave the task scheduler up.[NOTE: you can use procexp too]Type Windows/R (to get the Run box) and type regedit and OK. Ave.exe will start again, just do step #2 again.
[Note: Be careful with regedit. If you are not familiar with it, use other solutions for this infection]In Regedit, go to HKCR\.exe\shell\open\command. You will see something like this for (default):
"C:\Documents and Settings\[your account]\Local Settings\Application Data\ave.exe" /START "%1" %*Modify the value to be:
"%1" %*Do the same with HKCR\secfile\shell\open\command.Delete ave.exe from the locatio…

Playing with Spyder

Since they advertise so nicely how it works with numpy and matplotlib... not that there is anything wrong with eclipse and ipython - sometimes you need a quick way to test and idea.

Install SIP from source package (python; make; sudo make install) Download and install PyQT from reiverbank (python; make; sudo make instll)QScintilla
(In /QT4 qmake -spec macx-g++; make; sudo make install)
(In Python/ python; make; sudo make install)Download Spyder source package and install.

April fools

I'm hardened to April Fool's foolishness. But this eclipse rebranding thing really caught me off guard. I was there to see if there was a new version of Eclipse, and I found this:

Rails drag and drop with scriptaculous

From here:

<% element_to_drag_id = "item_#{}" %> <div id=<%= element_to_drag_id %> class='mydrop'>Whatever </div> <%= draggable_element(element_to_drag_id, :revert=>true) %><% element_to_drop_id = "receiver" %> <div id=<%= element_to_drop_id %> > Whatever else </div> <%= drop_receiving_element(element_to_drop_id, # The id of the receiving element :accept => "mydrop", # The CSS class of the dropped element :with => "'dropid=' + ('_').last())", # The query string parameters :url => {:action=> 'dropped'} # The action to call )%>Controller:
Do whatever you need. The id is passed in params[:dropid]. See views/keywords/_show_key.html.erb and controllers/keyword_controller.rb for illustration of how to use it.

There is an issue with dragging and dropping across di…

Resilient electronics

Someone spilled water on my cellphone (a prepaid T-mobile phone) at night, and in the morning, I picked it up and the display was blank- just lit with the backlight but no display. The phone would switch on and off by holding down the power button (the vibrate would go off indicating on/off). The person said to let it dry and it should be OK.

I was skeptical, since it was an electronic item that had soaked in (a little) water overnight with the power on, but I took out the battery, the SIM card, shook the water out and left it on the table. After an hour or two I came back, replaced the battery and found that the display was back. Pleasantly surprised I put the SIM card in and found that everything was intact, except that a few of the buttons were not working.

Emboldened by this, I turned on the heater and placed the cellphone without battery or SIM card on the radiator and left it for about 4 hours. After this, all cellphone functions had returned.

Flowing text in inkscape (Poster making)

You can flow text into arbitrary shapes in inkscape. (From a hint here).

You simply create a text box, type your text into it, create a frame with some drawing tool, select both the text box and the frame (click and shift) and then go to text->flow into frame.


The omnipresent anonymous asked:
Trying to enter sentence so that text forms the number three...any ideas?
The solution:
Type '3' using the text toolConvert to path using object->pathSize as necessaryRemove fillUngroupType in actual text in new text boxSelect the text and the '3' pathFlow the text

TimeTracker - see what files Time Machine is backing up

1.9GB backup! Since yesterday? I work hard, but not that hard. I wanted to see what exactly was getting backed up. Time Machine doesn't let you do that but TimeTracker from CharlesSoft allows you to peek into your Time Machine backups and see what is getting backed up for each backup and how big it is. For instance, its annoying but my email trash is getting backed up. It would, however, take too much time to go through and find every little think that I don't want backed up but is getting backed up, so...

Mac OS X time machine: deleting backups

From here:
You can delete specific folders and files from the backups, deleting all backups if needed. Open a finder window, navigate to the folder, open time machine, click the gear icon and select 'Delet backup'. If you are in the tree view you have an option to delete all backups of the selected folder.

LaTeX equations in inkscape on Mac OS X (10.5.8)

Warning message when trying to use the Tex extension:
The fantastic lxml wrapper for libxml2 is required by and therefore this extension. Please download and install the latest version from, or install it through your package manager by a command like: sudo apt-get install python-lxmlDownload and install libxml2 and xslt for mac from here. Follow install instructions. STATIC_DEPS=true easy_install lxmlsudo easy_install lxmlLeads to next error message
Contents/Resources/extensions/ DeprecationWarning: the md5 module is deprecated; use hashlib instead
  import os, sys, tempfile, traceback, glob, re, md5, copy
Traceback (most recent call last):
  File "Contents/Resources/extensions/", line 933, in <module>
  File "/Applications/Writing/", line 207, in affect
  File "Contents/Resources/extensions/textext.p…

qmake redux

In QT 4.6 qmake's default behavior has changed. If you just run qmake it will generate an xcode project. You now need to do
qmake -spec macx-g++
To force generation of a makefile

Inkscape, Mac OS X and X11

X11 latest version (XQuartz 2.4) copies stuff as a bitmap by default. Switch that off in the preferences to copy vector graphics.

ALT key won't work, preventing us from doing super script and subscript (kerning with ALT+up or down arrow keys)

ALT key can be made to work like this or this (but I was not successful)

"An error occurred while extracting one of the Network Connect components"

I love VPN. It allows me to log into my work computers from home and annoy them by giving them large amounts of work to do while I sleep. Harvard Medical uses a solution from Juniper Networks, and the client app is called Network We I went to connect, and I'm told to update and I say OK. And then I get this error message. I can't install the new version. 40 minutes later after following up several false leads, I find a JN page by copying and pasting the exact error message. It turns out that updating Java on my mac (which I guess I did at some point) changes some default password stored deep in the guts of Java from “changeit” to “changeme”.

I gota few things to say about this. The PG rated ones are
After looking through Juniper Network's knowledge base I have to say, the guy (or guys) in charge are pretty professional and thorough.Their website could do with a little bit better navigation thoughI would have expected Sun engineers to comeup with a better mechan…

time.time() vs time.clock()

From a variety of sources, notably here, we have:

time.clock() gives the best timer accuracy on Windows, while the time.time() function gives the best accuracy on Unix/Linux.

Additionally on non 'win32' systems time.clock() will measure application CPU time, which excludes time spent waiting for I/O while time.time() will measure 'absolute' time. On win32 time.clock() also measures CPU time.

If you want to time your code and get absolute times, do what timeit does:

if sys.platform == "win32": # On Windows, the best timer is time.clock() default_timer = time.clock else: # On most other platforms, the best timer is time.time() default_timer = time.time

MS word citations file formats etc.

There is one citations file called Sources.xml, created after you add your first citation
On Mac the location is ~/Documents/Microsoft User Data (see here for windows specific info)There is a paucity of documentation on the format (so surprising, no?) but various people have put effort into understanding it:
Straight forward code on one page for a bibtex to xml conversion.
Some one's journal of reverse engineering the xml format. 
bibutils - command line tools to convert citations between various formats
BibTex -> citation converter by Joonhwan Lee (closed source, free)
In short, while MS Word has wasted time and effort reinventing the wheel (and doing so badly) at least the format is text based. Really, all we need to do is convert our PIs to using LyX and we don't have to deal with this %$#@@ any more!

iTunes : getting songs from the same album to group together

When I pulled some of my CDs to iTunes I found that sometimes songs from the same album would appear, in album view, as different albums. It was very annoying. It turns out that iTunes won't group songs with the same album name but different artist (or different album artist) into the same album in album view. The solution is to select all the songs you think should be in the same album, right click for 'info' and then under 'options' check 'part of a compilation'. Make sure that the album artist is the same or is blank.

From apple's support page.

Rubble pile asteroids

As a child I learned about asteroids and have pictured them as solid pieces of rock of different sizes. Apparently, though, there have been suggestions since the 1970s and recent empirical data that some asteroids are actually collections of smaller rocks held loosely together by mutual gravity.

I don't know what proportion of asteroids are not monolithic, whether the majority of asteroids are such piles of rubble, but this was a piece of information that startled me, because it is from a field I was very interested in as a child, and as a child I had taken the astronomical statements as fact, rather than as interpretations of incomplete data.

The statement that asteroids are not monolithic blocks of stone, but are rather collections of small rocks is more interesting to me than some stupid political discussion about whether we should call a celestial body a 'planet' or a 'dwarf planet' or a salami hamburger.

From an article in Nature, this page and wikipedia it se…

QT 4.6 : QListView will not show an updated model without focus

I moved an application I wrote and use from Qt 4.2 to Qt 4.6. I have a widget where there is a QListView associated with a QStringListModel. I type in a text box, hit enter and add text to the QStringListModel. In Qt 4.2 this would cause QListView to automatically show the updated model. In 4.6 the updated view is only shown if QListView has focus. So now I have to setFocus() on the QListView and then setFocus() on the text box to make QListView show the updated model.


And we think these computers will be taking care of us in our old age.

PS. On the plus side, 4.2 had a bug where a text edit would not accept the enter key and would pass it onto the parent widget which would cause a dialog box with a text edit to be accepted. That has been fixed.

Trolltech giveth and trolltech taketh.