Saturday, December 11, 2010

Cleaning a fancy, metal candle holder

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

Thursday, October 14, 2010


"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."


Friday, October 1, 2010

Split screen in word

Use the splitter tool located on the right, just above the scroll bar
Drag the "splitter" down to where you want it

Wednesday, September 29, 2010

Remove horizontal line from Word

Problem: There are horizontal lines in the word document that can't be selected, only moved.
Solution: Set the cursor above the line, go to Format->Borders and Shading and then remove the border.

Thursday, September 9, 2010

Multidimensional find in pylab/numpy/matplotlib

A = pylab.random((3,3))
print A
idx = pylab.find(A < .5) #Returns an unravelled index
A.flat[idx] = .5 #allows us to use this flat index directly
print(A) #and it works just fine

Saturday, August 28, 2010

Parallel processing in a bash script - wait

Use the 'wait' command.

some command &
some other command &

command that needs the results of the previous two

Monday, August 16, 2010

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:

p = mp.Process(target=run)

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

Friday, August 6, 2010

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

Some fun with sound on Mac OS X

osascript -e “set Volume 4″ #Sets volume on machine
say -v Whisper “That was fun\!" #Uses text to speech converter

Change name of mounted volume on Mac OS X

diskutil rename /Volumes/Volume NewVolName

Some others:
Set Bonjour Name
sudo scutil –set LocalHostName NewName
Set Sharing Name
sudo scutil –set ComputerName NewName

Thursday, August 5, 2010

Latex/LyX/Beamer on Mac OS X

  1. MacTex
  2. Tex Live utility.
  3. Update/install the beamer package
  4. The beamer.layout file (referred to in the documentation) is NOT part of the beamer distribution but part of the LyX distribution. A recent LyX distribution should have it installed already
  5. You should now have a 'beamer' document class: use that and follow the beamer guide.

Tuesday, August 3, 2010

Task Coach

Task Coach : a really good, open source to-do list software that lets you make categories and sub categories and tasks and sub-tasks.  Incidentally, written in Python.

Matplotlib: change axis ticklabel properties

ax = pylab.gca()
labels = ax.get_xticklabels()
pylab.setp(labels, rotation=30, fontsize=10)

Tuesday, July 27, 2010

Monday, July 26, 2010

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.

  1. 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)
  2. 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

  1. grab the bz2 file
  3. bunzip2 hdf5-1.8.4-patch1.tar.bz2
  4. tar -xvf hdf5-1.8.4-patch1
  5. cd hdf5-1.8.4-patch1
  6. ./configure --prefix=/usr/local/hdf5
  7. make
  8. make check
  9. sudo make install
  10. make check-install
Install h5py

  1. su
  2. export HDF5_DIR=/usr/local/hdf5/
  3. export HDF5_API=18
  4. easy_install h5py
