<?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>Blog.Project13.pl &#187; guide</title>
	<atom:link href="http://www.blog.project13.pl/index.php/category/guide/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.blog.project13.pl</link>
	<description>The Blog of a Coder</description>
	<lastBuildDate>Sun, 05 Feb 2012 02:28:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Keeping processes alive using God&#8217;s power</title>
		<link>http://www.blog.project13.pl/index.php/coding/1338/keeping-processes-alive-using-gods-power/</link>
		<comments>http://www.blog.project13.pl/index.php/coding/1338/keeping-processes-alive-using-gods-power/#comments</comments>
		<pubDate>Thu, 04 Aug 2011 17:48:21 +0000</pubDate>
		<dc:creator>Ktoso</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[terminal heroes]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[god]]></category>
		<category><![CDATA[keep alive]]></category>
		<category><![CDATA[process watch]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.blog.project13.pl/?p=1338</guid>
		<description><![CDATA[God is a nice &#8220;framework&#8221; and daemon to watch Linux processes and restart them if necessary. As I&#8217;ve configured it today to work on an ubuntu machine here&#8217;s a quick howto: First install ruby, gem and god. apt-get install ruby, rubygems gem install god Then paste this initscript into /etc/init.d/god: got init script. Configure it [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://god.rubyforge.org/" onclick="urchinTracker('/outgoing/god.rubyforge.org/?referer=');"><strong>God</strong></a> is a nice &#8220;framework&#8221; and daemon to watch Linux processes and restart them if necessary. As I&#8217;ve configured it today to work on an ubuntu machine here&#8217;s a quick howto:</p>
<p>First install ruby, gem and god.</p>
<pre>
apt-get install ruby, rubygems
gem install god
</pre>
<p>Then paste this initscript into <strong>/etc/init.d/god</strong>: <a href="http://openmonkey.com/2008/05/27/god-init-script-for-debian-ubuntu-systems/" onclick="urchinTracker('/outgoing/openmonkey.com/2008/05/27/god-init-script-for-debian-ubuntu-systems/?referer=');">got init script</a>. Configure it to use <strong>/etc/god/config.rb</strong> for example, and there do some minor setup (using ruby, yay) so we can get emails if something happenes:</p>
<div class="geshi no ruby">
<ol>
<li class="li1">
<div class="de1"><span class="kw3">require</span> <span class="kw4">File</span>.<span class="me1">dirname</span><span class="br0">&#40;</span><span class="kw2">__FILE__</span><span class="br0">&#41;</span> <span class="sy0">+</span> <span class="st0">&#39;/watches.rb&#39;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1"># mailer configuration</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1"># &#8230;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re2">God::Contacts::Email</span>.<span class="me1">delivery_method</span> = <span class="re3">:sendmail</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">God.<span class="me1">contact</span><span class="br0">&#40;</span><span class="re3">:email</span><span class="br0">&#41;</span> <span class="kw1">do</span> <span class="sy0">|</span>c<span class="sy0">|</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; c.<span class="me1">name</span> = <span class="st0">&#39;ktoso&#39;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; c.<span class="me1">to_email</span> = <span class="st0">&#39;konrad.malawski@llp.pl&#39;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">end</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1"># include all watches</span></div>
</li>
<li class="li1">
<div class="de1">God.<span class="kw3">load</span> <span class="st0">&quot;/etc/god/watches/*.rb&quot;</span></div>
</li>
</ol>
</div>
<p>And then all that&#8217;s left to implement is a watch, so create an <strong>/etc/god/watches/xvbf.rb</strong>. It&#8217;s using a nice DSL to configure how God should act when a process dies etc:</p>
<div class="geshi no ruby">
<ol>
<li class="li1">
<div class="de1">God.<span class="me1">watch</span> <span class="kw1">do</span> <span class="sy0">|</span>w<span class="sy0">|</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; w.<span class="me1">uid</span> = <span class="st0">&quot;jenkins&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; w.<span class="me1">gid</span> = <span class="st0">&quot;jenkins&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; w.<span class="me1">name</span> = <span class="st0">&quot;xvfb&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; w.<span class="me1">interval</span> = <span class="nu0">30</span>.<span class="me1">seconds</span> <span class="co1"># default</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; w.<span class="me1">env</span> = <span class="br0">&#123;</span> <span class="st0">&quot;DISPLAY&quot;</span> <span class="sy0">=&gt;</span> <span class="st0">&quot;:99&quot;</span> <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; w.<span class="me1">start</span> = <span class="st0">&quot;Xvfb -ac :99 &amp;&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; w.<span class="me1">start_grace</span> = <span class="nu0">10</span>.<span class="me1">seconds</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; w.<span class="me1">restart_grace</span> = <span class="nu0">10</span>.<span class="me1">seconds</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; w.<span class="me1">behavior</span><span class="br0">&#40;</span><span class="re3">:clean_pid_file</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; w.<span class="me1">start_if</span> <span class="kw1">do</span> <span class="sy0">|</span>start<span class="sy0">|</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; start.<span class="me1">condition</span><span class="br0">&#40;</span><span class="re3">:process_running</span><span class="br0">&#41;</span> <span class="kw1">do</span> <span class="sy0">|</span>c<span class="sy0">|</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; c.<span class="me1">running</span> = <span class="kw2">false</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; c.<span class="me1">notify</span> = <span class="br0">&#91;</span><span class="st0">&#39;konrad&#39;</span><span class="br0">&#93;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">end</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">end</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">end</span></div>
</li>
</ol>
</div>
<p>The code is pretty much self explanatory. We watch if the process Xvfb is running, and if not, after the grace period we restart it. Optional info email could also be sent using the notify property.</p>
<p>That&#8217;s it, have fun automating your build environments!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.project13.pl/index.php/coding/1338/keeping-processes-alive-using-gods-power/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[git] bisect + maven = automate &#8220;breaking&#8221; commit search</title>
		<link>http://www.blog.project13.pl/index.php/coding/1217/git-bisect-maven-automate-breaking-commit-search/</link>
		<comments>http://www.blog.project13.pl/index.php/coding/1217/git-bisect-maven-automate-breaking-commit-search/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 21:34:31 +0000</pubDate>
		<dc:creator>Ktoso</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[terminal heroes]]></category>
		<category><![CDATA[#maven]]></category>
		<category><![CDATA[bisect]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[runner]]></category>
		<category><![CDATA[SCM]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.blog.project13.pl/?p=1217</guid>
		<description><![CDATA[Hey there guys. I hope some you enjoyed my presentation on SFI last weekend. The workshop was kinda chaotic (network problems mailny) but I&#8217;m sure some of you got convinced to use, or begin with trying out, git in yout next projects&#8230; :-) Well, that was all nice and cool but git (other DVCS have [...]]]></description>
			<content:encoded><![CDATA[<p>Hey there guys. I hope some you enjoyed my presentation on SFI last weekend. The workshop was kinda chaotic (network problems mailny) but I&#8217;m sure some of you got convinced to use, or begin with trying out, git in yout next projects&#8230; :-)</p>
<p>Well, that was all nice and cool but git (other DVCS have this too) has a lot more to offer! :-) Today we&#8217;ll look into git bisect and how to automate it&#8217;s execution using maven to look for a commit that breakes something. You may run ANY SCRIPT and even write your own and git will use it to test if a commit is &#8220;bad&#8221; or &#8220;good&#8221;. Ok, but let&#8217;s slowdown a little&#8230; What git bisect basically does is performing an binary search, between a range of commits you specify looking for &#8220;the first bad commit&#8221; you you can easily find what caused the bug and fix it. You can drive it by hand and after starting git bisect just test the commit by hand and tell git if it&#8217;s good or bad by &#8220;git bisect bad&#8221; &#8220;git bisect good&#8221;. Git is smart enough to find what commit he should &#8220;git checkout &#8230;&#8221; next to perform a binary search based on your anwsers. </p>
<p>Today we&#8217;ll learn how to make git cooperate with maven and find the first commit that introduced a test failure. See bellow for the full workflow you showcasing this:</p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames breakMe $ mvn org.apache.maven.plugins:maven-archetype-plugin:<span class="nu0">1.0</span>-alpha<span class="nu0">-7</span>:create -<span class="re2">DarchetypeGroupId=</span>org.apache.maven.archetypes -<span class="re2">DarchetypeArtifactId=</span>maven-archetype-quickstart -<span class="re2">DartifactId=</span>bisectfun -<span class="re2">DgroupId=</span>pl.project13</div>
</li>
<li class="li1">
<div class="de1"><span class="co0">#&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.</span></div>
</li>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames breakMe $ <span class="kw2">ls</span></div>
</li>
<li class="li1">
<div class="de1">bisectfun &nbsp;mavenbisect.<span class="kw2">sh</span></div>
</li>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames breakMe $ <span class="kw3">cd</span> bisectfun<span class="sy0">/</span></div>
</li>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames bisectfun $ <span class="kw2">mkdir</span> src<span class="sy0">/</span><span class="kw3">test</span><span class="sy0">/</span>resources<span class="sy0">/</span></div>
</li>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames bisectfun $ git init .</div>
</li>
<li class="li1">
<div class="de1">Initialized empty Git repository <span class="kw1">in</span> <span class="sy0">/</span>tmp<span class="sy0">/</span>breakMe<span class="sy0">/</span>bisectfun<span class="sy0">/</span>.git<span class="sy0">/</span></div>
</li>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames bisectfun $ git commit ^C</div>
</li>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames bisectfun $ vim .gitignore</div>
</li>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames bisectfun $ git add .</div>
</li>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames bisectfun $ git commit </div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#91;</span>master <span class="br0">&#40;</span>root-commit<span class="br0">&#41;</span> 5b46510<span class="br0">&#93;</span> &nbsp;Initial commit</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="nu0">4</span> files changed, <span class="nu0">78</span> insertions<span class="br0">&#40;</span>+<span class="br0">&#41;</span>, <span class="nu0">0</span> deletions<span class="br0">&#40;</span>-<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;create mode <span class="nu0">100644</span> .gitignore</div>
</li>
<li class="li1">
<div class="de1">&nbsp;create mode <span class="nu0">100644</span> pom.xml</div>
</li>
<li class="li1">
<div class="de1">&nbsp;create mode <span class="nu0">100644</span> src<span class="sy0">/</span>main<span class="sy0">/</span>java<span class="sy0">/</span>pl<span class="sy0">/</span>project13<span class="sy0">/</span>App.java</div>
</li>
<li class="li1">
<div class="de1">&nbsp;create mode <span class="nu0">100644</span> src<span class="sy0">/</span><span class="kw3">test</span><span class="sy0">/</span>java<span class="sy0">/</span>pl<span class="sy0">/</span>project13<span class="sy0">/</span>AppTest.java</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">********************************************************************************</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Git Achievement Unlocked<span class="sy0">!</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Master Author <span class="br0">&#40;</span>Level <span class="nu0">10</span><span class="br0">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Made <span class="nu0">2</span>^Level commits using git commit. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">********************************************************************************</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0">#&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.</span></div>
</li>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames bisectfun <span class="sy0">@</span> master $ mvn <span class="kw3">test</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0">#&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#91;</span>INFO<span class="br0">&#93;</span> BUILD SUCCESSFUL</div>
</li>
<li class="li1">
<div class="de1"><span class="co0">#&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.</span></div>
</li>
</ol>
</div>
<p>Ok up until now we&#8217;ve just created a simple repository we&#8217;ll be running the tests on. Let&#8217;s tag this state as &#8220;yeah it&#8217;s working here&#8221; just so that I don&#8217;t have to remeber the SHA-1 of this commit. </p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames bisectfun <span class="sy0">@</span> master $ git tag wasOkHere</div>
</li>
</ol>
</div>
<p>And now we&#8217;ll run a script that does some random commit action, just so that bisect has a lot of commits to work on.</p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames bisectfun <span class="sy0">@</span> master $ <span class="kw1">for</span> i <span class="kw1">in</span> <span class="br0">&#123;</span><span class="nu0">1</span>..<span class="nu0">50</span><span class="br0">&#125;</span>; <span class="kw1">do</span> fortune <span class="sy0">&gt;</span> src<span class="sy0">/</span><span class="kw3">test</span><span class="sy0">/</span>resources<span class="sy0">/</span>fortune<span class="re1">$i</span>; git add .; git commit -a -m <span class="st0">&#39;some commit&#39;</span>; <span class="kw1">done</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#91;</span>master 20ae1c1<span class="br0">&#93;</span> some commit</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="nu0">1</span> files changed, <span class="nu0">3</span> insertions<span class="br0">&#40;</span>+<span class="br0">&#41;</span>, <span class="nu0">0</span> deletions<span class="br0">&#40;</span>-<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;create mode <span class="nu0">100644</span> src<span class="sy0">/</span><span class="kw3">test</span><span class="sy0">/</span>resources<span class="sy0">/</span>fortune1</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#91;</span>master 64b779e<span class="br0">&#93;</span> some commit</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="nu0">1</span> files changed, <span class="nu0">15</span> insertions<span class="br0">&#40;</span>+<span class="br0">&#41;</span>, <span class="nu0">0</span> deletions<span class="br0">&#40;</span>-<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;create mode <span class="nu0">100644</span> src<span class="sy0">/</span><span class="kw3">test</span><span class="sy0">/</span>resources<span class="sy0">/</span>fortune2</div>
</li>
<li class="li1">
<div class="de1"><span class="co0">#&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0">#&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0">#&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.</span></div>
</li>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames bisectfun <span class="sy0">@</span> master $ mvn clean <span class="kw3">test</span> <span class="sy0">&gt;</span> <span class="sy0">/</span>dev<span class="sy0">/</span>null <span class="nu0">2</span><span class="sy0">&gt;</span> <span class="sy0">/</span>dev<span class="sy0">/</span>null</div>
</li>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames bisectfun <span class="sy0">@</span> master $ <span class="kw3">echo</span> <span class="re4">$?</span></div>
</li>
<li class="li1">
<div class="de1"><span class="nu0">0</span></div>
</li>
</ol>
</div>
<p>The tests are still passing&#8230; time to change that! We&#8217;ll break the build with the following commit. And then generate yet another 50 commits to &#8220;hide it&#8221;&#8230; ;-)</p>
<div class="geshi no bash">
<div class="head">ktoso@dynames bisectfun @ master $ echo &#8220;fail :D&#8221; >> src/test/java/pl/project13/AppTest.java</div>
<ol>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames bisectfun <span class="sy0">@</span> master $ <span class="kw3">echo</span> <span class="st0">&quot;fail :D&quot;</span> <span class="sy0">&gt;&gt;</span> src<span class="sy0">/</span><span class="kw3">test</span><span class="sy0">/</span>java<span class="sy0">/</span>pl<span class="sy0">/</span>project13<span class="sy0">/</span>AppTest.java </div>
</li>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames bisectfun <span class="sy0">@</span> master $ <span class="kw3">echo</span> <span class="st0">&quot;fail :D&quot;</span> <span class="sy0">&gt;&gt;</span> src<span class="sy0">/</span><span class="kw3">test</span><span class="sy0">/</span>java<span class="sy0">/</span>pl<span class="sy0">/</span>project13<span class="sy0">/</span>AppTest.java </div>
</li>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames bisectfun <span class="sy0">@</span> master $ git add .</div>
</li>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames bisectfun <span class="sy0">@</span> master $ git commit </div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#91;</span>master 09a58fb<span class="br0">&#93;</span> <span class="kw3">let</span> it crash</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="nu0">1</span> files changed, <span class="nu0">3</span> insertions<span class="br0">&#40;</span>+<span class="br0">&#41;</span>, <span class="nu0">0</span> deletions<span class="br0">&#40;</span>-<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames bisectfun <span class="sy0">@</span> master $ <span class="kw1">for</span> i <span class="kw1">in</span> <span class="br0">&#123;</span><span class="nu0">1</span>..<span class="nu0">50</span><span class="br0">&#125;</span>; <span class="kw1">do</span> fortune <span class="sy0">&gt;</span> src<span class="sy0">/</span><span class="kw3">test</span><span class="sy0">/</span>resources<span class="sy0">/</span>fortune<span class="re1">$i</span>; git add .; git commit -a -m <span class="st0">&#39;some commit&#39;</span>; <span class="kw1">done</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#91;</span>master f83cdae<span class="br0">&#93;</span> some commit</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="nu0">1</span> files changed, <span class="nu0">3</span> insertions<span class="br0">&#40;</span>+<span class="br0">&#41;</span>, <span class="nu0">3</span> deletions<span class="br0">&#40;</span>-<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#91;</span>master 725c5ce<span class="br0">&#93;</span> some commit</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="nu0">1</span> files changed, <span class="nu0">4</span> insertions<span class="br0">&#40;</span>+<span class="br0">&#41;</span>, <span class="nu0">15</span> deletions<span class="br0">&#40;</span>-<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;rewrite src<span class="sy0">/</span><span class="kw3">test</span><span class="sy0">/</span>resources<span class="sy0">/</span>fortune2 <span class="br0">&#40;</span><span class="nu0">100</span><span class="sy0">%</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0">#&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0">#&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0">#&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.</span></div>
</li>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames bisectfun <span class="sy0">@</span> master $ <span class="kw1">for</span> i imvn clean <span class="kw3">test</span> <span class="sy0">&gt;</span> <span class="sy0">/</span>dev<span class="sy0">/</span>null <span class="nu0">2</span><span class="sy0">&gt;</span> <span class="sy0">/</span>dev<span class="sy0">/</span>null</div>
</li>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames bisectfun <span class="sy0">@</span> master $ <span class="kw3">echo</span> <span class="re4">$?</span></div>
</li>
<li class="li1">
<div class="de1"><span class="nu0">1</span></div>
</li>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames bisectfun <span class="sy0">@</span> master $ <span class="kw3">echo</span> <span class="st0">&#39;!!!!!!!!!!!!!!OH NO IT FAILS!!!!!!!!&#39;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">!!!!!!!!!!!!!!!!</span>OH NO IT FAILS<span class="sy0">!!!!!!!!</span></div>
</li>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames bisectfun <span class="sy0">@</span> master $ git tag failsHere</div>
</li>
</ol>
</div>
<p>Ok the test&#8217;s fail now. But suppose you didn&#8217;t know which commit introduced the bug (in our case made the test&#8217;s fail). You&#8217;d have to guess which one, or check them all or just work it out by looking at your current repository state. But since you&#8217;re doing small commits and do them often &#8211; it&#8217;ll be great if you found out which commit caused this failure. As it&#8217;s preferably small, it&#8217;ll be very easy to find out what change caused the build to fail. No is the time to use <strong>git bisect</strong>!</p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames bisectfun <span class="sy0">@</span> master $ git bisect start</div>
</li>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames bisectfun <span class="sy0">@</span> master $ git bisect bad failsHere </div>
</li>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames bisectfun <span class="sy0">@</span> master $ git bisect good wasOkHere </div>
</li>
<li class="li1">
<div class="de1">Bisecting: <span class="nu0">50</span> revisions left to <span class="kw3">test</span> after this <span class="br0">&#40;</span>roughly <span class="nu0">6</span> steps<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#91;</span>ca199e0cbd19e498eabf6196036313e206b00a7f<span class="br0">&#93;</span> some commit</div>
</li>
</ol>
</div>
<p>We&#8217;ve started bisect, and told him which commit we&#8217;re sure is working and which we&#8217;re sure is failing. Git will now checkout a commit he found &#8220;somewhat in the middle&#8221; and will continue to bisect (binary search) the commit history based on wether a commit is &#8220;good&#8221; or &#8220;bad&#8221;. We could just tell it git by hand by doing &#8220;git bisect good/bad&#8221; etc. But let&#8217;s <strong>git bisect run</strong> a script to do this for us :</p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames bisectfun <span class="sy0">@</span> <span class="br0">&#40;</span>no branch<span class="br0">&#41;</span> $ git bisect run ..<span class="sy0">/</span>mavenbisect.<span class="kw2">sh</span></div>
</li>
<li class="li1">
<div class="de1">running ..<span class="sy0">/</span>mavenbisect.<span class="kw2">sh</span></div>
</li>
<li class="li1">
<div class="de1">Bisecting: <span class="nu0">25</span> revisions left to <span class="kw3">test</span> after this <span class="br0">&#40;</span>roughly <span class="nu0">5</span> steps<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#91;</span>c8658db8e0c5df1d603a9a96ae7a04e71c4ba9d1<span class="br0">&#93;</span> some commit</div>
</li>
<li class="li1">
<div class="de1">running ..<span class="sy0">/</span>mavenbisect.<span class="kw2">sh</span></div>
</li>
<li class="li1">
<div class="de1">Bisecting: <span class="nu0">12</span> revisions left to <span class="kw3">test</span> after this <span class="br0">&#40;</span>roughly <span class="nu0">4</span> steps<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#91;</span>ddc2100ab90d0624df74e81f17d7ed7ea0fc9a61<span class="br0">&#93;</span> some commit</div>
</li>
<li class="li1">
<div class="de1">running ..<span class="sy0">/</span>mavenbisect.<span class="kw2">sh</span></div>
</li>
<li class="li1">
<div class="de1">Bisecting: <span class="nu0">5</span> revisions left to <span class="kw3">test</span> after this <span class="br0">&#40;</span>roughly <span class="nu0">3</span> steps<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#91;</span>31ba35661eecb7a96159e483954d315a63a3789d<span class="br0">&#93;</span> some commit</div>
</li>
<li class="li1">
<div class="de1">running ..<span class="sy0">/</span>mavenbisect.<span class="kw2">sh</span></div>
</li>
<li class="li1">
<div class="de1">Bisecting: <span class="nu0">2</span> revisions left to <span class="kw3">test</span> after this <span class="br0">&#40;</span>roughly <span class="nu0">2</span> steps<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#91;</span>725c5cec8803b1e62dd36a3b74fd8c52d42e807c<span class="br0">&#93;</span> some commit</div>
</li>
<li class="li1">
<div class="de1">running ..<span class="sy0">/</span>mavenbisect.<span class="kw2">sh</span></div>
</li>
<li class="li1">
<div class="de1">Bisecting: <span class="nu0">0</span> revisions left to <span class="kw3">test</span> after this <span class="br0">&#40;</span>roughly <span class="nu0">1</span> step<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#91;</span>f83cdaeb34072a6f9c9a63abf8bb8f2390b996de<span class="br0">&#93;</span> some commit</div>
</li>
<li class="li1">
<div class="de1">running ..<span class="sy0">/</span>mavenbisect.<span class="kw2">sh</span></div>
</li>
<li class="li1">
<div class="de1">Bisecting: <span class="nu0">0</span> revisions left to <span class="kw3">test</span> after this <span class="br0">&#40;</span>roughly <span class="nu0">0</span> steps<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#91;</span>09a58fbf2821c4f66c003a65f19f6ff99f5ee37d<span class="br0">&#93;</span> <span class="kw3">let</span> it crash</div>
</li>
<li class="li1">
<div class="de1">running ..<span class="sy0">/</span>mavenbisect.<span class="kw2">sh</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">09a58fbf2821c4f66c003a65f19f6ff99f5ee37d is the first bad commit</div>
</li>
<li class="li1">
<div class="de1">commit 09a58fbf2821c4f66c003a65f19f6ff99f5ee37d</div>
</li>
<li class="li1">
<div class="de1">Author: Konrad Malawski <span class="sy0">&lt;</span>konrad .malawski<span class="sy0">@</span>project13.pl<span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1">Date: &nbsp; Wed Mar <span class="nu0">16</span> <span class="nu0">22</span>:<span class="nu0">02</span>:<span class="nu0">38</span> <span class="nu0">2011</span> <span class="nu0">+0100</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw3">let</span> it crash</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">:<span class="nu0">040000</span> <span class="nu0">040000</span> ef88527072e0b1532819a75f288a0e65a2737c6a 49083a7d820a731d5edad117a4af097bd9ffb444 M &nbsp; &nbsp; &nbsp;src</div>
</li>
<li class="li1">
<div class="de1">bisect run success</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames bisectfun <span class="sy0">@</span> <span class="br0">&#40;</span>no branch<span class="br0">&#41;</span> $ git show 09a58fbf2821c4f66c003a65f19f6ff99f5ee37d</div>
</li>
<li class="li1">
<div class="de1">commit 09a58fbf2821c4f66c003a65f19f6ff99f5ee37d</div>
</li>
<li class="li1">
<div class="de1">Author: Konrad Malawski <span class="sy0">&lt;/</span>konrad<span class="sy0">&gt;&lt;</span>konrad .malawski<span class="sy0">@</span>project13.pl<span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1">Date: &nbsp; Wed Mar <span class="nu0">16</span> <span class="nu0">22</span>:<span class="nu0">02</span>:<span class="nu0">38</span> <span class="nu0">2011</span> <span class="nu0">+0100</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw3">let</span> it crash</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">diff</span> &#8211;git a<span class="sy0">/</span>src<span class="sy0">/</span><span class="kw3">test</span><span class="sy0">/</span>java<span class="sy0">/</span>pl<span class="sy0">/</span>project13<span class="sy0">/</span>AppTest.java b<span class="sy0">/</span>src<span class="sy0">/</span><span class="kw3">test</span><span class="sy0">/</span>java<span class="sy0">/</span>pl<span class="sy0">/</span>project13<span class="sy0">/</span>AppTest.java</div>
</li>
<li class="li1">
<div class="de1">index c6ffd44..b27c8b8 <span class="nu0">100644</span></div>
</li>
<li class="li1">
<div class="de1">&#8212; a<span class="sy0">/</span>src<span class="sy0">/</span><span class="kw3">test</span><span class="sy0">/</span>java<span class="sy0">/</span>pl<span class="sy0">/</span>project13<span class="sy0">/</span>AppTest.java</div>
</li>
<li class="li1">
<div class="de1">+++ b<span class="sy0">/</span>src<span class="sy0">/</span><span class="kw3">test</span><span class="sy0">/</span>java<span class="sy0">/</span>pl<span class="sy0">/</span>project13<span class="sy0">/</span>AppTest.java</div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">@@</span> <span class="nu0">-36</span>,<span class="nu0">3</span> <span class="nu0">+36</span>,<span class="nu0">6</span> <span class="sy0">@@</span> public class AppTest</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;assertTrue<span class="br0">&#40;</span> <span class="kw2">true</span> <span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">+fail :D</div>
</li>
<li class="li1">
<div class="de1">+fail :D</div>
</li>
<li class="li1">
<div class="de1">+fail :D</div>
</li>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames bisectfun <span class="sy0">@</span> <span class="br0">&#40;</span>no branch<span class="br0">&#41;</span> $ git bisect reset </div>
</li>
<li class="li1">
<div class="de1">Previous HEAD position was 09a58fb&#8230; <span class="kw3">let</span> it crash</div>
</li>
<li class="li1">
<div class="de1">Switched to branch <span class="st0">&#39;master&#39;</span></div>
</li>
<li class="li1">
<div class="de1">ktoso<span class="sy0">@</span>dynames bisectfun <span class="sy0">@</span> master $ </div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">&lt;/</span>konrad<span class="sy0">&gt;</span></div>
</li>
</ol>
</div>
<p>Yeah, we&#8217;ve found our failing commit :-) You could use any script you want here, it just has to return 0 if git should think it&#8217;s a &#8220;good commit&#8221; and &#8220;not 0&#8243; if it&#8217;s a &#8220;bad commit&#8221;. I&#8217;ve even seen runners written in PHP running or spellcheckers &#8211; you name it&#8230; :-) Ok but how does this magical script that we&#8217;ve just run look like?</p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1"><span class="co0">#!/bin/sh</span></div>
</li>
<li class="li1">
<div class="de1">mvn clean <span class="kw3">test</span> <span class="sy0">&gt;</span> <span class="sy0">/</span>dev<span class="sy0">/</span>null <span class="nu0">2</span><span class="sy0">&gt;</span> <span class="sy0">/</span>dev<span class="sy0">/</span>null</div>
</li>
</ol>
</div>
<p>Whoa, that&#8217;s simple&#8230; :-) Keep on git hacking guys! See you soon, with some more git or java tips&#8230; :-) Oh and I&#8217;ll post my presentation (holefully with video) from SFI soon, so keep an eye out! :-)</p>
<p>PS: Yup, the <strong>code retreat</strong> we&#8217;re (SCKRK with a little help from the <a href="http://www.java.pl" onclick="urchinTracker('/outgoing/www.java.pl?referer=');">PolishJUG</a>) organizing got &#8220;sold out&#8221; after just 3h&#8230; ;-) Be sure to take a look and be quicker next time! <a href="http://coderetreat.sckrk.com" onclick="urchinTracker('/outgoing/coderetreat.sckrk.com?referer=');">http://coderetreat.sckrk.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.project13.pl/index.php/coding/1217/git-bisect-maven-automate-breaking-commit-search/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[terminal heroes] Display git branch in shell prompt (PS1)</title>
		<link>http://www.blog.project13.pl/index.php/fun/1198/terminal-heroes-display-git-branch-in-shell-prompt-ps1/</link>
		<comments>http://www.blog.project13.pl/index.php/fun/1198/terminal-heroes-display-git-branch-in-shell-prompt-ps1/#comments</comments>
		<pubDate>Sat, 26 Feb 2011 22:29:01 +0000</pubDate>
		<dc:creator>Ktoso</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[terminal heroes]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[branch]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[prompt]]></category>
		<category><![CDATA[ps1]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://www.blog.project13.pl/?p=1198</guid>
		<description><![CDATA[I don&#8217;t think I&#8217;ve blogged about this but I&#8217;ve seen this sometime ago and now decided to add it to my .bashrc for good. It&#8217;s a simple trick to make an awesome PS1 shell prompt, displaying the branch you are currently on (if you&#8217;re in a git versioned directory). Not that I&#8217;m forgetting what branch [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t think I&#8217;ve blogged about this but I&#8217;ve seen this sometime ago and now decided to add it to my .bashrc for good. It&#8217;s a simple trick to make an awesome PS1 shell prompt, displaying the branch you are currently on (if you&#8217;re in a git versioned directory). Not that I&#8217;m forgetting what branch I&#8217;m on, but I hope it&#8217;ll make me create more branches more often and never &#8220;just work on master&#8221; :-)</p>
<p><a href="http://www.blog.project13.pl/wp-content/uploads/2011/02/awesome-git-branch-in-shell.png"><img src="http://www.blog.project13.pl/wp-content/uploads/2011/02/awesome-git-branch-in-shell.png" alt="" title="awesome-git-branch-in-shell" width="530" class="aligncenter size-full wp-image-1211" /></a></p>
<p>The code comes from <a href="http://arnorehn.de/cgi-bin/weblog_basic/index.php?p=34" onclick="urchinTracker('/outgoing/arnorehn.de/cgi-bin/weblog_basic/index.php?p=34&amp;referer=');">http://arnorehn.de/cgi-bin/weblog_basic/index.php?p=34</a> so big kudos too him :-)</p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1"><span class="co0"># in your ~/.bashrc for example</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">alias</span> <span class="re2">gitka=</span><span class="st0">&#39;gitk &#8211;all&#39;</span> <span class="co0">#unrelated to this post, but very useful :-)</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">function</span> formattedGitBranch <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re2">_branch=</span><span class="st0">&quot;$(git branch 2&gt;/dev/null | sed -e &quot;</span><span class="sy0">/</span>^\s<span class="sy0">/</span>d<span class="st0">&quot; -e &quot;</span>s<span class="sy0">/</span>^\<span class="sy0">*</span>\s<span class="sy0">//</span><span class="st0">&quot;)&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw3">test</span> -n <span class="st0">&quot;$_branch&quot;</span> <span class="sy0">&amp;&amp;</span> <span class="kw3">echo</span> -e <span class="st0">&quot; @<span class="es0">\e</span>[0;32m $_branch&quot;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0">#export PS1=&quot;\u@\h \W \[\e[m\]\$(formattedGitBranch) \[\e[1;32m\]\$ \[\e[m\]\[\e[0m\]&quot; </span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">export</span> <span class="re2">PS1=</span><span class="st0">&quot;<span class="es0">\u</span>@<span class="es0">\h</span> <span class="es0">\W</span><span class="es0">\[</span><span class="es0">\e</span>[m<span class="es0">\]</span><span class="es0">\$</span>(formattedGitBranch)<span class="es0">\[</span><span class="es0">\e</span>[0m<span class="es0">\]</span> <span class="es0">\$</span> &quot;</span></div>
</li>
</ol>
</div>
<p>Cheers and <b>happy hacking</b>!</p>
<p>PS: I&#8217;m waiting for my T-shirt and stickers (for training participants) to arrive from github. I&#8217;d love they make it in time for <a href="http://www.sfi.org.pl" onclick="urchinTracker('/outgoing/www.sfi.org.pl?referer=');">SFI</a> but I&#8217;m not sure if it&#8217;s even possible hmmm&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.project13.pl/index.php/fun/1198/terminal-heroes-display-git-branch-in-shell-prompt-ps1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Setup git on windows to use kdiff3 as it&#8217;s mergetool</title>
		<link>http://www.blog.project13.pl/index.php/coding/1192/setup-git-on-windows-to-use-kdiff3-as-its-mergetool/</link>
		<comments>http://www.blog.project13.pl/index.php/coding/1192/setup-git-on-windows-to-use-kdiff3-as-its-mergetool/#comments</comments>
		<pubDate>Fri, 25 Feb 2011 23:04:22 +0000</pubDate>
		<dc:creator>Ktoso</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[diff]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[mergetool]]></category>
		<category><![CDATA[Project13]]></category>
		<category><![CDATA[SCM]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[training]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.blog.project13.pl/?p=1192</guid>
		<description><![CDATA[As I&#8217;ll be leading BOTH a presentation and a workshop about git at the upcomming Academic It Festival I&#8217;m preparing myselffor the most problematic of all problems&#8230; MS Windows! Just kidding ;-) But it&#8217;s highly probable that most users will have Windows installed on their notebooks so I&#8217;ll better be prepared :-) One of the [...]]]></description>
			<content:encoded><![CDATA[<p>As I&#8217;ll be leading BOTH a presentation and a workshop about git at the upcomming <a href="http://sfi.org.pl/edycja-2011/prelegenci" onclick="urchinTracker('/outgoing/sfi.org.pl/edycja-2011/prelegenci?referer=');">Academic It Festival</a> I&#8217;m preparing myselffor the most problematic of all problems&#8230; MS Windows! Just kidding ;-) But it&#8217;s highly probable that most users will have Windows installed on their notebooks so I&#8217;ll better be prepared :-) One of the things woth using for merges is&#8230; the mergetool. My favourite (besides intellij) is <strong>KDiff3</strong> it really rocks and usability and look and feel are on a very high standard.</p>
<p>As I&#8217;d rather show the participants around git and not just &#8220;how the hell do I use vimdiff?!&#8221; I&#8217;m posting this little snippet on howto use KDiff3 on windows. Of course we&#8217;re probably going to have quite simple conflicts that could easily be conflicted without tooling but it&#8217;s nice to have one prepared when you need one. So, this is what you need to run KDiff3 on windows as a mergetool (paste this inside of your <strong>.git/config </strong>file)</p>
<pre>
<code>[merge]
    tool = kdiff3

[mergetool "kdiff3"]
    path = C:/Program Files/KDiff3/kdiff3.exe
    keepBackup = false
    trustExitCode = false
</code>
</pre>
<p>And you&#8217;ll need to download kdiff3 for windows of course, this can be done on <a href="http://sourceforge.net/projects/kdiff3/files/kdiff3/0.9.95/" onclick="urchinTracker('/outgoing/sourceforge.net/projects/kdiff3/files/kdiff3/0.9.95/?referer=');">their sourceforga page</a>. And that&#8217;s basically it. I&#8217;ll reconfirm that this really works tomorrow as I&#8217;m getting somewhat tired already&#8230; Well then&#8230;</p>
<p><em>Gundam fighters set, ready&#8230;.. goooo!</em><br />
<em style="font-size:xx-small">* stupid quote from  G Gundam ;-)</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.project13.pl/index.php/coding/1192/setup-git-on-windows-to-use-kdiff3-as-its-mergetool/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>[release] maven-git-commit-id-plugin</title>
		<link>http://www.blog.project13.pl/index.php/fun/1174/release-maven-git-commit-id-plugin/</link>
		<comments>http://www.blog.project13.pl/index.php/fun/1174/release-maven-git-commit-id-plugin/#comments</comments>
		<pubDate>Sun, 13 Feb 2011 15:25:18 +0000</pubDate>
		<dc:creator>Ktoso</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[freedom]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[#maven]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[release]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://www.blog.project13.pl/?p=1174</guid>
		<description><![CDATA[Yup, today I&#8217;m releasing yet another piece of cool free software! It solves a problem we&#8217;ve had at our company, the tester tometimes tested stuff that wasn&#8217;t deployed yet, and the developers thought it was deployed and this caused some weird situations sometimes. Using the plugin I&#8217;ve written, we&#8217;re able to expose &#8220;which version is [...]]]></description>
			<content:encoded><![CDATA[<p>Yup, today I&#8217;m releasing yet another piece of cool free software! It solves a problem we&#8217;ve had at our company, the tester tometimes tested stuff that wasn&#8217;t deployed yet, and the developers thought it was deployed and this caused some weird situations sometimes. Using the plugin I&#8217;ve written, we&#8217;re able to expose &#8220;which version is this?&#8221; using repository information from<strong> git </strong>in our webapps. Yes there are maven plugins that do this, but none of them supported git &#8211; so I wrote my own and hope you guys will find it as useful as we do!</p>
<p><strong>UPDATE</strong><br />
The plugin is now available from <strong>Sonatype Nexus</strong>!</p>
<pre>
    <repository>
        <id>sonatype-releases</id>
        <name>Sonatype Releases</name>
        <url>https://oss.sonatype.org/content/repositories/releases/</url>
    </repository>
</pre>
<p><strong>END OF UPDATE</strong></p>
<p>Now I&#8217;ll be a bit lazy and just paste the README I&#8217;ve prepared for <strong><a href="https://github.com/ktoso/maven-git-commit-id-plugin/" target="_blank" onclick="urchinTracker('/outgoing/github.com/ktoso/maven-git-commit-id-plugin/?referer=');">maven-git-commit-id-plugin on github</a></strong>.</p>
<div id="readme">
<div>
<h2>Maven plugin: git-commit-id-plugin</h2>
<p><strong>git-commit-id-plugin</strong> is a plugin quite similar to <a href="https://fisheye.codehaus.org/browse/mojo/tags/buildnumber-maven-plugin-1.0-beta-4" target="_blank" onclick="urchinTracker('/outgoing/fisheye.codehaus.org/browse/mojo/tags/buildnumber-maven-plugin-1.0-beta-4?referer=');">build-number maven plugin</a> for example but as buildnumber only supports svn (which is very sad) and  cvs (which is even more sad, and makes bunnies cry) I had to quickly  develop an git version of such a plugin. For those who don&#8217;t know the  previous plugins, let me explain what this plugin does:</p>
<h3>Sample scenario why this plugin is useful</h3>
<p>If you develop your maven project inside an git repository (which you  hopefully already are docing) you may want to know exactly what changeset is currently deployed online. Why is this useful? Well,  the tester won&#8217;t come to you screaming &#8220;heeey that bug ain&#8217;t fixed&#8221; of  course you&#8217;d reply &#8220;but I fixed it this morning!&#8221; and after some  searching you notice &#8220;oh&#8230; it&#8217;ll be online after the next deployment,  sorry tester&#8230; :-(&#8220;.</p>
<p>This scenario keeps repeating sometimes, thus you can state which  commit fixes/closes the bug, note this in JIRA etc and then the tester  will know if it&#8217;s already online (by the commit date for example).</p>
<h2>Usage</h2>
<h3>Getting the plugin</h3>
<p>I&#8217;ll be trying to get this plugin out to sonatype for others to use if more simply, for now it&#8217;s quickest to just:</p>
<pre><code>  git clone git://github.com/ktoso/maven-git-commit-id-plugin.git maven-git-commit-id-plugin
  cd maven-git-commit-id-plugin
  mvn install
</code></pre>
<p>and you&#8217;re ready to use it ;-) I&#8217;m also thinking about making this  github repo a maven repository, which would make the above step not  needed &#8211; but first let&#8217;s wait if sonatype let me in with this project,  k? ;-)</p>
<h3>Using the plugin</h3>
<p>It&#8217;s really simple to setup this plugin, here&#8217;s a sample pom that you may base your <strong>pom.xml</strong> on:</p>
<pre><code>   &lt;?xml version="1.0" encoding="UTF-8"?&gt;
   &lt;project xmlns="http://maven.apache.org/POM/4.0.0"
            xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
       &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;

       &lt;groupId&gt;pl.project13.maven&lt;/groupId&gt;
       &lt;artifactId&gt;my-git-plugin-sample-app&lt;/artifactId&gt;
       &lt;packaging&gt;war&lt;/packaging&gt;
       &lt;version&gt;0.1&lt;/version&gt;
       &lt;name&gt;my-git-plugin-sample-app&lt;/name&gt;
       &lt;url&gt;http://www.blog.project13.pl&lt;/url&gt;

       &lt;parent/&gt;

       &lt;dependencies /&gt;

       &lt;build&gt;
           &lt;!-- GIT COMMIT ID PLUGIN CONFIGURATION --&gt;
           &lt;resources&gt;
               &lt;resource&gt;
                   &lt;directory&gt;src/main/resources&lt;/directory&gt;
                   &lt;filtering&gt;true&lt;/filtering&gt;
                   &lt;includes&gt;
                       &lt;include&gt;**/*.properties&lt;/include&gt;
                       &lt;include&gt;**/*.xml&lt;/include&gt;
                   &lt;/includes&gt;
               &lt;/resource&gt;
           &lt;/resources&gt;

           &lt;plugins&gt;
               &lt;plugin&gt;
                   &lt;groupId&gt;pl.project13.maven&lt;/groupId&gt;
                   &lt;artifactId&gt;git-commit-id-plugin&lt;/artifactId&gt;
                   &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
                   &lt;executions&gt;
                       &lt;execution&gt;
                           &lt;goals&gt;
                               &lt;goal&gt;revision&lt;/goal&gt;
                           &lt;/goals&gt;
                       &lt;/execution&gt;
                   &lt;/executions&gt;
                   &lt;configuration&gt;
                       &lt;prefix&gt;git&lt;/prefix&gt; &lt;!-- that's the default value --&gt;
                       &lt;dateFormat&gt;dd.MM.yyyy '@' HH:mm:ss z&lt;/dateFormat&gt; &lt;!-- that's the default value --&gt;
                       &lt;verbose&gt;true&lt;/verbose&gt; &lt;!-- false is default for this --&gt;
                       &lt;dotGitDirectory&gt;${project.basedir}/../.git&lt;/dotGitDirectory&gt; &lt;!-- required, you have to specify this path --&gt;
                   &lt;/configuration&gt;
               &lt;/plugin&gt;
               &lt;!-- END OF GIT COMMIT ID PLUGIN CONFIGURATION --&gt;

               &lt;!-- other plugins --&gt;
           &lt;/plugins&gt;
       &lt;/build&gt;
   &lt;/project&gt;
</code></pre>
<p>Based on the above part of a working POM you should be able to figure out the rest, I mean you are a maven user after all&#8230; ;-) Note that the resources filtering is important for this plugin to work, don&#8217;t omit it!</p>
<p>Now you just have to include such a properties file in your project under <code>/src/main/resources</code> (and call it <strong>git.properties</strong> for example) and maven will put the appropriate properties in the placeholders:</p>
<pre><code> git.branch=${git.branch}

 git.build.user.name=${git.build.user.name}
 git.build.user.email=${git.build.user.email}
 git.build.time=${git.build.time}

 git.commit.id=${git.commit.id}
 git.commit.user.name=${git.commit.user.name}
 git.commit.user.email=${git.commit.user.email}
 git.commit.message.full=${git.commit.message.full}
 git.commit.message.short=${git.commit.message.short}
 git.commit.time=${git.commit.time}
</code></pre>
<p>The <code>git</code> prefix may be configured in the plugin declaration above.</p>
<h3>Maven resource filtering + Spring = GitRepositoryState Bean</h3>
<p>You&#8217;ll most probably want to wire these plugins somehow to get easy  access to them during runtime. We&#8217;ll use spring as an example of doing  this. Start out with with adding the above steps to your project, next paste  this <strong>git-bean.xml</strong> into the <code>/src/main/resources/</code> directory (or any other, just adjust the paths later on):</p>
<pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
&lt;beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"&gt;

    &lt;bean name="gitRepositoryInformation"&gt;
        &lt;property name="branch" value="${git.branch}"/&gt;
        &lt;property name="commitId" value="${git.commit.id}"/&gt;
        &lt;property name="commitTime" value="${git.commit.time}"/&gt;
        &lt;property name="buildUserName" value="${git.build.user.name}"/&gt;
        &lt;property name="buildUserEmail" value="${git.build.user.email}"/&gt;
        &lt;property name="commitMessageFull" value="${git.commit.message.full}"/&gt;
        &lt;property name="commitMessageShort" value="${git.commit.message.short}"/&gt;
        &lt;property name="commitUserName" value="${git.commit.user.name}"/&gt;
        &lt;property name="commitUserEmail" value="${git.commit.user.email}"/&gt;
    &lt;/bean&gt;

&lt;/beans&gt;
</code></pre>
<p>And here&#8217;s the source of the bean we&#8217;re binding here:</p>
<pre><code>package pl.project13.maven.example.git;

import org.codehaus.jackson.annotate.JsonWriteNullProperties;

/**
 * A spring controlled bean that will be injected
 * with properties about the repository state at build time.
 * This information is supplied by my plugin - &lt;b&gt;pl.project13.maven.git-commit-id-plugin&lt;/b&gt;
 *
 * @author Konrad Malawski
 */
@JsonWriteNullProperties(true)
public class GitRepositoryState {
  String branch;                  // =${git.branch}
  String commitId;                // =${git.commit.id}
  String buildUserName;           // =${git.build.user.name}
  String buildUserEmail;          // =${git.build.user.email}
  String buildTime;               // =${git.build.time}
  String commitUserName;          // =${git.commit.user.name}
  String commitUserEmail;         // =${git.commit.user.email}
  String commitMessageFull;       // =${git.commit.message.full}
  String commitMessageShort;      // =${git.commit.message.short}
  String commitTime;              // =${git.commit.time}

  public GitRepositoryState() {
  }

  /* Generate setters and getters here */
}
</code></pre>
<p>The source for it is also on the repo of this plugin. Of course, <em>feel free to drop out the jackson annotation</em> if you won&#8217;t be using it.</p>
<p>The last configuration related thing we need to do is to load up this bean in your appContext, so open up your <strong>applicationContext.xml</strong> or whatever you call it in your project and add these lines in the  section:</p>
<pre><code>&lt;context:property-placeholder location="classpath:*.properties" /&gt;
&lt;import resource="classpath:/git-bean.xml"/&gt;
</code></pre>
<p>Of course, you may adjust the paths and file locations as you please, no problems here&#8230; :-) <em>Now you&#8217;re ready to use your GitRepositoryState Bean!</em> Let&#8217;s create an sample <strong>Spring MVC Controller</strong> to test it out:</p>
<pre><code> @Controller
 @RequestMapping("/git")
 public class GitService extends BaseWebService {

     @Autowired
     GitRepositoryState gitRepoState;

     @RequestMapping("/status")
     public ModelAndView checkGitRevision() throws WebServiceAuthenticationException {
       ServerResponse&lt;GitRepositoryState&gt; response = new ServerResponse&lt;GitRepositoryState&gt;(gitRepoState);
       return createMAV(response);
     }
 }
</code></pre>
<p>Don&#8217;t mind the createMAV and responses stuff, it&#8217;s just example code.  And feel free to use constructor injection, it&#8217;s actually a better idea  ;-)</p>
<p>In the end <em>this is what this service would return</em>:</p>
<pre><code> {
     "branch" : "testing-maven-git-plugin",
     "commitTime" : "06.01.1970 @ 16:16:26 CET",
     "commitId" : "787e39f61f99110e74deed68ab9093088d64b969",
     "commitUserName" : "Konrad Malawski",
     "commitUserEmail" : "konrad.malawski@java.pl",
     "commitMessageFull" : "releasing my fun plugin :-)
                            + fixed some typos
                            + cleaned up directory structure
                            + added license etc",
     "commitMessageShort" : "releasing my fun plugin :-)",
     "buildTime" : "06.01.1970 @ 16:17:53 CET",
     "buildUserName" : "Konrad Malawski",
     "buildUserEmail" : "konrad.malawski@java.pl"
 }
</code></pre>
<p>That&#8217;s all folks! <strong>Happy hacking!</strong></p>
<h2>Configuration details</h2>
<p>Just a short recap of the available parameters&#8230;</p>
<p>Required parameters:</p>
<ul>
<li> <strong>dotGitDirectory</strong> &#8211; (required) the location of your .git  folder. Try to use ${project.basedir} as root for this, and navigate  using ../ to higher up folder to easily use this plugin in multi module  enviroments etc. An example would be: <code>${project.basedir}/../.git</code></li>
</ul>
<p>Optional parameters:</p>
<ul>
<li> <strong>prefix</strong> &#8211; (default: git) is the &#8220;namespace&#8221; for all exposed properties</li>
<li> <strong>dateFormat</strong> &#8211; (default: dd.MM.yyyy &#8216;@&#8217; HH:mm:ss z) is a  normal SimpleDateFormat String and will be used to represent  git.build.time and git.commit.time</li>
<li> <strong>verbose</strong> &#8211; (default: false) if true the plugin will print a summary of all collected properties when it&#8217;s done</li>
</ul>
<h2>License</h2>
<p>I&#8217;m releasing this plugin under the <strong>GNU Lesser General Public License 3.0</strong>. You&#8217;re free to use it as you wish, the license text is attached in the LICENSE file. You may contact me if you want this to be released on a different license, just send me an email konrad.malawski@java.pl :-)</p>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.project13.pl/index.php/fun/1174/release-maven-git-commit-id-plugin/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>G73 keyboard backlight scripts</title>
		<link>http://www.blog.project13.pl/index.php/fun/1163/g73-keayboard-backlight-scripts/</link>
		<comments>http://www.blog.project13.pl/index.php/fun/1163/g73-keayboard-backlight-scripts/#comments</comments>
		<pubDate>Sat, 29 Jan 2011 19:09:42 +0000</pubDate>
		<dc:creator>Ktoso</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[freedom]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[gaming]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[terminal heroes]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[fsf]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[notebook]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[terminal]]></category>

		<guid isPermaLink="false">http://www.blog.project13.pl/?p=1163</guid>
		<description><![CDATA[I&#8217;ve upgraded my desktop and laptop last week. By &#8220;and&#8221; I mean that I&#8217;ve bought an desktop replacement class notebook &#8211; an Asus G73 series. Amongst many nice parts it has I&#8217;m very happy about the harddrives &#8211; Seagate Momentus XT, click the link to see an very interesting benchmark of it. Anyways, that&#8217;s not [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve upgraded my desktop and laptop last week. By &#8220;and&#8221; I mean that I&#8217;ve bought an desktop replacement class notebook &#8211; an <strong>Asus G73 </strong>series. Amongst many nice parts it has I&#8217;m very happy about the harddrives &#8211; <a href="http://www.tomshardware.com/reviews/seagate-momentus-xt-hybrid-hard-drive-ssd,2638.html" onclick="urchinTracker('/outgoing/www.tomshardware.com/reviews/seagate-momentus-xt-hybrid-hard-drive-ssd_2638.html?referer=');">Seagate Momentus XT</a>, click the link to see an very interesting benchmark of it. Anyways, that&#8217;s not what this post should be about.</p>
<p>The G73 has an backlit keyboard, which may come in handy while late night coding without lights on as I like to code sometimes. (I&#8217;m using a X6 Sidewinder, even with this Notebook so it&#8217;s not like it&#8217;s keyboard matters to me most of the time ;-)) As usual with such &#8220;super cool addons&#8221; the funtion keys regulating the keyboard backlight seemed to only work on Windows &#8211; which I&#8217;m only using for gaming (but rarely) and testing if the software I happened to write runs ok on it. Anyways, turns out that the keyboard does really well integrate with linux, and you just need a few simple commands to use it, I&#8217;ve made them available on github :-)</p>
<p><a href="https://github.com/ktoso/g73-keyboard-backlight-sh/" onclick="urchinTracker('/outgoing/github.com/ktoso/g73-keyboard-backlight-sh/?referer=');">https://github.com/ktoso/<strong>g73-keyboard-backlight-sh</strong></a> &lt;- Go here to check it out :-)</p>
<div class="geshi no markdown">
<div class="head">Asus G73 Keyboard Backlight GNU/Linux Scripts</div>
<ol>
<li class="li1">
<div class="de1">=============================================
</div>
</li>
<li class="li1">
<div class="de1">To enable the `Fn + F3` and `Fn + F4` shortcuts to work under linux and really
</div>
</li>
<li class="li1">
<div class="de1">manipulate the backlight brighntess on your *Asus G73* series notebook, follow theese simple steps:
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">1. Clone this repository to your home directory (or wherever you want to, I&#39;ll do this example for ~/ for simplicity)
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;cd
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;git clone git://github.com/ktoso/g73-keyboard-backlight-sh.git g73
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;
</div>
</li>
<li class="li1">
<div class="de1">2. Make sure all scripts are marked executable:
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;cd g73
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;chmod +x *.sh
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">3. Take a look at these scripts to make sure you trust them, why? Because they&#39;ll need root access,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;without asking for the password. Now we&#39;ll add these scripts to allow `sudo`to run them without
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;asking for any password:
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;su -c &#39;visudo&#39; # or &#39;sudo visudo&#39; if you&#39;re a sudoer (on ubuntu etc)
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;There just add the following lines at the end of this file (or similar, with the script names etc).
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;Of course, replace `ktoso` and `/home/ktoso/` with your *username* and *your home directory*.
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;## allow running keyboard backlight scripts
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;ktoso ALL=(ALL) NOPASSWD:/home/ktoso/g73/*
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">4. Now all that&#39;s left is to setup the key bindings for the scripts. If you&#39;re on KDE4, just go to
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;*System Settings -&amp;gt; Shortcuts and Gestures -&amp;gt; Custom Shortcuts* and *edit -&amp;gt; import&#8230;* the file **~/g73/g73_keyboard.khotkeys**
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; which contains ready keybindings for these scripts.
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; Now you may use `Fn + F3` to make the keyboard backlight shine **less**, and the `Fn + F4` combination to make it shine **more**.</div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.project13.pl/index.php/fun/1163/g73-keayboard-backlight-scripts/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Git@JavaCamp: fix-1: When does git &#8220;see&#8221; an rename explicitly?</title>
		<link>http://www.blog.project13.pl/index.php/fun/1069/gitjavacamp-fix-1-when-does-git-see-an-rename-explicitly/</link>
		<comments>http://www.blog.project13.pl/index.php/fun/1069/gitjavacamp-fix-1-when-does-git-see-an-rename-explicitly/#comments</comments>
		<pubDate>Sun, 07 Nov 2010 01:37:56 +0000</pubDate>
		<dc:creator>Ktoso</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[git add]]></category>
		<category><![CDATA[git move]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[move]]></category>
		<category><![CDATA[mv]]></category>
		<category><![CDATA[pitfall]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://www.blog.project13.pl/?p=1069</guid>
		<description><![CDATA[Yup, it&#8217;s time for two follow ups to problems we encountered during my life examples. Why didn&#8217;t git see our &#8220;rename&#8221; as rename? Although yes it is true just as I said during the presentation that &#8220;git mv is just an alias&#8221; I&#8217;ve forgotten about that it&#8217;s an little bit bigger alias: git mv oldname [...]]]></description>
			<content:encoded><![CDATA[<p>Yup, it&#8217;s time for two follow ups to problems we encountered during my life examples. Why didn&#8217;t git see our &#8220;rename&#8221; as rename? Although yes it is true just as I said during the presentation that &#8220;git mv is just an alias&#8221; I&#8217;ve forgotten about that it&#8217;s an little bit bigger alias:</p>
<pre><code>
git mv oldname newname
        =
mv oldname newname
git add newname
git rm oldname</code></pre>
<p>Note that last line, git rm oldname is what we fotgot to do in our example, thus git was seeing an just the &#8220;new file&#8221; version of our operation. One line wrong, yet very important :-) Let&#8217;s check if it works this way:</p>
<p><code>[ktoso@homunculus test]$ ls<br />
jeden  typescript<br />
[ktoso@homunculus test]$ git init .<br />
Reinitialized existing Git repository in /home/ktoso/test/.git/<br />
[ktoso@homunculus test]$ cat jeden<br />
drugi pliczek<br />
[ktoso@homunculus test]$ echo 'dwadwa' &gt; dwa<br />
[ktoso@homunculus test]$ cat dwa<br />
dwadwa<br />
[ktoso@homunculus test]$ git add .<br />
[ktoso@homunculus test]$ git commit -m 'dodanie ich'<br />
[master (root-commit) a430782] dodanie ich<br />
2 files changed, 2 insertions(+), 0 deletions(-)<br />
create mode 100644 dwa<br />
create mode 100644 jeden<br />
create mode 100644 typescript<br />
[ktoso@homunculus test]$ git mv<br />
dwa         .git/       jeden       typescript<br />
[ktoso@homunculus test]$ <strong>git mv jeden nowy-jeden</strong><br />
[ktoso@homunculus test]$ git status<br />
# On branch master<br />
# Changes to be committed:<br />
#   (use "git reset HEAD &lt;file&gt;..." to unstage)<br />
#<br />
<strong>#       renamed:    jeden -&gt; nowy-jeden</strong><br />
#<br />
[ktoso@homunculus test]$ mv<br />
dwa         .git/       nowy-jeden  typescript<br />
[ktoso@homunculus test]$ <strong>mv dwa nowe-dwa</strong><br />
[ktoso@homunculus test]$ <strong>git add nowe-dwa</strong><br />
[ktoso@homunculus test]$ <strong>git rm dwa</strong><br />
rm 'dwa'<br />
[ktoso@homunculus test]$ git status<br />
# On branch master<br />
# Changes to be committed:<br />
#   (use "git reset HEAD &lt;file&gt;..." to unstage)<br />
#<br />
#       <strong>renamed:    dwa -&gt; nowe-dwa</strong><br />
#       renamed:    jeden -&gt; nowy-jeden<br />
#<br />
[ktoso@homunculus test]$ echo "problem Solved... :-)"<br />
</code>problem Solved&#8230; :-)</p>
<p>Yup, it actually detects the renames proppery. Even more, it would detect an &#8220;copy&#8221; action (this works even easier):</p>
<p><code>[ktoso@homunculus test]$ <strong>cp nowy-jeden nowy-jeden-jeden</strong><br />
[ktoso@homunculus test]$ <strong>git add .</strong><br />
[ktoso@homunculus test]$ git status<br />
# On branch master<br />
# Changes to be committed:<br />
#   (use "git reset HEAD &lt;file&gt;..." to unstage)<br />
#<br />
#       renamed:    dwa -&gt; nowe-dwa<br />
#       <strong>copied:     jeden -&gt; nowy-jeden</strong><br />
#       renamed:    jeden -&gt; nowy-jeden-jeden<br />
#       modified:   typescript<br />
#</code></p>
<p>I&#8217;m already converting all the presentations to MP4 files and they&#8217;ll be online soon I hope :-) Then I&#8217;ll also write an usual &#8220;review&#8221; as I always do with any confernce/meering. For now just a quick summary: An amazing attandee count, nice presentations and an very very nice crowd :-) Thanks a lot for all the talks, but let&#8217;s wair for my &#8220;review&#8221; with more informations about JC5&#8230; :-) (Oh, yes we&#8217;re allready planing JC6&#8230; ;-))</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.project13.pl/index.php/fun/1069/gitjavacamp-fix-1-when-does-git-see-an-rename-explicitly/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Tweets in WordPress; same timeline but skip in rss feed</title>
		<link>http://www.blog.project13.pl/index.php/project13/938/tweets-in-wordpress-same-timeline-but-skip-in-rss-feed/</link>
		<comments>http://www.blog.project13.pl/index.php/project13/938/tweets-in-wordpress-same-timeline-but-skip-in-rss-feed/#comments</comments>
		<pubDate>Mon, 11 Oct 2010 22:00:56 +0000</pubDate>
		<dc:creator>Ktoso</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[Project13]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.blog.project13.pl/?p=938</guid>
		<description><![CDATA[Hi guys, todays post is about yet another fun and small hack, namely: Having twitter posts (tweets) to be displayed right along all wordpress blog posts (posts) in the same timeline (wordpress main view). しかし!!! As my blog is being listed on http://www.dworld.pl/Blogsfera (and for other obvious reasons) I didn&#8217;t want all my tweets to [...]]]></description>
			<content:encoded><![CDATA[<p>Hi guys, todays post is about yet another fun and small hack, namely: Having twitter posts (tweets) to be displayed right along all wordpress blog posts (posts) in the same timeline (wordpress main view). <strong><acronym title="but (in japanese)">しかし</acronym>!!!</strong></p>
<p>As my blog is being listed on <a href="http://www.dworld.pl/Blogsfera" onclick="urchinTracker('/outgoing/www.dworld.pl/Blogsfera?referer=');">http://www.dworld.pl/Blogsfera</a> (and for other obvious reasons) I didn&#8217;t want all my tweets to be translated &#8220;1 to 1&#8243; to plain old blog posts since this would cause each of my tweets (which can be silly sometimes (but quite <strong>rarely!</strong>)) to land on dworld, which they obviously shouldn&#8217;t as it&#8217;s only an place for Java/Development oriented posts. Also I&#8217;d rather they&#8217;d take less space, and would skip all the categories/tags &#8211; it&#8217;s all in the tweet, so why repeat it again and again?</p>
<p>So&#8230; let&#8217;s start by importing tweets into wordpress. There&#8217;s an great plugin for that, and it&#8217;s called <strong><a href="http://skinju.com/wordpress/tweet-import" onclick="urchinTracker('/outgoing/skinju.com/wordpress/tweet-import?referer=');">Tweet Import</a> by skinju</strong>. Just install it and set it up to fetch your tweet&#8217;s at an regular basis. Ok, we&#8217;re done with step 1 &#8211; but neither are the current tweets smaller or ommitted in the rss feed. Let&#8217;s start by filtering them out from the rss feed:</p>
<p>Open up the file <em><strong>/wp-content/themes/default/functions.php </strong></em>and go to the end of the file, we&#8217;ll add an filter here. Please note that in step 1 you should have created an &#8220;twitter&#8221; category all tweets should be marked with. Let&#8217;s assume this category has an ID of 131, then the following code would do the filtering for us:</p>
<div class="geshi no php">
<div class="head">//add at end of file</div>
<ol>
<li class="li1">
<div class="de1"><span class="sy0">&lt;</span> ?php</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// filter out twitter posts from feed</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> exclude_category<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw1">if</span> <span class="br0">&#40;</span> is_feed<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="coMULTI">/* || is_home()*/</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;set_query_var<span class="br0">&#40;</span><span class="st0">&#39;cat&#39;</span><span class="sy0">,</span> <span class="st0">&#39;-131&#39;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">add_filter<span class="br0">&#40;</span><span class="st0">&#39;pre_get_posts&#39;</span><span class="sy0">,</span> <span class="st0">&#39;exclude_category&#39;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">?&gt;</span></div>
</li>
</ol>
</div>
<p>It&#8217;s a very nice trick, and it&#8217;s <a href="http://zeo.my/exclude-category-in-wordpress/" onclick="urchinTracker('/outgoing/zeo.my/exclude-category-in-wordpress/?referer=');">explained more in detail here</a>. The code is really simple, so no explaining here and let&#8217;s go and tune our view (<strong>yup, the RSS feed is already fixed!</strong>).</p>
<p>To setup our view to work a little different for tweets than for posts, well have to edit: <em><strong>/wp-content/themes/maze/index.php</strong></em> so open it up in your favourite editor and add such an if statement inside an post&#8217;s while statement:</p>
<div class="geshi no php">
<div class="head">//add the 2nd line, the rest is just here for the ease of locating the right place</div>
<ol>
<li class="li1">
<div class="de1">&nbsp; <span class="sy0">&lt;</span> ?php <span class="kw1">while</span> <span class="br0">&#40;</span>have_posts<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy0">:</span> the_post<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="kw2">?&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="sy0">&lt;</span> ?php <span class="kw1">if</span> <span class="br0">&#40;</span>in_category<span class="br0">&#40;</span><span class="st0">&#39;twitter&#39;</span><span class="br0">&#41;</span> <span class="sy0">==</span> <span class="kw2">false</span><span class="br0">&#41;</span><span class="sy0">:</span> <span class="co1">//display post?&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="sy0">&lt;</span>div id<span class="sy0">=</span><span class="st0">&quot;post-&lt;?php the_ID(); ?&gt;&quot;</span><span class="sy0">&gt;&lt;/</span>div<span class="sy0">&gt;</span></div>
</li>
</ol>
</div>
<p>Ok, with this done let&#8217;s write the else part&#8230;</p>
<div class="geshi no php">
<div class="head">//the else for the above if</div>
<ol>
<li class="li1">
<div class="de1"><span class="sy0">&lt;</span> ?php <span class="kw1">else</span><span class="sy0">:</span> <span class="co1">//display tweet ?&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="sy0">&lt;</span>div id<span class="sy0">=</span><span class="st0">&quot;tweet-&lt;?php the_ID(); ?&gt;&quot;</span> style<span class="sy0">=</span><span class="st0">&quot;padding: 15px 15px 0 0&quot;</span><span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="sy0">&lt;</span>div style<span class="sy0">=</span><span class="st0">&quot;background:none repeat scroll 0 0 #262626; font-size:12px; font-weight:normal; line-height:12px; margin:0 30px 10px 0; padding:5px 5px 5px 10px;&quot;</span><span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="sy0">&lt;</span> ?php the_content<span class="br0">&#40;</span><span class="st0">&#39;Read More&#8230;&#39;</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="kw2">?&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="sy0">&lt;/</span>div<span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="sy0">&lt;</span>div<span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;Tweeted by <span class="sy0">&lt;</span>a href<span class="sy0">=</span><span class="st0">&quot;http://www.twitter.com/ktosopl&quot;</span><span class="sy0">&gt;@</span>ktosopl<span class="sy0">&lt;/</span>a<span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="sy0">@</span> <span class="sy0">&lt;</span>a href<span class="sy0">=</span><span class="st0">&quot;&lt;?php $key=&quot;</span>tweetimport_twitter_post_uri<span class="st0">&quot;; echo get_post_meta($post-&gt;ID, $key, true); ?&gt;&quot;</span><span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="sy0">&lt;</span> ?php <span class="re1">$key</span><span class="sy0">=</span><span class="st0">&quot;tweetimport_date_imported&quot;</span><span class="sy0">;</span> <span class="kw3">echo</span> get_post_meta<span class="br0">&#40;</span><span class="re1">$post</span><span class="sy0">-&gt;</span><span class="me1">ID</span><span class="sy0">,</span> <span class="re1">$key</span><span class="sy0">,</span> <span class="kw2">true</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="kw2">?&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="sy0">&lt;/</span>a<span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="sy0">&lt;/</span>div<span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="sy0">&lt;/</span>div<span class="sy0">&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="sy0">&lt;</span> ?php <span class="kw1">endif</span> <span class="co1">//end display mode if?&gt;</span></div>
</li>
</ol>
</div>
<p><em>(You can complain about the in line css styling if you want later, I know it&#8217;s bad but this wordpress theme is a mess anyways&#8230; ;-))</em> Let&#8217;s have a look at the more important parts of this code part. You&#8217;ll notice that I&#8217;m using some weird <strong>get_post_meta()</strong> function. It&#8217;s an method that fetches additional information that each post CAN but doesn&#8217;t have to have. And as the TweetImport plugin does fill an post with a lot of useful tweet data, such as post time and tweet url &#8211; that&#8217;s what I&#8217;m fetching here. The rest should be quite self explanatory, there are bit&#8217;s of hardcoded &#8220;ktosopl&#8221; in there but hey &#8211; it&#8217;s just my blog and I&#8217;m a busy person ;-)</p>
<p>Hope you found this post interesting and maybe you&#8217;ll implement the same thing on your blogs&#8230;? :-)<br />
Cheers!</p>
<p>PS: Oh, and if your interested in talking on one of your upcomming JavaCamps &#8211; feel free to contact me or anyone from the <a href="http://www.java.pl" onclick="urchinTracker('/outgoing/www.java.pl?referer=');"><strong>java.pl</strong></a> team, we&#8217;re looking forward to hearing from you. The nearest meeting will probably be organized around 23&#8242;th or 6&#8242;th&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.project13.pl/index.php/project13/938/tweets-in-wordpress-same-timeline-but-skip-in-rss-feed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android: The &#8220;right way&#8221; &#8211; dependency injection</title>
		<link>http://www.blog.project13.pl/index.php/fun/786/android-the-right-way-dependency-injection/</link>
		<comments>http://www.blog.project13.pl/index.php/fun/786/android-the-right-way-dependency-injection/#comments</comments>
		<pubDate>Sat, 04 Sep 2010 22:56:08 +0000</pubDate>
		<dc:creator>Ktoso</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[dependency injection]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[guice]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.blog.project13.pl/?p=786</guid>
		<description><![CDATA[At work we use an hacked &#8220;up in a few hours&#8221; webapp to track our working hours. And its basically &#8220;enough&#8221;&#8230; until I have to get out from work (while being in a hurry &#8211; which I always am) and simply turn off my PC before stopping the work timer&#8230; I&#8217;d then have to switch [...]]]></description>
			<content:encoded><![CDATA[<p>At work we use an hacked &#8220;up in a few hours&#8221; webapp to track our working hours. And its basically &#8220;enough&#8221;&#8230; until I have to get out from work (while being in a hurry &#8211; which I always am) and simply turn off my PC before stopping the work timer&#8230; I&#8217;d then have to switch my PC back on and just to click this one damn button to &#8220;stop working&#8221;. So&#8230; what can be done to improve this, and make my life easier, while not hacking up a totaly new version of this app with pc-off detection etc etc..? The anwser I found was really simple and long due &#8211; my first Android app :-)</p>
<p>Nuff said, let&#8217;s get down to some code. Basic android stuff is really easy to grasp and I wasn&#8217;t entirely &#8220;new&#8221; to it so coding went without big problems. One thing I missed was Dependency Injection &#8211; which I learned to love thanks to JEE &#8211; esp. Spring and Guice. But fear not &#8211; here&#8217;s how you can use DI &#8211; using Guice &#8211; in your android apps:</p>
<p>Just get the <a href="http://code.google.com/p/roboguice/" onclick="urchinTracker('/outgoing/code.google.com/p/roboguice/?referer=');">RoboGuice</a> and <a href="http://code.google.com/p/google-guice/downloads/list" onclick="urchinTracker('/outgoing/code.google.com/p/google-guice/downloads/list?referer=');">Google Guice</a> (the NO-AOP version) JARs and attach them to your project. Next, you&#8217;ll have to configure your &#8220;Application&#8221; in your<strong> AndroidManifest.xml:</strong></p>
<div class="geshi no xml">
<div class="head">// AndroidManifest.xml</div>
<ol>
<li class="li1">
<div class="de1"><span class="sc1">&amp;lt;</span>application android:name=&quot;pl.xsolve.verfluchter.guice.MyApplication&quot; &#8230; /<span class="sc1">&amp;gt;</span></div>
</li>
</ol>
</div>
<p>The &#8220;android:name&#8221; specifies the &#8220;Application&#8221; class your app will use. This will be used by android as the &#8220;Application&#8221; instance, which would otherwise be just an plain old android &#8220;Aplication&#8221; &#8211; this is an common class for all your Activities and Services, you can do some global setup stuff here etc. And thats wat we are going to do right now:</p>
<div class="geshi no java">
<div class="head">//pl.xsolve.verfluchter.guice.MyApplication</div>
<ol>
<li class="li1">
<div class="de1"><span class="kw2">public</span> <span class="kw2">class</span> MyApplication <span class="kw2">extends</span> GuiceApplication <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; @Override</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">protected</span> <span class="kw4">void</span> addApplicationModules<span class="br0">&#40;</span>List<span class="sy0">&amp;</span>lt<span class="sy0">;</span>Module<span class="sy0">&amp;</span>gt<span class="sy0">;</span> modules<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; modules.<span class="me1">add</span><span class="br0">&#40;</span><span class="kw2">new</span> MyModule<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>We&#8217;re extending the GuiceApplication here, it&#8217;s provided by RoboGuice and allows us to easily add GuiceModules to our app &#8211; which then will be used in dependency resolution as they would normaly in any DI framework. If your interested, thats the ClassHierarhy we hooked into:</p>
<p><a href="http://www.blog.project13.pl/wp-content/uploads/2010/09/application.png"><img class="aligncenter size-full wp-image-791" title="application uml" src="http://www.blog.project13.pl/wp-content/uploads/2010/09/application.png" alt="" width="403" height="357" /></a>Ok, done. Now let&#8217;s setup Guice. It&#8217;s pretty straight foreward we bind interfaces to implementations Guice should use. If needed we could do some more interesting bindings (by our own annotations etc) but I don&#8217;t need such setups in my app so just such an module is ok:</p>
<div class="geshi no java">
<div class="head">// pl.xsolve.verluchter.guice.MyModule</div>
<ol>
<li class="li1">
<div class="de1"><span class="kw2">public</span> <span class="kw2">class</span> MyModule <span class="kw2">extends</span> AbstractAndroidModule <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; @Override</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">protected</span> <span class="kw4">void</span> configure<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// core stuff</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; bind<span class="br0">&#40;</span>AutoSettings.<span class="kw2">class</span><span class="br0">&#41;</span>.<span class="me1">to</span><span class="br0">&#40;</span>AutoSettingsImpl.<span class="kw2">class</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// &#8230;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// this will allow us to @Inject SharedPreferences, what would be somewhat difficulr using standart methods :-)</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; bindConstant<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">annotatedWith</span><span class="br0">&#40;</span>SharedPreferencesName.<span class="kw2">class</span><span class="br0">&#41;</span>.<span class="me1">to</span><span class="br0">&#40;</span><span class="st0">&quot;pl.xsolve.verfluchter&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>And you&#8217;re ready to go. Now you can inject all you want in constructors/setters/fields, for example like this:</p>
<div class="geshi no java">
<div class="head">// some class</div>
<ol>
<li class="li1">
<div class="de1">&nbsp; &nbsp; @Inject</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">public</span> AutoSettingsImpl<span class="br0">&#40;</span>SharedPreferences preferences, PasswdUtil passwdUtil<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">this</span>.<span class="me1">preferences</span> = preferences<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">this</span>.<span class="me1">passwdUtil</span> = passwdUtil<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// &#8230;</span></div>
</li>
</ol>
</div>
<p>Please note that normally to obtain an SharedPreferences instance you would have to be in an Activity and get it like this:</p>
<div class="geshi no java">
<div class="head">// what we had to do before DI&#8230;</div>
<ol>
<li class="li1">
<div class="de1">SharedPreferences preferences = getSharedPreferences<span class="br0">&#40;</span>SETTINGS_NAME, <span class="nu0">0</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">//the no-args version is also OK by the way&#8230;</span></div>
</li>
</ol>
</div>
<p>Another nice thing RoboGuice allows us to do is injecting relations from our view.xml&#8217;s into our Java sources &#8211; which reminds me a little of GWTs UiBinder, but a little reversed, as in GWT the view has all the ui:field=&#8221;blaField&#8221; and here we use R.id.* to pass and get those references&#8230; The overall feel and look stays quite the same I guess &#8211; variables linked to XML objects in the layour. :-) Anyways, here&#8217;s how this linking looks like without DI:</p>
<div class="geshi no java">
<div class="head">// notice the explicit casting that we MUST do, and also, we have to remember what this cast should be (not a problem with installij)</div>
<ol>
<li class="li1">
<div class="de1">&nbsp; &nbsp; TimePicker workingHourEndPicker<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; @Override</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">public</span> <span class="kw4">void</span> onCreate<span class="br0">&#40;</span>Bundle state<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">super</span>.<span class="me1">onCreate</span><span class="br0">&#40;</span>state<span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; setContentView<span class="br0">&#40;</span>R.<span class="me1">layout</span>.<span class="me1">settings</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; workingHourEndPicker = <span class="br0">&#40;</span>TimePicker<span class="br0">&#41;</span> findViewById<span class="br0">&#40;</span>R.<span class="me1">id</span>.<span class="me1">working_hour_end_picker</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// &#8230;</span></div>
</li>
</ol>
</div>
<p>And now the version using RoboGuice:</p>
<div class="geshi no java">
<div class="head">//yay for DI</div>
<ol>
<li class="li1">
<div class="de1">&nbsp; &nbsp; @InjectView<span class="br0">&#40;</span>R.<span class="me1">id</span>.<span class="me1">working_hour_end_picker</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; TimePicker workingHourEndPicker<span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; @Override</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">public</span> <span class="kw4">void</span> onCreate<span class="br0">&#40;</span>Bundle state<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="co1">// &#8230;</span></div>
</li>
</ol>
</div>
<p>Much cleaner in my opinion, and it introduces less places we have to remember changing when our UI Object changes from an TextView ro an WebView for example&#8230; It&#8217;s also possible to inject Strings and other resources this way.</p>
<p>Oh and by the way, the project I took the code samples and learned all this stuff on is on <a href="http://github.com/ktoso/verfluchter-android/" onclick="urchinTracker('/outgoing/github.com/ktoso/verfluchter-android/?referer=');">my GitHub, here</a>.</p>
<hr />
update: <strong>This post has been </strong><a href="http://www.dworld.pl/blogEntry/blog/113" onclick="urchinTracker('/outgoing/www.dworld.pl/blogEntry/blog/113?referer=');"><strong>FEATURED on dworld.pl</strong></a>!Yay, I&#8217;m glad that it seems to be somewhat useful :-) Next up&#8230; more Android, some GWT and some MongoDB :-) Love working with GOOD APIs :-)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.project13.pl/index.php/fun/786/android-the-right-way-dependency-injection/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>GWT Firefox 3.6+ plugin on 64bit Fedora 13</title>
		<link>http://www.blog.project13.pl/index.php/coding/760/gwt-firefox-3-6-plugin-on-64bit-fedora-13/</link>
		<comments>http://www.blog.project13.pl/index.php/coding/760/gwt-firefox-3-6-plugin-on-64bit-fedora-13/#comments</comments>
		<pubDate>Sat, 10 Jul 2010 12:17:49 +0000</pubDate>
		<dc:creator>Ktoso</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[gwt]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[xsolve]]></category>

		<guid isPermaLink="false">http://www.blog.project13.pl/?p=760</guid>
		<description><![CDATA[Hi again, this time a short code snippet &#8211; but a very useful one. At work I&#8217;m working on an Ubuntu 10.4 (love you guys for getting me a PC with Linux without making a fuss about it!) my laptop is on Fedora 13 i586 and my home PC is running Fedora 13 x64. Thank [...]]]></description>
			<content:encoded><![CDATA[<p>Hi again, this time a short code snippet &#8211; but a very useful one.</p>
<p>At work I&#8217;m working on an Ubuntu 10.4 (<em>love you guys for getting me a PC with Linux without making a fuss about it!</em>) my laptop is on Fedora 13 i586 and my home PC is running <strong>Fedora 13 x64</strong>. Thank goodnes they&#8217;re all linux&#8230; ;-) The problem <span style="text-decoration: line-through;">is</span> was that the <strong>Google Web Toolkit</strong> plugin isn&#8217;t working with Firefox 3.6.4 on an x64 system on linux! So&#8230; can&#8217;t I develop GWT stuff on my super powerful home PC? Of course I can, the only thing I needed to do, is to get the latest sources for the plugin and <strong>compile it for myself</strong> ;-) Here&#8217;s how:</p>
<div class="geshi no bash">
<div class="head">mkdir gwt-source</div>
<ol>
<li class="li1">
<div class="de1"><span class="kw3">cd</span> gwt-<span class="kw3">source</span></div>
</li>
<li class="li1">
<div class="de1">svn checkout http:<span class="sy0">//</span>google-web-toolkit.googlecode.com<span class="sy0">/</span>svn<span class="sy0">/</span>trunk<span class="sy0">/</span> trunk</div>
</li>
<li class="li1">
<div class="de1">svn checkout http:<span class="sy0">//</span>google-web-toolkit.googlecode.com<span class="sy0">/</span>svn<span class="sy0">/</span>plugin-sdks<span class="sy0">/</span> plugin-sdks</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">cd</span> trunk<span class="sy0">/</span>plugins<span class="sy0">/</span>xpcom</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">export</span> <span class="re2">BROWSER=</span>ff36</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">export</span> <span class="re2">DEFAULT_FIREFOX_LIBS=</span><span class="sy0">/</span>usr<span class="sy0">/</span>lib<span class="sy0">/</span>xulrunner-devel<span class="nu0">-1.9</span><span class="nu0">.2</span><span class="sy0">/</span>sdk<span class="sy0">/</span>lib<span class="sy0">/</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">make</span> clean</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">make</span></div>
</li>
<li class="li1">
<div class="de1">firefox prebuilt<span class="sy0">/</span>gwt-dev-plugin.xpi</div>
</li>
</ol>
</div>
<p>And we&#8217;re done &#8212; off to GWT development!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.project13.pl/index.php/coding/760/gwt-firefox-3-6-plugin-on-64bit-fedora-13/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

