Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

statico (5018)

Journal of statico (5018)

Sunday May 21, 2006
07:50 PM

welcome to Erie, PA

Computers typically make use of a "central processing unit," or CPU. After careful self-analysis during today's drive, I've realized that I make use of an "Ian processing unit," or IPU. Much like a CPU, the IPU can perform a lot of work so as long as the activity remains below a maximum threshold level.

Herewith an illustrative example: The IPU might be busy with two tasks. First, the IPU might trying to maintain a comfortable speed of 80 miles-per-hour on Interstate 90 westbound while trying not to get blown off the road due to disturbingly-high winds. Second, the IPU might be listening to the eleventh chapter of Bram Stoker's /Dracula/ courtesy of the LibriVox free audio book project. This would leave absolutely no IPU power for such tasks such as, say, noticing when precisely the light on the fuel gauge became lit.

(Emily's Corolla gets 30-35 miles after the fuel gauge lights up, so we were more than fine. Here's where you get to imagine nervous chuckling.)

Wednesday May 17, 2006
11:49 PM

road trip to cali

Emily and I are packed. Tomorrow, movers from TransAmerica will drag our belongings out of the house, and this weekend we'll begin our road trip across the country. It's actually cheaper for us to drive across the country and stay in hotels than for us to ship her car over and buy plane tickets.)

Let's review the plan, courtesy of AAA's TripTik plan:

  • May 21st - Leave Boston, MA, drive down I-90 to Erie, PA. Pass the vineyards, maybe stop in Dunkirk.
  • May 22nd - I-80 then I-90 and then I-89 to Janesville, WI. Apparently Dells, WI has some nifty sandstone. There will be some realization of how much driving remains.
  • May 23rd - I-90 through foresty Minnesota, then more Minnesota, then the rest of Minnesota. Eventually we'll hit Oacoma, SD.
  • May 24th - Continue on I-90 (surprise) to Rapid City, SD. Check out Mount Rushmore, Crazy Horse, Black Hills, etc. Is it politically correct to ask for a bison burger?
  • May 25th - Follow I-90 north of the Black Hills to Cody, WY, right outside Yellowstone National Park.
  • May 26th - Check out that famous geyser and the rest of Yellowstone. Carry on to Salt Lake City, UT.
  • May 27th - I-80 to route 95 to the Yosemite Gateway Motel.
  • May 28th - Check out Yosemite if we're not too sick of driving. Proceed to Mountain View, CA. Retrieve keys to new apartment, then make a visit to In-n-Out Burger.

I'll try to keep a log here and post some intermediate pictures on my Flickr account. Huzzah!

Tuesday May 02, 2006
08:38 AM

fin

College... check

That was quite a ride, this last semester. Instead of the general rule of taking easy classes during one's last semester, I had exactly four requirements to fill up. If you ever need an explanation of the linguistic properties of American Sign Language, I'm your guy.

(wipes brow)

Now, onto finding an apartment in Silicon Valley and beginning work on further interesting things. Can you say "road trip?"

Wednesday March 29, 2006
12:19 AM

stopgap

This is one of those "Holy hell I've been so busy" journal entries. Instead of sewing wit into crafty excuses, I'll simply enumerate what's been going on:

  • I've written the interesting parts of a source-to-MacScheme compiler for my compilers class.
  • I've studied and implemented various graphing algorithms (Dijkstra's, etc.)
  • I've given a presentation on what one might learn from administering the Stroop color-word test to CODAs.
  • I've written piles of labs describing the results of various perception experiments, such as the Muller-Lyer illusion.
  • I've accepted a job offer with a terrific company in California. Emily and I will be moving out there at the end of May.
Sunday January 22, 2006
07:50 PM

bass on the brain

The neck of my Peavey Foundation bass guitar is only slightly warped, even after years of neglect. Despite the action being too high and needing a new set of strings, it stays in tune. I'm not bothered with its condition because it's only the beater instrument.

However, when I pick the bass up and begin to play, my frustration grows. My technique has become sloppy. My walking bass improvisation has vaporized. My fingers are much more used to writing code than practicing modes and scales. I can hear the melody to "Oleo" in my head, but it takes a while to play it again.

I haven't played bass guitar seriously in five years, and I feel like crap admitting to it. I can picture the high-school version of myself gawking if he were to hear such a fact -- let alone my music or bass teachers.

When I was a senior in high school, I was happily cranking away tunes with my friends, my copy of Reason, or both. Then college happened. I was immersed in the depths of computer science and learning many new things, so I decided to put the music on hold. A few tracks percolated with a sprinkling of jam sessions, but nothing serious. I began to spend a lot more time listening to music than playing it.

