A clear explanation of PUT and POST

A very clear post in Open Sourcery PUT or POST: The REST of the Story about the difference between PUT and POST in REST. What the post doesn't make clear enough, though, is that PUT requests can be cached, while POST aren't.

Building scalable PHP / MySQL websites

The task: summarize notes from a lecture about scaling PHP apps. More →

Tim Brown: More perfect typography

A geeky approach to layout and typography - full lecture on Vimeo. More →

Tagging a Jenkins build automatically

The task: coming up with a branching strategy to work with Subversion and Jenkins. More →

Using Jenkins to replicate WordPress sites

The task: setting Jenkins up to recreate a WordPress site from data stores in a repository. More →

Installing Jenkins on OS X and Ubuntu

The task: setup a simple CI system for my Linode using Subversion, Jenkins, and Ant.
More →

Starting an HTTP server from any folder in OS X

One liner to start an HTTP server from any folder in OS X: alias server='open http://localhost:8000 && python -m SimpleHTTPServer'/via Jeffrey Way

Combining images with ImageMagick

Assorted ImageMagick commands to combine images (I use them for screenshots of interesting sites). Latest: arranging images in a grid
More →

Canvas tutorials links

The task: collect HTML5 canvas tutorials and assess them. More →

How to Make Your JavaScript Fast

Mozilla's David Mandelin has published an interesting slideshow about JS optimization. Here are the takeaway points in case it disappears. More →

A Google Apps Script boilerplate

The task: distill my Google Apps Script (GAS) know-how into a Spreadsheets boilerplate, and document it. More →

More CSS goodness

CSS is in serious danger of becoming sexy. If animations, transitions, and CSS shaders weren't enough, layout modules are on the way.

How to create a Sublime Text 2 snippet

Snippets are pieces of text, with or without placeholders, that you can have your editor paste in when you type a shortcut. Many editors have them; here's how to create them with the Sublime Text 2 editor.
More →

A script to take screenshots at regular intervals

The task: a Python shell script that calls webkit2png repeatedly to take screenshots of a website at various intervals. The script will be called webkit2loop. More →

Setting up Wifi hotspot for mobile development

Virtual Router allows you to set up a WiFi hotspot from your Windows 7 machine. Or you can do the same from the command line without any extra software. More →

Json to Google Tasks with the PHP API library

The task: a PHP shell script to read JSON data (from a file, or CouchDB for extra points), and use it to manage tasks in one's Calendar. The script will simply be called jsonToGoogleTasks.
More →

Configuration properties for Jasmine maven plugin

The configuration properties for the jasmin maven plugin in XML format. From the the Jasmine maven plugin homepage and the plugin source
More →

Showing passed Jasmine tests by default

I am sure I have missed an obvious config setting, but the quickest way I found to display passed tests in Jasmine when the page loads, without having to click on the checkbox, is with a JS function that uses the proxy / decorator pattern. More →

Reduce RSS noise with Yahoo! Pipes

A very simple Weekly Challenge to get me started. The task: create a series of aggregators of RSS and twitter feeds, and a simple HTML scraper, using Yahoo! Pipes. More →

Google Developer Day Berlin, 2011

Interesting day at the GDD Berlin. Didn't learn anything that blew me away, but it was good to see Google's enthusiasm for sharing their technology with developers. Still not convinced about DART, but the food wasn't bad.
[Update] all the slides from GDD Berlin are now available online
More →

Eclipse shortcuts

As I am moving to the Sublime Text editor, here are some Eclipse shortcuts before I forget them through lack of use. More →

Weekly Challenges

With so much exciting web technologies being developed, getting time to play with them all can be difficult. So I am trying weekly challenges, where I give myself a simple task, and a week to solve it using a technology of my choice. More →

PHPUnit assertions

For my reference, a list of PHPUnit assertions from the PHPUnit book More →

Handling error messages with jQuery.validate

If you are not happy with the jQuery.validate plugin displaying error messages within label tags (because they are clickable for checkboxes, or for whatever reason), set errorElementto the name of the tag you'd like to use, e.g.$("#form").validate({ errorElement: "span” });
More examples on Mitch Labrador's Tech Blog

Extract, transform, and load (ETL)

Extract, transform, and load (ETL) is a process in database usage and especially in data warehousing that involves: (E) Extracting data from outside sources; (T) Transforming it to fit operational needs (which can include quality levels); (T) Loading it into the end target (database or data warehouse). More →

