December 2009 Archives
Tue Dec 29 16:02:13 EST 2009
SSH tunneling
Kurt Schwehr had a great post last month about making ssh tunneling easier.
I wonder how robust a combination of these methods with fuse (mounting
shares over an ssh connection) and autossh
would be. It could give you a way to put sensors in the field and
have them log data (or at least periodically upload data) to any
server within CCOM by simply writing to what looks like a local
part of the file system. Would want to do something smart when the
link is down, but it seems like it might be possible.
Tue Dec 29 13:06:38 EST 2009
Pressure Fluctuations with Depth due to Surface Waves
In our AUV operations for seafloor mapping we have seen artifacts that result from the modulation of the AUV’s pressure sensor by waves passing over head.

In a recent survey, we were operating the AUV in 12 meters of
water at a depth of 6 meters down over very flat seafloor (<10
cm relief). There were relatively large surface waves with a
peak-to-peak amplitude of about 2 meters. These were surface
shallow-water gravity waves whose wavenumber, k, can be calculated
from their wave speed, c and their period, T by k = 2*pi /
(c*T). Wave speed, c, in turn, for this kind of wave is
calculated from c = sqrt(g*h) where g is gravity and h
is the total water depth. Using these relations and by equating the
pressure at depth due to surface gravity waves with the equation
for hydrostatic pressure (above) I calculated the error one should
see in bathymetry measurements made relative to the AUV’s depth
when the pressure sensor is used as its depth reference. (See
Water wave mechanics for engineers and scientists
By Robert George Dean and Robert A. Dalrymple for more of the
details.)

