Thursday, January 31, 2008

Rosewill IDE USB 2.0 external enclosure

Got this from newegg. It is the Rosewill RX35MV-U-BU SLV 3.5" IDE to USB 2.0 External Enclosure (Silver Aluminum & plastic). If you have an old hard disk drive (HDD) hanging about and it works and you want to convert it into external storage - give this a try.

Be aware that the design is iffy and the IDE connector pins that stick out from underneath the PCB may touch the aluminium case - I put two layers of duct tape strips to ensure isolation between the data pins/power and the case body per chance pressure on the case caused the aluminum body to short the power or data pins.

The standoffs between the drive and the enclosure are plastic, which doesn't make for such efficient heat conduction even though the body is aluminum.

The drive was easy and intuitive to assemble - took about 10 minutes. Vista has no problem recognizing and treating the enclosure as an external drive.

This is an IDE USB 2.0 device, IDE drives are going out of fashion now, being replaced by SATA

As a sample transfer speed I got a peak transfer rate of 18.9 MB/s (transferred 1.46 GB in about 2 min). The HDD was a Western Digital Caviar SE WD1600JB 160GB 7200 RPM IDE Ultra ATA100.

Rails project quick start quick list

  1. Build database using sql
  2. In command line do rails expt where expt is the name of the project
  3. under config/database.yml change sql adapter and database name
  4. ruby script/generate scaffold (model name) (repeat for each model)
  5. ruby script/server -edevelopment -p3000, replace development with test or production, replace 3000 with the port number you want
  6. now start messing with the internals

Sunday, January 27, 2008

Image vectorization

Inkscape is awesome.I just discovered image vectorization on inkscape. You just import a bitmap image and then go to path->trace bitmap [inkscape wiki]. The effects are amazing AND fast. I'm impressed.

update_attributes and associations - customizing rails magic

For sources in Rriki the user types in a list of authors for that publication and RRiki takes care of looking up the database of known authors, creating new entries if need be and then linking the relevant authors to the publication. This is all good and dandy for the user, but editing poses a problem: update_attributes takes its information from the form, which does not have the association information.

From we have :

def update_attributes(attributes)
self.attributes = attributes

All that was needed was to not use the bundled update_attributes and instead manually do

@source.attributes = params[:source]

Another instance where it is necessary to break into the comfy 'it just works' world of rails and customize some of the magic.

Saturday, January 26, 2008

Rails : Where to put what

I'm trying to clean up Rriki. Yes, this is procrastination and I should do my research, but clean code looks soooo nice !

Any way, I'm trying to program the rails way (some mumbo jumbo about MVC and DRY). For Rriki's 'sources' (storage for research articles, books etc.) I have a certain amount of processing that I have to do - I export the table data to BibTeX so I can use it with LaTeX, I import publication data from pubmed, and I write to auxiliary databases such as for bibus.

Currently code for this is placed in the model, in the controller and in sources_helper. But I have learned that this is not the true way. The proper coding etiquette is as follows
  1. Thin controllers : put as much of your logic in the model as possible and keep the controller slim and trim. Ideally, you should be able to glance at a controller method and figure out what information it grabs. [Jamis Buck]
  2. Fat models : Most of the logic will be about fetching, manipulating and parsing model data. So this IS the model's business.
  3. Use layouts : its a bit like css for rhtml
  4. Slim views : resist the temptation to write ruby code in rhtml - use a helper
  5. Fat helpers : move involved view code from views and controllers into helpers
Also see what goes where [Slash7].

Narbacular Drop

The ancestor to the portal game. Portals make me dizzy. Now this is a good use of physics engines! And it exercises your mind! [homepage]

Wednesday, January 23, 2008

First ever Vista BSOD

But I was probably asking for it - I was doing some image manipulation on the GIMP and my cores both went to 100% and the memory went to 100%...

Vacuum pumps

Are available from
  1. The science company. (search for vacuum pumps) The ones they have are plastic body, and they get a decent vacuum but for small volumes (each stroke moves about 15ml). They come with a guage
  2. The tool source. Which seems to be geared toward automotive (car) repair. They have a bunch of handheld vacs just like the science company. Their Mityvac range has some aluminum/zinc bodied pumps that get to 25inHg vacuum.
  3. Mityvac has a list of distributors on their page.
  4. Ralston instruments has nice looking vacuum pumps and gauges.

