<?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>Kristian Lunde &#187; web</title>
	<atom:link href="http://www.klunde.net/category/web/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.klunde.net</link>
	<description>www.klunde.net</description>
	<lastBuildDate>Sun, 18 Jul 2010 21:00:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Zend_Input_Filter and the Alnum Validator</title>
		<link>http://www.klunde.net/2010/07/18/zend_input_filter-and-the-alnum-validator/</link>
		<comments>http://www.klunde.net/2010/07/18/zend_input_filter-and-the-alnum-validator/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 21:00:28 +0000</pubDate>
		<dc:creator>Kristian Lunde</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[Zend_Input_Filter]]></category>
		<category><![CDATA[Zend_Validate_Alnum]]></category>

		<guid isPermaLink="false">http://www.klunde.net/?p=518</guid>
		<description><![CDATA[
			
				
			
		
The Zend_Input_Filter is a very useful tool when you need to validate and filter the input to your application. It allows you to both filter and validate the input without a lot of hassle. One of the cool features it has is that it allows you to add the validators you need and meta commands [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.klunde.net%2F2010%2F07%2F18%2Fzend_input_filter-and-the-alnum-validator%2F" onclick="urchinTracker('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.klunde.net_2F2010_2F07_2F18_2Fzend_input_filter-and-the-alnum-validator_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.klunde.net%2F2010%2F07%2F18%2Fzend_input_filter-and-the-alnum-validator%2F&amp;source=kristianlunde&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>The <a href="http://framework.zend.com/manual/en/zend.filter.input.html" onclick="urchinTracker('/outgoing/framework.zend.com/manual/en/zend.filter.input.html?referer=');">Zend_Input_Filter</a> is a very useful tool when you need to validate and filter the input to your application. It allows you to both filter and validate the input without a lot of hassle. One of the cool features it has is that it allows you to add the validators you need and meta commands to each validator. For instance you can set an <a href="http://framework.zend.com/manual/en/zend.validate.set.html" onclick="urchinTracker('/outgoing/framework.zend.com/manual/en/zend.validate.set.html?referer=');">Alnum</a> validator to allow empty fields, set a default text and so on. </p>
<p>I came over this annoying issue the other day when I tried to setup the Alnum validator to allow white spaces and have a few meta commands attached to the validator chain. The <a href="http://framework.zend.com/manual/en/zend.filter.input.html" onclick="urchinTracker('/outgoing/framework.zend.com/manual/en/zend.filter.input.html?referer=');">manual</a> says that you can do this:</p>
<div class="geshi no php">
<ol>
<li class="li1">
<div class="de1"><span class="re1">$validators</span> <span class="sy0">=</span> <span class="kw3">array</span><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="st0">&#39;month&#39;</span> &nbsp; <span class="sy0">=&gt;</span> <span class="kw3">array</span><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#39;Digits&#39;</span><span class="sy0">,</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">// string</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">new</span> Zend_Validate_Int<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">,</span> <span class="co1">// object instance</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">array</span><span class="br0">&#40;</span><span class="st0">&#39;Between&#39;</span><span class="sy0">,</span> <span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">12</span><span class="br0">&#41;</span> &nbsp;<span class="co1">// string with constructor arguments</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
</ol>
</div>
<p>Which I assumed would also work like this:</p>
<div class="geshi no php">
<ol>
<li class="li1">
<div class="de1"><span class="re1">$validators</span> <span class="sy0">=</span> <span class="kw3">array</span><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="st0">&#39;name&#39;</span> &nbsp; <span class="sy0">=&gt;</span> <span class="kw3">array</span><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#39;Alnum&#39;</span><span class="sy0">,</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">new</span> Zend_Validate_Alnum<span class="br0">&#40;</span><span class="kw2">true</span><span class="br0">&#41;</span><span class="sy0">,</span> <span class="co1">//allow whitespaces</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&#39;default&#39;</span> <span class="sy0">=&gt;</span> <span class="st0">&#39;&#39;</span><span class="sy0">,</span> &nbsp;<span class="co1">//meta command 1</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&#39;presence&#39;</span> <span class="sy0">=&gt;</span> <span class="st0">&#39;required&#39;</span><span class="sy0">,</span> <span class="co1">//meta command 2</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
</ol>
</div>
<p>This does not work though. You need to remove the validator type string and replace it with an instance of the Zend_Validate_Alnum validator to get it to accept whitespaces and meta commands. This is the right way to do it:</p>
<div class="geshi no php">
<ol>
<li class="li1">
<div class="de1"><span class="re1">$validators</span> <span class="sy0">=</span> <span class="kw3">array</span><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="st0">&#39;name&#39;</span> &nbsp; <span class="sy0">=&gt;</span> <span class="kw3">array</span><span class="br0">&#40;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">new</span> Zend_Validate_Alnum<span class="br0">&#40;</span><span class="kw2">true</span><span class="br0">&#41;</span><span class="sy0">,</span> <span class="co1">//allow whitespaces</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&#39;default&#39;</span> <span class="sy0">=&gt;</span> <span class="st0">&#39;&#39;</span><span class="sy0">,</span> <span class="co1">//meta command 1</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&#39;presence&#39;</span> <span class="sy0">=&gt;</span> <span class="st0">&#39;required&#39;</span><span class="sy0">,</span> <span class="co1">//meta command 2</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
</ol>
</div>
<p>The entire script ends up looking like this:</p>
<div class="geshi no php">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$filters</span> <span class="sy0">=</span> <span class="kw3">array</span><span class="br0">&#40;</span><span class="st0">&#39;name&#39;</span> <span class="sy0">=&gt;</span> <span class="st0">&#39;StringTrim&#39;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$validators</span> <span class="sy0">=</span> &nbsp;<span class="kw3">array</span><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="st0">&#39;name&#39;</span> &nbsp; <span class="sy0">=&gt;</span> <span class="kw3">array</span><span class="br0">&#40;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">new</span> Zend_Validate_Alnum<span class="br0">&#40;</span><span class="kw2">true</span><span class="br0">&#41;</span><span class="sy0">,</span> <span class="co1">//allow whitespaces</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&#39;default&#39;</span> <span class="sy0">=&gt;</span> <span class="st0">&#39;&#39;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&#39;presence&#39;</span> <span class="sy0">=&gt;</span> <span class="st0">&#39;required&#39;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$input</span> <span class="sy0">=</span> <span class="kw2">new</span> Zend_Input_Filter<span class="br0">&#40;</span><span class="re1">$filter</span><span class="sy0">,</span> <span class="re1">$input</span><span class="sy0">,</span> <span class="re1">$this</span><span class="sy0">-&gt;</span><span class="me1">getRequest</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">-&gt;</span><span class="me1">getParams</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.klunde.net/2010/07/18/zend_input_filter-and-the-alnum-validator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My Bookshelf &amp; openbook</title>
		<link>http://www.klunde.net/2009/11/22/my-bookshelf-openbook/</link>
		<comments>http://www.klunde.net/2009/11/22/my-bookshelf-openbook/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 23:19:54 +0000</pubDate>
		<dc:creator>Kristian Lunde</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[openbook]]></category>

		<guid isPermaLink="false">http://www.klunde.net/?p=469</guid>
		<description><![CDATA[
			
				
			
		
Yesterday I installed the openbook plugin for wordpress on this site. My intentions was to build a &#8220;My bookshelf&#8221; page similar to what Mats Lindh and Trond Huso have on their sites. 
I installed the plugin without any problems but the layout was a bit nasty. I don&#8217;t know if that was because of the [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.klunde.net%2F2009%2F11%2F22%2Fmy-bookshelf-openbook%2F" onclick="urchinTracker('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.klunde.net_2F2009_2F11_2F22_2Fmy-bookshelf-openbook_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.klunde.net%2F2009%2F11%2F22%2Fmy-bookshelf-openbook%2F&amp;source=kristianlunde&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Yesterday I installed the <a href="http://wordpress.org/extend/plugins/openbook-book-data/" onclick="urchinTracker('/outgoing/wordpress.org/extend/plugins/openbook-book-data/?referer=');">openbook</a> plugin for wordpress on this site. My intentions was to build a &#8220;My bookshelf&#8221; page similar to what <a href="http://e-mats.org/" onclick="urchinTracker('/outgoing/e-mats.org/?referer=');">Mats Lindh</a> and Trond Huso have on their sites. </p>
<p>I installed the plugin without any problems but the layout was a bit nasty. I don&#8217;t know if that was because of the theme I am running on this site or if the openbook markup was messed up. Anyway I rewrote the html and css for the openbooks template on its configuration page and added some custom css to the site to get it working. </p>
<p>This is my openbook template:</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">&lt;li&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;div class=&quot;medium&quot;&gt;[OB_COVER_MEDIUM]&lt;/div&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;div class=&quot;description&quot;&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;div class=&quot;title&quot;&gt;[OB_TITLE]&lt;/div&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;div class=&quot;meta-1&quot;&gt;Written by: [OB_AUTHORS]&lt;/div&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;div class=&quot;publisher-year&quot;&gt;[OB_PUBLISHER] [OB_PUBLISHYEAR]&lt;/div&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;div class=&quot;category&quot;&gt;[OB_LINK_WORLDCAT][OB_DOT][OB_READONLINE][OB_DOT][OB_LINK_LIBRARYTHING][OB_DOT][OB_LINK_GOOGLEBOOKS][OB_DOT][OB_LINK_BOOKFINDER]&lt;/div&gt;[OB_COINS]
</div>
</li>
<li class="li1">
<div class="de1">&lt;/div&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;div class=&quot;clearboth&quot;&gt;&lt;/div&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;/li&gt;</div>
</li>
</ol>
</div>
<p>This is the css I added:</p>
<div class="geshi no css">
<ol>
<li class="li1">
<div class="de1">ul<span class="re1">.books</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw1">list-style-type</span><span class="sy0">:</span> <span class="kw2">none</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">ul<span class="re1">.books</span> li <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw1">border-bottom</span><span class="sy0">:</span> <span class="re3">1px</span> <span class="kw2">solid</span> <span class="re0">#ccc</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw1">margin-bottom</span><span class="sy0">:</span> <span class="re3">15px</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw1">padding-bottom</span><span class="sy0">:</span> <span class="re3">15px</span><span class="sy0">;</span> </div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">ul<span class="re1">.books</span> li div<span class="re1">.medium</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;float<span class="re2">:left</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw1">margin-right</span><span class="sy0">:</span> <span class="re3">10px</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">ul<span class="re1">.books</span> li div<span class="re1">.medium</span> img <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;width<span class="re2">:<span class="re3">120px</span></span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">ul<span class="re1">.books</span> li div<span class="re1">.description</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw1">float</span><span class="sy0">:</span> <span class="kw1">left</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw1">width</span><span class="sy0">:</span> <span class="re3">450px</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">ul<span class="re1">.books</span> li div<span class="re1">.description</span> div <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw1">font-size</span><span class="sy0">:</span> <span class="re3">11px</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw1">padding-top</span><span class="sy0">:</span> <span class="re3">5px</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">ul<span class="re1">.books</span> li div<span class="re1">.clearboth</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw1">clear</span><span class="sy0">:</span> <span class="kw2">both</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>At last I added this custom html in the &#8220;my bookshelf&#8221; page:</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">&lt;ul class=&quot;books&quot;&gt;
</div>
</li>
<li class="li1">
<div class="de1"><i>[Open Library Server Error]</i> 
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><i>[Open Library Server Error]</i> 
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><i>[Open Library Server Error]</i> 
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&lt;/ul&gt;</div>
</li>
</ol>
</div>
<p>You can see the result here: <a href="http://www.klunde.net/my-bookshelf">My Bookshelf </a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klunde.net/2009/11/22/my-bookshelf-openbook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Cassandra and Thrift on OSX</title>
		<link>http://www.klunde.net/2009/11/20/installing-cassandra-and-thrift-on-osx/</link>
		<comments>http://www.klunde.net/2009/11/20/installing-cassandra-and-thrift-on-osx/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 21:39:14 +0000</pubDate>
		<dc:creator>Kristian Lunde</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[NoSQL]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[Cassandra]]></category>

		<guid isPermaLink="false">http://www.klunde.net/?p=410</guid>
		<description><![CDATA[
			
				
			
		
Cassandra is a NoSQL distributed database developed by Facebook, it is built to handle huge amounts of data and to perform CRUD operations quickly. The Cassandra site&#8217;s strap line says:
&#8220;The Apache Cassandra Project develops a highly scalable second-generation distributed database, bringing together  Dynamo&#8217;s fully distributed design and Bigtable&#8217;s ColumnFamily-based data model. 
Thrift is also [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.klunde.net%2F2009%2F11%2F20%2Finstalling-cassandra-and-thrift-on-osx%2F" onclick="urchinTracker('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.klunde.net_2F2009_2F11_2F20_2Finstalling-cassandra-and-thrift-on-osx_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.klunde.net%2F2009%2F11%2F20%2Finstalling-cassandra-and-thrift-on-osx%2F&amp;source=kristianlunde&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://incubator.apache.org/cassandra/" onclick="urchinTracker('/outgoing/incubator.apache.org/cassandra/?referer=');">Cassandra</a> is a <a href="http://en.wikipedia.org/wiki/NoSQL" onclick="urchinTracker('/outgoing/en.wikipedia.org/wiki/NoSQL?referer=');">NoSQL</a> distributed database developed by <a href="http://www.facebook.com" onclick="urchinTracker('/outgoing/www.facebook.com?referer=');">Facebook</a>, it is built to handle huge amounts of data and to perform <a href="http://en.wikipedia.org/wiki/Create,_read,_update_and_delete" onclick="urchinTracker('/outgoing/en.wikipedia.org/wiki/Create_read_update_and_delete?referer=');">CRUD</a> operations quickly. The Cassandra site&#8217;s strap line says:</p>
<p><i>&#8220;The Apache Cassandra Project develops a highly scalable second-generation distributed database, bringing together  Dynamo&#8217;s fully distributed design and Bigtable&#8217;s ColumnFamily-based data model. </i></p>
<p><a href="http://incubator.apache.org/thrift/" onclick="urchinTracker('/outgoing/incubator.apache.org/thrift/?referer=');">Thrift</a> is also developed by <a href="http://www.facebook.com" onclick="urchinTracker('/outgoing/www.facebook.com?referer=');">Facebook</a> and is a software framework for service development and is used as an interface to Cassandra. The Thrift page site says:</p>
<p><i>&#8220;Thrift is a software framework for scalable cross-language services development. It combines a software stack with a code generation engine to build services that work efficiently and seamlessly between C++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, Smalltalk, and OCaml.&#8221;</i></p>
<p>Both <a href="http://incubator.apache.org/cassandra/" onclick="urchinTracker('/outgoing/incubator.apache.org/cassandra/?referer=');">Cassandra</a> and <a href="http://incubator.apache.org/thrift/" onclick="urchinTracker('/outgoing/incubator.apache.org/thrift/?referer=');">Thrift</a> are apache incubator projects.</p>
<h2>Installing Cassandra</h2>
<h3>1. Download cassandra</h3>
<p>Download from: <a href="http://incubator.apache.org/cassandra/" onclick="urchinTracker('/outgoing/incubator.apache.org/cassandra/?referer=');">http://incubator.apache.org/cassandra/</a>.</p>
<h3>2. Create and set the correct paths in the storage-conf.xml</h3>
<p>You can find the storage-conf.xml file in your cassandra root directory /conf</p>
<p>My configuration file settings in storage-conf.xml:</p>
<div class="geshi no xml">
<ol>
<li class="li1">
<div class="de1">&nbsp; <span class="sc3"><span class="re1">&lt;CommitLogDirectory<span class="re2">&gt;</span></span></span>/Users/kristianlunde/tmp/cassandra-log/commitlog<span class="sc3"><span class="re1">&lt;/CommitLogDirectory<span class="re2">&gt;</span></span></span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="sc3"><span class="re1">&lt;DataFileDirectories<span class="re2">&gt;</span></span></span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;DataFileDirectory<span class="re2">&gt;</span></span></span>/Users/kristianlunde/workspaces/mysapient/cassandra/data<span class="sc3"><span class="re1">&lt;/DataFileDirectory<span class="re2">&gt;</span></span></span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="sc3"><span class="re1">&lt;/DataFileDirectories<span class="re2">&gt;</span></span></span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="sc3"><span class="re1">&lt;CalloutLocation<span class="re2">&gt;</span></span></span>/Users/kristianlunde/workspaces/mysapient/cassandra/callouts<span class="sc3"><span class="re1">&lt;/CalloutLocation<span class="re2">&gt;</span></span></span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="sc3"><span class="re1">&lt;BootstrapFileDirectory<span class="re2">&gt;</span></span></span>/Users/kristianlunde/workspaces/mysapient/cassandra/bootstrap<span class="sc3"><span class="re1">&lt;/BootstrapFileDirectory<span class="re2">&gt;</span></span></span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="sc3"><span class="re1">&lt;StagingFileDirectory<span class="re2">&gt;</span></span></span>/Users/kristianlunde/workspaces/mysapient/cassandra/staging<span class="sc3"><span class="re1">&lt;/StagingFileDirectory<span class="re2">&gt;</span></span></span></div>
</li>
</ol>
</div>
<p><strong>Notice:</strong> You have to create all these directories for cassandra to run properly.</p>
<h3>3. Set a log directory in the log4j.properties file</h3>
<p>This file is found in the same directory as the storage-conf.xml</p>
<h3>4. Check that you are running java 6 as default</h3>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1">&nbsp;java -version</div>
</li>
</ol>
</div>
<p>If you are running an earlier version of java you will have to change your version. Java 6 should already be installed on your mac if you keep your os in sync with the automatic updates from apple. You can change your java version by using the <a href="http://www.apple.com/macosx/what-is-macosx/apps-and-utilities.html#java" onclick="urchinTracker('/outgoing/www.apple.com/macosx/what-is-macosx/apps-and-utilities.html_java?referer=');">&#8220;Java Settings&#8221;</a> application located in your <em>/Application/Utilities</em> directory.</p>
<h3>5. Starting Cassandra</h3>
<p>You should be ready to go now, navigate to the root directory of your cassandra installation and start cassandra by typing:</p>
<div class="geshi no pre">
<ol>
<li class="li1">
<div class="de1">bin/cassandra -f</div>
</li>
</ol>
</div>
<p>If you dont see any error messages cassandra is probably running as it should, so it is time to test it out.</p>
<p>Cassandra comes with a CLI interface which allowes you to do simple queries to the database. Notice that the CLI interface is not not as powerful as the thrift interface. You can for instance not execute get queries in <a href="http://arin.me/code/wtf-is-a-supercolumn-cassandra-data-model" onclick="urchinTracker('/outgoing/arin.me/code/wtf-is-a-supercolumn-cassandra-data-model?referer=');">Super Columns</a>, those queries will create a java exception.</p>
<p>To test the CLI interface, run the following command from the cassandra root directory:</p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1">.<span class="sy0">/</span>bin<span class="sy0">/</span>cassandra-cli &#8211;host localhost &#8211;port <span class="nu0">9160</span></div>
</li>
</ol>
</div>
<p>Inserting values to the keyspace:</p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1">&nbsp;cassandra<span class="sy0">&gt;</span> <span class="kw1">set</span> Keyspace1.Standard1<span class="br0">&#91;</span><span class="st0">&#39;blog-post&#39;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&#39;name&#39;</span><span class="br0">&#93;</span> = <span class="st0">&#39;Installing Cassandra and Thrift OSX&#39;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;Value inserted.</div>
</li>
<li class="li1">
<div class="de1">&nbsp;cassandra<span class="sy0">&gt;</span> <span class="kw1">set</span> Keyspace1.Standard1<span class="br0">&#91;</span><span class="st0">&#39;blog-post&#39;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&#39;author&#39;</span><span class="br0">&#93;</span> = <span class="st0">&#39;Kristian Lunde&#39;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;Value inserted.</div>
</li>
</ol>
</div>
<p>	Retrieving data from the keyspace:</p>
<div class="geshi no bash">
<div class="head">cassandra> get Keyspace1.Standard1[&#39;blog-post&#39;]</div>
<ol>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="br0">&#40;</span><span class="re2">column=</span>name, <span class="re2">value=</span>Installing Cassandra and Thrift OSX; <span class="re2">timestamp=</span><span class="nu0">1258748376097</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="br0">&#40;</span><span class="re2">column=</span>author, <span class="re2">value=</span>Kristian Lunde; <span class="re2">timestamp=</span><span class="nu0">1258748405486</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;Returned <span class="nu0">2</span> rows.</div>
</li>
<li class="li1">
<div class="de1">&nbsp;cassandra<span class="sy0">&gt;</span></div>
</li>
</ol>
</div>
<h2>Installing Thrift</h2>
<p><strong>Update:</strong> I found this manual after I had installed thrift: <a href="http://wiki.apache.org/thrift/ThriftInstallationMacOSX" onclick="urchinTracker('/outgoing/wiki.apache.org/thrift/ThriftInstallationMacOSX?referer=');">http://wiki.apache.org/thrift/ThriftInstallationMacOSX</a>, using this install guide will probably fix the issues I had with compiling thrift.</p>
<h3>1. Download Thrift</h3>
<p>Download from <a href="http://incubator.apache.org/thrift/download/" onclick="urchinTracker('/outgoing/incubator.apache.org/thrift/download/?referer=');">http://incubator.apache.org/thrift/download/</a> and extract it.</p>
<h3>2. Check that you have installed the following:</h3>
<ul>
<li>g++ 3.3.5+</li>
<li>Runtime libraries for lex and yacc might be needed for the compiler.</li>
<li>boost 1.33.1+ (1.34.0 for building all tests) <a href="http://www.boost.org/" onclick="urchinTracker('/outgoing/www.boost.org/?referer=');">http://www.boost.org/</a>.</li>
</ul>
<p>I had to install boost manually:</p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">sudo</span> port <span class="kw2">install</span> boost</div>
</li>
</ol>
</div>
<p><strong>Notice:</strong> the boost installation might take a while, It took about 5 &#8211; 10 minutes on my Macbook PRO (2.53GHz).</p>
<p>You can see the full requirements for thrift at <a href="http://wiki.apache.org/thrift/ThriftRequirements" onclick="urchinTracker('/outgoing/wiki.apache.org/thrift/ThriftRequirements?referer=');">http://wiki.apache.org/thrift/ThriftRequirements</a>.</p>
<h3>3. Start the installation</h3>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1">&nbsp;kristian-lundes-macbook-pro:thrift kristianlunde$ .<span class="sy0">/</span>bootstrap.<span class="kw2">sh</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;configure.ac:<span class="nu0">26</span>: installing `.<span class="sy0">/</span>missing<span class="st0">&#39;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="st0"> configure.ac:26: installing `./install-sh&#39;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;compiler<span class="sy0">/</span><span class="kw2">cpp</span><span class="sy0">/</span>Makefile.am: installing `.<span class="sy0">/</span>depcomp<span class="st0">&#39;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="st0"> configure.ac: installing `./ylwrap&#39;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;kristian-lundes-macbook-pro:thrift</div>
</li>
</ol>
</div>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1">.<span class="sy0">/</span>configure</div>
</li>
</ol>
</div>
<p>This ended up in an error message for me:</p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1">&nbsp;.<span class="sy0">/</span>configure: line <span class="nu0">20722</span>: syntax error near unexpected token `MONO,<span class="st0">&#39;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="st0"> ./configure: line 20722: ` &nbsp;PKG_CHECK_MODULES(MONO, mono &gt;= 2.0.0, net_3_5=yes, net_3_5=no)&#39;</span></div>
</li>
</ol>
</div>
<p>To fix this I had to copy my pkg.m4 file from /opt/local/share/aclocal/pkg.m4 to my thrift/aclocal directory.</p>
<p>Navigate to your thrift root directory:</p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1">&nbsp;<span class="kw2">cp</span> <span class="sy0">/</span>opt<span class="sy0">/</span><span class="kw3">local</span><span class="sy0">/</span>share<span class="sy0">/</span><span class="kw2">aclocal</span><span class="sy0">/</span>pkg.<span class="kw2">m4</span> <span class="kw2">aclocal</span></div>
</li>
</ol>
</div>
<p>Thanks to <a href="http://aaronspotlatch.appspot.com/archive/Jul-2008" onclick="urchinTracker('/outgoing/aaronspotlatch.appspot.com/archive/Jul-2008?referer=');">http://aaronspotlatch.appspot.com/archive/Jul-2008</a> and<br />
<a href="http://qslack.com/post/thrift-macosx-104" onclick="urchinTracker('/outgoing/qslack.com/post/thrift-macosx-104?referer=');">http://qslack.com/post/thrift-macosx-104</a> for pointing me in the right direction.</p>
<p>You should now be ready to run make</p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">make</span></div>
</li>
</ol>
</div>
<p>and</p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">sudo</span> <span class="kw2">make</span> <span class="kw2">install</span></div>
</li>
</ol>
</div>
<p>You should now be able to run thrift on your mac.</p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1">thrift</div>
</li>
</ol>
</div>
<p>You should now be ready to build your amazing application with Cassandra if both your installation of Cassandra and Thrift were successful.</p>
<p>I will try to post another blog post shortly on using Cassandra, Thrift and PHP. Stay tuned. </p>
<h3>Resources</h3>
<ul>
<li><a href="http://incubator.apache.org/cassandra/" onclick="urchinTracker('/outgoing/incubator.apache.org/cassandra/?referer=');">The Cassandra Project</a></li>
<li><a href="http://wiki.apache.org/cassandra/FrontPage" onclick="urchinTracker('/outgoing/wiki.apache.org/cassandra/FrontPage?referer=');">The Cassandra Wiki</a></li>
<li><a href="http://wiki.apache.org/thrift/FrontPage" onclick="urchinTracker('/outgoing/wiki.apache.org/thrift/FrontPage?referer=');">The Thrift Wiki</a></li>
<li><a href="http://jetfar.com/installing-cassandra-and-thrift-on-snow-leopard-a-quick-start-guide/" onclick="urchinTracker('/outgoing/jetfar.com/installing-cassandra-and-thrift-on-snow-leopard-a-quick-start-guide/?referer=');">http://jetfar.com/installing-cassandra-and-thrift-on-snow-leopard-a-quick-start-guide/</a></li>
<li><a href="http://posulliv.com/?p=149" onclick="urchinTracker('/outgoing/posulliv.com/?p=149&amp;referer=');">Setting up a Cassandra cluster</a></li>
<li><a href="http://www.onemanclapping.org/2009/11/building-cassandra-thrift-bindings-on.html" onclick="urchinTracker('/outgoing/www.onemanclapping.org/2009/11/building-cassandra-thrift-bindings-on.html?referer=');">http://www.onemanclapping.org/2009/11/building-cassandra-thrift-bindings-on.html</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.klunde.net/2009/11/20/installing-cassandra-and-thrift-on-osx/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Amazon Frenzy</title>
		<link>http://www.klunde.net/2009/09/24/amazon-frenzy/</link>
		<comments>http://www.klunde.net/2009/09/24/amazon-frenzy/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 20:29:36 +0000</pubDate>
		<dc:creator>Kristian Lunde</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Real Life]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.klunde.net/?p=383</guid>
		<description><![CDATA[
			
				
			
		
The other day I had a frenzy at amazon and ordered quite a few books I have had on my shopping list. The books are of course all computer and web related. The books I ordered was:


Building Scalable Web Sites by Cal Henderson


High Performance MySQL


JavaScript: The Good Parts by Douglas Crockford
Don&#8217;t Make Me Think!: A [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.klunde.net%2F2009%2F09%2F24%2Famazon-frenzy%2F" onclick="urchinTracker('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.klunde.net_2F2009_2F09_2F24_2Famazon-frenzy_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.klunde.net%2F2009%2F09%2F24%2Famazon-frenzy%2F&amp;source=kristianlunde&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>The other day I had a frenzy at amazon and ordered quite a few books I have had on my shopping list. The books are of course all computer and web related. The books I ordered was:</p>
<ul>
<li>
<a href="http://www.amazon.co.uk/exec/obidos/ASIN/0596102356/ref=ox_ya_oh_product" onclick="urchinTracker('/outgoing/www.amazon.co.uk/exec/obidos/ASIN/0596102356/ref=ox_ya_oh_product?referer=');">Building Scalable Web Sites</a> by <a href="http://www.iamcal.com/" onclick="urchinTracker('/outgoing/www.iamcal.com/?referer=');">Cal Henderson</a>
</li>
<li>
<a href="http://www.amazon.co.uk/exec/obidos/ASIN/0596101716/ref=ox_ya_oh_product" onclick="urchinTracker('/outgoing/www.amazon.co.uk/exec/obidos/ASIN/0596101716/ref=ox_ya_oh_product?referer=');">High Performance MySQL</a>
</li>
<li>
<a href="http://www.amazon.co.uk/exec/obidos/ASIN/0596517742/ref=ox_ya_oh_product" onclick="urchinTracker('/outgoing/www.amazon.co.uk/exec/obidos/ASIN/0596517742/ref=ox_ya_oh_product?referer=');">JavaScript: The Good Parts</a> by <a href="http://www.crockford.com/" onclick="urchinTracker('/outgoing/www.crockford.com/?referer=');">Douglas Crockford</a></li>
<li><a href="http://www.amazon.co.uk/exec/obidos/ASIN/0321344758/ref=ox_ya_oh_product" onclick="urchinTracker('/outgoing/www.amazon.co.uk/exec/obidos/ASIN/0321344758/ref=ox_ya_oh_product?referer=');">Don&#8217;t Make Me Think!: A Common Sense Approach to Web Usability</a> by <a href="http://www.sensible.com/about.html" onclick="urchinTracker('/outgoing/www.sensible.com/about.html?referer=');">Steve Krug</a>
</li>
<li><a href="http://www.amazon.co.uk/exec/obidos/ASIN/0321503619/ref=ox_ya_oh_product" onclick="urchinTracker('/outgoing/www.amazon.co.uk/exec/obidos/ASIN/0321503619/ref=ox_ya_oh_product?referer=');">Cocoa Programming for Mac OS X</a> by <a href="http://en.wikipedia.org/wiki/Aaron_Hillegass" onclick="urchinTracker('/outgoing/en.wikipedia.org/wiki/Aaron_Hillegass?referer=');">Aaron Hillegass</a>
</li>
</ul>
<p>
I am halfway through the building scalable web sites and it is really good, even if you are a seasoned web developer I think you can learn quite a bit from it. I have also started to read the MySQL book and can&#8217;t wait to learn more about database replication, that is something I really want to find out more about. The &#8220;Don&#8217;t make me think&#8221; book will hopefully assist me on building more user friendly web sites, and hopefully the javascript book(still in the mail) will help me to brush up my js skills.
</p>
<p>
The Cocoa book was on sale, and you never know when you have to do a bit of programming for a mac <img src='http://www.klunde.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.klunde.net/2009/09/24/amazon-frenzy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Merging code bases</title>
		<link>http://www.klunde.net/2009/09/16/merging-code-bases/</link>
		<comments>http://www.klunde.net/2009/09/16/merging-code-bases/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 07:22:58 +0000</pubDate>
		<dc:creator>Kristian Lunde</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.klunde.net/?p=367</guid>
		<description><![CDATA[
			
				
			
		
Yesterday I had the &#8220;pleasure&#8221; of merging two code bases of the same application. The code bases had been developed in two different parts of the world, but shared a common foundation. I got access to a development version of the code base a few weeks ago, and the final delivery of the application was [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.klunde.net%2F2009%2F09%2F16%2Fmerging-code-bases%2F" onclick="urchinTracker('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.klunde.net_2F2009_2F09_2F16_2Fmerging-code-bases_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.klunde.net%2F2009%2F09%2F16%2Fmerging-code-bases%2F&amp;source=kristianlunde&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Yesterday I had the &#8220;pleasure&#8221; of merging two code bases of the same application. The code bases had been developed in two different parts of the world, but shared a common foundation. I got access to a development version of the code base a few weeks ago, and the final delivery of the application was done late last week. No version control system was shared between myself and the contractor which made the merge a bit more cumbersome. Unfortunately I could not wait for the contractor to finish the development before I started to add features and bug fixes to the application; this eventually resulted in two separate versions of the code base. </p>
<p>I was aware that this merge would going to happen from the very start so some precautions were taken before I started my own branch of the source code.</p>
<p>1. I separated all new features out in separate directories and added symbolic links to these in the existing code base. This worked very well and we had no problem at all adding the new features to the final delivery. </p>
<p>2. I tried to be very careful and keep track of all the bug fixes and changes done to the original code.</p>
<h2>Trouble</h2>
<p>I realized that we would have trouble with the final merge not long after I received the first development version, it was cluttered with bugs and issues which made it impossible to even run it in my development version. To get the application up and running I had to make a bunch of changes to the code. </p>
<p>In addition to the initial bugs I soon realized that the front end of the application (read: html and css) was a complete mess. The site was not browser compliant, nothing validated and it was impossible to go through. These issues would not be resolved by the contractor and since the project was on the clock it needed resolving as quickly as possible. This ended up in a complete rebuild of the front end which modified 300+ files. </p>
<h2>1st Attempt &#8211; Failure</h2>
<p>1. Created a git branch of my development code<br />
2. Added the final code from the contractor to the branch</p>
<p>This ended up in a complete mess, nothing working, a complete mess. </p>
<h2>2nd Attempt &#8211; Success</h2>
<p>When the final delivery from the contractor came through the two code bases was in completely different states, most of the bug fixes I had was still needed. </p>
<p>1. Created a git branch of my code base<br />
3. Found the differences from the initial development version we got and the final delivery</p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">diff</span> -qr dev final <span class="sy0">|</span> <span class="kw2">grep</span> -v -e <span class="st0">&#39;DS_Store&#39;</span> -e <span class="st0">&#39;Thumbs&#39;</span> <span class="sy0">|</span> <span class="kw2">sort</span> <span class="sy0">&gt;</span> changes.txt</div>
</li>
</ol>
</div>
<p>Where <i>dev</i> is the directory of the untouched development version we got access to, and <i>final</i> is the directory of the final delivery. This resulted in a complete list (<i>changes.txt</i>) of files which differed between the two original versions. It also identified files that was obsolete in and new files that was added.  An example of the content in the <i>changes.txt</i> can be seen below.</p>
<div class="geshi no text">
<ol>
<li class="li1">
<div class="de1">Files dev/view/file-1.php and final/view/file-1.php differ</div>
</li>
<li class="li1">
<div class="de1">Files dev/view/file-2.php and final/view/file-2.php differ</div>
</li>
<li class="li1">
<div class="de1">Only in dev/css: css-1.css</div>
</li>
<li class="li1">
<div class="de1">Only in dev/css: css-2.css</div>
</li>
<li class="li1">
<div class="de1">Only in dev/css: css-3.css</div>
</li>
<li class="li1">
<div class="de1">Only in final/css: css.css</div>
</li>
<li class="li1">
<div class="de1">Only in final/: file-a.php</div>
</li>
</ol>
</div>
<p>4. Once I had this overview I added all the new files from the final version into my git branch.<br />
5. Updated all the files I knew had not been changed. I had a list of all the core files which had been changed.<br />
6. I manually had to go through all the core files that had been changed and compare them with the files from the final delivery.<br />
7. Remove all old files which only were present in the development delivery.<br />
8. Manual comparison of all the front end files, updating and merging these files by hand. Diff can not be used here since the entire front end has changed, and it would only result in a complete difference, still there might have been changes that I needed to incorporate with the new front end.</p>
<p>I still have approx 150 front end files to compare, it is time consuming and frustrating labor, but it seems to be the only way to do it. I keep testing the application while doing the update and so far all of the changes and updates has been successful.</p>
<p>The positive flip of this is that I get a good overview of the code and understanding of the application when I have to go through much of the code from the final delivery.</p>
<p>I might not have chosen the best solution and I would love to hear your approach if you have done similar things or have an opinion about it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klunde.net/2009/09/16/merging-code-bases/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Retweet vs TweetMeme Wordpress plugins</title>
		<link>http://www.klunde.net/2009/09/10/retweet-vs-tweetmeme-wordpress-plugins/</link>
		<comments>http://www.klunde.net/2009/09/10/retweet-vs-tweetmeme-wordpress-plugins/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 07:15:00 +0000</pubDate>
		<dc:creator>Kristian Lunde</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.klunde.net/?p=361</guid>
		<description><![CDATA[
			
				
			
		
I decided earlier this week that I should add a Retweet plugin to my blog; so I googled &#8220;Retweet wordpress&#8221;, which gave me two good results the Retweet plugin and the TweetMeme plugin. I thought I would install and try both of them before I decided which one I should go for. 
Retweet
I installed the [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.klunde.net%2F2009%2F09%2F10%2Fretweet-vs-tweetmeme-wordpress-plugins%2F" onclick="urchinTracker('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.klunde.net_2F2009_2F09_2F10_2Fretweet-vs-tweetmeme-wordpress-plugins_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.klunde.net%2F2009%2F09%2F10%2Fretweet-vs-tweetmeme-wordpress-plugins%2F&amp;source=kristianlunde&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>I decided earlier this week that I should add a Retweet plugin to my blog; so I googled &#8220;Retweet wordpress&#8221;, which gave me two good results the <a href="http://wordpress.org/extend/plugins/twitter-retweet/" onclick="urchinTracker('/outgoing/wordpress.org/extend/plugins/twitter-retweet/?referer=');">Retweet</a> plugin and the <a href="http://wordpress.org/extend/plugins/tweetmeme/" onclick="urchinTracker('/outgoing/wordpress.org/extend/plugins/tweetmeme/?referer=');">TweetMeme</a> plugin. I thought I would install and try both of them before I decided which one I should go for. </p>
<h4>Retweet</h4>
<p>I installed the Retweet plugin first, this had to be installed, I had to add a custom field to each post and I had to add some PHP code to one of the template files. Once this was done I had to style the link myself.  </p>
<h4>TweetMeme</h4>
<p>The TweetMeme plugin however had to be installed and then it needed to be configured from a separate settings page. Once that was done it was added to all of my posts and it even showed how many retweets each post had. </p>
<h4>Conclusion</h4>
<p>When I need a plugin for wordpress I really do not want to do more than install it and do some configuration on a settings page. It is way to much hassle to modify template files and adding custom fields to the posts. </p>
<p>Guess which plugin I chose <img src='http://www.klunde.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.klunde.net/2009/09/10/retweet-vs-tweetmeme-wordpress-plugins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript snippets</title>
		<link>http://www.klunde.net/2009/06/18/javascript-snippets/</link>
		<comments>http://www.klunde.net/2009/06/18/javascript-snippets/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 22:55:29 +0000</pubDate>
		<dc:creator>Kristian Lunde</dc:creator>
				<category><![CDATA[web]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://www.klunde.net/?p=302</guid>
		<description><![CDATA[
			
				
			
		
Lately I have been doing some javascript development and I have written a couple of functions which I find really useful. I almost find the code snippets to be used on all sites I work on so I thought I would share them with you. Both the snippets are written using the jQuery library.
Opening urls [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.klunde.net%2F2009%2F06%2F18%2Fjavascript-snippets%2F" onclick="urchinTracker('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.klunde.net_2F2009_2F06_2F18_2Fjavascript-snippets_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.klunde.net%2F2009%2F06%2F18%2Fjavascript-snippets%2F&amp;source=kristianlunde&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Lately I have been doing some javascript development and I have written a couple of functions which I find really useful. I almost find the code snippets to be used on all sites I work on so I thought I would share them with you. Both the snippets are written using the <a href="http://www.jquery.com" rel="external" title="jQuery" onclick="urchinTracker('/outgoing/www.jquery.com?referer=');">jQuery</a> library.</p>
<h3>Opening urls in a separate window/tab in a xhtml strict environment</h3>
<p>The <i>target</i> attribute is not a valid attribute in xhtml strict and your site will fail to validate if you use it, so to get around this you can use replace your <i>target</i> attribute with the <i>rel</i> attribute. Adding the <i>rel=&#8221;external&#8221;</i> attribute on your anchors that points to an external source and adding some javascript solves the problem.</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">&lt;a href=&quot;http://www.klunde.net&quot; rel=&quot;external&quot; title=&quot;Klunde.net&quot;&gt;Kristian Lunde&lt;/a&gt;</div>
</li>
</ol>
</div>
<div class="geshi no javascript">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">function</span> externalLinks<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; $<span class="br0">&#40;</span><span class="st0">&quot;a[rel=&#39;external&#39;]&quot;</span><span class="br0">&#41;</span>.<span class="me1">each</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; $<span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span>.<span class="me1">attr</span><span class="br0">&#40;</span><span class="st0">&#39;target&#39;</span>, <span class="st0">&#39;_blank&#39;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span>; </div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span>;</div>
</li>
</ol>
</div>
<p>The code here is pretty self explaining, but to describe it briefly, the javascript function must be invoked once the DOM is loaded (see code further down on the page). The function loops through all anchors that have the <i>rel=&#8221;external&#8221;</i> attribute and add the attribute <i>target=&#8221;_blank&#8221;</i>. I guess this is a bit of a hack, but it works and it keeps the clients happy <img src='http://www.klunde.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h3>Creating spam proof mailto: anchors</h3>
<p>It is a well known fact that if you add your email address on a site in a plain mailto anchor you will be flooded by spam after a while. You can easily avoid this by adding a little bit of javascript on your site. </p>
<p>It works simply by printing out the email address as plain text replacing the @ with a &#8221; AT &#8221; and add the email addresses in a <i>div</i> or which ever element you prefer and add a set class to that tag. Then you run a small snippet of javascript that find all the elements with that class, I have chosen the class name &#8220;email&#8221;. The script replaces the content in all the elements with the email class with the proper html anchor. This can not be picked up by web crawlers and it displays the links properly for the user. All browsers without javascript support / enabled will of course only see the post AT somesite.com.</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">&lt;div class=&quot;email&quot;&gt;post AT &nbsp;somesite.com&lt;/div&gt;</div>
</li>
</ol>
</div>
<div class="geshi no javascript">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">function</span> createMailTo<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> c_email_field = $<span class="br0">&#40;</span><span class="st0">&#39;.email&#39;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw1">if</span><span class="br0">&#40;</span>$<span class="br0">&#40;</span>c_email_field<span class="br0">&#41;</span>.<span class="me1">length</span> <span class="sy0">&gt;</span> <span class="nu0">0</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; $<span class="br0">&#40;</span>c_email_field<span class="br0">&#41;</span>.<span class="me1">each</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw2">var</span> email = $<span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span>.<span class="me1">html</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">replace</span><span class="br0">&#40;</span><span class="st0">&#39; AT &#39;</span>, <span class="st0">&#39;@&#39;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;$<span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span>.<span class="me1">html</span><span class="br0">&#40;</span><span class="st0">&#39;&lt;a href=&quot;mailto:&#39;</span> + email + <span class="st0">&#39;&quot; rel=&quot;nofollow&quot; title=&quot;&#39;</span> + email + <span class="st0">&#39;&quot;&gt;&#39;</span> + email + <span class="st0">&#39;&lt;/a&gt;&#39;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#125;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span>;</div>
</li>
</ol>
</div>
<p>Running this script would transform the code into:</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">&lt;a href=&quot;mailto:post@somesite.com&quot; rel=&quot;nofollow&quot; title=&quot;post@somesite.com&quot;&gt;post@somesite.com&lt;/a&gt;</div>
</li>
</ol>
</div>
<h3>Putting it all together</h3>
<p>I have but together a simple example to illustrate the functions in action with all code and functionality. You should be able to copy this code save it as a .html file and run it in your browser.</p>
<div class="geshi no javascript">
<ol>
<li class="li1">
<div class="de1"><span class="sy0">&lt;!</span>DOCTYPE html <span class="kw2">PUBLIC</span> <span class="st0">&quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;</span> <span class="st0">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;</span><span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">&lt;</span>html<span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">&lt;</span>head<span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="sy0">&lt;</span>title<span class="sy0">&gt;</span>Javascript snippets<span class="sy0">&lt;/</span>title<span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">&lt;/</span>head<span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">&lt;</span>body<span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">&lt;</span>a href=<span class="st0">&quot;http://www.klunde.net&quot;</span> rel=<span class="st0">&quot;external&quot;</span> title=<span class="st0">&quot;Klunde.net&quot;</span><span class="sy0">&gt;</span>Kristian Lunde<span class="sy0">&lt;/</span>a<span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">&lt;</span>div <span class="kw2">class</span>=<span class="st0">&quot;email&quot;</span><span class="sy0">&gt;</span>post AT somesite.<span class="me1">com</span><span class="sy0">&lt;/</span>div<span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">&lt;</span>script type=<span class="st0">&quot;text/javascript&quot;</span> src=<span class="st0">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js&quot;</span><span class="sy0">&gt;&lt;/</span>script<span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">&lt;</span>script type=<span class="st0">&quot;text/javascript&quot;</span><span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> externalLinks<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; $<span class="br0">&#40;</span><span class="st0">&quot;a[rel=&#39;external&#39;]&quot;</span><span class="br0">&#41;</span>.<span class="me1">each</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; $<span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span>.<span class="me1">attr</span><span class="br0">&#40;</span><span class="st0">&#39;target&#39;</span>, <span class="st0">&#39;_blank&#39;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span>; </div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> createMailTo<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> c_email_field = $<span class="br0">&#40;</span><span class="st0">&#39;.email&#39;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw1">if</span><span class="br0">&#40;</span>$<span class="br0">&#40;</span>c_email_field<span class="br0">&#41;</span>.<span class="me1">length</span> <span class="sy0">&gt;</span> <span class="nu0">0</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; $<span class="br0">&#40;</span>c_email_field<span class="br0">&#41;</span>.<span class="me1">each</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw2">var</span> email = $<span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span>.<span class="me1">html</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">replace</span><span class="br0">&#40;</span><span class="st0">&#39; AT &#39;</span>, <span class="st0">&#39;@&#39;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;$<span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span>.<span class="me1">html</span><span class="br0">&#40;</span><span class="st0">&#39;&lt;a href=&quot;mailto:&#39;</span> + email + <span class="st0">&#39;&quot; rel=&quot;nofollow&quot; title=&quot;&#39;</span> + email + <span class="st0">&#39;&quot;&gt;&#39;</span> + email + <span class="st0">&#39;&lt;/a&gt;&#39;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#125;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">$<span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; externalLinks<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; createMailTo<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">&lt;/</span>script<span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">&lt;/</span>body<span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">&lt;/</span>html<span class="sy0">&gt;</span></div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.klunde.net/2009/06/18/javascript-snippets/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>On the move</title>
		<link>http://www.klunde.net/2009/06/03/on-the-move/</link>
		<comments>http://www.klunde.net/2009/06/03/on-the-move/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 20:00:07 +0000</pubDate>
		<dc:creator>Kristian Lunde</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[hosting]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://www.klunde.net/?p=297</guid>
		<description><![CDATA[
			
				
			
		
I am currently switching both domain host and web host, and in that case this site might be down for a little while. I am about to replicate the site to my new web host so hopefully it will be a minimum of down time.
I have chosen to leave servetheworld.net which has been my web [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.klunde.net%2F2009%2F06%2F03%2Fon-the-move%2F" onclick="urchinTracker('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.klunde.net_2F2009_2F06_2F03_2Fon-the-move_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.klunde.net%2F2009%2F06%2F03%2Fon-the-move%2F&amp;source=kristianlunde&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>I am currently switching both domain host and web host, and in that case this site might be down for a little while. I am about to replicate the site to my new web host so hopefully it will be a minimum of down time.</p>
<p>I have chosen to leave <a href="http://www.servetheworld.net" onclick="urchinTracker('/outgoing/www.servetheworld.net?referer=');">servetheworld.net</a> which has been my web host since 2003, they have done a great job, but the time has now come to move to a web host which can provide me with some more advanced features.</p>
<p>I have chosen<a href="http://www.webfaction.com/?affiliate=klunde" onclick="urchinTracker('/outgoing/www.webfaction.com/?affiliate=klunde&amp;referer=');"> webfaction.com</a> as my new web host. I chose them because they offer a multitude of different applications, for instance svn, python, ruby on rails and of course PHP. They also offer ssh access.  </p>
<p>I chose <a href="http://www.123-reg.co.uk" onclick="urchinTracker('/outgoing/www.123-reg.co.uk?referer=');">123-reg.com</a> to host my domain names, that was done out of convenience, they are well known, large and hopefully know what they are doing  <img src='http://www.klunde.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.klunde.net/2009/06/03/on-the-move/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting the default option of a ubercart product attribute</title>
		<link>http://www.klunde.net/2009/02/20/getting-the-default-option-of-a-ubercart-product-attribute/</link>
		<comments>http://www.klunde.net/2009/02/20/getting-the-default-option-of-a-ubercart-product-attribute/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 22:02:57 +0000</pubDate>
		<dc:creator>Kristian Lunde</dc:creator>
				<category><![CDATA[Drupal]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[Ubercart]]></category>

		<guid isPermaLink="false">http://www.klunde.net/?p=262</guid>
		<description><![CDATA[
			
				
			
		
In Orange Bus we are currently busy building a new web shop for a clothing company. We are building this web shop on Drupal 6 and Ubercart 2. While I was doing some tuning of the product page (built as a node template) on this site I suddenly realized that even though you can get [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.klunde.net%2F2009%2F02%2F20%2Fgetting-the-default-option-of-a-ubercart-product-attribute%2F" onclick="urchinTracker('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.klunde.net_2F2009_2F02_2F20_2Fgetting-the-default-option-of-a-ubercart-product-attribute_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.klunde.net%2F2009%2F02%2F20%2Fgetting-the-default-option-of-a-ubercart-product-attribute%2F&amp;source=kristianlunde&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>In Orange Bus we are currently busy building a new web shop for a clothing company. We are building this web shop on Drupal 6 and Ubercart 2. While I was doing some tuning of the product page (built as a node template) on this site I suddenly realized that even though you can get most of the information needed in from the <i>$node</i> object, you are unable to get the default options of each attribute.</p>
<p>In my case this attribute was the sizes of the products (small, medium, large and so on), the node object contained all the attributes but not the default options. It is not at all complicated to get this information but you do need to add some custom code to get a hold of the default options. I would argue that this should be included in the default node object, which really should not be a big deal adding. I guess I should add a patch for this, instead of going around the problem which is what I do and describe here. </p>
<p>To get a hold of this I had to call a ubercart specific function called <i>uc_product_get_attributes</i> function. This function takes a node id as parameter and return all an array of all the attributes related to the node. The array contain a set of attributes objects and these object contain all the information available on each attribute.</p>
<p>My solution was to call the <i>uc_product_get_attributes</i> function and get the <i>default_option</i> variable from the attribute object, see code example below.</p>
<div class="geshi no php">
<ol>
<li class="li1">
<div class="de1"><span class="co1">//get all attributes related to the node</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$attributes</span> <span class="sy0">=</span> uc_product_get_attributes<span class="br0">&#40;</span><span class="re1">$node</span><span class="sy0">-&gt;</span><span class="me1">nid</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">//get the id of default size of the product</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$default_size</span> <span class="sy0">=</span> <span class="re1">$attributes</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span><span class="sy0">-&gt;</span><span class="me1">default_option</span><span class="sy0">;</span></div>
</li>
</ol>
</div>
<p>It is simple, but it took me about an 30 minutes to determine the problem and adding a solution. Hopefully this will save someone the job of solving the same problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klunde.net/2009/02/20/getting-the-default-option-of-a-ubercart-product-attribute/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Flowplayer, https and the streamnotfound &#8220;problem&#8221;</title>
		<link>http://www.klunde.net/2009/01/16/flowplayer-https-and-the-streamnotfound-problem/</link>
		<comments>http://www.klunde.net/2009/01/16/flowplayer-https-and-the-streamnotfound-problem/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 14:25:40 +0000</pubDate>
		<dc:creator>Kristian Lunde</dc:creator>
				<category><![CDATA[web]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[Amazon S3]]></category>
		<category><![CDATA[Flowplayer]]></category>

		<guid isPermaLink="false">http://www.klunde.net/?p=240</guid>
		<description><![CDATA[
			
				
			
		
Lately I have been working on a project which used Amazon S3 to provide videos to Flowplayer on a website. This was working superbly until we added a link to a video using the https protocol. This broke the Flowplayer on Internet explorer 6 and 7 and Safari, and we got a:



streamNotFound, clip: &#39;https://someurl&#39;



Solution: Amazon [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.klunde.net%2F2009%2F01%2F16%2Fflowplayer-https-and-the-streamnotfound-problem%2F" onclick="urchinTracker('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.klunde.net_2F2009_2F01_2F16_2Fflowplayer-https-and-the-streamnotfound-problem_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.klunde.net%2F2009%2F01%2F16%2Fflowplayer-https-and-the-streamnotfound-problem%2F&amp;source=kristianlunde&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Lately I have been working on a project which used <a href="http://aws.amazon.com/s3/" onclick="urchinTracker('/outgoing/aws.amazon.com/s3/?referer=');">Amazon S3</a> to provide videos to <a href="http://flowplayer.org/" onclick="urchinTracker('/outgoing/flowplayer.org/?referer=');">Flowplayer</a> on a website. This was working superbly until we added a link to a video using the https protocol. This broke the <a href="http://flowplayer.org/" onclick="urchinTracker('/outgoing/flowplayer.org/?referer=');">Flowplayer</a> on Internet explorer 6 and 7 and Safari, and we got a:</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">streamNotFound, clip: &#39;https://someurl&#39;</div>
</li>
</ol>
</div>
<p>Solution: <a href="http://aws.amazon.com/s3/" onclick="urchinTracker('/outgoing/aws.amazon.com/s3/?referer=');">Amazon S3</a> supports both http and https, so replacing https with http solved the problem. This problem probably occurs because the web browser is unable to cache the data from the https url and therefore the <a href="http://flowplayer.org/" onclick="urchinTracker('/outgoing/flowplayer.org/?referer=');">Flowplayer</a> is unable to play the video.</p>
<p>Interestingly enough Firefox had no problem at all running <a href="http://flowplayer.org/" onclick="urchinTracker('/outgoing/flowplayer.org/?referer=');">Flowplayer</a> and https urls.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klunde.net/2009/01/16/flowplayer-https-and-the-streamnotfound-problem/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