Now, in the present, I know that a happy day is approaching quickly. In the next few months I'll have secured a permanent job. After graduation I plan to have my good bass, a Peavey Cirrus with neck-thru-body and a wenge & walnut finish, tuned and oiled. As much as I deeply enjoy my involvement with my university, I'm going to welcome the time I'll have to play music instead. When I carry my guitar out of the shop I'll be thinking of the next couple of years, who I'll find to jam with, what it'll be like to live in $location. And I'll be smiling.

Sunday January 08, 2006
06:38 PM

openings

The first sentence of any piece of writing is important, and last night I read one of the best openings ever written. It sits atop the acknowledgements of The Complete Calvin and Hobbes, a 30 lb., 3-volume boxed tome that contains every Calvin and Hobbes comic strip every drawn:

"As flattering as it is to have a lavish book like this,
it can be a little disturbing to see one's own career
embalmed in a box..."

The ingenuity is underscored by appropriateness. Watterson downplays the magnitude of the collection, yet the contents of the box contains a large staple of my childhood.

Another teriffic opening is on the back cover blurb for Perl Testing: A Developer's Notebook, written by chromatic:

"Can you think of a sexier topic in software development
than software testing?"

If there's a hall of fame for this sort of thing, let me know. I have two nominations.

Saturday December 31, 2005
09:50 PM

switching backgrounds in Gnome 2

One reason to use open-source software is if you enjoy the ability to create or alter any of the tools you use. I use Linux and the Gnome desktop environment, and I'm confident that if there's something that I want to do -- a customization or an application -- I can probably do it in Perl. If I can't, I can probably do it in Ruby. If not Ruby, there might be command-line tools. And if none of those are available, I can do it in C.

Every couple of minutes, the background on my dad's laptop changes to a random picture. The picture is one of many in a directory of Eleuthera images, some of which are mine. This sort of behavior doesn't exist for Gnome, plus I'm not always online with the ability to search for a solution, so I was curious as to how much work would be needed to this happen.

I fired up gconf-editor, the Gnome configuration editor, and searched for "background." Sure enough, there was a preference called /desktop/gnome/background/picture_filename whose value was an absolute path to the current background image. There were also other options to set the layout and background color.

Having the Gnome2 packages installed, I tried using Gnome2::Config to set the path to the background image:

#!/usr/bin/env perl
use strict;
use warnings;

use Gnome2;
Gnome2::Program->init( 'random-background', 0.01 );

my $path = '/desktop/gnome/background/picture_filename';
Gnome2::Config->set_string( $path,
    '/home/ian/pictures/to_upload/IMG_3644.JPG' );

This, unfortunately, didn't work at all. Before set_string(), the string returned by get_path() was empty. Afterwards, tests using get_string() claimed that the image had been set, but the background hadn't changed. Harumph.

Next I tried to use Ruby. Unfortunately, the Gnome libraries for Ruby weren't installed, so I looked for a command-line solution instead.

The gconftool-2 utility, which allows you set and get parameters on the command-line, worked perfectly. The following program takes one or more directories as arguments, finds all .jpg files in those directories, and picks one randomly and sets it as the background:

#!/usr/bin/env perl
use strict;
use warnings;

use IO::All;

die "usage: $0 <directory> ...\n" unless @ARGV;

my @pictures = grep /\.jpg$/i, map { io($_)->deep->all } @ARGV;
my $picture  = $pictures[ rand @pictures ];

my @options_to_set = (
    [ 'picture_options',  'scaled' ],
    [ 'picture_filename', $picture->absolute->pathname ],
    [ 'primary_color',    '#444444' ],
);

foreach my $tuple (@options_to_set) {
    my ( $key, $value ) = @$tuple;
    system(
        'gconftool-2',
        -t => 'string',
        -s => "/desktop/gnome/background/$key",
        $value
    );
}

This doesn't, however, perform the sexy fading transitions that Mac OS X does. I figure it's close enough for now.

Saturday December 17, 2005
06:25 PM

gift woes

Gardener's Supply Company shipped out the package on Monday via UPS Next-Day Air. It's Saturday, so where is it?

UPS.com lists the package with a "Rescheduled Delivery" date: today. During some investigation a UPS employee told me that this is really code for "we lost your package, recovered it Friday, and are shipping it today." Normally, aside from my annoyance, this wouldn't have been a problem -- except that I'm leaving the country tomorrow and UPS doesn't deliver on Saturdays here.

Serves me right for cutting this so close. At least they're refunding the difference of the next-day shipping, a service which I did not receive.

Tuesday December 13, 2005
12:34 AM

my code is gold