A mouse in the house : Webcam motion detection


We have a mouse in the house. I wanted to have the little intruder on camera. I dug out the old webcam and started to google for webcam motion detection software. Unfortunately a free but closed source program (Yawcam) won over a open source one (Dorgem). You can see the results in the video above.

The mouse makes its appearances at 3:00am, 3:50am and 5:26am. I forgot to add in time stamps to the images, but Yawcam can do that.

Dorgem was not satisfactory because I couldn't get motion detection to work. There was no way to adjust the threshold. I set it to take shots every 1s and it saved images with time stamped filenames (and a time stamp on the image itself) but the motion detection did not work. Perhaps the CCD noise kept triggering the software, I just got image dumps regularly at the 1s rate. [Help page on how to use Dorgem for motion detection]

Yawcam is more professionally designed. It has a motion detection preview pane where you can adjust thresholds or have the software adjust it automatically. The software highlights in real-time parts of the image where it detects motion. I found the auto-set tolerance level (20%) to be a bit high, perhaps because my motion trigger - a mouse - occupied a small part of the frame. I set the tolerance to 5% and the threshold to 95%.

Yawcam logs each motion event with several useful parameters. It has a "motion %". The first mouse appearance is triggered by a value of 5%. In contrast me walking across the kitchen is at 48%. My guess is that the % is the percentage of the screen that goes above motion detection threshold.

Once again:

Monday, January 21, 2008

Modifying Thunderbird tags

There is no good way to modify or delete tag definitions from the Thunderbird UI. The tag definitions are stored in prefs.js [mozillazine] in lines such as

user_pref("mailnews.tags.receipt.color", "#C0C0C0");
user_pref("mailnews.tags.receipt.tag", "Receipt");

in this case "receipt" is the name of the tag (the string that gets put into the mail header) and "Receipt" is what you see in thunderbird, and the highlight color is #C0C0C0, which is a light shade of gray.

Paper Art

Peter Callesen cuts outlines from a4 paper and then makes sculptures out of them, without ripping the continuity of the paper i.e. the paper is still attached together!

Thunderbird local folder tags redux : It can be done!

  1. Compacting a folder adds the X-Mozilla-Keys: header if it does not exist [mozillazine],[googlegroups thread],[bugzilla].
  2. You can force a folder compact by deleting an (unimportant) email and then compacting the folder. (Just clicking compact will do nothing to a folder if there is nothing to be deleted).
  3. Thunderbird, once it sees the X-Mozilla-Keys: header, will actually use it to store tags.
  4. You can verify this by deleting the .msf file and seeing if the tagging persists
  5. You can now move this email around (from inside Thunderbird) and the tags move with the email, even to a folder that, in general, does not have the X-Mozilla-Keys: header! True metadata.
  6. You can tag a folder that doesn't have the X-Mozilla-Keys: header and afterwards compact it and Thunderbird will move the tags into the header. Just make sure you really compact the folder (pt 2. above)
  7. Thunderbird stores tag definitions (highlight color etc.) in prefs.js
Good, now I can continue with my tagging of archived mail...

Sunday, January 20, 2008

Archiving email : Thunderbird tags not ready for primetime yet

Thunderbird stores email in plain text files (mbox format) that have names like INBOX and mysweetiesemails (files with no extensions). Riding with these mbox files are other plaintext files with corresponding names INBOX.msf and mysweetiesemails.msf . These .msf files are mail summary files used by thunderbird to speed up certain actions that would otherwise require repeated trawls through a large text file. The .msf files are autogenerated as required and can be deleted.

The good thing about mbox, I think, is that in the end it is not proprietary and it is plain text. Thunderbird has enough of a user base that whatever comes after Thunderbird will have a way to import mbox mail (if not use mbox directly).

I wanted to archive my email off my university's server onto local folders on my compuer. Thunderbird's "Local Folders" can be reconfigured to any folder on your computer, by going to tools->account settings.

I had organized my mail into different folders on my pop server by year, and some separate folders for special classes of emails (e.g. rejection notices from journals...). When I moved the emails, I decided to move them, by year, into archive folders on my computer (local folders).

Now, dumping all the mail into one archive "folder" (which would translate to one Thunderbird mbox file) would be fine, but I believe that this single file would balloon too much in size and eventually become unmanageable, so I settled on having a folder (mbox file) for each year.

