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 ^
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:

.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.

Searching Ruby on Rails Docs just got a lot easier

Ruby on Rails is a big framework, with hundreds (thousands?) of methods and classes. Thanks to the clever folk at Nodeta, their new documentation app APIdock provides an easy-to-use search/browse interface to the whole of Rails documentation. To quote the site:

APIdock is a web app that provides a rich and usable interface for searching, perusing and improving the documentation of projects that are included in the app.

The site also provides documentation for Ruby and RSpec. Two really interesting features of the site are the versions bar graph and dynamic keyword search.

The versions bar graph along the top of each documentation page lets you "go back in time" to past versions of the documentation, by clicking on the version number. The green and red tabs indicate when and by how much the documentation changed for that version, which is handy when you're trying to figure out just when and in what way a particular method was changed or deprecated:

The dynamic keyword search displays a "find as you type" drop-down list from which you can select the relevant documentation page. A little pie graph icon, divided into five wedges, indicates by the number of filled-in wedges how much information is available for each item:

So for example there's a lot of information about the form_for helper, but very little about the apply_form_for_options! helper. If you get as lost in Rails as I do, or you're just wondering what is the difference between form_remote_for and remote_form_for (hint: the former is an alias for the latter).

Try it!

Sunday, August 3, 2008

Search RDoc from jEdit using FastRI

Tried out Search_Ruby_documentation_v0.4.bsh, Jim Morris' version of a macro for searching Ruby documentation from jEdit. The macro depends on FastRI.

Saturday, August 2, 2008

Ruby on Rails 2.1.x Tutorial

Found a "to the point" tutorial over on Tutorialspoint.com that covers just enough Ruby on Rails 2.1.x to get (re)started.

Friday, July 18, 2008

Secure your Wordpress Blog! Now!

Took some time last night to read through Miss 604's WordCamp Fraser Valley Liveblog to see what I'd missed. When I read Kulpreet's question, "... how many people with websites can go to www.theirwebsite.com/wp-content/plugins and actually see the list of plugins", I thought, Okay, I'll give that a try. Whoops! Lookit that! There they are! Plain as day!

First I read and applied many of the tips in the WordPress Security Whitepaper which Kulpreet mentioned in his talk. I also installed and ran the WordPress Scanner, a WP plugin (from the same guys who wrote the whitepaper) that performs a number of security checks of the site.

I also had a read through the 9 easy ways to secure your Wordpress blog.

So I am feeling a lot better now that no-one can browse my plugins directory, guess my admin user name, or any number of other nasty hacks.

You should do this too. Go. Do it now.

Monday, July 14, 2008

WordCamping in the Fraser Valley

Thanks to a tip from my co-worker Bernie, I will be attending WordCamp in Fraser Valley | BlueFur.com to get some tips and ideas for this ol' blog. Good roster of speakers lined up, too!
[Edit: didn't make it to the meeting, but Miss 604's liveblog of the event is almost as good as being there]

Wednesday, May 28, 2008

THE most rational argument for global climate change action, period

I was a bit put off by Al Gore's fear-mongering, high-rise graphs. He tried to scare us into change, while peering pensively into his MacBook, or whatever model it was (p.s. - Al was an Apple board member at the time!).

Meanwhile, this anonymous guy makes the most compelling argument for action I've ever heard. No rhetoric, no fear, just listen to it & you'll be spreading the word, just as I am:

Saturday, May 17, 2008

How to get Vista to show the "Command Prompt Here" on a Folder List

For many years, on many PCs running various versions of Windows NT, 2000 and XP, applying the "Command Prompt Here" Powertoy was one of the first things I would do to customize the vanilla Windows environment (i.e. make it usable). Right-click a folder, select "DOS Prompt Here" or "Command Prompt Here" from the context menu, and voila, a DOS box opens, set to the folder you clicked on:

I was happy to find the same feature already baked into Windows Vista: hold down the shift key, right-mouse click on any folder in the view pane, then select "Open Command Window Here" from the context menu:

But try the same trick on a folder in the Folder Tree, sorry, the command's not there:

For some reason, in their wisdom the Microsoft UI engineers chose to omit the command from this particular menu.

Quite by chance, I discovered that the choice is available on the File menu in Vista, but it's not invoked in the same way: instead, select a folder in folder list, hold down the shift key then left-click (i.e. normal click) the File menu:

Vista then displays "Open Command Window Here" at the top of the menu. Okay, happy to have it back, even if it's in a place I didn't expect...

Sunday, May 11, 2008

Deleting the .ncb file fixes Intellisense Crash in VS 2008 Express

Argh! Visual Studio 2008 Express was crashing every time I right-clicked on any code belonging to the C++ template class declaration I was writing for my C++ course assignment. Googling "2008 intellisense crash" turned up a link to an MSDN forum discussion about VS crash when updating intellisense, wherein one of the posters suggested deleting the .ncb file. Before launching my project for the nth time, I deleted the .ncb file. Voila! Intellisense works again.

Friday, May 2, 2008

It was SOOOO easy...

Man, I saw the link to the WordPress Automatic Upgrade Plugin, and I thought "Yeah, right, like this is really gonna work". But WP's been bugging me to upgrade from version 2.3.something every time I log in, and it's a Friday night, and I can't be bothered fishing around on the WordPress site to read up on how to do the upgrade, and it's a pain to do the backups, so I went for it.

