Regular Expression (Regex) For Date part extraction/array split

Needed to use this recently to create a specificity parameter for an API at work, it gives you a key/value array from an ISO date string regardless of what is actually set in the string (e.g. if you give 2011-06-07 04 you’ll get an array back as array(‘year’=>2011, ‘month’ => 6, ‘day’ => 7, ‘hour’ => 4). If you enter 2011-06-07 04:43 you’ll get: array(‘year’=>2011, ‘month’ => 6, ‘day’ => 7, ‘hour’ => 4, ‘minute’ => 43), works from just a year all the way to seconds. /** * Gets the parts of a date that are set in an … Continue reading

My own PHP Extension Released – several time savers.

This weekend I’ve finished off my first public PHP extension using the (god awful) Zend PHP macro’s, function calls etc. There were 3 reasons for me doing this: 1) See how difficult it was 2) Create a true library for PHP projects to reduce code repetition across projects. 3) Add some speed to projects that crunch a lot of data in PHP. The extension I’ve released adds the following functions: /** * Given a multi line input, removes empty lines and whitespace at the ^ and $ of each line. * Remove duplicate lines by setting the second param to … Continue reading

CouchDB ServerDensity Plugin

We needed a CouchDB plugin in the office for some of our servers so I wrote one earlier and added it to the Plugin Store over at ServerDensity. You can download it at http://plugins.serverdensity.com/couchdb/ It’s a straight forward plugin that exposes all your databases statistics to SD for monitoring allowing you to fully customise your graphs/alerts.

Automating “Implemented methods” for a web based API

In my leedsphp talk last week I mentioned making a developer (and consumers) life easier by automatically implementing the allow methods functionality that your API may expose (e.g. you call PUT on a URL that only allows GET or POST). I did have an example slide there showing how to implement but I thought I’d posted a bare bones controller here that shows how it works. abstract class ApiController extends Zend_Rest_Controller { /** * Default head action. * * @internal * @return void */ public function headAction() { ob_start(); $this->getAction(); ob_get_clean(); } /** * Default get action. * * @internal … Continue reading

Custom version of beanstalkd available for download

We use beanstalkd at work for our job queue’s due to its very low memory footprint and speed. However it was missing a few features we needed so I decided to fork it on github and start working on it and I’m pleased to announce it’s now available to download. You can grab it at https://github.com/wadewomersley/beanstalkd-ww. * Added the much needed clear-tube function – removes all but reserved jobs, yes, even buried! * Fixed bug in log load where group reload was attempted while not supported. * Added removal of group reference from job on group delete * Fixed add_job_to_group … Continue reading

Using SSL in RestClient

RESTClient is a great little CLI and GUI tool for testing your REST API. I recently pushed a new API up in the office and it runs over SSL. I tried to test it in the RESTClient and got a PeerNotVerified error from Java. First thing I did was go to the SSL tab in RestClient presuming I could tell it to just trust the API…apparently not. So after a bit of web scouring about how to get Java to trust your site I came across instructions and thought I’d re-post here simplified for anyone who needs to query HTTPS … Continue reading