Tuesday, June 26, 2007

Markdown and Code Highlighting

Added a couple of WordPress plugins:

  1. PHP Markdown: because the default WordPress HTML editor mangled my code examples, and

  2. Dean's Source Code Highlighting Plugin: because I wanted my code snippets to look nice (obscures the lack of quality in my code examples :).


Hats off to Dean and Michel

Ruby script: find duplicate files

A quick google for a script that would find duplicate files by name in a directory tree turned up two promising techniques, one a Ruby script posted to OnJava by Bill Siggelkow and the other a bash script using common Unix tools.

Here's my attempt to reproduce the bash results in Ruby:

#!/usr/bin/env ruby
require 'find'

files = {}
found = {}

# read root directory from command line
ARGV.each do |arg|
Find.find(arg) do |f|
if File.file?(f)
# accumulate the file names
files[f] = File.basename(f)
end
end
end

# count up the number of each file name
files.each_value do |base|
# Ruby doesn't allow this Perl idiom: found[base]++
found[base] = 0 if !found[base]
found[base] += 1
end

# print the path of each file found more than once,
# prepended with rm command commented out
found.each do |name,count|
if count > 1
files.each do |path,filename|
if name == filename
puts "# rm #{path}"
end
end
end
end


Given a directory structure containing files with duplicate names in different directories, the output looks something like this:

# rm /market/fruits/tomato.txt
# rm /market/vegetables/tomato.txt
# rm /market/fruits/pea.txt
# rm /market/vegetables/pea.txt

The output could be piped to a shell script, in which you'd uncomment the "rm" statements for the files that should be deleted (if that's what you want).

This is all a bit clunky, if you've found a better or more Rubyesque way to do this, let me know!

Thursday, June 21, 2007

Config files

On a recent project at work, developing a test automation system on top of TestComplete, we tried two ways to store machine-specific configuration data:

  1. One file, shared by all installations, containing a section per machine

  2. One file per machine


At first I had set up a single config file specific to my development PC. When my team mate Alan picked up on the idea, to put some machine-specific data on his system, he created a global config file containing a section per machine. His reasoned that one file, with some common and some machine-specific sections, was more efficient than a collection of files with high redundancy.

The config files contained data specific to each developer or test instance, such as usernames and passwords on the system under test. We needed this data in first place to prevent clashes between developers as we exercised the system.

What we ultimately settled on was separating the single global config file back into one-per-machine. Even though we were following good development practice by using a svn repository, so no-one's edits would get lost or forgotten, we realized that once the project ramped up to 3 or 4 development machines, plus a couple of production servers, that config file would become a pumpkin.

Subverting Aptana

A persistent error in the integration of the Subclipse SVN client with Aptana IDE prevents the initial import of a project into an SVN repository. I don't think the problem lies with Subclipse, the client plugin, as much as a bug somewhere in the guts of the Eclipse IDE. I worked around the problem by using TortoiseSVN to perform the initial repository import, then carrying on with Subclipse in Aptana IDE.

To reproduce the problem, right-click on your project folder in the Navigator panel, then select the "Share Project..." wizard from the "Team" element of the project context menu. Aptana will display an error dialog:

aptana_svn_error1.PNG

The error message reads "org.eclipse.team.internal.ui.wizards.ConfigureProjectWizard cannot be cast to org.tigris.subversion.subclipse.ui.wizards.sharing.SharingWizard"

A couple of other Aptanans reported encountering the same error after I submitted it to the Aptana user forum, but the Aptana team hasn't come forth with a solution yet.

Here's how I worked around the problem:

  1. Download and install an SVN client, e.g. I use the TortoiseSVN Windows client on my Windows PC

  2. Create the new project in Aptana, e.g. "MyApp"

  3. Import the project to your SVN repository, e.g. "C:\rails\myapp" -> "svn://myhost.com/svn/rails/myapp/trunk"

  4. Now that the code is safely tucked up in your repository, delete the contents of the project folder, either in Windows or from Aptana.

  5. Back in Aptana, right-click in the Navigator pane then select "Import..." to open the project import dialog box. Follow the instructions to check out the contents of the trunk/ directory to a new Aptana project. [Note: modified this step to use Aptana instead of TortoiseSVN]

  6. You should now see Aptana's version of the SVN status hints overlaid on the project files and folders. As well, the project name will acquire the SVN repository path, e.g. [rails/myapp/trunk]

  7. That's it, you're good to go! Now you can use Aptana's SVN client to manage the project.

Wednesday, June 13, 2007

Pioneering?

According to an article in yesterday's Vancouver Sun, TNS Canadian Facts' survey on social networking revealed that "ten per cent of Canadians have a blog, ranging from a high of 31 per cent among the 13 to 17-year-old age group to three per cent among the 50-plus crowd". Only eight percent of my peers, the forty-something crowd, have their own blog. I guess that makes me a pioneer, even amongst all Canadians.

Why don't more middle-aged and senior Canadians have blogs? Services like Blogger.com make it as simple to write a blog as an email, so it can't be the technology. Even my 83 year-old great aunt has used email for the past 7 years!

Is it the fear of loss of privacy? Lack of anything to say? Perhaps older Canadians don't feel the need to let the whole world know their every thought. Would there be far less blogging amongst teens if they really realized that the whole world, not just the friends they trust, can read everything they put on Facebook?

What do you think?

Tuesday, June 12, 2007

What does phipster mean?

In case you hadn't gleaned it already, "Phipster" is a contraction of the first two and last letters of my first and last names: Philip Steiner.

David Black's explanation of his domain name, wobblini.net, prompted me to explain mine. But my favourite record as a child was Cecil the Seasick Sea Serpent. Go figure.

Monday, June 4, 2007

Moved from MS Windows Vista Home Premium to Ubuntu 7.04 (Fiesty Fawn) this weekend

What: Compaq Presario C506ca

Why: Windows Vista sucks.

When: Yesterday.

How: Ubuntu Live CD + apt-get + Ubuntu Wiki = done.

Ubuntu First Impressions



  • What sucks: fonts, headphone jack doesn't cut out speakers, lousy Palm support

  • What rocks: wireless networking, wireless keyboard/mouse, Aptana, online support/community, resource conservation, no viri (no antivirus yet, either!)

Web 2.0 Design, Dissected

It's all 'splained here. Once you've memorized this page, you can hold your own with any Mac-toting, dressed-all-in-black, goatee'd web designer.