<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

	<title>Progriff</title>
	<link href="http://progriff.com/atom.xml" rel="self" type="application/atom+xml" />
	<link href="http://progriff.com/" rel="alternate" type="text/html" />
	<id>http://progriff.com/</id>
	<icon>http://progriff.com/images/favicon.png</icon>
	<updated>2012-02-14T22:14:12+11:00</updated>
	<author>
		<name>Benson Lim</name>
	</author>

	
		<entry>
			<title type="html">BatchJHaml Update</title>
			<link href="http://progriff.com/2012/02/14/batchjhaml-update.html" rel="alternate" type="text/html" />
			<published>2012-02-14T00:00:00+11:00</published>
			<updated>2012-02-14T00:00:00+11:00</updated>
			<id>http://progriff.com/2012/02/14/batchjhaml-update</id>
			<content type="html" xml:base="http://progriff.com/2012/02/14/batchjhaml-update">&lt;h2&gt;
  BatchJHaml Update
&lt;/h2&gt;




&lt;h3&gt;14 February 2012&lt;/h3&gt;


&lt;p&gt;I've updated &lt;a href=&quot;https://github.com/pugnusferreus/batchjhaml&quot;&gt;BatchJHaml&lt;/a&gt; to support sub directories.
If you set the last argument to true, it'll generate the Haml file in subdirectories as well.
Do note that the layout folder will be omitted.&lt;/p&gt;

&lt;p&gt;Here is a sample from my build.xml&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;xml&quot;&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;target&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;run&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;java&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;fork=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;true&amp;quot;&lt;/span&gt; 
    &lt;span class=&quot;na&quot;&gt;classname=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;com.progriff.jhaml.BatchJHaml&amp;quot;&lt;/span&gt; 
    &lt;span class=&quot;na&quot;&gt;outputproperty=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;javaoutput&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;classpath&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;path&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;refid=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;classpath&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;path&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;location=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;${dist}/BatchJHaml.jar&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/classpath&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;arg&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;${haml.path}&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;arg&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;${haml.layout.path}&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;arg&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;${haml.output.path}&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;arg&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;${haml.output.extension}&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;arg&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;${haml.javascript.path}&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;arg&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;${haml.stylesheet.path}&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;arg&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;${haml.recursive}&amp;quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/java&amp;gt;&amp;lt;echo&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;message=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;${javaoutput}&amp;quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/target&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;For example if you have the following in your haml folder,&lt;/p&gt;

&lt;pre class=&quot;text&quot;&gt;
haml
  |-- someDir
        `- baz.haml
  `foo.haml
  `- bar.haml
&lt;/pre&gt;


&lt;p&gt;The resulting jsp folder will look like this&lt;/p&gt;

&lt;pre class=&quot;text&quot;&gt;
jsp
  |-- someDir
        `- baz.jsp
  `foo.jsp
  `- bar.jsp
&lt;/pre&gt;

</content>
		</entry>
	
		<entry>
			<title type="html">Resin 3.1 and Azure SDK for Java</title>
			<link href="http://progriff.com/2012/02/08/resin-azure-sdk-for-java.html" rel="alternate" type="text/html" />
			<published>2012-02-08T00:00:00+11:00</published>
			<updated>2012-02-08T00:00:00+11:00</updated>
			<id>http://progriff.com/2012/02/08/resin-azure-sdk-for-java</id>
			<content type="html" xml:base="http://progriff.com/2012/02/08/resin-azure-sdk-for-java">&lt;h2&gt;
  Resin 3.1 and Azure SDK for Java
&lt;/h2&gt;




&lt;h3&gt;08 February 2012&lt;/h3&gt;


&lt;p&gt;I was writing a REST service that will send a Cloud Queue Message to Azure.
After testing my utility class with JUnit, it passed.
However, when I tried to send a Cloud Queue Message via REST service (hosted in Resin 3.1), I got the following error:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;java&quot;&gt;&lt;span class=&quot;n&quot;&gt;java&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;lang&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;IllegalArgumentException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;property&lt;/span&gt; 
  &lt;span class=&quot;s&quot;&gt;&amp;quot;javax.xml.stream.isReplacingEntityReferences&amp;quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;supported&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;caucho&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;xml&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;stream&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;XMLInputFactoryImpl&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setProperty&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;XMLInputFactoryImpl&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;java&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;265&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;microsoft&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;windowsazure&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;services&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;core&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;storage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;utils&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;Utility&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;createXMLStreamReaderFromStream&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Utility&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;java&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;321&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Resin Web Server uses it's own &lt;code&gt;XMLInputFactory&lt;/code&gt; implementation called &lt;code&gt;com.caucho.xml.stream.XMLInputFactoryImpl&lt;/code&gt;.
