jlm-blog
~jlm

24-Nov-2015

twitcode #2: stream filter to decode MIME

Filed under: programming — jlm @ 12:12

Messing around with some mail handling scripts, I was surprised I didn’t find any good ways to decode MIME as a stream filter. Ten minutes later, I have 13 lines of Perl which do it in 201 characters in my normal non-terse style. It’s great for normal use, but a tiny bit of golfing fits it in a tweet’s 140-character limit:

$ cat mime_decode.pl
#!/usr/bin/perl -w
use strict; use utf8; use MIME::WordDecoder; 
binmode(STDOUT, ":utf8");
while (<>) { print mime_to_perl_string($_); }
$ wc mime_decode.pl
  4  16 137 mime_decode.pl

Good thing there was already a method which does all the real work…

21-Nov-2015

If business hours are 9–5, noon should be 1 PM

Filed under: time — jlm @ 08:36

Today the sun rose at 06:55. I rose at 07:15, being one of those morning persons who madden the folks who go to bed at 03:00, by which time I’ve been conked out fo[u]r hours. Yep, even being one of “those people”, I still missed the sunrise (and that’s normal for me).

Yet, today’s sunset… it’s at 16:53! The “day” closes before the banks do! Now, this crazy skewing of things isn’t because western California is geographically displaced from the reference meridian: high (“solar”) noon here is 11:54. If we’re only 6 minutes displaced from solar time, how come there’s so much more daylight in the morning than the evening? It’s because our standard “business hours” are shifted away from the center. Starting a working day at 09:00 and ending it at 17:00 has three hours before noon but five hours after it. If we shifted our clocks so that solar noon was ∼13:00 (which is what we do for the majority of the year which has DST in effect) then things would be more sensible: about four working hours before solar noon (09:00 – 13:00) and about four after it (13:00 – 17:00). The sun would have risen today at 07:55 and set at 17:53, and wouldn’t everyone be happier with that? Why don’t we just have “daylight savings time” in effect year-round? And then we’d also get the bonus of not having to move our clocks an hour twice a year. And of not having motorists on the roads with an hour less sleep than they’re used to on that one day in spring where DST starts and traffic accidents spike — which, come to think of it, is a far more important reason to quit doing a semiannual time change.

Powered by WordPress