<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>Cuppadev</title>
	<atom:link href="http://www.cuppadev.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cuppadev.co.uk</link>
	<description>Cuppalicious coding!</description>
	<pubDate>Sun, 17 Aug 2008 12:48:58 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<item>
		<title>Cloning Backpack</title>
		<link>http://www.cuppadev.co.uk/uncategorized/cloning-backpack/</link>
		<comments>http://www.cuppadev.co.uk/uncategorized/cloning-backpack/#comments</comments>
		<pubDate>Sun, 17 Aug 2008 11:42:04 +0000</pubDate>
		<dc:creator>James Urquhart</dc:creator>
		
		<category><![CDATA[Projects]]></category>

		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[AJAX]]></category>

		<category><![CDATA[backpack]]></category>

		<category><![CDATA[backpack clone]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[ruby on rails]]></category>

		<category><![CDATA[rucksack]]></category>

		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.cuppadev.co.uk/?p=242</guid>
		<description><![CDATA[Just over a month ago now, i got sick of my chief open source project, RailsCollab. Nobody seemed interested in it, and the code was growing tired and deprecated. So i decided to try making another open Ruby on Rails project.
Like my previous chief open source project, i decided my new one was also going [...]]]></description>
			<content:encoded><![CDATA[<p>Just over a month ago now, i got sick of my chief open source project, <a href="http://github.com/jamesu/railscollab/tree/master">RailsCollab</a>. Nobody seemed interested in it, and the code was growing tired and deprecated. So i decided to try making another open <a href="http://www.rubyonrails.org">Ruby on Rails</a> project.</p>
<p>Like my previous chief open source project, i decided my new one was also going to be a clone. Mainly because i couldn&#8217;t really come up with anything else more interesting, bu i also wanted to see what it would be like cloning something from scratch.</p>
<p>After much deliberation, i decided the focus of my attention would be to clone another of 37Signals&#8217; products. Not <a href="http://basecamphq.com/">Basecamp</a> this time - that has already been done to death. Instead, i decided to try and clone&#8230; <a href="http://www.backpackit.com/"><strong>Backpack</strong></a>!</p>
<p style="text-align:center"><a href="http://www.cuppadev.co.uk/wp-content/uploads/2008/08/picture-2.png"><img src="http://www.cuppadev.co.uk/wp-content/uploads/2008/08/picture-2-300x151.png" alt="" title="backpack" width="300" height="151" class="alignnone size-thumbnail wp-image-247" /></a></p>
<p>Interestingly while i looked far and wide for a comparable product, i couldn&#8217;t seem to find anything. The only one that came remotely close was <a href="http://tiddlywiki.org/">TiddlyWiki</a>. But while that was free and open, i felt it completely missed the niche that Backpack filled. Collaboratively edited pages, which are actually easy to edit.</p>
<h3>The nitty gritty</h3>
<p>First of all - before i even writ one line of code - i decided to check out Backpack&#8217;s underlying data models. They told me a lot about how Backpack worked, and of course they gave me a few hints about what data i should store.</p>
<pre style="height: 240px; overflow: auto;"><code>
Backpack

Models

(generally created and modified dates exist for all of these) 

Pages
    - scope
    - title
    - email_address

    Belongings (basically reference from page -> list item + position.
                     referred to by id)
    Lists
        - name
        List Items
            - completed
            - content
            - order
    Notes
        - title
        - content
    Seperators
        - name
        - page id
    Tags
        - name
    WriteboardLink
Writeboard
    - title

    WriteboardPages
        - content
Reminders
    - at time
    - content
    - creator
    - remindees [Users]
Emails
    - title
    - content
Statuses (one per user)
    - message (text)
    - last update
    - owner
Journals
    - body (length=255)
    - owner
    - last update
Users
    - name
Calendar
    - color
    - subscription url (pulling from other calendar?)
    - name
    - token (used in url for sharing)

    Events
        - title
        - occurs_at
        - occurs_until
        - reminded_at
        - remind (bool, note fixed time before)
        - all day (bool)
</code></pre>
<p>Next i decided to sketch out some of the models. <strong>has_many</strong>, <strong>belongs_to</strong>, etc. I also decided to give some models such as the &#8220;Belongings&#8221; different names, as i thought the originals sucked.</p>
<p>(Note that by this time i decided to concentrate my efforts on making a <strong>Page editor</strong>, as i felt that was the key defining feature)</p>
<p>After i got that out the way, i built a simple page <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer">RESTful</a> scaffold for editing pages. All it did was render page slots and the widgets contained therein. What it lacked was the rather crucial <a href="http://en.wikipedia.org/wiki/AJAX">AJAX</a> editing that was prevalent in Backpack.</p>
<p>So then i decided to take a closer look at how Backpack&#8217;s AJAX page editing worked. It turned out that there were a few crucial components:</p>
<ul>
<li><strong>The widgets</strong> - the real content of the page. e.g. Notes, Lists, Dividers</li>
<li><strong>The insertion bar</strong> - this pops up when you hover your mouse over the top or bottom of the widgets.</li>
<li><strong>The action bar</strong> - this pops up when you click &#8220;Insert Here&#8221; on the insertion bar, and is inserted between the relevant widgets.</li>
<li><strong>The actions on the action bar</strong> - when you click on them, either a widget is inserted (e.g. list) or a form is shown in the slate.</li>
<li><strong>The slate</strong> - this either exists in a container before the widgets, or in the action bar. It contains most of the forms.</li>
</ul>
<p>These components are almost exclusively powered by client-side Javascript. Only when you get to the parts where content is added, edited, or removed from a page do you get an AJAX request sent to the server. e.g. Inserting edit forms, adding widgets and belongings, etc.</p>
<p>What you get back from the server is usually Javascript code which alters the content in the page according to the request.</p>
<p>So once i figured all that out, i eventually managed to implement a rather nifty AJAX-powered page editor which somewhat resembled Backpack&#8217;s. Mission accomplished!</p>
<h3>The result</h3>
<p style="text-align: center;"><a href="http://www.cuppadev.co.uk/wp-content/uploads/2008/08/picture-11.png"><img src="http://www.cuppadev.co.uk/wp-content/uploads/2008/08/picture-11-300x132.png" alt="" title="rucksack" width="300" height="132" class="alignnone size-thumbnail wp-image-246" /></a></p>
<p>Well, here it is. It&#8217;s called Rucksack, and it acts similarly to Backpack. You can make pages, and share them with others to edit collaboratively. Strange but true.</p>
<p>&#8220;<em>Now wait a minute!</em>&#8221; you might be thinking, &#8220;<em>it looks like crap, and it doesn&#8217;t implement everything</em>&#8220;. True, but remember that i was only interested in implementing a <strong>proof-of-concept</strong> page editor. I wasn&#8217;t planning on implementing everything and making it look nice. That is for later.</p>
<p>Now while i did start off thinking of Rucksack as a Backpack clone, i don&#8217;t think it is the best frame of mind to be in. So for future development, i will be concentrating less on copying backpack, and more on tailoring it to what i think will be useful in organising.</p>
<p>Meanwhile, i have put the code up on <a href="https://github.com/jamesu/rucksack/tree">github for anyone to check out</a>.</p>
<p class="akst_link"><a href="http://www.cuppadev.co.uk/?p=242&amp;akst_action=share-this"  title="Email, post to del.icio.us, etc." id="akst_link_242" class="akst_share_link" rel="noindex nofollow">ShareThis</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://www.cuppadev.co.uk/uncategorized/cloning-backpack/feed/</wfw:commentRss>
		</item>
		<item>
		<title>JavaScript 2 dead? Have no fear, haXe is here!</title>
		<link>http://www.cuppadev.co.uk/webquirks/javascript-2-dead-have-no-fear-haxe-is-here/</link>
		<comments>http://www.cuppadev.co.uk/webquirks/javascript-2-dead-have-no-fear-haxe-is-here/#comments</comments>
		<pubDate>Wed, 13 Aug 2008 21:09:14 +0000</pubDate>
		<dc:creator>James Urquhart</dc:creator>
		
		<category><![CDATA[WebQuirks]]></category>

		<category><![CDATA[ecmascript]]></category>

		<category><![CDATA[haxe]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[standards]]></category>

		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.cuppadev.co.uk/?p=234</guid>
		<description><![CDATA[Earlier on, i noticed this little gem on reddit:

Which led me to this rather interesting mailing list post by Douglas Crockford:

I apologize for my ultrablunt comment. Let me be clear about what I
meant. It was decided at the Oslo meeting that the project formerly
known as ES4 is no more. Instead, there will be a new [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier on, i noticed this little gem on reddit:</p>
<p style="text-align:left"><img src="http://www.cuppadev.co.uk/wp-content/uploads/2008/08/picture-1.png" alt="" title="picture-1" width="428" height="58" class="alignnone size-full wp-image-235" /></p>
<p>Which led me to this rather interesting mailing list post by Douglas Crockford:</p>
<pre><code>
I apologize for my ultrablunt comment. Let me be clear about what I
meant. It was decided at the Oslo meeting that the project formerly
known as <strong>ES4 is no more</strong>. Instead, there will be a new project,
Harmony, which will be the work of a unified working group. We have
not yet agreed on a set of goals for Harmony.

I recommend that we close the ES4 list and open a harmony list to
support this new effort.
</code></pre>
<p>Looks like nobody can agree on any set goals for JavaScript 2 (i.e. ES4). Which leads me to think that as with a lot of web standards, JavaScript 2 is just a pipe dream.</p>
<p style="text-align:left"><a href="http://www.haxe.org"><img style="border:0px;" src="http://cuppadev.co.uk/assets/2007/10/4/haxe_banner.png"/></a></p>
<p>Fortunately though, the real world has a solution which already works. Its called <a href="http://www.haxe.org">haXe</a>, and it implements a lot of what JavaScript 2 <a href="http://blog.haxe.org/entry/25">should be</a>.</p>
<p>So instead of waiting about for some standards crackpots trying to cobble together a standard, you can write some real code.</p>
<p>Have fun with haXe.</p>
<p class="akst_link"><a href="http://www.cuppadev.co.uk/?p=234&amp;akst_action=share-this"  title="Email, post to del.icio.us, etc." id="akst_link_234" class="akst_share_link" rel="noindex nofollow">ShareThis</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://www.cuppadev.co.uk/webquirks/javascript-2-dead-have-no-fear-haxe-is-here/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Another way of using iPhone Web Apps Offline</title>
		<link>http://www.cuppadev.co.uk/webhacks/another-way-of-using-iphone-web-apps-offline/</link>
		<comments>http://www.cuppadev.co.uk/webhacks/another-way-of-using-iphone-web-apps-offline/#comments</comments>
		<pubDate>Sat, 09 Aug 2008 13:52:59 +0000</pubDate>
		<dc:creator>James Urquhart</dc:creator>
		
		<category><![CDATA[WebHacks]]></category>

		<category><![CDATA[iphone]]></category>

		<category><![CDATA[web development]]></category>

		<category><![CDATA[webkit]]></category>

		<guid isPermaLink="false">http://www.cuppadev.co.uk/?p=229</guid>
		<description><![CDATA[I mentioned a while ago that it was possible to make off-line web apps using a combination of the data:/ uri support and the database storage on the iPhone 2.0 firmware. While this solution works, it sure is a bit of a hack.
Fortunately there is another way to use web apps offline on the iPhone. [...]]]></description>
			<content:encoded><![CDATA[<p>I <a href="http://www.cuppadev.co.uk/oldbrew/iphone-magic/">mentioned a while ago</a> that it was possible to make off-line web apps using a combination of the data:/ uri support and the database storage on the iPhone 2.0 firmware. While this solution works, it sure is a bit of a hack.</p>
<p>Fortunately there is another way to use web apps offline on the iPhone. It turned out to be so simple i wondered why i didn&#8217;t think of it before. Well, here is how you do it:</p>
<p style="text-align:center;"><iframe src='http://docs.google.com/EmbedSlideshow?docid=dg44j92p_739svz9tz' frameborder='0' width='410' height='342'></iframe></p>
<p>Hey presto! While you do get a warning, you can still use your lovely web app offline. Unless of course, you restart your iPhone or close the window. If that happens, your data will still be safe if your web app uses the database api to store it. Just hope you get your signal back so you can start working again. :)</p>
<p class="akst_link"><a href="http://www.cuppadev.co.uk/?p=229&amp;akst_action=share-this"  title="Email, post to del.icio.us, etc." id="akst_link_229" class="akst_share_link" rel="noindex nofollow">ShareThis</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://www.cuppadev.co.uk/webhacks/another-way-of-using-iphone-web-apps-offline/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Fuzzy Times</title>
		<link>http://www.cuppadev.co.uk/webdev/fuzzy-times/</link>
		<comments>http://www.cuppadev.co.uk/webdev/fuzzy-times/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 20:04:28 +0000</pubDate>
		<dc:creator>James Urquhart</dc:creator>
		
		<category><![CDATA[WebDev]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[natural language parsing]]></category>

		<category><![CDATA[ruby on rails]]></category>

		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.cuppadev.co.uk/?p=218</guid>
		<description><![CDATA[Recently i have been writing a simple web-based reminder app which requires one to input dates and times. To input the date and time, normally one would add some sort of calendar widget which pops up. 

But personally i think this tends to be really awkward, especially if you don&#8217;t want to be specific about [...]]]></description>
			<content:encoded><![CDATA[<p>Recently i have been writing a simple web-based reminder app which requires one to input dates and times. To input the date and time, normally one would add some sort of calendar widget which pops up. </p>
<p style="text-align:center"><img src="http://www.cuppadev.co.uk/wp-content/uploads/2008/08/calendar-widget.png" alt="" title="calendar-widget1" width="138" height="185" class="alignnone size-thumbnail wp-image-223" /></p>
<p>But personally i think this tends to be really awkward, especially if you don&#8217;t want to be specific about dates or times. e.g. Speculative Opportunities. It also requires a lot of mouse clicking to find and enter the correct date and time.</p>
<p style="text-align:center"><img src="http://www.cuppadev.co.uk/wp-content/uploads/2008/08/reminders-parsing.png" alt="" title="reminders-parsing" width="275" height="143" class="alignnone size-thumbnail wp-image-220" /></p>
<p>Fortunately, there are libraries about which aim to solve this issue by allowing you to specify the time in English. Typically they are referred to as &#8220;Natural language&#8221; date/time parsers. In my case, i found one called <a href="http://chronic.rubyforge.org/">Chronic</a> which is distributed as a gem for Ruby. It has even got a nice <a href="http://www.rubyinside.com/chronic-ruby-date-time-parser-screencast-263.html">screencast</a>.</p>
<pre><code>sudo gem install chronic</code></pre>
<p>Consisting of only one public function, Chronic is really easy to use:</p>
<pre><code>
require 'chronic'
Chronic.parse("tomorrow at 5")
 #=> Fri Aug 08 17:00:00 +0100 2008
</code></pre>
<p>See? Nice and simple. We can also use the options to help chronic get the right time. e.g. If i really meant to say &#8220;Tomorrow at 5 AM&#8221;, i could fix it like this:</p>
<pre><code>
require 'chronic'
Chronic.parse("tomorrow at 5", :ambiguous_time_range => :none)
 #=> Fri Aug 08 5:00:00 +0100 2008
</code></pre>
<p>The options you can choose from are as follows:</p>
<ul>
<li><strong>:context</strong> - the context in which the time is assessed (<strong>:past</strong> or <strong>:future</strong>).</li>
<li><strong>:now</strong> - current time.</li>
<li><strong>:guess</strong> - if false, this returns a time range instead of guessing at a specific time.</li>
<li><strong>:ambiguous_time_range</strong> - range in hours in which an ambiguous time will be resolved. Best to think of it as hours to skip in the day when picking a time. e.g. setting this to 18 and inputting 5 will result in 5am the next day being chosen.</li>
</ul>
<p>Sadly i couldn&#8217;t seem to find any way of setting which time zone to evaluate the time in. This would have been useful when working with <a href="http://mad.ly/2008/04/09/rails-21-time-zone-support-an-overview/">Ruby on Rails 2.1&#8217;s new TimeZone support</a>. Fortunately though, i figured out a workaround which is as follows:</p>
<pre><code>
# grab time using current time zone as reference
ctime = Chronic.parse(value, :now => Time.zone.now)
# re-interpret time in current timezone
ctime = Time.zone.local(ctime.year, ctime.mon, ctime.day, ctime.hour, ctime.min, ctime.sec)
</code></pre>
<p>Basically this gives Chronic the time in the current time zone, which deals with relative times (e.g. &#8220;tomorrow&#8221;). It also re-interprets the calculated time in case you are a bit more specific (e.g. &#8220;5AM&#8221;).</p>
<p>For something a bit less hackish, one might want to check out <a href="http://github.com/technoweenie/chronic/tree/master">technoweenie&#8217;s fork on github</a>. This appears to allow you to tell Chronic to use a different Time class for calculating times, which should solve the problem.</p>
<p>So to conclude, i think Chronic is a nice and simple solution that works rather nicely for common cases.</p>
<h3>Other libraries</h3>
<p>If you aren&#8217;t using Ruby, have no fear. There are similar &#8220;Natural language&#8221; parsers available for other programming environments which work in a similar fashion to Chronic.</p>
<ul>
<li><a href="http://www.datejs.com/">Datejs</a> for JavaScript</li>
<li><a href="http://code.google.com/p/parsedatetime/">parsedatetime</a> for Python</li>
<li><a href="http://search.cpan.org/~schubiger/DateTime-Format-Natural-0.71/lib/DateTime/Format/Natural.pm">DateTime::Format::Natural</a> for Perl</li>
<li><a href="http://www.codeplex.com/DateTimeEnglishParse">DateTimeEnglishParser</a> for .net</li>
</ul>
<p class="akst_link"><a href="http://www.cuppadev.co.uk/?p=218&amp;akst_action=share-this"  title="Email, post to del.icio.us, etc." id="akst_link_218" class="akst_share_link" rel="noindex nofollow">ShareThis</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://www.cuppadev.co.uk/webdev/fuzzy-times/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Brain-Dead Canvas Quirk</title>
		<link>http://www.cuppadev.co.uk/webquirks/brain-dead-canvas-quirk/</link>
		<comments>http://www.cuppadev.co.uk/webquirks/brain-dead-canvas-quirk/#comments</comments>
		<pubDate>Sat, 02 Aug 2008 15:26:55 +0000</pubDate>
		<dc:creator>James Urquhart</dc:creator>
		
		<category><![CDATA[WebQuirks]]></category>

		<category><![CDATA[canvas]]></category>

		<category><![CDATA[html5]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.cuppadev.co.uk/?p=165</guid>
		<description><![CDATA[The HTML5 Canvas. Great, isn&#8217;t it? You can draw pretty much anything you want in a pre-defined area. In more recent browsers, you can even get &#038; set pixel data too, so you pretty much have full control over how things look.
 var ctx = document.getElementById('examplecanvas').getContext('2d'); ctx.fillRect(10,10,190,80); ctx.fillStyle = "rgb(255,255,255)"; ctx.fillRect(20,20,170,60);
The problem
Unfortunately, the Canvas suffers [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.whatwg.org/specs/web-apps/current-work/#the-canvas">HTML5 Canvas</a>. Great, isn&#8217;t it? You can draw pretty much anything you want in a pre-defined area. In more recent browsers, you can even get &#038; set pixel data too, so you pretty much have full control over how things look.</p>
<p> <canvas id="examplecanvas" width="210" height="100"></canvas><script type="text/javascript">var ctx = document.getElementById('examplecanvas').getContext('2d'); ctx.fillRect(10,10,190,80); ctx.fillStyle = "rgb(255,255,255)"; ctx.fillRect(20,20,170,60);</script></p>
<h3>The problem</h3>
<p>Unfortunately, the Canvas suffers from a pretty brain-dead design flaw. That is while you can get and set pixels, you cannot control when the pixel data you grab with <strong>getPixelData()</strong> will be freed from memory. This is exacerbated by the fact that the whole interface runs on top of JavaScript.</p>
<p>&#8220;<em>Now wait a minute</em>&#8220;, you might think &#8220;<em>doesn&#8217;t JavaScript have garbage collection for this sort of stuff</em>?&#8221;. Well, yes. The trouble is, JavaScript has <strong>no standardized garbage collection system</strong>, so depending on which browser you happen to be using it&#8217;s pot luck whether or not your pixel data will get freed on time.</p>
<h3>An example</h3>
<p>To start off with, <a href="http://www.cuppadev.co.uk/assets/canvas-quirk.html">here&#8217;s a really simple example test case</a>, using &#8220;<strong>putImageData(getImageData())</strong>&#8220;.</p>
<p>Now lets use a real example here. A while back, you might recall i was writing a <a href="http://www.cuppadev.co.uk/oldbrew/scumm-in-javascript/">SCUMM interpreter</a> in haXe that just so happened to compile to JavaScript as well. For the SCUMM runtime, i am required to display room graphics overlaid with various objects. The graphics are 8bit and use a palette, and that palette can be changed at runtime.</p>
<p style="text-align:center;"><img src="http://www.cuppadev.co.uk/wp-content/uploads/2008/08/palette_mapping.png" alt="R - PALETTE - RGB" title="palette_mapping" width="400" height="106" class="size-full wp-image-174" /></p>
<p>For performance reasons, i decode the graphics and store them in Canvas elements using only the red channel. In fact, throughout the graphics processing pipeline, the red channel is the only part of the pixel data i use. I also make heavy use of the native blitting functions (e.g. fillRect).</p>
<p>It&#8217;s not until i come to display the graphics that i re-map the pixels from the red channel into the final colours using the current palette. This requires me to <strong>getImageData()</strong> the current pixels in the canvas, iterate through and set the <strong>data[]</strong>, and then <strong>putImageData()</strong> back to the Canvas for the final result.</p>
<p>The trouble is since i am re-mapping the pixels every frame, memory usage on certain browsers (<a href="http://www.opera.com/">Opera</a>, <a href="http://www.mozilla.com/firefox/">Firefox</a>) <strong>skyrockets</strong> up to a certain threshold - anything up to 2gb depending on what is happening.</p>
<p style="text-align:center;"><img src="http://www.cuppadev.co.uk/wp-content/uploads/2008/08/mem_compare_testcase1.png" alt="" title="mem_compare_testcase1" width="442" height="75" class="alignnone size-medium wp-image-178" /></p>
<p>For the test case running on <a href="http://www.apple.com/macosx">OS X</a>, Opera> tops out at ~600mb. <a href="http://www.webkit.org">Webkit</a> and Firefox both top out at around 1.25gb (honestly though, i just stopped looking as it was getting stupid). It&#8217;s not until i either suspend re-draw and wait several seconds, or simply close the browser window that memory usage returns to normal.</p>
<p>Oddly enough when re-mapping the pixels in my SCUMM interpreter (not in the test case), Webkit&#8217;s memory usage stays constant. This flies in the face of what one would expect to happen based on the test case. As for why, it could be anything. The smaller canvas size, assignment of variables - who knows.</p>
<h3>Workarounds?</h3>
<p>Realistic workarounds include:</p>
<ul>
<li>Perform all graphics operations manually on a single set of pixel data (<strong>too slow!</strong>)</li>
<li>Use <strong>drawImage()</strong> as opposed to <strong>getImageData()</strong> &#038; <strong>putImageData()</strong></li>
<li>Limit the amount of screen updates</li>
<li>When working with palletised image data that needs re-mapping, store it as RGB, and re-calculate it <strong>only</strong> when the palette changes</li>
<li>Don&#8217;t use <strong>getImageData()</strong> at all, especially considering it doesn&#8217;t seem to work in Safari at the moment.</li>
</ul>
<p>Either that, or simply implement everything which needs pixel-level graphics manipulation in <a href="http://www.adobe.com/flash/">Flash</a> or a <a href="http://java.sun.com/applets/">Java Applet</a>, foregoing the pure Javascript ethic.</p>
<p class="akst_link"><a href="http://www.cuppadev.co.uk/?p=165&amp;akst_action=share-this"  title="Email, post to del.icio.us, etc." id="akst_link_165" class="akst_share_link" rel="noindex nofollow">ShareThis</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://www.cuppadev.co.uk/webquirks/brain-dead-canvas-quirk/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Running your own iPhone applications without paying the developer fee</title>
		<link>http://www.cuppadev.co.uk/platforms/running-your-own-iphone-applications-without-paying-the-developer-fee/</link>
		<comments>http://www.cuppadev.co.uk/platforms/running-your-own-iphone-applications-without-paying-the-developer-fee/#comments</comments>
		<pubDate>Tue, 22 Jul 2008 16:39:45 +0000</pubDate>
		<dc:creator>James Urquhart</dc:creator>
		
		<category><![CDATA[Platforms]]></category>

		<category><![CDATA[deployment]]></category>

		<category><![CDATA[development]]></category>

		<category><![CDATA[iphone]]></category>

		<guid isPermaLink="false">http://www.cuppadev.co.uk/?p=158</guid>
		<description><![CDATA[For those of you wanting to build off-line, native applications for the iPhone / iPod Touch (with the 2.0 Software Update), you might have been disappointed to hear you need to shelve out $99 yearly for the privilege of being able to run your applications on a real iPhone.
Ok, $99 might not be a lot, [...]]]></description>
			<content:encoded><![CDATA[<p>For those of you wanting to build off-line, native applications for the <a href="http://apple.com/iphone">iPhone</a> / <a href="http://www.apple.com/ipodtouch/">iPod Touch</a> (with the <a href="http://www.apple.com/iphone/softwareupdate/">2.0 Software Update</a>), you might have been disappointed to hear you need to shelve out $99 yearly for the privilege of being able to run your applications on a real iPhone.</p>
<p>Ok, $99 might not be a lot, but one also has to consider when you come to deploy your app for real, it might not pass through the rather stringent screening process to get it to the masses through the App Store.</p>
<p>Wouldn&#8217;t it be great if you could deploy any application you wanted for <strong>free</strong>?</p>
<p>Well thanks to the recently released pwnage tool, it&#8217;s now possible to run non-Apple-approved applications on your iPhone though &#8220;Jailbreaking&#8221;. I&#8217;ve spent quite a while trying to figure out how to get this working.  Here&#8217;s what i have come up with so far.</p>
<h3>First of all&#8230;</h3>
<p><em>If you are not using a Mac, or you don&#8217;t have the <a href="http://developer.apple.com/iphone/">iPhone SDK</a> installed, or alternatively the &#8220;open toolkit&#8221;, then these instructions will be of no use to you.</em></p>
<p>If you haven&#8217;t done so yet, Jailbreak your iPhone / iPod touch via the &#8220;pwnage tool&#8221;. For reference, this is what i did:</p>
<ol>
<li><a href="http://blog.iphone-dev.org/post/42931306/pwnagetool-2-0-1">Download the pwnage tool</a></li>
<li><a href="http://news.metaparadigma.de/?p=347">Create and transfer Jailbroken firmware using the pwnage tool</a></li>
</ol>
<p>After you&#8217;ve done all that, you&#8217;ll probably notice a new application called &#8220;Cydia&#8221; appears on your iPhone screen. This is basically the way end-users can access a wide range of free &#8220;homebrew&#8221; applications on their Jailbroken iPhone&#8217;s. If you want to deploy your application to end-users, you&#8217;ll have to get it into Cydia.</p>
<p style="text-align:left"><a href='http://www.cuppadev.co.uk/wp-content/uploads/2008/07/cydia-location.jpg'><img src="http://www.cuppadev.co.uk/wp-content/uploads/2008/07/cydia-location-133x200.jpg" alt="" title="cydia-location" width="133" height="200" class="alignnone size-thumbnail wp-image-162" /></a></p>
<p>But enough about Cydia for now&#8230; </p>
<h3>I&#8217;ve built applications, how on earth do i get them over to my iPhone?</h3>
<p style="text-align:left"><a href='http://www.cuppadev.co.uk/wp-content/uploads/2008/07/iphone_sdk_set.png'><img src="http://www.cuppadev.co.uk/wp-content/uploads/2008/07/iphone_sdk_set-300x56.png" alt="" title="Project, Set Active SDK, Device - iPhone OS 2.0" width="300" height="56" class="alignnone size-thumbnail wp-image-159" /></a></p>
<p>If you are using XCode, make sure you set the SDK of your application to &#8220;Device - iPhone OS 2.0&#8243; (or the equivalent if it exists). Then all you need to do is click &#8220;Build and go&#8221;, and your application should appear on your iPhone.</p>
<p style="text-align:left"><a href='http://www.cuppadev.co.uk/wp-content/uploads/2008/07/iphone_sdk_error.png'><img src="http://www.cuppadev.co.uk/wp-content/uploads/2008/07/iphone_sdk_error-300x111.png" alt="" title="iphone_sdk_error" width="300" height="111" class="alignnone size-thumbnail wp-image-161" /></a></p>
<p>Now you&#8217;ll probably get this rather &#8220;Unexpected error&#8221; popping up if you try and run your application with XCode.</p>
<p>Unfortunately while the pwnage tool allows you to run any application, that application still needs to be signed. So how do you sign it? Well, the best tutorial for that i have found is the &#8220;<a href="http://developer.apple.com/documentation/Security/Conceptual/CodeSigningGuide/Procedures/chapter_3_section_2.html">Code Signing Guide</a>&#8221; on Apple&#8217;s website.</p>
<p>You&#8217;ll need to make a self-signed certificate using the Keychain Access utility. <del datetime="2008-07-29T13:51:25+00:00">Then you should run the following commands in a terminal on your built application:</del></p>
<p><del datetime="2008-07-29T13:51:25+00:00">
<pre>
<code>
export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform//Developer/usr/bin/codesign_allocate
codesign -fs "Name of your certificate here" /Path/to/your/built/application.app
</code>
</pre>
<p></del></p>
<p><del datetime="2008-07-29T13:51:25+00:00">Unfortunately even when you do this, you still cannot run your app using XCode, so you can&#8217;t use any of those fancy debug tools with it. </del></p>
<p><del datetime="2008-07-29T13:51:25+00:00">In order to run your application, you&#8217;ll have to copy it over yourself. You can either use OpenSSH (installed through Cydia), or <a href="http://code.google.com/p/iphonedisk/">iphonedisk</a>. I used OpenSSH, as i had problems with the permissions not being preserved with iphonedisk:<br />
</del></p>
<pre>
<code>
<del datetime="2008-07-29T13:51:25+00:00">scp -r /Path/to/your/built/application.app root@address_of_your_iphone_or_ipod:/Applications/</del>
</code>
</pre>
<p><del datetime="2008-07-29T13:51:25+00:00">Re-load the springboard either by installing something with Cydia, or restarting your iPhone. And hey presto, your app appears!</del></p>
<p><strong>Update:</strong> There is now a way to get your apps working directly from XCode. Simply follow the <a href="http://www.246tnt.com/iPhone/#xcode">instructions here</a>, and you should be able to debug your application straight from XCode. Neat!</p>
<p style="text-align:left"><a href='http://www.cuppadev.co.uk/wp-content/uploads/2008/07/newapp-location.jpg'><img src="http://www.cuppadev.co.uk/wp-content/uploads/2008/07/newapp-location-133x200.jpg" alt="" title="newapp-location" width="133" height="200" class="alignnone size-thumbnail wp-image-163" /></a></p>
<p><em>Note: there are of course other ways to get your app working, but personally i found signing it to be the most obvious.</em></p>
<h3>Right, now my application is ready for public consumption</h3>
<p>Great! So how do we get it into Cydia? Well there are two options:</p>
<ol>
<li>Get the Cydia guy&#8217;s to host it in their repository</li>
<li><a href="http://www.saurik.com/id/7">Make your own repository</a></li>
</ol>
<p>Well i couldn&#8217;t figure out how you are meant to contact the Cydia guy&#8217;s to get your application in their repository. Realistically speaking, this is the only way people are going to find your application, considering there is currently no user friendly way to add new repositories to Cydia.</p>
<p>After all, would you really want to type all of this into the terminal to add a single repository?</p>
<pre>
<code>
ssh root@address_of_your_iphone_or_ipod
echo "deb http://location.of/apt_repository/ ./" > /etc/apt/sources.list.d/apt_repository.list
</code>
</pre>
<h3>To conclude</h3>
<p>If you are really serious about making money off developing iPhone apps, then i&#8217;d cough up and pay the $99 developer fee. That way you&#8217;ll be able to target <strong>every</strong> iPhone / iPod Touch user, while being able to charge a fee for downloading.</p>
<p>If however you have an application Apple are never going to distribute (e.g. emulators), or you are just playing about and don&#8217;t mind the lack of XCode integration for on-device debugging, then developing for Jailbroken devices is for you. Personally though i&#8217;d recommend you compile your own &#8220;open toolkit&#8221;, as developing your own unofficial apps using the official SDK is legally questionable.</p>
<p class="akst_link"><a href="http://www.cuppadev.co.uk/?p=158&amp;akst_action=share-this"  title="Email, post to del.icio.us, etc." id="akst_link_158" class="akst_share_link" rel="noindex nofollow">ShareThis</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://www.cuppadev.co.uk/platforms/running-your-own-iphone-applications-without-paying-the-developer-fee/feed/</wfw:commentRss>
		</item>
		<item>
		<title>First Impressions of iPhone v2.0 Firmware</title>
		<link>http://www.cuppadev.co.uk/platforms/first-impressions-of-iphone-v20-firmware/</link>
		<comments>http://www.cuppadev.co.uk/platforms/first-impressions-of-iphone-v20-firmware/#comments</comments>
		<pubDate>Sat, 12 Jul 2008 21:11:13 +0000</pubDate>
		<dc:creator>James Urquhart</dc:creator>
		
		<category><![CDATA[Platforms]]></category>

		<category><![CDATA[iphone]]></category>

		<category><![CDATA[safari]]></category>

		<category><![CDATA[web development]]></category>

		<category><![CDATA[webkit]]></category>

		<guid isPermaLink="false">http://www.cuppadev.co.uk/?p=154</guid>
		<description><![CDATA[Finally, Apple have released version 2.0 of their iPhone and iPod Touch firmware. Priced at $9.95 for Touch owners (though free to iPhone owners), i think it delivers excellent value for money, especially considering the previous update for the iPod Touch cost $20 and didn&#8217;t include the App Store.
The new features i am interested in [...]]]></description>
			<content:encoded><![CDATA[<p>Finally, Apple have released <a href="http://www.apple.com/uk/iphone/softwareupdate/">version 2.0</a> of their iPhone and iPod Touch firmware. Priced at $9.95 for Touch owners (though free to iPhone owners), i think it delivers excellent value for money, especially considering the previous update for the iPod Touch cost $20 and didn&#8217;t include the App Store.</p>
<p>The new features i am interested in however are all tied into the web browser. Specifically, the <a href="http://webkit.org/blog/126/webkit-does-html5-client-side-database-storage/">database support</a>, <a href="http://www.sitepen.com/blog/2008/07/10/touching-and-gesturing-on-the-iphone/">touch event handling</a>, <a href="http://webkit.org/blog/130/css-transforms/">CSS transforms</a>, and to tie everything together to make more native-looking apps, <a href="http://groups.google.com/group/iphonewebdev/browse_thread/thread/49470052638741f6?fwc=1">full-screen support.</a></p>
<h3>So is it worth it?</h3>
<p>Well i am pleased to report that most of these features have made their way to the update. My database demo which i <a href="http://www.cuppadev.co.uk/oldbrew/iphone-magic/">posted about previously</a> works fine, though initially i was a bit concerned that i didn&#8217;t see a &#8220;databases&#8221; section in the configuration options in Safari.</p>
<p style="text-align:center"><a href="http://www.cuppadev.co.uk/wp-content/uploads/2008/07/photo2.jpg"><img class="alignnone size-thumbnail wp-image-157" title="The result" src="http://www.cuppadev.co.uk/wp-content/uploads/2008/07/photo2-133x200.jpg" alt="" width="133" height="200" /></a><a href="http://www.cuppadev.co.uk/wp-content/uploads/2008/07/photo1.jpg"><img class="alignnone size-medium wp-image-156" title="The database section present and accounted for" src="http://www.cuppadev.co.uk/wp-content/uploads/2008/07/photo1-133x200.jpg" alt="" width="133" height="200" /></a><a href="http://www.cuppadev.co.uk/wp-content/uploads/2008/07/photo.jpg"><img class="alignnone size-thumbnail wp-image-155" title="Database storage" src="http://www.cuppadev.co.uk/wp-content/uploads/2008/07/photo-133x200.jpg" alt="" width="133" height="200" /></a></p>
<p>Turned out that this only appears when at least 1 database is created. A word of warning though: when i deleted my test database, the section vanished and i could only get it back by restarting the system. So watch out if you are playing about with it.</p>
<p>Sadly it appears that one of the binding features, the full-screen support, hasn&#8217;t made it into the update. Supposedly, you are meant to insert the a &#8220;apple-touch-fullscreen&#8221; meta tag into your HTML document, but i didn&#8217;t notice any difference whatsoever when i tried it. A huge disappointment, IMO.</p>
<p>Regardless, i think this is a positive step towards making the iPhone/iPod&#8217;s web application development platform actually useful - in a stark contrast to just over a year ago when Apple were promoting a rather limited web development platform with none of these cool features as <em>the only</em> way of getting third party applications on the iPhone.</p>
<p>Let&#8217;s not forget that for those not content with working within the limitations of the iPhone&#8217;s web development platform, there is now also the native <a href="http://developer.apple.com/iphone/">iPhone SDK</a>. So all in all, there&#8217;s a bit for everyone in this update.</p>
<p>So is it worth installing? Hell, yes!</p>
<p class="akst_link"><a href="http://www.cuppadev.co.uk/?p=154&amp;akst_action=share-this"  title="Email, post to del.icio.us, etc." id="akst_link_154" class="akst_share_link" rel="noindex nofollow">ShareThis</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://www.cuppadev.co.uk/platforms/first-impressions-of-iphone-v20-firmware/feed/</wfw:commentRss>
		</item>
		<item>
		<title>RailsCollab Alpha 3</title>
		<link>http://www.cuppadev.co.uk/projects/railscollab-alpha-3/</link>
		<comments>http://www.cuppadev.co.uk/projects/railscollab-alpha-3/#comments</comments>
		<pubDate>Wed, 09 Jul 2008 19:44:59 +0000</pubDate>
		<dc:creator>James Urquhart</dc:creator>
		
		<category><![CDATA[Projects]]></category>

		<category><![CDATA[activecollab]]></category>

		<category><![CDATA[projectpier]]></category>

		<category><![CDATA[railscollab]]></category>

		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.cuppadev.co.uk/?p=150</guid>
		<description><![CDATA[Hot off the presses, i&#8217;ve just pushed alpha 3 of RailsCollab to both Rubyforge and Github.
Railscollab? What&#8217;s that?
Railscollab is a re-write of the Project Management solution ActiveCollab (otherwise known as ProjectPier), which instead is written in Ruby and runs on the Ruby on Rails web development framework.
Why on earth would you want to do that?
Good [...]]]></description>
			<content:encoded><![CDATA[<p>Hot off the presses, i&#8217;ve just pushed alpha 3 of RailsCollab to both <a href="http://rubyforge.org/projects/railscollab/">Rubyforge</a> and <a href="http://github.com/jamesu/railscollab/commits/release-alpha3">Github</a>.</p>
<h3>Railscollab? What&#8217;s that?</h3>
<p>Railscollab is a re-write of the Project Management solution <a href="http://www.activecollab.com">ActiveCollab</a> (otherwise known as <a href="http://www.projectpier.org">ProjectPier</a>), which instead is written in <a href="http://www.ruby-lang.org">Ruby</a> and runs on the <a href="http://www.rubyonrails.org/">Ruby on Rails</a> web development framework.</p>
<h3>Why on earth would you want to do that?</h3>
<p>Good question. Well, it all started when the developer of ActiveCollab announced they were ditching the open source version and going commercial and closed source. Of course, there were people like me that didn&#8217;t like that. </p>
<p>So i decided to make my own fork - however i added a twist. I decided to re-write it using Ruby on Rails, since the original <a href="http://www.php.net">PHP</a> code was giving me a headache. Plus it seemed like a great way to get to know the Ruby on Rails framework.</p>
<p><em>Note that around the same time, another fork called ProjectPier arose, which opted to develop from the original PHP code.</em></p>
<h3>So what&#8217;s new?</h3>
<p>Quite a lot, actually. Pretty much everything that was present in ActiveCollab 0.7.x is now implemented, sans the the fancy web-based installer. I&#8217;ve also focussed a lot on fixing bugs and improving stability, as well as enhancing the time tracking components.</p>
<p style="text-align:left;"><a href="http://www.cuppadev.co.uk/wp-content/uploads/2008/07/time-tracking-csv1.png"><img class="size-thumbnail wp-image-152" title="time-tracking-csv1" src="http://www.cuppadev.co.uk/wp-content/uploads/2008/07/time-tracking-csv1-300x115.png" alt="Time tracking with CSV export" width="300" height="115" /></a></p>
<p>&#8230; and of course there is the configuration editor which takes advantage of Phusion Passenger.</p>
<p style="text-align:left;"><a href="http://www.cuppadev.co.uk/assets/rc_cnf.jpg"><img title="Configuration Editor" src="http://www.cuppadev.co.uk/assets/rc_cnf_th.jpg" alt="Configuration Editor" /></a></p>
<p>In addition, i have updated the RailsCollab demo, so if you don&#8217;t have the time to set everything up, you can still try out Alpha 3.</p>
<p>I&#8217;d also like to thank <strong>everyone</strong> (you know who you are) who has reported issues with RailsCollab over the past few months. Without your help, i doubt i would have had the willpower to make another release.</p>
<p>So what are you waiting for, <a href="http://freshbrew.cuppadev.co.uk">try it out already</a>. :)</p>
<p><strong>Edit:</strong> If you are stuck wondering &#8220;How do i login?&#8221;, have no fear, the solution is here. You will need to use <a href="http://openid.net/">OpenID</a> to login. </p>
<p style="text-align:left;"><img src="http://www.cuppadev.co.uk/assets/2007/8/11/openid.png" title="OpenID Logo" alt="OpenID Logo" /></p>
<p>Simply select the “Use OpenID” checkbox and type in your OpenID to login. An account should automatically be created for you if one does not already exist, provided that your OpenID provider provides a username, email, and name. </p>
<p>You can get an OpenID from many places - one of my favourites being <a href="https://www.myopenid.com/">myOpenID</a>.</p>
<p class="akst_link"><a href="http://www.cuppadev.co.uk/?p=150&amp;akst_action=share-this"  title="Email, post to del.icio.us, etc." id="akst_link_150" class="akst_share_link" rel="noindex nofollow">ShareThis</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://www.cuppadev.co.uk/projects/railscollab-alpha-3/feed/</wfw:commentRss>
		</item>
		<item>
		<title>A new focus</title>
		<link>http://www.cuppadev.co.uk/freshbrew/a-new-focus/</link>
		<comments>http://www.cuppadev.co.uk/freshbrew/a-new-focus/#comments</comments>
		<pubDate>Mon, 07 Jul 2008 21:31:42 +0000</pubDate>
		<dc:creator>James Urquhart</dc:creator>
		
		<category><![CDATA[freshbrew]]></category>

		<category><![CDATA[updates]]></category>

		<guid isPermaLink="false">http://www.cuppadev.co.uk/?p=149</guid>
		<description><![CDATA[Over the past few months, i have come to the conclusion that this blog needs a new focus.
When i first started this blog, i decided the focus was going to be &#8220;my work and anything related&#8221;. This turned out to be a bad focus point, as my real work at the time was quite honestly [...]]]></description>
			<content:encoded><![CDATA[<p>Over the past few months, i have come to the conclusion that this blog needs a new focus.</p>
<p>When i first started this blog, i decided the focus was going to be &#8220;my work and anything related&#8221;. This turned out to be a bad focus point, as my real work at the time was quite honestly boring, and writing about &#8220;anything&#8221; just simply wasn&#8217;t focussed enough.</p>
<p>More than anything, i&#8217;ve written about web development. It is a frontier which i find quite promising, and which i feel has leaped bounds these past few years. With the appearance of feature-rich development frameworks such as <a href="http://code.google.com/webtoolkit/">Google&#8217;s GWT</a> and <a href="http://www.sproutcore.com/">SproutCore</a> has come the realisation that the web - or more specifically the web browser - truly is a viable application development platform.</p>
<p><em>(Not to mention that modern web development in general does away with archaic and slow tools, instead emphasising simple and fast toolsets and the adoption of agile methodologies for quick turnaround)</em></p>
<p>So my new focus for this blog will be to write informative posts about the latest and greatest in the wonderful world of web development.</p>
<p>In addition, i&#8217;m going to be putting &#8220;anything else&#8221; on my new blog, <a href="http://jamesu.net">jamesu.net</a>.</p>
<p>So, let the experiment commence!</p>
<p> </p>
<p class="akst_link"><a href="http://www.cuppadev.co.uk/?p=149&amp;akst_action=share-this"  title="Email, post to del.icio.us, etc." id="akst_link_149" class="akst_share_link" rel="noindex nofollow">ShareThis</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://www.cuppadev.co.uk/freshbrew/a-new-focus/feed/</wfw:commentRss>
		</item>
		<item>
		<title>iPhone Magic</title>
		<link>http://www.cuppadev.co.uk/oldbrew/iphone-magic/</link>
		<comments>http://www.cuppadev.co.uk/oldbrew/iphone-magic/#comments</comments>
		<pubDate>Sat, 07 Jun 2008 02:55:55 +0000</pubDate>
		<dc:creator>James Urquhart</dc:creator>
		
		<category><![CDATA[oldbrew]]></category>

		<category><![CDATA[iphone]]></category>

		<category><![CDATA[safari]]></category>

		<category><![CDATA[web development]]></category>

		<category><![CDATA[webkit]]></category>

		<guid isPermaLink="false">http://crm.cuppadev.co.uk/?p=146</guid>
		<description><![CDATA[
 Recently i&#8217;ve been playing about with the iPhone SDK. I&#8217;m actually quite impressed at the great tools included to make development easier, whether you choose to develop native applications or web applications.
Since i wasn&#8217;t quite up to scratch with my Objective C, i thought i&#8217;d see how much better the in-built browser was. Using [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.cuppadev.co.uk/assets/dashcode.png" title="Dashcode" alt="Dashcode" style="float:left"/>
<p> Recently i&#8217;ve been playing about with the <a href="http://developer.apple.com/iphone/">iPhone <span class="caps">SDK</span></a>. I&#8217;m actually quite impressed at the great tools included to make development easier, whether you choose to develop native applications or web applications.</p>
<p>Since i wasn&#8217;t quite up to scratch with my Objective C, i thought i&#8217;d see how much better the in-built browser was. Using Dashcode, i was easily able to prototype some pretty neat touch-based interfaces.</p>
<p>Still, one of the major criticism&#8217;s i seem to find about developing web apps for the iPhone is a lack of an <strong>off-line</strong> option. If you aren&#8217;t connected to a network, you can&#8217;t make use of any web applications.</p>
<p>Well, that&#8217;s not strictly true. You can use the &#8220;data:/&#8221; <span class="caps">URI</span> hack, where you bookmark a <span class="caps">URL</span> containing the <span class="caps">HTML</span> of the application you want to use off-life. But this is not a very useful solution if you want to store persistent data your application can use after re-loading.</p>
<p>Which is why i was pleased to find out that the iPhone simulator in the <span class="caps">SDK</span> includes support for WebKit&#8217;s new <a href="http://webkit.org/blog/126/webkit-does-html5-client-side-database-storage/">Database storage <span class="caps">API</span></a>. In essence this means that you can persistently store pretty much anything you want on the client.</p>
<p>How is this useful on the iPhone? Well, it means we can now make very useful offline web applications with persistent data storage.</p>
<p>Here is the &#8220;proof of concept&#8221; i have cooked up.</p>
<p><a href="http://www.cuppadev.co.uk/iphone/database-images/">http://www.cuppadev.co.uk/iphone/database-images/</a></p>
<p>If you visit the above <span class="caps">URL</span> in the iPhone simulator, you should see three items which you can click on. (Note that these are all data:/ <span class="caps">URI</span>&#8217;s)</p>
<ul>
<li>The first creates a database (if it does not already exist) and stores the data for an image, which is then loaded back and shown on the page.</li>
<li>The second inserts a second image into the database. If you click on the first item again, there will now be two images shown on the page.</li>
<li>The third replaces the data of the first and the second image. If you click on the first item again, you might get a little shock.</li>
</ul>
<p>There are of course limitations to this Database <span class="caps">API</span>. Access to databases is restricted on a per-domain basis (although in Webkit &#8220;data:/&#8221; <span class="caps">URL</span>&#8217;s are treated as a single domain), and on the iPhone simulator you only get up to 5mb of storage.</p>
<p>Still, it works and i can see it being a very useful feature for future web applications on the iPhone.</p>
<p>This actually works in Safari 3.1 too, so you don&#8217;t need to download the huge iPhone <span class="caps">SDK</span> to try this out. It technically should work in Firefox 3 too, though as of yet i haven&#8217;t managed to get it to allow access to the database.</p>
<p class="akst_link"><a href="http://www.cuppadev.co.uk/?p=146&amp;akst_action=share-this"  title="Email, post to del.icio.us, etc." id="akst_link_146" class="akst_share_link" rel="noindex nofollow">ShareThis</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://www.cuppadev.co.uk/oldbrew/iphone-magic/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.607 seconds -->
<!-- Cached page served by WP-Cache -->
<!-- Compression = gzip -->