Archive

Posts Tagged ‘How To’

HTML 5 – Websocket Chat Demo

October 25th, 2010 16 comments

The HTML 5 initiative contains a draft spec for WebSockets which allow a browser to establish a full-duplex, bi-directional communication channel over a single TCP socket. This allows web developers to establish real time two way communications with a server using simple javascript without resorting to Flash, Java, ajax long polling, comet, forever iframe, or other current workarounds. Here I’ve written a simple browser chat using WebSockets for the client and PHP for the server.

Read more…
Categories: HTML 5 Tags: , , ,

Squashfs – Compressed Filesystem Backup

October 18th, 2010 1 comment

I am way overdue upgrading my primary work machine to the latest Ubuntu release. The biggest thing that has been holding me back (besides finding the time) is the fear of losing some file or system config which will take ages to recreate. Often when I upgrade a system like this, I simply install a new hard drive and keep the old drive around in case I need to dig up some file I don’t have handy in any other location. But this is a laptop and I am already nearly out of free space. What I’m going to do this time is use Squashfs to create a compressed, read-only filesystem inside a file which can be placed on an external drive.

Read more…
Categories: Linux Tags: ,

Calculating Distances in SQL

April 30th, 2010 1 comment

Sooner or later when dealing with data that contains addresses, you’ll need to perform distance calculations. Some examples might be “which store is nearest to location X” or “display all hotels within 20 miles of the customer’s location sorted by distance”. This post deals with such calculations based on positions designated by latitude and longitude. The process of determining the latitude and longitude of an address is called geocoding and is outside the scope of this article.

Read more…
Categories: How To, MySQL Tags: , ,

Creating OS X-style DMG volumes in Linux

March 20th, 2010 4 comments

Working in a cross-platform environment, I sometimes find it necessary to deal with DMG files (Apple disk images). Instead of finding a coworker with a Mac, I have found it easier to equip my linux machine to be able to read, write, and create these images (uncompressed only) natively.

The key is the fact that a DMG image is merely a HFS+ filesystem in a single file (similar to the way a .iso file is a CDROM filesystem in a single file). While I’m not sure how the extra DMG options (such as encryption, compression, or being “internet enabled”) work under OS X, I have verified that it is easy to create simple, uncompressed DMG images from scratch in linux. Here’s what works for me under Ubuntu Dapper & Feisty.

Read more…
Categories: How To, Linux, OS X Tags: , , ,