This past Spring, at some point in my Software Development class, I had an opportunity to mimic a joke I once heard. Professor, I said, all my code is perfect. I assume that any bugs I find are in the Perl language itself. It was funny because it was so absurd. We all laughed and chortled.

Now, it's not funny anymore. A claim with this level of silliness has appeared.

First, consider the basics of trusting user input. Would you ever write the following CGI script?

#!/bin/sh
echo "Content-type: text/plain"
echo
eval $QUERY_STRING

Somewhere, halfway around the world, a kid punches in http://example.com/~you/test.cgi?rm%20-rf%20" and erases what he can of your hard drive and attached storage. The consequences are obvious.

After this occurred, however, would you blame sh? Is every implementation of sh around the planet broken? Of course not. So why is Webmin blaming Perl for a similar mistake?

Perl syslog bug attack

Effects Webmin versions below 1.250 and Usermin versions below 1.180, with
syslog logging enabled.

    When logging of failing login attempts via syslog is enabled, an
    attacker can crash and possibly take over the Webmin webserver, due to
    a bug in Perl's syslog function. [...]

Take a look at the vulnerability details. Webmin passes some user input right to sprintf, which is known to be about as safe to pass user input to as the eval keyword. Yet, the developers blame Perl.

(A correction has been emailed.)

Thursday December 01, 2005
11:11 PM

knowledge

A month ago I was saying to myself, "I know a large amount of stuff. I believe that I'm well off in terms of knowledge." I was confident that I'd be ready to be plopped on the front lines of the job market wearing shiny armor and carrying a mighty-powerful axe. This vision, however, has been slightly tarnished by the realization that I might not be as well-prepared as I had thought.

Let's pretend my future boss says, "For this, you'll probably want to create blabbity-blah and write your own parser." A parser, madame? Erm, uh, kinda, well, gee, uhm, hlaughalugah, context-free grammar? What? Yes, I understand the basics. I'm aware that LL is easier than LR, but I'm a bit unclear as to why left-recursive grammars can't be handled by top-down parsers.

Compilers is a part of my brain that, when accessed, responds with unnerving silence. Recalling the time in New Hampshire when I was planting anti-gopher bombs and accidentally inhaled some of the orange, peas-and-carrots-smelling poisonous gas, I feel like that event formed some gaping cavity in my skull. Cut away half of Ian's brain and you'll see said cavity, and inside will be a small, crumpled Post-it note enscrawled with "TODO: learn compilers."

The worry is that I can't fill this hole in my head the way I curb all other knowledge cravings. When I want to know something, the magical Internet showers me with all sorts of material I can submerge myself in. XSLT's key() function? Currying? JavaScript as a programming language? Etymology of the word truant? Give me a day, sir, and I shall digest, consume, surround myself with this material, and I will store it among the other fine truffles of information in my head.

Enter parser-generators. The VH1 true story of yacc and lex. "Ian, you know automata, right," I'll think to myself. This subject, unlike the aforementioned, is like the rock-climbing wall with slippery pegs. Kwowing the why of compilers and parser-generators isn't just documented in a HOWTO somewhere. This subject, unlike the aforementioned, requires a significant guru, to give me a hand from over the top of the rock-climbing wall. This subject isn't just Ajax or knowing why you can modify a shell script while it's running -- this is bad-ass knowledge.

Programming Languages. Algorithms. Automata. Operating systems. Databases. Compilers. Grab your college/university's Computer Science course listing and look at the bottom half. This is bad-ass knowledge. This is the stuff that, when known, lets one understand not just how, but why.

I'm confident that I'll always be able to get the how; I'm scared that I don't know enough why.

For various reasons that I won't get into here, I switched from a Computer Science degree to a dual major in Computer Science and Cognitive Psychology. The reasons, however, do not outweigh the fact that I won't be able to take a compilers, algorithms or operating systems class. My fault? Likely.

A lot of my education has been memorize. Ask me why drive reduction theory is silly. Or characteristics of a well-managed team. Or how it's possible to calculate the size of a distant object at the other end of the galaxy. These are all things I've had to memorize and, for the longest time, I mistakingly thought that, in this field, piles of facts was the path to go.

Here's the solution, assuming that time-travel is possible. Future Ian borrows a time machine and warps back in time to Early Ian, just as he's entered college. Future Ian sits Past Ian down and asks, "You want to be a bad-ass computer science ninja, right?" Past Ian nods even though the questions was obviously rhetorical. "Don't switch majors. Take all the hard CS classes you can get your hands on. It's not about learning lots of things, it's about learning why things are." Past Ian nods despite obvious time-continuum paradoxes. Before Future Ian warps out he leaves some cliche last advice: "Oh, and when you're offered tons of peach schnapps, don't make a night out of it. You'll get sick and lose a pair of pants."