Feed items

Getting up and running with virtualenv on Mac OSX Lion.

I recently purchased a new Macbook Air and had forgotten all of the various steps to get virtualenv up and running. Using the native Python packaged with OSX resulted in Could not call install_name_tool — you must have Apple’s development tools installed which I found confusing given that, you know, I have Xcode installed.
Resorting to my old friend MacPorts, it took me a few tries and plenty of googling to get up and running. To save you some time should you be in a similar position, here are the commands you will need;

Drupal meets geolocation with Quova

Quova – the worlds largest geolocation provider – has sponsored the development of a suite of Drupal modules to bring geolocation to Drupal.
With their suite of modules site developers can now easily create locale aware, geo-targeted compelling experiences in Drupal.
The suite of modules for both Drupal 6 and 7 includes:

Interleaving numbers

When you have two numbers that need to be indexed together for speedy lookups there are a variety of mechanisms that can be used, a fast and efficient mechanism is called the Morton Interleave.

Better integration with Facebook for Django

I’ve really been enjoying working with Django for the last few months, it’s an incredibly powerful and elegant framework and I sorely wish there was an equivalent in PHP.
This said, I was sadly unimpressed with the social landscape support. Facebook’s own Python SDK has a slew of bugs and is not actively maintained, I recommend people use David Ziegler’s fork.

Consulting

I am available for short term consulting work in the following areas:

  • Project planning, scoping or evaluation (£250 p/d)
  • PHP, Python or VHDL development (£400 p/d)

If your project deadline has slipped, or your development team is under performing, or you’ve lost money due to a rogue contractor walking away – then please get in contact. I specialise in emergency support and project analysis and have a wide area of expertise.
Companies I’ve recently worked for:

Retrieve time from an NTP server

There’s a lot of code floating around the internet to communicate with NTP servers, unfortunately none of the ones I found actually worked. Here’s a low level implementation:

Dealing with human readable network addresses

Let’s say we need to build a list of network addresses to whitelist access to a restricted area, or blacklist a troublesome spammer. It’s handy to be able to enter data in a variety of formats, including hostnames, IP addresses, and IP ranges.
Usually we will store this information as a long, then we can easily see if a requesting IP address falls within our list of networks simply by numerical comparison, specifically: start_range < requesting_ip < end_range.
However, our user doesn't want to enter the list of IPs as a long so we need tools to convert between an attractive input format, and an array of start and end ranges.
To accomplish this, we define two functions network_expand_range and network_compact_range. Let’s have a look:

Executing a callback for all files in a directory

A common question when dealing with deep directory structures concerns how a function can be applied recursively to all the files in the target directory, regardless of the depth. This function, directory_walk, builds an internal stack (uses no recursion) and iteratively applies the user supplied callback providing a fast and flexible approach.

Why I’ll never eBay again

I listed my old Macbook Pro 15″ laptop for sale on eBay today. I paid my fees. I reviewed my add. I was happy for about 6 minutes, until I received the following barrage of emails:
—————————————————————–
MC010 A26 TKO NOTICE: Restored Account- aidanlister
—————————————————————–
Hello aidanlister (aidanlister@gmail.com),
It appears that your account was accessed by an unauthorised third party to list items without your permission. At this time we have taken several steps to secure your eBay account. Be assured that your credit card and banking information is safe as this information is kept encrypted on a secure server and cannot be viewed by anyone.
Followed by:
—————————————————————–
MC040 NOTICE: eBay Auction(s) Cancelled – User Agreement – Abusing eBay
—————————————————————–
Hello aidanlister (aidanlister@gmail.com),

Implementing row level access control in CakePHP

The ACL Component in CakePHP is very powerful and can be used to solve a wide variety of access control problems. In this tutorial, we provide a step-by-step guide for implementing row level access control to a model. We will assume at least a basic understanding of ACL and Auth in CakePHP.
The example I am using is an editing platform. At the top of the tree are Volumes, each of which contain many Papers. Authors have access to papers, while Editors have access to volumes and all the papers there-in. Because we have two trees, it’s important to design our ACL tree well or it quickly becomes unmanageable. We’ll call the top of our tree Papers, but this choice is arbitrary.
We create the following ACO hierarchy: Papers/Volume/Paper