The transfer from pop to local archive folder went fine, but of course, I lost my special organization, so the mail from an editor of a magazine complimenting me on my work (important to me) in 2005 got mixed in with several hundred emails between me and my colleagues trying to figure out some trivial, daily work related stuff (not so important) also in 2005.

This highlights, to me, the need to have some kind of categorization that travels with each individual email, so it won't get lost if you move it around - like ratings and tags and captions for images, which are now stored within the jpg as metadata, so you don't have separate files that need to travel with your pictures, storing captions and ratings etc.

Thunderbird's tag (formerly label) system covers this. But be aware that not only are there no standards for labels in emails, the mbox storage format, though popularly supported is not a formal standard and comes in different inconsistent forms. So tagging, recognized by Thunderbird 2.0 may not be by Thunderbird 3.0 or FutureMailClient 1.0. Heck, people have had problems when mixing labels (TB1.5) and tags (TB2.0).

Anyhow, Thunderbird supposedly stores tag information in the message header with the "X-Mozilla-Keys" header and I got all excited until I found out that for local folders the tags get stored in the .msf and not the header [Bug 378973]. So, for the moment I've given up on tagging or labeling until the dust settles. I may even go back to separate folders.

Incidentally is a good place to browse mozilla source code. Thunderbird stuff is found here. The code for handling tags is here.

Saturday, January 19, 2008

Turning interactivity off when drawing in matplotlib

Running in interactive mode is great and all, but I just learned that in interactive mode EVERY plotting command causes a COMPLETE redraw. That would explain all the flickering and delay in a script I put together that changes the plot each time a mouse action is executed on the axes.

However, ioff() comes to the rescue. This nifty function temporarily turns off interactivity, so that all those plotting commands go in a pipeline and you can show it all in the end when you want to.

Friday, January 18, 2008

Loose Manhole Cover V : The buck passes (almost) full circle

(Read episodes I, II, III, IV first).

The buck has almost come full circle, I think I'm at 290 degrees. I phoned CableCom again today (naturally they didn't call me back as promised) and they took my complaint and said they would pass it on to Verizon but the lady was sure that it was the county's responsibility.

I'm now expecting Verizon (if they do anything at all) to say its the County's problem.

Heh, heh. Now, I need to start getting things in writing so I can have, on paper confirmation of the nexus of the universe, this loose man hole cover that everyone thinks is the other guy's responsibility.

Heh, actually wouldn't that mean I could just take the lid and sell it on ebay? I mean if PG. County says its Verizon's responsibility and if Verizon/CableCom says its PG County's that means ... its no ones ... so its abandoned ... so ... finders keepers

Add column to table

To add a column to a table

ALTER TABLE `table_name` ADD COLUMN `new_col` DATETIME COMMENT 'comment' AFTER `col`;

Converting raster images to SVG

I needed to merge photos I took of a setup with some figures of data. I was thinking to convert my photo (.jpg) into svg format (my idea was that it would be zoomable, and perhaps smaller in size). However, a look at scale-a-vector suggested to me that the conversion is not worth it. So I'm merely going to paste in my bitmap photos of the setup onto my vector figures of the data.

The only annoying thing about Python...

...actually Ipython

In [2]: exit
Out[2]: Type exit() to exit.

In [3]: exit()
Do you really want to exit ([y]/n)?

is that you can check-out any time you like, but you can never leave.

Thursday, January 17, 2008

3D scanning

Looking into 3D scanning I came across several home brew methods. This guy was actually selling a method (I guess he was selling the line laser, because he claims the software is free) - DAVID-Laserscanner. And there is the Next engine which retails for a cool $2500.

Drawing database diagrams

I wanted to do some documentation for Rriki which involved drawing database tables and how table rows are related to each other. I looked around and tried dia and MySQL workbench. Dia is able to export to SVG and it can draw connectors between blocks so that when you move the blocks the connectors move. However the SVG export is not correctly interpreted by Inkscape. The blocks are drawn correctly, the labels on the blocks are offset from their desired positions, and the label of the last drawn block is missing.

MySQL workbench can grab table definitions from a sql dump, and you can draw relations between tables, but the drawing is very clumsy, and the display flickers continuously.

I went back to good old Inkscape for my diagram.