According to this &lt;a href=&quot;http://www.caucho.com/resin-3.1/doc/jaxp.xtp&quot;&gt;article&lt;/a&gt;, you can override the
implementation by having &lt;code&gt;&amp;lt;system-property/&amp;gt;&lt;/code&gt; following in your &lt;code&gt;resin.conf&lt;/code&gt;.
Put the following to use the JDK's version of XMLInputFactoryImpl&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;xml&quot;&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;system-property&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;javax.xml.stream.XMLInputFactory=&lt;/span&gt;
  &lt;span class=&quot;s&quot;&gt;&amp;quot;com.sun.xml.internal.stream.XMLInputFactoryImpl&amp;quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Problem solved? Not really. Tried running the REST service again and I got the following:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;java&quot;&gt;&lt;span class=&quot;n&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;microsoft&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;windowsazure&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;services&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;core&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;storage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;StorageException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; 
  &lt;span class=&quot;n&quot;&gt;XML&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;specified&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;syntactically&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;valid&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;After looking at the Azure SDK for Java's &lt;a href=&quot;https://github.com/WindowsAzure/azure-sdk-for-java&quot;&gt;source&lt;/a&gt;,
I've found out that the XMLOutputFactory and XMLStreamWriter was unable to generate the XML request body in
&lt;code&gt;com.microsoft.windowsazure.services.queue.client
  .QueueRequest.generateMessageRequestBody&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Why? If you do a simple system out on the class name, resin is using it's own implementation
for XMLOutputFactory and XMLStreamWriter.
So add the following as well into your resin.conf&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;xml&quot;&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;system-property&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;javax.xml.stream.XMLOutputFactory=&lt;/span&gt;
  &lt;span class=&quot;s&quot;&gt;&amp;quot;com.sun.xml.internal.stream.XMLOutputFactoryImpl&amp;quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;system-property&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;javax.xml.stream.XMLStreamWriter=&lt;/span&gt;
  &lt;span class=&quot;s&quot;&gt;&amp;quot;com.sun.xml.internal.stream.writers.XMLStreamWriterImpl&amp;quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;tl;dr? Add the following in your resin.conf&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;xml&quot;&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;system-property&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;javax.xml.stream.XMLInputFactory=&lt;/span&gt;
  &lt;span class=&quot;s&quot;&gt;&amp;quot;com.sun.xml.internal.stream.XMLInputFactoryImpl&amp;quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;system-property&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;javax.xml.stream.XMLOutputFactory=&lt;/span&gt;
  &lt;span class=&quot;s&quot;&gt;&amp;quot;com.sun.xml.internal.stream.XMLOutputFactoryImpl&amp;quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;system-property&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;javax.xml.stream.XMLStreamWriter=&lt;/span&gt;
  &lt;span class=&quot;s&quot;&gt;&amp;quot;com.sun.xml.internal.stream.writers.XMLStreamWriterImpl&amp;quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;After that, my code works perfectly. I'm sure there are other weird problems as well,
I'll keep you posted if I've found anymore weird stuff.&lt;/p&gt;
</content>
		</entry>
	
		<entry>
			<title type="html">Hibernate won't update my object!</title>
			<link href="http://progriff.com/2012/01/06/hibernate-wont-update.html" rel="alternate" type="text/html" />
			<published>2012-01-06T00:00:00+11:00</published>
			<updated>2012-01-06T00:00:00+11:00</updated>
			<id>http://progriff.com/2012/01/06/hibernate-wont-update</id>
			<content type="html" xml:base="http://progriff.com/2012/01/06/hibernate-wont-update">&lt;h2&gt;
  Hibernate won't update my object!
&lt;/h2&gt;




&lt;h3&gt;06 January 2012&lt;/h3&gt;


&lt;p&gt;Yesterday, I was given a Hibernate related bug to fix.
We have an object, say object A which has a list of object B.
This list of object B are stored as a JSON string in table A.&lt;/p&gt;

&lt;p&gt;So here's the problem, after calling a &lt;code&gt;session.update&lt;/code&gt; on object A with the updated object B,
the change was not persisted into the database.
After hours of Googling and some help from Michael who is a fellow colleague of mine, I found the problem.&lt;/p&gt;

&lt;p&gt;According to this &lt;a href=&quot;http://stackoverflow.com/questions/4293768/does-hibernate-update-an-entity-that-has-not-changed&quot;&gt;article&lt;/a&gt;,
Hibernate will only do a &lt;code&gt;UPDATE&lt;/code&gt; statement after &lt;code&gt;session.flush()&lt;/code&gt;.
During this operation, Hibernate will compare the original object and the object to be updated.&lt;/p&gt;

&lt;p&gt;This &lt;a href=&quot;http://blog.xebia.com/2009/11/09/understanding-and-writing-hibernate-user-types/&quot;&gt;article&lt;/a&gt; explains
how Hibernate compares the object.&lt;/p&gt;

