<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Beyond The Corner</title>
	<atom:link href="http://blog.beyondthecorner.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.beyondthecorner.co.uk</link>
	<description>The blog of Marcus Ramsden, a software developer.</description>
	<lastBuildDate>Sat, 14 Jan 2012 21:46:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='blog.beyondthecorner.co.uk' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Beyond The Corner</title>
		<link>http://blog.beyondthecorner.co.uk</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://blog.beyondthecorner.co.uk/osd.xml" title="Beyond The Corner" />
	<atom:link rel='hub' href='http://blog.beyondthecorner.co.uk/?pushpress=hub'/>
		<item>
		<title>Customised UINavigationBar background in iOS 4 and 5</title>
		<link>http://blog.beyondthecorner.co.uk/2011/11/02/217/</link>
		<comments>http://blog.beyondthecorner.co.uk/2011/11/02/217/#comments</comments>
		<pubDate>Wed, 02 Nov 2011 22:19:08 +0000</pubDate>
		<dc:creator>Marcus Ramsden</dc:creator>
				<category><![CDATA[Apple Programming]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[UIKit]]></category>

		<guid isPermaLink="false">http://blog.beyondthecorner.co.uk/?p=217</guid>
		<description><![CDATA[Recently I came across the situation that I needed to support a custom background for a UINavigationBar in an app that had to work for both iOS 4 and iOS 5. After some Googling I came up with this approach. First the easy one, iOS 5; Note the test on the navigation bar class to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.beyondthecorner.co.uk&amp;blog=7482100&amp;post=217&amp;subd=beyondtc&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Recently I came across the situation that I needed to support a custom background for a UINavigationBar in an app that had to work for both iOS 4 and iOS 5. After some Googling I came up with this approach.</p>
<p>First the easy one, iOS 5;</p>
<p><pre class="brush: objc;">
if ([[UINavigationBar class] respondsToSelector:@selector(appearance)]) {
    [self.navigationController.navigationBar setBackgroundImage:navigationBackgroundImage forBarMetrics:UIBarMetricsDefault];
}
</pre></p>
<p>Note the test on the navigation bar class to check if it supports the UI proxy extensions. This must be done in iOS 4 otherwise a crash will result.</p>
<p>Now for iOS 4 we have to create a category, fortunately this is very simple;</p>
<p><pre class="brush: objc;">
@implementation UINavigationBar (CustomBackground)

- (void)drawRect:(CGRect)rect
{
    UIImage *navBackgroundImage = [[UIImage imageNamed:@&quot;navigation-background&quot;] stretchableImageWithLeftCapWidth:0.0 topCapHeight:0.0];
    [navBackgroundImage drawInRect:rect];
}

@end
</pre></p>
<p>The <code>drawRect:</code> method is not called in iOS 5 so it is safe to leave this category in your app. Just as a small side note, Apple has deprecated <code>strechableImageLeftCapWidth:topCapHeight:</code> in iOS 5 in favour of <code>resizableImageWithCapInsets:</code>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/beyondtc.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/beyondtc.wordpress.com/217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/beyondtc.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/beyondtc.wordpress.com/217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/beyondtc.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/beyondtc.wordpress.com/217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/beyondtc.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/beyondtc.wordpress.com/217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/beyondtc.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/beyondtc.wordpress.com/217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/beyondtc.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/beyondtc.wordpress.com/217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/beyondtc.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/beyondtc.wordpress.com/217/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.beyondthecorner.co.uk&amp;blog=7482100&amp;post=217&amp;subd=beyondtc&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.beyondthecorner.co.uk/2011/11/02/217/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/37e58a68398752b5f8db87172bbe6046?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cuscus1986</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating a URL query string using an NSDictionary</title>
		<link>http://blog.beyondthecorner.co.uk/2011/05/14/creating-a-url-query-string-using-an-nsdictionary/</link>
		<comments>http://blog.beyondthecorner.co.uk/2011/05/14/creating-a-url-query-string-using-an-nsdictionary/#comments</comments>
		<pubDate>Sat, 14 May 2011 15:41:24 +0000</pubDate>
		<dc:creator>Marcus Ramsden</dc:creator>
				<category><![CDATA[Apple Programming]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">http://blog.beyondthecorner.co.uk/?p=207</guid>
		<description><![CDATA[I finally got round to making this into a category. It&#8217;s a simple function for turning a dictionary into a query string, ready for appending to the end of a URL. Using this category is very simple; You can get the sourcecode as a gist.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.beyondthecorner.co.uk&amp;blog=7482100&amp;post=207&amp;subd=beyondtc&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I finally got round to making this into a category. It&#8217;s a simple function for turning a dictionary into a query string, ready for appending to the end of a URL.</p>
<p><pre class="brush: objc;">
// NSDictionary+QueryStringBuilder.h

#import &lt;Foundation/Foundation.h&gt;

@interface NSDictionary (QueryStringBuilder)

- (NSString *)queryString;

@end
</pre></p>
<p><pre class="brush: objc;">
// NSDictionary+QueryStringBuilder.m

NSString * escapeString(NSString *string) 
{
  NSString *s = (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,
		  (CFStringRef)unencodedString,
		  NULL,
		  (CFStringRef)@&quot;!*'\&quot;();:@&amp;=+$,/?%#[]% &quot;,
		  kCFStringEncodingUTF8);
  return [s autorelease];
}

@implementation NSDictionary (QueryStringBuilder)

- (NSString *)queryString
{
    NSMutableString *queryString = nil;
    NSArray *keys = [self allKeys];

    if ([keys count] &gt; 0) {
        for (id key in keys) {
            id value = [self objectForKey:key];
            if (nil == queryString) {
                queryString = [[[NSMutableString alloc] init] autorelease];
                [queryString appendFormat:@&quot;?&quot;];
            } else {
                [queryString appendFormat:@&quot;&amp;&quot;];
            }

            if (nil != key &amp;&amp; nil != value) {
                [queryString appendFormat:@&quot;%@=%@&quot;, escapeString(key), escapeString(value)];
            } else if (nil != key) {
                [queryString appendFormat:@&quot;%@&quot;, escapeString(key)];
            }
    }

    return queryString;
}

@end
</pre></p>
<p>Using this category is very simple;</p>
<p><pre class="brush: objc;">
NSDictionary *queryParameters = [NSDictionary dictionaryWithValuesAndKeys:1, @&quot;page&quot;, nil, @&quot;enabled&quot;, 25, @&quot;size&quot;, nil];
[queryParameters queryString]; // This will return &quot;?page=1&amp;enabled&amp;size=25&quot;
</pre></p>
<p>You can get the sourcecode as a <a href="https://gist.github.com/972328">gist</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/beyondtc.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/beyondtc.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/beyondtc.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/beyondtc.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/beyondtc.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/beyondtc.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/beyondtc.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/beyondtc.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/beyondtc.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/beyondtc.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/beyondtc.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/beyondtc.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/beyondtc.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/beyondtc.wordpress.com/207/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.beyondthecorner.co.uk&amp;blog=7482100&amp;post=207&amp;subd=beyondtc&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.beyondthecorner.co.uk/2011/05/14/creating-a-url-query-string-using-an-nsdictionary/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/37e58a68398752b5f8db87172bbe6046?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cuscus1986</media:title>
		</media:content>
	</item>
		<item>
		<title>Android development on OS X without Eclipse</title>
		<link>http://blog.beyondthecorner.co.uk/2011/01/15/android-on-os-x-without-eclipse/</link>
		<comments>http://blog.beyondthecorner.co.uk/2011/01/15/android-on-os-x-without-eclipse/#comments</comments>
		<pubDate>Sat, 15 Jan 2011 22:56:45 +0000</pubDate>
		<dc:creator>Marcus Ramsden</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[homebrew]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">http://beyondtc.wordpress.com/?p=142</guid>
		<description><![CDATA[I finally got started with playing around on Android. In this post I share the process I used to getting set up with Android development using Apache Maven and the Android Maven Plugin rather than Eclipse.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.beyondthecorner.co.uk&amp;blog=7482100&amp;post=142&amp;subd=beyondtc&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://beyondtc.files.wordpress.com/2011/01/android.png"><img src="http://beyondtc.files.wordpress.com/2011/01/android.png?w=594&#038;h=278" alt="" title="Android Post Image" width="594" height="278" class="aligncenter size-full wp-image-187" /></a></p>
<h4>Introduction</h4>
<p>I am finally getting started with playing around with some Android development and the first order of business is getting my development environment set up. I&#8217;m going to be doing most of my development on OS X using Apache Maven and Textmate, of course in your situation you could use your favourite text editor, I side more with vim fans <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  I&#8217;m making the assumption that the reader is comfortable with the terminal, additionally a dosage of no fear if you are following these steps.</p>
<h4>Homebrew</h4>
<p>To get the ball rolling we&#8217;re going to start with everyone&#8217;s favourite missing package manager, <a href="http://mxcl.github.com/homebrew/">Homebrew</a>. If you haven&#8217;t got Homebrew installed already then you&#8217;ll be glad to know that installation is pretty simple to do;</p>
<p><pre class="brush: bash; light: true;">
ruby -e &quot;$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)&quot;
</pre></p>
<p>If you haven&#8217;t got Xcode installed yet this script will install it for you. If this is the case you may want to go get a drink as it may take some time.</p>
<h4>Android SDK</h4>
<p>Now that we have Homebrew installed we can get the Android SDK tools installed. Thanks to Homebrew this is a simple process and you don&#8217;t even have to visit a website, this appeals to the exceedingly lazy developer in me. Just go ahead and run;</p>
<p><pre class="brush: bash; light: true;">
brew install android
</pre></p>
<p>Once Homebrew has installed the Android SDK you can just straight away run the android command thanks to Homebrew setting everything up for you. So go ahead and run the Android SDK and AVD manager by running <code>android</code> on the command line. Then you can make your AVD and install the desired versions of the Android SDK. You may need to update your android tools since it appears that the Homebrew formula is a little out of date with the current version, but this is simple enough to do.</p>
<p>At this point let&#8217;s create an android project to make sure that everything is ready to go. I created a HelloAndroid application targeted for Android 2.1;<br />
<pre class="brush: bash; light: true;">
android create project --package com.example.helloandroid \
  --activity HelloAndroid \
  --target 3 \
  --path &lt;path-to-project-folder&gt;/HelloAndroid
</pre></p>
<p>Then to make sure that everything is set up right and working fire up your Android emulator and then run <code>ant install</code>. Once this is done go ahead and make sure the app runs on the emulator. Assuming this works then run <code>ant uninstall</code> to uninstall the app from the emulator.</p>
<h4>Apache Maven</h4>
<p>Whilst I do prefer to avoid a full blown IDE I do like some automation in places and Apache Maven is a big old help with this. The first thing to do is get maven installed, again thanks to Homebrew this is simple;<br />
<pre class="brush: bash;">
brew install maven
</pre></p>
<p>Now we need to get the project set up with maven. We will be using the <a href="http://code.google.com/p/maven-android-plugin">Maven Android Plugin</a> to help us out. The first thing we need to do is remove the following files;<br />
<pre class="brush: bash; light: true;">
rm -r bin build.xml build.properties libs
</pre></p>
<p>Next we setup our environment for the Maven Android Plugin. We need to set a <code>ANDROID_HOME</code> environment variable. In .bash_profile add the following line;<br />
<pre class="brush: bash; light: true;">
export ANDROID_HOME=`brew --prefix android`
</pre></p>
<p>Setting up the project for use with maven needs the following <code>pom.xml</code> file created in the root of the project;<br />
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;
  xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
  xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;com.example.helloandroid&lt;/groupId&gt;
  &lt;artifactId&gt;helloandroid&lt;/artifactId&gt;
  &lt;packaging&gt;apk&lt;/packaging&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;name&gt;HelloAndroid&lt;/name&gt;
  
  &lt;dependencies&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;com.google.android&lt;/groupId&gt;
      &lt;artifactId&gt;android&lt;/artifactId&gt;
      &lt;version&gt;2.1.2&lt;/version&gt;
      &lt;scope&gt;provided&lt;/scope&gt;
    &lt;/dependency&gt;
  &lt;/dependencies&gt;
  
  &lt;build&gt;
    &lt;sourceDirectory&gt;src&lt;/sourceDirectory&gt;
    &lt;plugins&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
        &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
        &lt;configuration&gt;
          &lt;source&gt;1.6&lt;/source&gt;
          &lt;target&gt;1.6&lt;/target&gt;
        &lt;/configuration&gt;
      &lt;/plugin&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;com.jayway.maven.plugins.android.generation2&lt;/groupId&gt;
        &lt;artifactId&gt;maven-android-plugin&lt;/artifactId&gt;
        &lt;configuration&gt;
          &lt;sdk&gt;
            &lt;path&gt;${env.ANDROID_HOME}&lt;/path&gt;
            &lt;platform&gt;1.6&lt;/platform&gt;
          &lt;/sdk&gt;
          &lt;emulator&gt;
             &lt;avd&gt;standard&lt;/avd&gt;
             &lt;wait&gt;6000&lt;/wait&gt;
          &lt;/emulator&gt;
          &lt;deleteConflictingFiles&gt;true&lt;/deleteConflictingFiles&gt;
        &lt;/configuration&gt;
        &lt;extensions&gt;true&lt;/extensions&gt;
      &lt;/plugin&gt;
    &lt;/plugins&gt;
  &lt;/build&gt;
  
&lt;/project&gt;
</pre></p>
<p>Once the <code>pom.xml</code> file is created then we can see if it is all set up right by running;<br />
<pre class="brush: bash;">
mvn help:describe -Dplugin=android
</pre></p>
<p>Running this should give details about goals available for the android maven plugin. For reference here are the goals;<br />
<pre class="brush: plain; highlight: [10,15,21,30,33,37,41,53,56,62,68,71,74,78,82,85]; light: true;">
Name: Maven Android Plugin - maven-android-plugin
Description: Maven Plugin for Android
Group Id: com.jayway.maven.plugins.android.generation2
Artifact Id: maven-android-plugin
Version: 2.8.3
Goal Prefix: android

This plugin has 16 goals:

android:apk
  Description: Creates the apk file. By default signs it with debug keystore.
    Change that by setting configuration parameter
    &lt;sign&gt;&lt;debug&gt;false&lt;/debug&gt;&lt;/sign&gt;.

android:deploy
  Description: Deploys the built apk file, or another specified apk, to a
    connected device.
    Automatically performed when running mvn integration-test (or mvn install)
    on a project with instrumentation tests.

android:deploy-dependencies
  Description: Deploys all directly declared dependencies of &lt;type&gt;apk&lt;/type&gt;
    in this project's pom.
    Usually used in a project with instrumentation tests, to deploy the apk to
    test onto the device before running the deploying and running the
    instrumentation tests apk.
    Automatically performed when running mvn integration-test (or mvn install)
    on a project with instrumentation tests.

android:dex
  Description: Converts compiled Java classes to the Android dex format.

android:emulator-start
  Description: EmulatorStartMojo can start the Android Emulator with a
    specified Android Virtual Device (avd).

android:emulator-stop
  Description: EmulatorStartMojo can stop the Android Emulator with a
    specified Android Virtual Device (avd).

android:generate-sources
  Description: Generates R.java based on resources specified by the resources
    configuration parameter.
    Generates java files based on aidl files.
    
    If the configuration parameter deleteConflictingFiles is true (which it is
    by default), this goal has the following side-effects:
    - deletes any R.java files found in the source directory.
    - deletes any .java files with the same name as an .aidl file found in the
      source directory.
    - deletes any Thumbs.db files found in the resource directory.

android:instrument
  Description: Runs the instrumentation apk on device.

android:internal-integration-test
  Description: Internal. Do not use.
    Called automatically when the lifecycle reaches phase integration-test.
    Figures out whether to call goals in this phase; and if so, calls
    android:instrument.

android:internal-pre-integration-test
  Description: Internal. Do not use.
    Called automatically when the lifecycle reaches phase pre-integration-test.
    Figures out whether to call goals in this phase; and if so, calls
    android:deploy-dependencies and android:deploy.

android:pull
  Description: Copy file/dir from device.

android:push
  Description: Copy file/dir to device.

android:redeploy
  Description: Redeploys the built apk file, or another specified apk, to a
    connected device. This simply tries to undeploy the APK and re-deploy it.

android:undeploy
  Description: Undeploys the built apk file, or another specified apk, from a
    connected device.

android:unpack
  Description: unpack library.

android:zipalign
  Description: ZipalignMojo can run the zipalign command against the apk.
</pre></p>
<p>If you see that then you are all set and ready to go. I&#8217;m hoping to get some more blog posts up about my development exploits on android. If you want to read more about the maven android plugin then have a look at their website <a href="http://code.google.com/p/maven-android-plugin">http://code.google.com/p/maven-android-plugin</a>.</p>
<p><strong>Update 1:</strong> I did have some troubles with the <code>android:emulator-start</code> goal. But it turned out I had missed the emulator block in the maven-android-plugin configuration block. Found this information in <a href="http://www.sonatype.com/books/mvnref-book/reference/android-dev-sect-custom-details.html">Sonatype&#8217;s Maven Reference Guide</a>. Also I corrected a typo in the pom.xml definition.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/beyondtc.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/beyondtc.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/beyondtc.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/beyondtc.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/beyondtc.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/beyondtc.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/beyondtc.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/beyondtc.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/beyondtc.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/beyondtc.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/beyondtc.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/beyondtc.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/beyondtc.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/beyondtc.wordpress.com/142/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.beyondthecorner.co.uk&amp;blog=7482100&amp;post=142&amp;subd=beyondtc&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.beyondthecorner.co.uk/2011/01/15/android-on-os-x-without-eclipse/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:thumbnail url="http://beyondtc.files.wordpress.com/2011/01/android.png?w=150" />
		<media:content url="http://beyondtc.files.wordpress.com/2011/01/android.png?w=150" medium="image">
			<media:title type="html">Android Post Image</media:title>
		</media:content>

		<media:content url="http://1.gravatar.com/avatar/37e58a68398752b5f8db87172bbe6046?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cuscus1986</media:title>
		</media:content>

		<media:content url="http://beyondtc.files.wordpress.com/2011/01/android.png" medium="image">
			<media:title type="html">Android Post Image</media:title>
		</media:content>
	</item>
		<item>
		<title>HubKit &#8211; Creating a new Objective-C iOS Library</title>
		<link>http://blog.beyondthecorner.co.uk/2011/01/06/hubkit-creating-a-new-objective-c-ios-library/</link>
		<comments>http://blog.beyondthecorner.co.uk/2011/01/06/hubkit-creating-a-new-objective-c-ios-library/#comments</comments>
		<pubDate>Wed, 05 Jan 2011 23:58:18 +0000</pubDate>
		<dc:creator>Marcus Ramsden</dc:creator>
				<category><![CDATA[Apple Programming]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">http://beyondtc.wordpress.com/?p=117</guid>
		<description><![CDATA[My work has taken an interesting turn in the last few months. I have been busy settling into my new job where I have been cast from a web developer, dabbling in php, ruby, java to varying degrees, to an iOS developer. This has been an exciting period for me and I think that I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.beyondthecorner.co.uk&amp;blog=7482100&amp;post=117&amp;subd=beyondtc&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>My work has taken an interesting turn in the last few months. I have been busy settling into my new job where I have been cast from a web developer, dabbling in php, ruby, java to varying degrees, to an iOS developer.</p>
<p>This has been an exciting period for me and I think that I am finally starting to get a handle on things. On my list of things to get my head around is creating libraries for Objective-C for use in iOS applications and possibly, in a boon for reuse, OS X as well. I settled on creating an Objective-C wrapper for the Github API which I will probably take further and develop into an iOS application over time, ideally a one that is targeted at both the iPhone and the iPad as my new job has yet to see me make anything for Apple&#8217;s tablet.</p>
<p>What I am really interested with this project is, what makes a good API that is nice and easy to use for the average iOS developer? I already have the start of an answer is that it should presumably echo the existing Cocoa Apis as I have noticed that these are quite consistent at the high level which as a result makes them easier to learn or at least take a guess to a reasonable start to using an as yet unmet API.</p>
<p>I hope over the process that I will do a better job at keeping my somewhat unloved blog a little more up to date with my experiences.</p>
<p>I suppose the other important part is the project page for the library can be found at <a href="https://github.com/mramsden/hubkit">Github</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/beyondtc.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/beyondtc.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/beyondtc.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/beyondtc.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/beyondtc.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/beyondtc.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/beyondtc.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/beyondtc.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/beyondtc.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/beyondtc.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/beyondtc.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/beyondtc.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/beyondtc.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/beyondtc.wordpress.com/117/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.beyondthecorner.co.uk&amp;blog=7482100&amp;post=117&amp;subd=beyondtc&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.beyondthecorner.co.uk/2011/01/06/hubkit-creating-a-new-objective-c-ios-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/37e58a68398752b5f8db87172bbe6046?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cuscus1986</media:title>
		</media:content>
	</item>
		<item>
		<title>VirtualBox SDK Machine Status</title>
		<link>http://blog.beyondthecorner.co.uk/2010/04/22/virtualbox-sdk-machine-status/</link>
		<comments>http://blog.beyondthecorner.co.uk/2010/04/22/virtualbox-sdk-machine-status/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 13:54:10 +0000</pubDate>
		<dc:creator>Marcus Ramsden</dc:creator>
				<category><![CDATA[virtualbox]]></category>
		<category><![CDATA[conky]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://beyondtc.wordpress.com/?p=82</guid>
		<description><![CDATA[In this post I share the small results of my first play with the Virtualbox Python SDK to create a useful little status script which can then in turn be used in Conky.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.beyondthecorner.co.uk&amp;blog=7482100&amp;post=82&amp;subd=beyondtc&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img src="http://beyondtc.files.wordpress.com/2010/04/virtualbox.png?w=594&#038;h=278" alt="" title="Virtualbox Post Logo" width="594" height="278" class="aligncenter size-full wp-image-189" /></p>
<p>I have taken to using VirtualBox in my day to day development work. The reason for this is it provides a nicely isolated development sandbox which I can go ahead and clutter up with the usual tools, then when things go wrong I just have to trash the machine and clone from an existing image that I have pre-made. So far this has made life much easier for me.</p>
<p>My preferred approach to running my machines is to start them up in headless mode and then shell into them using a static IP assigned through the VirtualBox host-only network. The only issue with using headless mode is that there is potentially no indication of the state of the machine, basically when can I shell into my machine? Since I was already using conky to report the status of my host machine I thought that I would add to my conkyrc so that I could see the state of play with regards to VirtualBox and the machines available to it.</p>
<p>I decided to make use of the <a href="http://dlc.sun.com/virtualbox/vboxsdkdownload.html">VirtualBox Python SDK</a> to write a small application that can report on the status of my machines. The deb installation of VirtualBox supplied by Sun/Oracle contains the SDK as well, I am unsure if this is the case for the version of VirtualBox OSE available on the Ubuntu repositories. Also I don&#8217;t know what the state of play is with other linux distributions. You may want to download the SDK anyway as this includes all of the documentation for using the API.</p>
<p>So with that out the way onto the script that I created to report the status of my machines;<br />
<pre class="brush: python;">
#!/usr/bin/env python
from vboxapi import VirtualBoxManager
import getopt
import sys

opts, args = getopt.getopt(sys.argv[1:], &quot;&quot;, ['conky', 'vbox-version'])
useConky = False
for o, a in opts:
        if o == '--conky':
                useConky = True

virtualBoxManager = VirtualBoxManager('XPCOM', None)
virtualBox = virtualBoxManager.vbox
for o, a in opts:
        if o == '--vbox-version':
                print virtualBox.version
                sys.exit(0)

machines = virtualBox.getMachines()
for machine in machines:
        machineName = machine.name
        machineStatus = &quot;null&quot;
        machineStatuses = {
                0: 'null',
                1: '${color red}powered off$color' if useConky else 'powered off',
                2: '${color red}saved$color' if useConky else 'saved',
                3: '${color yellow}teleported$color' if useConky else 'teleported',
                4: '${color red}aborted$color' if useConky else 'aborted',
                5: '${color green}running$color' if useConky else 'running',
                6: '${color yellow}paused$color' if useConky else 'paused',
                7: '${color red}stuck$color' if useConky else 'stuck',
                8: '${color blue}teleporting$color' if useConky else 'teleporting',
                9: '${color blue}live snapshotting$color' if useConky else 'live snapshotting',
                10: '${color blue}starting$color' if useConky else 'starting',
                11: '${color blue}stopping$color' if useConky else 'stopping',
                12: '${color blue}saving$color' if useConky else 'saving',
                13: '${color blue}restoring$color' if useConky else 'restoring'
                 }
        machineStatus = machineStatuses.get(machine.state)
        print machineName, &quot;-&quot;, machineStatus
</pre></p>
<p>This script will accept the following arguments when executed;</p>
<pre>
virtualboxstatus [--conky] [--vbox-version]

  --conky
    Adds any additional colors for conky to render.

  --vbox-version
    Displays the installed version of VirtualBox then exits.
</pre>
<p>Once this script is made we just need to add it to our conkyrc in order to render the status of our machines. In my conkyrc I added the following;<br />
<pre class="brush: plain;">
${color red}VIRTUALBOX STATUS$color - Version ${execpi 600 ~/bin/virtualboxstatus --vbox-version}
${execpi 1 ~/bin/virtualboxstatus --conky}
</pre></p>
<p>Here&#8217;s a screenshot of this script in action;<br />
<a href="http://beyondtc.files.wordpress.com/2010/04/virtualboxstatus-screenshot.png"><img src="http://beyondtc.files.wordpress.com/2010/04/virtualboxstatus-screenshot.png?w=594" alt="VirtualBox status in conky" title="virtualboxstatus-screenshot"   class="alignnone size-full wp-image-89" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/beyondtc.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/beyondtc.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/beyondtc.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/beyondtc.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/beyondtc.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/beyondtc.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/beyondtc.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/beyondtc.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/beyondtc.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/beyondtc.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/beyondtc.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/beyondtc.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/beyondtc.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/beyondtc.wordpress.com/82/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.beyondthecorner.co.uk&amp;blog=7482100&amp;post=82&amp;subd=beyondtc&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.beyondthecorner.co.uk/2010/04/22/virtualbox-sdk-machine-status/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:thumbnail url="http://beyondtc.files.wordpress.com/2010/04/virtualbox.png?w=150" />
		<media:content url="http://beyondtc.files.wordpress.com/2010/04/virtualbox.png?w=150" medium="image">
			<media:title type="html">Virtualbox Post Logo</media:title>
		</media:content>

		<media:content url="http://1.gravatar.com/avatar/37e58a68398752b5f8db87172bbe6046?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cuscus1986</media:title>
		</media:content>

		<media:content url="http://beyondtc.files.wordpress.com/2010/04/virtualbox.png" medium="image">
			<media:title type="html">Virtualbox Post Logo</media:title>
		</media:content>

		<media:content url="http://beyondtc.files.wordpress.com/2010/04/virtualboxstatus-screenshot.png" medium="image">
			<media:title type="html">virtualboxstatus-screenshot</media:title>
		</media:content>
	</item>
		<item>
		<title>Installing RVM on Debian Lenny</title>
		<link>http://blog.beyondthecorner.co.uk/2010/04/06/installing-rvm-on-debian-lenny/</link>
		<comments>http://blog.beyondthecorner.co.uk/2010/04/06/installing-rvm-on-debian-lenny/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 18:37:21 +0000</pubDate>
		<dc:creator>Marcus Ramsden</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[rvm]]></category>

		<guid isPermaLink="false">http://beyondtc.wordpress.com/?p=67</guid>
		<description><![CDATA[My work has seen me doing a lot of work in ruby recently and more specifically in rails. I recently have been making a lot of use of Ruby Version Manager (RVM). This is a little gem (pun intended) and allows you to easily install multiple versions of ruby, and manage multiple sets of gems [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.beyondthecorner.co.uk&amp;blog=7482100&amp;post=67&amp;subd=beyondtc&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>My work has seen me doing a lot of work in ruby recently and more specifically in rails. I recently have been making a lot of use of <a href="http://rvm.beginrescueend.com">Ruby Version Manager (RVM)</a>. This is a little gem (pun intended) and allows you to easily install multiple versions of ruby, and manage multiple sets of gems for each of these ruby installations. All in all a very nifty little gem and has saved me a huge amount of time. I primarily setup my development environments on throw away virtual machines so that I don&#8217;t end up hosing my actual computer.</p>
<p>Currently my OS of choice for my VMs is Debian Lenny. This is a rundown of the commands that need to get up and running with rvm.</p>
<p><em><br />
Edit<br />
Rather then taking this &#8220;gem install&#8221; approach you can just run;</p>
<blockquote><p>bash &lt; &lt;(curl http://rvm.beginrescueend.com/releases/rvm-install-latest)</p></blockquote>
<p>Thanks to Wayne for the really quick comment <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
</em></p>
<p>First start off by install ruby and rubygems from the Debian repositories;</p>
<blockquote><p>apt-get install ruby rubygems</p></blockquote>
<p>Once this is done I like to make sure that I have the latest version of rubygems, this is done through the handy rubygems-update gem since the Debian rubygems package disables <code>gem update --system</code>;</p>
<blockquote><p>
gem install rubygems-update<br />
/var/lib/gems/1.8/bin/update_rubygems
</p></blockquote>
<p>Once this is complete you now need to install rvm;</p>
<blockquote><p>gem install rvm</p></blockquote>
<p>The next step after installing the rvm gem is to finalise the installation by running the <code>rvm-install</code> command. Depending on your setup you may be able to run this directly if the rubygems bin directory is on your path. If not then you will need to run;</p>
<blockquote><p>/var/lib/gems/1.8/bin/rvm-install</p></blockquote>
<p>Now we need to follow the final setup phase for rvm which is given to us by <code>rvm-install</code>. In <code>/home/&lt;username&gt;/.bashrc</code> you need to comment out the line <code>[ -z "$PS1" ] &amp;&amp; return</code> and add the following code to the end of the file;</p>
<blockquote><p>
if [[ -s /home/&lt;username&gt;/.rvm/scripts/rvm ]]; then<br />
&nbsp;&nbsp;source /home/&lt;username&gt;/.rvm/scripts/rvm<br />
fi
</p></blockquote>
<p>Once this is done you will need to logout of your shell and back in again for the settings to take effect. If you run <code>rvm list</code> you should now see that you have no rvm managed versions of ruby installed and then there is the system version which is what aptitude installed for us. Also a warning about the command <code>file</code> not being found. This is solved by;</p>
<blockquote><p>apt-get install file</p></blockquote>
<p>Now before installing an rvm managed version of ruby there are a final few dependencies that need to be installed;</p>
<blockquote><p>apt-get install build-essential curl zlib1g-dev libreadline5-dev libxml2-dev libsqlite3-dev</p></blockquote>
<p>Then all you need to do is run;</p>
<blockquote><p>rvm install 1.8.7</p></blockquote>
<p>You now have a ruby environment setup as I set mine up ready for use. One thing to note is that to install gems you should use <code>rvmsudo</code> rather then <code>sudo</code>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/beyondtc.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/beyondtc.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/beyondtc.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/beyondtc.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/beyondtc.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/beyondtc.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/beyondtc.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/beyondtc.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/beyondtc.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/beyondtc.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/beyondtc.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/beyondtc.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/beyondtc.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/beyondtc.wordpress.com/67/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.beyondthecorner.co.uk&amp;blog=7482100&amp;post=67&amp;subd=beyondtc&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.beyondthecorner.co.uk/2010/04/06/installing-rvm-on-debian-lenny/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/37e58a68398752b5f8db87172bbe6046?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cuscus1986</media:title>
		</media:content>
	</item>
		<item>
		<title>Zend Framework and Twig</title>
		<link>http://blog.beyondthecorner.co.uk/2009/10/13/zend-framework-and-twig/</link>
		<comments>http://blog.beyondthecorner.co.uk/2009/10/13/zend-framework-and-twig/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 01:12:39 +0000</pubDate>
		<dc:creator>Marcus Ramsden</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[twig]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://beyondtc.wordpress.com/?p=40</guid>
		<description><![CDATA[Update It looks like I should keep a closer eye on the mailing lists for new projects. Some people have already started to look into integrating Twig with the Zend Framework. The thread can be found in the group here. I have a small confession to make. Whilst I do love the Zend Framework I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.beyondthecorner.co.uk&amp;blog=7482100&amp;post=40&amp;subd=beyondtc&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Update</strong> It looks like I should keep a closer eye on the mailing lists for new projects. Some people have already started to look into integrating Twig with the Zend Framework. The thread can be found in the group <a href="http://groups.google.com/group/twig-users/browse_thread/thread/41cf9e3cad767dad">here</a>.</p>
<p>I have a small confession to make. Whilst I do love the Zend Framework I have been seeing other frameworks and indeed languages behind it&#8217;s back. One of these frameworks include Django for Python. Admittedly every time I start up in a new framework I do always seem to come back to the Zend Framework fold but I guess that must be down to the fact that I just prefer PHP, it&#8217;s where I feel comfortable.</p>
<p>There was one feature that stuck with me about Django though, and that was it&#8217;s template language. I found this to be very enjoyable to do, and to be honest in my view of things using PHP as my template language wasn&#8217;t cutting it anymore in my books. I suspect that some people will strongly disagree with my arguments but then again this is what I feel is the beauty of PHP, there are so many tools out there that I can make them fit with my preferred style.</p>
<p>Fortunately the Symfony crowd have come to the rescue with, what I think is, a nice little template language called <a href="http://www.twig-project.org/">Twig</a>. It resembles the style of templates found in Django with curly braces all over the place rather than PHP tags. Plus it lets you include blocks of templates in with other templates, this appealed to me because I found that <pre class="brush: php;">&lt;?php echo $this-&gt;render(&quot;view-file.phtml&quot;); ?&gt;</pre> was getting too much for me. Additionally since the template language is very similar in both form and function to the Django template language anyone coming over shouldn&#8217;t have any problems settling in on the template front.</p>
<p>I have been getting stuck into more features of the Zend Framework and thought that it would be fun to write an integration layer so that Twig can be used in Zend Framework. The solution I came up with works for default views and views contained inside modules.</p>
<p>To start with I created a wrapper around the main Twig_Environment class. This class is responsible for loading a template and then rendering it with the supplied data.</p>
<p><pre class="brush: php;">
&lt;?php
class ZExt_Twig extends Zend_View_Abstract
{
  
  private $_twig = null;
  
  public function __construct($applicationRoot, $modulesDir = &quot;&quot;)
  {
    $twigLoader = new ZExt_Twig_Loader($applicationRoot, $modulesDir);
    $this-&gt;_twig = new Twig_Environment($twigLoader);
  }
  
  protected function _run()
  {
    $template = func_get_arg(0);
    echo $template-&gt;render($this-&gt;getVars());
  }
  
  protected function _script($name)
  {
    return $this-&gt;_twig-&gt;loadTemplate($name)
  }
  
}
</pre></p>
<p>I will come onto the ZExt_Twig_Loader class shortly. The two methods _run and _script are both overriden methods from Zend_View_Abstract. These get called when the render method of the parent class get&#8217;s called. The _script function is responsible for loading the appropriate Twig template and then returning it.<br />
The _run method is called when we are ready to hand off to the Twig rendering engine. The first argument to this method should be the template object that was returned by the _script method. Note that when the render method is being called we are passing in an array of any data that might have been assigned to the view.</p>
<p>Next the ZExt_Twig_Loader class is responsible for loading the appropriate template file from the standard Zend Framework application directory structure.</p>
<p><pre class="brush: php;">
&lt;?php
class ZExt_Twig_Loader extends Twig_Loader
{

	/**
	 * @var string
	 */
	private $_applicationRoot = null;

	/**
	 * @var string
	 */
	private $_modulesDir = null;

	/**
	 * @var string
	 */
	private $_viewsDir = null;
	
	/**
	 * Constructor.
	 *
	 * @param string	$applicationRoot The application root.
	 * @param string	$modulesDir The directory where all modules are found.
	 * @param string	$viewsDir The path where views should be located in both the application root and
	 * modules directory.
	 * @param string 	$cache The compiler cache directory.
	 * @param boolean	$autoReload Whether to reload the template if the orginal source changed.
	 *
	 * @see Twig_Loader
	 */
	public function __construct($applicationRoot, $modulesDir, $viewsDir = &quot;/views/scripts&quot;, 
		$cache = null, $autoReload = true)
	{
		$this-&gt;setApplicationRoot($applicationRoot);
		$this-&gt;setModulesDir($modulesDir);
		$this-&gt;setViewsDir($viewsDir);

		parent::__construct($cache, $autoReload);
	}

	/**
	 * Returns the source of the next view to load based on the supplied name.
	 * The name in this instance should take the form 'module/controller/action',
	 * 'controller/action', or just 'action'.
	 * 
	 * @param string	$name The view to load.
	 * 
	 * @return array An array consisting of the source code as the first element, and
	 * the last modification time as the second one or false if it's not relevant.
	 */
	public function getSource($name)
	{
		$name = $this-&gt;_parseName($name);
		$templateFilePath = $this-&gt;getApplicationRoot();
		if (!is_null($name['module']))
		{
			$templateFilePath .= DIRECTORY_SEPARATOR.$name['module'];
		}
		$templateFilePath .= DIRECTORY_SEPARATOR.$this-&gt;getViewsDir();
		$templateFilePath .= DIRECTORY_SEPARATOR.$name['controller'].DIRECTORY_SEPARATOR.$name['action'].$name['extension'];
		
		if (!file_exists($templateFilePath))
		{
			throw new Zend_Exception(&quot;The template file $templateFilePath does not exist.&quot;);
		}

		error_log($templateFilePath);
		return array(file_get_contents($templateFilePath), filemtime($templateFilePath));
		
	}

	public function getViewsDir()
	{
		return $this-&gt;_viewsDir;
	}

	public function setViewsDir($viewsDir)
	{
		$this-&gt;_viewsDir = $viewsDir;
	}

	public function getApplicationRoot()
	{
		return $this-&gt;_applicationRoot;
	}

	public function setApplicationRoot($applicationRoot)
	{
		$this-&gt;_applicationRoot = $applicationRoot;
	}

	public function getModulesDir()
	{
		return $this-&gt;_modulesDir;
	}

	public function setModulesDir($modulesDir)
	{
		$this-&gt;_modulesDir = $modulesDir;
	}

	private function _parseName($name)
	{
		$matches = array();
		preg_match(&quot;/(\..*)$/&quot;, $name, $matches);
		$name = substr($name, 0, strpos($name, $matches[1]));
		$parsedName = array('module' =&gt; null, 'controller' =&gt; 'index', 'action' =&gt; 'index', 'extension' =&gt; $matches[1]);
		$parts = split(&quot;/&quot;, $name);
		switch (sizeof($parts))
		{
			case 3:
				$parsedName['module'] = array_shift($parts);
			case 2:
				$parsedName['controller'] = array_shift($parts);
			case 1:
				$parsedName['action'] = array_shift($parts);
		}
		
		return $parsedName;
	}
}
</pre></p>
<p>The main method of interest from this class is ZExt_Twig_Loader::getSource. This method is called by the Twig environment when ZExt_Twig::loadTemplate is called. This function then parses the file name passed to it and returns an array containing an array of all the lines in the template file and the time the file was last modified. The template is then parsed by the Twig template engine.</p>
<p>Finally to get this all working I added the following function to the bootstrap</p>
<p><pre class="brush: php;">
public function _initTwigView()
{
	$twigView = new ZExt_Twig(APPLICATION_PATH, APPLICATION_PATH.&quot;/modules&quot;);
	$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper(&quot;ViewRenderer&quot;);
	$viewRenderer-&gt;setView($twigView);

	return $twigView;
}
</pre></p>
<p>This now means that a Twig template view will be loaded instead of the default Zend_View style template.</p>
<p>There are still a few aspects I have to try out with this approach such as the availability of view helpers and whether I can include other templates using the Twig engine syntax, or if I will still have to use Zend Framework helpers to achieve this. Finally I need to tidy up some of the method signatures as there are some such as the ZExt_Twig_Loader constructor that have parameters which cannot be assigned.</p>
<p>All of the code in this article is available on <a href="http://gist.github.com/264227">GitHub</a>.</p>
<p>Any suggestions for improvements would be appreciated <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/beyondtc.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/beyondtc.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/beyondtc.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/beyondtc.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/beyondtc.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/beyondtc.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/beyondtc.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/beyondtc.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/beyondtc.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/beyondtc.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/beyondtc.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/beyondtc.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/beyondtc.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/beyondtc.wordpress.com/40/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.beyondthecorner.co.uk&amp;blog=7482100&amp;post=40&amp;subd=beyondtc&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.beyondthecorner.co.uk/2009/10/13/zend-framework-and-twig/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/37e58a68398752b5f8db87172bbe6046?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cuscus1986</media:title>
		</media:content>
	</item>
		<item>
		<title>PEAR Update Issues On Snow Leopard</title>
		<link>http://blog.beyondthecorner.co.uk/2009/10/09/pear-update-issues-on-snow-leopard/</link>
		<comments>http://blog.beyondthecorner.co.uk/2009/10/09/pear-update-issues-on-snow-leopard/#comments</comments>
		<pubDate>Fri, 09 Oct 2009 13:39:13 +0000</pubDate>
		<dc:creator>Marcus Ramsden</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[pear]]></category>
		<category><![CDATA[snow leopard]]></category>

		<guid isPermaLink="false">http://beyondtc.wordpress.com/?p=34</guid>
		<description><![CDATA[So I just came across some weirdness on my default install of PHP on Snow Leopard. I wanted to install the latest version of PHPUnit in order to carry out some testing, but it was asking me to update PEAR. So I ran the usual PEAR update command; This appeared to run without any issues. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.beyondthecorner.co.uk&amp;blog=7482100&amp;post=34&amp;subd=beyondtc&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So I just came across some weirdness on my default install of PHP on Snow Leopard. I wanted to install the latest version of PHPUnit in order to carry out some testing, but it was asking me to update PEAR. </p>
<p>So I ran the usual PEAR update command;<br />
<pre class="brush: bash;">
$ sudo pear upgrade pear
</pre></p>
<p>This appeared to run without any issues. But subsequently whenever I attempted to run PEAR I was greeted with the following error message;<br />
<pre class="brush: bash;">
/usr/local/bin/pear: fork: Resource temporarily unavailable
</pre></p>
<p>I took a look inside the offending file as it is just a simple command to run the PEAR script. It looked like this;<br />
<pre class="brush: bash;">
pear /usr/lib/php/pearcmd.php
</pre></p>
<p>Obviously the script was infinitely attempting to spawn itself causing the resource temporarily unavailable error. So the simple fix was to change the script to the following;<br />
<pre class="brush: bash;">
php /usr/lib/php/pearcmd.php $@
</pre></p>
<p>I&#8217;m not quite sure why the script changed when I upgraded but it appeared to. I figured I should pop this note up in case anyone else gets caught out, or indeed I forget and get caught out again. Any insight on why this might have happened would be appreciated.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/beyondtc.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/beyondtc.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/beyondtc.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/beyondtc.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/beyondtc.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/beyondtc.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/beyondtc.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/beyondtc.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/beyondtc.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/beyondtc.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/beyondtc.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/beyondtc.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/beyondtc.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/beyondtc.wordpress.com/34/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.beyondthecorner.co.uk&amp;blog=7482100&amp;post=34&amp;subd=beyondtc&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.beyondthecorner.co.uk/2009/10/09/pear-update-issues-on-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/37e58a68398752b5f8db87172bbe6046?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cuscus1986</media:title>
		</media:content>
	</item>
		<item>
		<title>Pretty URLs with EPrints</title>
		<link>http://blog.beyondthecorner.co.uk/2009/09/21/pretty-urls-with-eprints/</link>
		<comments>http://blog.beyondthecorner.co.uk/2009/09/21/pretty-urls-with-eprints/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 23:44:31 +0000</pubDate>
		<dc:creator>Marcus Ramsden</dc:creator>
				<category><![CDATA[eprints]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[apache]]></category>

		<guid isPermaLink="false">http://beyondtc.wordpress.com/?p=18</guid>
		<description><![CDATA[Recently I have been working on a project which was focused on adding Homepages and Profiles for users to EPrints repositories called MicroViews. Currently when a user logs into an EPrints repository all you are presented with is your Manage Deposits page. With MicroViews the user will be presented with a Homepage which provides them [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.beyondthecorner.co.uk&amp;blog=7482100&amp;post=18&amp;subd=beyondtc&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Recently I have been working on a project which was focused on adding Homepages and Profiles for users to EPrints repositories called MicroViews. Currently when a user logs into an EPrints repository all you are presented with is your Manage Deposits page. With MicroViews the user will be presented with a Homepage which provides them with various pieces of information about the repository which is relevant to them, for example what are their most popular publications and if there are any issues with their publications that have been raised at the last audit.</p>
<p>The extension also adds a profile page to EPrints for each user. The idea of profile pages is to provide a static external facing page which the rest of the world can see. This page would include basic information about the user and the publications they have added to the repository. This effectively provides a biography of the user with regards to the repository.</p>
<p>One thing that we wanted to do is create pretty URLs for the user profiles of the form http://examplerepository.com/profile/. Initially we did this by making a modification to perl_lib/EPrints/Apache/Rewrite.pm but this was not the ideal situation for a plugin since this is a modification to the core code of EPrints. The problem with this approach is that if the repository administrator went on to update their core EPrints install then they would end up losing the hand made modification which is required for the plugin and they would have to add it again.</p>
<p>Instead we investigated creating a custom URL handler and adding it to the request handling chain using archives/ARCHIVEID/cfg/apachevhosts.conf. By doing this we won&#8217;t change any core EPrints code and all of the changes will be safe from any auto generated changes. The first thing we did was create a custom rewrite handler which took the following shape;</p>
<p><pre class="brush: perl;">
package EPrints::Plugin::MePrints::Apache::Rewrite;

use strict;
use warnings;

our @ISA = qw/ EPrints::Plugin /;

use EPrints::Apache::AnApache;

sub handler
{
  my( $r ) = @_;
  my $uri = $r-&gt;uri;
  my $repository_id = $r-&gt;dir_config( &quot;EPrints_ArchiveID&quot; );
  if( !defined $repository_id )
  {
    return DECLINED;
  }
  my $repository = EPrints::Repository-&gt;new( $repository_id );

  if( $uri =~ m! ^\/profile\/([0-9a-zA-Z]+)$ !x )
  {
    # Find the user and if found set the appropriate filename for the response object.
    # If the user is not found then don't do anything or return anything and this will
    # cause EPrints to respond with a 404 error.
  }
  else
  {
    return DECLINED;
  }
}
</pre></p>
<p>Next we needed to add only one line to the archves/ARCHIVEID/cfg/apachevhost.conf file;</p>
<p><pre class="brush: plain;">
PerlTransHandler EPrints::Plugin::MePrints::Apache::Rewrite
</pre></p>
<p>After a server reset we had the pretty URLs for the profile pages. This works thanks to the PerlTransHandler statement in the apachevhost.conf file. What this does is add a handler to the chain of handlers to be run. By default in EPrints there is only one handler and that is the default one. What we have done with the change above is add a handler into the chain before that. The handler method in EPrints::Plugin::MePrints::Apache::Rewrite gets called and if it gets a match for profile then it goes ahead and handles it. The &#8220;return DECLINED&#8221; tells Apache that it should move onto the next URI translation handler in the chain.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/beyondtc.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/beyondtc.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/beyondtc.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/beyondtc.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/beyondtc.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/beyondtc.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/beyondtc.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/beyondtc.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/beyondtc.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/beyondtc.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/beyondtc.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/beyondtc.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/beyondtc.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/beyondtc.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.beyondthecorner.co.uk&amp;blog=7482100&amp;post=18&amp;subd=beyondtc&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.beyondthecorner.co.uk/2009/09/21/pretty-urls-with-eprints/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/37e58a68398752b5f8db87172bbe6046?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cuscus1986</media:title>
		</media:content>
	</item>
		<item>
		<title>Prototype Element Update Confusion</title>
		<link>http://blog.beyondthecorner.co.uk/2009/08/05/prototype-element-update-confusion/</link>
		<comments>http://blog.beyondthecorner.co.uk/2009/08/05/prototype-element-update-confusion/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 23:49:14 +0000</pubDate>
		<dc:creator>Marcus Ramsden</dc:creator>
				<category><![CDATA[eprints]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://beyondtc.wordpress.com/?p=26</guid>
		<description><![CDATA[At work we are currently working on reimplementing a piece of software called SNEEP. SNEEP is a plugin for repository software called EPrints which is developed at the University of Southampton. According to the Registry of Open Access Repositories (ROAR) EPrints currently has 333 installations around the world as of 6th August 2009. As part [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.beyondthecorner.co.uk&amp;blog=7482100&amp;post=26&amp;subd=beyondtc&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>At work we are currently working on reimplementing a piece of software called SNEEP. SNEEP is a plugin for repository software called EPrints which is developed at the University of Southampton. According to the <a href="http://roar.eprints.org">Registry of Open Access Repositories (ROAR)</a> EPrints currently has 333 installations around the world as of 6th August 2009. As part of the SNEEP plugin we have been adding in the ability to edit comments and notes using AJAX meaning that users don’t have to leave the deposit page to author their comments or notes.</p>
<p>EPrints comes with the <a href="http://prototypejs.org/">Prototype</a> and <a href="http://script.aculo.us/">Scriptaculous</a> JavaScript libraries installed so we had to use these as opposed to my regular choice of <a href="http://jquery.com/">jQuery</a>. Owing to the static approach used for generating the document views in EPrints we had to inject the whole comments section of the document using AJAX. We did this by having the server generate the DOM and then sending it back to the browser which injects it into the page. This way the page can dynamically load the comments box depending on if a user is logged in or not.</p>
<p>Initially we managed to get the code running with Firefox and Safari but we had no joy with the code in IE. Here is some of the code that was originally used.</p>
<p><pre class="brush: jscript;">
function sneepCommentFormInit(transport) {
  // Load in the HTML generated by the server side script
  $('ep_sneep_main').update(transport.responseText);

  // If the server sent back a form so the user can write a new comment
  // then we need to remove the old submit button and add one which is
  // attached to one of our JavaScript functions.
  $$(&quot;.ep_sneep_comment_form_container&quot;).each(function(element) {
    var submitButton = document.createElement(&quot;input&quot;);
    submitButton.writeAttribute(&quot;type&quot;, &quot;button&quot;);
    submitButton.writeAttribute(&quot;id&quot;, &quot;sneep_comment_submit&quot;);
    submitButton.writeAttribute(&quot;value&quot;, $(&quot;sneep_comment_submit&quot;).readAttribute(&quot;value&quot;));
    submitButton.observe('click', sneepCommentFormSubmit);
    $(&quot;sneep_comment_submit&quot;).remove();
    element.appendChild(submitButton);
    var inputcallback = document.createElement(&quot;input&quot;);
    inputcallback.writeAttribute(&quot;type&quot;, &quot;hidden&quot;);
    inputcallback.writeAttribute(&quot;name&quot;, &quot;callback&quot;);
    inputcallback.writeAttribute(&quot;value&quot;, &quot;1&quot;);
    element.appendChild(inputcallback);
  });
}

Event.observe(window, 'load', function() {
  var rm = window.location.href.match(/(https?:\/\/.*)\/(\d+)\/?/);
  if (rm != null) {
    new Ajax.Request(rm[1]+'/cgi/sneep/view_sneep?eprintid='+rm[2]+'&amp;amp;type=comment', {
      method: 'get',
      onCreate: function() {
        // Put up a loading message
      },
      onComplete: sneepCommentFormInit
    });
  }
});
</pre></p>
<p>The problem appeared to be that IE does not finish loading the updated content before attempting to add the hidden field and attaching a new submit button which calls our client side method rather than allowing the form to submit straight back to the server.</p>
<p>The solution we chose for this issue was to modify the initial on load function in the following way;</p>
<p><pre class="brush: jscript;">
Event.observe(window, 'load', function() {
  var rm = window.location.href.match(/(https?:\/\/.*)\/(\d+)\/?/);
  if (rm != null) {
    new Ajax.Request(rm[1]+'/cgi/sneep/view_sneep?eprintid='+rm[2]+'&amp;amp;type=comment', {
      method: 'get',
      onCreate: function() {
        // Put up a loading message
      },
      onComplete: function(transport) {
        $('ep_sneep_main').update(transport.responseText+
          &quot;&lt;script type=\&quot;text/javascript\&quot;&gt;&quot;+
          &quot;sneepCommentFormInit();&quot;+
          &quot;&lt;/script&gt;&quot;);
      }
    });
  }
});
</pre></p>
<p>Basically in this code we removed the code from sneepCommentFormInit() that handles the returned text and put it inside the anonymous onComplete method. We also appended some JavaScript that gets executed as soon as it is evaluated. This means that the form initialization code is only run once all of the HTML has been interpreted and loaded meaning that IE now has the submit intercept function correctly attached.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/beyondtc.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/beyondtc.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/beyondtc.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/beyondtc.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/beyondtc.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/beyondtc.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/beyondtc.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/beyondtc.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/beyondtc.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/beyondtc.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/beyondtc.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/beyondtc.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/beyondtc.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/beyondtc.wordpress.com/26/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.beyondthecorner.co.uk&amp;blog=7482100&amp;post=26&amp;subd=beyondtc&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.beyondthecorner.co.uk/2009/08/05/prototype-element-update-confusion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/37e58a68398752b5f8db87172bbe6046?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cuscus1986</media:title>
		</media:content>
	</item>
	</channel>
</rss>
