OS X Dashboard: Loading a file

January 9, 2009 on 11:00 am | In Programming | No Comments

Dashboard has a strange limitation on the amount of data that can be read from a process. When I use /bin/sh cat ..., it only reads a few KB. Last night, as I was falling asleep, I realized how to get around this. OS X is a real operating system, so it has Perl (or whatever scripting language you prefer), so I hacked up the following script:

#!/usr/bin/perl

use strict;

my ($file, $offset, $length) = @ARGV;

my $data;
{
local $/ = undef;
open(F, '< '.$file);
$data = ;
close(F);
}

print substr($data, $offset, $length);

This will print a chunk of length $length from $file starting at $offset. If you want the entire file, simply loop, starting from zero, until you don’t get any more data.

Think Outside the Box

January 9, 2009 on 10:54 am | In Driving in LA | No Comments

I saw this on the back windshield of a Scion xB, which I have always called the “delivery van” because it looks like a box. Ironic :)

Gate — Part 2

January 7, 2009 on 10:22 am | In House | No Comments

Our gate finally opens all the way again! After we had it built, I carved out a notch for each hinge, but since then, the wood dried and expanded. Over Christmas, I spent a morning enlarging the notches, but it became obvious that the only way to solve the problem was to remove the vertical (partial) plank from the hinge end of the gate. I borrowed my parents’ circular saw and cut the horizontal trim plank in order to get access to the screws holding the vertical plank. After removing it and enlarging the notches in the 2×4’s on which all the planks are mounted, it opens all the way.

Sleeping Beauty

January 3, 2009 on 7:41 pm | In Deep Thoughts | No Comments

Our daughter loved the Princess Fantasy Faire at Disneyland. The show included a knight who spoke of the Shield of Virtue and the Sword of Truth, references to the shield and sword in Sleeping Beauty. It sounded rather corny the way it was presented, but it got me thinking. Pop culture has long since discarded them, but Virtue really is a shield against many forms of Evil, and Truth really is a sword that cuts through an awful lot of nonsense, including pop culture!

Resetting Your Tongue

January 3, 2009 on 7:30 pm | In Miscellaneous | No Comments

Have you ever been faced with a suite of sweets for dessert? If you’re not careful, you might eat a really sweet one first, and then another, equally good but less sweet item may taste nothing because your tongue is already saturated. I’ve discovered that salt is the perfect way to reset your sweetness receptors. Salty soup, salty peanuts, etc. all reset my tongue almost instantly. YMMV!

« Previous Page

Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds. Valid XHTML and CSS. ^Top^