&lt;p&gt;The fix? In your Hibernate user type, override the &lt;code&gt;deepCopy&lt;/code&gt; and return another instance of list.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;java&quot;&gt;&lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Object&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;deepCopy&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Object&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;throws&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;HibernateException&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

  &lt;span class=&quot;c1&quot;&gt;// if value is null, return null&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;c1&quot;&gt;// convert the value to a List first&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ObjectB&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;objectBList&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ObjectB&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;c1&quot;&gt;// create a new Arraylist and add all the objects&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ObjectB&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;newObjectBList&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ArrayList&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ObjectB&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;();&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ObjectB&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;objectB&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;objectBList&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;newObjectBList&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;objectB&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;newObjectBList&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;



</content>
		</entry>
	
		<entry>
			<title type="html">Normalize your video with FFmpeg</title>
			<link href="http://progriff.com/2011/10/22/normalize-your-video-with-ffmpeg.html" rel="alternate" type="text/html" />
			<published>2011-10-22T00:00:00+11:00</published>
			<updated>2011-10-22T00:00:00+11:00</updated>
			<id>http://progriff.com/2011/10/22/normalize-your-video-with-ffmpeg</id>
			<content type="html" xml:base="http://progriff.com/2011/10/22/normalize-your-video-with-ffmpeg">&lt;h2&gt;
  Normalize your video with FFmpeg
&lt;/h2&gt;




&lt;h3&gt;22 October 2011&lt;/h3&gt;


&lt;p&gt;It's been a while since I've updated my blog. I didn't encounter any weird things until last week.&lt;/p&gt;

&lt;p&gt;At Movideo, we've been haunted by videos that goes out of sync with it's audio.
The symptom goes something like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Plays a dynamic bitrate video that was encoded using Movideo's Encoder application.&lt;/li&gt;
&lt;li&gt;In the beginning, audio and video is in sync.&lt;/li&gt;
&lt;li&gt;A crackling noise appeared and then the audio and video goes out of sync.&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;We've decided to use &lt;a href=&quot;http://www.mplayerhq.hu/DOCS/HTML/en/mencoder.html&quot;&gt;MEncoder&lt;/a&gt; to normalize
the original video which is in .mov format.&lt;/p&gt;

&lt;p&gt;The command&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;mencoder -ovc copy -af &lt;span class=&quot;nv&quot;&gt;volnorm&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;1 -oac libmp3lame input.mov -o output.mov
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;creates a mov file
which Quick Time won't recognize at all. Tried viewing it with Windows Media Player and there's audio but no video.
After that, I upload the video via Movideo's Admin interface. The re-encoded video still goes out of sync.&lt;/p&gt;

&lt;p&gt;The solution to this is to re-encode the audio with FFmpeg with&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;ffmpeg -i input.mov -vcodec copy -acodec libmp3lame output.mov
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Now, output.mov can be viewed by Quick Time and works fine on Windows Media Player.
Then, I tried uploading the output.mov via Movideo's Admin interface and the video doesn't go out of sync anymore.&lt;/p&gt;
</content>
		</entry>
	
		<entry>
			<title type="html">Generating JSPs With BatchJHaml</title>
			<link href="http://progriff.com/2011/07/10/generating-jsp-with-batchjhaml.html" rel="alternate" type="text/html" />
			<published>2011-07-10T00:00:00+10:00</published>
			<updated>2011-07-10T00:00:00+10:00</updated>
			<id>http://progriff.com/2011/07/10/generating-jsp-with-batchjhaml</id>
			<content type="html" xml:base="http://progriff.com/2011/07/10/generating-jsp-with-batchjhaml">&lt;h2&gt;
  Generating JSPs With BatchJHaml
&lt;/h2&gt;




&lt;h3&gt;10 July 2011&lt;/h3&gt;


&lt;p&gt;Last year, I was assigned to build a web app using &lt;a href=&quot;http://struts.apache.org/&quot;&gt;Struts&lt;/a&gt;.
I wanted a Haml interpreter and found &lt;a href=&quot;https://github.com/raymyers/JHaml&quot;&gt;JHaml&lt;/a&gt;.
The problem is it only converts Haml strings to HTML. I need something to convert .haml files to .html or .jsp files.
Why should you use Haml? See &lt;a href=&quot;http://haml-lang.com/&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Due to this limitation, I created &lt;a href=&quot;https://github.com/pugnusferreus/batchjhaml&quot;&gt;BatchJHaml&lt;/a&gt;.
If you're using BatchJHaml as a standalone app, it's pretty straight forward.
But what if you want to include BatchJHaml into your Ant build script?
Here's what you need to do.&lt;/p&gt;

