<?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>Code Nomad</title>
	<atom:link href="http://jasonkarns.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://jasonkarns.com/blog</link>
	<description>Tales of a Transient Programmer</description>
	<lastBuildDate>Thu, 19 Apr 2012 21:57:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>LOAD ALL THE RUBIES!!!</title>
		<link>http://jasonkarns.com/blog/load-all-the-rubies/</link>
		<comments>http://jasonkarns.com/blog/load-all-the-rubies/#comments</comments>
		<pubDate>Thu, 19 Apr 2012 21:57:25 +0000</pubDate>
		<dc:creator>jasonkarns</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[cucumber]]></category>

		<guid isPermaLink="false">http://jasonkarns.com/blog/?p=321</guid>
		<description><![CDATA[Dangerous Cucumber Loading Issue I recently discovered a potentially dangerous issue with how cucumber loads ruby files. The standard cucumber project expects a features directory in which to place your .feature files. Standard practice is to place supporting ruby files in features/support and to place step definitions in features/step_definitions, but that&#8217;s just convention. Cucumber recursively [...]]]></description>
			<content:encoded><![CDATA[<h2>Dangerous Cucumber Loading Issue</h2>
<p>I recently discovered a <a href="https://github.com/cucumber/cucumber/issues/269">potentially dangerous issue with how cucumber loads ruby files</a>. The standard cucumber project expects a <kbd>features</kbd> directory in which to place your <kbd>.feature</kbd> files. Standard practice is to place supporting ruby files in <kbd>features/support</kbd> and to place step definitions in <kbd>features/step_definitions</kbd>, but that&#8217;s just convention. Cucumber recursively loads <em>all</em> .rb files under <kbd>features/</kbd> (ensuring only that <kbd>features/support/env.rb</kbd> is loaded first). This is all well and good, so long as you actually have a features directory (and it&#8217;s in the root of your project). So what happens if you name your features directory something else or your features directory is in a sub-directory? If you remember to tell cucumber which directory to load from, everything is fine (<kbd>`cucumber alternative_folder/`</kbd>). If you forget, however, cucumber will dutifully load (recursively) <strong>every ruby file it can find</strong>!</p>
<h3>format_hard_drive.rb</h3>
<p>This is still not much of a problem, assuming all your ruby files are just plain old ruby classes or benign ruby scripts. The problem really rears it&#8217;s head if, say, you have a <kbd>utility_scripts</kbd> directory full of potentially dangerous scripts for setting up project directories, manipulating test databases, or pretty much anything. (Who else has an <code>`rm -rf /`</code> ruby script?)</p>
<p><img src="http://jasonkarns.com/blog/wp-content/uploads/2012/04/3ouy3w1.jpg" alt="Cucumber - Load All The Things!!!" title="Cucumber - Load All The Things!!!" width="320" height="240" class="alignnone size-full wp-image-322" /></p>
<h3>Lesson</h3>
<p>Name your features directory <kbd>features</kbd>.</p>
<div class="rpxsocial"><div class="rpxsharebutton" onclick="rpxWPsocial('Share:','Dangerous Cucumber Loading Issue I recently discovered a potentially dangerous issue with how cucumber loads ruby files. The sta...','http://jasonkarns.com/blog/load-all-the-rubies/','LOAD ALL THE RUBIES!!!','Shared LOAD ALL THE RUBIES!!!','','321', this);"><div class="rpx_share_label">&nbsp;</div><div class="rpx_social_icons"><div class="rpx_icon rpx_size30 rpx_facebook" title="Facebook"></div><div class="rpx_icon rpx_size30 rpx_twitter" title="Twitter"></div></div></div> &nbsp;</div> <div class="rpx_clear"></div>]]></content:encoded>
			<wfw:commentRss>http://jasonkarns.com/blog/load-all-the-rubies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fetch and Iterate</title>
		<link>http://jasonkarns.com/blog/fetch-and-iterate/</link>
		<comments>http://jasonkarns.com/blog/fetch-and-iterate/#comments</comments>
		<pubDate>Wed, 18 Apr 2012 04:33:34 +0000</pubDate>
		<dc:creator>jasonkarns</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[while-loop]]></category>

		<guid isPermaLink="false">http://jasonkarns.com/blog/?p=317</guid>
		<description><![CDATA[Tonight I stumbled across a blog post from the future! Or something like that. On 4/17 at 11:30PM I read a blog post that was published on 4/18 at 1:54. Time zones = time travel. Anyway… It was about finding a cleaner, more succinct, syntax for a standard pattern: fetch_data, process_data, rinse and repeat until [...]]]></description>
			<content:encoded><![CDATA[<p>Tonight I stumbled across a <a href="http://qfox.nl/weblog/248">blog post</a> <em>from the future</em>! Or something like that. On 4/17 at 11:30PM I read a blog post that was published on 4/18 at 1:54. Time zones = time travel. <em>Any</em>way…</p>
<p>It was about finding a cleaner, more succinct, syntax for a standard pattern:    <br />fetch_data, process_data, rinse and repeat until no more data!</p>
<p>Quick, <a href="http://qfox.nl/weblog/248">go read the original post</a>. Don’t worry, it’s short.</p>
<p>{elevator music}</p>
<p>Okay, so how do we improve this? Well, in some languages (like JavaScript, Ruby, PHP, et. al), an assignment expression actually returns a value. And since the expression returns a value, the expression itself can be used as the looping condition, like so:</p>
<pre><code>while(data = fetch()){
  process(data);
}​</code></pre>
<p>Notice the single equals sign? We are doing assignment here, not an equality check. We invoke <var>fetch()</var> and the result is returned and assigned to <var>data</var>. Now the value of <var>data</var> itself is used as the <kbd>while</kbd> condition. So the data is continually fetched and processed until <var>fetch()</var> returns a falsy value. (In JavaScript, that would be one of <kbd>false</kbd>, <kbd>undefined</kbd>, <kbd>null</kbd>, <kbd>0</kbd>, <kbd>&quot;&quot;</kbd>, or <kbd>NaN</kbd>)</p>
<p>This is a very common pattern in PHP, especially when fetching/querying data from a database. It’s a much less common pattern in JavaScript, but still quite valid. As is with most useful things, this approach can be misused. It can easily be confused for a typo (missing an equals sign?) so it should be used with care. For instance, ensuring that your <var>fetch()</var> function and <var>data</var> variable are named clearly should make it less likely to be misunderstood. When used appropriately, it can certainly increase the clarity of your code.</p>
<p><iframe style="width: 100%; height: 300px" src="http://jsfiddle.net/jasonkarns/Je4Mc/embedded/js,result" frameborder="0" allowfullscreen="allowfullscreen"></iframe></p>
<div class="rpxsocial"><div class="rpxsharebutton" onclick="rpxWPsocial('Share:','Tonight I stumbled across a blog post from the future! Or something like that. On 4/17 at 11:30PM I read a blog post that was pu...','http://jasonkarns.com/blog/fetch-and-iterate/','Fetch and Iterate','Shared Fetch and Iterate','','317', this);"><div class="rpx_share_label">&nbsp;</div><div class="rpx_social_icons"><div class="rpx_icon rpx_size30 rpx_facebook" title="Facebook"></div><div class="rpx_icon rpx_size30 rpx_twitter" title="Twitter"></div></div></div> &nbsp;</div> <div class="rpx_clear"></div>]]></content:encoded>
			<wfw:commentRss>http://jasonkarns.com/blog/fetch-and-iterate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ANSI color in Windows shells</title>
		<link>http://jasonkarns.com/blog/ansi-color-in-windows-shells/</link>
		<comments>http://jasonkarns.com/blog/ansi-color-in-windows-shells/#comments</comments>
		<pubDate>Wed, 04 Apr 2012 02:36:00 +0000</pubDate>
		<dc:creator>jasonkarns</dc:creator>
				<category><![CDATA[shell]]></category>
		<category><![CDATA[ansicolor]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[mingw]]></category>

		<guid isPermaLink="false">http://jasonkarns.com/blog/?p=306</guid>
		<description><![CDATA[Having used git on windows for over three years now, I&#8217;ve fallen back in love with the command line. Bash, of course, not the windows command prompt. Beautiful, ubiquitous, warty bash. Git depends heavily on GNU utilities so on Windows it requires either cygwin or msys. Having been burned by cygwin in the past, I [...]]]></description>
			<content:encoded><![CDATA[<p>Having used git on windows for over three years now, I&#8217;ve fallen back in love with the command line. Bash, of course, not the windows command prompt. Beautiful, ubiquitous, warty bash. Git depends heavily on GNU utilities so on Windows it requires either cygwin or msys. Having been burned by cygwin in the past, I prefer the minimalism and simplicity of msys + mingw. Along with git, the entire ruby ecosystem lives in the shell. However, the numerous tools, gems and utilities that assume standard ANSI color support in the shell began to wear on me. Lo and behold, there is a lovely solution to provide ansi color support for bash (and cmd) on Windows: <a href="https://github.com/adoxa/ansicon">ansicon</a>.</p>
<p><a href="https://github.com/adoxa/ansicon/downloads">Download the zip</a> and extract. There are a few ways to install:</p>
<ol>
<li>Extract to a permanent location (I use <var>C:/bin/ansicon</var>). Execute <kbd>ansicon.exe -i</kbd> from within the appropriate directory for your system (x86/x64), and you&#8217;re all set. Any new shells (bash and windows cmd included) will autorun the ansicon utility for displaying color output. Be sure not to move the executable prior to running <kbd>ansicon.exe –u</kbd>. This removes the registry entry and prevents an ugly error message for every command shell.</li>
<li>Alternatively, place the ansicon executable in your <kbd>PATH</kbd>, or add its location to your <kbd>PATH</kbd>. Then you can launch ansicon for a session with <kbd>ansicon.exe –p</kbd>.</li>
</ol>
<p>This utility has been working great for my on Windows XP. I&#8217;ve been having trouble getting it to work on Windows 7, but I hear it should be supported. I&#8217;ll post an update when the Windows 7 issue is resolved.</p>
<h4 id="update_20120410T0245">Update</h4>
<p>Root cause, <a href="https://github.com/adoxa/ansicon/issues/28#issuecomment-4968769">uncovered</a>! If you use JRuby with a 64-bit JVM on Windows x64, ansicon won&#8217;t work. The issue is that ansicon (64-bit) is capable of injecting into 32-bit processes, but not vice versa. Currently, the JRuby launcher is a 32-bit executable. Thus, if you&#8217;re running a 64-bit shell (cmd, bash, or otherwise), ansicon will inject correctly into that process. It will then inject successfully into the 32-bit JRuby launcher process. At this point, for all intents and purposes, you&#8217;re running the 32-bit version of ansicon. Thus, if you&#8217;re running JRuby on a 64-bit JVM, then 32-bit ansicon is not able to inject into 64-bit JVM. There is an <a href="https://jira.codehaus.org/browse/JRUBY-6586">open feature request for JRuby</a> to ship its 64-bit version with a 64-bit launcher. You should vote for this feature. I also hear that <a href="https://github.com/adoxa">adoxa</a> (Jason Hood) has a potential fix for this issue in the works. Stay posted.</p>
<p>Of course, the easiest solution at the moment is to ensure that JRuby uses a 32-bit JVM. Just change (or set) your <kbd>JAVA_HOME</kbd> environment variable to point to a 32-bit JVM and you&#8217;re golden.</p>
<h4 id="update_20120416T2314">Update 2: Issue Resolved</h4>
<p>The <a href="https://github.com/adoxa/ansicon/downloads">latest 64-bit binaries</a> (<a href="(https://github.com/downloads/adoxa/ansicon/ansi6432.zip">ansi6432.zip</a>) have fixed the issue. Just download and extract them over-top the 1.51 version.<br />
<img src="http://jasonkarns.com/blog/wp-content/uploads/2012/04/color-300x159.png" alt="" title="Windows x64 MINGW Bash with ANSI color with ansicon" width="300" height="159" class="alignnone size-medium wp-image-315" /></p>
<div class="rpxsocial"><div class="rpxsharebutton" onclick="rpxWPsocial('Share:','Having used git on windows for over three years now, I&#8217;ve fallen back in love with the command line. Bash, of course, not ...','http://jasonkarns.com/blog/ansi-color-in-windows-shells/','ANSI color in Windows shells','Shared ANSI color in Windows shells','','306', this);"><div class="rpx_share_label">&nbsp;</div><div class="rpx_social_icons"><div class="rpx_icon rpx_size30 rpx_facebook" title="Facebook"></div><div class="rpx_icon rpx_size30 rpx_twitter" title="Twitter"></div></div></div> &nbsp;</div> <div class="rpx_clear"></div>]]></content:encoded>
			<wfw:commentRss>http://jasonkarns.com/blog/ansi-color-in-windows-shells/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Subdirectory Checkouts with git sparse-checkout</title>
		<link>http://jasonkarns.com/blog/subdirectory-checkouts-with-git-sparse-checkout/</link>
		<comments>http://jasonkarns.com/blog/subdirectory-checkouts-with-git-sparse-checkout/#comments</comments>
		<pubDate>Tue, 15 Nov 2011 22:17:20 +0000</pubDate>
		<dc:creator>jasonkarns</dc:creator>
				<category><![CDATA[git]]></category>
		<category><![CDATA[read-tree]]></category>
		<category><![CDATA[sparse-checkout]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://jasonkarns.com/blog/?p=297</guid>
		<description><![CDATA[If there is one thing I miss about SVN having switched to git (and trust me, it’s the only thing), it is the ability to checkout only a sub-tree of a repository. As of version 1.7, you can check out just a sub-tree in git as well! Now not only does git support checking out [...]]]></description>
			<content:encoded><![CDATA[<p>If there is one thing I miss about SVN having switched to git (and trust me, it’s the only thing), it is the ability to checkout only a sub-tree of a repository. As of version 1.7, you can check out just a sub-tree in git as well! Now not only does git support checking out sub-directories, it does it better than subversion!</p>
<h2>New Repository</h2>
<p>There is a bit of a catch-22 when doing a sub-tree checkout for a new repository. In order to only checkout a sub-tree, you’ll need to have the <kbd>core.sparsecheckout</kbd> option set to <kbd>true</kbd>. Of course, you need to have a git repository before you can enable sparse-checkout. So, rather than doing a <kbd>git clone</kbd>, you’ll need to start with <kbd>git init</kbd>.</p>
<ol>
<li>
<p>Create and initialize your new repository:</p>
<pre class="shell">mkdir &lt;repo&gt; &amp;&amp; cd &lt;repo&gt;
git init
git remote add –f &lt;name&gt; &lt;url&gt;</pre>
</li>
<li>
<p>Enable sparse-checkout:</p>
<pre class="shell">git config core.sparsecheckout true</pre>
</li>
<li>
<p>Configure sparse-checkout by listing your desired sub-trees in <kbd>.git/info/sparse-checkout</kbd>: </p>
<pre class="shell">echo some/dir/ &gt;&gt; .git/info/sparse-checkout
echo another/sub/tree &gt;&gt; .git/info/sparse-checkout</pre>
</li>
<li>
<p>Checkout from the remote:</p>
<pre class="shell">git pull &lt;remote&gt; &lt;branch&gt;</pre>
</li>
</ol>
<h2>Existing Repository</h2>
<p>If you already have a repository, simply enable and configure sparse-checkout as above and do <kbd>git read-tree</kbd>.</p>
<ol>
<li>
<p>Enable sparse-checkout:</p>
<pre class="shell">git config core.sparsecheckout true</pre>
</li>
<li>
<p>Configure sparse-checkout by listing your desired sub-trees in <kbd>.git/info/sparse-checkout</kbd>: </p>
<pre class="shell">echo some/dir/ &gt;&gt; .git/info/sparse-checkout
echo another/sub/tree &gt;&gt; .git/info/sparse-checkout</pre>
</li>
<li>
<p>Update your working tree:</p>
<pre class="shell">git read-tree -mu HEAD</pre>
</li>
</ol>
<h2>Modifying sparse-checkout sub-trees</h2>
<p>If you later decide to change which directories you would like checked out, simply edit the sparse-checkout file and run <kbd>git read-tree</kbd> again as above.</p>
<p>Be sure to read the <a href="http://schacon.github.com/git/git-read-tree.html#_sparse_checkout">documentation on read-tree/sparse-checkout</a>. The sparse-tree file accepts file patterns similar to .gitignore. It also accepts negations—enabling you to specify certain directories or files to <strong>not</strong> checkout.</p>
<p>Now there isn’t <em>anything</em> that svn does better than git!</p>
<div class="rpxsocial"><div class="rpxsharebutton" onclick="rpxWPsocial('Share:','If there is one thing I miss about SVN having switched to git (and trust me, it’s the only thing), it is the ability to checko...','http://jasonkarns.com/blog/subdirectory-checkouts-with-git-sparse-checkout/','Subdirectory Checkouts with git sparse-checkout','Shared Subdirectory Checkouts with git sparse-checkout','','297', this);"><div class="rpx_share_label">&nbsp;</div><div class="rpx_social_icons"><div class="rpx_icon rpx_size30 rpx_facebook" title="Facebook"></div><div class="rpx_icon rpx_size30 rpx_twitter" title="Twitter"></div></div></div> &nbsp;</div> <div class="rpx_clear"></div>]]></content:encoded>
			<wfw:commentRss>http://jasonkarns.com/blog/subdirectory-checkouts-with-git-sparse-checkout/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JRuby on MSYS &#124; MinGW</title>
		<link>http://jasonkarns.com/blog/jruby-on-msys-mingw/</link>
		<comments>http://jasonkarns.com/blog/jruby-on-msys-mingw/#comments</comments>
		<pubDate>Tue, 05 Jul 2011 19:14:35 +0000</pubDate>
		<dc:creator>jasonkarns</dc:creator>
				<category><![CDATA[jruby]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[mingw]]></category>
		<category><![CDATA[msys]]></category>

		<guid isPermaLink="false">http://jasonkarns.com/blog/?p=266</guid>
		<description><![CDATA[For many Windows users, like myself, the easiest way to get up and running with Ruby is to install JRuby. If you&#8217;re like me, then you may also be a Git user. Now this is just a hunch, but I would wager that if you&#8217;re a git user and interested in ruby, then there is [...]]]></description>
			<content:encoded><![CDATA[<p>For many Windows users, like myself, the easiest way to get up and running with Ruby is to install JRuby. If you&#8217;re like me, then you may also be a Git user. Now this is just a hunch, but I would wager that if you&#8217;re a git user and interested in ruby, then there is a high probability that you&#8217;re also a fan of proper *nix shells. If all of the above hold true, keep reading.</p>
<p>As a Windows user without access to a proper command line shell (and too tired of fighting with cygwin), I was delighted to have a bash shell at my command after installing msysgit. The subsystem beneath msysgit is MSYS | MinGW. According to their site, MinGW (&#8220;Minimalistic GNU for Windows&#8221;) is a collection of freely available and freely distributable Windows specific header files and import libraries combined with GNU toolsets that allow one to produce native Windows programs that do not rely on any 3rd-party C runtime DLLs.[<a href="http://www.mingw.org/wiki/MinGW">1</a>] In addition to MinGW, MSYS is a collection of GNU utilities such as bash, make, gawk and grep to allow building of applications and programs which depend on traditionally UNIX tools to be present. It is intended to supplement MinGW and the deficiencies of the cmd shell. [<a href="http://www.mingw.org/wiki/MSYS">2</a>] In simplest terms, MSYS | MinGW is a lightweight Cygwin. It is &#8216;lightweight&#8217; because it doesn&#8217;t provide *nix system calls or a POSIX emulation layer. However, if you&#8217;re looking for the standard *nix toolsets on Windows, MSYS | MinGW is a great utility.</p>
<h2>NoClassDefFoundError: org/jruby/Main</h2>
<p>With MinGW installed along with msysgit, I&#8217;ve returned to the bash shell as my primary shell on Windows. However, because MinGW is not quite *nix, nor is it really Windows, the standard JRuby installation doesn&#8217;t work out of the box. After running the JRuby installer, you pop open a bash shell and run <kbd>jruby -v</kbd> to verify the jruby/ruby version. Or you try to run <kbd>irb</kbd> or <kbd>jirb</kbd> to get a ruby console. Or you try to install a gem via <kbd>gem install</kbd>. Up pops an giant error:</p>
<pre>Exception in thread "main" java.lang.NoClassDefFoundError: org/jruby/Main
Caused by: java.lang.ClassNotFoundException: org.jruby.Main
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: org.jruby.Main.  Program will exit.</pre>
<h2>Of Shells and Executables</h2>
<p>So what&#8217;s the problem? The JRuby installer for Windows includes quite a bit of stuff in the bin directory. First and foremost is jruby.exe. This is the real executable for Windows. You&#8217;ll also see jruby.bat. This is just a wrapper which calls jruby.exe. (I assume this is an backwards-compatibility artifact from before the jruby.exe launcher existed.) You&#8217;ll also notice an extension-less jruby shell script. When you execute any of these jruby commands (<kbd>jruby</kbd>, <kbd>irb</kbd>, <kbd>jirb</kbd>, <kbd>gem</kbd>, etc) from a Windows command prompt, it will fire off jruby.exe or jruby.bat because those are the file extensions it is configured to look for. However, the MinGW bash shell prefers the jruby shell script and executes that first. Near the top of this shell script, you&#8217;ll find a block of code that determines the OS the shell is running under.</p>
<pre class="shell"># ----- Identify OS we are running under ---------------
case "`uname`" in
  CYGWIN*) cygwin=true;;
  Darwin) darwin=true;;
esac</pre>
<p>The shell script assumes we&#8217;re either *nix, CYGWIN or Darwin (Mac). This is understandable as the Windows Command Prompt will not attempt to execute this script. However, now that we&#8217;re using a proper bash shell with MinGW, we need to tell JRuby to expect MinGW.</p>
<h2>The Fix(es)</h2>
<p>The simplest fix is to delete the shell script. This way, when MinGW searches for an executable, the first it finds is jruby.exe. Alternatively, you can add the following line to the case statement in the jruby script:</p>
<pre class="shell">MINGW*) jruby.exe "$@"; exit $?;;</pre>
<p>This line simply checks if running on MinGW and, if so, executes jruby.exe passing along any parameters. The shell script returns with the same exit code as jruby.exe. Now the case statement should look like:</p>
<pre class="shell"># ----- Identify OS we are running under ---------------
case "`uname`" in
  CYGWIN*) cygwin=true;;
  Darwin) darwin=true;;
  MINGW*) jruby.exe "$@"; exit $?;;
esac</pre>
<h2>OSS and GitHub to the Rescue</h2>
<p>Thanks to JRuby being an Open Source project, and GitHub for having awesome collaboration tools, <a href="https://github.com/jasonkarns/jruby/commit/8766f84b774ae5ae68204931bd4eab61b81a2056">this patch</a> was <a href="https://github.com/jruby/jruby/pull/37">submitted</a> and <a href="https://github.com/jruby/jruby/pull/42#commits-ref-eed8778">accepted</a> to <a href="https://github.com/jruby/jruby">the JRuby project on GitHub</a>. Future installations of JRuby should work on MinGW out of the box.</p>
<div class="rpxsocial"><div class="rpxsharebutton" onclick="rpxWPsocial('Share:','For many Windows users, like myself, the easiest way to get up and running with Ruby is to install JRuby. If you&#8217;re like m...','http://jasonkarns.com/blog/jruby-on-msys-mingw/','JRuby on MSYS | MinGW','Shared JRuby on MSYS | MinGW','','266', this);"><div class="rpx_share_label">&nbsp;</div><div class="rpx_social_icons"><div class="rpx_icon rpx_size30 rpx_facebook" title="Facebook"></div><div class="rpx_icon rpx_size30 rpx_twitter" title="Twitter"></div></div></div> &nbsp;</div> <div class="rpx_clear"></div>]]></content:encoded>
			<wfw:commentRss>http://jasonkarns.com/blog/jruby-on-msys-mingw/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubiquity in Firefox 5</title>
		<link>http://jasonkarns.com/blog/ubiquity-in-firefox-5/</link>
		<comments>http://jasonkarns.com/blog/ubiquity-in-firefox-5/#comments</comments>
		<pubDate>Thu, 30 Jun 2011 17:08:59 +0000</pubDate>
		<dc:creator>jasonkarns</dc:creator>
				<category><![CDATA[ubiquity]]></category>
		<category><![CDATA[firefox]]></category>

		<guid isPermaLink="false">http://jasonkarns.com/blog/?p=261</guid>
		<description><![CDATA[As may be clear by my ubiquitycommands github repository, I am an avid Ubiquity user. So much so, in fact, that I delayed upgrading to Firefox 5 until I was able to find a version of Ubiquity that works with Firefox 5. Wonder of wonders, I have found that version. Satyr Murky continues to work [...]]]></description>
			<content:encoded><![CDATA[<p>As may be clear by <a href="https://github.com/jasonkarns/ubiquitycommands">my ubiquitycommands github repository</a>, I am an avid Ubiquity user. So much so, in fact, that I delayed upgrading to Firefox 5 until I was able to find a version of Ubiquity that works with Firefox 5. Wonder of wonders, I have found that version.</p>
<p>Satyr Murky continues to work on a <a href="https://bitbucket.org/satyr/ubiquity">community-maintained fork</a> of the <a href="http://mozillalabs.com/ubiquity">original Mozilla.org version</a> of Ubiquity. Luckily for us, it works in Firefox 5.</p>
<p>Thank you, <a href="https://bitbucket.org/satyr">Satyr</a>!</p>
<p>Download: <a href="https://bitbucket.org/satyr/ubiquity/downloads">Ubiquity</a> (<a href="https://bitbucket.org/satyr/ubiquity/downloads/tip.xpi">tip.xpi</a>)</p>
<div class="rpxsocial"><div class="rpxsharebutton" onclick="rpxWPsocial('Share:','As may be clear by my ubiquitycommands github repository, I am an avid Ubiquity user. So much so, in fact, that I delayed upgrad...','http://jasonkarns.com/blog/ubiquity-in-firefox-5/','Ubiquity in Firefox 5','Shared Ubiquity in Firefox 5','','261', this);"><div class="rpx_share_label">&nbsp;</div><div class="rpx_social_icons"><div class="rpx_icon rpx_size30 rpx_facebook" title="Facebook"></div><div class="rpx_icon rpx_size30 rpx_twitter" title="Twitter"></div></div></div> &nbsp;</div> <div class="rpx_clear"></div>]]></content:encoded>
			<wfw:commentRss>http://jasonkarns.com/blog/ubiquity-in-firefox-5/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Test Your Transformations</title>
		<link>http://jasonkarns.com/blog/test-your-transformations/</link>
		<comments>http://jasonkarns.com/blog/test-your-transformations/#comments</comments>
		<pubDate>Tue, 28 Jun 2011 01:19:09 +0000</pubDate>
		<dc:creator>jasonkarns</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[transforms]]></category>
		<category><![CDATA[web.config]]></category>

		<guid isPermaLink="false">http://jasonkarns.com/blog/?p=241</guid>
		<description><![CDATA[Web.config transforms are a really great tool for setting up environment-specific configuration files. However, the transform syntax can be a bit obscure, and tracking down configuration bugs is just painful. For this, there is a great testing tool hosted on AppHarbor. Paste in your web.config contents in one box, drop in your transform in another [...]]]></description>
			<content:encoded><![CDATA[<p>Web.config transforms are a really great tool for setting up environment-specific configuration files. However, the transform syntax can be a bit obscure, and tracking down configuration bugs is just painful.</p>
<p>For this, there is a <a href="http://webconfigtransformationtester.apphb.com/">great testing tool hosted on AppHarbor</a>. Paste in your web.config contents in one box, drop in your transform in another and out comes the transformed web.config. Never waste time messing with your web.config transforms again!</p>
<p><img src="http://jasonkarns.com/blog/wp-content/uploads/2011/06/webconfig.png" alt="screenshot of the web.config transform tester service" title="Web.config Transform Tester" width="524" height="550" class="alignnone size-full wp-image-251" /></p>
<div class="rpxsocial"><div class="rpxsharebutton" onclick="rpxWPsocial('Share:','Web.config transforms are a really great tool for setting up environment-specific configuration files. However, the transform sy...','http://jasonkarns.com/blog/test-your-transformations/','Test Your Transformations','Shared Test Your Transformations','','241', this);"><div class="rpx_share_label">&nbsp;</div><div class="rpx_social_icons"><div class="rpx_icon rpx_size30 rpx_facebook" title="Facebook"></div><div class="rpx_icon rpx_size30 rpx_twitter" title="Twitter"></div></div></div> &nbsp;</div> <div class="rpx_clear"></div>]]></content:encoded>
			<wfw:commentRss>http://jasonkarns.com/blog/test-your-transformations/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Google Calendar &gt; Lotus Notes</title>
		<link>http://jasonkarns.com/blog/google-calendar-lotus-notes/</link>
		<comments>http://jasonkarns.com/blog/google-calendar-lotus-notes/#comments</comments>
		<pubDate>Mon, 20 Jun 2011 12:00:53 +0000</pubDate>
		<dc:creator>jasonkarns</dc:creator>
				<category><![CDATA[productivity]]></category>
		<category><![CDATA[calendar]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[lotusnotes]]></category>

		<guid isPermaLink="false">http://jasonkarns.com/blog/?p=211</guid>
		<description><![CDATA[Are you forced to use Lotus Notes at work? Do you prefer Google Calendar? Would you like to have your Lotus Notes calendar synced to your Google calendar? Solution: CalSync! CalSync is a great little utility that runs in the background and automatically syncs your Lotus Notes calendar with Google Calendar. You can download it [...]]]></description>
			<content:encoded><![CDATA[<p>Are you forced to use Lotus Notes at work? Do you prefer Google Calendar? Would you like to have your Lotus Notes calendar synced to your Google calendar? Solution: CalSync!</p>
<p>CalSync is a great little utility that runs in the background and automatically syncs your Lotus Notes calendar with Google Calendar. You can <a href="http://sourceforge.net/projects/lntogoogle/">download it from SourceForge</a>. It&#8217;s a standalone application that doesn&#8217;t require installation. Simply extract the zip file into a directory of your choosing and open the executable. You&#8217;ll need to provide you Lotus Notes account information, as well as your Google account information. (I recommend using Google&#8217;s 2-factor authentication and setting up an application-specific password for CalSync.)</p>
<p><img src="http://jasonkarns.com/blog/wp-content/uploads/2011/06/calsync-account-300x245.png" alt="screenshot of calsync account info dialog" title="CalSync Account Info" width="300" height="245" class="alignnone size-medium wp-image-229" /></p>
<p>After providing your account information, you can configure how you would like it to sync with Google Calendar. Personally, I recommend creating a new Google Calendar that is dedicated to syncing with your Lotus Notes calendar.</p>
<p><img src="http://jasonkarns.com/blog/wp-content/uploads/2011/06/calsync-acct_options-243x300.png" alt="screenshot of calsync account options dialog" title="CalSync Account Options" width="243" height="300" class="alignnone size-medium wp-image-230" /></p>
<p>There are plenty of additional configuration options to customize how/when your calendar items are synced. And, of course, to have it start with windows, simply add a shortcut to CalSync to your Startup folder. Now you can get your Lotus Notes work calendar on your smartphone via Google!</p>
<div class="rpxsocial"><div class="rpxsharebutton" onclick="rpxWPsocial('Share:','Are you forced to use Lotus Notes at work? Do you prefer Google Calendar? Would you like to have your Lotus Notes calendar synce...','http://jasonkarns.com/blog/google-calendar-lotus-notes/','Google Calendar > Lotus Notes','Shared Google Calendar > Lotus Notes','','211', this);"><div class="rpx_share_label">&nbsp;</div><div class="rpx_social_icons"><div class="rpx_icon rpx_size30 rpx_facebook" title="Facebook"></div><div class="rpx_icon rpx_size30 rpx_twitter" title="Twitter"></div></div></div> &nbsp;</div> <div class="rpx_clear"></div>]]></content:encoded>
			<wfw:commentRss>http://jasonkarns.com/blog/google-calendar-lotus-notes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Userscripts, Userstyles and Ubiquity</title>
		<link>http://jasonkarns.com/blog/userscripts-userstyles-and-ubiquity/</link>
		<comments>http://jasonkarns.com/blog/userscripts-userstyles-and-ubiquity/#comments</comments>
		<pubDate>Thu, 16 Jun 2011 23:45:57 +0000</pubDate>
		<dc:creator>jasonkarns</dc:creator>
				<category><![CDATA[ubiquity]]></category>
		<category><![CDATA[userscripts]]></category>
		<category><![CDATA[userstyles]]></category>

		<guid isPermaLink="false">http://jasonkarns.com/blog/?p=214</guid>
		<description><![CDATA[A while ago I described how to merge two git repositories into one. I discovered how to do this as I was attempting to consolidate a number of git repositories that I have on GitHub. Previously, I had a separate git repository for each user script, user style and ubiquity command that I&#8217;ve written. It [...]]]></description>
			<content:encoded><![CDATA[<p>A while ago I described how to <a href="http://jasonkarns.com/blog/merge-two-git-repositories-into-one/">merge two git repositories into one</a>. I discovered how to do this as I was attempting to consolidate a number of git repositories that I have on GitHub. Previously, I had a separate git repository for each user script, user style and ubiquity command that I&#8217;ve written. It was getting unmanageable so I decided to create a single git repository for my <a href="https://github.com/jasonkarns/userscripts">user scripts</a>, another for my <a href="https://github.com/jasonkarns/userstyles">user styles</a>, and a third for my <a href="https://github.com/jasonkarns/ubiquitycommands">ubiquity commands</a>. You can now find my them all on GitHub.</p>
<h3>Userscripts</h3>
<p>[<a href="https://github.com/jasonkarns/userscripts">GitHub repository</a>]</p>
<dl>
<dt><a href="https://github.com/jasonkarns/userscripts/tree/master/tweetapaper">Tweetapaper</a></dt>
<dd>adds &#8216;Tweet&#8217; links to articles in your Instapaper queue. [<a href="http://userscripts.org/scripts/show/93786">install from Userscripts.org</a>]</dd>
<dt><a href="https://github.com/jasonkarns/userscripts/tree/master/instasubmit">Instasubmit</a></dt>
<dd>auto-submits the Instapaper Add form when loaded via Google Reader&#8217;s Send To Instapaper action. [<a href="http://userscripts.org/scripts/show/98861">install from Userscripts.org</a>]</dd>
<dt><a href="https://github.com/jasonkarns/userscripts/tree/master/radapaper">Radapaper</a></dt>
<dd>adds &#8216;Radbox&#8217; links to articles in your Instapaper queue. [<a href="http://userscripts.org/scripts/show/98864">install from Userscripts.org</a>]</dd>
<dt><a href="https://github.com/jasonkarns/userscripts/tree/master/treasurydirect_login">TreasuryDirect Login</a></dt>
<dd>makes the password field editable so that you can use the keyboard to log in. [<a href="http://userscripts.org/scripts/show/98865">install from Userscripts.org</a>]</dd>
</dl>
<h3>Userstyles</h3>
<p>[<a href="https://github.com/jasonkarns/userstyles">GitHub repository</a>]</p>
<dl>
<dt><a href="https://github.com/jasonkarns/userstyles/tree/master/gmail_smime_icons">Gmail &#8211; Icons for S/Mime Messages</a></dt>
<dd>adds icons to messages in Gmail which have been digitally signed or encrypted using S/MIME. [<a href="http://userstyles.org/styles/14323">install from Userscripts.org</a>]</dd>
<dt><a href="https://github.com/jasonkarns/userstyles/tree/master/tab_notifier">Tab Notifier</a></dt>
<dd>highlights any open Gmail, Google Reader, Google Voice, and Facebook tab when there are unread items. [<a href="http://userstyles.org/styles/14571">install from Userscripts.org</a>]</dd>
</dl>
<h3>Ubiquity Commands</h3>
<p>[<a href="https://github.com/jasonkarns/ubiquitycommands">GitHub repository</a>]</p>
<dl>
<dt><a href="https://github.com/jasonkarns/ubiquitycommands/tree/master/claimid">ClaimID</a></dt>
<dd>easily claim URLs under your ClaimID account. [<a href="http://jasonkarns.github.com/ubiquitycommands/claimid/">install from GitHub</a>]</dd>
<dt><a href="https://github.com/jasonkarns/ubiquitycommands/tree/master/wishlistr">Wishlistr</a></dt>
<dd>easily add items to a Wishlistr wishlist. [<a href="http://jasonkarns.github.com/ubiquitycommands/wishlistr/">install from GitHub</a>]</dd>
</dl>
<div class="rpxsocial"><div class="rpxsharebutton" onclick="rpxWPsocial('Share:','A while ago I described how to merge two git repositories into one. I discovered how to do this as I was attempting to consolida...','http://jasonkarns.com/blog/userscripts-userstyles-and-ubiquity/','Userscripts, Userstyles and Ubiquity','Shared Userscripts, Userstyles and Ubiquity','','214', this);"><div class="rpx_share_label">&nbsp;</div><div class="rpx_social_icons"><div class="rpx_icon rpx_size30 rpx_facebook" title="Facebook"></div><div class="rpx_icon rpx_size30 rpx_twitter" title="Twitter"></div></div></div> &nbsp;</div> <div class="rpx_clear"></div>]]></content:encoded>
			<wfw:commentRss>http://jasonkarns.com/blog/userscripts-userstyles-and-ubiquity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Merge Two Git Repositories Into One</title>
		<link>http://jasonkarns.com/blog/merge-two-git-repositories-into-one/</link>
		<comments>http://jasonkarns.com/blog/merge-two-git-repositories-into-one/#comments</comments>
		<pubDate>Thu, 24 Mar 2011 01:14:27 +0000</pubDate>
		<dc:creator>jasonkarns</dc:creator>
				<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://jasonkarns.com/blog/?p=174</guid>
		<description><![CDATA[A few weeks ago I tweeted: &#8220;Just did 2 subtree merges in order to combine 2 partially-related git repos into a single repo and still maintain history. #gitrocks&#8221; Wanna learn how to do it? Here we go&#8230; TL;DR # create new project as the parent $ mkdir new_parent_project $ cd new_parent_project $ git init $ [...]]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago I <a href="https://twitter.com/jasonkarns/status/45888163079663616">tweeted</a>: &#8220;Just did 2 subtree merges in order to combine 2 partially-related git repos into a single repo and still maintain history. #gitrocks&#8221; Wanna learn how to do it? Here we go&#8230;</p>
<h2>TL;DR</h2>
<pre class="sh"><code># create new project as the parent
$ mkdir new_parent_project
$ cd new_parent_project
$ git init
$ touch .gitignore
$ git ci -am "initial commit"

# merge project A into subdirectory A
$ git remote add -f projA /path/to/projA
$ git merge -s ours --no-commit projA/master
$ git read-tree --prefix=subdirA/ -u projA/master
$ git ci -m "merging projA into subdirA"

# merge project B into subdirectory B
$ git remote add -f projB /path/to/projB
$ git merge -s ours --no-commit projB/master
$ git read-tree --prefix=subdirB/ -u projB/master
$ git ci -m "merging projB into subdirB"
</code></pre>
<p>The most common use case for sub-tree merges, that I&#8217;m aware of, is to merge another git repository into a subdirectory in an existing repository. There are quite a few tutorials which cover these steps. In fact, the second two sets of commands above do exactly that. However, I discovered that in order to merge two repositories into a new repository, the new repository must already have a prior commit in it. Otherwise, the sub-tree merges will not work as planned. So, as in the first set of commands above, be sure to create at least one initial commit prior to doing the sub-tree merges. It can be as trivial as committing an empty file. But without it, the merges will not work correctly. Armed with this knowledge, you can follow the <a href="http://help.github.com/subtree-merge">tutorial</a> on GitHub on merging sub-trees. Or you can follow along with me here.</p>
<h3>Create Parent Repo</h3>
<p>First, create a new, empty project to act as the parent project for our two existing repositories.</p>
<pre class="sh"><code>Jason@BRUTUS ~/dev
$ mkdir parent

Jason@BRUTUS ~/dev
$ cd parent/

Jason@BRUTUS ~/dev/parent
$ git init
Initialized empty Git repository in ~/dev/parent/.git/
</code></pre>
<p>Now we need to create the initial commit. This is essential.</p>
<pre class="sh"><code>Jason@BRUTUS ~/dev/parent (master #)
$ touch .gitignore

Jason@BRUTUS ~/dev/parent (master #)
$ git ci -am "initial commit"
[master (root-commit) fc6f5ad] initial commit
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 .gitignore
</code></pre>
<h3>Merge Project A Into Subdirectory</h3>
<p>Next, we add a remote to the first project we&#8217;d like to import. We&#8217;ll give the remote a name (<var>projectA</var>) and pass the <kbd>-f</kbd> option so that it will fetch the contents of this remote immediately.</p>
<pre class="sh"><code>Jason@BRUTUS ~/dev/parent (master)
$ git remote add -f projectA /path/to/projectA
Updating projectA
warning: no common commits
remote: Counting objects: 16, done.
remote: Compressing objects: 100% (16/16), done.
remote: Total 16 (delta 7), reused 0 (delta 0)
Unpacking objects: 100% (16/16), done.
From /path/to/projectA
 * [new branch]      master     -> projectA/master
</code></pre>
<p>Now, let&#8217;s run a merge but not commit the result (<kbd>--no-commit</kbd> flag). We also need to specify the merge strategy <var>ours</var> with the <kbd>-s</kbd> switch.</p>
<pre class="sh"><code>Jason@BRUTUS ~/dev/parent (master)
$ git merge -s ours --no-commit projectA/master
Automatic merge went well; stopped before committing as requested
</code></pre>
<p>Now that we are in merging mode, we&#8217;ll read in the tree from the remote, taking care to provide a subdirectory into which the subproject will go. This is specified with with <kbd>--prefix</kbd> switch. Also, add the <kbd>-u</kbd> flag to update the working tree with our changes.</p>
<pre class="sh"><code>Jason@BRUTUS ~/dev/parent (master|MERGING)
$ git read-tree --prefix=projA/ -u projectA/master
</code></pre>
<p>The remote has been merged into its own subdirectory and the changes have been staged. Now we can simply commit them.</p>
<pre class="sh"><code>Jason@BRUTUS ~/dev/parent (master +|MERGING)
$ git ci -m "merging project A into subdirectory"
[master 4d2d50d] merging project A into subdirectory
</code></pre>
<h3>Merge Project B Into Subdirectory</h3>
<p>At this point, we have Project A merged into its own subdirectory within our new parent project. Merging in Project B uses the same simple steps as above.</p>
<pre class="sh"><code>Jason@BRUTUS ~/dev/parent (master)
$ git remote add -f projectB /path/to/projectB
Updating projectB
warning: no common commits
remote: Counting objects: 47, done.
remote: Compressing objects: 100% (47/47), done.
remote: Total 47 (delta 23), reused 0 (delta 0)
Unpacking objects: 100% (47/47), done.
From /path/to/projectB
 * [new branch]      master     -> projectB/master

Jason@BRUTUS ~/dev/parent (master)
$ git merge -s ours --no-commit projectB/master
Automatic merge went well; stopped before committing as requested

Jason@BRUTUS ~/dev/parent (master|MERGING)
$ git read-tree --prefix=projB/ -u projectB/master

Jason@BRUTUS ~/dev/parent (master +|MERGING)
$ git ci -m "merging project B into subdirectory"
[master 8f41792] merging project B into subdirectory
</code></pre>
<h3>Pulling In Updates</h3>
<p>If the original repositories (Projects A and B in this example) continue to live on elsewhere as separate projects, you can easily pull in updates to your new parent repo. Using the sub-tree merge strategy, the updates will be applied properly to the applicable subdirectory.</p>
<pre class="sh"><code>Jason@BRUTUS ~/dev/parent (master)
$ git pull -s subtree projectA master
</code></pre>
<p>However, if you no longer have any need for the original repositories, they can be deleted and the remotes in your new parent project can safely be removed.</p>
<p>Below is a screenshot of a repository after two sub-tree merges. The repositories that I merged were two separate userstyles: one for using tab color for notifications (gtab) and another for adding S/MIME icons to gmail&#8217;s inbox (gmail). Each of these two projects have their own history that was maintained after the merge. Now they are each in their own subdirectory in a common <em>userstyles</em> git repository. As you can see, the two projects each have their own lines of development that do not include any common ancestry until the merge point.</p>
<p><a href="http://jasonkarns.com/blog/wp-content/uploads/2011/03/merging.png"><img src="http://jasonkarns.com/blog/wp-content/uploads/2011/03/merging.png" alt="" title="GitK After Subtree Merge" width="545" height="331" class="alignnone size-full wp-image-187" /></a></p>
<div class="rpxsocial"><div class="rpxsharebutton" onclick="rpxWPsocial('Share:','A few weeks ago I tweeted: &#8220;Just did 2 subtree merges in order to combine 2 partially-related git repos into a single repo...','http://jasonkarns.com/blog/merge-two-git-repositories-into-one/','Merge Two Git Repositories Into One','Shared Merge Two Git Repositories Into One','','174', this);"><div class="rpx_share_label">&nbsp;</div><div class="rpx_social_icons"><div class="rpx_icon rpx_size30 rpx_facebook" title="Facebook"></div><div class="rpx_icon rpx_size30 rpx_twitter" title="Twitter"></div></div></div> &nbsp;</div> <div class="rpx_clear"></div>]]></content:encoded>
			<wfw:commentRss>http://jasonkarns.com/blog/merge-two-git-repositories-into-one/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