Education by Slashdot

There was some story on slashdot and was tagged myhovercraftisfullofeels. Naturally I started a search on this and this page told me that it was some monty python thing. And I realized how much of my education about the fake modern world has come from slashdot.

For instance I have learned acronyms and phrases

IANAL - I am not a lawyer
IANAP - I am not a physicist
YMMV - Your mileage may vary
YRO - your rights online
ISP - internet service provider (In the real world this is Indian Sari Palace)
OMG ponies!!!!
in this house we obey the laws of thermodynamics
my hovercraft is full of eels
vapor ware
In Soviet Russia YOU educate slashdot

I have learned about cool websites

xkcd - a cool geek comic
dark roasted blend

And tens of other tid-bits of modern geek speak than enable me to maintain my alter ego at work and blend in.

Ahh, slashdot, where the comments are so much more interesting than the articles.

Wednesday, January 16, 2008

Freespace 2

Remember Descent? Descent Freespace (no blood relation)? Well, apparently there was Freespace 2. I wasn't informed. Then, apparently it was open sourced and released, and now there is a whole ecology working on it! And you can get it through bittorrent (The client claims I'll have it in 8hrs. I think I'll while away the time working on my paper).

Monday, January 14, 2008

Matlab, nested functions, and variables

I rejoiced that MATLAB lets you have locally declared functions. Ahh, where are Python's namespaces? All hail Python. Fie promiscuous MATLAB! poor shadow, false pretender.. ahem..

Ok, so I go and nest a function and load some data from a file and Boom! MATLAB cries Uncle, with some wimpy excuse that it can't load variables into a static workspace. I ask you, is that grown up behavior?

So I have to do this round about thing: Suppose I have a mat file segmenting.mat with 6 variables called segment, dive_trials, dive_segment, trials, interaction, and capture. I have to load them into an explicit variable (thisisbogus) and then I have them as structure fields. Ewww.

thisisbogus = load('segmenting')

thisisbogus =

segment: [43x2 double]
dive_trials: [2 3 4 5 7 8 9 10 12 16 19 20 26 29 32 38 39 41 43]
dive_segment: [19x2 double]
trials: [1x38 double]
interaction: [43x1 double]
capture: [43x1 double]

I didn't want to type the bazillion lines of code to assign each field back to a variable, so I automated it

thisisbogus = load('segmenting')
bog = fieldnames(thisisbogus)
for n=1:length(bog),
disp([bog{n} ' = getfield(thisisbogus,bog{' num2str(n) '});'])

which prints

segment = getfield(thisisbogus,bog{1});
dive_trials = getfield(thisisbogus,bog{2});
dive_segment = getfield(thisisbogus,bog{3});
trials = getfield(thisisbogus,bog{4});
interaction = getfield(thisisbogus,bog{5});
capture = getfield(thisisbogus,bog{6});

Which can be pasted into the MATLAB function.

I get this nagging feeling that MathWorks is getting sloppy, I wonder why. This makes me upset, just like Microsoft Word's half-baked implementation of a cross-referencing system.

Then why don't I just go use Python and Latex then, you say? I do, I do, but JEB prefers Word files, and my co-authors use MATLAB and Word...

Sunday, January 13, 2008

UMD archery website up

The energetic guys setting up the UMD archery club have got the website up and running, and they have a google groups list up. From the website I see that they've got money to buy bows! I'm looking forward to shooting with them.

Loose Manhole Cover IV

(Read episodes I, II and III first).

I called up CableCom at 1-800-322-6852 and they took my complaint and home number and home address and said someone would call be back in the morning. Lets see how private contractors compare to government workers.

