Encoding JSON in Objective-C with PhoneGap

I needed to encode JSON from Objective-C and send it back as a response to the JavaScript side of my app. Not immediately finding anything to suggest that PhoneGap supported JSON, all attempts to include Stig’s JSON framework failed due to name conflicts.

Fortunately, PhoneGap supports encoding JSON out of the box:

(Source: wiki.phonegap.com)

Display SVG Using the <img> Tag

This post has been moved here.

Clearing Floats the Easy Way

An outer element has children that float (for example, in a grid display). You need the outer element to stretch around the floated elements. What do you do?

Until recently, my standby was to add an extra child element after the others with the property clear: both.

This is a messy and intrusive solution because it forces you to add markup to do the job of layout. Isn’t it possible to fix this problem with CSS? Yes, it is.

Alex Walker points out that setting overflow: auto on the containing element does the trick. In code:

Shoreline: A Google Closure Project Template

Post has been moved here.

Canvas Tag Cheat Sheet

Canvas Tag Cheat Sheet

Silk, Amazon’s new browser, may represent an even bigger innovation than Kindle Fire’s $199 price.

(Source: amazonsilk.wordpress.com)

Implementing the iOS ‘wiggle’ effect using CSS3.

(Source: youtube.com)

Distance from a Point to a Line in JavaScript

As part of some experimentation with the HTML5 canvas tag, I needed a function to calculate the shortest distance from a point to a line. Here it is:

Clean and effective.

(Source: jsfromhell.com)