<?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>frogcake.net &#187; Geek</title>
	<atom:link href="http://www.frogcake.net/blog/category/geek/feed" rel="self" type="application/rss+xml" />
	<link>http://www.frogcake.net/blog</link>
	<description></description>
	<lastBuildDate>Sun, 22 Jan 2012 21:22:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>TextMate for IntelliJ users</title>
		<link>http://www.frogcake.net/blog/2011/11/30/textmate-for-intellij-users</link>
		<comments>http://www.frogcake.net/blog/2011/11/30/textmate-for-intellij-users#comments</comments>
		<pubDate>Wed, 30 Nov 2011 13:55:47 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Geek]]></category>

		<guid isPermaLink="false">http://www.frogcake.net/blog/?p=1083</guid>
		<description><![CDATA[I use IntelliJ IDEA. I also use TextMate. The fact that I spend most of my day in IntelliJ means I&#8217;m used to IntelliJ&#8217;s keyboard mapping which happens to be slightly different from TextMate&#8217;s. The biggest difference I found was with the Home and End keys and the Delete Line mapping. So here&#8217;s how to [...]]]></description>
			<content:encoded><![CDATA[<p>I use <a href="http://www.jetbrains.com/idea/" >IntelliJ IDEA</a>. I also use <a href="http://macromates.com/" >TextMate</a>. The fact that I spend most of my day in IntelliJ means I&#8217;m used to IntelliJ&#8217;s keyboard mapping which happens to be slightly different from TextMate&#8217;s.</p>
<p>The biggest difference I found was with the Home and End keys and the Delete Line mapping. So here&#8217;s how to make TextMate work more like IntelliJ.</p>
<h4>Change Home and End keys</h4>
<p>From <a href="http://blog.macromates.com/2005/key-bindings-for-switchers/" >this old blog post</a>:<br/>
Create the custom KeyBindings folder (if it doesn&#8217;t already exist):</p>

<div class="wp_syntax" ><div class="code" ><pre class="bash"  style="font-family:monospace;" ><span style="color: #c20cb9; font-weight: bold;" >mkdir</span> ~<span style="color: #000000; font-weight: bold;" >/</span>Library<span style="color: #000000; font-weight: bold;" >/</span>KeyBindings</pre></div></div>

<p>Create a key bindings file called DefaultKeyBinding.dict in this directory with the following content:</p>

<div class="wp_syntax" ><div class="code" ><pre class="objc"  style="font-family:monospace;" ><span style="color: #002200;" >&#123;</span>
    <span style="color: #11740a; font-style: italic;" >/* home */</span>
    <span style="color: #bf1d1a;" >&quot;<span style="color: #2400d9;" >\U</span>F729&quot;</span>  <span style="color: #002200;" >=</span> <span style="color: #bf1d1a;" >&quot;moveToBeginningOfLine:&quot;</span>;
    <span style="color: #bf1d1a;" >&quot;$<span style="color: #2400d9;" >\U</span>F729&quot;</span> <span style="color: #002200;" >=</span> <span style="color: #bf1d1a;" >&quot;moveToBeginningOfLineAndModifySelection:&quot;</span>;
&nbsp;
    <span style="color: #11740a; font-style: italic;" >/* end */</span>
    <span style="color: #bf1d1a;" >&quot;<span style="color: #2400d9;" >\U</span>F72B&quot;</span>  <span style="color: #002200;" >=</span> <span style="color: #bf1d1a;" >&quot;moveToEndOfLine:&quot;</span>;
    <span style="color: #bf1d1a;" >&quot;$<span style="color: #2400d9;" >\U</span>F72B&quot;</span> <span style="color: #002200;" >=</span> <span style="color: #bf1d1a;" >&quot;moveToEndOfLineAndModifySelection:&quot;</span>;
&nbsp;
    <span style="color: #11740a; font-style: italic;" >/* page up/down */</span>
    <span style="color: #bf1d1a;" >&quot;<span style="color: #2400d9;" >\U</span>F72C&quot;</span>  <span style="color: #002200;" >=</span> <span style="color: #bf1d1a;" >&quot;pageUp:&quot;</span>;
    <span style="color: #bf1d1a;" >&quot;<span style="color: #2400d9;" >\U</span>F72D&quot;</span>  <span style="color: #002200;" >=</span> <span style="color: #bf1d1a;" >&quot;pageDown:&quot;</span>;
<span style="color: #002200;" >&#125;</span></pre></div></div>

<h4>Change Delete Line mapping</h4>
<p>Go to Bundles &gt; Bundle Editor &gt; Show Bundle Editor.<br/>
In text bundle, change Delete Line from CTRL+K to CMD+DELETE.<br/>
In the text bundle, Delete to Beginning of Line macro, click the X to remove the same binding.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.frogcake.net/blog/2011/11/30/textmate-for-intellij-users/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Devoxx &#8211; Project Coin, Defective Java and the Social Network</title>
		<link>http://www.frogcake.net/blog/2010/11/18/devoxx-project-coin-defective-java-and-the-social-network</link>
		<comments>http://www.frogcake.net/blog/2010/11/18/devoxx-project-coin-defective-java-and-the-social-network#comments</comments>
		<pubDate>Thu, 18 Nov 2010 23:17:39 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Geek]]></category>
		<category><![CDATA[devoxx]]></category>

		<guid isPermaLink="false">http://www.frogcake.net/blog/?p=1022</guid>
		<description><![CDATA[Joe Darcy and Maurizio Cimadamore gave a preview of the changes coming up in Project Coin. These are small changes to the Java language that will be added to Java 7. They all look pretty useful and include: Strings in switch Collection literals &#60;&#62; (generic type inference) Multicatch catch &#40;ClassNotFoundException &#124; NoSuchMethodException e&#41; &#123; // [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.frogcake.net/blog/wp-content/uploads/2010/11/LogoDevoxx150dpi.jpg" ><img hspace="1em"  vspace="1em"  align="right"  class="alignright size-medium wp-image-994"  title="LogoDevoxx150dpi"  src="http://www.frogcake.net/blog/wp-content/uploads/2010/11/LogoDevoxx150dpi-300x112.jpg"  alt=""  width="300"  height="112"   style="float:right; margin:0 0 1em 1em; border:black 1px solid;"/></a>Joe Darcy and Maurizio Cimadamore gave a preview of the changes coming up in <a href="http://openjdk.java.net/projects/coin/" >Project Coin</a>. These are small changes to the Java language that will be added to Java 7. They all look pretty useful and include:</p>
<ul>
<li>Strings in switch</li>
<li>Collection literals</li>
<li>&lt;&gt; (generic type inference)</li>
<li>Multicatch</li>
</ul>

<div class="wp_syntax" ><div class="code" ><pre class="java"  style="font-family:monospace;" ><span style="color: #000000; font-weight: bold;" >catch</span> <span style="color: #009900;" >&#40;</span><span style="color: #003399;" >ClassNotFoundException</span> <span style="color: #339933;" >|</span> <span style="color: #003399;" >NoSuchMethodException</span> e<span style="color: #009900;" >&#41;</span> <span style="color: #009900;" >&#123;</span>
    <span style="color: #666666; font-style: italic;" >// Do something</span>
    <span style="color: #000000; font-weight: bold;" >throw</span><span style="color: #009900;" >&#40;</span>e<span style="color: #009900;" >&#41;</span><span style="color: #339933;" >;</span>
<span style="color: #009900;" >&#125;</span></pre></div></div>

<p>Bill Pugh&#8217;s session was as popular as expected for his talk about defective code and how static analysis with <a href="http://findbugs.sourceforge.net/" >FindBugs</a> can help. I&#8217;ve heard Bill talk about this stuff before but this time he was emphasising that not all bugs are equal. All code has bugs but some mistakes don&#8217;t really matter.</p>
<p>Google&#8217;s code has over 1000 null pointer bugs but few if any NullPointerExceptions in running code are caused by these. You need to determine which bugs are worth your time to fix.</p>
<p>The most important bugs are generally those which can cost you money on the first day they manifest themselves and those bugs that occur silently. This is why Bill is a fan of runtime exceptions; if something unexpected happens, you want to know about it.</p>
<p>Devoxx is held in a massive cinema complex and so after all the talks today the organisers put on a showing of <a href="http://www.imdb.com/title/tt1285016/" ><em>The Social Network</em></a>, a movie about the founders of Facebook. I really enjoyed the film. All the performances were great and I really liked the soundtrack by Trent Reznor. You don&#8217;t need to be a geek to enjoy this film. I don&#8217;t know how much of it is actually true but it paints an interesting picture of Mark Zuckerberg and draws nice connections between our concepts of &#8216;friendship&#8217;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.frogcake.net/blog/2010/11/18/devoxx-project-coin-defective-java-and-the-social-network/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Devoxx &#8211; Improve the performance of your Spring app</title>
		<link>http://www.frogcake.net/blog/2010/11/17/devoxx-improve-the-performance-of-your-spring-app</link>
		<comments>http://www.frogcake.net/blog/2010/11/17/devoxx-improve-the-performance-of-your-spring-app#comments</comments>
		<pubDate>Wed, 17 Nov 2010 21:43:49 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Geek]]></category>
		<category><![CDATA[devoxx]]></category>

		<guid isPermaLink="false">http://www.frogcake.net/blog/?p=1011</guid>
		<description><![CDATA[This talk by Costin Leau was about the new caching features in Spring 3.1. After going over some problems you can face when caching (stale data, thrashing, distributed caches) and different caching patterns he introduced the declarative caching of Spring 3.1. It uses AOP and can be declared on methods by adding the @Cacheable annotation. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.frogcake.net/blog/wp-content/uploads/2010/11/LogoDevoxx150dpi.jpg" ><img hspace="1em"  vspace="1em"  align="right"  class="alignright size-medium wp-image-994"  title="LogoDevoxx150dpi"  src="http://www.frogcake.net/blog/wp-content/uploads/2010/11/LogoDevoxx150dpi-300x112.jpg"  alt=""  width="300"  height="112"   style="float:right; margin:0 0 1em 1em; border:black 1px solid;"/></a>This talk by Costin Leau was about the new caching features in Spring 3.1.</p>
<p>After going over some problems you can face when caching (stale data, thrashing, distributed caches) and different caching patterns he introduced the declarative caching of Spring 3.1.</p>
<p>It uses AOP and can be declared on methods by adding the @Cacheable annotation. This annotation caches a method&#8217;s return value using it&#8217;s parameters as the key although this can be customised.</p>
<p>Eg:</p>

<div class="wp_syntax" ><div class="code" ><pre class="java"  style="font-family:monospace;" >@Cacheable
<span style="color: #000000; font-weight: bold;" >public</span> <span style="color: #003399;" >Owner</span> loadOwner<span style="color: #009900;" >&#40;</span><span style="color: #000066; font-weight: bold;" >int</span> id<span style="color: #009900;" >&#41;</span><span style="color: #339933;" >;</span>
&nbsp;
@Cacheable<span style="color: #009900;" >&#40;</span><span style="color: #0000ff;" >&quot;owners&quot;</span><span style="color: #009900;" >&#41;</span>
<span style="color: #000000; font-weight: bold;" >public</span> <span style="color: #003399;" >Owner</span> loadOwner<span style="color: #009900;" >&#40;</span><span style="color: #000066; font-weight: bold;" >int</span> id<span style="color: #009900;" >&#41;</span><span style="color: #339933;" >;</span>
&nbsp;
<span style="color: #666666; font-style: italic;" >// Using Spring expression language</span>
@Cacheable<span style="color: #009900;" >&#40;</span>key<span style="color: #339933;" >=</span><span style="color: #0000ff;" >&quot;tag.name&quot;</span><span style="color: #009900;" >&#41;</span>
<span style="color: #000000; font-weight: bold;" >public</span> <span style="color: #003399;" >Owner</span> loadOwner<span style="color: #009900;" >&#40;</span>Tag tag, <span style="color: #003399;" >Date</span> created<span style="color: #009900;" >&#41;</span><span style="color: #339933;" >;</span>
&nbsp;
@Cacheable<span style="color: #009900;" >&#40;</span>key<span style="color: #339933;" >=</span><span style="color: #0000ff;" >&quot;T(someType).hash(name)&quot;</span><span style="color: #009900;" >&#41;</span>
<span style="color: #000000; font-weight: bold;" >public</span> <span style="color: #003399;" >Owner</span> loadOwner<span style="color: #009900;" >&#40;</span><span style="color: #003399;" >String</span> name<span style="color: #009900;" >&#41;</span><span style="color: #339933;" >;</span>
&nbsp;
<span style="color: #666666; font-style: italic;" >// Only cache on condition</span>
@Cacheable<span style="color: #009900;" >&#40;</span>condition<span style="color: #339933;" >=</span><span style="color: #0000ff;" >&quot;name &lt; 10&quot;</span><span style="color: #009900;" >&#41;</span>
<span style="color: #000000; font-weight: bold;" >public</span> <span style="color: #003399;" >Owner</span> loadOwner<span style="color: #009900;" >&#40;</span><span style="color: #003399;" >String</span> name, <span style="color: #003399;" >Date</span> created<span style="color: #009900;" >&#41;</span><span style="color: #339933;" >;</span></pre></div></div>

<p>The @CacheEvict annotation invalidates the cache:</p>

<div class="wp_syntax" ><div class="code" ><pre class="java"  style="font-family:monospace;" >@CacheEvict
<span style="color: #000000; font-weight: bold;" >public</span> <span style="color: #000066; font-weight: bold;" >void</span> deleteOwner<span style="color: #009900;" >&#40;</span><span style="color: #000066; font-weight: bold;" >int</span> id<span style="color: #009900;" >&#41;</span><span style="color: #339933;" >;</span>
&nbsp;
@CacheEvict<span style="color: #009900;" >&#40;</span><span style="color: #0000ff;" >&quot;owners&quot;</span>, key<span style="color: #339933;" >=</span><span style="color: #0000ff;" >&quot;id&quot;</span><span style="color: #009900;" >&#41;</span>
<span style="color: #000000; font-weight: bold;" >public</span> <span style="color: #000066; font-weight: bold;" >void</span> deleteOwner<span style="color: #009900;" >&#40;</span><span style="color: #000066; font-weight: bold;" >int</span> id, <span style="color: #000066; font-weight: bold;" >boolean</span> saveCopy<span style="color: #009900;" >&#41;</span><span style="color: #339933;" >;</span>
&nbsp;
@CacheEvict<span style="color: #009900;" >&#40;</span>name<span style="color: #339933;" >=</span><span style="color: #0000ff;" >&quot;owners&quot;</span>, allEntries<span style="color: #339933;" >=</span><span style="color: #000066; font-weight: bold;" >true</span><span style="color: #009900;" >&#41;</span>
<span style="color: #000000; font-weight: bold;" >public</span> <span style="color: #000066; font-weight: bold;" >void</span> batchUpdate<span style="color: #009900;" >&#40;</span><span style="color: #009900;" >&#41;</span></pre></div></div>

<p>You can also use your own stereotype annotations. Instead of spreading @Cacheable everywhere:</p>

<div class="wp_syntax" ><div class="code" ><pre class="java"  style="font-family:monospace;" >@Retention<span style="color: #009900;" >&#40;</span>RetentionPolicy.<span style="color: #006633;" >RUNTIME</span><span style="color: #009900;" >&#41;</span>
@Target<span style="color: #009900;" >&#40;</span><span style="color: #009900;" >&#123;</span>ElementType.<span style="color: #006633;" >METHOD</span><span style="color: #009900;" >&#125;</span><span style="color: #009900;" >&#41;</span>
@Cacheable<span style="color: #009900;" >&#40;</span><span style="color: #0000ff;" >&quot;results&quot;</span><span style="color: #009900;" >&#41;</span>
<span style="color: #000000; font-weight: bold;" >public</span> @<span style="color: #000000; font-weight: bold;" >interface</span> SlowService <span style="color: #009900;" >&#123;</span>
&nbsp;
<span style="color: #009900;" >&#125;</span>
&nbsp;
@SlowService
<span style="color: #000000; font-weight: bold;" >public</span> Source search<span style="color: #009900;" >&#40;</span><span style="color: #003399;" >String</span> tag<span style="color: #009900;" >&#41;</span> <span style="color: #009900;" >&#123;</span>...<span style="color: #009900;" >&#125;</span></pre></div></div>

<p>Spring is not a cache provider itself. You plug in your own cache provider (ehcache, JBoss Cache, etc).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.frogcake.net/blog/2010/11/17/devoxx-improve-the-performance-of-your-spring-app/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Devoxx &#8211; Performance Anxiety</title>
		<link>http://www.frogcake.net/blog/2010/11/17/devoxx-performance-anxiety</link>
		<comments>http://www.frogcake.net/blog/2010/11/17/devoxx-performance-anxiety#comments</comments>
		<pubDate>Wed, 17 Nov 2010 21:20:49 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Geek]]></category>
		<category><![CDATA[devoxx]]></category>

		<guid isPermaLink="false">http://www.frogcake.net/blog/?p=1008</guid>
		<description><![CDATA[I doubt Joshua Bloch suffers from performance anxiety but it was slightly ironic that there were some technical problems before he started his talk, titled Performance Anxiety, to an absolutely packed room at Devoxx today. I knew it would be a popular session so I got there early and so managed to find a seat, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.frogcake.net/blog/wp-content/uploads/2010/11/LogoDevoxx150dpi.jpg" ><img hspace="1em"  vspace="1em"  align="right"  class="alignright size-medium wp-image-994"  title="LogoDevoxx150dpi"  src="http://www.frogcake.net/blog/wp-content/uploads/2010/11/LogoDevoxx150dpi-300x112.jpg"  alt=""  width="300"  height="112"   style="float:right; margin:0 0 1em 1em; border:black 1px solid;"/></a>I doubt Joshua Bloch suffers from performance anxiety but it was slightly ironic that there were some technical problems before he started his talk, titled <em>Performance Anxiety</em>, to an absolutely packed room at Devoxx today. I knew it would be a popular session so I got there early and so managed to find a seat, unlike the others who sat on the steps or crowded the doorway.</p>
<p>His talk was about <em>microbenchmarking</em> &#8211; measuring the performance of a small piece of code as opposed to <em>profiling</em> an application.</p>
<p>In the good old days performance could be estimated simply by counting program instructions. Now it is simply impossible to do this because of the &#8216;abstraction gap&#8217;.  As code has become more and more complex it has become harder and harder to estimate and measure the performance.  Complexity and predictability are inversely related.</p>
<p>Even benchmarking code doesn&#8217;t really work with consecutive runs often showing a variance of 20%. The code and systems are so complex nobody really knows where this variance comes from.</p>
<p>The solution is to run a bunch of JVMs in sequence and then statistically analyse the data (mean, median, standard dev, etc).</p>
<p>Basically, benchmarking is really, really hard and most benchmarks are seriously broken. Either the results are unrelated to the test or the error bars exceed the measured values.</p>
<p><a href="http://code.google.com/p/caliper/" >Caliper</a> is microbenchmarking framework from Google which can help.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.frogcake.net/blog/2010/11/17/devoxx-performance-anxiety/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Devoxx &#8211; The Next Big JVM Language</title>
		<link>http://www.frogcake.net/blog/2010/11/17/devoxx-the-next-big-jvm-language</link>
		<comments>http://www.frogcake.net/blog/2010/11/17/devoxx-the-next-big-jvm-language#comments</comments>
		<pubDate>Wed, 17 Nov 2010 15:22:05 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Geek]]></category>
		<category><![CDATA[devoxx]]></category>

		<guid isPermaLink="false">http://www.frogcake.net/blog/?p=1006</guid>
		<description><![CDATA[Stephen Colebourne gave an entertaining talk to a packed room called The Next Big JVM Language. He went over the features of such new JVM languages as Groovy, Clojure, Scala and Fantom (which I&#8217;d never heard of). He seemed to be leaning toward Fantom as the language of choice before delivering the punchline that the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.frogcake.net/blog/wp-content/uploads/2010/11/LogoDevoxx150dpi.jpg" ><img hspace="1em"  vspace="1em"  align="right"  class="alignright size-medium wp-image-994"  title="LogoDevoxx150dpi"  src="http://www.frogcake.net/blog/wp-content/uploads/2010/11/LogoDevoxx150dpi-300x112.jpg"  alt=""  width="300"  height="112"   style="float:right; margin:0 0 1em 1em; border:black 1px solid;"/></a>Stephen Colebourne gave an entertaining talk to a packed room called The Next Big JVM Language. He went over the features of such new JVM languages as Groovy, Clojure, Scala and <a href="http://fantom.org/" >Fantom</a> (which I&#8217;d never heard of).</p>
<p>He seemed to be leaning toward Fantom as the language of choice before delivering the punchline that the best candidate for the Next Big Language might be a backwards incompatible version of Java itself.</p>
<p>I think I agree. Oracle should get rid of all that legacy crap in JDK 9.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.frogcake.net/blog/2010/11/17/devoxx-the-next-big-jvm-language/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Devoxx day two</title>
		<link>http://www.frogcake.net/blog/2010/11/16/devoxx-day-two</link>
		<comments>http://www.frogcake.net/blog/2010/11/16/devoxx-day-two#comments</comments>
		<pubDate>Tue, 16 Nov 2010 21:46:15 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Geek]]></category>
		<category><![CDATA[devoxx]]></category>

		<guid isPermaLink="false">http://www.frogcake.net/blog/?p=1000</guid>
		<description><![CDATA[A couple of pretty heavy-going sessions at Devoxx today. First up was Cassandra by Example with Jonathan Ellis one of the founders of Cassandra support company Riptano. I have already had some experience with Cassandra at both my previous and current jobs but it was good to go over the principals of Cassandra as well [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.frogcake.net/blog/wp-content/uploads/2010/11/LogoDevoxx150dpi.jpg" ><img hspace="1em"  vspace="1em"  align="right"  class="alignright size-medium wp-image-994"  title="LogoDevoxx150dpi"  src="http://www.frogcake.net/blog/wp-content/uploads/2010/11/LogoDevoxx150dpi-300x112.jpg"  alt=""  width="300"  height="112"   style="float:right; margin:0 0 1em 1em; border:black 1px solid;"/></a>A couple of pretty heavy-going sessions at Devoxx today. First up was Cassandra by Example with Jonathan Ellis one of the founders of Cassandra support company <a href="http://www.riptano.com/" >Riptano</a>.</p>
<p>I have already had some experience with Cassandra at both my <a href="http://www.openx.org" >previous</a> and <a href="http://www.amee.com" >current</a> jobs but it was good to go over the principals of Cassandra as well as seeing an example application deconstructed.</p>
<p>Cassandra&#8217;s strengths are:</p>
<ul>
<li>Scalability</li>
<li>Reliability</li>
<li>No single point of failure</li>
<li>Multiple data centre support</li>
<li>Integrated <a href="http://hadoop.apache.org/" >Hadoop</a> support (lets you run map reduce jobs on data in Cassandra without any ETL)</li>
</ul>
<p>Of course Cassandra is not ACID and has limited support for OLTP ad-hoc queries. However, companies that have really scaled traditional RDBMSs like MySQL or Oracle end up dispensing with these features anyway in order to achieve that scale.</p>
<p>Jonathan had an interesting quote from Twitter:</p>
<blockquote  style="margin:1em; padding:0 2em; background:url(http://www.frogcake.net/blog/wp-content/themes/panorama/images/quotes.gif) no-repeat left top; color:#888;margin:1em; padding:0 2em; background:url(http://www.frogcake.net/blog/wp-content/themes/panorama/images/quotes.gif) no-repeat left top; color:#888;"><p>It used to take 2 weeks to perform an ALTER TABLE on the tweets table</p></blockquote>
<p>This is  definitely something I can sympathise with. If you don&#8217;t plan ahead it can be easy to suddenly find your tables are so big they cannot be changed without serious pain, downtime or both.</p>
<p>When designing a relational schema we tend to think of objects and relationships. With Cassandra we need to think of objects and the queries we want to run against them. For each type of query you will need a column family (something <em>like</em> a table).</p>
<p>When choosing a key for rows, a natural key is best. If you need a surrogate key, use a UUID as integers may create collisions due to the distributed nature of Cassandra. <a href="http://en.wikipedia.org/wiki/Universally_unique_identifier#Version_1_.28MAC_address.29" >Version 1 UUIDs</a> can be sorted by time but if you don&#8217;t need time ordering, use <a href="http://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_.28random.29" >version 4 UUID</a>.</p>
<p>Using <a href="http://wiki.apache.org/cassandra/API" >Thrift</a> directly should be avoided at all costs in favour of higher level libraries like <a href="https://github.com/rantav/hector" >Hector</a>. There is a JPA implementation called <a href="http://code.google.com/p/kundera/" >Kundera</a> but this is based around Lucene so unless search is an important part of your application it may not be the best choice.</p>
<p>The afternoon was spent learning what&#8217;s new in Hibernate with Emmanuel Bernard from JBoss.</p>
<p>Fetch profiles can be defined and chosen at runtime, eg:</p>

<div class="wp_syntax" ><div class="code" ><pre class="java"  style="font-family:monospace;" >@<span style="color: #003399;" >Entity</span>
@FetchProfile<span style="color: #009900;" >&#40;</span>name <span style="color: #339933;" >=</span> <span style="color: #0000ff;" >&quot;all&quot;</span>,
    fetchOverrides <span style="color: #339933;" >=</span> <span style="color: #009900;" >&#123;</span>
        @FetchProfile.<span style="color: #006633;" >FetchOverride</span><span style="color: #009900;" >&#40;</span>
            entity <span style="color: #339933;" >=</span> Customer.<span style="color: #000000; font-weight: bold;" >class</span>,
            association <span style="color: #339933;" >=</span> <span style="color: #0000ff;" >&quot;orders&quot;</span>,
            mode <span style="color: #339933;" >=</span> FetchMode.<span style="color: #006633;" >JOIN</span><span style="color: #009900;" >&#41;</span>
        @FetchProfile.<span style="color: #006633;" >FetchOverride</span><span style="color: #009900;" >&#40;</span>
            entity <span style="color: #339933;" >=</span> Order.<span style="color: #000000; font-weight: bold;" >class</span>,
            association <span style="color: #339933;" >=</span> <span style="color: #0000ff;" >&quot;country&quot;</span>,
            mode <span style="color: #339933;" >=</span> FetchMode.<span style="color: #006633;" >JOIN</span><span style="color: #009900;" >&#41;</span>
<span style="color: #009900;" >&#125;</span><span style="color: #009900;" >&#41;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;" >public</span> <span style="color: #000000; font-weight: bold;" >class</span> Customer <span style="color: #009900;" >&#123;</span>
    @Id @GeneratedValue <span style="color: #000000; font-weight: bold;" >private</span> <span style="color: #000066; font-weight: bold;" >long</span> id<span style="color: #339933;" >;</span>
    <span style="color: #000000; font-weight: bold;" >private</span> <span style="color: #003399;" >String</span> name<span style="color: #339933;" >;</span>
    <span style="color: #000000; font-weight: bold;" >private</span> <span style="color: #000066; font-weight: bold;" >long</span> customerNumber<span style="color: #339933;" >;</span>
    @OneToMany <span style="color: #000000; font-weight: bold;" >private</span> Set<span style="color: #339933;" >&amp;</span>lt<span style="color: #339933;" >;</span>Order<span style="color: #339933;" >&amp;</span>gt<span style="color: #339933;" >;</span> orders<span style="color: #339933;" >;</span>
&nbsp;
<span style="color: #666666; font-style: italic;" >// standard getter/setter</span>
<span style="color: #009900;" >&#125;</span>
&nbsp;
Session session <span style="color: #339933;" >=</span> ...<span style="color: #339933;" >;</span>
session.<span style="color: #006633;" >enableFetchProfile</span><span style="color: #009900;" >&#40;</span> <span style="color: #0000ff;" >&quot;all&quot;</span> <span style="color: #009900;" >&#41;</span><span style="color: #339933;" >;</span>  <span style="color: #666666; font-style: italic;" >// name matches @FetchProfile name</span>
Customer customer <span style="color: #339933;" >=</span> <span style="color: #009900;" >&#40;</span>Customer<span style="color: #009900;" >&#41;</span> session.<span style="color: #006633;" >get</span><span style="color: #009900;" >&#40;</span> Customer.<span style="color: #000000; font-weight: bold;" >class</span>, customerId <span style="color: #009900;" >&#41;</span><span style="color: #339933;" >;</span>
session.<span style="color: #006633;" >disableFetchProfile</span><span style="color: #009900;" >&#40;</span> <span style="color: #0000ff;" >&quot;all&quot;</span> <span style="color: #009900;" >&#41;</span><span style="color: #339933;" >;</span> <span style="color: #666666; font-style: italic;" >// or just close the session</span></pre></div></div>

<p>A lot of time was spent on the Criteria API which lets you write object oriented, type-safe and strongly typed queries.</p>
<p>Hibernate Search provides lucene-based full text search for Hibernate and looks quite neat. You get transparent index synchronisation and support for clustering and loading of massive indexes.</p>
<p><a href="http://docs.jboss.org/envers/docs/index.html" >Hibernate Envers</a> also looks really interesting. This is a framework for dealing with historical data in Hibernate.</p>
<p>Entities are versioned and all changes (insert, update, delete) are audited transparently. The existing tables are unchanged but new audit tables are created for each entity. For example a Person table will get a Person_AUD table. This looks the same with the addition of revision number and revision type (add, delete, modify) columns.</p>
<p>You can look up by revision and query by revision or entity history. You can also define a RevisionEntity to add new fields atop the standard revision number and date.</p>
<p>It looks really helpful for auditing and dealing with historical data although there is of course a performance hit to inserts, updates and deletes as the audit table must be written to as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.frogcake.net/blog/2010/11/16/devoxx-day-two/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Devoxx day one</title>
		<link>http://www.frogcake.net/blog/2010/11/15/devoxx-day-one</link>
		<comments>http://www.frogcake.net/blog/2010/11/15/devoxx-day-one#comments</comments>
		<pubDate>Mon, 15 Nov 2010 23:08:46 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Geek]]></category>
		<category><![CDATA[devoxx]]></category>

		<guid isPermaLink="false">http://www.frogcake.net/blog/?p=993</guid>
		<description><![CDATA[Today was the first day of Devoxx, the European Java conference held in Antwerp. The first two days are actually the &#8216;University&#8217; sessions. These are longer, more in depth talks and the first one I went to was the &#8216;Productive Programmer&#8217; by Neal Ford from Thoughtworks. This was an interesting talk split into two sections, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.frogcake.net/blog/wp-content/uploads/2010/11/LogoDevoxx150dpi.jpg" ><img hspace="1em"  vspace="1em"  align="right"  class="alignright size-medium wp-image-994"  title="LogoDevoxx150dpi"  src="http://www.frogcake.net/blog/wp-content/uploads/2010/11/LogoDevoxx150dpi-300x112.jpg"  alt=""  width="300"  height="112"   style="float:right; margin:0 0 1em 1em; border:black 1px solid;"/></a>Today was the first day of Devoxx, the European Java conference held in Antwerp.</p>
<p>The first two days are actually the &#8216;University&#8217; sessions. These are longer, more in depth talks and the first one I went to was the &#8216;Productive Programmer&#8217; by Neal Ford from Thoughtworks.</p>
<p>This was an interesting talk split into two sections, the first dealing with the mechanics of productivity and the second consisting of a number of tips putting these principals into practice.</p>
<p>The overarching theme was that &#8220;any time you are doing simple repetitive stuff on behalf of your computer it is laughing at you&#8221;. This means don&#8217;t type the same commands over and over but it also means learning keyboard shortcuts for your IDE and OS.</p>
<p>Neal demonstrated the <a href="http://plugins.intellij.net/plugin/?id=1003" >Key Promoter plugin</a> for IntelliJ which will pop up keyboard shortcuts whenever you use a menu item instead. I already use the GOTO class shortcut in IntelliJ all the time but didn&#8217;t know you can just type the capital letters of a class and it will find it. For example type &#8216;mac&#8217; to find MyAwesomeClass.</p>
<p>Neal is so productive he doesn&#8217;t even bother to type the left hand side of statements in IntelliJ; he lets the IDE fill that in for him (using introduce variable). <img src="http://www.frogcake.net/blog/wp-includes/images/smilies/icon_smile.gif"  alt=":-)"  class="wp-smiley" /> </p>
<p>Neal also talked about a concept called &#8216;locus of attention&#8217; and the need to make your environment quiet to preserve your locus of attention. The higher the level of concentration, the denser the ideas, so turn off notifications, don&#8217;t keep email open all the time. Windows is the worst at stealing focus; &#8220;it is like a bored 3 year old&#8221;. Another reason why 80% of people here seem to have Macs&#8230; I quite like the idea of using something like <a href="http://www.lachoseinteractive.net/en/products/doodim/" >Doodim</a> to gradually dim everything on your desktop apart from the application you are working in.</p>
<p>The problem with using graphical tools to navigate a file system or class structure is that the hierarchies are too deep. Any time you know where you want to get to already it will be faster to search than to navigate. So make use of shortcuts like GOTO class or OSX menu item search.</p>
<p>Another neat idea was to use <a href="http://seleniumhq.org/" >Selenium</a> to record interactions for debugging web apps. Rather than having to repeatedly click through a sequence to get to where you need to be in the app, simply record the sequence using Selenium and play it back instantly. Even better: get your QA team to record a Selenium script to reproduce a bug and have them attach that to the JIRA ticket instead of a screenshot.</p>
<p>Neal suggests to always use a &#8216;real&#8217; programming language for scripting (groovy, ruby, php) instead of sed or awk. This allows your little tools to grow into assets and lets you add unit tests and refactor.</p>
<p>The second major session was an introduction to MongoDB by Alvin Richards. This was a pretty in depth session and as he said it was a bit like drinking from the firehose but I came away liking what I saw.</p>
<p>MongoDB belongs to the so-called NoSQL family of data stores and is &#8216;document oriented&#8217;. Documents are stored as binary JSON and the schema is not fixed. This makes it really easy for your schema to evolve with your application.</p>
<p>With MongoDB you get all this built in:</p>
<ul>
<li>Horizontal scaling</li>
<li>Simplified schema evolution</li>
<li>Simplified deployment and operation</li>
</ul>
<p>Reads can be scaled using replica sets. These are a cluster of servers where any node can be the primary and failover/recovery is handled automatically. All writes go to the primary node.</p>
<p>Writes can be scaled using automatic sharding. MongoDB&#8217;s sharding is transparent to the application code and migrations and rebalancing are handled automatically with no down-time(!)</p>
<p>You can write Map Reduce functions in JavaScript for MongoDB.</p>
<p>You can either use the low-level java library to talk to MongoDB or use <a href="http://code.google.com/p/morphia/" >Morphia</a> which provides a kind of O/R wrapper to map your POJOs. Morphia gives you Annotations like @Entity, @Transient, @Indexed, @PrePersist, @PreSave, @PostPersist, etc.</p>
<p>To backup MongoDB you can either use mongodump/mongorestore which gives you a binary dump that is not neccesarily consistent from start to finish or use fsync + lock from a slave and then snapshot the files.</p>
<p>It was a long day but a good start to the conference. Tomorrow I&#8217;m starting with another NoSQL data store: Cassandra.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.frogcake.net/blog/2010/11/15/devoxx-day-one/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sharkproof</title>
		<link>http://www.frogcake.net/blog/2010/03/31/sharkproof</link>
		<comments>http://www.frogcake.net/blog/2010/03/31/sharkproof#comments</comments>
		<pubDate>Wed, 31 Mar 2010 21:55:10 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Geek]]></category>

		<guid isPermaLink="false">http://www.frogcake.net/blog/?p=881</guid>
		<description><![CDATA[I may never go to the moon, but it&#8217;s nice to know that if I do my Speedmaster will still keep ticking. I like watches. I particularly like watches that have some history or character about them. Watches that are designed for a purpose, not just to look good. Omega have released a new version [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="lightbox"  href="http://www.frogcake.net/blog/wp-content/uploads/2010/03/ploprof.png" ><img hspace="1em"  vspace="1em"  align="right"  class="alignright size-medium wp-image-924"  title="Omega Seamaster PloProf"  src="http://www.frogcake.net/blog/wp-content/uploads/2010/03/ploprof-218x300.png"  alt=""  width="218"  height="300"   style="float:right; margin:0 0 1em 1em; border:black 1px solid;"/></a>I may never go to the moon, but it&#8217;s nice to know that if I do my <a href="http://www.omega.ch/minisites/speedmaster/generic/minisite.html" >Speedmaster</a> will still keep ticking.</p>
<p>I like watches. I particularly like watches that have some history or character about them. Watches that are designed for a purpose, not just to look good.</p>
<p>Omega have released a new version of their <a href="http://www.omegawatches.com/gents/seamaster/ploprof-1200-m/" >Seamaster PloProf</a>. The standard Seamaster is a nice watch, good enough for James Bond, but the PloProf is like a Seamaster on steroids.</p>
<p>The first PloProf (the name comes from <em>plongeurs professionnels</em> – French for “professional divers”) was first released in 1970 and it was rated to the man-crushing depth of 600M. It also looked like no other watch. The crown was on the other side and under a protective shield to allow freer wrist movement and to protect against any accidental changes at depth.</p>
<p>At the 2 o&#8217;clock position is the orange bezel-release security pusher. You need to push this to move the bezel, again to prevent any accidental asphyxiation on the sea floor.</p>
<p>The new PloProf has all these same features as the original but doubles the depth to a giant squid-dwelling 1200M. You can also get it with a &#8220;Sharkproof&#8221; bracelet.</p>
<p>Nice to know that if you drop it in the bath, or get your arm bitten off by a shark it will still keep time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.frogcake.net/blog/2010/03/31/sharkproof/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>You do not have permission</title>
		<link>http://www.frogcake.net/blog/2010/02/10/you-do-not-have-permission</link>
		<comments>http://www.frogcake.net/blog/2010/02/10/you-do-not-have-permission#comments</comments>
		<pubDate>Wed, 10 Feb 2010 09:35:08 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Geek]]></category>

		<guid isPermaLink="false">http://www.frogcake.net/blog/?p=892</guid>
		<description><![CDATA[Miguel found this screenshot in an old email from when we were working on permissions and preferences in OpenX: The subject of the email was &#8220;Permissions &#38; Settings: Learn From The Masters&#8221;]]></description>
			<content:encoded><![CDATA[<p>Miguel found this screenshot in an old email from when we were working on permissions and preferences in <a href="http://www.openx.org" >OpenX</a>:</p>
<p><img hspace="auto"  class="aligncenter size-full wp-image-893"  title="Vista error message"  src="http://www.frogcake.net/blog/wp-content/uploads/2010/02/vista_error_message.jpg"  alt=""  width="496"  height="169"   style="display: block; margin-left: auto; margin-right: auto; border:black 1px solid;"/></p>
<p>The subject of the email was &#8220;Permissions &amp; Settings: Learn From The Masters&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.frogcake.net/blog/2010/02/10/you-do-not-have-permission/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Piping Wired</title>
		<link>http://www.frogcake.net/blog/2009/07/19/piping-wired</link>
		<comments>http://www.frogcake.net/blog/2009/07/19/piping-wired#comments</comments>
		<pubDate>Sun, 19 Jul 2009 21:03:20 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Geek]]></category>

		<guid isPermaLink="false">http://www.frogcake.net/blog/?p=610</guid>
		<description><![CDATA[Love how there is now a UK version of Wired?  Hate how it doesn&#8217;t have Scott Brown or Steven Levy? I do. I mean, Warren Ellis is great and all but I miss my favourite regular writers from US Wired. Well now I&#8217;ve finally found a use for Yahoo Pipes, that cool but strangely pointless [...]]]></description>
			<content:encoded><![CDATA[<p><img hspace="1em"  vspace="1em"  align="right"  class="alignright size-medium wp-image-611"  title="Big Pipes"  src="http://www.frogcake.net/blog/wp-content/uploads/2009/07/pipes-300x225.jpg"  alt="Big Pipes"  width="300"  height="225"   style="float:right; margin:0 0 1em 1em; border:black 1px solid;"/>Love how there is now a <a href="http://www.wired.co.uk" >UK version of Wired</a>?  Hate how it doesn&#8217;t have Scott Brown or Steven Levy?</p>
<p>I do.</p>
<p>I mean, <a href="http://www.wired.co.uk/wired-magazine/archive/2009/06/start/warren-ellis.aspx" >Warren Ellis is great</a> and all but I miss my favourite regular writers from US Wired.</p>
<p>Well now I&#8217;ve finally found a use for <a href="http://pipes.yahoo.com" >Yahoo Pipes</a>, that cool but strangely pointless thing Yahoo built a couple of years ago.</p>
<p>Luckily Wired post all their magazine content online (an inferior format, unworthy of Wired&#8217;s awesome graphic design, but I&#8217;m not going to buy both editions of the magazine, especially as they share some of the feature articles) so I created a <a href="http://pipes.yahoo.com/pipes/pipe.info?_id=oM0Hl9tL3hGlhpHuPW7D0g" >pipe</a> to suck down the Wired RSS feed and filter it for articles by Scott Brown and Steven Levy.</p>
<p>Now I have the best of both worlds.</p>
<p>You can get an <a href="http://pipes.yahoo.com/pipes/pipe.run?_id=oM0Hl9tL3hGlhpHuPW7D0g&amp;_render=rss" >RSS version of the pipe here</a>.</p>
<p><em>Image: <a href="http://www.flickr.com/photos/uwehermann/3100832391" >Uwe Hermann</a></em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.frogcake.net/blog/2009/07/19/piping-wired/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

