<?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>Goldin++</title>
	<atom:link href="http://evgeny-goldin.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://evgeny-goldin.com/blog</link>
	<description>args.each{ println it }</description>
	<lastBuildDate>Sat, 03 Dec 2011 02:53:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>&#8220;UI/UX and Continuous Deployment&#8221; video</title>
		<link>http://evgeny-goldin.com/blog/ui-continuous-deployment/</link>
		<comments>http://evgeny-goldin.com/blog/ui-continuous-deployment/#comments</comments>
		<pubDate>Sat, 03 Dec 2011 02:03:48 +0000</pubDate>
		<dc:creator>Evgeny Goldin</dc:creator>
				<category><![CDATA[Video]]></category>
		<category><![CDATA[Continuous Deployment]]></category>
		<category><![CDATA[UI]]></category>

		<guid isPermaLink="false">http://evgeny-goldin.com/blog/?p=3997</guid>
		<description><![CDATA[ILTechTalks has met again and this time to discuss the issue of Continuous Deployment and UI development. First session was given by Ori Lahav (@orilahav) and Shaked Simchi from Outbrain and the seond one by Omri Nachman from Wix. Audio file (mp3) of the session. Audio file (mp3) of the session.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.meetup.com/ILTechTalks/"><strong>ILTechTalks</strong></a> has met <a href="http://www.meetup.com/ILTechTalks/events/40140572/">again</a> and this time to discuss the issue of Continuous Deployment and UI development. First session was given by Ori Lahav (<a href="http://twitter.com/#!/orilahav">@orilahav</a>) and Shaked Simchi from <a href="http://www.outbrain.com/">Outbrain</a> and the seond one by Omri Nachman from <a href="http://www.wix.com/">Wix</a>. </p>
<p><iframe src="http://player.vimeo.com/video/32967933?title=0&amp;byline=0&amp;portrait=0" width="630" height="346" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></p>
<p><a href="http://goo.gl/hLUun">Audio file (mp3)</a> of the session.</p>
<p><iframe src="http://player.vimeo.com/video/32971396?title=0&amp;byline=0&amp;portrait=0" width="630" height="346" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></p>
<p><a href="http://goo.gl/0DmBK">Audio file (mp3)</a> of the session.</p>
]]></content:encoded>
			<wfw:commentRss>http://evgeny-goldin.com/blog/ui-continuous-deployment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lion Video Conversion Tools</title>
		<link>http://evgeny-goldin.com/blog/lion-video-conversion-tools/</link>
		<comments>http://evgeny-goldin.com/blog/lion-video-conversion-tools/#comments</comments>
		<pubDate>Sat, 03 Dec 2011 01:13:06 +0000</pubDate>
		<dc:creator>Evgeny Goldin</dc:creator>
				<category><![CDATA[Video]]></category>
		<category><![CDATA[Lion]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://evgeny-goldin.com/blog/?p=3979</guid>
		<description><![CDATA[After recording technical sessions I visit on my camera, there was a clear need to share them on a reliable and controllable platform. Without thinking too much I started with Vimeo Plus as it provides a reasonable compromise between the price, storage space and overall control. In a way, I much prefer to pay and [...]]]></description>
			<content:encoded><![CDATA[<p>After recording technical sessions I visit on my camera, there was a clear need to share them on a reliable and controllable platform. Without thinking too much I started with <a href="http://vimeo.com/plus">Vimeo Plus</a> as it provides a reasonable compromise between the price, storage space and overall control. In a way, I much prefer to pay and then have something to say (and demand!) rather than rely on free services, behaving on their own will.</p>
<p>My second issue was converting <strong><code>MOD</code></strong> files recorded by the camera before uploading them to Vimeo. Initially, <a href="http://handbrake.fr/">HandBrake</a> looked like an excellent solution as it compresses <code>mod</code>s to <strong><code>mkv</code></strong>, my preferable format. On top of that it was free, which doesn&#8217;t happen a lot in the Mac world. However, I found out my camera starts recording new <code>mod</code> file every 60 minutes. To verify that and see if any recording is lost in the middle I recorded my digital clock for about 3 hours and found out no time above one second is lost. To merge the files I switched to <a href="http://www.wondershare.com/mac-video-converter-ultimate/">Video Converter Ultimate for Mac</a> which is more capable than HandBrake although it is not free. This application also allows conversion of <code>mkv</code> files resulting from the merge to <code>mp3</code> audio so that people would be able to download the smaller audio files to their players. As a long-time iPod listener, I believe having a downloadable <code>mp3</code> file is definitely a must for any technical session being recorded. </p>
<p>Another application I found for conversion of video files (to audio and video formats, including <code>mp4</code> and <code>mp3</code>) was <a href="http://www.mirovideoconverter.com/">Miro Video Converter</a>, also a free one but with a limited functionality. For instance, it doesn&#8217;t allow to control the compression quality.</p>
<p>At the end of the day, video converter from Wondershare is the one I use the most although I have all 3 of them installed.</p>
<p><a href="http://www.alfredapp.com/"><img border="0" src="http://evgeny-goldin.com/blog/wp-content/uploads/2011/12/Mac-Video-Tools1.png" alt="" title="Mac Video Tools shown by Alfred" width="615" height="257" class="aligncenter size-full wp-image-3988" /></a></p>
<p>One thing I wouldn&#8217;t suggest, though, is clicking the &#8220;Remember it as my default option&#8221; checkbox in the converter welcome screen as I found no way to switch the conversion mode later and had to reinstall the application to undo the default &#8220;Video&#8221; mode.</p>
<p><a href="http://www.wondershare.com/mac-video-converter-ultimate/"><img border="0" src="http://evgeny-goldin.com/blog/wp-content/uploads/2011/12/Video-Converter1.png" alt="" title="Video Converter Ultimate for Mac" width="549" height="314" class="aligncenter size-full wp-image-3987" /></a></p>
<p>Well, now I have created my own <a href="http://vimeo.com/channels/263367">&#8220;Technical Sessions&#8221;</a> Vimeo channel (reposted here in <a href="http://evgeny-goldin.com/blog/category/video/">&#8220;Video&#8221;</a> category) where all sessions I ever visit will be uploaded to. The link to corresponding <code>mp3</code> files is available in every video &#8220;Description&#8221;. Right now most sessions are in Hebrew but this will change next year.</p>
]]></content:encoded>
			<wfw:commentRss>http://evgeny-goldin.com/blog/lion-video-conversion-tools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Big Data &amp; LivePerson: Hadoop and MapReduce</title>
		<link>http://evgeny-goldin.com/blog/big-data-liveperson/</link>
		<comments>http://evgeny-goldin.com/blog/big-data-liveperson/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 13:55:41 +0000</pubDate>
		<dc:creator>Evgeny Goldin</dc:creator>
				<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://evgeny-goldin.com/blog/?p=3962</guid>
		<description><![CDATA[ILTechTalks organized another event yesterday &#8211; &#8220;Big Data &#038; LivePerson&#8221; where Ophir Cohen (@ophchu) from LivePerson presented company experience with Hadoop and MapReduce.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.meetup.com/ILTechTalks/"><strong>ILTechTalks</strong></a> organized another event yesterday &#8211; <a href="http://www.meetup.com/ILTechTalks/events/39864572/">&#8220;Big Data &#038; LivePerson&#8221;</a> where Ophir Cohen (<a href="http://twitter.com/#!/ophchu"><strong>@ophchu</strong></a>) from LivePerson presented company experience with Hadoop and MapReduce.</p>
<p><iframe src="http://player.vimeo.com/video/32504726?title=0&amp;byline=0&amp;portrait=0" width="630" height="346" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe><br />
<br/><br />
<iframe src="http://player.vimeo.com/video/32505056?title=0&amp;byline=0&amp;portrait=0" width="630" height="346" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://evgeny-goldin.com/blog/big-data-liveperson/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>10 Cool Facts about Gradle</title>
		<link>http://evgeny-goldin.com/blog/10-cool-facts-gradle/</link>
		<comments>http://evgeny-goldin.com/blog/10-cool-facts-gradle/#comments</comments>
		<pubDate>Wed, 31 Aug 2011 15:24:43 +0000</pubDate>
		<dc:creator>Evgeny Goldin</dc:creator>
				<category><![CDATA[Gradle]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[builds]]></category>

		<guid isPermaLink="false">http://evgeny-goldin.com/blog/?p=3933</guid>
		<description><![CDATA[About a month ago @saylambda user group (lambda.org.il) had a &#8220;JavaScript as a Functional Language&#8221; meeting, very nicely presented by Zachary Kessin (@zkessin). You can see a summary, HTML slides and video recording of the session. This time the subject was Groovy and Ronen Narkis (@narkisr) presented Groovy as a language, its powerful GDK, AST [...]]]></description>
			<content:encoded><![CDATA[<p>About a month ago <a href="http://twitter.com/#!/saylambda"><strong>@saylambda</strong></a> user group (<a href="http://www.lambda.org.il/">lambda.org.il</a>) had a &#8220;JavaScript as a Functional Language&#8221; meeting, very nicely presented by Zachary Kessin (<a href="http://twitter.com/#!/zkessin">@zkessin</a>). You can see a <a href="http://www.evernote.com/shard/s63/sh/015c6fcf-bb47-4fa9-8cd0-518809d8e75e/2be707e66f87818ced94b24902876665">summary</a>, <a href="http://www.lambda.org.il/meetings/past/javascript/slides">HTML slides</a> and <a href="http://vimeo.com/27759669">video recording</a> of the session. </p>
<p>This time the subject was Groovy and Ronen Narkis (<a href="http://twitter.com/#!/narkisr">@narkisr</a>) presented Groovy as a language, its powerful GDK, AST and MOP capabilities together with GPars examples. Ronen presentation is available in his <a href="https://github.com/narkisr/lambda-groovy">GitHub repository</a>.</p>
<p>I was invited to speak about Gradle and since my session was targeted to the audience where not everyone was familiar with either Groovy or Gradle I decided not to cover it feature-by-feature or go into any technical details (and we were short on time, as always). Instead, I picked 10 facts about Gradle which, coming from the Maven background, made me say &#8220;Hmm, that&#8217;s cool!&#8221; in the past. Hope you&#8217;ll share my experience so here it is.</p>
<p><object type='application/x-shockwave-flash' wmode='opaque' data='http://static.slideshare.net/swf/ssplayer2.swf?id=9082958&doc=10coolfactsaboutgradle-110831074317-phpapp01' width='630' height='516'><param name='movie' value='http://static.slideshare.net/swf/ssplayer2.swf?id=9082958&doc=10coolfactsaboutgradle-110831074317-phpapp01' /><param name='allowFullScreen' value='true' /></object><br />
<br/></p>
<p>
My other presentations are now available <a href="https://github.com/evgeny-goldin/presentations">in GitHub</a> as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://evgeny-goldin.com/blog/10-cool-facts-gradle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gradle CodeNarc Plugin</title>
		<link>http://evgeny-goldin.com/blog/gradle-codenarc-plugin/</link>
		<comments>http://evgeny-goldin.com/blog/gradle-codenarc-plugin/#comments</comments>
		<pubDate>Sat, 13 Aug 2011 00:05:39 +0000</pubDate>
		<dc:creator>Evgeny Goldin</dc:creator>
				<category><![CDATA[Gradle]]></category>
		<category><![CDATA[codenarc]]></category>

		<guid isPermaLink="false">http://evgeny-goldin.com/blog/?p=3910</guid>
		<description><![CDATA[After working on Gradle CodeNarc plugin for some time and using it in 3 of my projects, I decided to officially release it last week. This plugin allows to easily run a CodeNarc Groovy code analysis from your Gradle build script. In the simplest form the plugin can be used as: which adds new "codenarc" [...]]]></description>
			<content:encoded><![CDATA[<p>After working on <a href="http://evgeny-goldin.com/wiki/Gradle-CodeNarc-plugin"><strong>Gradle CodeNarc plugin</strong></a> for some time and using it in 3 of my projects, I decided to officially release it last week. This plugin allows to easily run a <a href="http://codenarc.sourceforge.net/"><strong>CodeNarc</strong></a> Groovy code analysis from your Gradle build script.</p>
<p>In the simplest form the plugin can be used as:</p>
<pre class="brush: groovy; title: ; notranslate">
..
apply from: 'https://raw.github.com/evgeny-goldin/gradle-plugins/master/src/main/groovy/CodeNarc.gradle'
..
</pre>
<p>which adds new <code><strong>"codenarc"</strong></code> Gradle task. But it is better not to rely on default values of CodeNarc version and RuleSet files which will change every time a newer CodeNarc version is released. Specifying some of parameters makes Gradle builds less vulnerable to CodeNarc updates:   </p>
<pre class="brush: groovy; title: ; notranslate">
..
codenarcVersion      = '0.15'
codenarcRuleSetFiles = [ 'codenarc.groovy' ]
apply from: 'https://raw.github.com/evgeny-goldin/gradle-plugins/master/src/main/groovy/CodeNarc.gradle'
..
</pre>
<p>As always, examples and documentation are available <a href="http://evgeny-goldin.com/wiki/Gradle-CodeNarc-plugin">in the Wiki</a>. Your comments, feedback and <a href="http://evgeny-goldin.org/youtrack/issues/gp?q=Subsystem%3A+gradle-codenarc-plugin+">bug reports</a> are most welcome!</p>
<p>This is the third Gradle plugin released as of today. Two others are:</p>
<ul>
<li><strong><a href="http://evgeny-goldin.com/wiki/Gradle-about-plugin">&#8220;About&#8221; plugin</a></strong> adds textual &#8220;about&#8221; file to build artifacts created, linking each binary artifact to the build environment and sources it was created with. The file added contains details about build date and time, last commit made in the project, Java / Gradle versions used for build and some other optional elements like project dependencies, local paths, system and environment variables. If the project was built by Jenkins, TeamCity or Hudson build server then corresponding job details are also added to the file generated.<br/><br/>This is a simple and powerful way to keep all your artifacts aware of their build context, timestamp, and environment.</li>
<p/>
<li><strong><a href="http://evgeny-goldin.com/wiki/Gradle-duplicates-plugin">&#8220;Duplicates&#8221; plugin</a></strong> locates duplicate libraries in Gradle configurations. Duplicate libraries have different coordinates (group or name) but contain an identically named classes, i.e., classes with identical fully qualified names. One source of possible duplicates are changes done to library coordinates in Maven repositories. When libraries evolve, migrate, grow up and split up they may start naming their artifacts differently. And then having an old and new version of the same library in Gradle configuration causes a duplicate problem.<br/><br/>Another possible source of duplicate classes in the same configuration are repacking portions of one library in another which may happen from time to time. Whatever reason for duplicate is, this plugin quickly locates all of them and either fails the build or displays a warning.</li>
</ul>
<p><br/></p>
<p/>
New Gradle plugins will surely be added later so stay tuned! </p>
]]></content:encoded>
			<wfw:commentRss>http://evgeny-goldin.com/blog/gradle-codenarc-plugin/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Pomodoro Technique Summary</title>
		<link>http://evgeny-goldin.com/blog/pomodoro-technique-summary/</link>
		<comments>http://evgeny-goldin.com/blog/pomodoro-technique-summary/#comments</comments>
		<pubDate>Sun, 31 Jul 2011 09:19:46 +0000</pubDate>
		<dc:creator>Evgeny Goldin</dc:creator>
				<category><![CDATA[Wiki]]></category>

		<guid isPermaLink="false">http://evgeny-goldin.com/blog/?p=3901</guid>
		<description><![CDATA[I&#8217;ve decided to give Pomodoro technique a try. This is a fairly simple time-management system where one is supposed to work in chunks of 25 minutes without interruptions with 3-5 minutes breaks between each chunk. And there are longer 15-30 minutes breaks every 4 chunks. That&#8217;s basically it but there are many more details which [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve decided to give <a href="http://www.pomodorotechnique.com/"><strong>Pomodoro technique</strong></a> a try. This is a fairly simple time-management system where one is supposed to work in chunks of 25 minutes <em>without interruptions</em> with 3-5 minutes breaks between each chunk. And there are longer 15-30 minutes breaks every 4 chunks. That&#8217;s basically it but there are many more details which I&#8217;ve <a href="http://evgeny-goldin.com/wiki/The_Pomodoro_Technique">summarized in the Wiki</a>.</p>
<p>Some more good news! <a href="http://oreilly.com/catalog/0636920010326"><strong>&#8220;Jenkins: The Definitive Guide&#8221;</strong></a> published by O&#8217;Reilly Media now contains my contribution dedicated to <a href="http://evgeny-goldin.com/wiki/Maven-jenkins-plugin"><strong><code>"maven-jenkins-plugin"</code></strong></a> in chapter 10, &#8220;Generating Your Maven Build Jobs Automatically&#8221;. I would like to thank <a href="http://www.wakaleo.com/"><strong>John Ferguson Smart</strong></a> for letting me provide this contribution!</p>
]]></content:encoded>
			<wfw:commentRss>http://evgeny-goldin.com/blog/pomodoro-technique-summary/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Paul Bloom: The origins of pleasure</title>
		<link>http://evgeny-goldin.com/blog/paul-bloom-origins-pleasure/</link>
		<comments>http://evgeny-goldin.com/blog/paul-bloom-origins-pleasure/#comments</comments>
		<pubDate>Sat, 30 Jul 2011 13:46:30 +0000</pubDate>
		<dc:creator>Evgeny Goldin</dc:creator>
				<category><![CDATA[Video]]></category>
		<category><![CDATA[ted]]></category>

		<guid isPermaLink="false">http://evgeny-goldin.com/blog/?p=3897</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><object width="526" height="374"><param name="movie" value="http://video.ted.com/assets/player/swf/EmbedPlayer.swf"></param><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always"/><param name="wmode" value="transparent"></param><param name="bgColor" value="#ffffff"></param><param name="flashvars" value="vu=http://video.ted.com/talk/stream/2011G/Blank/PaulBloom_2011G-320k.mp4&#038;su=http://images.ted.com/images/ted/tedindex/embed-posters/PaulBloom_2011G-embed.jpg&#038;vw=512&#038;vh=288&#038;ap=0&#038;ti=1198&#038;lang=&#038;introDuration=15330&#038;adDuration=4000&#038;postAdDuration=830&#038;adKeys=talk=paul_bloom_the_origins_of_pleasure;year=2011;theme=evolution_s_genius;theme=new_on_ted_com;theme=how_the_mind_works;theme=a_taste_of_tedglobal_2011;theme=what_makes_us_happy;event=TEDGlobal+2011;tag=Science;tag=happiness;tag=philosophy;tag=psychology;&#038;preAdTag=tconf.ted/embed;tile=1;sz=512x288;" /><embed src="http://video.ted.com/assets/player/swf/EmbedPlayer.swf" pluginspace="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" bgColor="#ffffff" width="526" height="374" allowFullScreen="true" allowScriptAccess="always" flashvars="vu=http://video.ted.com/talk/stream/2011G/Blank/PaulBloom_2011G-320k.mp4&#038;su=http://images.ted.com/images/ted/tedindex/embed-posters/PaulBloom_2011G-embed.jpg&#038;vw=512&#038;vh=288&#038;ap=0&#038;ti=1198&#038;lang=&#038;introDuration=15330&#038;adDuration=4000&#038;postAdDuration=830&#038;adKeys=talk=paul_bloom_the_origins_of_pleasure;year=2011;theme=evolution_s_genius;theme=new_on_ted_com;theme=how_the_mind_works;theme=a_taste_of_tedglobal_2011;theme=what_makes_us_happy;event=TEDGlobal+2011;tag=Science;tag=happiness;tag=philosophy;tag=psychology;&#038;preAdTag=tconf.ted/embed;tile=1;sz=512x288;"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://evgeny-goldin.com/blog/paul-bloom-origins-pleasure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An importance of wrapping variables</title>
		<link>http://evgeny-goldin.com/blog/wrapping-variables/</link>
		<comments>http://evgeny-goldin.com/blog/wrapping-variables/#comments</comments>
		<pubDate>Mon, 20 Jun 2011 12:56:12 +0000</pubDate>
		<dc:creator>Evgeny Goldin</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://evgeny-goldin.com/blog/?p=3869</guid>
		<description><![CDATA[Long time ago I developed a habit of wrapping every variable logged in [ .. ]: The reasons were mostly to spot any trailing whitespaces in variables logged which was very helpful in error messages. As simple as it sounds, lots of messages thrown or logged today still don&#8217;t enclose variables in any special characters [...]]]></description>
			<content:encoded><![CDATA[<p>Long time ago I developed a habit of wrapping every variable logged in <strong><code>[ .. ]</code></strong>: </p>
<pre class="brush: groovy; title: ; notranslate">
Java:   log.error( &quot;Class [&quot; + c + &quot;] not found&quot; )
Java:   log.error( String.format( &quot;Class [%s] not found&quot;, c ))
Groovy: log.error( &quot;Class [$c] not found&quot; )
</pre>
<p>The reasons were mostly to spot any trailing whitespaces in variables logged which was very helpful in error messages. As simple as it sounds, lots of messages thrown or logged today still don&#8217;t enclose variables in any special characters which can make them quite obscure. </p>
<p>What would you say about this error message ?</p>
<pre class="brush: groovy; title: ; notranslate">
..
java.lang.IllegalArgumentException: No enum const class Something.
	at java.lang.Enum.valueOf(Enum.java:196)
..
</pre>
<p>I was surprised why failing <strong><code>Enum.valueOf()</code></strong> didn&#8217;t include the wrong value in the error message. But it did! Here&#8217;s the failing code:</p>
<pre class="brush: groovy; title: ; notranslate">
..
enum Something{ A, B }
assert Something.A != Something.valueOf( '' )
..
</pre>
<p>So it was an empty <strong><code>String</code></strong>. Normally, wrong <strong><code>Enum.valueOf()</code></strong> input is printed:</p>
<pre class="brush: groovy; title: ; notranslate">
..
enum Something{ A, B }
assert Something.A != Something.valueOf( 'C' )

java.lang.IllegalArgumentException: No enum const class Something.C
	at java.lang.Enum.valueOf(Enum.java:196)
..
</pre>
<p>But with empty argument <strong><code>"No enum const class Something."</code></strong> simply looked like a period at the end of the sentence! I wish it was <strong><code>"No enum const class [Something.]"</code></strong> instead.</p>
<pre class="brush: groovy; title: ; notranslate">
// &quot;java/lang/Enum.java&quot;
public static &lt;T extends Enum&lt;T&gt;&gt; T valueOf(Class&lt;T&gt; enumType,
                                            String name) {
    T result = enumType.enumConstantDirectory().get(name);
    if (result != null)
        return result;
    if (name == null)
        throw new NullPointerException(&quot;Name is null&quot;);
    throw new IllegalArgumentException(
        &quot;No enum const &quot; + enumType +&quot;.&quot; + name);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://evgeny-goldin.com/blog/wrapping-variables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Groovy 1.8.0 &#8211; meet JsonBuilder!</title>
		<link>http://evgeny-goldin.com/blog/groovy-jsonbuilder/</link>
		<comments>http://evgeny-goldin.com/blog/groovy-jsonbuilder/#comments</comments>
		<pubDate>Fri, 17 Jun 2011 17:18:07 +0000</pubDate>
		<dc:creator>Evgeny Goldin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[groovy builders]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[JsonBuilder]]></category>
		<category><![CDATA[MarkupBuilder]]></category>

		<guid isPermaLink="false">http://evgeny-goldin.com/blog/?p=3799</guid>
		<description><![CDATA[Groovy 1.8.0 released in April brought a lot of new features to the language, one of them is native JSON support through JsonSlurper for reading JSON and JsonBuilder for writing JSON. I recently used JsonBuilder in one of my projects and initially experienced some difficulties in understanding how it operates. My assumption was that JsonBuilder [...]]]></description>
			<content:encoded><![CDATA[<div style='float:right;margin-left:10px;margin-top:-54px;'>
<script type='text/javascript'>var dzone_url = 'http://evgeny-goldin.com/blog/groovy-jsonbuilder/'</script><br />
<script type='text/javascript'>var dzone_title = 'Groovy 1.8.0 – meet JsonBuilder!'</script><br />
<script type='text/javascript'>var dzone_style = '2'</script><br />
<script language='javascript' src='http://widgets.dzone.com/widgets/zoneit.js'></script>
</div>
<p><a href="http://docs.codehaus.org/display/GROOVY/Groovy+1.8+release+notes"><strong>Groovy 1.8.0</strong></a> released in April brought <em>a lot</em> of new features to the language, one of them is <a href="http://docs.codehaus.org/display/GROOVY/Groovy+1.8+release+notes#Groovy1.8releasenotes-NativeJSONsupport">native JSON support</a> through <a href="http://groovy.codehaus.org/gapi/groovy/json/JsonSlurper.html"><strong><code>JsonSlurper</code></strong></a> for reading JSON and <a href="http://groovy.codehaus.org/gapi/groovy/json/JsonBuilder.html"><strong><code>JsonBuilder</code></strong></a> for writing JSON. </p>
<p>I recently used <strong><code>JsonBuilder</code></strong> in one of my projects and initially experienced some difficulties in understanding how it operates. My assumption was that <strong><code>JsonBuilder</code></strong> works similarly to <a href="http://groovy.codehaus.org/Creating+XML+using+Groovy's+MarkupBuilder"><strong><code>MarkupBuilder</code></strong></a> but as I have quickly found out, it really doesn&#8217;t.</p>
<p>Let&#8217;s take a simple example. Assume we have a class <strong><code>Message</code></strong> that we would like to serialize to XML markup and JSON.</p>
<pre class="brush: groovy; title: ; notranslate">
@groovy.transform.Canonical
class Message {
    long   id
    String sender
    String text
}

assert 'Message(23, me, some text)' ==
       new Message( 23, 'me', 'some text' ).toString()
</pre>
<p>Here I used Groovy 1.8.0 <a href="http://docs.codehaus.org/display/GROOVY/Groovy+1.8+release+notes#Groovy1.8releasenotes-@Canonical"><strong><code>@Canonical</code></strong></a> annotation providing automatic <a href="http://docs.codehaus.org/display/GROOVY/Groovy+1.8+release+notes#Groovy1.8releasenotes-@ToString"><strong><code>toString()</code></strong></a>, <a href="http://docs.codehaus.org/display/GROOVY/Groovy+1.8+release+notes#Groovy1.8releasenotes-@EqualsAndHashCode"><strong><code>equals()</code></strong> and <strong><code>hashCode()</code></strong></a> and a  <a href="http://docs.codehaus.org/display/GROOVY/Groovy+1.8+release+notes#Groovy1.8releasenotes-@TupleConstructor">tuple (ordered) constructor</a>. </p>
<p>Let&#8217;s serialize a number of messages to XML.</p>
<pre class="brush: groovy; title: ; notranslate">
def messages = [ new Message( 23, 'me', 'some text'       ),
                 new Message( 24, 'me', 'some other text' ),
                 new Message( 25, 'me', 'same text'       )]

def writer = new StringWriter()
def xml    = new groovy.xml.MarkupBuilder( writer )

xml.messages() {
    messages.each { Message m -&gt; message( id     : m.id,
                                          sender : m.sender,
                                          text   : m.text )}
}

assert writer.toString() == &quot;&quot;&quot;
&lt;messages&gt;
  &lt;message id='23' sender='me' text='some text' /&gt;
  &lt;message id='24' sender='me' text='some other text' /&gt;
  &lt;message id='25' sender='me' text='same text' /&gt;
&lt;/messages&gt;&quot;&quot;&quot;.trim()
</pre>
<p>Well, that was pretty straightforward. Let&#8217;s try to do the same with JSON.</p>
<pre class="brush: groovy; title: ; notranslate">
def json = new groovy.json.JsonBuilder()

json.messages() {
    messages.each { Message m -&gt; message( id     : m.id,
                                          sender : m.sender,
                                          text   : m.text )}
}

assert json.toString() ==
       '{&quot;messages&quot;:{&quot;message&quot;:{&quot;id&quot;:25,&quot;sender&quot;:&quot;me&quot;,&quot;text&quot;:&quot;same text&quot;}}}'
</pre>
<p>Wow, where did all other messages go? Why only one last message in the list was serialized?<br />
How about this:</p>
<pre class="brush: groovy; title: ; notranslate">
json = new groovy.json.JsonBuilder()

json.messages() {
    message {
        id     23
        sender 'me'
        text   'some text'
    }
    message {
        id     24
        sender 'me'
        text   'some other text'
    }
}

assert json.toString() ==
       '{&quot;messages&quot;:{&quot;message&quot;:{&quot;id&quot;:24,&quot;sender&quot;:&quot;me&quot;,&quot;text&quot;:&quot;some other text&quot;}}}'
</pre>
<p>Same story. Initially I was puzzled, but then <strong><code>JsonBuilder</code></strong> <a href="https://fisheye.codehaus.org/browse/groovy/tags/GROOVY_1_8_0/src/main/groovy/json/JsonBuilder.groovy?hb=true">source code</a> showed that every invocation overrides the previous content:</p>
<pre class="brush: groovy; title: ; notranslate">
JsonBuilder(content = null) {
    this.content = content
}

def call(Map m) {
    this.content = m
    return content
}

def call(List l) {
    this.content = l
    return content
}

def call(Object... args) {
    this.content = args.toList()
    return this.content
}

def call(Closure c) {
    this.content = JsonDelegate.cloneDelegateAndGetContent(c)
    return content
}
</pre>
<p><u>As you see, one should invoke <strong><code>JsonBuilder</code></strong> exactly once, passing it a <strong><code>Map</code></strong>, <strong><code>List</code></strong>, varargs or <strong><code>Closure</code></strong></u>. This makes <strong><code>JsonBuilder</code></strong> very different from <strong><code>MarkupBuilder</code></strong> which can be updated as many times as needed. It could be caused by the JSON itself, whose format is stricter than free-form XML markup: something that started as a JSON map with a single <strong><code>Message</code></strong>, can not be made into array of <strong><code>Messages</code></strong> out of sudden. </p>
<p>The argument passed to <strong><code>JsonBuilder</code></strong> (<code>Map</code>, <code>List</code>, varargs or <code>Closure</code>) can also be specified in constructor so there&#8217;s no need to invoke a builder at all. You can simply initialize it with the corresponding data structure and call <strong><code>toString()</code></strong> right away. Let&#8217;s try this!</p>
<pre class="brush: groovy; title: ; notranslate">
def listOfMaps = messages.collect{
                 Message m -&gt; [ id     : m.id,
                                sender : m.sender,
                                text   : m.text ]}

assert new groovy.json.JsonBuilder( listOfMaps ).toString() ==
       '''[{&quot;id&quot;:23,&quot;sender&quot;:&quot;me&quot;,&quot;text&quot;:&quot;some text&quot;},
           {&quot;id&quot;:24,&quot;sender&quot;:&quot;me&quot;,&quot;text&quot;:&quot;some other text&quot;},
           {&quot;id&quot;:25,&quot;sender&quot;:&quot;me&quot;,&quot;text&quot;:&quot;same text&quot;}]'''.
       readLines()*.trim().join()
</pre>
<p>Now it works :) After converting the list of messages to the list of Maps and sending them to the JsonBuilder in one go, the <strong><code>String</code></strong> generated contains all messages from the list. All code above is available in <a href="http://groovyconsole.appspot.com/script/498001">Groovy web console</a> so you are welcome to try it out.</p>
<p>Btw, for viewing JSON online I recommend an excellent <a href="http://chris.photobooks.com/json/default.htm"><strong>&#8220;JSON Visualization&#8221;</strong></a> application made by Chris Nielsen. <a href="http://jsonviewer.stack.hu/">&#8220;Online JSON Viewer&#8221;</a> is another popular option, but I much prefer the first one. And for offline use <a href="http://jsonviewer.codeplex.com/">&#8220;JSON Viewer&#8221;</a> makes a good <a href="http://www.fiddler2.com/fiddler2/">Fiddler</a> plugin.</p>
<p><a href="http://chris.photobooks.com/json/default.htm"><img src="http://evgeny-goldin.com/blog/wp-content/uploads/2011/06/JSON-Visualization2.png" alt="" title="JSON Visualization by Chris Nielsen" width="629" height="429" class="aligncenter size-full wp-image-3860" /></a></p>
<p>P.S.<br />
If you need to read this JSON on the client side by sending, say, Ajax GET request, this can be easily done with <a href="http://api.jquery.com/jQuery.get/"><strong>jQuery.get()</strong></a>:</p>
<pre class="brush: groovy; title: ; notranslate">
&lt;script type=&quot;text/javascript&quot;&gt;
var j = jQuery;

j( function() {
    j.get( 'url',
           { timestamp: new Date().getTime() },
           function ( messages ){
               j.each( messages, function( index, m ) {
                   alert( &quot;[&quot; + m.id + &quot;][&quot; + m.sender + &quot;][&quot; + m.text + &quot;]&quot; );
               });
           },
           'json'
        );
});
&lt;/script&gt;
</pre>
<p>Here I use a neat trick of a <strong><code><em>j</em></code></strong> shortcut to avoid typing <strong><code>jQuery</code></strong> too many times when using <strong><code>$</code></strong> is not an option.</p>
]]></content:encoded>
			<wfw:commentRss>http://evgeny-goldin.com/blog/groovy-jsonbuilder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Displaying Git branch in Linux command prompt</title>
		<link>http://evgeny-goldin.com/blog/displaying-git-branch-linux-command-prompt/</link>
		<comments>http://evgeny-goldin.com/blog/displaying-git-branch-linux-command-prompt/#comments</comments>
		<pubDate>Sun, 05 Jun 2011 09:57:41 +0000</pubDate>
		<dc:creator>Evgeny Goldin</dc:creator>
				<category><![CDATA[Git]]></category>

		<guid isPermaLink="false">http://evgeny-goldin.com/blog/?p=3777</guid>
		<description><![CDATA[Even though I create "dev" branch for all my Git projects and perform all development work there, I need to make sure I&#8217;m still on the "dev" branch from time to time. "gs" is my alias to "git status" and I run it very frequently for that and other purposes. But this beautiful Git presentation [...]]]></description>
			<content:encoded><![CDATA[<p>Even though I create <strong><code>"dev"</code></strong> branch for all my Git projects and perform all development work there, I need to make sure I&#8217;m still on the <strong><code>"dev"</code></strong> branch from time to time. <strong><code>"gs"</code></strong> is my alias to <strong><code>"git status"</code></strong> and I run it very frequently for that and other purposes. </p>
<p>But this beautiful <a href="http://www.slideshare.net/lucamilanesio/git-workshop-33degree-2011-krakow"><strong>Git presentation</strong></a> (<a href="http://33degree.org/pdf/LucaMilanesioGit.pptx">download</a>) by Luca Milanesio of <a href="http://gitenterprise.com/">GitEnterprise</a> and <a href="http://www.hudson-mobi.com/">HudsonMobi</a> provided a <a href="http://www.slideshare.net/lucamilanesio/git-workshop-33degree-2011-krakow/38">better solution</a>! Take a look:</p>
<pre class="brush: bash; title: ; notranslate">
[~/projects]$ git clone git://git.kernel.org/pub/scm/git/git.git
[~/projects]$ cd git
[~/projects/git]$ git checkout v1.7.5.4
[~/projects/git]$ make prefix=/usr/local all
[~/projects/git]$ sudo make prefix=/usr/local install
[~/projects/git]$ git --version
git version 1.7.5.4
[~/projects/git]$ source contrib/completion/git-completion.bash
[~/projects/git]$ export PS1='\W$(__git_ps1 &quot; (%s)&quot;) \$ '
git ((v1.7.5.4)) $
</pre>
<p>Now my command prompt always displays current Git branch. Let&#8217;s try TeamCity build agent checkout folder:</p>
<pre class="brush: bash; title: ; notranslate">
git ((v1.7.5.4)) $ cd ~/java/agent/work/56ff0db610964031/
56ff0db610964031 (master) $
</pre>
<p>It works! Many thanks, Luca.</p>
<pre class="brush: bash; title: ; notranslate">
#[12:48:47][~/projects/git] ((v1.7.5.4)) $ cat ~/.bash_profile | grep PS1
PS1='#[\t][\w]$(__git_ps1 &quot; (%s)&quot;) \$ '
#[12:49:45][~/projects/git] ((v1.7.5.4)) $ cd
#[12:52:40][~] $
</pre>
]]></content:encoded>
			<wfw:commentRss>http://evgeny-goldin.com/blog/displaying-git-branch-linux-command-prompt/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