How to recover if you did use HDF 1.8.5:
  1. Download, compile and install the correct version of HDF (as above)
  2. Get rid of the h5py egg compiled against this by doing:
    sudo easy_install -m h5py to get rid of paths etc.
    rm -r /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/h5py-1.3.0-py2.6-macosx-10.3-fat.egg (or where ever your egg is, to get rid of the compiled version)
  3. reinstall
  4. run tests to be sure

    Wednesday, July 21, 2010

    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.

    disown and nohup

    Problem: Need to make a running *nix process nohup
    CTRL+Z to suspend
    bg to background
    disown to make it effectively nohup

    From here and here and here

    Tuesday, June 22, 2010

    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.

    Friday, June 18, 2010

    Paste html table into excel

    From a hint in the comments on this thread.
    1. View page source
    2. Copy table source, starting with the <table> tag
    3. "Paste special" into excel as "text"

    Wednesday, June 16, 2010

    Time Machine over a network

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

      Wednesday, June 2, 2010

      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.

      Sunday, May 23, 2010

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

      1. 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.
      2. 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.
      3. 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.
      4. 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.

      Wednesday, May 19, 2010

      GLIPY - a promising but defunct enhanced shell for Python

      From here, we find the home page form GLiPy. GLiPy is a graphical shell for python. It adds interesting features that allow plotting of numpy matrices in line with the generating code. Unfortunately it seems to be defunct now.
      Some related shells for Python:

      Saturday, May 15, 2010

      Tuesday, May 11, 2010

      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!

      Monday, May 10, 2010

      Installing multiprocessing on Python 2.5

      multiprocessing comes standard with python 2.6, but you can hand install it for Python 2.5.

      svn checkout python-multiprocessing
      cd python-multiprocessing
      sudo python install   

      Saturday, May 8, 2010

      Nikon 35mm f/1.8 AF-S

      1. Metal mount
      2. Comes with lens hood and lens case
      3. Very light
      4. Small, but not as small as those pictures of it on the D300 make you think
      5. 52mm thread
      6. Rapid focus
      7. Very sharp

      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.

      Tuesday, May 4, 2010

      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.

      Monday, May 3, 2010

      Wednesday, April 28, 2010

      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.

      Monday, April 12, 2010

      Print a number in binary in python


      as in


      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:

      1. Type Ctrl/Shift/Escape to bring up the task manager (or right click on the task bar).
      2. Kill the ave.exe process. The popups will disappear. Leave the task scheduler up.[NOTE: you can use procexp too]
      3. Type Windows/R (to get the Run box) and type regedit and OK.
      4. 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]
      5. 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" %*
      6. Modify the value to be:
        "%1" %*
      7. Do the same with HKCR\secfile\shell\open\command.
      8. Delete ave.exe from the location in step 5. [NOTE: I could just not find this program]
        At this point, you have control back and no more popups.
      9. Download the current version of Malwarebytes' Anti-Malware and run it.
      10. Choose to fix the items the scan found.
      11. Run a scan of your regular anit-virus program.

      Friday, April 9, 2010

      Trying out alternative mac browsers

      From this page:

      Sunrise: small, can't go to http://localhost:3000/ (keeps interpreting it as search term), no ad block
      Shira: last update was in 2007 - did not try
      Camino: looks fine, kept trying to launch bloglines, MyYahoo and something else

      Thursday, April 1, 2010

      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.

      1. Install SIP from source package (python; make; sudo make install)
      2. Download and install PyQT from reiverbank (python; make; sudo make instll)
      3. QScintilla
        (In /QT4 qmake -spec macx-g++; make; sudo make install)
        (In Python/ python; make; sudo make install)
      4. 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 ajax confirmation (are you sure?)

      <%= link_to_remote 'Delete source', :url => { :action => "delete", :id => source},
          :confirm => 'Are you sure?',
          :html => {:title => 'Destroy source'} %>   

      Thursday, March 18, 2010

      Combining (concatenating) pdfs on mac

      A free automator work flow called combinepdfs is available. It works fine for combining a bunch of pdf files into one.

      Wednesday, March 17, 2010


      Easy as pie to install, and runs fine. See the tutorial here.

      Simple and quick interactivity in pylab plots

      Refer to the api:

      import pylab
      fig = pylab.figure()
      pylab.plot(pylab.rand(10), pylab.rand(10))
      def onclick(event):
      print 'button=%d, x=%d, y=%d, xdata=%f, ydata=%f'%(
      event.button, event.x, event.y, event.xdata, event.ydata)

      cid = fig.canvas.mpl_connect('button_press_event', onclick)

      Saturday, March 13, 2010

      rake tasks example

      An example of a rake task is given under /lib/tasks/migratedata.rake

      Rails drag and drop with scriptaculous

      From here:

      <% element_to_drag_id = "item_#{}" %>
      <div id=<%= element_to_drag_id %> class='mydrop'>
      <%= draggable_element(element_to_drag_id, :revert=>true) %>
      <% element_to_drop_id = "receiver" %>
      <div id=<%= element_to_drop_id %> >
      Whatever else
      <%= 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
      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 divs that have overflow:auto on

      This can be fixed by setting :ghosting=>true in the draggable.

      Friday, March 12, 2010

      rails 2.3.2 to 2.3.5

      sudo gem update rails
      sudo gem install rack --version '1.0.1' (rails won't play with the latest version of rack 1.1.0)
      sudo gem update bluecloth

      make sure you haven't set a particular rails gem version in environment.rb


      You should be all set

      Thursday, March 4, 2010

      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.

      Tuesday, February 16, 2010

      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 tool
      • Convert to path using object->path
      • Size as necessary
      • Remove fill
      • Ungroup
      • Type in actual text in new text box
      • Select the text and the '3' path
      • Flow the text

        Tuesday, February 9, 2010

        Mencoder: Change speed and size of movie and output such that Quicktime can play it

        mencoder input.mp4 -speed 0.33 -vf scale=450:360 -ovc lavc -ffourcc DX50 -oac pcm -o output_slowmo_small.avi

        The -ffourcc DX50 makes it quicktime playable
        The pcm is needed when we change speed (copy won't work)

        Monday, February 8, 2010

        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...

        Sunday, February 7, 2010

        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-lxml
        1. Download and install libxml2 and xslt for mac from here. Follow install instructions. 
        2. STATIC_DEPS=true easy_install lxml
        3. sudo easy_install lxml
        Leads 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/", line 348, in effect
            % ';\n'.join(converter_errors))
        RuntimeError: No Latex -> SVG converter available:
        Pdf2Svg: Command pdf2svg failed: [Errno 2] No such file or directory;
        PstoeditPlotSvg: Command pstoedit -help failed: [Errno 2] No such file or directory;
        SkConvert: Command pstoedit failed: [Errno 2] No such file or directory

        1. Down load and expand pstoedit from here.
        2. ./configure
        3. make
        Fails, some problem with ImageMagic. From here we can compile without all that.
        1. ./configure --without-magick
        2. make
        3. sudo make install
        More later

        Saturday, February 6, 2010

        Mobile phone <-> email (T-mobile)

        From here and here:

        e-mail to phone:
        e-mail address: [phone number]
        Resulting SMS:[my email]/Subject/Body

        phone to e-mail:
        Phone number: 500
        Text: [your email]/Subject/Body
        Resulting email
        Subject: Subject
        Body: Body

        Tuesday, February 2, 2010

        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

        Monday, February 1, 2010

        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)

        Sizing for posters, talks and papers

        Following society for neuroscience guidelines for figures:
        Text on figures should be 2-6mm high -> 5.6pt to 17pt
        Using figure labeling to be at least 8pt Arial for papers = 2.8mm
        Use a scaling of x2 for talks = 5.6mm
        Use a scaling of x4 for posters =  11.3mm

        Sunday, January 31, 2010

        "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 though
        • I would have expected Sun engineers to comeup with a better mechanism for a default password than putting 'changeit' or 'changeme' somewhere. Make a separate mechanism for password free access and give an option to activate a password if one wishes.
        • Now that I've changed the password back, I wonder what this now breaks?
        God, and these machines will be taking care of us in our old age...

        Friday, January 29, 2010

        Strange behavior of dict from Manager() in python's multiprocessing module

        import multiprocessing as mp

        def f(d):
          d['f'] = {}
          d['f']['msg'] = 'I am here'

        manager = mp.Manager()
        d = manager.dict()

        p = mp.Process(target=f, args=(d,))


        print d

        d = {}

        print d


        {'f': {}}
        {'f': {'msg': 'I am here'}}

        Whaa???? BUGREPORT!

        Update: Some one has suffered before me.

        Thursday, January 28, 2010

        Tuesday, January 26, 2010

        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
            # On most other platforms, the best timer is time.time()
            default_timer = time.time

        Monday, January 25, 2010

        MS word citations file formats etc.

        1. There is one citations file called Sources.xml, created after you add your first citation
        2. On Mac the location is ~/Documents/Microsoft User Data (see here for windows specific info)
        3. There is a paucity of documentation on the format (so surprising, no?) but various people have put effort into understanding it:
          1. Straight forward code on one page for a bibtex to xml conversion.
          2. Some one's journal of reverse engineering the xml format. 
          3. bibutils - command line tools to convert citations between various formats
          4. 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!

        Sunday, January 24, 2010

        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.

        Thursday, January 21, 2010

        Firefox 3.6 : new tab

        New tab opens right next to the active one, not at the end of the currently open tabs. Nice.

        Wednesday, January 20, 2010

        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 seems that the evidence for asteroids being rubble piles is:
        1. Many asteroids have very low desities, indicating a lot of empty space within them
        2. Clark R. Chapman and Donald R. Davis theoretically showed from energy considerations that, after a collision, pieces of an asteroid were more likely to fall back together under mutual gravity, than to fly apart.
        3. Many asteroids have large craters on them. If the asteroids were solid, the collision that generated such a large crater would have shattered the asteroid. If the asteroid was a rubble pile, the loose collection of rocks would absorb and dissipate the energy remaining together as a pile.
        4. No large asteroid has been found that spins faster than the limit at which a collection of rocks of that size would fly apart due to centrifugal force (bite me).
        5. When near earth asteroids pass us, their shape is altered due to tidal forces to an extent only possible if they are collections of small rocks.

        I had a dream once, of sending robot spaceships to mine the asteroids and bring back valuable materials. I need to revise the design a little bit...

        Sunday, January 17, 2010

        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.

        Monday, January 11, 2010

        Altering Python strings

        Python strings are immutable. Which means, that unlike in ruby and some other languages you can not do:

        str = 'Dodge This'
        str[-2:] = 'at'

        You need to do:

        str = 'Dodge This'
        str = str[:-2] + 'at'

        Friday, January 8, 2010

        String escaping for database queries in Python

        From python docs, use parameter substitution rather than some complicated home brewed escaping solution:

        Sqlite uses '?' (question marks) as placeholders