Resetting the HTC Hero

It seems the 'Factory Reset' option in the 'Security' setting of the HTC Hero has been removed. Here's a way of doing a hard reset that actually works.
More →

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

Advanced Evernote search

It isn't immediately obvious, but Evernote offers advanced search operators. More →

Google Maps introduces weather

Google Maps introduces weather - in the pulldown menu at the top right corner of the map itself. More →

Facebook continuos integration cycle

There is an interesting screencast by Chuck Rossi, release manager, on how they manage the release process at Facebook. Worth seeing, but if you haven't got the time, here's a quick executive summary. More →

PHP 5.4 introduces short arrays

The more time I spend coding in Javascript, the more PHP feels old and clumsy. Many developers feel that way, and that's probably why they introduced a small, JS-like improvement in PHP 5.4 - short arrays: $a = [1, 2, 3, 4]; $a = ['one' => 1, 2, 'three' => 3, 4];

Capsule CRM is not much use to a freelancer

I have been using Capsule, a CRM, for a couple of years, to help me manage the endless stream of emails from recruiters. It has some good features, but it is not really suited to freelancers. It may work well for sales people, though. Perhaps. More →

Beyond polyfills: sugar.js

While front end developers debate about polyfills, a slightly more controversial Javascript library, Sugar.js, promises to "let you do more with less code". I am still in two minds about this. More →

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

Web Intents

Paul Kinlan's Web Intents post ends with "This project will fundamentally change and improve the way we build applications on the web today for our users". A strong statement - and to be fair, the project does look interesting.
Still very early days though.

So far there is a WebIntents API on github, some examples on Intent: Share and some examples on webintents.org.

CSS3 transitions callbacks

CSS3 transitions fire off a TransitionEnd event when they end, so that you can attach a Javascript handler to it. The only (minor) inconvenient is that the event takes different names depending on the platform. More →

Running Chrome with flags

Some of the more bleeding edge features of Chrome are switched off by default. You can switch some on by visiting 'about:flags' in Chrome. For the rest, you'll have to start the browser from the command line and type the option manually. On a mac you do that by typing open -a /Applications/Google\ Chrome.app/ --args --YOUR-FLAGS-HERE
Here's a list of Chrome command line switches More →

A good place for scripts in OSX

I always used to wonder where to put unix based scripts on my Mac without them getting in the way. The solution is simple: create a bin folder in your home directory, and add it to the path: export PATH=~/bin:$PATH(from the Advanced Command Line Screencasts)

Converting a category to a taxonomy in WordPress

Here is some code to create a new taxonomy term for each post of a given category. More →

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.

Hello Alfred, and farewell Quicksilver

Quicksilver has been moribund for a while*, and it was only a matter of time before I switched to Alfred. The switch was much simpler than I anticipated - I had the two apps running side by side until I was satisfied I could do the same things with both. Didn't take long at all.

* apparently not - see comments More →

Disabling auto-revisions in WordPress

Auto-revisions can be very useful, but I find they just fill up the database with needless data, so I disable them with this line in wp-config.php:
define( ‘WP_POST_REVISIONS’, false ); More →

Most plastic containers are not recyclable


Plastic labelling can be misleading, because you need to know what the numbers mean to know whether an item is safe to re-use as your lunchbox. Most aren't. More →

WordPress external links HTML generator bookmarklet

Here is a bookmarklet to generate HTML code for external links you can paste in your WP editor (or any editor for that matter). Just drag it to your browser's link toolbar.

[ External WP Link ] More →

Awesome Screenshot browser extension by diigo.com

Just installed the Awesome Screenshot browser extension by diigo.com on Chrome - very happy with it. So far it's the best extension of its type I have tried. You can quickly just save the screen grab as is, or you can annotate it first, which is very helpful. 5 stars.

Google Apps Script (GAS) now available for Google Docs

Google have just extended Google Apps Script to work in Google Docs too. API Documentation is available.

Getting rid of the GoogleSoftwareUpdate agent

I installed the latest version of Google Chrome on my Mac, and next time I logged on I got a Little Snitch alert - GoogleSoftwareUpdate was trying to connect to Google. Apparently this happens with all Google software, like Google Earth etc. Here's how to get rid of it. More →

Getting started with Google Apps Script part 1