&lt;p&gt;1.) Run &lt;code&gt;git clone git@github.com:pugnusferreus/batchjhaml.git&lt;/code&gt; in your terminal&lt;/p&gt;

&lt;p&gt;2.) cd to BatchJHaml&lt;/p&gt;

&lt;p&gt;3.) Run &lt;code&gt;ant&lt;/code&gt; and &lt;code&gt;BatchJHaml.jar&lt;/code&gt; will appear in the &lt;code&gt;dist&lt;/code&gt; directory.&lt;/p&gt;

&lt;p&gt;4.) Copy and paste &lt;code&gt;BatchJHaml.jar&lt;/code&gt; in your local lib directory.&lt;/p&gt;

&lt;p&gt;5.) Copy the following into your local lib directory as well. You can find them in the &lt;code&gt;BatchJHaml/lib&lt;/code&gt; folder.
If you already have the following, you can ommit this step.
If you have a later version of the following jars, you can use them as well.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;commons-io-1.4.jar&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;commons-lang-2.5.jar&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;guava-r06.jar&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;jhaml-0.1.2.jar&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;markdownj-1.0.2b4-0.3.0.jar&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;6.) Copy the following build target into your build.xml&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;xml&quot;&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;target&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;compile-haml&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;echo&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;message=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;Converting haml files into jsp ...&amp;quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;java&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;fork=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;true&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;classname=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;com.progriff.jhaml.BatchJHaml&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;classpath&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;fileset&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;dir=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;${library.home}&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;include&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;**/commons-io-*.jar&amp;quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;include&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;**/commons-lang-*.jar&amp;quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;include&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;**/guava-*.jar&amp;quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;include&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;**/jhaml-*.jar&amp;quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;include&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;**/markdownj-*.jar&amp;quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;/fileset&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;path&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;location=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;${library.home}/BatchJHaml.jar&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/classpath&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;arg&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;~/YourProject/haml&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;arg&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;~/YourProject/haml/layouts&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;arg&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;~/YourProject/jsp&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;arg&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;jsp&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;arg&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;~/YourProject/javascripts&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;arg&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;~/YourProject/stylesheets&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/java&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/target&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;7.) In your &lt;code&gt;build&lt;/code&gt; target, add &lt;code&gt;compile-haml&lt;/code&gt; to your &lt;code&gt;depends&lt;/code&gt;. Example:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;xml&quot;&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;target&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;build&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;depends=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;clean, prepare,compile, compile-haml&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;And enjoy your Haml.&lt;/p&gt;
</content>
		</entry>
	
		<entry>
			<title type="html">Modernizing Lunchpicker Part 2</title>
			<link href="http://progriff.com/2011/07/09/modernizing-lunchpicker-pt2.html" rel="alternate" type="text/html" />
			<published>2011-07-09T00:00:00+10:00</published>
			<updated>2011-07-09T00:00:00+10:00</updated>
			<id>http://progriff.com/2011/07/09/modernizing-lunchpicker-pt2</id>
			<content type="html" xml:base="http://progriff.com/2011/07/09/modernizing-lunchpicker-pt2">&lt;h2&gt;
  Modernizing Lunchpicker Part 2
&lt;/h2&gt;




&lt;h3&gt;9 July 2011&lt;/h3&gt;


&lt;p&gt;When I wrote lunchpicker, I was obviously not yet enlightened with &lt;a href=&quot;http://en.wikipedia.org/wiki/Test-driven_development&quot;&gt;TDD&lt;/a&gt;.
While migrating lunchpicker from Rails 2 to Rails 3, I took the opportunity to learn &lt;a href=&quot;http://rspec.info/&quot;&gt;RSpec&lt;/a&gt;.
So again, here is my journey with RSpec. Since lunchpicker is a Rails app, I'll be using &lt;a href=&quot;http://rspec.info/rails/&quot;&gt;rspec-rails&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;1.) Some stuff from the Sass plugin has been deprecated in Rails3.
Remove the plugin by removing the directory in vendor/plugins and add &lt;code&gt;https://github.com/jasoncodes/hassle.git&lt;/code&gt; in your Gemfile.&lt;/p&gt;

&lt;p&gt;2.) Move &lt;code&gt;filter_parameter_logging&lt;/code&gt; in &lt;code&gt;application_controller.rb&lt;/code&gt; to &lt;code&gt;/config/application.rb&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;3.) Remove the test folder because we'll be using Rspec&lt;/p&gt;

