Archive for October, 2009

SWEC 0.4

Thursday, October 15th, 2009

About two weeks back I released SWEC version 0.4. The largest new thing in this release is an updated file format for writing test definitions. Thew new format is a lot more flexible, and will also allow me to extend its syntax with more capabilities more easily later on. It can still read the old file format, and I’ll keep the compat code in there until SWEC 0.6 – so people have time to update their files (only minor changes are needed to update them to the new file format, should only take a couple of minutes).

Other than that I extended the command-line parser, so you can now say “swec example.com -s /test.html” where you would previously have had to do “swec --baseurl example.com -s /test.html“. Other than that it’s mostly a bunch of cleanups, some refactoring and a few minor bugfixes, in addition to a new test suite so the thing can be properly sanity-checked before release.

If you need to sanity check dynamic websites, give SWEC a go.

Fixing PHP documentation woes

Wednesday, October 14th, 2009

I prefer writing in Perl or Ruby, but sometimes the choice of language has been made by someone else, a position I have found myself in lately. When using perl and ruby, there’s always perldoc and ri, so documentation is a quick command away in any of my terminals, which thanks to screen is never fewer than ten. PHP however, has no such tool, the docs are in HTML and many distros don’t even package the HTML docs. So, to avoid the pain of switching out of the safety of my terminal and into a web browser all the time, and speed up my work, I wrote an app, phpdocr. It’s quite simple, it scrapes php.net (and caches the result for quick viewing later) and displays the parsed HTML in your pager – resulting in something sort of like perldoc or ri. So if you have the same itch, grab it from http://random.zerodogg.org/phpdocr.

The app itself, of course, is not written in PHP – it’s written in ruby.

Sanity checking mason

Tuesday, October 13th, 2009

I have found myself doing quite a bit of mason at work lately, both maintaining old legacy stuff and as the view in a catalyst app.

While doing this I found myself missing the old ‘perl -c’ to quickly sanity check code, however naturally that won’t work on Mason – as mason is essentially HTML with inline perl, not the other way around. As such I wrote a quick script that emulates ‘perl -c’ by loading the file using mason inside eval then printing any errors. The script itself is pretty simple, though it doesn’t have any support for printing useful line numbers – but at least it gives an idea of what/where the problem is. The script also declares $c and $m, as at least for Catalyst – those will be available.

You can clone the gist, or just copy+paste the code:

Dynamically loading git bash-completion

Monday, October 12th, 2009

I have to admit, I love git. It has really made me more efficient, and I can’t honestly think of ever switching back to ie. svn.

My shell is bash, and up until now I used a very simple bash completion for git, but at times I do see myself wanting something a bit more comprehensive. However, I really don’t want bash to be slow to open (of course, the definition of “slow” is quite individual – over a second is way too much ;), which it can be if it needs to load all bash completion definitions when starting. Therefore I wrote a small bash function for my .bashrc that will dynamically load the git bash completion when it first is accessed. Bash starts fast, and I get git bash completion – problem solved (well, the first time git bash completion is used, it of course takes a tad longer than normal because it needs to load it first, but that’s completely livable). As a bonus, it will fall back to my old and simple completion if the proper one is not available.

Here’s the code snippet: