dws's Journal http://use.perl.org/~dws/journal/ dws's use Perl Journal en-us use Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners. 2012-01-25T02:06:29+00:00 pudge pudge@perl.org Technology hourly 1 1970-01-01T00:00+00:00 dws's Journal http://use.perl.org/images/topics/useperl.gif http://use.perl.org/~dws/journal/ Sufficiently universal access http://use.perl.org/~dws/journal/28737?from=rss <p> In the finally-got-off-my-butt-and-did-it department, I now have a network drive that all of the computers here can talk to. The NSLU2 (network storage minus the storage) I bought two months back has been sitting on my desk with a big USB drive plugged in (under the desk). The NSLU2 runs samba. The laptops saw it right away. The last, lingering step was to get the Linux boxes talking to it. Done. This is the first time since I've owned more than one computer that they've all been able to directly share storage. No more sneaker net or bouncing files off a remote server. The network drive needs its own backup, but that's the easy part. </p><p> Everyone is now safely (cough) backed up, and I can get on with the Ubuntu upgrade that my desktop has been nagging me about for weeks. </p> dws 2006-02-20T02:14:16+00:00 journal GIFs or PNGs without pain? Tell me! http://use.perl.org/~dws/journal/28655?from=rss <p> Is there portable Perl somewhere for producing GIFs or PNGs? </p><p> Every month or so, usually in different environments, I need to produce data-drive graphic for some web app. If I'm lucky (which has been about 25% of the time), GD will be installed. If I'm not lucky (again, about 25% of the time), I either can't acquire admin rights on the box, or can't marshall all of the pieces needed to build GD, and then burn up time doing some kludgey one-off. The in-between 50% just takes time. </p><p> This time, I scratched the itch by finding a half a page of pure Ruby for generating PNGs, and did the data analysis and graph production in another two pages of Ruby. </p><p> There's gotta be a way to painlessly convert bits to some web-friendly image format in Perl. </p> dws 2006-02-12T21:56:45+00:00 journal Perl in/on the small http://use.perl.org/~dws/journal/28172?from=rss <p> For the holidays, I gave myself an <a href="http://www1.linksys.com/products/product.asp?prid=640&amp;scid=43">NSLU2</a>, (AKA "Slug"), which a small, fanless Network Attached Storage device minus the storage, which attaches via USB. (The picture doesn't do it justice; the Slug is about the size of a moderately thick paperback book.) NSLU2s go for about $85 USD if you shop around. </p><p> The same folks who cracked the Linksys Router also figured out how to flash a new Linux into the NSLU2, yielding a tiny (albeit slow) Linux box that draws about 9 Watts and is absolutely silent. There's a thriving <a href="http://www.nslu2-linux.org/">hacker community</a>, which has come up with several hardward mods, including which resistor to clip to double the lock speed of the ARM chip from 133Mhz to a whopping 266Mhz. </p><p> I'm going to migrate several periodic tasks (e.g., network backups, periodic scraping of some web pages, etc.) onto mine, which will further plans for a silent home office by freeing up an older, larger, noisier box. </p> dws 2005-12-30T17:44:40+00:00 journal The power is out... http://use.perl.org/~dws/journal/28047?from=rss <p><nobr> <wbr></nobr>... but the home network and wireless are still up. </p><p> Go, Uninterruptable Power Supply! </p><p> It's not too late to ask Santa for one (or two). One of mine is getting on in years, so I'll take advantage of post holidays sales to replace it with something beefier. </p> dws 2005-12-18T17:24:48+00:00 journal Replace Me! (Bay Area Perl/XP Job) http://use.perl.org/~dws/journal/28006?from=rss <p> I'm making a career change. As a consequence, a <a href="http://jobs.perl.org/job/3421">position is opening</a> up at <a href="http://www.airwave.com/">AirWave Wireless</a> in San Mateo. </p><p> AirWave is a late stage startup with customers who love the product. (Here's a <a href="http://www.mobilehealthdata.com/article.cfm?articleid=1729">recent product review</a>.) The team has been doing Agile (XP, tuned for local conditions; serious Test-Driven Development) for several years. As one indicator, we have 25% more test code by volume than we do product code. It's the best, most productive team of this size that I've ever worked with, and I'll miss them. If you're looking for a great team to do great Perl work, drop 'em a line, or feel free to ask me questions out-of-band (dws at davewsmith dot com). </p> dws 2005-12-15T17:20:21+00:00 journal Familiarity http://use.perl.org/~dws/journal/27436?from=rss <p> You know you've worked with someone long enough when you can tell from a subtle change in their tone of voice that they're about to speak a silly idea. </p> dws 2005-11-03T22:01:06+00:00 journal Signs that you need a vacation http://use.perl.org/~dws/journal/25591?from=rss When the alarm went off this morning, I went into a waking dream where a pleasant female voice was reading CVS checkin comments in place of the morning news. dws 2005-07-08T21:39:50+00:00 journal How I spent my long weekend http://use.perl.org/~dws/journal/25535?from=rss I'm getting too old to be renting jackhammers, but <i>damn</i> that was fun. dws 2005-07-06T02:03:19+00:00 journal An 8-line start, and then tiny steps http://use.perl.org/~dws/journal/24623?from=rss <p> It's surprising how far you can get in one day by starting with </p><blockquote><div><p> <tt>#!/usr/bin/perl -w<br>use strict;<br>use Test;<br>use WWW::Mechanize;<br> <br>use constant STARTING_URL =&gt; 'http://localhost//notyetbuilt.cgi';<br> <br>my $agent = WWW::Mechanize-&gt;new();<br>$agent-&gt;get(STARTING_URL);<br>ok( $agent-&gt;status, 200 );</tt></p></div> </blockquote><p> and then writing just enough CGI code to make that first little test pass, and then by writing the next test, and then writing just enough code to make <i>that</i> pass, and so on. Tiny step by tiny step. </p><p> By the end of the day, what looked like two days of work is nearly done, with good functional test coverage. Add unit tests on the other side, as appropriate. </p><p> Replace <tt>Test</tt> with <tt>Test::Simple</tt> or <tt>Test::More</tt> as your preferences dictate. </p><p> A shout out to <a href="http://use.perl.org/~petdance/">Andy</a> for a fine piece of work on <tt>WWW::Mechanize</tt>, which made quick work of driving form development. </p> dws 2005-05-11T01:41:10+00:00 journal "But that couldn't possibly break!" http://use.perl.org/~dws/journal/24440?from=rss <p> We had one of those "This can't possible fail, we didn't change code anywhere near there!" unit test failures today while doing a full test suite run after spending the day on a story card. The failing test file hadn't been touched for a while, nor had the code it was testing. But when I ran the test file by hand, it passed. Uh oh. </p><p> Long, hard experience has shown that 98% of the time this happens, there's some obscure interaction that's been missed or forgotten, or some other test just happens to leave the system in just the right (wrong) state to expose some wacky interaction. </p><p> Then there's the other 2%. </p><p> It turns out that our test harness uses <tt>file</tt> to determine how to run an individual test file. (Most of our tests are in perl scripts; a small few are something else.) And a nightly automatic update had just upgraded the database that <tt>file</tt> uses. Now, if 0x200 bytes into a file the characters "MP" appear, <tt>file</tt> identifies the file as some Apple block file thing, regardless of whether the file starts with <tt>#!/usr/bin/perl</tt>. And on this one particular test script, 512 bytes into the file... </p> dws 2005-04-29T07:01:03+00:00 journal Riddle me this http://use.perl.org/~dws/journal/24337?from=rss <p> Why, on a small bare-bones system that doesn't have room for a floppy in the case, or even a connector for a floppy on the motherboard, does the manual insist on making a bootable floppy to upgrade the BIOS? </p><p> I suspect blind copy/paste behavior on the part of the manual's authors. </p> dws 2005-04-23T18:59:09+00:00 journal Fighting back chaos, one shelf at a time http://use.perl.org/~dws/journal/24336?from=rss <p> The project to make my study livable has been growing ever more complex, with simplification just over the horizon. The floor is still stacked with stuff that needs organizing, though it's now in plastic tubs. Shelves have been acquired, and will get bolted to the wall as soon as I can pull the desk back. (And the desk will go on 1" risers when it gets pushed back forward.) This provides the opportunity to rewires the rat's nest behind the desk, or at least use cable ties to contain the mess. </p><p> Getting momentum on this project has been hard. It's been easier to just learn to live with the mess. One driver has been getting rid of old tower computers and big monitors, replacing them with a cute little mini-itx and mATX systems that share a flat panel monitor. That freed up space, creating a much-needed small win in the fight, and clearing a path for the next round. </p> dws 2005-04-23T18:54:33+00:00 journal An unexpected leak http://use.perl.org/~dws/journal/24150?from=rss <p> DBD::Pg 1.31 leaks memory when you rebind values (e.g., when you execute a second query with values). When you're re-executing a prepared query a small number of times on a slow, periodic basis, this can be tricky to track down. </p><p> Fedora Core 3 ships with 1.32, which fixes that problem. </p> dws 2005-04-12T19:56:11+00:00 journal Kudos to Newegg http://use.perl.org/~dws/journal/24148?from=rss I'm liking Newegg.com more and more. Their emailed invoice includes the serial numbers for all of the components I ordered, warranty contact info for parts Newegg doesn't warranty, warranty reminders for parts they do, and FedEx tracking links. Go, e-commerce! dws 2005-04-12T19:51:25+00:00 journal Apache and Alias, Ambushed! http://use.perl.org/~dws/journal/23846?from=rss <p> Running FC3? Had trouble getting <tt>Alias</tt> working with Apache when pointing outside of<nobr> <wbr></nobr><tt>/var/www</tt>? Three hours of my life got burned up figuring this one out. Story <a href="http://www.davewsmith.com/blog/index.php/fedora-ambushes-apache.html">here</a>. </p> dws 2005-03-25T20:21:35+00:00 journal Sic Transit Hardwarium Mundi http://use.perl.org/~dws/journal/23752?from=rss <p> There's a <a href="http://www.crc.org/">warehouse</a> in Sunnyvale where old computers go to retire. It's an impressive place, with stack and stacks of old equipment, some of which gets resold, some fixed up and donated to worthy causes, and the rest recycled. I went today to donate two old (but working!) 15" monitors, after failing entirely to give them away. From the size of today's pile of monitors, a dozen other people had the same idea. </p><p> I'll make another trip there next week after scrubbing an old P-II of any possible blackmail material. I was considering salvaging the case and a few parts and rebuilding, but after pricing out the replacement motherboards <i>et al.</i>, it's less expensive to buy new, not that I need more hardware. </p> dws 2005-03-20T06:05:41+00:00 journal Cough, cough, sneeze http://use.perl.org/~dws/journal/23702?from=rss <p> There are two coughs and a sneeze that have been playing slow-motion ping-pong around our office for the past several months, occassionally knocking a coworker out for a few days. Nature and the weather have contributed recently by dumping a visible amount pollen into the air. </p><p> Current favorites are Ricola Elderberry cough drops and "Emer'gen-C" fizzy drink mix. I'm considering buying stock. </p> dws 2005-03-17T18:59:58+00:00 journal Late-Night Configuration Problems http://use.perl.org/~dws/journal/23626?from=rss <p>Previously:</p><ul> <li>Install Fedora Core 3. Turn off a bunch of services. <b>done</b> </li><li>Setup Samba and move a bunch of stuff off of other boxes. <b>done</b> </li><li>Turn on and configure Apache. <b>done</b> </li><li>Configure the router to port forward HTTP and SSH to the new box. Test. <b>done</b></li> <li>Setup a skeleton "nothing to see here" web page and test. <b>done</b> </li><li>Setup some other random web stuff and test. <b>done</b> </li><li>Get dynamic DNS set up through dyndns.org, and teach the router about it. Test. <b>done</b> </li></ul><p>Picking up the story again last night at 1 AM:</p><ul> <li>Setup and configure MySQL. <b>done</b> </li><li>Migrate databases off of the old box. <b>done</b> </li><li>Generate SSL cert for Apache, restart, and test locally. <b>done</b> </li><li>Setup a virtual domain for dynamic DNS. Test locally. <b>done</b> </li><li>Configure the router to also port forward HTTPS. Test... Connection refused. Hm... Double-check the router to make sure I didn't get dyslexic with the HTTPS port number. Nope. Check the httpd logs. Nothing. Restart Apache and try again. http works; https doesn't. Triple check everything. Nada. <b>wtf?</b> </li></ul><p> The punchline, found at 2 AM after much flailing, was in<nobr> <wbr></nobr><tt>/etc/sysconfig/iptables</tt>, which I'd touched once to get Samba working, and had then forgotten about. My FC3 install had ports unblocked for HTTP and SSH, but not HTTPS. Go figure. Add a line to support tcp on port 443, restart iptables, and test. Ah. Much better. Now I can sleep the sleep of those who can securely serve up a "nothing to see here" page from a home linux box. </p> dws 2005-03-12T19:58:55+00:00 journal Tools hiding in plain sight http://use.perl.org/~dws/journal/23262?from=rss <p> Years back I bought a solar powered calculator that does hex and octal. (Actually, I bought six, since they were on closeout sale for a couple of bucks each. I gave four to coworkers, and took one of the remaining two home.) Whenever I run into one of those bit pattern problems (like funky subnet masks), I reach for the calculator. </p><p> This week, while working on some problem that required radix conversion, the teamate I was pairing with reached for... the Windows calculator. The words "but<nobr> <wbr></nobr>..." had nearly made it out my mouth when he pulled down the View menu and selected Scientific. Suddenly, there was a calculator that could do radix conversions. Right there in front of me where I'd never noticed it, because I'd never had the need or urge (or curiosity) to pull down the View menu to see what the options were. </p><p> Makes me wonder what else is hiding in plain sight. </p> dws 2005-02-20T00:50:50+00:00 journal Time flies like a banana http://use.perl.org/~dws/journal/23247?from=rss <blockquote><div><p> <i>Time is nature's way to keep everything from happening all at once.<br> John Wheeler</i></p></div> </blockquote><p> No, Time is nature's way to keep everything <b>wrong</b> from happening all at once. And right now, nature needs some debugging. While waiting to hear from the Volkswagen dealer about whether they could get the part they needed to start fixing the car (toxic fumes out of the heater vents--it's what's for breakfast!), my cell phone took a dive into a puddle. After missing the train. While recovering from a mild flu. </p><p> They didn't have the part. </p><p> <b>But later...</b> </p><p> The VW dealer got the part and fixed the car under warranty, costing me a grand total of $5.21 to put gas in the rental car they sprang for. And the cellphone survived the dunking. </p><p> Sometimes time just gets things bunched up. </p> dws 2005-02-18T17:42:47+00:00 journal Overheard in passing http://use.perl.org/~dws/journal/23168?from=rss <p> Outside the neighborhood coffee shop. Two guys in their 70's, one wearing a flannel shirt and a straw hat. The other carrying a walking stick. The fellow with the hat is speaking.</p><blockquote><div><p>"You need a switch, not a hub."</p></div> </blockquote><p> I love living in Silicon Valley. </p> dws 2005-02-13T05:03:13+00:00 journal That other kind of JOIN http://use.perl.org/~dws/journal/23167?from=rss <p> I've been doing database-related work for most of the last 15+ years, yet last week was only the second time I've needed to use a <small>FULL OUTER JOIN</small> in production code. </p><p> We use <small>LEFT JOIN</small> as an interview question to gauge a candidate's knowledge of SQL, but this was one of those "we may get some from here, we may get some from there, but we need to count either as one" situations (with a few twists) were a <small>LEFT JOIN</small> wasn't sufficient, and I didn't want to introduce additional queries into this particular piece of code. As Holmes would say, it was a "three pipe problem." Nailing it was the high point to an otherwise good week. </p> dws 2005-02-13T04:53:01+00:00 journal Weekend Archaeology http://use.perl.org/~dws/journal/23055?from=rss <p> This weekend I bought a bunch of mid-sized plastic tubs from the local storage place, and went on a cleaning binge in my study. Amoung the random things uncovered were the receipts for the 300Mhz Celeron box I built in '99 "to carry me into the next century". The receipt noted $190 USD for an 8Gb Maxtor drive. Last week I picked up 160Gb for $60. That's ~$25/Gb to &lt;$0.50/Gb in 6 years. Not bad. </p><p> The plastic tubs are clear, so it'll be easier to find stuff in the closet. So far I have one tub filled with power strips and cords, and another full of Cat5 and phone lines. I suspect I'll never need most of 'em. The SCSI cables went into the give-way pile. </p> dws 2005-02-06T23:53:35+00:00 journal Bit-scraping Car Talk http://use.perl.org/~dws/journal/22950?from=rss <p> One of the high points of the weekend used to be listening to <a href="http://www.cartalk.com/">Car Talk</a> while driving. My travel pattern has changed since moving, and I almost always miss the show now. I had rigged up an FM-radio to audio-in connection to let me capture<nobr> <wbr></nobr>.wav files to burn to CD, but this never seemed to work out quite right, and that was back before I had a USB MP3 player. </p><p>Car Talk keeps the most recent show available as a RealAudio feed. Bits. Hm... </p><p> Hypothetically, then, and with the help of a co-worker who knows the sekret of getting mplayer installed on Linux (configure yum to point to freshrpms.net, import their PGP key, use yum to install mplayer, and then figure out how to download and install the essential codecs), one could threw together a script that scrapes the Car Talk site for links to the ReadAudio files, streams them disk, converts them from<nobr> <wbr></nobr>.rm to<nobr> <wbr></nobr>.wav, and finally (via lame) to an<nobr> <wbr></nobr>.mp3 in a Samba directory named for the week. From there, it would be a quick copy into an MP3 player, and from there to a happier commute. </p><p> It would be a slow process (the RealAudio feed seems to be throttled), but that's what a 2 AM cron job is for. The basic incantation for ripping a segment of the show would probably look something like </p><blockquote><div><p> <tt>$rtsp =<nobr> <wbr></nobr>... link to real audio stream<nobr> <wbr></nobr>...<br>mplayer -noframedrop -dumpfile tmp.rm \<br> -dumpstream&nbsp; $rtsp<br>mplayer -ao pcm -aofile tmp.wav -vo \<br> -null -vc dummy --playlist tmp.rm<br>lame -h -b 128 tmp.wav segment$n.mp3</tt></p></div> </blockquote><p> I'd be surpised if this same recipe didn't apply to lots of interesting feeds. </p> dws 2005-01-31T09:53:39+00:00 journal A Sloooow Install http://use.perl.org/~dws/journal/22607?from=rss <p> Installing and configuring Linux is something I do infrequently enough to forget a lot of little details, like "This is going to be a headless system. How do I <i>not</i> start X?" (Answer: Edit<nobr> <wbr></nobr><tt>/etc/inittab</tt> and change <tt>runlevel</tt> to 3) and "What are all of these strange processes listening on sockets, and how to I shut them down/off?" </p><p> Moving bits off to a backup server before repartitioning (to make a proper<nobr> <wbr></nobr><tt>/home</tt> partition this time) took longer than expected, largely because we discovered that the switch between the boxes was (a) 10Mbit, and (b) flakey. Crossover cable to the rescue. </p><p> Now I'm waiting while the CDs spin, after which I'll struggle through more small stuff I've forgotten, like how to set up MySQL and PostgreSql, and which settings in <tt>httpd.conf</tt> need tweaking. Then comes the fun part: Sorting out what's changed in <tt>mod_perl</tt> land between RH8 and FC3. </p><p> Part of me thinks I should do this more often. </p> dws 2005-01-07T02:34:28+00:00 journal Process Failures That Smell http://use.perl.org/~dws/journal/22451?from=rss <p> Once you've got the pie process down, and are producing repeatably outstanding pumpkin pies, don't adjust the oven temperature after your wife has discovered that the oven has been cooking 25F&deg; low. Stick with what works. "But the recipe says..." isn't a winning move. Trust me on this. </p><p> There are parallels here to software development, I'm sure. </p> dws 2004-12-25T02:31:16+00:00 journal Bizarre Bugs on a Monday Morning http://use.perl.org/~dws/journal/22393?from=rss <p> This morning's expedition into the bizzare involved tracking down an obscure interaction between mod_perl 1.99 and <tt>CGI::Simple.</tt> Normally, these two get along just fine, though we noticed a while back that file uploads would cause later users of the same Apache process (e.g., some <i>other</i> browser) to lose URI arguments. (Finding this involved some fine detective work and a bit of luck.) The fix at the time was to note that a <tt>multipart/form-data</tt> post had just been handled, then rflush the request object and exit the process. File uploads were infrequent in our app, so forcing Apache to start a new process was no big deal. </p><p> Time passes, and along comes a feature that requires keeping the connection alive. Debugging ensues. </p><p> When the dust settled, it appears that there are two problems that manage to avoid each other <i>almost</i> all of the time. The first is that the Apache object hangs on to the request type (which is normally undefined, but will be <tt>multipart/form-data</tt> when a correctly coded file upload happens), and reports this as the type for subsequent requests, including GETs. An oops, but a mostly benign one. </p><p> The complementary problem, in <tt>CGI::Simple</tt>, is that requests with a type of <tt>multipart/form-data</tt> get special handling, <i>regardless of the request method</i>. If the request doesn't include arguments, nobody notices. But if there are URI arguments, they get ignored in favor of a non-existent form. An oops, and one that would occassional cause our app to squawk. </p><p> I suggested a fix in the bug report: only do the <tt>multipart/form-data</tt> handling if the request method is POST. </p><p> Debugging Apache processes isn't fun, but it beats late holiday shopping. </p> dws 2004-12-21T08:31:12+00:00 journal Travel Trivia Redux http://use.perl.org/~dws/journal/22054?from=rss <p> New Mexico really does have an <a href="http://www.itsatrip.org/abqinfo/faq/">Official State Question</a>. The question, which you'll get asked in many places when you order local food, is "red or green?" The question asks which of the two common chile pepper sauces you'd like with your food. (New Mexico offers some truly yummy chile peppers, which turn into truly yummy sauces.) The common responses are "red", "green", and "Christmas". The latter response asks for a bit of each. Countering with "which is hotter|better today?" is also acceptable. </p><p> No points awarded. </p> dws 2004-11-29T19:15:07+00:00 journal Monday Morning. All Tests Pass. Blah. http://use.perl.org/~dws/journal/22053?from=rss <p> I am really, <i>really</i> wishing that I'd left myself a failing unit test before the 4-day Thanksgiving weekend. Picking up the pieces this morning and answering "O.K., what's next?" took too long, even though I left a checklist of what to do next. A failing unit test might have jump-started the process by providing instant focus. </p> dws 2004-11-29T18:55:54+00:00 journal Travel Trivia Quiz http://use.perl.org/~dws/journal/21928?from=rss <p> For 25 points, what is the State Question for New Mexico, and what are the three usual answers. </p><p> No googling, please. </p><p> <b>O.K.,</b> I guess this is a hard one, so here's a hint: The question offers an alternative between two colors. 15 points for the 3 standard responses. </p> dws 2004-11-20T01:05:26+00:00 journal