<?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/"
	>

<channel>
	<title>Lasse Bunk&#039;s weblog</title>
	<atom:link href="http://lassebunk.dk/feed/" rel="self" type="application/rss+xml" />
	<link>http://lassebunk.dk</link>
	<description>Ruby on Rails, programming, and SEO</description>
	<lastBuildDate>Sat, 19 May 2012 10:18:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Translate your Ruby on Rails models and database tables using acts_as_translatable</title>
		<link>http://lassebunk.dk/2012/05/15/translate-your-ruby-on-rails-models-and-database-tables-using-acts_as_translatable/</link>
		<comments>http://lassebunk.dk/2012/05/15/translate-your-ruby-on-rails-models-and-database-tables-using-acts_as_translatable/#comments</comments>
		<pubDate>Tue, 15 May 2012 15:32:39 +0000</pubDate>
		<dc:creator>lassebunk</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[Fields]]></category>
		<category><![CDATA[I18n]]></category>
		<category><![CDATA[Localization]]></category>
		<category><![CDATA[Models]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Translation]]></category>

		<guid isPermaLink="false">http://lassebunk.dk/?p=2648</guid>
		<description><![CDATA[Ruby on Rails plugin for easy translation of models and database tables.]]></description>
			<content:encoded><![CDATA[<p><a href="https://github.com/lassebunk/acts_as_translatable">acts_as_translatable</a> is a plugin for easy translation of your Ruby on Rails models and database tables.</p>
<h2>Installation</h2>
<p>In your Gemfile:</p>
<pre class="brush: ruby; title: ; notranslate">
gem 'acts_as_translatable'
</pre>
<p>Install the new gem:</p>
<pre class="brush: bash; title: ; notranslate">
bundle install
</pre>
<h2>Example</h2>
<p>Generate translations for a category model with name and description fields, with default locale set to ‘en’ (English):</p>
<pre class="brush: bash; title: ; notranslate">
$ rails generate acts_as_translatable en category name description
</pre>
<p>This will create the necessary migration. Then run:</p>
<pre class="brush: bash; title: ; notranslate">
$ rake db:migrate
</pre>
<p>Then add to <strong>app/models/category.rb</strong>:</p>
<pre class="brush: ruby; title: ; notranslate">
class Category &lt; ActiveRecord::Base
  acts_as_translatable_on :name, :description
  ...
end
</pre>
<p>And play around with I18n:</p>
<pre class="brush: ruby; title: ; notranslate">
I18n.locale = &quot;en&quot;
Category.first.update_attribute :name, &quot;English name&quot;

I18n.locale = &quot;de&quot;
Category.first.update_attribute :name, &quot;Deutsche Name&quot;
</pre>
<p>Also try in combination with my <a href="https://github.com/lassebunk/translate_acts_as_translatable_models">translate_acts_as_translatable_models</a> plugin to automatically translate your acts_as_translatable enabled models.</p>
<p>Have fun! Please send comments and suggestions to <a href="mailto:lassebunk@gmail.com">lassebunk@gmail.com</a>, and issues at <a href="https://github.com/lassebunk/acts_as_translatable/issues">GitHub</a>, please <img src='http://lassebunk.dk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>
<a href="http://twitter.com/lassebunk" onclick="abtest.trackGoal(21, this);" class="icon twitter">Follow me on Twitter</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://lassebunk.dk/2012/05/15/translate-your-ruby-on-rails-models-and-database-tables-using-acts_as_translatable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Translate your Ruby on Rails YAML files using Bing</title>
		<link>http://lassebunk.dk/2012/05/09/translate-your-ruby-on-rails-yaml-files-using-bing/</link>
		<comments>http://lassebunk.dk/2012/05/09/translate-your-ruby-on-rails-yaml-files-using-bing/#comments</comments>
		<pubDate>Tue, 08 May 2012 22:44:06 +0000</pubDate>
		<dc:creator>lassebunk</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Bing]]></category>
		<category><![CDATA[I18n]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Translation]]></category>
		<category><![CDATA[YAML]]></category>

		<guid isPermaLink="false">http://lassebunk.dk/?p=2639</guid>
		<description><![CDATA[This plugin allows you to simply translate your Ruby on Rails YAML files into any language using Bing.]]></description>
			<content:encoded><![CDATA[<p>I have created a plugin named <a href="https://github.com/lassebunk/bing_translate_yaml">bing_translate_yaml</a> that allows you to simply translate your <a href="http://rubyonrails.org">Ruby on Rails</a> <a href="http://yaml.org/">YAML</a> files into any language using <a href="http://www.bing.com/">Bing</a>. The plugin takes your YAML files from the <strong>config/locales</strong> folder and converts them to any language of your choice.</p>
<p>In your <strong>Gemfile</strong>:</p>
<pre class="brush: ruby; title: ; notranslate">
gem 'bing_translate_yaml'
</pre>
<p>Then run:</p>
<pre class="brush: bash; title: ; notranslate">
$ bundle install
</pre>
<p>Make sure you have your translation files in e.g.:</p>
<pre class="brush: bash; title: ; notranslate">
config/locales/en.yml (English)
config/locales/de.yml (German)
config/locales/es.yml (Spanish)
</pre>
<p>Then run:</p>
<pre class="brush: bash; title: ; notranslate">
$ rake translate from=en to=es
</pre>
<p>This will create (or update) the following file:</p>
<pre class="brush: bash; title: ; notranslate">
config/locales/es.yml
</pre>
<p>Simple as cake! Enjoy <img src='http://lassebunk.dk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>
<a href="http://twitter.com/lassebunk" onclick="abtest.trackGoal(21, this);" class="icon twitter">Follow me on Twitter</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://lassebunk.dk/2012/05/09/translate-your-ruby-on-rails-yaml-files-using-bing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating your own WordPress plugin database migration framework</title>
		<link>http://lassebunk.dk/2012/01/14/wordpress-plugin-database-migration-framework/</link>
		<comments>http://lassebunk.dk/2012/01/14/wordpress-plugin-database-migration-framework/#comments</comments>
		<pubDate>Sat, 14 Jan 2012 22:58:42 +0000</pubDate>
		<dc:creator>lassebunk</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[How-to]]></category>
		<category><![CDATA[Migration]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://lassebunk.dk/?p=2413</guid>
		<description><![CDATA[How to create a database migration framework for WordPress that automatically migrates changes to your plugin database structure.]]></description>
			<content:encoded><![CDATA[<p>So, how do you migrate changes to your database structure from one version to another (like you may know it from <a href="http://guides.rubyonrails.org/migrations.html">Ruby on Rails</a>) when you are writing a WordPress plugin? Here&#8217;s one way to do it.</p>
<p>Let&#8217;s assume that the database migration should take place when the plugin is activated. Assuming your plugin is named <strong>myplugin</strong>, put this code in the <strong>myplugin.php</strong> file:</p>
<pre class="brush: php; title: ; notranslate">
register_activation_hook(__FILE__, 'myplugin_install');
</pre>
<p>This makes WordPress execute the <code>myplugin_install()</code> method when the user activates your plugin.</p>
<p>Next, add this method:</p>
<pre class="brush: php; title: ; notranslate">
function myplugin_install() {
  myplugin_migrate();
}
</pre>
<p>And our migration method:</p>
<pre class="brush: php; title: ; notranslate">
function myplugin_migrate() {
  global $wpdb;

  $migs = myplugin_migrations();

  $current_migration = get_option('myplugin_current_migration', 0);
  $needed_migration = count($migs);

  for ($i = $current_migration; $i &lt; $needed_migration; $i++) {
    $mig = $migs[$i];
    $wpdb-&gt;query($mig);
  }

  if ($current_migration == 0) {
    add_option('myplugin_current_migration', $needed_migration);
  } else {
    update_option('myplugin_current_migration', $needed_migration);
  }
}
</pre>
<p>What this does is that it runs through database statements (queries) returned from the <code>myplugin_migrations()</code> method. Let&#8217;s implement the actual migrations – add this method:</p>
<pre class="brush: php; title: ; notranslate">
function myplugin_migrations() {
  global $wpdb;

  $migs = array();

  // Create example table
  $migs[] = '
  CREATE TABLE '.$wpdb-&gt;prefix.'myplugin_examples (
    id int(11) NOT NULL AUTO_INCREMENT,
    name varchar(255) NOT NULL,
    PRIMARY KEY (id)
  )';

  // Add examples
  $migs[] = &quot;INSERT INTO &quot;.$wpdb-&gt;prefix.&quot;myplugin_examples SET name='First example'&quot;;
  $migs[] = &quot;INSERT INTO &quot;.$wpdb-&gt;prefix.&quot;myplugin_examples SET name='Second example'&quot;;

  // Return the migrations
  return $migs;
}
</pre>
<p>That would create an example table and insert some values.</p>
<p>Now imagine that two months later you need a <strong>description</strong> field in your <strong>examples</strong> table. What do you do? It&#8217;s as easy as adding one line of code to the migrations:</p>
<pre class="brush: php; title: ; notranslate">
// Add description field to examples
$migs[] = &quot;ALTER TABLE &quot;.$wpdb-&gt;prefix.&quot;myplugin_examples ADD description VARCHAR( 255 ) NOT NULL&quot;;
</pre>
<p>Deactivate and activate the plugin, and you table now has an extra field. Easy as cake! <img src='http://lassebunk.dk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Share your thoughts, opinions, and suggestions below.</p>
<p>
<a href="http://twitter.com/lassebunk" onclick="abtest.trackGoal(21, this);" class="icon twitter">Follow me on Twitter</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://lassebunk.dk/2012/01/14/wordpress-plugin-database-migration-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to split test themes using A/B Test for WordPress (video)</title>
		<link>http://lassebunk.dk/2012/01/14/split-test-ab-test-wordpress-themes/</link>
		<comments>http://lassebunk.dk/2012/01/14/split-test-ab-test-wordpress-themes/#comments</comments>
		<pubDate>Sat, 14 Jan 2012 18:01:31 +0000</pubDate>
		<dc:creator>lassebunk</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[A/B Test for WordPress]]></category>
		<category><![CDATA[A/B testing]]></category>
		<category><![CDATA[How-to]]></category>
		<category><![CDATA[Multivariate testing]]></category>
		<category><![CDATA[Split testing]]></category>
		<category><![CDATA[Themes]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://lassebunk.dk/?p=2386</guid>
		<description><![CDATA[How to use the A/B Test for WordPress plugin to split test your WordPress themes.]]></description>
			<content:encoded><![CDATA[<p>In this presentation I&#8217;m demonstrating how to use the <a href="/plugins/abtest/">A/B Test for WordPress</a> plugin to split test <a href="http://wordpress.org">WordPress</a> themes on your site:</p>
<p><iframe width="560" height="315" src="http://www.youtube.com/embed/GniZ0mkz3mU" frameborder="0" allowfullscreen></iframe></p>
<p>Visit the plugin page: <a href="/plugins/abtest/">A/B Test for WordPress</a></p>
<p>
<a href="http://twitter.com/lassebunk" onclick="abtest.trackGoal(21, this);" class="icon twitter">Follow me on Twitter</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://lassebunk.dk/2012/01/14/split-test-ab-test-wordpress-themes/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Split testing button colors using A/B Test for WordPress (video)</title>
		<link>http://lassebunk.dk/2012/01/14/split-test-button-colors-ab-test-wordpress/</link>
		<comments>http://lassebunk.dk/2012/01/14/split-test-button-colors-ab-test-wordpress/#comments</comments>
		<pubDate>Sat, 14 Jan 2012 17:31:57 +0000</pubDate>
		<dc:creator>lassebunk</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[A/B Test for WordPress]]></category>
		<category><![CDATA[A/B testing]]></category>
		<category><![CDATA[Multivariate testing]]></category>
		<category><![CDATA[Split testing]]></category>

		<guid isPermaLink="false">http://lassebunk.dk/?p=2366</guid>
		<description><![CDATA[How to use A/B Test for WordPress to split test the colors of a button linking to a product page.]]></description>
			<content:encoded><![CDATA[<p>In this presentation I&#8217;m demonstrating how to use the <a href="/plugins/abtest/">A/B Test for WordPress</a> plugin to split test button colors on your <a href="http://wordpress.org">WordPress</a> site:</p>
<p><iframe width="560" height="315" src="http://www.youtube.com/embed/Ia15LQJGG9A" frameborder="0" allowfullscreen></iframe></p>
<p>Visit the plugin page: <a href="/plugins/abtest/">A/B Test for WordPress</a></p>
<p>
<a href="http://twitter.com/lassebunk" onclick="abtest.trackGoal(21, this);" class="icon twitter">Follow me on Twitter</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://lassebunk.dk/2012/01/14/split-test-button-colors-ab-test-wordpress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using the A/B Test for WordPress plugin to split test between themes</title>
		<link>http://lassebunk.dk/2012/01/14/abtest-wordpress-plugin-split-test-themes/</link>
		<comments>http://lassebunk.dk/2012/01/14/abtest-wordpress-plugin-split-test-themes/#comments</comments>
		<pubDate>Sat, 14 Jan 2012 14:30:21 +0000</pubDate>
		<dc:creator>lassebunk</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[A/B Test for WordPress]]></category>
		<category><![CDATA[A/B testing]]></category>
		<category><![CDATA[How-to]]></category>
		<category><![CDATA[Multivariate testing]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Split testing]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://lassebunk.dk/?p=2289</guid>
		<description><![CDATA[How to use the A/B Test for WordPress plugin to split test between your WordPress themes.]]></description>
			<content:encoded><![CDATA[<p>I recently created the <a href="/plugins/abtest/">A/B Test for WordPress</a> plugin which enables the <a href="http://wordpress.org">WordPress</a> blog or site owner to easily split test content, stylesheets, javascripts, and, what we&#8217;ll be discussing today, themes.</p>
<p>Let&#8217;s say you have a blog and you have been using the standard WordPress Twenty Eleven theme for a while but now you saw this great looking theme that&#8217;s just a must have. How do you find out if this new theme will make your site perform better or worse, and how will it affect outbound link clicks to your new book at Amazon? Let&#8217;s find out <img src='http://lassebunk.dk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>WordPress comes with the Twenty Eleven theme, so we&#8217;ll split test between this and another theme. Let&#8217;s install the free <a href="http://wordpress.org/extend/themes/adventure-journal">Adventure Journal</a> theme:</p>
<p><a href="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-3.53.48-PM.png"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-3.53.48-PM-450x256.png" alt="" title="Screen Shot 2012-01-14 at 3.53.48 PM" width="450" height="256" class="alignnone size-medium wp-image-2308" /></a></p>
<p>For information on how to install themes, visit <a href="http://codex.wordpress.org/Using_Themes">Using Themes</a> on the WordPress site.</p>
<p>Then <a href="/plugins/abtest/">intall the plugin</a> and activate it in <strong>Plugins</strong>:</p>
<p><a href="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-3.36.21-PM.png"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-3.36.21-PM-450x146.png" alt="" title="Screen Shot 2012-01-14 at 3.36.21 PM" width="450" height="146" class="alignnone size-medium wp-image-2299" /></a></p>
<p>Click the <strong>A/B Testing</strong> link right below <strong>Settings</strong>:</p>
<p><a href="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-3.41.42-PM.png"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-3.41.42-PM.png" alt="" title="Screen Shot 2012-01-14 at 3.41.42 PM" width="280" height="132" class="alignnone size-full wp-image-2301" /></a></p>
<p>Click <strong>Create new experiment</strong>:</p>
<p><a href="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-3.42.47-PM.png"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-3.42.47-PM.png" alt="" title="Screen Shot 2012-01-14 at 3.42.47 PM" width="275" height="194" class="alignnone size-full wp-image-2302" /></a></p>
<p>Enter <strong>&#8220;Split testing my theme&#8221;</strong> as <strong>Name</strong> and select <strong>Theme</strong> as <strong>Experiment type</strong>:</p>
<p><a href="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-3.46.10-PM.png"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-3.46.10-PM.png" alt="" title="Screen Shot 2012-01-14 at 3.46.10 PM" width="381" height="234" class="alignnone size-full wp-image-2304" /></a></p>
<p>Click <strong>Create experiment</strong>.</p>
<p>Click <strong>Edit</strong> below <strong>Experiment 1</strong>:<br />
<a href="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-3.48.11-PM.png"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-3.48.11-PM.png" alt="" title="Screen Shot 2012-01-14 at 3.48.11 PM" width="438" height="250" class="alignnone size-full wp-image-2305" /></a></p>
<p>Select the <strong>Adventure Journal</strong> theme:</p>
<p><a href="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-3.56.51-PM.png"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-3.56.51-PM.png" alt="" title="Screen Shot 2012-01-14 at 3.56.51 PM" width="372" height="242" class="alignnone size-full wp-image-2311" /></a></p>
<p>Click <strong>Update variation</strong>.</p>
<p>Do the same for <strong>Variation 2</strong> where you select <strong>Twenty Eleven</strong> as the theme.</p>
<p>Click <strong>Back to experiments</strong> at the bottom of the page:</p>
<p><a href="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-3.58.53-PM.png"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-3.58.53-PM.png" alt="" title="Screen Shot 2012-01-14 at 3.58.53 PM" width="250" height="64" class="alignnone size-full wp-image-2312" /></a></p>
<p>Now we&#8217;re going into <strong>Debug mode</strong> to test our variations. About the Debug mode:</p>
<p><em>&#8220;Normally, when a user first sees a variation to an experiment, this variation is locked for this user so that – in this session – she always sees the same variation.<br />
If you want to test your experiments without this variation lock taking place for you (and only you), you can enable debug mode. Also, when entering debug mode, all tracking will be disabled for your session.&#8221;</em></p>
<p>Click <strong>Enter debug mode</strong> in the top right corner of the screen:</p>
<p><a href="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-4.02.28-PM.png"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-4.02.28-PM.png" alt="" title="Screen Shot 2012-01-14 at 4.02.28 PM" width="261" height="87" class="alignnone size-full wp-image-2316" /></a></p>
<p>Debug mode is now <strong>on</strong>:</p>
<p><a href="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-4.03.06-PM.png"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-4.03.06-PM.png" alt="" title="Screen Shot 2012-01-14 at 4.03.06 PM" width="255" height="61" class="alignnone size-full wp-image-2317" /></a></p>
<p>Now go to the <strong>front page</strong> of your site, and you&#8217;ll see one of the themes being displayed:</p>
<p><a href="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-4.03.48-PM.png"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-4.03.48-PM-450x212.png" alt="" title="Screen Shot 2012-01-14 at 4.03.48 PM" width="450" height="212" class="alignnone size-medium wp-image-2318" /></a></p>
<p>Now click <strong>Refresh</strong> a couple of times, and you&#8217;ll see that the theme changes:</p>
<p><a href="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-4.05.10-PM.png"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-4.05.10-PM-450x218.png" alt="" title="Screen Shot 2012-01-14 at 4.05.10 PM" width="450" height="218" class="alignnone size-medium wp-image-2319" /></a></p>
<p>Neat, eh? <img src='http://lassebunk.dk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Back into the <strong>admin</strong> interface, click <strong>Exit debug mode</strong>:</p>
<p><a href="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-4.06.45-PM.png"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-4.06.45-PM.png" alt="" title="Screen Shot 2012-01-14 at 4.06.45 PM" width="262" height="102" class="alignnone size-full wp-image-2322" /></a></p>
<p>We&#8217;ll now set up a link and track when this link is clicked. We&#8217;ll use a link to a book on Amazon to simulate an author site with a &#8220;Buy my book&#8221; link.</p>
<p>Click <strong>Split testing my theme</strong> and scroll down to <strong>Goals</strong>:</p>
<p><a href="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-4.08.52-PM.png"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-4.08.52-PM.png" alt="" title="Screen Shot 2012-01-14 at 4.08.52 PM" width="410" height="228" class="alignnone size-full wp-image-2323" /></a></p>
<p>Click <strong>Get tracking code</strong> right below <strong>Goal 1</strong> and you&#8217;ll see this screen:</p>
<p><a href="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-4.09.52-PM.png"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-4.09.52-PM-450x197.png" alt="" title="Screen Shot 2012-01-14 at 4.09.52 PM" width="450" height="197" class="alignnone size-medium wp-image-2324" /></a></p>
<p>Select the <strong>javascript</strong> code below <strong>To track a link</strong> and copy it to the clipboard using <strong>CMD + C</strong> (on a Mac) or <strong>CTRL + C</strong> (on a PC):</p>
<p><a href="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-4.11.54-PM.png"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-4.11.54-PM-450x56.png" alt="" title="Screen Shot 2012-01-14 at 4.11.54 PM" width="450" height="56" class="alignnone size-medium wp-image-2327" /></a></p>
<p>We&#8217;ll now create a <strong>widget</strong> with our link to Amazon.</p>
<p>Click <strong>Appearance</strong> and then <strong>Widgets</strong> in the menu to the left:</p>
<p><a href="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-4.13.39-PM.png"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-4.13.39-PM.png" alt="" title="Screen Shot 2012-01-14 at 4.13.39 PM" width="238" height="122" class="alignnone size-full wp-image-2329" /></a></p>
<p>Insert a widget by dragging a <strong>Text</strong> box from the <strong>Available Widgets</strong> box:</p>
<p><a href="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-4.16.21-PM.png"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-4.16.21-PM.png" alt="" title="Screen Shot 2012-01-14 at 4.16.21 PM" width="272" height="80" class="alignnone size-full wp-image-2331" /></a></p>
<p>Onto the <strong>Main Sidebar</strong> on the right:<br />
<a href="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-4.17.50-PM.png"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-4.17.50-PM-450x409.png" alt="" title="Screen Shot 2012-01-14 at 4.17.50 PM" width="450" height="409" class="alignnone size-medium wp-image-2332" /></a></p>
<p>Enter <strong>&#8220;Buy my book&#8221;</strong> as <strong>Title</strong> and insert this code below:<br />
<code><br />
&lt;a href=&quot;http://www.amazon.com/WordPress-Power-Guide-Blogging-ebook/dp/B004UW29IK/ref=sr_1_1?ie=UTF8&amp;qid=1326554345&amp;sr=8-1&quot; onclick=&quot;abtest.trackGoal(1, this);&quot;&gt;Buy my book on Amazon&lt;/a&gt;<br />
</code></p>
<p>Like this:</p>
<p><a href="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-4.21.28-PM.png"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-4.21.28-PM-450x171.png" alt="" title="Screen Shot 2012-01-14 at 4.21.28 PM" width="450" height="171" class="alignnone size-medium wp-image-2335" /></a></p>
<p>Notice how we&#8217;re using the <code>onclick=&quot;abtest.trackGoal(1, this);&quot;</code> code? That&#8217;s what&#8217;s tracking our link when we click it.</p>
<p>Click <strong>Save</strong>.</p>
<p>Now go back onto the <strong>front page</strong> and you&#8217;ll see that the widget has been inserted into your site:</p>
<p><a href="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-4.23.03-PM.png"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-4.23.03-PM.png" alt="" title="Screen Shot 2012-01-14 at 4.23.03 PM" width="343" height="104" class="alignnone size-full wp-image-2336" /></a></p>
<p>So far so good.</p>
<p>Try clicking the <strong>link</strong>.<br />
You have now tracked a goal completion!</p>
<p>Back into the <strong>admin</strong> interface, click on the <strong>experiment</strong> and you&#8217;ll see that it has tracked a goal completion:</p>
<p><a href="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-4.27.45-PM.png"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-14-at-4.27.45-PM-450x77.png" alt="" title="Screen Shot 2012-01-14 at 4.27.45 PM" width="450" height="77" class="alignnone size-medium wp-image-2337" /></a></p>
<p>Nice! Now you just need to wait and see which theme performs better.</p>
<p>For more info, installation instructions, and tutorials, visit the <a href="/plugins/abtest/">A/B Test for WordPress</a> plugin page.</p>
<p>Also, please feel free to <a href="/contact/">contact me</a> if you have any questions.</p>
<p>
<a href="http://twitter.com/lassebunk" onclick="abtest.trackGoal(21, this);" class="icon twitter">Follow me on Twitter</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://lassebunk.dk/2012/01/14/abtest-wordpress-plugin-split-test-themes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introduction to the A/B Test for WordPress plugin (video)</title>
		<link>http://lassebunk.dk/2012/01/14/ab-test-for-wordpress/</link>
		<comments>http://lassebunk.dk/2012/01/14/ab-test-for-wordpress/#comments</comments>
		<pubDate>Sat, 14 Jan 2012 00:28:48 +0000</pubDate>
		<dc:creator>lassebunk</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[A/B Test for WordPress]]></category>
		<category><![CDATA[A/B testing]]></category>
		<category><![CDATA[Multivariate testing]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Split testing]]></category>

		<guid isPermaLink="false">http://lassebunk.dk/?p=2235</guid>
		<description><![CDATA[A/B testing plugin for WordPress that makes it easy to A/B test any WordPress blog or site.]]></description>
			<content:encoded><![CDATA[<p><a href="/plugins/abtest/">A/B Test for WordPress</a> is a <a href="http://wordpress.org">WordPress</a> <a href="http://wordpress.org/extend/plugins/">plugin</a> that makes it easy to A/B split test your WordPress blog or site.</p>
<p><a href="/plugins/abtest/">Visit the plugin page</a> for more information, download, tutorials, and videos.</p>
<p>Here is a video introduction:</p>
<p><iframe width="560" height="315" src="http://www.youtube.com/embed/4VRxXj2e3_I" frameborder="0" allowfullscreen></iframe></p>
<p>&rarr; <a href="http://downloads.wordpress.org/plugin/abtest.zip">Download the plugin</a> (or <a href="/plugins/abtest/">see more information</a>)</p>
<p>Please feel free to <a href="/contact/">contact me</a> if you have any questions.</p>
<p>
<a href="http://twitter.com/lassebunk" onclick="abtest.trackGoal(21, this);" class="icon twitter">Follow me on Twitter</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://lassebunk.dk/2012/01/14/ab-test-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Making a simple Twitter app using iOS 5, Xcode 4.2, and storyboards</title>
		<link>http://lassebunk.dk/2012/01/09/making-a-simple-twitter-app-using-ios-5-xcode-4-2-and-storyboards/</link>
		<comments>http://lassebunk.dk/2012/01/09/making-a-simple-twitter-app-using-ios-5-xcode-4-2-and-storyboards/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 07:18:01 +0000</pubDate>
		<dc:creator>lassebunk</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[Beginner]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[How-to]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Storyboards]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://lassebunk.dk/?p=2040</guid>
		<description><![CDATA[How to use iOS 5, Xcode 4.2, and storyboards to create a simple Twitter app that will list tweets and show details about each tweet.]]></description>
			<content:encoded><![CDATA[<p>After recently learning to do iOS (iPhone and iPad) apps I thought I&#8217;d share some of the insigts I&#8217;ve gained over the last few weeks. Let&#8217;s do this by making a simple Twitter app that will list tweets and when you click a tweet, show details about the tweet and user.</p>
<p>Start by creating a new project from <strong>File</strong> &rsaquo; <strong>New</strong> &rsaquo; <strong>New Project</strong>.</p>
<p><a href="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-08-at-8.35.26-PM.png"><img class="size-full wp-image-2041" title="New Project" src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-08-at-8.35.26-PM.png" alt="" width="464" height="276" /></a></p>
<p>Select <strong>Master-Detail Application</strong> and click <strong>Next</strong>.</p>
<p><a href="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-08-at-8.47.37-PM.png"><img class="alignnone size-full wp-image-2042" title="Screen Shot 2012-01-08 at 8.47.37 PM" src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-08-at-8.47.37-PM.png" alt="" width="582" height="279.3333333333333" /></a></p>
<p>As Product Name enter &#8216;Twitter Test&#8217;. Make sure the <strong>Use Storyboard</strong> and <strong>Use Automatic Reference Counting</strong> check boxes are checked. Click <strong>Next</strong>.</p>
<p>Select where to save the project and click <strong>Create</strong>.</p>
<p><a href="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-08-at-8.51.22-PM.png"><img class="alignnone size-full wp-image-2044" title="Screen Shot 2012-01-08 at 8.51.22 PM" src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-08-at-8.51.22-PM.png" alt="" width="385.3333333333333" height="306" /></a></p>
<p>Your project is now created. It has automatically set up a storyboard a master view controller and a detail view controller. The storyboard is where we will design our app – the controllers are where the programming takes place.</p>
<p>Let&#8217;s open up our storyboard to see what it contains. Click on <strong>MainStoryboard.storyboard</strong> to the left and the storyboard comes up:</p>
<p><a href="http://lassebunk.dk/2012/01/09/making-a-simple-twitter-app-using-ios-5-xcode-4-2-and-storyboards/screen-shot-2012-01-08-at-8-57-31-pm/" rel="attachment wp-att-2050"><img class="alignnone size-medium wp-image-2050" title="Screen Shot 2012-01-08 at 8.57.31 PM" src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-08-at-8.57.31-PM-450x186.png" alt="" width="449.3333333333333" height="185.33333333333334" /></a></p>
<p>This basically tells us that we have:</p>
<ol>
<li>A <strong>navigation view controller</strong> – that&#8217;s the type of controller that automatically gives a Back button when you navigate from a list view down to a detail view.</li>
<li>A <strong>master view controller</strong> – that&#8217;s where we&#8217;ll have our tweet list.</li>
<li>A <strong>the detail view controller</strong> – that&#8217;s where we&#8217;ll have details about each tweet.</li>
</ol>
<p>The lines between each controller are called <strong>&#8216;segues&#8217;</strong>. We&#8217;ll talk more about these later on when we handle the action when the user selects a tweet.</p>
<p>Let&#8217;s set up our <strong>table view</strong>.</p>
<p>Select the table view in the tree view to the left:</p>
<p><a href="http://lassebunk.dk/2012/01/09/making-a-simple-twitter-app-using-ios-5-xcode-4-2-and-storyboards/screen-shot-2012-01-08-at-9-23-32-pm/" rel="attachment wp-att-2056"><img class="alignnone size-medium wp-image-2056" title="Screen Shot 2012-01-08 at 9.23.32 PM" src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-08-at-9.23.32-PM-450x227.png" alt="" width="449.3333333333333" height="226" /></a></p>
<p>And to the right select <strong>Dynamic Prototypes</strong> instead of <strong>Static Cells</strong>:</p>
<p><a href="http://lassebunk.dk/2012/01/09/making-a-simple-twitter-app-using-ios-5-xcode-4-2-and-storyboards/screen-shot-2012-01-08-at-9-24-32-pm/" rel="attachment wp-att-2057"><img class="alignnone size-full wp-image-2057" title="Screen Shot 2012-01-08 at 9.24.32 PM" src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-08-at-9.24.32-PM.png" alt="" width="387.3333333333333" height="227.33333333333334" /></a></p>
<p>This tells the table view that we&#8217;re going to set up the cells <strong>dynamically</strong> from our controller.</p>
<p>Next, again in the tree view to the left, select the <strong>Table View Cell</strong>:</p>
<p><a href="http://lassebunk.dk/2012/01/09/making-a-simple-twitter-app-using-ios-5-xcode-4-2-and-storyboards/screen-shot-2012-01-08-at-9-26-33-pm/" rel="attachment wp-att-2058"><img class="alignnone size-full wp-image-2058" title="Screen Shot 2012-01-08 at 9.26.33 PM" src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-08-at-9.26.33-PM.png" alt="" width="381.3333333333333" height="224" /></a></p>
<p>And, on the right, set style to <strong>Subtitle</strong> and <strong>Identifier</strong> to <strong>&#8216;TweetCell&#8217;</strong> – that&#8217;s the name we&#8217;re going to use in our code to find the cell so we can fill out its details:<br />
<a href="http://lassebunk.dk/2012/01/09/making-a-simple-twitter-app-using-ios-5-xcode-4-2-and-storyboards/screen-shot-2012-01-08-at-9-28-24-pm/" rel="attachment wp-att-2059"><img class="alignnone size-full wp-image-2059" title="Screen Shot 2012-01-08 at 9.28.24 PM" src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-08-at-9.28.24-PM.png" alt="" width="308" height="163.33333333333334" /></a></p>
<p>You&#8217;ll see that the view style changes – that&#8217;s the style we&#8217;ll use to display the tweet text as the title, and tweet author as the subtitle:</p>
<p><a href="http://lassebunk.dk/2012/01/09/making-a-simple-twitter-app-using-ios-5-xcode-4-2-and-storyboards/screen-shot-2012-01-08-at-9-36-25-pm/" rel="attachment wp-att-2066"><img class="alignnone size-full wp-image-2066" title="Screen Shot 2012-01-08 at 9.36.25 PM" src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-08-at-9.36.25-PM.png" alt="" width="435" height="189" /></a></p>
<p>So, now we&#8217;re all set up in the storyboard part – at least as far as the master view goes. Don&#8217;t worry – we&#8217;ll get back to the detail view later on.</p>
<p>Go into <strong>MasterViewController.m</strong> by selecting it on the left:</p>
<p><a href="http://lassebunk.dk/2012/01/09/making-a-simple-twitter-app-using-ios-5-xcode-4-2-and-storyboards/screen-shot-2012-01-08-at-9-40-49-pm/" rel="attachment wp-att-2069"><img class="alignnone size-medium wp-image-2069" title="Screen Shot 2012-01-08 at 9.40.49 PM" src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-08-at-9.40.49-PM-450x154.png" alt="" width="450" height="154" /></a></p>
<p>This is where all the action will take place. But first we need to set up an instance variable to contain our tweets.</p>
<p>Click on <strong>MasterViewController.h</strong> to the left:</p>
<p><a href="http://lassebunk.dk/2012/01/09/making-a-simple-twitter-app-using-ios-5-xcode-4-2-and-storyboards/screen-shot-2012-01-08-at-9-45-54-pm/" rel="attachment wp-att-2070"><img class="alignnone size-medium wp-image-2070" title="Screen Shot 2012-01-08 at 9.45.54 PM" src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-08-at-9.45.54-PM-450x158.png" alt="" width="450" height="158" /></a></p>
<p>And replace the <code>@interface</code> to <code>@end</code> part with the following code:</p>
<pre class="brush: objc; title: ; notranslate">
@interface MasterViewController : UITableViewController {
    NSArray *tweets;
}

- (void)fetchTweets;

@end
</pre>
<p>This tells Objective-C that we have a <code>tweets</code> instance variable and a <code>fetchTweets</code> method.</p>
<p>Now to the actual tweet fetching. Go back into <strong>MasterViewController.m</strong> and insert the following method:</p>
<pre class="brush: objc; title: ; notranslate">
- (void)fetchTweets
{
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSData* data = [NSData dataWithContentsOfURL:
                        [NSURL URLWithString: @&quot;https://api.twitter.com/1/statuses/public_timeline.json&quot;]];

        NSError* error;

        tweets = [NSJSONSerialization JSONObjectWithData:data
                                                 options:kNilOptions
                                                   error:&amp;error];

        dispatch_async(dispatch_get_main_queue(), ^{
            [self.tableView reloadData];
        });
    });
}
</pre>
<p>What this does is that it makes a <strong>separate thread</strong> to fetch the JSON data and then goes back to the main thread to update the table view when it&#8217;s done. The reason to do this is that if we were to get the data using the <strong>main thread</strong>, then the application would lock up until the data was loaded.</p>
<p>Call this method from inside the <code>viewDidLoad</code> method:</p>
<pre class="brush: objc; title: ; notranslate">
- (void)viewDidLoad
{
    [super viewDidLoad];
    [self fetchTweets];
}
</pre>
<p>This tells the application to load the JSON data as soon as the view loads.</p>
<p>So now our Twitter feed is loaded into to our instance variable named <code>tweets</code>. This now contains an array holding a number of <code>NSDictionary</code> objects where <code>NSDictionary</code> is a key/value collection.</p>
<p>Next, insert the following two methods:</p>
<pre class="brush: objc; title: ; notranslate">
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return tweets.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @&quot;TweetCell&quot;;

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

    NSDictionary *tweet = [tweets objectAtIndex:indexPath.row];
    NSString *text = [tweet objectForKey:@&quot;text&quot;];
    NSString *name = [[tweet objectForKey:@&quot;user&quot;] objectForKey:@&quot;name&quot;];

    cell.textLabel.text = text;
    cell.detailTextLabel.text = [NSString stringWithFormat:@&quot;by %@&quot;, name];

    return cell;
}
</pre>
<p>And run your application. Click the <strong>Run</strong> icon:</p>
<p><a href="http://lassebunk.dk/2012/01/09/making-a-simple-twitter-app-using-ios-5-xcode-4-2-and-storyboards/screen-shot-2012-01-08-at-10-15-22-pm/" rel="attachment wp-att-2076"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-08-at-10.15.22-PM.png" alt="" title="Screen Shot 2012-01-08 at 10.15.22 PM" width="75" height="56" class="alignnone size-full wp-image-2076" /></a></p>
<p>And it works:</p>
<p><a href="http://lassebunk.dk/2012/01/09/making-a-simple-twitter-app-using-ios-5-xcode-4-2-and-storyboards/screen-shot-2012-01-08-at-10-13-07-pm/" rel="attachment wp-att-2075"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-08-at-10.13.07-PM-239x450.png" alt="" title="Screen Shot 2012-01-08 at 10.13.07 PM" width="239" height="450" class="alignnone size-medium wp-image-2075" style="border: none;" /></a></p>
<p>Pretty simple, huh? <img src='http://lassebunk.dk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Well, can&#8217;t dwell on our success, so let&#8217;s go on to something that needs to be done.</p>
<p>Try selecting a tweet. Our intention was to load the detail view, but this doesn&#8217;t happen. Why not?</p>
<p>Go back into the storyboard:</p>
<p><a href="http://lassebunk.dk/2012/01/09/making-a-simple-twitter-app-using-ios-5-xcode-4-2-and-storyboards/screen-shot-2012-01-08-at-10-21-12-pm/" rel="attachment wp-att-2079"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-08-at-10.21.12-PM-450x243.png" alt="" title="Screen Shot 2012-01-08 at 10.21.12 PM" width="450" height="243" class="alignnone size-medium wp-image-2079" /></a></p>
<p>Notice how there&#8217;s no segue between the master view controller and the detail view controller. What happened was that when we went from static cells to prototype cells in the storyboard before, it erased it, so now it doesn&#8217;t know what to do. Let&#8217;s help it out.</p>
<p>To the left, <strong>CTRL + drag</strong> from the <strong>Table View Cell</strong> to <strong>Detail View Controller</strong>, and select <strong>Push</strong>:</p>
<p><a href="http://lassebunk.dk/2012/01/09/making-a-simple-twitter-app-using-ios-5-xcode-4-2-and-storyboards/screen-shot-2012-01-08-at-10-26-34-pm/" rel="attachment wp-att-2081"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-08-at-10.26.34-PM.png" alt="" title="Screen Shot 2012-01-08 at 10.26.34 PM" width="394" height="299" class="alignnone size-full wp-image-2081" /></a></p>
<p>Now it knows what to do, so try hitting <strong>Run</strong> again.</p>
<p><a href="http://lassebunk.dk/2012/01/09/making-a-simple-twitter-app-using-ios-5-xcode-4-2-and-storyboards/untitled/" rel="attachment wp-att-2082"><img src="http://lassebunk.dk/media/2012/01/Untitled-235x450.png" alt="" title="Untitled" width="235" height="450" class="alignnone size-medium wp-image-2082" /></a></p>
<p>And it works.</p>
<p>In the storyboard, double click on the <strong>&#8216;Master&#8217;</strong> and <strong>&#8216;Detail&#8217;</strong> titles and change them to <strong>&#8216;Tweets&#8217;</strong> and <strong>&#8216;Tweet&#8217;</strong> accordingly:<br />
<a href="http://lassebunk.dk/2012/01/09/making-a-simple-twitter-app-using-ios-5-xcode-4-2-and-storyboards/screen-shot-2012-01-08-at-10-30-55-pm/" rel="attachment wp-att-2085"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-08-at-10.30.55-PM-450x148.png" alt="" title="Screen Shot 2012-01-08 at 10.30.55 PM" width="450" height="148" class="alignnone size-medium wp-image-2085" /></a></p>
<p>Click on the <strong>segue</strong> between the table view and detail view:</p>
<p><a href="http://lassebunk.dk/2012/01/09/making-a-simple-twitter-app-using-ios-5-xcode-4-2-and-storyboards/screen-shot-2012-01-08-at-10-36-47-pm/" rel="attachment wp-att-2088"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-08-at-10.36.47-PM.png" alt="" title="Screen Shot 2012-01-08 at 10.36.47 PM" width="336" height="281" class="alignnone size-full wp-image-2088" /></a></p>
<p>And change its identifier to <strong>&#8216;showTweet&#8217;</strong>:</p>
<p><a href="http://lassebunk.dk/2012/01/09/making-a-simple-twitter-app-using-ios-5-xcode-4-2-and-storyboards/screen-shot-2012-01-08-at-10-37-54-pm/" rel="attachment wp-att-2089"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-08-at-10.37.54-PM-450x261.png" alt="" title="Screen Shot 2012-01-08 at 10.37.54 PM" width="450" height="261" class="alignnone size-medium wp-image-2089" /></a></p>
<p>In MasterViewController.m, right below <code>#import "MasterViewController.h"</code>, insert the following code:</p>
<pre class="brush: objc; title: ; notranslate">
#import &quot;DetailViewController.h&quot;
</pre>
<p>This is to give us access to the detail view controller from the master view controller.</p>
<p>Insert the following method:</p>
<pre class="brush: objc; title: ; notranslate">
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@&quot;showTweet&quot;]) {

        NSInteger row = [[self tableView].indexPathForSelectedRow row];
        NSDictionary *tweet = [tweets objectAtIndex:row];

        DetailViewController *detailController = segue.destinationViewController;
        detailController.detailItem = tweet;
    }
}
</pre>
<p>Basically what this does is that it tells the app what to do when it hits the segue between the master view and the detail view. It identifies the selected row, finds the tweet, and then sets the detailItem property on the detail view controller. (The detailItem property was automatically created when we selected <strong>Master-Detail Application</strong> in the beginning. Thanks Xcode!)</p>
<p>Now we&#8217;re ready to do the <strong>detail view controller</strong>.</p>
<p>Open up the storyboard and delete the label saying <strong>&#8216;Detail view content goes here&#8217;</strong>. We&#8217;ll be creating our own.</p>
<p>Insert a label for the name, a label for the tweet, and an image view for the profile image, like this:</p>
<p><a href="http://lassebunk.dk/2012/01/09/making-a-simple-twitter-app-using-ios-5-xcode-4-2-and-storyboards/screen-shot-2012-01-08-at-11-03-48-pm/" rel="attachment wp-att-2100"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-08-at-11.03.48-PM-429x450.png" alt="" title="Screen Shot 2012-01-08 at 11.03.48 PM" width="429" height="450" class="alignnone size-medium wp-image-2100" /></a></p>
<p>You can customize the text sizes like you want.</p>
<p>We&#8217;ll need a way to call these new controls from our code. This is done by creating three outlets which is a sort of wire, or connection, between the view and the controller. In <strong>DetailViewController.h</strong>, replace the <code>@interface</code> line with the following code:</p>
<pre class="brush: objc; title: ; notranslate">
@interface DetailViewController : UIViewController {
    IBOutlet UIImageView *profileImage;
    IBOutlet UILabel *nameLabel;
    IBOutlet UILabel *tweetLabel;
}
</pre>
<p>Now we have created the outlets. We now need to reference, or connect, these from our views. To the left, <strong>CTRL + drag</strong> from <strong>Detail View Controller</strong> to <strong>&#8216;Label &#8211; Name goes here&#8217;</strong> and select <strong>nameLabel</strong>:</p>
<p><a href="http://lassebunk.dk/2012/01/09/making-a-simple-twitter-app-using-ios-5-xcode-4-2-and-storyboards/screen-shot-2012-01-08-at-11-09-44-pm/" rel="attachment wp-att-2101"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-08-at-11.09.44-PM.png" alt="" title="Screen Shot 2012-01-08 at 11.09.44 PM" width="383" height="191" class="alignnone size-full wp-image-2101" /></a></p>
<p><strong>CTRL + drag</strong> also from <strong>Detail View Controller</strong> to <strong>&#8216;Label &#8211; Tweet goes here&#8217;</strong> and select <strong>tweetLabel</strong>, and from <strong>Detail View Controller</strong> to <strong>&#8216;Image View&#8217;</strong> and select <strong>profileImage</strong>.</p>
<p>Now we can call the labels and image view from our code.</p>
<p>In DetailViewController.rb, replace the <code>configureView</code> method with the following code:</p>
<pre class="brush: objc; title: ; notranslate">
- (void)configureView
{
    if (self.detailItem) {
        NSDictionary *tweet = self.detailItem;

        NSString *text = [[tweet objectForKey:@&quot;user&quot;] objectForKey:@&quot;name&quot;];
        NSString *name = [tweet objectForKey:@&quot;text&quot;];

        tweetLabel.lineBreakMode = UILineBreakModeWordWrap;
        tweetLabel.numberOfLines = 0;

        nameLabel.text = text;
        tweetLabel.text = name;

        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
            NSString *imageUrl = [[tweet objectForKey:@&quot;user&quot;] objectForKey:@&quot;profile_image_url&quot;];
            NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:imageUrl]];

            dispatch_async(dispatch_get_main_queue(), ^{
                profileImage.image = [UIImage imageWithData:data];
            });
        });
    }
}
</pre>
<p>Try running the code, and there you have it – a list view and a detail view showing the tweet!</p>
<div style="overflow: hidden;">
<a href="http://lassebunk.dk/2012/01/09/making-a-simple-twitter-app-using-ios-5-xcode-4-2-and-storyboards/screen-shot-2012-01-09-at-7-46-31-am/" rel="attachment wp-att-2122"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-09-at-7.46.31-AM-239x450.png" alt="" title="Screen Shot 2012-01-09 at 7.46.31 AM" width="239" height="450" class="alignleft size-medium wp-image-2122" style="border: none;" /></a><a href="http://lassebunk.dk/2012/01/09/making-a-simple-twitter-app-using-ios-5-xcode-4-2-and-storyboards/screen-shot-2012-01-09-at-7-46-34-am/" rel="attachment wp-att-2123"><img src="http://lassebunk.dk/media/2012/01/Screen-Shot-2012-01-09-at-7.46.34-AM-239x450.png" alt="" title="Screen Shot 2012-01-09 at 7.46.34 AM" width="239" height="450" class="alignleft size-medium wp-image-2123" style="border: none;" /></a>
</div>
<p>Hope you liked it <img src='http://lassebunk.dk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<ul>
<li>Check out more of the Twitter API <a href="https://api.twitter.com/1/statuses/public_timeline.json">here</a> and <a href="https://dev.twitter.com/docs/api/1/get/statuses/public_timeline">here</a></li>
<li>More JSON <a href="http://www.raywenderlich.com/5492/working-with-json-in-ios-5">here</a></li>
<li>Thanks to the team at <a href="http://www.raywenderlich.com/">Ray Wendelich</a> for inspiring me to begin iOS programming</li>
</ul>
<p>
<a href="http://twitter.com/lassebunk" onclick="abtest.trackGoal(21, this);" class="icon twitter">Follow me on Twitter</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://lassebunk.dk/2012/01/09/making-a-simple-twitter-app-using-ios-5-xcode-4-2-and-storyboards/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Sitemap Notifier: Ruby on Rails plugin for notifying search engines of changes to sitemap</title>
		<link>http://lassebunk.dk/2011/09/18/sitemap-notifier/</link>
		<comments>http://lassebunk.dk/2011/09/18/sitemap-notifier/#comments</comments>
		<pubDate>Sun, 18 Sep 2011 19:08:16 +0000</pubDate>
		<dc:creator>lassebunk</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Bing]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[Sitemaps]]></category>
		<category><![CDATA[Yahoo]]></category>

		<guid isPermaLink="false">http://lassebunk.dk/?p=2004</guid>
		<description><![CDATA[Ruby on Rails plugin that automatically notifies Google, Bing, and Yahoo when your models change.]]></description>
			<content:encoded><![CDATA[<p><a href="https://github.com/lassebunk/sitemap_notifier">Sitemap Notifier</a> is a <a href="http://rubyonrails.org">Ruby on Rails</a> plugin that, when installed, automatically notifies <a href="http://www.google.com">Google</a>, <a href="http://www.bing.com">Bing</a>, and <a href="http://www.yahoo.com">Yahoo</a> of changes to your models, i.e. changes to your <a href="http://www.sitemaps.org/">sitemap</a>. It also works in conjunction with the <a href="http://lassebunk.dk/2010/10/29/ruby-on-rails-sitemap-plugin/">Dynamic Sitemaps</a> plugin.</p>
<h3>Installation</h3>
<p>In Rails 3:</p>
<pre class="brush: bash; title: ; notranslate">
$ rails plugin install git://github.com/lassebunk/sitemap_notifier.git
</pre>
<h3>Example</h3>
<p>Start by generating initializer and route:</p>
<pre class="brush: bash; title: ; notranslate">
$ rails generate sitemap_notifier sitemap_notifier
</pre>
<p>In config/initializers/sitemap_notifier.rb:</p>
<pre class="brush: ruby; title: ; notranslate">
# wait 10 minutes between notifications
SitemapNotifier::Notifier.delay = 600

# replace this with your own url
SitemapNotifier::Notifier.sitemap_url = &quot;http://example.com/sitemap.xml&quot;
</pre>
<h3>After installation</h3>
<p>After you install and configure the plugin, it’ll automatically notify Google, Bing, and Yahoo every time you update a model. After each notification, it’ll wait 10 minutes (by default) before notifying again. This is to ensure that for example a batch update won’t trigger an equal amount of notifications.</p>
<p>
<a href="http://twitter.com/lassebunk" onclick="abtest.trackGoal(21, this);" class="icon twitter">Follow me on Twitter</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://lassebunk.dk/2011/09/18/sitemap-notifier/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ApiBuilder: Ruby on Rails XML and JSON builder in one</title>
		<link>http://lassebunk.dk/2011/09/12/introducing-apibuilder-xml-and-json-builder-in-one/</link>
		<comments>http://lassebunk.dk/2011/09/12/introducing-apibuilder-xml-and-json-builder-in-one/#comments</comments>
		<pubDate>Mon, 12 Sep 2011 17:26:15 +0000</pubDate>
		<dc:creator>lassebunk</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Builder]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://lassebunk.dk/?p=1966</guid>
		<description><![CDATA[ApiBuilder is a Ruby on Rails plugin that generates XML and JSON from a single specification.]]></description>
			<content:encoded><![CDATA[<p><a href="https://github.com/lassebunk/api_builder" title="ApiBuilder on GitHub">ApiBuilder</a> is a <a href="http://rubyonrails.org/">Ruby on Rails</a> template engine that allows for multiple formats being laid out in a single specification, currently XML and <a href="http://json.org/">JSON</a>. The template engine then returns a hash that is converted to either JSON or XML.</p>
<p>Like this:</p>
<p>In <em>app/views/api/users/index.apibuilder</em>:</p>
<pre class="brush: ruby; title: ; notranslate">
array :users do
  @users.each do |user|
    element :user do
      id @user.id
      name @user.name
    end
  end
end
</pre>
<p>Returns:</p>
<pre class="brush: jscript; title: ; notranslate">
[
  {
    &quot;id&quot;: 1234,
    &quot;name&quot;: &quot;Peter Jackson&quot;
  },
  {
    &quot;id&quot;: 1235,
    &quot;name&quot;: &quot;Marilyn Monroe&quot;
  }
]
</pre>
<p>And the equivalent XML.</p>
<p>In <em>app/views/api/users/show.apibuilder</em>:</p>
<pre class="brush: ruby; title: ; notranslate">
element :user do
  id @user.id
  name @user.name
  address do
    street @user.street
    city @user.city
  end
  array :interests do
    @user.interests.each do |interest|
      element :interest, interest.name
    end
  end
end
</pre>
<p>Returns:</p>
<pre class="brush: jscript; title: ; notranslate">
{
  &quot;id&quot;: 1234,
  &quot;name&quot;: &quot;Peter Jackson&quot;,
  &quot;address&quot;: {
    &quot;street&quot;: &quot;123 High Way&quot;,
    &quot;city&quot;: &quot;Gotham City&quot;
  },
  &quot;interests&quot;: [
    &quot;Movies&quot;,
    &quot;Computers&quot;,
    &quot;Internet&quot;
  ]
}
</pre>
<p>And the equivalent XML.</p>
<p>You can then call your API like this:</p>
<p><em>http://example.com/api/users?format=json</em></p>
<p>or</p>
<p><em>http://example.com/api/users?format=xml</em></p>
<p>and so on.</p>
<p>Installation:</p>
<pre class="brush: bash; title: ; notranslate">
$ rails plugin install git://github.com/lassebunk/api_builder.git
</pre>
<p>Documentation and examples: <a href="https://github.com/lassebunk/api_builder" title="ApiBuilder at GitHub">Check out ApiBuilder at GitHub</a>.<br />
Looking forward to comments and suggestions <img src='http://lassebunk.dk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>
<a href="http://twitter.com/lassebunk" onclick="abtest.trackGoal(21, this);" class="icon twitter">Follow me on Twitter</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://lassebunk.dk/2011/09/12/introducing-apibuilder-xml-and-json-builder-in-one/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

