<?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>non-random ramble &#187; code</title>
	<atom:link href="http://jimbarritt.com/non-random/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://jimbarritt.com/non-random</link>
	<description>adventures in code</description>
	<lastBuildDate>Tue, 20 Sep 2011 13:16:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>The &#8216;R&#8217; Sessions</title>
		<link>http://jimbarritt.com/non-random/2011/03/07/the-r-sessions/</link>
		<comments>http://jimbarritt.com/non-random/2011/03/07/the-r-sessions/#comments</comments>
		<pubDate>Mon, 07 Mar 2011 07:13:12 +0000</pubDate>
		<dc:creator>Jim Barritt</dc:creator>
				<category><![CDATA[r]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[thoughtblog]]></category>

		<guid isPermaLink="false">http://jimbarritt.com/non-random/?p=774</guid>
		<description><![CDATA[(Image from http://datamining.typepad.com) A few years ago whilst working on my MSc thesis I was heavily into R a statistical analysis package which has a functional language feel to it. My friend Marc Hasenbank, a few others and I ran a series of workshops for people wanting an introduction to R. I recently wanted to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://datamining.typepad.com/gallery/blog-map-gallery.html"><img src="http://datamining.typepad.com/photos/uncategorized/newblogcrop.png" width=400></img></a><br />
(Image from <a href="http://datamining.typepad.com">http://datamining.typepad.com</a>)</p>
<p>A few years ago whilst working on my MSc thesis I was heavily into <a href="http://cran.r-project.org/">R</a> a statistical analysis package which has a functional language feel to it. My friend Marc Hasenbank, a few others and I ran a series of workshops for people wanting an introduction to R. I recently wanted to show this to someone so thought I would post a link. The code from the tutorials can be found <a href="http://www.vuw.ac.nz/staff/stephen_hartley/software/R/rug.htm">here</a></p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fjimbarritt.com%2Fnon-random%2F2011%2F03%2F07%2Fthe-r-sessions%2F&amp;title=The%20%26%238216%3BR%26%238217%3B%20Sessions"><img src="http://jimbarritt.com/non-random/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://jimbarritt.com/non-random/2011/03/07/the-r-sessions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Help JUnitMax play with Hamcrest 1.3</title>
		<link>http://jimbarritt.com/non-random/2010/12/14/help-junitmax-play-with-hamcrest-1-3/</link>
		<comments>http://jimbarritt.com/non-random/2010/12/14/help-junitmax-play-with-hamcrest-1-3/#comments</comments>
		<pubDate>Tue, 14 Dec 2010 16:19:51 +0000</pubDate>
		<dc:creator>Jim Barritt</dc:creator>
				<category><![CDATA[testing]]></category>
		<category><![CDATA[thoughtblog]]></category>

		<guid isPermaLink="false">http://jimbarritt.com/non-random/?p=757</guid>
		<description><![CDATA[I have been working on converting our codebase to JUnit, with a secondary aim of trying out JUnitMax. I ran the Max and quickly discovered that it failed when trying to execute assertions using the Hamcrest hasItems matcher. The assertion looks something like: This error frequently occurs because JUnit packages an older Version of the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://jimbarritt.com/non-random/wp-content/uploads/2010/12/cat_and_dog.jpg" rel="lightbox[757]"><img src="http://jimbarritt.com/non-random/wp-content/uploads/2010/12/cat_and_dog.jpg" alt="" title="cat_and_dog" width="512" height="384" class="aligncenter size-full wp-image-758" /></a></p>
<p>I have been working on converting our codebase to JUnit, with a secondary aim of trying out <a href="http://www.junitmax.com/">JUnitMax</a>.</p>
<p>I ran the Max and quickly discovered that it failed when trying to execute assertions using the Hamcrest <code><i>hasItems</i></code> matcher.</p>
<p>The assertion looks something like:</p>
<pre name='code' class='java:nogutter:nocontrols'>
NoSuchMethodException describeMismatch
</pre>
<p>This error frequently occurs because JUnit packages an older Version of the <code>org.hamcrest.Matcher</code> class which does not have the <code>describeMismatch</code> method. </p>
<p>I dug around a bit in the plugins directory in the eclipse install folder and found that it contains a <code>junit-4.8.2.jar</code>. Happy days I thought, I can simply do what I&#8217;ve been getting used to doing for a while and replace it with <code>junit-dep-4.8.2.jar</code> which does <b>not</b> contain the hamcrest classes. </p>
<p>Unfortunately this didn&#8217;t quite work. It turns out that you need to call it exactly the same <code>junit-4.8.2.jar</code>. I thought this was because there&#8217;s an entry in the <code>MANIFEST.MF</code> file but I tried to change it and that didn&#8217;t work too well.</p>
<p>Renaming the Jar file however works a treat and now I have full JUnitMax action on my box.</p>
<p>I&#8217;ve posted on the JUnitMax forums about the problem <a href="http://tech.groups.yahoo.com/group/junitmax/message/294">here</a>.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fjimbarritt.com%2Fnon-random%2F2010%2F12%2F14%2Fhelp-junitmax-play-with-hamcrest-1-3%2F&amp;title=Help%20JUnitMax%20play%20with%20Hamcrest%201.3"><img src="http://jimbarritt.com/non-random/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://jimbarritt.com/non-random/2010/12/14/help-junitmax-play-with-hamcrest-1-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using TextMate with R</title>
		<link>http://jimbarritt.com/non-random/2010/11/16/using-textmate-with-r/</link>
		<comments>http://jimbarritt.com/non-random/2010/11/16/using-textmate-with-r/#comments</comments>
		<pubDate>Tue, 16 Nov 2010 21:35:57 +0000</pubDate>
		<dc:creator>Jim Barritt</dc:creator>
				<category><![CDATA[r]]></category>
		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://jimbarritt.com/non-random/?p=750</guid>
		<description><![CDATA[I&#8217;ve been using the R language for some years now but didn&#8217;t have it installed on my current machine. TextMate is a great editor to use as it has a custom bundle that gives you syntax highlighting and executes commands for you in the R console. To install the R bundle: Then in TextMate choose [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.r-project.org/"><img src="http://www.r-project.org/Rlogo.jpg" alt="rlogo" /></a></p>
<p>I&#8217;ve been using the <a href="http://www.r-project.org/">R</a> language for some years now but didn&#8217;t have it installed on my current machine. </p>
<p><a href="http://macromates.com/">TextMate</a> is a great editor to use as it has a custom bundle that gives you syntax highlighting and executes commands for you in the R console.</p>
<p>To install the R bundle:</p>
<pre name='code' class='java:nogutter:nocontrols'>
cd ~/Library/Application\ Support/TextMate/Bundles/
svn co http://svn.textmate.org/trunk/Bundles/R.tmbundle/
</pre>
<p>Then in TextMate choose Bundles->Bundle Editor->Reload Bundles.</p>
<p>There is one tweak I make which is that I like to press ⌘ + RETURN to execute the current selection in the R console. So edit the bundle and find R.app in the commands and change the key. Also I like it to return back to text mate afterwards, so I add the following to the script:</p>
<pre name='code' class='java:nogutter:nocontrols'>
-e &#8216;tell application &#8220;TextMate&#8221; to activate&#8217; \
</pre>
<p>I also removed the line about setting the current dir. This was a little fiddly &#8211; I found that I had to make sure I selected the entire line and cut it then delete, making sure there are no end of line characters. So it looks like this:</p>
<pre name='code' class='java:nogutter:nocontrols'>
# input is selection or document
rawText=&#8221;`cat`&#8221;
curDir=&#8221;
if [[ ${#TM_DIRECTORY} -gt 0 ]]; then
	curDir=&#8221;$TM_DIRECTORY&#8221;
fi
osascript -e &#8216;on run(theCode)&#8217; \
		  -e &#8216;tell application &#8220;R&#8221; to activate&#8217; \
		  -e &#8216;tell application &#8220;R&#8221; to cmd (item 1 of theCode)&#8217; \
		  -e &#8216;tell application &#8220;TextMate&#8221; to activate&#8217; \
		  -e &#8216;end run&#8217; &#8212; &#8220;$rawText&#8221; &#8220;$curDir&#8221;
</pre>
<p>All good.</p>
<p>UPDATE: 07/02/2011 &#8211; R now comes with a 64bit version so if you are on a macbook you can replace &#8220;R&#8221; in the code above with &#8220;R64&#8243;</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fjimbarritt.com%2Fnon-random%2F2010%2F11%2F16%2Fusing-textmate-with-r%2F&amp;title=Using%20TextMate%20with%20R"><img src="http://jimbarritt.com/non-random/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://jimbarritt.com/non-random/2010/11/16/using-textmate-with-r/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Oracle Jdbc Driver 10.2.0.2.0 fails to render Euro (€) when db is set to WE8MSWIN1252 encoding</title>
		<link>http://jimbarritt.com/non-random/2010/11/08/oracle-jdbc-driver-10-2-0-2-0-fails-to-render-euro-e-when-db-is-set-to-we8mswin1252-encoding/</link>
		<comments>http://jimbarritt.com/non-random/2010/11/08/oracle-jdbc-driver-10-2-0-2-0-fails-to-render-euro-e-when-db-is-set-to-we8mswin1252-encoding/#comments</comments>
		<pubDate>Mon, 08 Nov 2010 16:46:41 +0000</pubDate>
		<dc:creator>Jim Barritt</dc:creator>
				<category><![CDATA[databases]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[random]]></category>

		<guid isPermaLink="false">http://jimbarritt.com/non-random/?p=741</guid>
		<description><![CDATA[We just spent a few glorious hours or so trawling the internet and writing old skool jdbc code, to discover this little beauty. Simply upgrade to 10.2.0.5 of the jdbc driver and it goes away. Thanks to this post http://efreedom.com/Question/1-377745/Oracle-JDBC-Euro-Character we discovered our problem. For the full details on the euro&#8230;. http://www.fileformat.info/info/unicode/char/20ac/index.htm And if your [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://jimbarritt.com/non-random/wp-content/uploads/2010/11/euro_sign.png" rel="lightbox[741]"><img src="http://jimbarritt.com/non-random/wp-content/uploads/2010/11/euro_sign.png" alt="" title="euro_sign" width="100" height="100" class="aligncenter size-full wp-image-743" /></a></p>
<p>We just spent a few glorious hours or so trawling the internet and writing old skool jdbc code, to discover this little beauty. Simply upgrade to 10.2.0.5 of the jdbc driver and it goes away.</p>
<p>Thanks to this post http://efreedom.com/Question/1-377745/Oracle-JDBC-Euro-Character we discovered our problem.</p>
<p>For the full details on the euro&#8230;. </p>
<p>http://www.fileformat.info/info/unicode/char/20ac/index.htm</p>
<p>And if your really bored:</p>
<p>http://www.fileformat.info/info/unicode/char/1f47e/index.htm</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fjimbarritt.com%2Fnon-random%2F2010%2F11%2F08%2Foracle-jdbc-driver-10-2-0-2-0-fails-to-render-euro-e-when-db-is-set-to-we8mswin1252-encoding%2F&amp;title=Oracle%20Jdbc%20Driver%2010.2.0.2.0%20fails%20to%20render%20Euro%20%28%E2%82%AC%29%20when%20db%20is%20set%20to%20WE8MSWIN1252%20encoding"><img src="http://jimbarritt.com/non-random/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://jimbarritt.com/non-random/2010/11/08/oracle-jdbc-driver-10-2-0-2-0-fails-to-render-euro-e-when-db-is-set-to-we8mswin1252-encoding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hibernate Proxy InstantiationException</title>
		<link>http://jimbarritt.com/non-random/2010/07/23/hibernate-proxy-instantiationexception/</link>
		<comments>http://jimbarritt.com/non-random/2010/07/23/hibernate-proxy-instantiationexception/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 13:39:31 +0000</pubDate>
		<dc:creator>Jim Barritt</dc:creator>
				<category><![CDATA[hibernate]]></category>

		<guid isPermaLink="false">http://jimbarritt.com/non-random/?p=602</guid>
		<description><![CDATA[Changing entities to be lazy loaded led me to the following problem: Thanks to Kristian I jumped straight to the problem. From the Hibernate docs: Cat has a no-argument constructor. All persistent classes must have a default constructor (which can be non-public) so that Hibernate can instantiate them using Constructor.newInstance(). It is recommended that you [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://jimbarritt.com/non-random/wp-content/uploads/2010/07/facade.jpg" rel="lightbox[602]"><img src="http://jimbarritt.com/non-random/wp-content/uploads/2010/07/facade.jpg" alt="" title="facade" width="500" height="375" class="aligncenter size-full wp-image-603" /></a></p>
<p>Changing entities to be lazy loaded led me to the following problem:</p>
<pre name='code' class='java:nogutter:nocontrols'>
@OneToMany(fetch = FetchType.LAZY)
</pre>
<pre name='code' class='java:nogutter:nocontrols'>
Caused by: org.hibernate.HibernateException: Javassist Enhancement failed: Thing
	at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(JavassistLazyInitializer.java:142)
	at org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.getProxy(JavassistProxyFactory.java:72)
	at org.hibernate.tuple.entity.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:402)
	at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3483)
&#8230;.
Caused by: java.lang.InstantiationException: Thing_$$_javassist_38
	at java.lang.Class.newInstance0(Class.java:340)
	at java.lang.Class.newInstance(Class.java:308)
	at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(JavassistLazyInitializer.java:139)
</pre>
<p>Thanks to <a href="http://kristian-domagala.blogspot.com/2008/10/proxy-instantiation-problem-from.html">Kristian</a> I jumped straight to the problem. From the <a href="http://docs.jboss.org/hibernate/core/3.3/reference/en/html/persistent-classes.html#persistent-classes-pojo-constructor">Hibernate docs</a>:</p>
<blockquote><p>Cat has a no-argument constructor. All persistent classes must have a default constructor (which can be non-public) so that Hibernate can instantiate them using Constructor.newInstance(). It is recommended that you have a default constructor with <strong>at least</strong> package visibility for runtime proxy generation in Hibernate.</p></blockquote>
<p>This should probably read &#8220;It is essential&#8230;.&#8221;</p>
<p>Anyway now everything is real lazy so happy days.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fjimbarritt.com%2Fnon-random%2F2010%2F07%2F23%2Fhibernate-proxy-instantiationexception%2F&amp;title=Hibernate%20Proxy%20InstantiationException"><img src="http://jimbarritt.com/non-random/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://jimbarritt.com/non-random/2010/07/23/hibernate-proxy-instantiationexception/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Log4J settings for working with Hibernate</title>
		<link>http://jimbarritt.com/non-random/2010/07/23/log4j-settings-for-working-with-hibernate/</link>
		<comments>http://jimbarritt.com/non-random/2010/07/23/log4j-settings-for-working-with-hibernate/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 12:28:37 +0000</pubDate>
		<dc:creator>Jim Barritt</dc:creator>
				<category><![CDATA[hibernate]]></category>

		<guid isPermaLink="false">http://jimbarritt.com/non-random/?p=588</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><a href="http://jimbarritt.com/non-random/wp-content/uploads/2010/07/hibernate.png" rel="lightbox[588]"><img src="http://jimbarritt.com/non-random/wp-content/uploads/2010/07/hibernate.png" alt="" title="hibernate" width="600" /></a><br />
<pre name='code' class='xml:nogutter:nocontrols'>
	<!--
		These  hibernate values are quite tuned to provide a clear output of SQL and what parameters are bound
		org.hibernate should be on WARN so you don't see loads or random stuff
		org.hibernate.jdbc.ConnectionManager on DEBUG to show open and closing of connections
		org.hibernate.SQL on DEBUG to see the actual SQL statements (also need to turn it on in HibernateSessionFactory (show_sql=true)
		org.hibernate.type on TRACE	so that you can see which parameters are bound to the statements
		Any custom type mappers should also be put on trace so that you see them binding (of course you need to add the logging statements yourself)
		Please be careful when checking in this file to not check in local changes for specific debugging purposes
	-->
	<logger name="org.hibernate">
  		<level value="warn"/>
	</logger>
	<logger name="org.hibernate.jdbc.ConnectionManager">
  		<level value="debug"/>
	</logger>
	<logger name="org.hibernate.SQL">
  		<level value="debug"/>
	</logger>
	<category name="org.hibernate.type">
<priority value="trace"/>
	</category>
</pre></p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fjimbarritt.com%2Fnon-random%2F2010%2F07%2F23%2Flog4j-settings-for-working-with-hibernate%2F&amp;title=Log4J%20settings%20for%20working%20with%20Hibernate"><img src="http://jimbarritt.com/non-random/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://jimbarritt.com/non-random/2010/07/23/log4j-settings-for-working-with-hibernate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing JRuby with Intellij (OS X)</title>
		<link>http://jimbarritt.com/non-random/2010/07/03/installing-jruby-with-intellij-os-x/</link>
		<comments>http://jimbarritt.com/non-random/2010/07/03/installing-jruby-with-intellij-os-x/#comments</comments>
		<pubDate>Sat, 03 Jul 2010 09:14:25 +0000</pubDate>
		<dc:creator>Jim Barritt</dc:creator>
				<category><![CDATA[build]]></category>
		<category><![CDATA[intellij]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jruby]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[thoughtblog]]></category>

		<guid isPermaLink="false">http://jimbarritt.com/non-random/?p=573</guid>
		<description><![CDATA[GET it from http://jruby.org/ There is a download page, download and exract the tar file somehwere. I put it in /System/Library/Frameworks/JRuby.framework/jruby-1.5.1 I then created a symbolic link to jruby_current And then simply add it to my ~/.bash_profile Now you can add the JRuby SDK to your Java Module in Intellij: Now you can have ruby [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://jimbarritt.com/non-random/wp-content/uploads/2010/07/jruby.png" rel="lightbox[573]"><img src="http://jimbarritt.com/non-random/wp-content/uploads/2010/07/jruby.png" alt="" title="jruby" width="235" height="232" class="aligncenter size-full wp-image-574" /></a></p>
<p>GET it from <a href="http://jruby.org/#2">http://jruby.org/</a></p>
<p>There is a download page, download and exract the tar file somehwere.</p>
<p>I put it in <code>/System/Library/Frameworks/JRuby.framework/jruby-1.5.1</code></p>
<p>I then created a symbolic link to <code>jruby_current</code><br />
<pre name='code' class='java:nogutter:nocontrols'>
ln -s jruby-1.5.1/ jruby_current
</pre></p>
<p>And then simply add it to my <code>~/.bash_profile</code></p>
<pre name='code' class='java:nogutter:nocontrols'>
$vi ~/.bash_profile
export PATH=/System/Library/Frameworks/JRuby.framework/jruby_current/bin:$PATH
#Reload the profile&#8230;
$. ~/.bash_profile
#Try out jruby&#8230;
$jruby -v
jruby 1.5.1 (ruby 1.8.7 patchlevel 249) (2010-06-06 f3a3480) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_17) [x86_64-java]
</pre>
<p>Now you can add the JRuby SDK to your Java Module in Intellij:</p>
<p><a href="http://jimbarritt.com/non-random/wp-content/uploads/2010/07/jruby_sdk.png" rel="lightbox[573]"><img src="http://jimbarritt.com/non-random/wp-content/uploads/2010/07/jruby_sdk.png" alt="" title="jruby_sdk" width="600" /></a></p>
<p>Now you can have ruby and Java in the same project. Awesome.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fjimbarritt.com%2Fnon-random%2F2010%2F07%2F03%2Finstalling-jruby-with-intellij-os-x%2F&amp;title=Installing%20JRuby%20with%20Intellij%20%28OS%20X%29"><img src="http://jimbarritt.com/non-random/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://jimbarritt.com/non-random/2010/07/03/installing-jruby-with-intellij-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google reader &#8220;shared items&#8221; plugin for wordpress</title>
		<link>http://jimbarritt.com/non-random/2010/06/06/google-reader-shared-items-plugin-for-wordpress/</link>
		<comments>http://jimbarritt.com/non-random/2010/06/06/google-reader-shared-items-plugin-for-wordpress/#comments</comments>
		<pubDate>Sun, 06 Jun 2010 16:08:38 +0000</pubDate>
		<dc:creator>Jim Barritt</dc:creator>
				<category><![CDATA[meta]]></category>
		<category><![CDATA[thoughtblog]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://jimbarritt.com/non-random/?p=517</guid>
		<description><![CDATA[I find google reader a useful way to aggregate information from many blogs. Particularly convenient is to be able to read these on my iPhone and then mark them as shared. That way I can build up a list of information I am interested in. This is then conveniently exposed as an RSS feed by [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://jimbarritt.com/non-random/wp-content/uploads/2010/06/googlereader1.png" rel="lightbox[517]"><img src="http://jimbarritt.com/non-random/wp-content/uploads/2010/06/googlereader1.png" alt="" title="googlereader" width="500" class="aligncenter size-full " /></a></p>
<p>I find google reader a useful way to aggregate information from many blogs. Particularly convenient is to be able to read these on my iPhone and then mark them as shared. That way I can build up a list of information I am interested in.</p>
<p>This is then conveniently exposed as an RSS feed by google. You can see my shared items at <a href="http://www.google.co.uk/reader/shared/jim.barritt">http://www.google.co.uk/reader/shared/jim.barritt</a> for example.</p>
<p>I used to have a sidebar on this site which had a snippet directly from google reader, but it was determined to have its own style. I wanted a wordpress plugin that would do it for me and found <a href="http://wordpress.org/extend/plugins/recommended-reading-google-reader-shared/">&#8220;Recommended Reading Google Reader&#8221; by C. Murray Consulting</a></p>
<p>Its the nice &#8220;READING&#8221; section on my sidebar. Thanks guys! You just saved me from writing my own!</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fjimbarritt.com%2Fnon-random%2F2010%2F06%2F06%2Fgoogle-reader-shared-items-plugin-for-wordpress%2F&amp;title=Google%20reader%20%26%238220%3Bshared%20items%26%238221%3B%20plugin%20for%20wordpress"><img src="http://jimbarritt.com/non-random/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://jimbarritt.com/non-random/2010/06/06/google-reader-shared-items-plugin-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Make Fireworks IntelliJ Plugin Ignore Integration Tests</title>
		<link>http://jimbarritt.com/non-random/2010/05/28/make-fireworks-intellij-plugin-ignore-integration-tests/</link>
		<comments>http://jimbarritt.com/non-random/2010/05/28/make-fireworks-intellij-plugin-ignore-integration-tests/#comments</comments>
		<pubDate>Fri, 28 May 2010 10:37:00 +0000</pubDate>
		<dc:creator>Jim Barritt</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://jimbarritt.com/non-random/?p=497</guid>
		<description><![CDATA[http://www.wafermaneuver.com/nick/img/photo/fireworks2.jpg The Fireworks Plugin for IntelliJ allows you to automatically run all your unit tests when you make a change to the code. Its a well behaved plugin, it allows you to configure wether or not to do this so you can just turn it on or off. Whilst using it I made a detour [...]]]></description>
			<content:encoded><![CDATA[<p><img width="400" src="http://www.wafermaneuver.com/nick/img/photo/fireworks2.jpg" /><br />
<code>http://www.wafermaneuver.com/nick/img/photo/fireworks2.jpg</code></p>
<p>The <a href="http://plugins.intellij.net/plugin/?id=1106">Fireworks</a> Plugin for IntelliJ allows you to automatically run all your unit tests when you make a change to the code. </p>
<p>Its a well behaved plugin, it allows you to configure wether or not to do this so you can just turn it on or off. </p>
<p>Whilst using it I made a detour to <a href="http://blog.gigoo.org/2010/05/26/how-can-pomodore-help-you-shave-a-yak/">Shave a couple of Yaks</a>. So thought I&#8217;d document it here.</p>
<p>I found it was also running some integration tests which relied on the file system and so didn&#8217;t work because there doesn&#8217;t appear to be a way to specify the working directory (you can specify JVM args so I could use that instead. I submitted an <a href="http://code.google.com/p/dontmakemetest/issues/detail?id=4">issue</a>. </p>
<p>In the mean time, actually I thought I would rather not run my integration tests. Fortunately Fireworks allows a regex pattern to decide which files are tests.</p>
<p>After some hunting, I found the <a href="http://stackoverflow.com/questions/406230/regular-expression-to-match-string-not-containing-a-word">following post</a> on stack overflow which gave me the clues i needed to include <code>Test</code> but <strong>not</strong> <code>IntegrationTest</code>.</p>
<p>The solution takes advantage of <a href="http://www.regular-expressions.info/lookaround.html">&#8220;lookaround&#8221;</a> features of regex. The syntax in question is:</p>
<pre name='code' class='java:nogutter:nocontrols'>
(?!Integration)
</pre>
<p>The <code>(?!  regex )</code> syntax means negative look ahead. You can put any regex in there. In our case, just &#8220;Integration&#8221;. This says, something not followed by &#8220;Integration&#8221;.</p>
<p>The code on stack overflow had some unnescessary syntax at the beginning (^) and I changed the ordering around a bit to make it read more logically.</p>
<pre name='code' class='java:nogutter:nocontrols'>
(.(?!Integration))*Test
</pre>
<p>The first &#8220;<code>^</code>&#8221; was unnescessary, and putting the &#8220;<code>.</code>&#8221; first made it read better i think. The parentheses are to provide some structure (regex groups) more than any functional reason. </p>
<p>So in words, the new expression reads &#8220;match any repeating character (<code>.*</code>) not followed by &#8220;Integration&#8221; <code>(?!Integration)</code>), then only match if &#8220;Test&#8221; is on the end.</p>
<p>Here is a test case for it (which along with some other regex stuff can be found on <a href="http://github.com/jimbarritt/spikes/tree/master/regex/src/test/unit/java/com/jimbarritt/spikes/regex/">Github</a> :</p>
<pre name='code' class='java:nogutter:nocontrols'>
    @Test
    public void matchesUnitTestsButNotIntegrationTests() {
        String expression = &#8220;(.(?!Integration))*Test&#8221;;
        Pattern pattern = Pattern.compile(expression);
        assertThat(pattern.matcher(&#8220;SomeUnitTest&#8221;).matches(), is(true));
        assertThat(pattern.matcher(&#8220;SomeIntegrationTest&#8221;).matches(), is(false));
        assertThat(pattern.matcher(&#8220;SomeNonTestClass&#8221;).matches(), is(false));
    }
</pre>
<p>I found it hard to get this to work on the command line with grep. But I&#8217;ve got too much YAK HAIR on my floor now!</p>
<p>Now the Yaks are shaved I can go back to putting a system property in to allow my integration test to work.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fjimbarritt.com%2Fnon-random%2F2010%2F05%2F28%2Fmake-fireworks-intellij-plugin-ignore-integration-tests%2F&amp;title=Make%20Fireworks%20IntelliJ%20Plugin%20Ignore%20Integration%20Tests"><img src="http://jimbarritt.com/non-random/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://jimbarritt.com/non-random/2010/05/28/make-fireworks-intellij-plugin-ignore-integration-tests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Link from log console output to a line of code in IntelliJ</title>
		<link>http://jimbarritt.com/non-random/2010/05/16/link-from-log-console-output-to-a-line-of-code-in-intellij/</link>
		<comments>http://jimbarritt.com/non-random/2010/05/16/link-from-log-console-output-to-a-line-of-code-in-intellij/#comments</comments>
		<pubDate>Sun, 16 May 2010 13:47:55 +0000</pubDate>
		<dc:creator>Jim Barritt</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[ides]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[thoughtblog]]></category>

		<guid isPermaLink="false">http://jimbarritt.com/non-random/?p=480</guid>
		<description><![CDATA[Whilst playing around with some code analysis I thought it would be useful to be able to output a hyperlink back to a line of code in the IDE console. As it happens, you can &#8220;Trick&#8221; IntelliJ to do this with the following log statement: The pattern it seems to match is something like at [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://jimbarritt.com/non-random/wp-content/uploads/2010/05/clickfromconsole.gif" rel="lightbox[480]"><img src="http://jimbarritt.com/non-random/wp-content/uploads/2010/05/clickfromconsole.gif" alt="" title="clickfromconsole" width="800"  class="aligncenter size-full wp-image-481" /></a></p>
<p>Whilst playing around with some code analysis I thought it would be useful to be able to output a hyperlink back to a line of code in the IDE console. As it happens, you can &#8220;Trick&#8221; IntelliJ to do this with the following log statement:</p>
<pre name='code' class='java:nogutter:nocontrols'>
    @Test
    public void canClickOnAFileInTheConsoleAndGoToTheLineOfCode() {
        log.info(String.format(&#8220;Check it at %s. (%s.java:%d)&#8221;,
            getClass().getName(), getClass().getSimpleName(), 15));
    }
</pre>
<p>The pattern it seems to match is something like <code>at {classFullName}.{identifier}({classSimpleName}.java)</code></p>
<p><code>classFullName</code> has to be a valid class name.<br />
<code>identifier</code> is usually used for the method name, but it can be anything. The full stop is nescessary. So in the example above, I put a space in there and so it reads like a sentance.</p>
<p>Anyone know a another way to do this?</p>
<p>UPDATE: </p>
<p>Actually it seems that you can get something similar if you output a full path name, e.g.:</p>
<pre name='code' class='java:nogutter:nocontrols'>
    File f = new File(&#8220;./src/test/resource/testfiles/level_01/level_01_01/file_01_01_A.txt&#8221;);
    log.info(f.getAbsolutePath() + &#8220;:&#8221; + 34);
</pre>
<p>This will create a link in the output window to the line of the file. Nice.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fjimbarritt.com%2Fnon-random%2F2010%2F05%2F16%2Flink-from-log-console-output-to-a-line-of-code-in-intellij%2F&amp;title=Link%20from%20log%20console%20output%20to%20a%20line%20of%20code%20in%20IntelliJ"><img src="http://jimbarritt.com/non-random/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://jimbarritt.com/non-random/2010/05/16/link-from-log-console-output-to-a-line-of-code-in-intellij/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