Incidentally, I was curious as to who CableCom was. From google we see that CableCom could be:
  1. A swiss based cable/internet/phone company.
  2. A Wisconsin-based company that does network cabling and fiber optic construction.
  3. A telemarketing company (bad industry, bad industry, don't call me) based who knows where.
  4. A Chicago based contractor.
  5. A UK based cable TV company.
  6. A Norwegian company. And, yess ze doo tak lik Bork, iff you luk at zee leenks like "Kontakt oss" on that page.
And that's just the first two pages. I'm going with the wisconsin one because Verizon has hired CableCom to do the fibreoptic work.

Vista hibernation and Bittorrent

Yesterday whenever I put my vista running laptop into hibernation it would resume immediately. It turned out that Bittorrent (I have v 6.0) when it sits in the system tray, causes this problem. I had to exit the client and the computer hibernated as usual. Fortunately by the time I had discovered this I had not gotten in too deep in tweaking settings that are best left alone when they work!

Saturday, January 12, 2008

The Mechanical Universe

When I was in school I enjoyed immensely a program called The Mechanical Universe. It is a series of lectures on physics and each lecture starts out in a class room (The series was produced at the California Institute of Technology) with the professor introducing a concept. Then the lecture takes off and uses historical reconstruction, demonstrations and animations to explain the concept.

The humor and drama conveyed were great at holding my interest, and this multimodal method stuck in my mind much better than dry textbooks.

The Mechanical Universe remains in my memory as one of the better uses of television. It has been made with public money and I am happy to see that you can stream the video to your computer from

Friday, January 11, 2008

Vista defragmenter

Vista's defragmenter, unlike XP's and win98's displays no information about the disk's fragmentation state, or defragmentation progress.

However the help does say that using defrag.exe will yield more details. defrag.exe is a command line version that reminds me of linux system utilities. Remember to run it as admin. On a side note, who would have thought that Microsoft would implicitly say guis are evil?

One major improvement is that you can work while defragmentation is going on, and the process doesn't seem to affect things.

Thursday, January 10, 2008

Loose Manhole cover III

After my initial complaint a prompt response from PG County sends me in search of Bell.
  1. google search for "bell pg county" takes us to Bell Atlantic-Maryland v. PG County.
  2. google search for "bell atlantic-maryland" takes us to the fcc and we learn that this is now Verizon Maryland.
  3. google search for "verizon maryland" leads to here.
    I see they have a lot of things about corporate responsibility etc. etc. Good thing our tax-paid scientists (me) are going to scientifically test how correct those statements are...
  4. As a blogger, I understand I am now a journalist, at least in utopia (AKA Canada), so should I contact their media person? No, I think I will go with Network Transformation and Upgrade, and call cablecom who is their contractor for PG County. 1-800-322-6852
  5. Dare I phone them at 7:44am? Ok, I'll wait till regular business hours.

Loose Manhole cover II

PG County gets a silver medal for service.

I made a complaint to PG county about a loose manhole cover near our house on Jan 7th. On Jan 9th 3:13pm a gentleman called Wilkerson left a message on our phone system saying that he took a look at the manhole cover and its not part of the PG County drainage system, but belongs to Bell, so I'll have to call them. He also recalls coming over last year to take a look at the same manhole cover. I made a complaint via their web system last year! So they did come. They do exist!

So why am I being such a hard ass and giving them only a Silver medal? Well, Mr. Wilkerson was prompt, he looked into it, and he told me what he found, and how to proceed. To get the gold, PG County should have picked up the phone on my tax paying behalf and chewed out Bell (AT&T? or what ever they are calling themselves nowadays to hide from anti-trust).

Hmm, as a government employee I would have kinda enjoyed harassing a private company because they were giving bad service to a government sector client i.e. everyday Joe.

Anyhoo, Silver medal to PG County for
  1. Easy to find service
  2. Prompt taking of complaint
  3. Prompt response and investigation of complaint
  4. (BUT) Not going that extra mile to fully resolve complaint
Ok, now to track down bell.

Wednesday, January 9, 2008

Glossy Laptop display

My laptop has a glossy display (HP calls it a BrightView display). It is marginally annoying when there are bright surfaces behind you. When the screen is off, you would think, from the reflections, that its impossible to use, but the LCD displays pretty bright images, so they usually drown out the background behind.

I had never been able to use the laptop outside, because of reflections, until today. I decided to try again and this time, instead of sitting facing the sun I sat at an angle to it. It was amazing! At the proper angle, the back of the display diffusely reflects the sunlight, causing the screen to now act like an old fashioned LCD with no back-light.

It looks a little weird, because the letters clearly float above the greenish background (like the LCD on a clock or watch), but I was able to use it in bright sunlight, on battery (i.e. dimmed display). It was amazing.

So the trick to using the BrightView LCD in sunlight is to turn so that the sun is not reflecting directly off the screen, but is otherwise illuminating it.

For a nice description of how this works look here.

(Thanks to Ben for pointing out original post was obtuse in parts)

Tuesday, January 8, 2008

FarCry user map : Outpost 22

Just now I was whining about how Matto3 and Matto4 did not have enough stealth for me even though the level design/objects etc. was awesome. And then I downloaded and started to play Outpost22.

One word.


Of course, I'm biased by the fact that

I Love Stealth.

And this map is heaven for stealth tactics, diversionary tactics, hit and run and trap tactics.

This is so far my favorite FarCry map, even, perhaps, including the official FarCry ones, though I don't have them so well in memory.

Matto3 and Matto4 *almost* make it to my favourite list

What I really enjoyed about FarCry was the stealth element. My favorite weapons are the sniper rifle and the silenced machine pistol. I enjoy well made maps, good atmosphere and well, stealth.

I hate "boss" fights, be they with "Bosses" or large numbers of enemies at the same time, out in the open. I also hate Trigens, but that's a good kind of hate.

So Matto3 and Matto4 almost made it for me, with Matto3 beating Matto4 except for the incomplete nature of Matto3's story.

Matto3: The good
  1. Silenced pistol with scope! Heaven!
  2. Lots and lots of humor scattered around.
  3. AWESOME maps. Really. Absolute top-notch crafting of textures, objects etc.
  4. Some innovative aspects, like shooting gas cylinder valves to turn them into rockets
  5. Some manipulation of the environment
  6. Multiple routes, to an extent
  7. Matrix style slow mo!
  8. No trigens

Matto3: The bad
  1. Incomplete - not really bad.
  2. Boss fight at a certain level
  3. No sniper rifle
  4. Jack Carvers voice acting. Sorry, even if I allow him to be British (quite suddenly, an ethnicity transplant as it were), that's not a native British accent.
Matto4: The good
  1. same as Matto3, except, see below.

Matto4: The bad
  1. Dude, where's my sniper rifle?
  2. Dude, where's my suppressed machine pistol?
  3. Dude, what's with all these Boss fights?
So, all in all Matto3,4 will appeal to most FarCry players, except those who want a stealth option.

Monday, January 7, 2008

Loose Manhole cover

There is a loose manhole on a street cover near our house. Cars going over it make a very loud clanking noise. This will be a test of PG County Government efficiency.

A. How hard is it to find who to contact about this?
  1. A google search "prince george county government" takes us quickly to
  2. PG county where a top menu option takes us to
  3. Government and a easily naviagble side menu takes us to
  4. Department of Public Works and Transportation where though there is no option for a "loose manhole cover" there are things to do with roadways. I decided that "drainage" would be most appropriate since these dudes should have the tool set to open (and perhaps replace) manhole covers.
  5. Office of Highway Maintenance's (OHM) Customer Service Office at (301) 499-8520 seems to be the people to contact.
B. Does this work?
Yes! I get patched through to a operator who takes the details of the loose manhole lid and gives me a confirmation number.

All done over lunch, say 15min tops starting cold. So far, I'm happy to be paying taxes to PG County.

Now lets see how long the business end takes.

Saturday, January 5, 2008

Name (and url) change

When I first started this blog I decided that it would be about my stumbling around to learn Python. I had a page on my old website where I collected all kinds of assorted information I gathered trying to solve different problems. This blog finally got enough non-Python miscellanea that I decided to rename it and re-url it to what it should have been in the first place - "Assorted Experience".

I thought this was going to be painful or impossible. I knew you could change the name of the blog and the description, but the url too? From a hint here and some trying on of names I got it all squared away.

Dots in your gmail

Google help clears up a mystery for me. I often get emails meant for other people on my gmail account. There is always one difference between my gmail address and the mistaken one - a dot. Google has set up things so that adding or removing dots from the name part of your address still directs mail "properly". So if you register the address then mail sent to also gets to you.

This is an interesting choice on the part of google. I can't think of a good reason why you would do this.

Wednesday, January 2, 2008

Debugging in rails

config.breakpoint_server has been deprecated and has no effect:

to fix look here.

RoR 2.0 has very nice info messages!

Cleaning up RRiki

update sources set sources.`note_text` = replace(sources.`note_text`,'Research Support, Non-U.S. Gov\'t','')

delete links, keywords from links, keywords where and keywords.word='Research Support, Non-U.S. Gov\'t'

Ain't databases fun