The plot above shows that for our scenario, we should see artifacts of about 80 cm. In fact, this was exactly what we saw!
Tue Dec 29 12:37:37 EST 2009
Creating a Movie from Images Using FFMPEG
I'm still learning how to use Fledermaus 7. For my CCOM Seminar presentation I made my first FM7 animation.
Actually, that’s not really true. I used FM to automatically create a sequence of jpeg images which I then stitched together with ffmpeg to make the movie. I think the whole process is meant to be handled by the FM, but my version of FM may not be up to date or the functionality may not be fully implemented. (Or, more likely, I just don’t know what I'm doing.)
In any case, to create the jpg files I selected
‘Tools->Render Movie…’ in the menubar within FM. The next pages
allows one to set up the details including the movie name which is
pre-pended to each jpg image. After clicking “OK” a set of
“play/record/ buttons will appear which you can use to ‘record’
your movie. When you're done click the ‘stop’ bottom. At this point
you'll have many many jpg images whose naming convention is
something like moviename_10xxx.jpg where
xxx is a three digit number index.
I used ffmpeg to stitch these together. Although
one can download and compile ffmpeg directly, it is also available
as a package on a Mac through fink. I had tried this long ago and
found that an older version of the ffmpeg fink package seg-faulted
with more than about 150 images. However the latest version worked
without fail.
Here’s the command-line entry for making the movie (I'm not showing the actual movie here as I've not yet figured out how to best package something like this for the web.):
ffmpeg -f image2 -i mendumsmovie_10%03d.jpg video.mpg
It took several attempts to get the syntax correct for matching
the file names. The %03d indicates three zero-padded
digits. If you had more than 999 images you'd have something more
like 1$04d.
Also, this 19 ffmpeg commands for all needs has a fantastic list of what can be done with ffmpeg and how to do it.
I have not even looked at what ffmpeg can do as a
server. Another day perhaps.
Tue Dec 29 12:03:38 EST 2009
CCOM Weekly Seminar - AUV Operations Summer 2009
A few weeks ago I gave the CCOM weekly seminar. The topic was an overview of our AUV operations this summer with the Gavia AUV, whose operation we share with Art Trembanis' CSHEL lab. I am “Chief Engineer”, which means it is generally ok when I break things, as long as I'm willing to fix them.
There were requests for the presentation for those who could not attend (note, this file is about 50 MB).

Mon Dec 28 12:09:17 EST 2009
Nanoblogger setup with Markdown
I have long been using nanoblogger for this blog with sometimes frustrating results. I never wanted to have to write html in my blog posts. It simply slows down my thought process too much to have to remember and embed html in every post for simple formatting, adding of images, links etc. So I wanted to use a wiki markup language with nanoblogger.
I started using a python clone of John Gruber’s Markdown. The exact version I used is provided as part of SQLAlchemy within the Enthought Python Distribution. It took some start and stops to get this working right. In fact I didn’t realize immediately that nanoblogger wasn’t actually implementing the markdown transformation for me. Out of frustration and the need to begin doing more documentation of my work that I finally sat down to figure things out.
What I found looks like a bug in nanoblogger-3.4.1, but I cannot
be sure that it is not a configuration issue on my part. In any
case, within the nanoblogger library, a script called
tools.sh has a subroutine called
write_entry() within which the variable
NB_EntryBody was being reset after the markdown plugin
had been applied. After commenting this out and modifying the
markdown.sh script to use NB_EntryMeta
rather than NB_EntryBody everything seemed to be
working fine. These changes have been sent to Kevin Wood who
developed nanoblogger. He is verifying that it is indeed a bug that
needs fixing and not something particular to my configuration.
After a few days of using Markdown on a more regular basis I found a limitation that I really wanted to fix, namely that in the standard Markdown implementation there is no way to specify the dimensions of an image. This meant having to write raw html for an image link to specify it’s dimensions on the resulting web page. So I googled around a bit and found Discount.
Discount is a c implementation of Markdown with several extensions, including the ability to specify the dimensions of an image in an image link. Great! Oh, but shoot. discount also has an irritating limitation! Discount’s mechanism for specifying image size is all-or-nothing. That is, you have to specify both dimensions of an image, in which case if you don’t specify values with the same ratio as that of the original image it will render stretched in one direction or another. Html allows you to specify only one dimension (height or width) and the other dimension will be chosen to maintain the original aspect ratio.
So I modified the code to allow the simple method of specifying
image dimensions (e.g. =300x400) to accept one
dimension or the other (e.g. =300x or
=x400). Here’s the patch to the file
generate.c within the Discount code base:
635,637c635,643
< if ( tag->WxH && ref->height && ref->width ) {
< Qprintf(f," height=\"%d\"", ref->height);
< Qprintf(f, " width=\"%d\"", ref->width);
---
> /* Mod by Val Schmidt, Dec 2009. */
> /* Allows one to specify only one of width or height as =150x or =x150 */
> if ( tag->WxH && (ref->height || ref->width) ) {
> if (ref->height > 0) {
> Qprintf(f," height=\"%d\"", ref->height);
> }
> if (ref->width > 0) {
> Qprintf(f, " width=\"%d\"", ref->width);
> }
So far everything is working fine. I use BBedit to write my blog posts and a simple unix script run through BBedit’s “Unix Scripts” functionality pipes the text in the current editor window through markdown and allows me to quickly preview the results before finishing the entry. I like this a lot!
Wed Dec 23 22:33:17 EST 2009
Modifying a file in place with Perl
This is documented several other places including here, but one of the really cool things you can do with command-line perl is to execute on-the-fly changes to many files though a single command line entry. For example, suppose I had 100 files with comments of # that I needed to be comments of %. I could change them all with
perl -i.orig -pe 's/\#/\%/'
My original files would now be named filename.orig
and new files would exist with the change. This is a simple
example, but the general idea is very powerful and very handy.
Wed Dec 23 22:02:50 EST 2009
Christmas in New Hampshire
I was walking around the neighborhood a few nights ago and snapped this photo with my iphone.

Thu Dec 10 12:14:53 EST 2009
Accessing an Airport from the Command Line
Today I found a really neat tool. It is a command-line utility,
buried in MacOS, that allows inspecting and changing operation of
the wireless device. It’s called airport.
First lets make access to it easier with a soft link.
cd /usr/local/bin sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport
Next lets figure out how to use it.
airport -h
airport AirPort v.528.1 (528.1.0)
Supported arguments:
-z --disassociate Disassociate from any network
-i[] --ibss=[] Create IBSS
-x --xml Print info as XML
-s[] --scan=[] Perform a wireless broadcast scan.
Will perform a directed scan if the optional is provided
-r --repeats= Repeat the command the specified number of times
-A[] --associate=[] Associate to network.
Will prompt for network name if arg is not specified
and if necessary, for a password if the network is using WEP or WPA.
The following additional arguments may be specified with this command:
--bssid= Specify BSSID to associate with
--password= Specify a WEP key or WPA password
-I --getinfo Print current wireless status, e.g. signal info, BSSID, port type etc.
-P --psk= Create PSK from specified pass phrase and SSID.
The following additional arguments must be specified with this command:
--ssid= Specify SSID when creating a PSK
-c[] --channel=[] Set arbitrary channel on the card
-h --help Show this help
You don’t need admin privileges to see your configuration
airport -I or to scan the current networks
airport -s, but you do to associate with a new network
airport -Anewnetwork.
Sun Dec 6 19:32:07 EST 2009
BREAD!
For my birthday, Alice bought me a cool book – “Artisan Bread on 5 Minutes a Day”.
Today I gave it a try. In Chapter 3 there’s the recipe. Painfully simple. Flour, water, salt and yeast. You make a very wet dough in a big bucket (no kneading – just stirring.) You make a lot. Then you can pull dough off to bake any day you like for up to about 10 days (or until it runs out). There’s a side-bar with a handy way to impress your friends – “6, 3, 3, 13”. Six cups water, three tablespoons salt, three table spoons yeast, 13 cups flour (which is almost a 5 lb bag). There’s also a note I think – something about a 10 quart bucket.
I ignored this part – the 10 quart bucket part. Or maybe forgot about it. My bucket is 6 quarts. Turns out, this is not enough!

As you can see, what I created was an explosive tub of dough capable of flattening an entire city block. Well, maybe I exaggerate here, but enough to make a BIG bang when I pealed off the top. It was really scary.
None-the-less, this evening we produced our first loaf of bread. Look at this!!!

Thu Dec 3 10:20:41 EST 2009
Nanoblogger Upgrade
Today I upgraded to nanoblogger-3.4.1 from 3.4rc2. It was a pretty seamless upgrade – only required a careful comparison of old and new configuration files. I wouldn’t have made the upgrade had my hard drive not crashed recently requiring a new OS-X installation. Interestingly I restored from a Time Machine backup and rather than restoring the contents of /usr/local/ to /usr/local/ it goes to ‘/usr/local (old Mac)’ or something similar. It is nice that someone was thinking enough to not trash it altogether.
Thu Dec 3 09:29:57 EST 2009
Welcome to NanoBlogger 3.4!
Welcome to NanoBlogger, a small weblog engine for the UNIX command line.
Quick Reference
- create new weblog (directory) ...
nb -b <blog_dir> add weblog - create new article ...
nb add article - create new entry (w/o tag) ...
nb add entry - create new tag ...
nb add tag - tag new entry ...
nb --tag [tag_id] add entry - list entries ...
nb list <query> - list tags ...
nb list tags - list entries by tag ...
nb list tag [tag_id] - edit entry ...
nb edit entry [entry_id] - tag entry ...
nb --tag [tag_id] tag-entry [entry_id] - untag entry ...
nb --tag [tag_id] delete entry [entry_id] - delete tag ...
nb delete tag [tag_id] - delete entry ...
nb delete entry [entry_id] - draft entry or article ...
nb draft [draft_file] - import draft as entry ...
nb import entry [draft_file] - import draft as article ...
nb import article [draft_file] - update weblog ...
nb update <all|DATE|main|max|articles|feeds>
<query> may equal all,tag,DATE or
max (defaults to all)
Thank you for choosing NanoBlogger. Please direct comments and suggestions to the mailing list or submit a bug report to the project page over at sourceforge.net.
