<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>The Programmer Man</title>
	
	<link>http://theprogrammerman.com</link>
	<description />
	<lastBuildDate>Thu, 12 Apr 2012 07:50:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/TheProgrammerMan" /><feedburner:info uri="theprogrammerman" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>My first steps in learning German</title>
		<link>http://feedproxy.google.com/~r/TheProgrammerMan/~3/OuT7wNy473w/</link>
		<comments>http://theprogrammerman.com/2012/04/12/my-first-steps-in-learning-german/#comments</comments>
		<pubDate>Thu, 12 Apr 2012 07:50:27 +0000</pubDate>
		<dc:creator>bibix</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[german]]></category>
		<category><![CDATA[languages]]></category>
		<category><![CDATA[learning]]></category>

		<guid isPermaLink="false">http://theprogrammerman.com/?p=251</guid>
		<description><![CDATA[I haven&#8217;t learned a new language for quite a time. I even forgot how much I like it and how entertaining it is. Everywhere I go, I try to learn at least basic sentences, grammar and numerals. It worked best<span class="ellipsis">&#8230;</span> <a href="http://theprogrammerman.com/2012/04/12/my-first-steps-in-learning-german/"><div class="read-more">Read more &#8250;</div><!-- end of .read-more --></a>]]></description>
			<content:encoded><![CDATA[<p>I haven&#8217;t learned a new language for quite a time. I even forgot how much I like it and how entertaining it is. Everywhere I go, I try to learn at least basic sentences, grammar and numerals. It worked best when I visited Prague couple years ago. I was able to use the Czech language 90% of the time. It&#8217;s good to have a dictionary with you all the time:)</p>
<p>Since I plan to move to Switzerland, I have decided to improve my knowledge of German. I forgot most of it, since last time I was using it was in high school.</p>
<h2>The old times</h2>
<p>I remember that it was much easier to learn languages in primary school. There were mostly foreign channels on cable tv, so I could listen to English, German, French and many others. Most of the computer programs and games in the era of C64 were in English or German and actually seeing Polish on computer screen was kind of weird. I have been exposed to foreign languages all the time (as I&#8217;ve been watching many cartoons:)).</p>
<h2>vs Now</h2>
<p>Today there is no single fully German channel on my cable tv. There aren&#8217;t many in English either, but I don&#8217;t watch cartoons any more. Most games and apps are translated into Polish. The rich media stream of language resources dried out.</p>
<p>But I know that it&#8217;s good for me to learn German from all sources I can reach, and not only from textbook. So here I some steps I took to learn it faster and better.</p>
<h2>Getting a dictionary</h2>
<p>First of all I bought myself a dictionary. There&#8217;s nothing more important than a small book that I can carry with me. When I use a dictionary I can look at words at the same page, find similarities, patterns, find new words and meanings. I can check if words similar in Polish are also similar in German and I can learn how words are created. My dictionary is always close to me.</p>
<h2>Language course</h2>
<p>Much to my surprise, all language courses are scheduled for one year and start in September or October. There are some super expensive one month fast paced courses for businessmen, but I&#8217;m not a businessman. There are also some during summer, but it&#8217;s still couple months I don&#8217;t want to waste.<br />
That didn&#8217;t discourage me from taking a course &#8211; online. I have found fantastic materials at the Deutsche Welle site (<a href="http://www.dw.de">www.dw.de</a>). They were prepared together with people from Goethe Institut. That means this is a really good material. There are several courses available for different levels. You can also learn Polish there:) You can take a course in your language, there are German courses in many languages. They have really done a good job. I enjoy learning from these pages. When I found this page, I immediately pinned it as an app in my firefox as I visit it very often.</p>
<h2>Television</h2>
<p>Well, I thought that since Polish tv stations offer a VOD with their programs, maybe also I could find German television over internet. And there are many stations that you can watch for free. I will post links later since I haven&#8217;t saved them after my search. What I found difficult when I watch tv shows is kind of lack of context. It&#8217;s difficult to only see and hear and have no idea what is actually going on. I find watching DVDs much more helpful.</p>
<h2>DVDs</h2>
<p>I was surprised with that, but watching a movie in English with German subtitles is just great. On my trip to Zurich in March, I watched like that several movies and bought some DVDs to watch at home. Usually first I watch movie in English with German subtitles. I get the contexts, the plot and connect the subtitles to scenes. Then I watch the movie in German with German subtitles. I don&#8217;t understand everything, but I learn pronunciation, note interesting words, I can follow the plot and I find the movie entertaining instead of being lost.</p>
<h2>Computer</h2>
<p>As mentioned earlier, 20 years ago all apps and games were in English and German. I thought that least I can do, I can change the language of my operating system to German. Of course I can&#8217;t do that with Windows, but I don&#8217;t use it often.<br />
In Ubuntu I just installed the language and put it first on priority list. To my surprise after restart not only my system was in German, but all the applications too! That&#8217;s awesome &#8211; first of all thanks to Ubuntu developers it&#8217;s very simple, second &#8211; I don&#8217;t have to install anything from the beginning, it just works. Also many web search results appear in German, that&#8217;s great! It was 5 minutes of work that put me in the middle of German language. I will be honest with you. I was to partition my disk in laptop to give some more space to Ubuntu. I freaked out when I saw gparted in German. I&#8217;m not in that league yet. Fortunately it&#8217;s super easy to start an application in different language. In the console:</p>
<pre><code>LANGUAGE=en gparted
</code></pre>
<p>And that&#8217;s it. Gparted starts in English if you have English installed. I still shake my head surprised that it is so simple and works so well.</p>
<p>Ok, that&#8217;s it for today. I will publish few more points on my approach soon.</p>
<img src="http://feeds.feedburner.com/~r/TheProgrammerMan/~4/OuT7wNy473w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://theprogrammerman.com/2012/04/12/my-first-steps-in-learning-german/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://theprogrammerman.com/2012/04/12/my-first-steps-in-learning-german/</feedburner:origLink></item>
		<item>
		<title>Git branching model</title>
		<link>http://feedproxy.google.com/~r/TheProgrammerMan/~3/g8HVTSQUNdY/</link>
		<comments>http://theprogrammerman.com/2012/04/11/git-branching-model/#comments</comments>
		<pubDate>Wed, 11 Apr 2012 21:45:26 +0000</pubDate>
		<dc:creator>bibix</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://theprogrammerman.com/?p=248</guid>
		<description><![CDATA[Before I started working with git, I&#8217;ve been involved in setup of release process for our application. We were using svn as a versioning system. When I moved to git (on my laptop only), I had in mind all steps<span class="ellipsis">&#8230;</span> <a href="http://theprogrammerman.com/2012/04/11/git-branching-model/"><div class="read-more">Read more &#8250;</div><!-- end of .read-more --></a>]]></description>
			<content:encoded><![CDATA[<p>Before I started working with git, I&#8217;ve been involved in setup of release process for our application. We were using svn as a versioning system.</p>
<p>When I moved to git (on my laptop only), I had in mind all steps that that lead from first commit to fix a bug, to deployment on production. And I wondered whether it is applicable to git repositories. I have found really nice git branching model: <a href="http://nvie.com/posts/a-successful-git-branching-model/">Git Flow</a>. I can see it is popular and basically isn&#8217;t very different from what we have been using. What I really like about it is that it uses branches a lot. They are so light in git, that using them is almost seamless. All the pain caused by svn&#8217;s slow checkout, branching and merging is cured.</p>
<p>Today creating a branch is first thing I do when I develop some new code for my project. Having a branch lets me commit early and often without messing with what&#8217;s already working. I wouldn&#8217;t mind if Intellij commited a file when I press Ctrl+s, although that could look scary in the repo&#8217;s log:) Until it&#8217;s done, I use Ctrl+k often.</p>
<p>Anyway, the Git Flow model is based on central repository. I wonder if there&#8217;s a distributed release model for dvcs.</p>
<img src="http://feeds.feedburner.com/~r/TheProgrammerMan/~4/g8HVTSQUNdY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://theprogrammerman.com/2012/04/11/git-branching-model/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://theprogrammerman.com/2012/04/11/git-branching-model/</feedburner:origLink></item>
		<item>
		<title>magick: Getting rid of the border</title>
		<link>http://feedproxy.google.com/~r/TheProgrammerMan/~3/MSGjTquYpUA/</link>
		<comments>http://theprogrammerman.com/2012/04/04/magick-getting-rid-of-the-border/#comments</comments>
		<pubDate>Wed, 04 Apr 2012 16:01:21 +0000</pubDate>
		<dc:creator>bibix</dc:creator>
				<category><![CDATA[shell]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[imagemagick]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://theprogrammerman.com/?p=233</guid>
		<description><![CDATA[Having an image of a Super-Tapir, you can see a lot of space around the main character. Knowing exact position of the superhero would ease removal of the border, but looking for it might be painful. Fortunately someone before me<span class="ellipsis">&#8230;</span> <a href="http://theprogrammerman.com/2012/04/04/magick-getting-rid-of-the-border/"><div class="read-more">Read more &#8250;</div><!-- end of .read-more --></a>]]></description>
			<content:encoded><![CDATA[<p>Having an image of a Super-Tapir, you can see a lot of space around the main character.<br />
<img src="http://theprogrammerman.com/wp-content/uploads/2012/04/supertapir1.jpg" alt="" title="supertapir" width="167" height="100" class="aligncenter size-full wp-image-241" /></p>
<p>Knowing exact position of the superhero would ease removal of the border, but looking for it might be painful. Fortunately someone before me had this problem. There are actually several methods to remove excess of pixels. The one I used is the <strong>trim</strong> method.</p>
<pre class="brush:bash">convert supertapir.jpg -trim tapir-trim-sample01.jpg
</pre>
<p>And the result</p>
<p><img src="http://theprogrammerman.com/wp-content/uploads/2012/04/supertapir-trim01.jpg" alt="" title="supertapir-trim01" width="146" height="82" class="aligncenter size-full wp-image-242" /></p>
<p>is not exactly what I expected. The border recognition needs to be a bit more tolerant to color changes and you can control it with <strong>-fuzz</strong> parameter.</p>
<pre class="brush:bash">convert supertapir.jpg -fuzz 5% -trim tapir-trim-sample02.jpg
</pre>
<p><img src="http://theprogrammerman.com/wp-content/uploads/2012/04/supertapir-trim02.jpg" alt="" title="supertapir-trim02" width="133" height="76" class="aligncenter size-full wp-image-243" /> Fanfares! Works like a charm.</p>
<img src="http://feeds.feedburner.com/~r/TheProgrammerMan/~4/MSGjTquYpUA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://theprogrammerman.com/2012/04/04/magick-getting-rid-of-the-border/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://theprogrammerman.com/2012/04/04/magick-getting-rid-of-the-border/</feedburner:origLink></item>
		<item>
		<title>magick: Converting set of images to single pdf</title>
		<link>http://feedproxy.google.com/~r/TheProgrammerMan/~3/kJgFIZApD88/</link>
		<comments>http://theprogrammerman.com/2012/04/04/magick-converting-set-of-images-to-single-pdf/#comments</comments>
		<pubDate>Tue, 03 Apr 2012 22:29:57 +0000</pubDate>
		<dc:creator>bibix</dc:creator>
				<category><![CDATA[shell]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[imagemagick]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://theprogrammerman.com/?p=217</guid>
		<description><![CDATA[Some tasks are so simple that it&#8217;s just hard to believe. The tool I use is imagemagick sudo apt-get install imagemagick It has plenty of options and they just pop up when I need them. After manually aligning set of<span class="ellipsis">&#8230;</span> <a href="http://theprogrammerman.com/2012/04/04/magick-converting-set-of-images-to-single-pdf/"><div class="read-more">Read more &#8250;</div><!-- end of .read-more --></a>]]></description>
			<content:encoded><![CDATA[<p>Some tasks are so simple that it&#8217;s just hard to believe. The tool I use is <strong>imagemagick</strong></p>
<pre class="brush:bash">sudo apt-get install imagemagick
</pre>
<p>It has plenty of options and they just pop up when I need them. After manually aligning set of images in Libre Office, finding out that single command can do it really impressed me. I can see many one-liners in my life.</p>
<p>So, having several images:</p>
<pre class="brush:bash">img00.jpg
img01.jpg
...
img99.jpg
</pre>
<p>All you need to do is pick a good name for your pdf</p>
<pre class="brush:bash">convert img*.jpg images.pdf
</pre>
<p>I expected imagemagick to be able to batch convert images and crop or resize them.</p>
<pre class="brush:bash">convert img*.jpg -resize 50% img-small%d.jpg
</pre>
<p>Where <strong>%d</strong> will be replaced with processed file number.<br />
But more time we spend together, more powerful it looks.</p>
<img src="http://feeds.feedburner.com/~r/TheProgrammerMan/~4/kJgFIZApD88" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://theprogrammerman.com/2012/04/04/magick-converting-set-of-images-to-single-pdf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://theprogrammerman.com/2012/04/04/magick-converting-set-of-images-to-single-pdf/</feedburner:origLink></item>
		<item>
		<title>Do you Git?</title>
		<link>http://feedproxy.google.com/~r/TheProgrammerMan/~3/51BZ_SY2VZk/</link>
		<comments>http://theprogrammerman.com/2012/03/10/do-you-git/#comments</comments>
		<pubDate>Sat, 10 Mar 2012 00:25:45 +0000</pubDate>
		<dc:creator>bibix</dc:creator>
				<category><![CDATA[shell]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[dot files]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[prompt]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://theprogrammerman.com/?p=172</guid>
		<description><![CDATA[The title tells everything. I&#8217;ve started using git about 1.5 year ago to work with remote svn repo in a more pleasant way. It was a blessing. I could switch between branches quickly, work on feature branches and stash refactorings<span class="ellipsis">&#8230;</span> <a href="http://theprogrammerman.com/2012/03/10/do-you-git/"><div class="read-more">Read more &#8250;</div><!-- end of .read-more --></a>]]></description>
			<content:encoded><![CDATA[<p>The title tells everything. I&#8217;ve started using git about 1.5 year ago to work with remote svn repo in a more pleasant way. It was a blessing. I could switch between branches quickly, work on feature branches and stash refactorings (I&#8217;ve been using Intellij&#8217;s feature for this earlier). There was still svn on the other side, so I couldn&#8217;t fully benefit from &#8220;distributed&#8221; part of git. What a change it was anyway! Now git is a core part of every single day. I use it for all kind of projects, not only dev. I version Ubuntu&#8217;s dot files, cv &amp; other docs, scripts. The best thing is sharing. First time it took me just couple minutes to share the project over LAN. I was very surprised that it&#8217;s so easy. With git&#8217;s support for ssh you just clone the repo as any other from the web. It&#8217;s so nice to have multiple versions of documents on branches with all their history. I used to use multiple directories and accidental overwrite was a disaster. Now I just clone repository to another computer and have a backup of all versions with their history. It&#8217;s like two more dimensions of file hierarchy &#8211; I get history and multiple versions. Plus everything is well commented in the log. So, I added a line to my <em>.bashrc</em> to modify my prompt line. It now displays branch I&#8217;m on and number of added/deleted/modified files.
<pre class="brush: bash; title: ; notranslate"> PS&amp;#92;_GIT&amp;#92;_PART=&amp;quot;(git branch 2&amp;gt;/dev/null | grep -e '&amp;#92;* ' | sed 's/^..&amp;#92;(.&lt;em&gt;&amp;#92;)/{&amp;#92;1|/'; git status | grep -c -e '#.&lt;/em&gt;&amp;#92;(modified&amp;#92;|new file&amp;#92;|deleted&amp;#92;):' | sed 's/&amp;#92;(.*&amp;#92;)/&amp;#92;1}/') | sed '$!N;s:&amp;#92;&amp;#92;&amp;#92;n::' &amp;quot; </pre>
<p> Ok, I agree that it&#8217;s write only:) It should be in one line in .bashrc. Now last thing is to make it part of your PS1. Like this
<pre class="brush: bash; title: ; notranslate"> PS1=&quot;... &#92;$($PS&#92;_GIT&#92;_PART) ...&quot; </pre>
<p> And now my prompt looks like this:
<pre class="brush: bash; title: ; notranslate"> bibix@sputnik:~{master|1}$ </pre>
<p> There&#8217;s no need now to check branch or status every time I change directory to some git repo.</p>
<img src="http://feeds.feedburner.com/~r/TheProgrammerMan/~4/51BZ_SY2VZk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://theprogrammerman.com/2012/03/10/do-you-git/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://theprogrammerman.com/2012/03/10/do-you-git/</feedburner:origLink></item>
		<item>
		<title>Problem 24 in Scala</title>
		<link>http://feedproxy.google.com/~r/TheProgrammerMan/~3/MQykjjQ68Uk/</link>
		<comments>http://theprogrammerman.com/2011/10/27/problem-24-in-scala/#comments</comments>
		<pubDate>Thu, 27 Oct 2011 14:43:23 +0000</pubDate>
		<dc:creator>bibix</dc:creator>
				<category><![CDATA[project euler]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://theprogrammerman.com/?p=156</guid>
		<description><![CDATA[So, it&#8217;s more than two years since I started to use Groovy. At the beginning I solved couple Project Euler problems and moved to scripting. I still love Groovy, but couple months ago I started to look at Scala. What<span class="ellipsis">&#8230;</span> <a href="http://theprogrammerman.com/2011/10/27/problem-24-in-scala/"><div class="read-more">Read more &#8250;</div><!-- end of .read-more --></a>]]></description>
			<content:encoded><![CDATA[<p>So, it&#8217;s more than two years since I started to use Groovy.<br />
At the beginning I solved couple Project Euler problems and moved to scripting. I still love Groovy, but couple months ago I started to look at Scala. What can I say about it?</p>
<p>IT IS AWESOME</p>
<p>Until I started using it, I was thinking that dynamic typing is just a hidden cost of all the features I get with Groovy. Errors at run-time were painful, but I quickly learned the patterns to follow when developing dynamically typed code.</p>
<p>With Scala I found out that static typing can be used together with all those higher order functions, functional programming etc. And it makes me much more comfortable.</p>
<p>I approached Scala the usual way. I solved first problem from Project Euler. It worked fine, but I didn&#8217;t like the style. There was too much Java in my Scala code and I knew it can look better, more functional. And the only functional language I had been using so far was Haskell.<br />
So, I took a Haskell tutorial from <a href="http://en.wikibooks.org/wiki/Haskell" title="http://en.wikibooks.org/wiki/Haskell" target="_blank"></a> and started to look for similarities in Scala. Rewriting Project Euler&#8217;s solutions in functional style was a lot of fun and training for my brain. Now it&#8217;s more natural.</p>
<p>Since I posted solution for the Problem 024 in Groovy. Here&#8217;s one in Scala:</p>
<pre class="brush: scala; title: ; notranslate">
object Problem024 extends App {
  val nums = (0 until 10).toList.permutations
  val result = nums drop(999999) next() map(_.toString) reduce(_+_)
  Console.println(result)
}
</pre>
<p>It&#8217;s a simple bruteforce. What is beautiful about it? The <code>List.permutations</code> method returns <code>Iterator</code>. In Groovy similar method returns a <code>Set</code> which makes it almost useless. There&#8217;s an alternative method in Groovy <code>Collection.eachPermutation</code>, but it takes a closure as a parameter. The third option is using <code>PermutationGenerator</code> which returns an <code>Iterator</code>, which I didn&#8217;t know of two years ago.</p>
<p>What I see is that Scala&#8217;s type system is really well thought. If there are or were any glitches, they were quickly fixed (from small version to small version). It&#8217;s not <del>four</del> two years development cycle like in case of Java.</p>
<p>So far, I&#8217;ve solved more than 40 problems in Project Euler. You can see sources at <a href="https://github.com/bibix/euler" title="github.com/bibix/euler" target="_blank">https://github.com/bibix/euler</a>. And many of them are one-liners thanks to Scala.</p>
<p>And you can always <a href="http://www.twitter.com/bibixdev">follow me on Twitter</a></p>
<img src="http://feeds.feedburner.com/~r/TheProgrammerMan/~4/MQykjjQ68Uk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://theprogrammerman.com/2011/10/27/problem-24-in-scala/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://theprogrammerman.com/2011/10/27/problem-24-in-scala/</feedburner:origLink></item>
		<item>
		<title>Gradle snippets: Modularize your scripts</title>
		<link>http://feedproxy.google.com/~r/TheProgrammerMan/~3/RTnl_UY_8Lw/</link>
		<comments>http://theprogrammerman.com/2011/03/07/gradle-snippets-modularize-your-scripts/#comments</comments>
		<pubDate>Mon, 07 Mar 2011 22:28:48 +0000</pubDate>
		<dc:creator>bibix</dc:creator>
				<category><![CDATA[gradle snippets]]></category>
		<category><![CDATA[build configuration]]></category>
		<category><![CDATA[groovy]]></category>

		<guid isPermaLink="false">http://theprogrammerman.com/?p=146</guid>
		<description><![CDATA[Build files tend to grow in time. New tasks are added, some customizations are made and you end up with several pages of groovy code. Gradle is based on Groovy, so many constructs can be really simplified, but often it&#8217;s<span class="ellipsis">&#8230;</span> <a href="http://theprogrammerman.com/2011/03/07/gradle-snippets-modularize-your-scripts/"><div class="read-more">Read more &#8250;</div><!-- end of .read-more --></a>]]></description>
			<content:encoded><![CDATA[<p>Build files tend to grow in time. New tasks are added, some customizations are made and you end up with several pages of groovy code. Gradle is based on Groovy, so many constructs can be really simplified, but often it&#8217;s not enough. That&#8217;s where Gradle comes in. You can split your build files into logical pieces:</p>
<pre class="brush: groovy; title: ; notranslate">
// in build.gradle
apply from: &quot;libraries.gradle&quot;
apply from: &quot;subprojectsTasks.gradle&quot;
</pre>
<pre class="brush: groovy; title: ; notranslate">
// in libraries.gradle
versions = [
  abc: &quot;1.6&quot;
]

libraries = [
  abc: &quot;org.abc:abc:${versions.abc}&quot;
]
</pre>
<pre class="brush: groovy; title: ; notranslate">
// in subprojetsTasks.gradle
subprojects {
  apply plugin:&quot;java&quot;

  dependencies {
    compile libraries.abc
  }
}
</pre>
<p>And that&#8217;s it. You can safely split your build file into logical parts. </p>
<img src="http://feeds.feedburner.com/~r/TheProgrammerMan/~4/RTnl_UY_8Lw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://theprogrammerman.com/2011/03/07/gradle-snippets-modularize-your-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://theprogrammerman.com/2011/03/07/gradle-snippets-modularize-your-scripts/</feedburner:origLink></item>
		<item>
		<title>Gradle snippets: extract your dependencies</title>
		<link>http://feedproxy.google.com/~r/TheProgrammerMan/~3/aNBkR5jpmwA/</link>
		<comments>http://theprogrammerman.com/2011/01/20/gradle-snippets-extract-your-dependencies/#comments</comments>
		<pubDate>Thu, 20 Jan 2011 22:51:32 +0000</pubDate>
		<dc:creator>bibix</dc:creator>
				<category><![CDATA[gradle snippets]]></category>
		<category><![CDATA[build configuration]]></category>
		<category><![CDATA[dependencies]]></category>
		<category><![CDATA[groovy]]></category>

		<guid isPermaLink="false">http://theprogrammerman.com/?p=138</guid>
		<description><![CDATA[I believe you&#8217;ll find this in every gradle project you can download from the net. Since it&#8217;s groovy it&#8217;s best to just declare a map with your external dependencies in root project. You can then use it in your subprojects<span class="ellipsis">&#8230;</span> <a href="http://theprogrammerman.com/2011/01/20/gradle-snippets-extract-your-dependencies/"><div class="read-more">Read more &#8250;</div><!-- end of .read-more --></a>]]></description>
			<content:encoded><![CDATA[<p>I believe you&#8217;ll find this in every gradle project you can download from the net. Since it&#8217;s groovy it&#8217;s best to just declare a map with your external dependencies in root project. You can then use it in your subprojects just by accessing a key from map.</p>
<p>Let&#8217;s see a sample configuration:</p>
<pre class="brush: groovy; title: ; notranslate">
// def versions would create script local variable
versions = [
        camel: &quot;2.5.0&quot;
]

libraries = [
        camel: [group:&quot;org.apache.camel&quot;, name:&quot;camel-core&quot;, version:versions.camel],
        camelBindy: &quot;org.apache.camel:camel-bindy:${versions.camel}&quot;
]
</pre>
<p>You can see two maps actually: <em>versions</em> and <em>variables</em>.<br />
First one defines versions used for particular libraries. Since camel version is used in multiple places, you can just extract it and keep outside the libraries definitions.<br />
<em>Libraries</em> is a map of our dependencies.</p>
<p>Usage is also simple:</p>
<pre class="brush: groovy; title: ; notranslate">
// somewhere in root project or subprojects
dependencies {
  compile libraries.camel
  compile libraries.camelBindy
}
</pre>
<img src="http://feeds.feedburner.com/~r/TheProgrammerMan/~4/aNBkR5jpmwA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://theprogrammerman.com/2011/01/20/gradle-snippets-extract-your-dependencies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://theprogrammerman.com/2011/01/20/gradle-snippets-extract-your-dependencies/</feedburner:origLink></item>
		<item>
		<title>Gradle snippets: Rename your subprojects’ build files</title>
		<link>http://feedproxy.google.com/~r/TheProgrammerMan/~3/34bQq_9-dlw/</link>
		<comments>http://theprogrammerman.com/2010/11/28/gradle-snippets-rename-your-subprojects-build-files/#comments</comments>
		<pubDate>Sun, 28 Nov 2010 21:18:37 +0000</pubDate>
		<dc:creator>bibix</dc:creator>
				<category><![CDATA[gradle snippets]]></category>
		<category><![CDATA[build configuration]]></category>
		<category><![CDATA[gradle]]></category>
		<category><![CDATA[groovy]]></category>

		<guid isPermaLink="false">http://theprogrammerman.com/?p=131</guid>
		<description><![CDATA[It&#8217;s good to have project separated into modules. It encourages separation of functionalities and simplifies code. Fortunately gradle supports multiple projects very well. Having a project with 2 modules like this: - awesome-project-root -- build.gradle -- settings.gradle -+ persistence ----<span class="ellipsis">&#8230;</span> <a href="http://theprogrammerman.com/2010/11/28/gradle-snippets-rename-your-subprojects-build-files/"><div class="read-more">Read more &#8250;</div><!-- end of .read-more --></a>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s good to have project separated into modules. It encourages separation of functionalities and simplifies code. Fortunately gradle supports multiple projects very well.<br />
Having a project with 2 modules like this:</p>
<pre>
- awesome-project-root
-- build.gradle
-- settings.gradle
-+ persistence
---- build.gradle
-+ processing
---- build.gradle
</pre>
<p>Next thing is to add to <em>settings.gradle</em> several lines with subprojects:</p>
<pre class="brush: groovy; title: build.gradle; notranslate">
include &quot;persistence&quot;
include &quot;processing&quot;
</pre>
<p>Since now you have 3 <em>build.gradle</em> files in your repository. They are configured as subprojects. You may read more about subprojects in <a href="http://gradle.org/0.9-rc-3/docs/userguide/multi_project_builds.html">gradle&#8217;s documentation</a>. It may be confusing when your projects grows up and you&#8217;ll have more of them.</p>
<p>Really nice thing I&#8217;ve found in hibernate&#8217;s configuration (see <a href="https://github.com/hibernate/hibernate-core">https://github.com/hibernate/hibernate-core</a>), is renaming of all these build.gradle files.</p>
<pre class="brush: groovy; title: settings.gradle; notranslate">
rootProject.children.each { project -&gt;
    project.buildFileName = &quot;${project.name}.gradle&quot;
    assert project.projectDir.isDirectory()
    assert project.buildFile.isFile()
}
</pre>
<p>This little code snippet lets gradle know that your project&#8217;s structure will be:</p>
<pre>
awesome-project-root
-- build.gradle
-- settings.gradle
-+ persistence
---- <strong><em>persistence.gradle</em></strong>
-+ processing
---- <strong><em>processing.gradle</em></strong>
</pre>
<p>And this really simplifies navigation. I think it&#8217;d be nice if gradle supported both naming conventions.</p>
<img src="http://feeds.feedburner.com/~r/TheProgrammerMan/~4/34bQq_9-dlw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://theprogrammerman.com/2010/11/28/gradle-snippets-rename-your-subprojects-build-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://theprogrammerman.com/2010/11/28/gradle-snippets-rename-your-subprojects-build-files/</feedburner:origLink></item>
		<item>
		<title>It’s all about dynamic</title>
		<link>http://feedproxy.google.com/~r/TheProgrammerMan/~3/e2CA7G2nT-o/</link>
		<comments>http://theprogrammerman.com/2010/02/22/its-all-about-dynamic/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 20:08:48 +0000</pubDate>
		<dc:creator>bibix</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[design pattern]]></category>
		<category><![CDATA[groovy]]></category>

		<guid isPermaLink="false">http://theprogrammerman.com/?p=99</guid>
		<description><![CDATA[In previous post I mentioned about the visitor pattern and how to use it in Java. I also use groovy in my projects and there&#8217;s a much better way to solve the problem with processing collections. I have found a<span class="ellipsis">&#8230;</span> <a href="http://theprogrammerman.com/2010/02/22/its-all-about-dynamic/"><div class="read-more">Read more &#8250;</div><!-- end of .read-more --></a>]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://theprogrammerman.com/2010/02/14/visitor-pattern-in-java/">previous post</a> I mentioned about the visitor pattern and how to use it in Java. I also use groovy in my projects and there&#8217;s a much better way to solve the problem with processing collections.</p>
<p>I have found a site about <a href="http://nice.sourceforge.net/visitor.html">shortcomings of the visitor pattern</a>.<br />
The proposed solution in <a href="http://nice.sourceforge.net/">Nice</a> programming language are, so called, multimethods.<br />
I asked myself if I could use similar solution in groovy. The answer is yes, fortunately. Multimethods (or multiple dispatch) can be used in groovy. </p>
<p>In groovy you don&#8217;t have to implement visitor pattern and extend your domain objects. The following code will work just as you would expect:</p>
<pre class="brush: groovy; title: ; notranslate">
// Base class
class Feature {
    String name

    public String toString() {
        return &quot;Feature{&quot; +
                &quot;name='&quot; + name + '\'' +
                '}';
    }
}

class BooleanFeature extends Feature{
    boolean value

    public String toString() {
        return &quot;BooleanFeature{&quot; +
                &quot;value=&quot; + value +
                '}';
    }
}

class StringFeature extends Feature{
    String value

    public String toString() {
        return &quot;StringFeature{&quot; +
                &quot;value='&quot; + value + '\'' +
                '}';
    }
}

// Class that processes Feature and its descendants
class Multimethod {
    def printFeature(Feature feature) {
        println &quot;printFeature: $feature&quot;
    }

    def printFeature(BooleanFeature feature) {
        println &quot;printBooleanFeature: $feature&quot;
    }

    def printFeature(StringFeature feature) {
        println &quot;printStringFeature: $feature&quot;
    }
}

Feature feature = new Feature(name:'feature')
Feature booleanFeature = new BooleanFeature(name:'booleanFeature', value:true)
Feature stringFeature = new StringFeature(name:'stringFeature', value:'Hello world')
List&lt;Feature&gt; features = [feature, booleanFeature, stringFeature, otherFeature]

Multimethod multimethod = new Multimethod()

features.each { multimethod.printFeature it}
</pre>
<p>The output is:</p>
<pre class="brush: plain; title: ; notranslate">
printFeature: Feature{name='feature'}
printBooleanFeature: BooleanFeature{value=true}
printStringFeature: StringFeature{value='Hello world'}
</pre>
<p>You can see the <em>Feature</em> class and some simple hierarchy. They represent domain classes. The <em>Multimethod</em> class is our processor. It would have to be a Visitor in java, in order to correctly process the collection of <em>Feature</em> elements. It&#8217;s not the case in groovy, as it dynamically resolves the type of parameters during runtime. </p>
<p>It saves a lot of coding. Now there&#8217;s no need to create class hierarchy only to process a collection properly. This also means, that there&#8217;s no need to overload a method for all classes that extend the <em>Feature</em> class.</p>
<img src="http://feeds.feedburner.com/~r/TheProgrammerMan/~4/e2CA7G2nT-o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://theprogrammerman.com/2010/02/22/its-all-about-dynamic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://theprogrammerman.com/2010/02/22/its-all-about-dynamic/</feedburner:origLink></item>
	</channel>
</rss>