&lt;p&gt;4.) Add the following lines into your Gemfile. These gems should be loaded in Dev and Testing environments only.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&lt;span class=&quot;n&quot;&gt;group&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:development&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:test&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;rspec-rails&amp;#39;&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;spork&amp;#39;&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;awesome_print&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:require&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;ap&amp;#39;&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;mocha&amp;#39;&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;shoulda&amp;#39;&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;vcr&amp;#39;&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;webmock&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:require&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;kp&quot;&gt;false&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;5.) Run &lt;code&gt;bundle install&lt;/code&gt; and then run &lt;code&gt;rails g rspec:install&lt;/code&gt;.
This will create the rspec folder and the rake file to create a test database.&lt;/p&gt;

&lt;p&gt;6.) The structure of your &lt;code&gt;spec/&lt;/code&gt; directory should mirror that of &lt;code&gt;app/&lt;/code&gt;.
For example, the spec file for &lt;code&gt;app/models/location.rb&lt;/code&gt; would be &lt;code&gt;spec/models/location_spec.rb&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;7.) Create your rspec test! Need example? See &lt;a href=&quot;https://github.com/pugnusferreus/lunchpicker/tree/master/spec&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;8.) Now, in the lunchpicker directory, type &lt;code&gt;bundle exec rspec spec&lt;/code&gt;.
This will run the tests. Since we're testing the controllers and models, rspec would need to bootstrap all the Rails stuff.
The result? Slowness.&lt;/p&gt;

&lt;p&gt;9.) To overcome this, we'll be using spork to bootstrap the Rails libraries.
Open another terminal window and &lt;code&gt;cd&lt;/code&gt; to the lunchpicker folder.
Type in &lt;code&gt;bundle exec spork rspec&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;10.) Open another window and &lt;code&gt;cd&lt;/code&gt; into the lunchpicker folder.
Type in &lt;code&gt;bundle exec rspec --drb spec&lt;/code&gt;.
Notice that the tests run faster.
If you change any Rails related config, remember to restart spork.&lt;/p&gt;

&lt;p&gt;What's VCR? VCR records your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests.
We're interacting with Google Weather which is an external API.&lt;/p&gt;

&lt;p&gt;ps. &lt;a href=&quot;http://lunch.progriff.com&quot;&gt;lunchpicker&lt;/a&gt; is now Rails 3&lt;/p&gt;
</content>
		</entry>
	
		<entry>
			<title type="html">Modernizing Lunchpicker</title>
			<link href="http://progriff.com/2011/06/26/modernizing-lunchpicker.html" rel="alternate" type="text/html" />
			<published>2011-06-26T00:00:00+10:00</published>
			<updated>2011-06-26T00:00:00+10:00</updated>
			<id>http://progriff.com/2011/06/26/modernizing-lunchpicker</id>
			<content type="html" xml:base="http://progriff.com/2011/06/26/modernizing-lunchpicker">&lt;h2&gt;
  Modernizing Lunchpicker
&lt;/h2&gt;




&lt;h3&gt;26 June 2011&lt;/h3&gt;


&lt;p&gt;Lunchpicker is my first project with Rails. Back then, there was alot of hype regarding Rails and that was why I started Lunchpicker
to have a taste of Ruby On Rails. Yes, I fell in love with it immediately.&lt;/p&gt;

&lt;p&gt;Wife had some plans for the entire afternoon and I've decided to dedicate my entire Saturday afternoon on migrating Lunchpicker from Rails 2 to Rails 3.
Here's a blog post on my adventure. Thanks &lt;a href=&quot;http://twitter.com/#!/jasoncodes&quot;&gt;@jasoncodes&lt;/a&gt; for helping!&lt;/p&gt;

&lt;p&gt;1 . Install &lt;a href=&quot;https://rvm.beginrescueend.com/&quot;&gt;RVM&lt;/a&gt;.
RVM allows you to install, manage and work with multiple ruby environments.
For example, you can have project A running in Ruby 1.8.x and project B running in Ruby 1.9.x&lt;/p&gt;

&lt;p&gt;2 . For lunchpicker, here is my .rvmrc file&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;    &lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;cat .rvmrc
    rvm --create 1.9.2@lunchpicker
    
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;3 . Now, we need to intall Bundler.
Bundler manages your application's dependencies via Gemfile.
Here's a sample of lunchpicker's Gemfile&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&lt;span class=&quot;n&quot;&gt;source&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;http://rubygems.org&amp;#39;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;rails&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;3.0.9&amp;#39;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;google_weather&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:git&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;http://github.com/Ennova/google-weather.git&amp;#39;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;informal&amp;#39;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;haml&amp;#39;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;httparty&amp;#39;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;authlogic&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:git&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;http://github.com/radar/authlogic.git&amp;#39;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;pg&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:require&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;pg&amp;#39;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;sass&amp;#39;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;dynamic_form&amp;#39;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;4 . After creating a Gemfile, run &lt;code&gt;gem install bundler&lt;/code&gt; and then run &lt;code&gt;bundle intall&lt;/code&gt; to install all the dependencies in your rvm.&lt;/p&gt;

