Debugging with audio
Andreas Jansson | 08 September 2011
echo "here";Sometimes you just want to know that you took the right branch in an if statement, or that the value of a variable is what you expect it to be. Sometimes you don't have the need, time or incentive to fire up the debugger, you just want to dump a few variables to stdout. That works really well if you're writing a CLI script and it's okay if you work on old-fashioned HTML, but when it comes to debugging AJAX requests, it's pretty useless. When the response comes back to the browser you have to open up the web inspector and look at the network activity to find that particular requested document, click to look at the contents and dig out that debug message from the raw source. Not fun.
PDF DOC XLS ODF from PHP?
Zdenek Machek | 01 September 2011
Every PHP developer will sooner or later face a request to output a document as a PDF, XLS, DOC or ODF. Exporting each format by hand is as time consuming as it is dull - especially things like point-by-point positioning of elements in a PDF. So how can we get around this tedious chore using PHP?
Writing MySQL functions in C
Andreas Jansson | 15 December 2010
In the previous post Zdenek explained how to use MySQL stored functions to calculate the distance between two points on the lat/lng plane. Here I take his function as a starting point to describe how to implement user defined functions written in C, and import them into MySQL.
User defined functions (UDF) are compiled C functions that you can use as normal functions within MySQL. UDFs have a number of advantages over stored functions written using SQL, the most important being improved performance and the fact that you can use them as aggregate functions (like you can with SUM(), AVG(), etc.).
Writing UDFs is easy. So is compiling and importing UDFs into MySQL. First you need to do a little bit of setting up. This is how you do it (in Ubuntu and Red Hat).
Automatic geolocation and SQL
Zdenek Machek | 16 November 2010
Recently we launched a website and platform for iGo Gift Vouchers. One of the screens shows an interactive list of the shops where vouchers can be used. The classic interface design pattern for this is to ask users to provide a postcode, or the name of a city or town, and then display the shops in that area on a map.
As usual, we decided to try something new and improve a little on the traditional functionality. We wanted to automatically detect where the user is right now, so we can display shops in their area as soon as they arrive on the page, without them having to enter any information. You can see how it works at www.igogiftvouchers.co.uk/myigo - when your browser asks if you would like to share your location with the page, just click the option to accept.
So why Geolocation and SQL? The first part of this task, identifying where the user is, is handled on the client side usining JavaScript. But SQL comes in as the best and fastest tool for the second part of the task: identifying which shops are nearest and should be displayed on the map.
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
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.
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
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.
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...
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?