Google Apps Script (GAS) is an implementation of Javascript that runs on Google cloud servers and allows access to Google services. Support is still somewhat flaky, but if you are already familiar with Javascript it is an exciting technology to get into. In this simple Google Apps Script primer, we will use a Google Docs spreadsheet to learn the basics More →

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) More →

Locking screen in OS X with Quicksilver

UPDATE: don't waste your time with Quicksilver. Use Alfred instead.

YUI Docs error: DeprecationWarning

I was happily running YUI Docs when suddenly it stopped working with the error: "DeprecationWarning: the sets module is deprecated". Turns out that YUI Docs doesn't like any code above the first Javadoc block.

The Unix side of OS X – what goes in which directory

One of the nice things about OS X is that it has Unix under the bonnet. That means you can install all sorts of geeky software like ImageMagick or xdebug; but, knowing where to put things can be confusing if you are new to it. Here's a quick guide to the folder in OS X, particularly the Unix (or strictly speaking, FreeBSD) side. More →

Joining PDF files in OS X from the command line

In OS X, PDF files can be concatenated manually using Preview. But if you are happy using Terminal there's an easier way, thanks to a Python script installed by default in /System/Library/Automator More →

Domain-driven design

Everyone at work seems excited about Domain-driven design. Here are some useful links More →

Tenancy Deposit Protection in the UK

Having to deal with boring admin landlord admin. This may be useful, so I thought I'd share it.
More →

The best Italian cheeses

Occasionally cheese lovers ask me to recommend them good, less known Italian cheeses. Here's my list.
More →

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"

More →

Finding recently changed files with Terminal

To list files that were changed in the last day, sorted by size, using Apple's Terminal, or any Unix / Linux bash shell: sudo find / -type f -mtime -1 -print0 | xargs -0 du -sk | sort -nr(thanks mynamewasgone!)
More →

La Vispa Teresa

Actually titled 'La Farfalletta' (the small butterfly) this is a short children poem written by the milanese Luigi Sailer in the 1850s. Trilussa, a roman poet, added a risqué extension it in 1917. More →

Google XML Sitemaps plugin for WordPress

XML Sitemaps are documents which list all the pages in a site, including some metadata for each page. They are useful for search engine indexing. Arne Brachhold has created a great free sitemap plugin for WordPress called Google XML Sitemaps More →

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.

Quickly removing empty array elements in PHP

A quick way to remove empty elements from an array is using array_filter without a callback function.
$myArray = array_filter( $myArray ); This will also remove 0s (zeroes) though. More →

Copying files matching a pattern, preserving directory structure, with cpio

To copy a directory tree ignoring all the .svn folders, use this
cd DIR_FROM find . \! \( -name . -or -name ".svn" -or -path "*/.svn/*" \) -print | cpio -padv PTH_TO More →

Using filter_var to validate email addresses in PHP

As from version 5.2, PHP comes with built-in data filtering. Which makes validating emails and URL very, very easy. More →

Batch unrar from the command line on Mac OS X

Rar is a popular archive format on the web. When I need to unarchive several rar files at once, I use RarLab's command line tool. Here's how.
More →

Removing black border from Mac OS X Leopard screenshots

When you take a screenshot of a window with Mac OS X Leopard (CMD+CTRL+SHIFT+4, then spacebar), and paste it into Photoshop, it will be surrounded by an annoying black frame around it. Here's how to get rid of it. More →

Getting ant to read user parameters

You can set use the input task to make Ant ask for parameters on the command line at runtime. More →

Using OpenOffice to batch convert file formats on OS X

In my increasingly more and more frustrating attempt at finding some use for OpenOffice, I tackled file formats, including batch file conversion. As you can expect for an application written in Java, it wasn't easy. More →

Connecting to mySql from OpenOffice.org on OSX

I tried to have a play with the OpenOffice 3.0 db app to see how it would work on OSX as a way to input data into mySql databases. More →

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). More →

Sending emails with non ASCII characters from Classic ASP

To have an ASP page send an email with non-ASCII European text (Cyrillic, Greek, Czech, etc) you'll need to use UTF-8. More →

Serving an Excel Worksheet to a browser.

Writing an excel worksheet to a browser is pretty simple - all you need is the correct response type, and to format the data using an HTML table. More →

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

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:Number = Math.pow( Math.random(), 2 );