&lt;p&gt;5 . Go into the lunchpicker directory and run &lt;code&gt;rails new .&lt;/code&gt;.
It'll obviously overwrite your old configurations with Rails 3's. Replace all the files.&lt;/p&gt;

&lt;p&gt;6 . Do a diff and merge all your codes (controllers, models, js, css, haml etc.)&lt;/p&gt;

&lt;p&gt;7 . Remove config/initializers/new_rails_defaults.rb&lt;/p&gt;

&lt;p&gt;8 . Remove scaffold related html from the &lt;code&gt;public&lt;/code&gt; folder&lt;/p&gt;

&lt;p&gt;9 . In your helpers, mark your HTML fragements as safe. For example you should change&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;-&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;HTML&lt;/span&gt;
&lt;span class=&quot;sh&quot;&gt;  &amp;lt;p&amp;gt;&lt;/span&gt;
&lt;span class=&quot;sh&quot;&gt;    blah&lt;/span&gt;
&lt;span class=&quot;sh&quot;&gt;  &amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;HTML&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;to&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;-&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;HTML&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;html_safe&lt;/span&gt;
&lt;span class=&quot;sh&quot;&gt;  &amp;lt;p&amp;gt;&lt;/span&gt;
&lt;span class=&quot;sh&quot;&gt;    blah&lt;/span&gt;
&lt;span class=&quot;sh&quot;&gt;  &amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;HTML&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;10 . If you have a non ActiveRecord model, and if you're using Validatable, change it to &lt;a href=&quot;https://github.com/joshsusser/informal&quot;&gt;Informal&lt;a/&gt;.
For Lunchpicker, search.rb is not an ActiveRecord model.
Also, we need to change&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&lt;span class=&quot;n&quot;&gt;validates_presence_of&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:sheltered&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;to&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&lt;span class=&quot;n&quot;&gt;validates_inclusion_of&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:sheltered&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:in&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kp&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kp&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;We're using validate inclusion rather than presence for booleans. This is due to the way Object#blank? handles boolean values. false.blank? # =&gt; true&lt;/p&gt;

&lt;p&gt;11 . Add the following lines to config/application.rb. This will prefix the tablename infront of the PK. eg. venue_id&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&lt;span class=&quot;n&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;active_record&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;primary_key_prefix_type&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:table_name_with_underscore&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;active_record&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;schema_format&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:sql&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;12 . default.html.haml has been changed to application.html.haml in Rails 3.
Run &lt;code&gt;git mv default.html.haml application.html.haml&lt;/code&gt; and don't forget to remove the application.html.erb as well.&lt;/p&gt;

&lt;p&gt;13 . Switch rails.js from Prototype to jQuery. Remove controls.js, dragdrop.js, effect.js and prototype.js. Please see
&lt;a href=&quot;https://github.com/pugnusferreus/lunchpicker/blob/0e278acf24d1764d03c8ededa02e364da7c1c409/public/javascripts/rails.js&quot;&gt;rails.js&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;14 . Add rails.js in the application.html.haml for Unobtrusive Javascript support.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;javascript_include_tag&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;rails&amp;#39;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;15 . If you run &lt;code&gt;rake db:migrate&lt;/code&gt; before step 11, run &lt;code&gt;rake db:reset&lt;/code&gt; and then &lt;code&gt;rake db:migrate&lt;/code&gt; again.&lt;/p&gt;

&lt;p&gt;I hope that this will be useful to you if you need to migrate any old Rails 2 application to Rails 3.
I'll use this opportunity to add unit test with RSpec.&lt;/p&gt;

&lt;p&gt;The Rails 3 version of lunch picker won't be in production till unit test is done!&lt;/p&gt;
</content>
		</entry>
	
		<entry>
			<title type="html">Mocking with Mockito</title>
			<link href="http://progriff.com/2011/06/18/mocking-with-mockito.html" rel="alternate" type="text/html" />
			<published>2011-06-18T00:00:00+10:00</published>
			<updated>2011-06-18T00:00:00+10:00</updated>
			<id>http://progriff.com/2011/06/18/mocking-with-mockito</id>
			<content type="html" xml:base="http://progriff.com/2011/06/18/mocking-with-mockito">&lt;h2&gt;
  Mocking with Mockito
&lt;/h2&gt;




&lt;h3&gt;18 June 2011&lt;/h3&gt;


&lt;p&gt;At movideo, we're using &lt;a href=&quot;http://mockito.org/&quot;&gt;Mockito&lt;/a&gt; as our mocking framework.
Mockito provides a clean and simple API to mock your Java objects.&lt;/p&gt;

