A brief sampling of my work
In: Uncategorized
2 Mar 2010I sometimes keep and share development related scripts in the repository, but by default, svn will not remember file modes. To set the script to execute, simply type:
svn propset svn:executable ON myfile.sh
In TortoiseSVN, just set a new property on the file:

In: Uncategorized
17 Jan 2010So I’ve been using virtual machines much more frequently recently, but only new VM’s that I’ve created. This weekend was my first attempt at P2V (physical to virtual). I have a decent XP dual core machine that has served me well for the last 2 years, but after my upgrade to a nice I7 Win7 laptop, there’s no going back.
However, the dual core is still very useful. Beyond a useful test rig for XP, it’s also my only way to get a true IE6 platform to test my web apps. Yes, I know there are many alternatives (Multiple IE’s, Spoon.net, etc.). Still sometimes, you have obscure bugs that you absolutely can not reproduce without a native installation. On top of that, when debugging with tools like MS Visual Web Developer that’s usually beyond the capabilities of the alternatives.
So why not just use Virtual PC and MS’s Internet Explorer Application Compatibility VPC Images? Because MS purposefully cripples Win7 Home Premium from using Virtual PC.
Also if I could successfully transfer my physical machine to a virtual one, I’d have access to all my old apps and a system that I backup easily and perfectly forever.
So which route – VirtualBox or VMWare? Both are free (if you only need VMWare player), but VMWare still dominates virtually, right? (Of course, there’s some dispute.) Plus, when looking over the instructions for P2V, there was no contest. VMWare provides a nice converter, and VirtualBox had so many additional requirements/steps (not the least of which was another OS).
Unfortunately, VMWare was not to be. I tried the converter a few times – making sure all the right services where stopped or started as needed, and it looked promising up to the very end but ultimately – BSOD.
So take two with VirtualBox, fortunately, I have my Ubuntu CD, so I could use dd to copy the entire disk (not just the windows partition), and then apt-get the VBoxManage software.
Time to convert the image. First, I shared the newly cloned image on my USB external drive with my Ubuntu VM (also running on VirtualBox)
mkdir /mnt/share sudo mount -t vboxsf shared /mnt/share cd /mnt/share VBoxManage convertfromraw ImageFile.dd OutputFile.vdi
It was a tedious process taking hours to clone, convert, and complete but required little monitoring. Now ready to boot again and … Bam – no further than “XLDR -ATA error”.
I thought I was stuck now, and starting to wonder how anyone was doing P2V. Though after some quick googling, I found this post. So mounted the XP CD, booted to recovery console, fixmbr, fixboot, and I was on my way again. That is until it was time to reactive my XP installation (argh! I got it to work but was considering using WGA Killer if need be.)
It was a long ordeal, and in retrospect, I probably could have gone further with my VMWare diagnosis. I should have tried the recovery console for those BSOD’s as well.
Still, I’m up and running and a little bit wiser. I think.
Now it’s time to resize and play with gparted. A more thorough guide is here.
In: Uncategorized
5 Jan 2010I recently needed to modify hundreds of links on a wiki page based on a dynamic value, so I created a simple bookmarklet (ModWikiLinks).
I searched for a tool to properly format/shrink it and found: the bookmarklet crunchinator.
var user = prompt('Enter your username');
var links = document.querySelectorAll('a[href*=localhost]');
for (i in links) {
if (typeof links[i].href !== "undefined") {
links[i].href = links[i].href.replace(/http:\/\/[^\/]+/,'http://trus_global.'+user+'.webdev.gspt.net');
links[i].target = '_blank';
}
}
In: Uncategorized
3 Dec 2009I recently learned about pcregrep, a enhanced grep that supports perl regex syntax. This is great for searches that span multiple line. For example, the other day I was looking thru old css files that had a border set to 0 to be removed due to the inclusion of a reset.css lib. So ….
pcregrep --color --exclude_dir=".svn" --exclude="reset.css" -rn -M "\bimg\b[^{]*?{[^}]*?(padding|margin|border)\s*:\s*0\s*;" .
Piping its output to a few commands, and I can search for bad code, find it’s line number, and who to blame:
$ pcregrep --exclude_dir=".svn" -rn "id=['\"]\w+ " . | awk -F: '{str="svn blame " $1 " 2>/dev/null | head -" $2 " | tail -1"; printf "%s:%d", $1, $2; system(str)}'
In this case, it was me?! :p
In: Uncategorized
31 Oct 2009Back with more one liners…
This one converts all html tags in a file to lowercase.
perl -pi.old -e 's/(<\/?)(address|applet|area|a|base|basefont|big|blockquote|body|br|b|caption|center|cite|code|dd|dfn|dir|div|dl|dt|em|font|form|h1|h2|h3|h4|h5|h6|head|hr|html|img|input|isindex|i|kbd|link|li|map|menu|meta|ol|option|param|pre|p|samp|script|select|small|strike|strong|style|sub|sup|table|td|textarea|th|title|tr|tt|ul|u|var)([\s\/>])/$1.lc($2).$3/gie' file
This concatenates all files of a specified type – prefixed with its title. Useful for quick code review across many files.
for i in $(find -regex ".*\.jsp$"); do echo '<!--' $i '-->'; cat $i; done > combined.jsp
This one removes all multiline comments from a file.
perl -pi.old -e 'BEGIN {$/ = undef;} s#\*.*?\*/##sg' test
If you understand the -p option, you’ll understand why the BEGIN block is necessary and why the s flag is not very useful without the BEGIN. To really understand, what’s going on I recommend reading perlrun.
This portifolio represents a brief sampling of my work. More thorough demonstrations and walk-thrus of my latest and greatest work are available via remote virtual session on DimDim, a free flash based web conferencing tool.
You can view my resume here.
Also note that I recently joined StackOverflow where you will find me asking and answering many web development questions.