apache_prettify

Nick Nettleton | 24 April 2009

apache_prettify adds code colouring and line numbers to Apache configuration code - the stuff you write in httpd.conf and .htaccess. Most useful if you are publishing this sort of code in your blog.

  • Written in JavaScript - works in the browser
  • Dead easy to use
  • Compatible with all JS libraries - jQuery, prototype, etc
  • Quick - just a couple of regexs
  • Lightweight - 1.35K minified
  • To change the appearance, just edit apache_prettify.css

Read more Comment


apacheinfo

Nick Nettleton | 24 April 2009

A bit like phpinfo() for Apache, apacheinfo tells you which Apache modules you do (and don't) have installed. Especially useful if you don't have access to httpd.conf, or you can just drop it in a password-protected admin area for quick reference.

Read more Comment


Our brand new tech blog

Nick Nettleton | 24 April 2009

Welcome to our brand new tech blog, which I hope will in time be full of fabulous, magical and shiny clever things.

For those that don't already know, I'm Nick Nettleton, and Loft Digital is my company. We're a digital agency in London and by day we create geekily smart websites and apps for ecommerce, publishers and are various others. By night, well, we try to put our computers down, but sometimes things just get too exciting!

To keep life simple, I've ported a lot of content over from my old blog nicknettleton.com, warts and all. There's been some great discussion there that I'd like to keep alive - especially on PHP / UTF8 and, bizarrely the simplest of all things - trimming a string in Javascript.

Over the coming months I'll be sharing and open-sourcing lots of code from the various problems we've solved over the years, as well offering up some general banter on the tech scene and the political bits and bobs that go with this.

Anyways, thanks for listening up. Do drop me any questions if you have them, via my email at the top of the page. Look forward to chatting!

Nick

Read more Comment


jquery fadeLoad plugin

Nick Nettleton | 23 April 2009

A tiny little jQuery plugin - works just like jQuery load(), but combines it with a nice, subtle fade out/in transition.

Also includes the fix for the IE cleartype fade bug.

Read more 2 comments


Validate a credit card number in JavaScript

Nick Nettleton | 12 August 2007

When you're writing web apps, it's good to do validation both in the browser and on the server side. Do it in the browser to provide your user with instant feedback, and on the server for real security, as all client-side validation can be tricked or circumvented by those who know how.

Validating credit card numbers is a little tricky. They all follow a special algorithm, whose name I forget. But here are the mechanics of it...

Read more 1 comment


Intro to microformats

Nick Nettleton | 08 July 2006

Microformats are an important  - no, very important - new idea on the web. In fact, I think they are so important, they could precipitate a leap of evolution more important than AJAX and as important as XML web services. But first, an introduction.

The focal site for microformats, microformats.org, is not clear at all on what microformats are, but here is my understanding:

Microformats build on the semantic capabilities of the web, using existing standards.

Unless you're fairly technical, that's probably meaningless. So, to explain. <h1>, <h2>, <p>, <ul> - all of these and other HTML tags are designed to tell human readers, web browsers and other HTML readers what sort of information they contain. Not what it looks like - that's what CSS is for - but how that bit of information relates to other bits on the page. Is it a heading, a paragraph or a list of things?

Read more 7 comments


CMYK, RGB and PHP

Nick Nettleton | 04 July 2006

Brighter by the dozenA month or so ago, we were putting the finishing touches to the Lena White website, which sells OPI nail lacquer, among other things.

Lacquer is all about colour, so we wanted to give shoppers a way to quickly and visually browse all the available colours with colour swatches, rather than the more traditional product shot route. This makes particular sense because all lacquer bottles look pretty much the same, photos of them give a poor impression of the actual colour, and they take up way more screen estate than is helpful to anyone.

Read more 8 comments


PHP UTF-8 cheatsheet

Nick Nettleton | 03 July 2006

When we started building DropSend, we decided to support all languages worldwide from the start. The interface is currently in English only, but the application can send, store, sort and process your data whatever language you want. As a result, we have a good number of customers out east.

To support worldwide languages, you need to use UTF-8 encoding for your web pages, emails and application, rather than ISO 8859-1 or another common western encoding, since these don't support characters used in languages such as Japanese and Chinese.

Happily, UTF-8 is transparent to the core Latin characterset, so you won't need to convert all your data to start using UTF-8. But there are a number of other issues to deal with. In particular, because UTF-8 is a multibyte encoding, meaning one character can be represented by more one or more bytes. This causes trouble for PHP, because the language parses and processes strings based on bytes, not characters, and makes mincemeat multibyte strings - for example, by splitting characters 'in half', bodging up regular expressions, and rendering email unreadable.

There are a number of great articles online about UTF-8 and how it works - Joel Spolski's comes to mind - but very few about how to actually get it working with PHP and iron out all the bugs. So, here to save you the time we put in, is a quick cheatsheet and info about a few common issues.

Read more 67 comments


Optimising while() loops in PHP

Nick Nettleton | 02 July 2006

Following the for() tests, I performed the same tests for while() loops. The speeds were very similar to the for() tests across the board, with just one syntax standing out: the one that doesn't use a comparison operator. It was about 50% faster than all the others:

$i = 1000000 ;
while($i){ $i-- ; }

As with the for() test, this is a count-down loop, which checks the boolean value of $i without a comparison operator for each iteration.

Read more 2 comments


JSON - better than XML?

Nick Nettleton | 02 July 2006

JavaScript coders have been doing it for ages. Now it's got a name: JSON, or JavaScript Object Notation.

One of the sexier features of JavaScript is a shorthand notations for defining and populating a data structure containing objects and arrays. So, instead of:

me          = new Object() ;
me.name = 'Nick' ;
me.age = 30 ;
me.hobby = new Array()
me.hobby[0] = 'Reading' ;
me.hobby[1] = 'Writing' ;
me.smelly = false ;

You can do this...

Read more 4 comments