<?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>ganglio&#039;s &#187; Coding</title>
	<atom:link href="http://ganglio.eu/home/category/coding/feed/" rel="self" type="application/rss+xml" />
	<link>http://ganglio.eu/home</link>
	<description>a place for stuff and stuffings</description>
	<lastBuildDate>Tue, 12 Jul 2011 10:05:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<image><title>ganglio&#039;s</title><url>http://ganglio.eu/logo.png</url><link>http://ganglio.eu/home</link><width>800</width><height>641</height><description>ganglio&#039;s - http://ganglio.eu/home</description></image>		<item>
		<title>Playing with BASH prompt and GIT</title>
		<link>http://ganglio.eu/home/2010/11/29/playing-with-bash-prompt-and-git/</link>
		<comments>http://ganglio.eu/home/2010/11/29/playing-with-bash-prompt-and-git/#comments</comments>
		<pubDate>Mon, 29 Nov 2010 20:29:31 +0000</pubDate>
		<dc:creator>ganglio</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[geek]]></category>

		<guid isPermaLink="false">http://www.ganglio.eu/home/?p=381</guid>
		<description><![CDATA[It&#8217;s more than a year now since I started using GIT and I can say that is the best versioning system ever invented. It&#8217;s fast, really fast. And clean. I used SVN at the univ and it was a bloody pain. Merging branches was awful and it easily got messed although it was just two [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s more than a year now since I started using GIT and I can say that is the best versioning system ever invented.<br />
It&#8217;s fast, really fast. And clean. I used SVN at the univ and it was a bloody pain. Merging branches was awful and it easily got messed although it was just two of us working on the same project.<br />
Now we are three from 6 different machines and everything is just a piece of cake.<br />
You pull in the morning. Commit your changes every now and then. And push in the evening.<br />
No fuss no pain.<br />
Just nicely simple.</p>
<p>As I&#8217;m a console guy, I came up with a nice configuration for my bash prompt that tells me what&#8217;s going on with the project.</p>
<p>I thought it would be nice to share it with you. Here it is:</p>
<p>First add the following functions to your <i>.bash_profile</i> or <i>.bashrc</i> or, if you are a really clean guy, to your <i>.bash_functions</i></p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">function</span> parse_git_branch_and_add_brackets <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re2">branch=</span>$<span class="br0">&#40;</span>git branch &#8211;no-color <span class="nu0">2</span>&gt; /dev/null | <span class="kw2">sed</span> -e <span class="st0">&#8216;/^[^*]/d&#8217;</span> -e <span class="st0">&#8216;s/* <span class="es0">\(</span>.*<span class="es0">\)</span>/<span class="es0">\1</span>/&#8217;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re2">repo=</span>$<span class="br0">&#40;</span>git config &#8211;get <span class="st0">&quot;branch.$branch.remote&quot;</span> <span class="nu0">2</span>&gt; /dev/null<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw3">echo</span> <span class="st0">&quot; [&quot;</span><span class="re1">$branch</span><span class="st0">&quot;@&quot;</span><span class="re1">$repo</span><span class="st0">&quot;]&quot;</span> | <span class="kw2">sed</span> -e <span class="st0">&#8216;/^<span class="es0">\ </span><span class="es0">\[</span>@<span class="es0">\]</span>/d&#8217;</span></div>
</li>
<li class="li2">
<div class="de2"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">function</span> parse_git_status <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re2">status=</span>$<span class="br0">&#40;</span><span class="kw3">echo</span> `git status -s <span class="nu0">2</span>&gt; /dev/null | <span class="kw2">awk</span> <span class="st0">&#8216;{print $1;}&#8217;</span> | <span class="kw2">sort</span> | <span class="kw2">uniq</span> -c | <span class="kw2">sed</span> -e <span class="st0">&quot;s/??/U/g&quot;</span> | <span class="kw2">sed</span> -E <span class="st0">&quot;s/([0-9]*)<span class="es0">\ </span>([A-Z])/<span class="es0">\1</span><span class="es0">\2</span>/&quot;</span>`<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re2">status=</span>$<span class="br0">&#40;</span><span class="kw3">echo</span> <span class="st0">&quot;(&quot;</span><span class="re1">$status</span><span class="st0">&quot;)&quot;</span> | <span class="kw2">sed</span> -e <span class="st0">&quot;/^()$/d&quot;</span><span class="br0">&#41;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re2">ahead=</span>$<span class="br0">&#40;</span>git status <span class="nu0">2</span>&gt; /dev/null | <span class="kw2">grep</span> ahead | <span class="kw2">awk</span> <span class="st0">&#8216;{print $9;}&#8217;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re2">ahead=</span>$<span class="br0">&#40;</span><span class="kw3">echo</span> <span class="st0">&quot;{&quot;</span><span class="re1">$ahead</span><span class="st0">&quot;}&quot;</span> | <span class="kw2">sed</span> <span class="st0">&quot;/^{}$/d&quot;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw3">echo</span> -e <span class="st0">&quot;<span class="es0">\0</span>33[01;32m&quot;</span><span class="re1">$status</span><span class="st0">&quot;<span class="es0">\0</span>33[01;0m&quot;</span><span class="st0">&quot;<span class="es0">\0</span>33[01;31m&quot;</span><span class="re1">$ahead</span><span class="st0">&quot;<span class="es0">\0</span>33[01;0m&quot;</span></div>
</li>
<li class="li2">
<div class="de2"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>Then edit your <i>.bashrc</i> (or <i>.bash_profile</i> depending on your distro) and find the line where the variable <i>PS1</i> is defined. Once found, change it as follows:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="re2">PS1=</span><span class="st0">'${debian_chroot:+($debian_chroot)}<span class="es0">\[</span><span class="es0">\0</span>33[01;32m<span class="es0">\]</span><span class="es0">\u</span>@<span class="es0">\h</span><span class="es0">\[</span><span class="es0">\0</span>33[00m<span class="es0">\]</span>:<span class="es0">\[</span><span class="es0">\0</span>33[00;34m<span class="es0">\]</span><span class="es0">\w</span><span class="es0">\[</span><span class="es0">\0</span>33[1;33m<span class="es0">\]</span>$(parse_git_branch_and_add_brackets)<span class="es0">\[</span><span class="es0">\0</span>33[0m<span class="es0">\]</span>$(parse_git_status) <span class="es0">\$</span> &#8216;</span></div>
</li>
</ol>
</div>
<p>If you are on a Mac (and I really hope for you that you are :þ) the line is the following:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="re2">PS1=</span><span class="st0">&#8216;<span class="es0">\h</span>:<span class="es0">\W</span> <span class="es0">\u</span><span class="es0">\[</span><span class="es0">\0</span>33[1;33m<span class="es0">\]</span>$(parse_git_branch_and_add_brackets)<span class="es0">\[</span><span class="es0">\0</span>33[0m<span class="es0">\]</span><span class="es0">\[</span>$(parse_git_status)<span class="es0">\]</span> <span class="es0">\$</span> &#8216;</span></div>
</li>
</ol>
</div>
<p>And that&#8217;s it.</p>
<p>Now your prompt should look as the following:</p>
<div id="attachment_382" class="wp-caption aligncenter" style="width: 465px"><img src="http://www.ganglio.eu/home/wp-content/uploads/2010/11/GIT-powered-BASH-prompt.png" alt="" title="GIT powered BASH prompt" width="455" height="20" class="size-full wp-image-382" /><p class="wp-caption-text">GIT powered BASH prompt</p></div>
<p>The part between square brackets are the branch and the repo. The part between the round brackets is the status of your working folder at the moment. The part between the curly brackets is how many commits you are ahead of the master branch.<br />
In my case the branch is <b>master</b> and the repo is <b>origin</b>. I have one file added but not yet committed <b>(A)</b>, one file untracked <b>(U)</b> and one file modified <b>(M)</b>. And I&#8217;m one commit ahead of the master.</p>
<p>Useful, isn&#8217;t it?</p>
<p><b>[update]</b><br />
There was a small bug in the <i>parse_git_status</i> function. I added a <i>sort</i> before the <i>uniq</i> so that it properly groups the changes.<br />
<b>[/update]</b></p>
]]></content:encoded>
			<wfw:commentRss>http://ganglio.eu/home/2010/11/29/playing-with-bash-prompt-and-git/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Harmony</title>
		<link>http://ganglio.eu/home/2010/06/01/harmony/</link>
		<comments>http://ganglio.eu/home/2010/06/01/harmony/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 11:24:16 +0000</pubDate>
		<dc:creator>ganglio</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[web apps]]></category>

		<guid isPermaLink="false">http://www.ganglio.eu/home/?p=292</guid>
		<description><![CDATA[Amazing HTML5 procedural canvas-drawing example. Completely written in HTML5 &#038; JS it&#8217;s a funny toy to play with and a good showcase of the possibilities offered by the new standard. Looking forward for a wide implementation (along with CSS3 specs). By Mr. Doob via Digital Tools]]></description>
			<content:encoded><![CDATA[<p>Amazing HTML5 procedural canvas-drawing example.</p>
<p>Completely written in HTML5 &#038; JS it&#8217;s a funny toy to play with and a good showcase of the possibilities offered by the new standard.<br />
Looking forward for a wide implementation (along with CSS3 specs).</p>
<div id="attachment_293" class="wp-caption aligncenter" style="width: 271px"><a target="_blank" href="http://mrdoob.com/projects/harmony/"><img src="http://www.ganglio.eu/home/wp-content/uploads/2010/06/Harmony-261x300.png" alt="" title="Harmony" width="261" height="300" class="size-medium wp-image-293" /></a><p class="wp-caption-text">Harmony</p></div>
<p>By <a target="_blank" href="http://mrdoob.com/blog/post/689">Mr. Doob</a> via <a target="_blank" href="http://digitaltools.node3000.com/blog/2503-harmony-html5-canvas-drawing?utm_source=feedburner&#038;utm_medium=feed&#038;utm_campaign=Feed%3A+digitaltools+%28Digital+Tools%29&#038;utm_content=Google+Reader">Digital Tools</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ganglio.eu/home/2010/06/01/harmony/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Word Clock: The Widget &#8211; Update</title>
		<link>http://ganglio.eu/home/2009/11/18/word-clock-the-widget-update/</link>
		<comments>http://ganglio.eu/home/2009/11/18/word-clock-the-widget-update/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 12:01:11 +0000</pubDate>
		<dc:creator>ganglio</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[update]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false">http://www.ganglio.eu/home/?p=62</guid>
		<description><![CDATA[Quick update on the Word Clock Widget. Now it uses cufón to render the clock using user selected fonts. The font I&#8217;m using is Circled by Roger White. From my personal tastes point of view I advise to use monospaced fonts, but it&#8217;s just my tastes. As usual, the code is here.]]></description>
			<content:encoded><![CDATA[<p>Quick update on the Word Clock Widget.</p>
<p>Now it uses <a href="http://cufon.shoqolate.com/generate/" target="_blank">cufón</a> to render the clock using user selected fonts.</p>
<p>The font I&#8217;m using is <a href="http://www.fontspace.com/roger-white/circled" target="_blank">Circled</a> by Roger White.<br />
From my personal tastes point of view I advise to use monospaced fonts, but it&#8217;s just my tastes.</p>
<p>As usual, the code is <a href="http://www.ganglio.eu/home/wp-content/uploads/2009/11/wordclock_widget_1.1.zip">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ganglio.eu/home/2009/11/18/word-clock-the-widget-update/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Word Clock: The Widget</title>
		<link>http://ganglio.eu/home/2009/11/17/word-clock-the-widget/</link>
		<comments>http://ganglio.eu/home/2009/11/17/word-clock-the-widget/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 13:42:52 +0000</pubDate>
		<dc:creator>ganglio</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false">http://www.ganglio.eu/home/?p=45</guid>
		<description><![CDATA[As promised I, finally, got some time to complete the widget. It is based on my Geektools script and uses jQuery and jQuery Timers for automatic update. Here the code: Word Clock Widget Have fun!]]></description>
			<content:encoded><![CDATA[<p>As promised I, finally, got some time to complete the widget.</p>
<p>It is based on my <a href="http://projects.tynsoe.org/en/geektool/" target="_blank">Geektools</a> script and uses jQuery and jQuery Timers for automatic update.</p>
<p>Here the code: <a href="http://www.ganglio.eu/home/wp-content/uploads/2009/11/wordclock_widget.zip">Word Clock Widget</a></p>
<p>Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://ganglio.eu/home/2009/11/17/word-clock-the-widget/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Updated Word Clock</title>
		<link>http://ganglio.eu/home/2009/11/17/updated-word-clock/</link>
		<comments>http://ganglio.eu/home/2009/11/17/updated-word-clock/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 11:40:50 +0000</pubDate>
		<dc:creator>ganglio</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[geektool]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://www.ganglio.eu/home/?p=38</guid>
		<description><![CDATA[I Finally found some time to fix a couple of bugs in the Word Clock code. Here the updated one. Soon I&#8217;ll upload a completed (AJAX based) version of the Word Clock plugin.]]></description>
			<content:encoded><![CDATA[<p>I Finally found some time to fix a couple of bugs in the Word Clock code.</p>
<p>Here the updated <a href="http://www.ganglio.eu/home/wp-content/uploads/2009/11/word-clock-1.1.zip">one</a>.</p>
<p>Soon I&#8217;ll upload a completed (AJAX based) version of the Word Clock plugin.</p>
]]></content:encoded>
			<wfw:commentRss>http://ganglio.eu/home/2009/11/17/updated-word-clock/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My new desktop clock</title>
		<link>http://ganglio.eu/home/2009/10/11/my-new-desktop-clock/</link>
		<comments>http://ganglio.eu/home/2009/10/11/my-new-desktop-clock/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 18:10:27 +0000</pubDate>
		<dc:creator>ganglio</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[geektool]]></category>

		<guid isPermaLink="false">http://www.ganglio.eu/home/?p=17</guid>
		<description><![CDATA[I just finished my desktop wordclock. It&#8217;s a PHP script for GeekTool The idea came from an article I read on Boing Boing few days ago. I thought why not implement it on my desktop. Unfortunately I don&#8217;t remember the original post. If you have any kind of information about it please let me know. [...]]]></description>
			<content:encoded><![CDATA[<p>I just finished my desktop wordclock.<br />
It&#8217;s a PHP script for <a title="GeekTool" href="http://projects.tynsoe.org/en/geektool/" target="_blank">GeekTool</a><br/><br />
The idea came from an article I read on <a title="Boing Boing" href="http://boingboing.net/" target="_blank">Boing Boing</a> few days ago. I thought why not implement it on my desktop. Unfortunately I don&#8217;t remember the original post. If you have any kind of information about it please let me know.<br/>
</p>
<div id="attachment_19" class="wp-caption aligncenter" style="width: 310px"><img src="http://www.ganglio.eu/home/wp-content/uploads/2009/10/word-clock-300x212.jpg" alt="How it appears on my desktop" title="word clock" width="300" height="212" class="size-medium wp-image-19" /><p class="wp-caption-text">How it appears on my desktop</p></div>
<p>Here there&#8217;s <a title="the code" href='http://www.ganglio.eu/home/wp-content/uploads/2009/10/word-clock.zip'>the code</a>.</p>
<p><span style="font-weight: bold">UPDATE</span>&nbsp;I finally discovered that the article the idea is from <a href="http://lifehacker.com/" target="_blank">Lifehacker</a>. This <a href="http://lifehacker.com/5373272/build-a-wallclock-that-displays-time-in-plain-english" target="_blank">article</a>, for sake of precision.</p>
]]></content:encoded>
			<wfw:commentRss>http://ganglio.eu/home/2009/10/11/my-new-desktop-clock/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