And you know what? It Just Worked. Migrated all my stuff, kept all my plugins (although, it didn't reactivate them, maybe it wasn't supposed to, I don't remember). Otherwise, it was killer - good feedback, lotsa hand holding and reassurance along the way. Fetched, unpacked and installed the whole thing. Click, click click. And now I have a spiffy new WordPress 2.5.1 install.

Best part? It's free. I made a donation to Keith nonetheless, because he made the upgrade so easy, and to encourage him to keep up the good work. If you've been putting off a WP, hop on over to Keith's site, grab the plugin and try it. I think you'll be happy, and support him, too.

Thursday, May 1, 2008

More Pylons Stuff

As John promised,
Zero to 60 with Pylons in just minutes (Part 2) is online! Now if I only had the time to play with this stuff...

What did I just edit?

I checked out some code files from Razor (don't ask, we use an old CM system), created a couple of new ones, now I want to quickly double-check which of the thousands of files in our source tree are the ones I checked out or created (don't ask, we use an old CM system), so I can check the changes back in and introduce the new files (if I forget, guess who gets the wooden spoon for breaking the build):

So fire up a DOS prompt and type in:

C:\path to my code\>dir *.cpp *.h *.vcproj
/b /s /a:-r &gt; \usafipd\updated_files.txt

This says "list all of the code files and Visual Studio project files from here on down that are writeable (i.e. not locked by Razor), then dump the results to a file in case there are hundreds of filenames to review.

This gives me a file, updated_files.txt, containing a nice list of all the .cpp, .h and .vcproj (Visual Studio project) files I checked out (i.e. made writeable).

Invisible, indeed!

The book The Invisible Web: Uncovering Information Sources Search Engines Can't See, cited in John Battelle's book The Search: How Google and Its Rivals Rewrote the Rules of Business and Transformed Our Culture, describes the problem posed by the unsearchable areas of the Web, such as subscription-only databases. Intrigued, I scooted over to the Invisible Web's companion website, only to find the web is actually just a little bit more invisible than I thought:

Monday, April 14, 2008

Vote for mod_rails!

Hey, Dreamhost - when are we going to get mod_rails on our shared server accounts? Fellow Dreamhosters, if you've been waiting for an easier way to deploy and run small Rails apps, then vote for the mod_rails suggestion!

Sunday, April 13, 2008

Pylons stuff

John Brennan brings us a short Pylons intro Zero to 60 with Pylons… in just minutes (Part 1). Can hardly wait for Part 2!

Also noticed The Definitive Guide to Pylons from Pylons lead developer James Gardner is slated to arrive in July 2008.

Friday, April 11, 2008

Another evaluation of Google AppEngine

Todd Hoff explains how distributed web apps can leverage the much-maligned CGI interface in Google AppEngine - A First Look

Web app hosting as a service?

Kevin Yank opins on the effect services like Google's App Engine may have on web hosting choices. By abstracting away the details of configuring and deploying web apps for a particular host system, services like App Engine and Heroku may give developers more time to concentrate on providing business value (creating applications instead of fighting with servers). The greatest benefit may accrue to independent developers, students and hobby developers, who haven't the time, money or server-fu to set up and administer their own dedicated server, virtual or otherwise.

Thursday, April 10, 2008


Came across a useful link: www.osalt.com Open Source Alternative - Find Open Source Alternatives to commercial software. Thanks to Jimmy, who made note of osalt.com in his comment to Jeff Atwood's post on the value of open source vs. commercial software on Jeff's always thoughtful blog, Coding Horror.

Monday, March 10, 2008

Your loops got game?

Koen deWitters published an article on game loop design that should be of interest to anyone who designs software. He explains not only how to design a game loop, but why one technique is better than another, with simple, clear examples.

Monday, February 4, 2008

Small C++ Project, huge .ncb file?

I'm taking COMP 2617 C++ for Object Oriented Software Development at BCIT, and using Microsoft Visual C++ 2008 Express Edition to do my homework. Pretty sweet little IDE, lots of Pro VS 2005 goodness for free!

But - why does the .ncb file (Intellisense parser database) for my dinky little C++ program, all of 160 lines in one 5Kb .cpp file, weigh in at over 2Mb?! According to Li Shao in this thread on the MSDN forum, "In VS2005, we have made change to remove this prebuilt ncb and dynamically parsed the files including the system headers into project ncb.", in response to the original poster, who complained that "... an NCB file of 50KB under VS 2003 now has 500-600 KB, a 200 KB NCB under VS 2003 now has about 2 MB. And NCB files that used to have a size of 2-3MB now have 25-30 MB." Sheesh! This is progress?

Wednesday, January 23, 2008

Tuesday, January 15, 2008

Help me help

OK, so in an effort to "monetize" this blog, I added a Donate button yesterday (lookey over yonder ->). I'd like to donate 50% of all donations to a worthwhile cause—the other half just helps keep this site, and my webbish ambitions, alive—assuming of course there's any whole to divide up in the first place!

So come on, make a donation, then convince me why I should benefact your favourite charity.

Monday, January 14, 2008

Images missing from Windows Vista Help and Support Pages

I switched back to Vista a couple of weeks ago, after giving up trying to live in Kubuntu for the second time in a year. I noticed one minor nit after I moved back in, all of the image graphics in Vista's Help and Support pages had mysteriously disappeared, leaving only little boxes with red x's behind them. Fortunately, a quick Googling brought me to Ramesh Srinivasan's solution - a quick registry patch file, courtesy of Mr. Srinvasan, restored the help page graphics to their former glory.

Thursday, January 10, 2008

Diffing where I want, and diffing the same file

I use WinMerge a lot for general interactive file diff/merge/munging. It's great, free, etc. But what I'd really like is a diff tool that a) lets *me* decide which bits in each buffer match up as the starting point, and b) let me compare two sections of the same file. Does this exist? Please let me know. Please.