<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Muharem Hrnjadovic</title>
	<atom:link href="http://muharem.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://muharem.wordpress.com</link>
	<description>Cool ideas revolving around computers and programming</description>
	<lastBuildDate>Mon, 15 Oct 2012 14:35:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='muharem.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Muharem Hrnjadovic</title>
		<link>http://muharem.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://muharem.wordpress.com/osd.xml" title="Muharem Hrnjadovic" />
	<atom:link rel='hub' href='http://muharem.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Shifting gears</title>
		<link>http://muharem.wordpress.com/2012/10/15/shifting-gears/</link>
		<comments>http://muharem.wordpress.com/2012/10/15/shifting-gears/#comments</comments>
		<pubDate>Mon, 15 Oct 2012 12:44:53 +0000</pubDate>
		<dc:creator>muharem</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[cloud computing]]></category>
		<category><![CDATA[openstack]]></category>
		<category><![CDATA[rackspace]]></category>

		<guid isPermaLink="false">http://muharem.wordpress.com/?p=219</guid>
		<description><![CDATA[After almost 2 years with the OpenQuake project I will be joining Rackspace as a technical cloud advocate on 01-Nov-2012. This is novel and exciting in many ways as I will have the opportunity to pursue long standing interests and passions (cloud computing, scalable and robust IT architectures, open source, strategic thinking, reaching out to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=muharem.wordpress.com&#038;blog=484506&#038;post=219&#038;subd=muharem&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>After almost 2 years with the OpenQuake project I will be joining Rackspace as a technical cloud advocate on 01-Nov-2012.</p>
<p>This is novel and exciting in many ways as I will have the opportunity to pursue long standing interests and passions (cloud computing, scalable and robust IT architectures, open source, strategic thinking, reaching out to technical audiences etc.) as part of my *day* job.</p>
<p>I am looking forward to working with the good folks at Rackspace, the cloud community at large and anybody interested in putting cloud technology to good use!</p>
<p>See you around!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/muharem.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/muharem.wordpress.com/219/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=muharem.wordpress.com&#038;blog=484506&#038;post=219&#038;subd=muharem&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://muharem.wordpress.com/2012/10/15/shifting-gears/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/f1a09b9c485088ddd8eaf7809d5b6873?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">muharem</media:title>
		</media:content>
	</item>
		<item>
		<title>First experiments with golang</title>
		<link>http://muharem.wordpress.com/2011/08/01/first-experiments-with-golang/</link>
		<comments>http://muharem.wordpress.com/2011/08/01/first-experiments-with-golang/#comments</comments>
		<pubDate>Mon, 01 Aug 2011 08:44:02 +0000</pubDate>
		<dc:creator>muharem</dc:creator>
				<category><![CDATA[concurrency]]></category>
		<category><![CDATA[golang]]></category>
		<category><![CDATA[goroutine]]></category>

		<guid isPermaLink="false">http://muharem.wordpress.com/?p=192</guid>
		<description><![CDATA[I finally found some time to look at the Go programming language (aka golang). In order to get a feeling for it I picked a random Google code jam problem and programmed it in Go. The code used in the experiments that follow is pretty simple the main module handles the command line arguments and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=muharem.wordpress.com&#038;blog=484506&#038;post=192&#038;subd=muharem&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I finally found some time to look at the <a href="http://golang.org/">Go programming language</a> (aka <code>golang</code>). In order to get a feeling for it I picked a <a href="http://code.google.com/codejam/contest/dashboard?c=351101#s=p0">random Google code jam problem</a> and <a href="https://github.com/al-maisan/exercises/tree/master/cj-a-store-credit">programmed it in Go</a>.</p>
<p>The code used in the experiments that follow is pretty simple</p>
<ul>
<li><a href="https://github.com/al-maisan/exercises/blob/master/cj-a-store-credit/main.go">the main module</a> handles the command line arguments and prints the results</li>
<li><a href="https://github.com/al-maisan/exercises/blob/master/cj-a-store-credit/input.go">the input module</a> parses the input file and starts a calculation for each input</li>
<li><a href="https://github.com/al-maisan/exercises/blob/master/cj-a-store-credit/calculate.go">the calculation module</a> finds a solution for a single input and writes it to a result channel</li>
</ul>
<h2>first impressions</h2>
<p>My first impressions were mostly positive: <code>Go</code> has</p>
<ul>
<li><a href="http://golang.org/doc/docs.html">decent documentation</a> covering the language proper as well as the <a href="http://golang.org/pkg/">standard library</a></li>
<li>a fast compiler resulting in short edit-compile-test cycles</li>
<li>a nice standard library and a wealth of packages (provided by the community)</li>
<li>a lively and friendly <a href="http://groups.google.com/group/golang-nuts">mailing list</a> and <code>irc</code> channel</li>
</ul>
<p>The language has quite a <b>&#8220;direct&#8221;</b> feel to it: I could get to work and be productive almost immediately.<br />
This is in stark contrast to other languages I tried to learn recently e.g. <a href="http://www.scala-lang.org/">Scala</a> (back in January): it required a lot of reading and even a couple of days into it I was not really productive in Scala.</p>
<p><code>Go</code> is quite the opposite, the barrier to entry is low, the language is clean and simple. The combined declaration and initialisation operator (<code>':='</code>) alone is a godsend.</p>
<p>Coming from a Python background the main thing I was missing was the <a href="http://en.wikipedia.org/wiki/Read-eval-print_loop">REPL</a>. Who knows, maybe there is even one out there but I just did not find it yet..?</p>
<h2>playing with goroutines</h2>
<p>One of the most attractive <code>golang</code> features is its support for concurrent programming via <a href="http://golang.org/doc/effective_go.html#goroutines">goroutines</a> and I wanted to play with these.</p>
<p>The programming problem chosen came with an input for 50 calculations. I used it to create inputs with 50, 100 and 200 <b>*thousand*</b> calculations. All calculations are independent of each other i.e. ideally parallelisable.</p>
<p>Being a fairly young language still <code>Go</code> <a href="http://golang.org/doc/effective_go.html#parallel">does not parallelise code by default</a>. If CPU parallelism is desired one must tell the run-time how many goroutines shall execute simultaneously.</p>
<p>The code I wrote <a href="https://github.com/al-maisan/exercises/blob/master/cj-a-store-credit/input.go#L95">starts each calculation in a separate goroutine</a> and allows the user to <a href="https://github.com/al-maisan/exercises/blob/master/cj-a-store-credit/main.go#L40">specify the number of CPUs/cores that should be used</a> to execute the program.</p>
<p>Using a <a href="https://github.com/al-maisan/exercises/blob/master/cj-a-store-credit/run-test">bash script</a> I ran the resulting program varying both the number of calculations and the number of CPU cores.</p>
<p>These experiments were conducted on a 32-core server (Quad-Core AMD Opteron Processor 8356) with 64GB of RAM running <code>Ubuntu 11.04</code> server. Also, I ran each configuration for three consecutive times and used the average duration in the graph below.</p>
<p>Apparently the <code>golang</code> run-time was not able to utilise more than 8 cores when running this particular program.</p>
<p><img src="https://github.com/al-maisan/exercises/raw/master/cj-a-store-credit/data/calc-stats.png" alt="50, 100 and 200 thousand calculations running on 1 through 16 CPU cores" /></p>
<p>As can be seen from the graph (<a href="https://github.com/al-maisan/exercises/raw/master/cj-a-store-credit/data/calc-stats.png">full size</a>) above, executing the program on more than 8 cores did not decrease its running time futher.</p>
<p>The <code>200K</code> calculations input file is a bit over half a gigabyte so I suspected that the program is dominated by <tt>I/O</tt> and the goroutines cannote execute because the <a href="https://github.com/al-maisan/exercises/blob/master/cj-a-store-credit/input.go#L65">result channel</a> is full.</p>
<p>That lead me to <a href="https://github.com/al-maisan/exercises/blob/master/cj-a-store-credit/main.go#L34">experiment with different result channel sizes</a>. The resulting running times (e.g. for <code>200K</code> calculations) can be seen in the graph (<a href="https://github.com/al-maisan/exercises/raw/master/cj-a-store-credit/data/200k-rchans-variation.png">full size</a>) below.</p>
<p><img src="https://github.com/al-maisan/exercises/raw/master/cj-a-store-credit/data/200k-rchans-variation.png" alt="The 200K calculations running on 1 through 16 CPU cores and with varying result channel sizes" /></p>
<p>However, varying the result channel sizes did not seem to have a big effect.</p>
<p>Anyway, I am pretty happy with the code at this point but suggestions are always welcome, particularly those aiming at improving the degree of parallelism <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<h2>conclusions</h2>
<p>I am amazed how far I got by investing approx. 10 hours in learning <code>Go</code> and programming in it.</p>
<p>Having used <a href="http://www.python.org/"><code>python</code></a> almost exclusively for the last 5 years I am pretty spoiled when it comes to code conciseness and productivity.<br />
<code>Go</code> is not too far away though, and, programming in it was fun and enjoyable.</p>
<p>I will definitely continue to explore it. Maybe <em>you</em> should give it a whirl as well <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/muharem.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/muharem.wordpress.com/192/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=muharem.wordpress.com&#038;blog=484506&#038;post=192&#038;subd=muharem&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://muharem.wordpress.com/2011/08/01/first-experiments-with-golang/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/f1a09b9c485088ddd8eaf7809d5b6873?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">muharem</media:title>
		</media:content>

		<media:content url="https://github.com/al-maisan/exercises/raw/master/cj-a-store-credit/data/calc-stats.png" medium="image">
			<media:title type="html">50, 100 and 200 thousand calculations running on 1 through 16 CPU cores</media:title>
		</media:content>

		<media:content url="https://github.com/al-maisan/exercises/raw/master/cj-a-store-credit/data/200k-rchans-variation.png" medium="image">
			<media:title type="html">The 200K calculations running on 1 through 16 CPU cores and with varying result channel sizes</media:title>
		</media:content>
	</item>
		<item>
		<title>EuroPython talk info</title>
		<link>http://muharem.wordpress.com/2011/06/21/europython-talk-info/</link>
		<comments>http://muharem.wordpress.com/2011/06/21/europython-talk-info/#comments</comments>
		<pubDate>Tue, 21 Jun 2011 16:41:07 +0000</pubDate>
		<dc:creator>muharem</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[amqp]]></category>
		<category><![CDATA[EuroPython]]></category>
		<category><![CDATA[RabbitMQ]]></category>

		<guid isPermaLink="false">http://muharem.wordpress.com/?p=184</guid>
		<description><![CDATA[The slides from the EuroPython talk (python &#38; amqp) I held this morning are here. I&#8217;ll post a link to the video when it becomes available. There are two things I wanted to mention but did not get to: python-celery: if you are looking to partition and distribute computations do take a look at it. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=muharem.wordpress.com&#038;blog=484506&#038;post=184&#038;subd=muharem&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>The slides from the <a href="http://ep2011.europython.eu/conference/talks/its-the-message-stupid">EuroPython talk (python &amp; amqp)</a> I held this morning <a href="https://github.com/al-maisan/ep11/blob/master/presentation/messaging-ep2011.pdf?raw=true">are here</a>. I&#8217;ll post a link to the video when it becomes available.</p>
<p>There are two things I wanted to mention but did not get to:</p>
<ol>
<li><a href="http://ask.github.com/celery/">python-celery</a>: if you are looking to partition and distribute computations do take a look at it. We are using it in the <a href="http://openquake.org/">OpenQuake</a> project and are <em>very</em> happy with it.</li>
<li><a href="http://www.manning.com/videla/">RabbitMQ in Action</a>: in case you are using <a href="http://www.rabbitmq.com/">RabbitMQ</a> or plan to do so get this book. I started reading it recently and derived a lot of value from it.</li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/muharem.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/muharem.wordpress.com/184/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=muharem.wordpress.com&#038;blog=484506&#038;post=184&#038;subd=muharem&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://muharem.wordpress.com/2011/06/21/europython-talk-info/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/f1a09b9c485088ddd8eaf7809d5b6873?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">muharem</media:title>
		</media:content>
	</item>
		<item>
		<title>How to dual-boot a stable/experimental system with minimal breakage</title>
		<link>http://muharem.wordpress.com/2011/04/30/how-to-dual-boot-a-stableexperimental-system-with-minimal-breakage/</link>
		<comments>http://muharem.wordpress.com/2011/04/30/how-to-dual-boot-a-stableexperimental-system-with-minimal-breakage/#comments</comments>
		<pubDate>Sat, 30 Apr 2011 09:26:04 +0000</pubDate>
		<dc:creator>muharem</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://muharem.wordpress.com/?p=176</guid>
		<description><![CDATA[For a couple of years now I have been using a scheme that allows me to dual-boot a stable system (for work) and an experimental system (for fun) with minimal breakage. Recent reports of people who upgraded their linux machines and ended up with a broken system prompted me to share it. The idea is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=muharem.wordpress.com&#038;blog=484506&#038;post=176&#038;subd=muharem&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>For a couple of years now I have been using a scheme that allows me to dual-boot a stable system (for work) and an experimental system (for fun) with minimal breakage.<br />
Recent reports of people who upgraded their linux machines and ended up with a broken system prompted me to share it.</p>
<p>The idea is to divide your hard disk into at least 7 partitions</p>
<pre>
    root/usr system 1            12GB
    root/usr system 2            12GB
    /var partition system 1       6GB
    /var partition system 2       6GB
    shared /tmp partition         4GB
    shared swap partition         2GB
    shared home partition       100GB
</pre>
<p>Just in case you are wondering about the small partition sizes: I am using a 160 GB SSD. It was the best hardware investment in a long time and really makes a difference.<br />
If you are using e.g. a 320/500GB hard disk feel free to double the partition sizes (and/or triple the size of the home partition).</p>
<p>When installing a new linux now only two partitions dedicated to that particular installation are needed:</p>
<ul>
<li>a root/usr partition</li>
<li>a /var partition</li>
</ul>
<p>All the others (/tmp, swap, and /home) are shared. This works particularly well when the two installed systems are reasonably similar (e.g. Ubuntu 10.10 and 11.04). What you can do with the set-up described above is a full/proper installation of the desired system as opposed to an upgrade.</p>
<p>Please note that backing up data you cannot afford to lose is a standard procedure <b>before</b> you tinker with your system (e.g. prior to OS installations and/or upgrades).</p>
<p>Sometimes the experimental system is so unstable that I use another technique: a <code>chroot/schroot</code> combination.</p>
<p>There was e.g. a period during which an installed Ubuntu 11.04 was &#8220;unusable&#8221; (for me) but I needed to run it for a number of reasons.<br />
I resorted to running Ubuntu 10.10 as my main work system and having an 11.04 chroot. Entering the latter via the schroot utility made for a fairly seamless experience.</p>
<p>I hope this helps <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/muharem.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/muharem.wordpress.com/176/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=muharem.wordpress.com&#038;blog=484506&#038;post=176&#038;subd=muharem&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://muharem.wordpress.com/2011/04/30/how-to-dual-boot-a-stableexperimental-system-with-minimal-breakage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/f1a09b9c485088ddd8eaf7809d5b6873?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">muharem</media:title>
		</media:content>
	</item>
		<item>
		<title>SSDs are the way to go!</title>
		<link>http://muharem.wordpress.com/2011/03/12/ssds-are-the-way-to-go/</link>
		<comments>http://muharem.wordpress.com/2011/03/12/ssds-are-the-way-to-go/#comments</comments>
		<pubDate>Sat, 12 Mar 2011 09:37:06 +0000</pubDate>
		<dc:creator>muharem</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[I love it]]></category>
		<category><![CDATA[ssd]]></category>
		<category><![CDATA[thinkpad]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://muharem.wordpress.com/?p=161</guid>
		<description><![CDATA[I bought an intel X25-M SSD last week and it does make a *big* difference! It is faster, develops less noise and heat and the battery lasts longer. I am using it with a lenovo thinkpad t410 laptop running Ubuntu 10.10 and it&#8217;s just great! For what it&#8217;s worth I am running a pretty recent [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=muharem.wordpress.com&#038;blog=484506&#038;post=161&#038;subd=muharem&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I bought an <a href="http://www.storagereview.com/intel_x25-m_ssd_review"><code>intel X25-M SSD</code></a> last week and it does make a *big* difference!  It is faster, develops less noise and heat and the battery lasts longer.</p>
<p>I am using it with a lenovo <code>thinkpad t410</code> laptop running <code>Ubuntu 10.10</code> and it&#8217;s just great!</p>
<p>For what it&#8217;s worth I am running <a href="http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.38-rc8-natty/">a pretty recent kernel</a> in conjunction with the <code>Ubuntu maverick</code> userland. Not sure how well the normal <code>2.6.35 kernel</code> supports SSDs.  </p>
<p>Anyway, SSDs are the way to go <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/muharem.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/muharem.wordpress.com/161/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=muharem.wordpress.com&#038;blog=484506&#038;post=161&#038;subd=muharem&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://muharem.wordpress.com/2011/03/12/ssds-are-the-way-to-go/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/f1a09b9c485088ddd8eaf7809d5b6873?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">muharem</media:title>
		</media:content>
	</item>
		<item>
		<title>What is the best way to reset a file in a git topic branch?</title>
		<link>http://muharem.wordpress.com/2011/03/09/what-is-the-best-way-to-reset-a-file-in-a-git-topic-branch/</link>
		<comments>http://muharem.wordpress.com/2011/03/09/what-is-the-best-way-to-reset-a-file-in-a-git-topic-branch/#comments</comments>
		<pubDate>Wed, 09 Mar 2011 20:26:57 +0000</pubDate>
		<dc:creator>muharem</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[review]]></category>

		<guid isPermaLink="false">http://muharem.wordpress.com/?p=156</guid>
		<description><![CDATA[Sometimes, when reviewing topic branches, I like to reset a file (to whatever it was in the master branch) and play around with it. I figured out how to do that (see below) but it&#8217;s a bit clunky. Please take a look and comment if you know of a better way. Here goes the example: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=muharem.wordpress.com&#038;blog=484506&#038;post=156&#038;subd=muharem&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Sometimes, when reviewing topic branches, I like to reset a file (to whatever it was in the master branch) and play around with it.</p>
<p>I figured out how to do that (see below) but it&#8217;s a bit clunky. Please take a look and comment if you know of a better way.</p>
<p>Here goes the example: first a repository is initialised and a file is added to it.</p>
<pre>
$ mkdir -p gitreset

$ cd gitreset/

$ git init .
Initialized empty Git repository in /home/muharem/tmp/gitreset/.git/

$ cat &gt; a
This is file a, rev. 1
^D

$ git add a

$ git commit -a -m "initial commit"
[master (root-commit) 3e74747] initial commit
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 a
</pre>
<p>Next a topic branch is created and the file is modified in the former.</p>
<pre>
$ git checkout -b topic-branch master 
Switched to a new branch 'topic-branch'

$ cat &gt; a
This is file a, rev. 2
^D

$ git diff
diff --git a/a b/a
index 595c3aa..7eb0dca 100644
--- a/a
+++ b/a
@@ -1 +1 @@
-This is file a, rev. 1
+This is file a, rev. 2

$ git commit -a -m "change to file a"
[topic-branch 300108e] change to file a
 1 files changed, 1 insertions(+), 1 deletions(-)
</pre>
<p>Now I would like to reset the file to whatever it was in the master branch.</p>
<pre>
$ git reset master a
Unstaged changes after reset:
M	a

$ cat a
This is file a, rev. 2

$ git diff
diff --git a/a b/a
index 595c3aa..7eb0dca 100644
--- a/a
+++ b/a
@@ -1 +1 @@
-This is file a, rev. 1
+This is file a, rev. 2

$ git diff --staged
diff --git a/a b/a
index 7eb0dca..595c3aa 100644
--- a/a
+++ b/a
@@ -1 +1 @@
-This is file a, rev. 2
+This is file a, rev. 1
</pre>
<p>It appears the file was reset but the revision of interest is in the staging area. To get that revision into the working tree I need to do additional work.</p>
<pre>
$ git diff --staged | patch -p1
patching file a

$ cat a
This is file a, rev. 1
</pre>
<p>Is there a way to have the changes resulting from <code>git reset</code> in the working tree straightaway?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/muharem.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/muharem.wordpress.com/156/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=muharem.wordpress.com&#038;blog=484506&#038;post=156&#038;subd=muharem&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://muharem.wordpress.com/2011/03/09/what-is-the-best-way-to-reset-a-file-in-a-git-topic-branch/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/f1a09b9c485088ddd8eaf7809d5b6873?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">muharem</media:title>
		</media:content>
	</item>
		<item>
		<title>OpenQuake is hiring in Zürich and in Pavia</title>
		<link>http://muharem.wordpress.com/2011/03/03/openquake-is-hiring-in-zurich-and-in-pavia/</link>
		<comments>http://muharem.wordpress.com/2011/03/03/openquake-is-hiring-in-zurich-and-in-pavia/#comments</comments>
		<pubDate>Thu, 03 Mar 2011 12:45:53 +0000</pubDate>
		<dc:creator>muharem</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[job]]></category>
		<category><![CDATA[opening]]></category>
		<category><![CDATA[openquake]]></category>
		<category><![CDATA[opportunity]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://muharem.wordpress.com/?p=145</guid>
		<description><![CDATA[The OpenQuake project is looking to hire two Python developers (one in Zürich/Switzerland, the other in Pavia/Italy). We are a global and public project, do our development in accordance with agile principles and all our code is open. Please see [1] and [2] below for more details on what we do. In case you are [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=muharem.wordpress.com&#038;blog=484506&#038;post=145&#038;subd=muharem&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>The OpenQuake project is looking to hire two Python developers (one in Zürich/Switzerland, the other in Pavia/Italy).</p>
<p>We are a global and public project, do our development in accordance with agile principles and all our code is open.</p>
<p>Please see [1] and [2] below for more details on what we do.</p>
<p>In case you are interested, please send me an email (<code>muharem</code> SPAM-SUCKS <code>linux.com</code>) with your date of availability, your CV as well as some (python) code samples.</p>
<p>[1] <a href="http://www.globalquakemodel.org/">http://www.globalquakemodel.org</a><br />
[2] <a href="http://www.openquake.org/">http://www.openquake.org</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/muharem.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/muharem.wordpress.com/145/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=muharem.wordpress.com&#038;blog=484506&#038;post=145&#038;subd=muharem&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://muharem.wordpress.com/2011/03/03/openquake-is-hiring-in-zurich-and-in-pavia/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/f1a09b9c485088ddd8eaf7809d5b6873?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">muharem</media:title>
		</media:content>
	</item>
		<item>
		<title>The world has changed</title>
		<link>http://muharem.wordpress.com/2011/02/20/the-world-has-changed/</link>
		<comments>http://muharem.wordpress.com/2011/02/20/the-world-has-changed/#comments</comments>
		<pubDate>Sun, 20 Feb 2011 17:55:00 +0000</pubDate>
		<dc:creator>muharem</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[lenovo]]></category>
		<category><![CDATA[social web]]></category>
		<category><![CDATA[t410]]></category>
		<category><![CDATA[thinkpad]]></category>

		<guid isPermaLink="false">http://muharem.wordpress.com/?p=146</guid>
		<description><![CDATA[Whether for the better or the worse is left as an exercise to the reader but it definitely has changed. The other day I was whining diffusely about the breakage of my new lenovo thinkpad t410. A day later I get a response. And a useful one at that! Think about it! When did we [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=muharem.wordpress.com&#038;blog=484506&#038;post=146&#038;subd=muharem&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Whether for the better or the worse is left as an exercise to the reader but it definitely has changed.</p>
<p>The other day I was <a href="http://twitter.com/al_maisan/status/38522625881944064">whining diffusely</a> about the breakage of my new <code>lenovo</code> <code>thinkpad</code> <code>t410</code>. A day later I get <a href="http://twitter.com/#!/lenovoforums/status/38738809231253504">a response</a>. And a useful one at that!</p>
<p>Think about it! When did we ever have this before? Random people from a different continent taking note of one&#8217;s utterances and sharing their knowledge?</p>
<p>Just in case you missed it, the world has changed. And in this particular case I quite like it <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/muharem.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/muharem.wordpress.com/146/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=muharem.wordpress.com&#038;blog=484506&#038;post=146&#038;subd=muharem&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://muharem.wordpress.com/2011/02/20/the-world-has-changed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/f1a09b9c485088ddd8eaf7809d5b6873?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">muharem</media:title>
		</media:content>
	</item>
		<item>
		<title>Vim mappings for the win</title>
		<link>http://muharem.wordpress.com/2010/09/27/124/</link>
		<comments>http://muharem.wordpress.com/2010/09/27/124/#comments</comments>
		<pubDate>Mon, 27 Sep 2010 07:51:05 +0000</pubDate>
		<dc:creator>muharem</dc:creator>
				<category><![CDATA[tools]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[geek]]></category>
		<category><![CDATA[mapping]]></category>
		<category><![CDATA[unit test]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://muharem.wordpress.com/?p=124</guid>
		<description><![CDATA[I mostly work in source code hierarchies where for a given source file X.source the location of the file with the unit tests is tests/test_X.source and more often than not I need to do edit the unit tests after having opened the actual source file. Being the geek that I am I *obviously* need to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=muharem.wordpress.com&#038;blog=484506&#038;post=124&#038;subd=muharem&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I mostly work in source code hierarchies where for a given source file <code>X.source</code> the location of the file with the unit tests is <code>tests/test_X.source</code> and more often than not I need to do edit the unit tests after having opened the actual source file.</p>
<p>Being the geek that I am I <strong>*obviously*</strong> need to come up with some sort of optimisation or shortcut even if it takes <code>10x</code> as long as stupidly typing in <code>":e tests/test_X.source"</code> all the time <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Thankfully, the solution in <a href="http://www.vim.org">vim</a> turns out to be quite straightforward. The following mapping (conveniently added to your <code>$HOME/.vimrc</code> file) will open the unit test file when you type <code>%%</code></p>
<pre>
nnoremap %% :e =escape(expand("%:h")."/tests/test_".expand("%:t"), "")^M
</pre>
<p>Please note that the last bit (<code>"^M"</code>) is just <em>one</em> character (the <code>Enter</code> key) that you can get by typing <code>^V</code> followed by the <code>Enter</code> key.</p>
<p>I guess what I should really do is write a <em>configurable</em> <code>vim plugin</code> that opens arbitrary files/locations based on the current buffer/location. Oh well, so much to do and so little time <code> <img src='http://s2.wp.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </code></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/muharem.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/muharem.wordpress.com/124/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=muharem.wordpress.com&#038;blog=484506&#038;post=124&#038;subd=muharem&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://muharem.wordpress.com/2010/09/27/124/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/f1a09b9c485088ddd8eaf7809d5b6873?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">muharem</media:title>
		</media:content>
	</item>
		<item>
		<title>Tool of the year!</title>
		<link>http://muharem.wordpress.com/2010/06/12/119/</link>
		<comments>http://muharem.wordpress.com/2010/06/12/119/#comments</comments>
		<pubDate>Sat, 12 Jun 2010 09:53:53 +0000</pubDate>
		<dc:creator>muharem</dc:creator>
				<category><![CDATA[tools]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[clipboard]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[parcellite]]></category>
		<category><![CDATA[x-windows]]></category>

		<guid isPermaLink="false">http://muharem.wordpress.com/?p=119</guid>
		<description><![CDATA[I have been suffering from the multiple clipboards &#8220;feature&#8221; under X-Windows/Gnome for quite a while and finally found a solution: parcellite. Install it, run it, right-click on the icon, select &#8220;preferences&#8221; from the menu, check &#8220;Use Primary (Selection)&#8221; and &#8220;Synchronize clipboards&#8221; in the &#8220;Behavior&#8221; tab. .. and enjoy life again<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=muharem.wordpress.com&#038;blog=484506&#038;post=119&#038;subd=muharem&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I have been suffering from the multiple clipboards &#8220;feature&#8221; under X-Windows/Gnome for quite a while and finally found a solution: <code>parcellite</code>.</p>
<p>Install it, run it, right-click on the icon, select &#8220;preferences&#8221; from the menu, check &#8220;Use Primary (Selection)&#8221; and &#8220;Synchronize clipboards&#8221; in the &#8220;Behavior&#8221; tab.</p>
<p>.. and enjoy life again <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/muharem.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/muharem.wordpress.com/119/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=muharem.wordpress.com&#038;blog=484506&#038;post=119&#038;subd=muharem&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://muharem.wordpress.com/2010/06/12/119/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/f1a09b9c485088ddd8eaf7809d5b6873?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">muharem</media:title>
		</media:content>
	</item>
	</channel>
</rss>