&lt;p&gt;Let's say Class1 has a couple of arguments for it's constructor and you do not want to provide each arguments,
you can simply do:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;java&quot;&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;org&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;mockito&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;Mockito&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;mock&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;then, you do&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;java&quot;&gt;&lt;span class=&quot;n&quot;&gt;Class1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;class1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mock&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Class1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;If you want to mock a certain method call in class1, do the following:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;java&quot;&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;org&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;mockito&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;Mockito&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;when&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;org&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;junit&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;Assert&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;assertEquals&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;then, you do&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;java&quot;&gt;&lt;span class=&quot;n&quot;&gt;when&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;class1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;methodReturnsString&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;thenReturn&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;foo&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;assertEquals&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;foo&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;class2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;callClass1Method&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Assuming that&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;java&quot;&gt; &lt;span class=&quot;n&quot;&gt;class2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;callClass1Method&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt; will call&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;java&quot;&gt; &lt;span class=&quot;n&quot;&gt;class1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;methodReturnsString&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;the assertion will be successful.&lt;/p&gt;

&lt;p&gt;To get a better picture of what Mockito can do for you, you can checkout my Mockito Test project
from my &lt;a href=&quot;https://github.com/pugnusferreus/mockito_test&quot;&gt;Github Sample Project&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I'll assume that you have Git, Java 1.6 and Ant installed on your machine.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;git clone https://github.com/pugnusferreus/mockito_test&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;cd mockito_test&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ant&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Open docs/unitTest/index.html in your browser&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;You can see that all the unit tests pass.&lt;/p&gt;

&lt;p&gt;Thanks &lt;a href=&quot;http://twitter.com/#!/cstrzadala&quot;&gt;@cstrzadala&lt;/a&gt; for introducing Mockito to all of us!&lt;/p&gt;
</content>
		</entry>
	
		<entry>
			<title type="html">Unit Test Your Java DAO With Hibernate And HSQL DB</title>
			<link href="http://progriff.com/2011/06/05/unit-test-your-java-dao-with-hibernate-and-hsql.html" rel="alternate" type="text/html" />
			<published>2011-06-05T00:00:00+10:00</published>
			<updated>2011-06-05T00:00:00+10:00</updated>
			<id>http://progriff.com/2011/06/05/unit-test-your-java-dao-with-hibernate-and-hsql</id>
			<content type="html" xml:base="http://progriff.com/2011/06/05/unit-test-your-java-dao-with-hibernate-and-hsql">&lt;h2&gt;
  Unit Test Your Java DAO With Hibernate And HSQL DB
&lt;/h2&gt;




&lt;h3&gt;05 June 2011&lt;/h3&gt;


&lt;p&gt;Unlike Rails which allow you to do unit test on your models, there's no easy way to actually unit test your Java DAO.
Sometimes, we do not have access to the development database or we do not want to polute the development database with our data.&lt;/p&gt;

&lt;p&gt;Sure, we could run a local db on our machine.
What happen if it's a huge RDBMS like Oracle or DB2?
Yes, the previous sentence sounds enterprisey but as a Java developer, you can't get away with enterprisey things.&lt;/p&gt;

&lt;p&gt;Take a look at this sample &lt;a href=&quot;https://github.com/pugnusferreus/dao_unit_test&quot;&gt;project&lt;/a&gt;.
Assuming that your current project is using Hibernate as your ORM, you can use &lt;a href=&quot;http://hsqldb.org/&quot;&gt;HSQL DB&lt;/a&gt; to load up a &quot;in memory&quot; database for your unit test.
Hibernate and hsql will automatically creates the table for you.&lt;/p&gt;

