August 22, 2005 at 7:41 pm
· Filed under imported
Well this is stupid. I recently rebuilt the fence in my backyard. In
doing so, I took all the nails out of the boards and separated the
untreated cedar from the treated posts and concrete anchors. I then
took the posts and anchors to the transfer station (”the dump”) and
cut the boards into short planks and intended to have a beach fire
party over the summer. Now I see that
href="http://www.ci.seattle.wa.us/parks/parkspaces/GoldenGardens/fire.htm">city
policy forbids anything but “firewood” in the fire pits. Huh? But
I’ve got clean, untreated cedar - shouldn’t that be fine? I called the
parks office and now I understand that the city decided that they
don’t care if I clean my wood (ahem) or that I’m not burning treated
boards because letting me do so opens the floodgates for every dumbass
in town to show up with wood with enough arsenic to kill everybody at
the beach and who’ll inevitably whine “but they’s burnin’ fences,
too!” Oh well - anybody want a bunch of old, short planks of cedar?
Permalink
August 22, 2005 at 8:49 am
· Filed under imported
Adam (whose weblog requires I log in to leave comments directly)
href="http://adammonsen.com/blog/index.php/2005/08/20/factorial_challenge_python_perl_ruby_and">notices
that python and ruby’s performance seem great while C is (naturally)
very fast. Perl is in the mix, too, and he kindly doesn’t tear it
apart though based on the numbers he would seem justified in doing
so. I wondered if perl was realy that slow so I decided to take
a look…
Let’s start with the listing:
#!/usr/bin/perl
# Computes factorial for number passed as first command
# line argument.
use Math::BigInt lib => 'GMP';
$b = Math::BigInt->new([0]);
print $b->bfac(),"n";
This yields some pretty miserable numbers (mine):
bash-2.05b$ time perl facta.pl 40
815915283247897734345611269596115894272000000000
real 0m0.056s
user 0m0.050s
sys 0m0.010s
Yowza! But what if we don’t import the whole 140k Math::BigInt
namespace and new up one of its objects? That brings us a lot closer
to apples and apples…
sub fact {
if ($_[0] == 0) {
return 1;
} else {
return ($_[0] * fact($_[0] - 1));
}
}
print fact ([0]);
Show us what you’ve got, Randall!
bash-2.05b$ time perl factp.pl 40
8.15915283247898e+47
real 0m0.003s
user 0m0.000s
sys 0m0.000s
Bitchin! My moral is not “perl is just as fast as ruby or python” –
nor “perl gracefully handles big numbers just like python and ruby”,
because 5.8 doesn’t, though perl 6, which would be the ruby or python
contemporary, may — but that “a huge feature-rich class is usually
slower than a single dedicated routine.”
Permalink
August 22, 2005 at 6:52 am
· Filed under imported
I spent some quality time with my favorite music player,
href="http://www.foobar2000.com/">foobar2000 (or “:D” as it’s
affectionately known amongst the geeks who a) tolerate using software
named “foobar2000″ and b) highly prize content over style) cleaning up
the tags on all my electronic music. I thought I’d done this ages ago
but evidently I had not.
My music workflow (which I’m pretty happy with) goes like this
- Download it to some folder
- If it isn’t tagged, tag it. Usually I can use foobar’s “freedb >
Get Tags” function to automagically retrieve the tags for any album,
but if the album is not found, I can do one or all of the following in
one batch operation: set the artist (”Kinski”), set the album (”Alpine
Static”), auto-track number, guess value from filename (usually
following a pattern something like: “%tracknumber% - %title%”). Now
it’s tagged.
- Once it’s tagged, use foobar’s mass renamer to rename into the
stage 01 (”renamed”) directory like so:
(((%artist%,_, )),unknown
artist)\(%album%,unknown
album)\(%tracknumber%,(%tracknumber%,(%tracknumber%,2),__)-((%title%,_,
)),%_filename%). That’s pretty hairy so commenting to show what’s
going on (short story: “artist\album\tracknumber-title”):
(
((%artist%,_, )), # artist based on tag, first words capitalized...
unknown artist) # ...or "unknown artist" if untagged
# directory delimiter
(
%album%, # album based on tag...
unknown album) # or "unknown album"
# directory delimiter
(
%tracknumber%, # if we have a tracknumber...
( # then...
%tracknumber%, # ...if the tracknumber tag is set
(%tracknumber%,2), # tracknumber, padded to two chars ("2" becomes "02")
__ # else two underscores
)
- # hyphen
((%title%,_, )), # title from tag, capitalized, with _'s turned to spaces
%_filename%) # else just use the filename
- Now that it’s all renamed, I load it back into foobar and can play
it or convert it. If I’m ripping from a CD, this is the first step to
adding it to my collection and I need to be careful that the
formatting string use (%_diskwriter_index%,2) since the
%tracknumber% doesn’t work like I’d expect from CDs. My converter
settings are to generate ogg vorbis, usually at quality 3 which
creates files that are a lot smaller than comparable quality
mp3’s. This renaming moves the files from stage 01 (”renamed”) to
stage 02 (”processed/new”).
- Finally at some later date, it’s no longer new and I move it to
the stage 03 (”processed/collection”) permanent collection.
Normally that works great, but somehow a bunch of stuff in my
processed collection wasn’t tagged. How do I deal with this? Foobar
to the rescue, again!
My music winds up in the typical folder structure everybody uses:
03-archived\Husker Du\Ticket to Ride.ogg
03-archived\Husker Du\Metal Circus\01-Real World.ogg
Where album tracks collected together in “artist\album” and
miscellaneous tracks without tracknumbers are in the “artist”
folder. To get everything cleaned up, I set up a foobar script that
runs four actions to get the common four tags set:
- ALBUM =
(((%_path%,3),03-archived),(%_path%),Unknown)
- album is either the current directory of the file, or “unknown” if
this is a non-album style miscellaneous track
- ARTIST =
(((%_path%,3),03-archived),(%_path%,2),(%_path%))
- artist is either the current directory of the file for non-album
tracks, or the directory two levels up
- TRACKNUMBER =
((%_filename%,-),(%_filename%,1,((%_filename%,-),1)),1)
- tracknumber is set to “everything up through the hyphen” if there is
a hyphen, or 1 (this is broken but I can’t find any way using foobar’s
tagging reference to ensure that “everything up through the hyphen” is numeric,
but it’s right 95% of the time)
- TITLE =
(%title%,((%_filename%,-),(%_filename%,(1,(%_filename%,-)),(%_filename%)),%_filename%))
- title leaves the tag alone if it’s already set, otherwise it uses
everything after the first hyphen (this is also imperfect but also
almost always right).
Now my whole catalog is neatly tagged and organized again. Foobar is
the perl of music players: it makes easy things easy (well, mostly
easy) and hard things possible.
Permalink