Running maven with custom properties

A workaround for when Java developers hardcode local paths in maven scripts and commit the pom files to source control – something would be the name of the path, clean install war:inplace is just a sample command:
mvn -Psomething="/PATH/TO/SOMETHING" clean install war:inplace

Avoid the mysql extension in PHP

There are a few different ways of handling MySQL in in PHP. Ext/mysql, i.e. the functions that start with mysql_xxx, is the oldest and most well known. It is also insecure, doesn’t use all the database features, and will be phased out and in future releases. Use mysqli instead, or at least pdo_mysql. Continue reading

Refreshing bash_profile

If you edit your .bash_profile you will need to either quit your current terminal window and open a new one, or run this command to reload the settings: source ~/.bash_profile.

SVN status codes

Running the status command in the command line version of subversion returns a list of files with a one letter code in front of each file name. Here’s a list of those one letter codes and what they mean.
svn status
M src/index.php (etc)
Continue reading

Finding files inside an archive with Terminal

Looking for files inside an archive, without having to extract them first? Using Apple’s Terminal, or any Unix / Linux bash shell:

find /dir/ -iname archive.tar -print0 | xargs -0 tar t -f | grep "filename you are searching for"
find /dir/ -iname archive.zip -print0 | xargs -0 unzip -l | grep "filename you are searching for"
find /dir/ -iname archive.rar -print0 | xargs -0 unrar l | grep "filename you are searching for"

Continue reading

Site redesign – v6.0

Finally finished redesigning the site. Still testing it and cleaning it up, but it’s pretty much there. The old one was a bit fiddly, and I wanted to separate the blog from the portfolio proper. Also, I intend to add more Ajax and Flash functionality, bit by bit as I have time.

Setting A Bash Prompt in OS X

To change the command line prompt on bash, my shell of choice, you need to edit the file .bash_profile in your home directory. To do that, UNIX machos will tell you to use vi. This I find only slightly less painful than walking on my knees on dried chickpeas, and I won’t touch it (I won’t even touch vim, its marginally less awkward cousin). Continue reading

Converting a collection to a JScript object in ASP

Enumerators are collections of data that can be iterated through. Although useful, they are not compliant with ECMAScript standards, and therefore I prefer not to use them. Some objects in the ASP environment however, such as Request.Form, are provided as Enumerators, and need to be converted them to standard JScript objects. Here’s a couple of routines to do so. Continue reading

Skewing random numbers towards 0

A quick way to skew random numbers towards 0 is to raise them to some powers – the higher the power, the higher the skew. Obviously not the most efficient way of doing it, but could be useful in certain occasions where performance is not an issue.
var num = Math.pow( Math.random(), 2 );