&lt;p&gt;Here's how. I'll assume that you have Git, Java 1.6 (or whatever it's called now) and Ant installed on your machine.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;git clone https://github.com/pugnusferreus/dao_unit_test&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;cd dao_unit_test&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ant&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Open docs/unitTest/index.html in your browser&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;You can see that all the unit tests pass.&lt;/p&gt;

&lt;p&gt;Make sure that your hibernate config points to the HSQL DB and your model is mapped.
Open up &quot;com.progriff.dao.UserDaoTest&quot; and you can see that it's your typical Java Unit Test&lt;/p&gt;
</content>
		</entry>
	
		<entry>
			<title type="html">Things to do before you start programming</title>
			<link href="http://progriff.com/2011/05/23/things-to-do-before-you-start-programming.html" rel="alternate" type="text/html" />
			<published>2011-05-23T00:00:00+10:00</published>
			<updated>2011-05-23T00:00:00+10:00</updated>
			<id>http://progriff.com/2011/05/23/things-to-do-before-you-start-programming</id>
			<content type="html" xml:base="http://progriff.com/2011/05/23/things-to-do-before-you-start-programming">&lt;h2&gt;
  Things to do before you start programming
&lt;/h2&gt;




&lt;h3&gt;23 May 2011&lt;/h3&gt;


&lt;p&gt;I've been reading &lt;a href=&quot;http://pragprog.com/titles/ahptl/pragmatic-thinking-and-learning&quot;&gt;Pragmatic Thinking &amp;amp; Learning&lt;/a&gt; by Andy Hunt.
In one of the chapters, the author talks about UML. Yes, even I myself find that UML can get a bit boring. He suggests that I literally draw out
the diagram. And so I did. The author also suggests that you can do the same with Lego bricks or by role playing, but I won't go into that.&lt;/p&gt;

&lt;p&gt;At &lt;a href=&quot;http://www.movideo.com&quot;&gt;movideo&lt;/a&gt;, I've been assigned to make a program that runs on the server and upload videos to YouTube. In the future
we might externally syndicate our videos to another provider (eg. Vimeo). So, I come up with
&lt;a href=&quot;/images/external_syndication.png&quot;&gt;this&lt;/a&gt; diagram to see how it can aid me with my software development process.&lt;/p&gt;

&lt;p&gt;This diagram actually helped me by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Acting as a check list&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Making Test-driven Development(TDD) easier. Why? By looking at this diagram, you'll be able to see the hollistic picture. By having a hollistic picture of the entire application that you're about to write, it's easier for you to write unit test for it's expected behaviour&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Writing pseudo codes. I don't actually write pseudocode à la COBOL era, but for every function that I write, I'll write comments of the things that I need to do.For example:&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;java&quot;&gt;    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;c1&quot;&gt;// do validation&lt;/span&gt;
      
      &lt;span class=&quot;c1&quot;&gt;// check if record exists&lt;/span&gt;
      
      &lt;span class=&quot;c1&quot;&gt;// save to database   &lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
  
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Most importantly, before you start scribbling, get away from your computer. Computers can be distracting at times (emails, IM, Twitter). You'll be able to see a hollistic view without those distractions.&lt;/p&gt;
</content>
		</entry>
	
		<entry>
			<title type="html">How to install jekyll</title>
			<link href="http://progriff.com/2011/05/18/how-to-install-jekyll.html" rel="alternate" type="text/html" />
			<published>2011-05-18T00:00:00+10:00</published>
			<updated>2011-05-18T00:00:00+10:00</updated>
			<id>http://progriff.com/2011/05/18/how-to-install-jekyll</id>
			<content type="html" xml:base="http://progriff.com/2011/05/18/how-to-install-jekyll">&lt;h2&gt;
  How to install jekyll
&lt;/h2&gt;




&lt;h3&gt;18 May 2011&lt;/h3&gt;


&lt;p&gt;This is my first blog post entry for progriff.com. Since this blog was made with &lt;a href=&quot;https://github.com/mojombo/jekyll&quot;&gt;Jekyll&lt;/a&gt;, I'll walk you through how to setup a basic blog with Jekyll. Why Jekyll? Here are a couple of points I could think of :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It generates static pages for you.&lt;/li&gt;
&lt;li&gt;You do not need a database in your server&lt;/li&gt;
&lt;li&gt;You do not need a webserver (Apache, IIS, etc ...)&lt;/li&gt;
&lt;li&gt;Without all those mumbo jumbo on your server, your server will be more secure&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Here's how:&lt;/p&gt;

&lt;p&gt;1 . First, install Jekyll&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;    &lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo gem install jekyll
    
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;2 . Then install rdiscount&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;    &lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo gem install rdiscount
    
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;3 . Make a directory. Let's call it blog.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;    &lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;mkdir blog
    &lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;blog
    
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;4 . Create the directory structure as of below.&lt;/p&gt;

&lt;pre class=&quot;text&quot;&gt;
      blog
        |-- _layouts
                `-- default.html
                `-- post.html
        |-- _posts
           `-- 2011-05-18-foo-bar.md
        |-- _site
        |-- css
        `-- index.html
        `-- _config.yml
    
&lt;/pre&gt;


&lt;p&gt;5 . This is optional. If you need code syntax highlighting, you'll need Pygment.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;    &lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sudo easy_install Pygments
    &lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;pygmentize -S default -f html &amp;gt; /path/to/your/blog/css/pygment.css
    
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;6 . Take a look at the &lt;a href=&quot;https://github.com/pugnusferreus/progriff_blog&quot;&gt;source&lt;/a&gt; for this blog and copy whatever you need.&lt;/p&gt;

&lt;p&gt;7 . After you're done, you want to preview your blog. In your terminal, type&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;    &lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;jekyll --server --auto
    
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;8 . Go to your browser and go to &quot;http://localhost:4000&quot;&lt;/p&gt;

&lt;p&gt;9 . If you need to compile the pages without starting the server, just type &quot;jekyll&quot;&lt;/p&gt;
</content>
		</entry>
	

</feed>
