Tuesday, December 16, 2008

Using caret '^' in Windows batch files

The caret '^' character serves two purposes in Windows batch files:

1. line continuations:
~~~
@echo off

dir ^
/ad ^
c:\temp
~~~~
results in dir /ad c:\temp, which lists only the directories in C:\temp. (Thanks to SteveGTR for that example.)

2. Escaping reserved shell characters & | ( < > ^. Use a preceding caret to escape and print the character:



echo this pipe will print ^| but this one won't |
echo and this will print one caret ^^

Tuesday, December 2, 2008

Monotype font for Wordpress "Write Post" text area

I like to use a monotype font (e.g. Courier) when I edit my blog posts in HTML mode. Wordpress seems to default to a proportional font. Try as I might, I couldn't find an easy way to change this from the WP admin pages, so I resorted to hacking the responsible stylesheet, /wp-admin/wp-admin.css, adding the font-family declaration for the #content text area:


editorcontainer #content {
font-family: Courier New, Courier, sans-serif;
padding: 0;
line-height: 150%;
border: 0 none;
outline: none;
}

Friday, September 12, 2008

Using an STL list with current and next iterators

General algorithm for using a "current" and a "next" iterator on an STL list, which doesn't provide a convenient next() method (random-access containers such as vector do):


std::list<Foo>::iterator currIter, nextIter;

currIter = list.begin();

while(currIter != list.end())
{
currIter->doStuff(); // do something with the curr item

nextIter = ++currIter; //advance the iter and set it to next
if(nextIter != list.end()) // still safe to use next item
{
nextIter->doStuff(); // do something with the next item
}
}

Thursday, September 4, 2008

TLDs for TLC

Thanks to "Jon", who pointed out that the Top Level Domain (TLD) example.org is reserved for those times when you need a bogus domain for testing or documentation. Go ahead, click it!

Even better, under RFC 2606 four TLDs are reserved for your testing and documentation pleasure. To quote the RFC:






















TLDPurpose
.testtesting of current or new DNS related code
.exampledocumentation or examples
.invalidonline construction of domain names that are sure
to be invalid and which it is obvious at a glance are invalid
.localhostloop back

Friday, August 22, 2008

Railsconf '08 in 36 minutes

Thanks to Gregg Pollack of Rails Envy for posting Railsconf in 36 minutes for those of us who couldn't attend Railsconf '08 this year.

Sunday, August 17, 2008

Send in the Clones, there ought to be clones...

Sad to say, Star Wars: The Clone Wars was a letdown. The Star Wars saga is a thread running through my life, spanning from my teenage enthusiasm for science fiction, galactic empires and space travel to my middle-aged enthusiasm for world history, the Roman Empire and politics, so I feel a real connection to the characters, the story of their lives and the universe they inhabit. But this latest film just doesn't generate the "gee-whiz" feeling I got when I saw the first Star Wars film (Episode IV: A New Hope) in 1977, or the rich, dramatic overtones and sense of "closing the circle" projected in the last film, Episode III: Revenge of the Sith.



Cinematically, the lighting, camera angles and timing of Clone Wars evoked the style of the '40s cliffhangers from which a young George Lucas derived the whole Star Wars oeuvre. I especially liked the artist's-brush-like textures of the surfaces, and the almost sculptural feel of the character's facial expressions. The droids, even though we've seen them depicted in lifelike CG in the preceding three episodes, came across with the airbrushed sheen of '50s sci-fi star Robbie the Robot, especially the dwarf spider and super battle droids.



But the story line was thin and the plot ridiculously childish, especially after the high drama of Anikin's transformation into Darth Vader in Episode III. The story boils down to a long, drawn out sequence of battle scenes that revolve around rescuing Jabba the Hutt's grotesquely endearing child.



Where are the grand galaxy-spanning themes and character development of the previous episodes? The character of Asoka, the four-foot nothing Padawan "youngling" who tags after Anikin, is his guilty conscience annoyingly brought to life - "But remember, Sky Guy, your duty is to rescue this ugly but adorable Hutt baby..." or words to that effect. Asajj Ventress, who is perhaps Darth Maul's second cousin, reminded me of the Evil Queen in Disney's Snow White, but with a handy double-bladed light-saber.



Oh well, my 11-year old and his pal got a few giggles out of the baby Hutt's facial mugging. He'll probably turn up as a Burger King kid's meal prize. Let's hope not.

Gotta Get Yer Clone On!

Going to take my 11 year-old to see Star Wars: The Clone Wars this afternoon. Not so sure I'll like it as animated movie, although the trailer looked pretty good, but I've been an off-and-on fan of the franchise since I saw the original Star Wars, long ago in a theatre not so far away - before there was digital revision, DVDs, bit torrents... ah, the Galaxy isn't what it once was, young Jedi.