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'}}


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