Friday, February 18, 2011

7 +- 2

The issue with computer science (well, and all other engineering disciplines) is complexity.  We can't deal with how complex our "artifacts" are.  Our brains are built with a working memory size of about seven objects.  Maybe hunting parties, or family sizes, were seven?  Using any more of our brains to track more things was a waste and would lead to a loss of efficiency?  Is this why telephone number are seven digits long?  Don't know.  What I do know is that once something we're looking at has more than seven objects, we are incapable of understanding it.  More than seven visible variables, nesting levels, etc., and we can't understand what we're looking at.  Hence functional decomposition and object-oriented programming.  Most people whom claim to do OO, don't, but that's a post for another day.  For today, check out for a visual demonstration of the property.  Most people can only count to 7 (+-2) without having to "chunk" (group and then count).  See:,_Plus_or_Minus_Two for a more rigorous treatment of this.

Tuesday, February 8, 2011

dd surprise

I was testing the speed of external USB harddrives and ran across something that surprised me.  I have assumed for a while that increasing the block size while doing a dd improved throughput but I tested anyway, and it didn't.  Here are the figures for not specifying block size, and then using 500k, 1m, and 500m:
 10,460,172 bytes/sec
 10,385,009 bytes/sec bs=500k
 10,529,657 bytes/sec bs=1m
  9,573,095 bytes/sec bs=500m
Looking at the overall speed of USB 2 (it's 480Mbps or 62,914,560 bytes/sec), it appears that it's USB that is the limit in this case.  We're getting not quite 20% of theoretical.  This on a MacBook Pro running Snow Leopard.

Tuesday, February 1, 2011

Applescripting notes

I wish i had more time to learn about Applescript as there are a bunch of things i'd like to do with it...  One thing i've done is create this small script to unmount volumes and put my MacBook Pro to sleep:
tell application "Finder"
    eject (every disk whose ejectable is true)
end tell
I have a Hendge dock for it ( to save all the plugging and unplugging, but at the end of the day, i wanted something to unmount and sleep.
So, run the AppleScript Editor and develop or paste what you want.  Click "Compile".  Do a "Save As" and save it to your home directory's Library/Scripts directory with a name such as "Eject and Sleep".
Then, you can also map a key to it: System Preferences, Keyboard, Keyboard Shortcuts.  Choose Application Shortcuts, click '+'.  Choose All Applications, Menu Title: Eject and Sleep, or whatever you typed before, and end the key combination you'd like...
Another thing one can map are "Services" on object such as directories.  So, if you can left click on a folder and there is something listed under Services, you can create a keyboard shortcut for it.  Here are two images demonstrating that.