<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>I am a ruby on rails developer at oneforty. This is where I post useful coding/unix snippets. I also have a blog for larger thoughts about software development and startup life.</description><title>freerobby's snippets</title><generator>Tumblr (3.0; @freerobby)</generator><link>http://snippets.freerobby.com/</link><item><title>Vendor Gems Quickly</title><description>&lt;p&gt;Here&amp;#8217;s a bash function to vendor gems in your Rails app.&lt;/p&gt;
&lt;p&gt;Usage:&lt;/p&gt;
&lt;pre&gt;vg &amp;lt;gem name&amp;gt; [gem version]&lt;/pre&gt;
&lt;p&gt;This will install the gem in your ./vendor/gems directory, without installing documentation or dependencies. The version can be specific (i.e. 2.4.3) or minimal (i.e. &amp;#8220;&amp;gt;= 2.4&amp;#8221;).&lt;/p&gt;
&lt;p&gt;Add the following to your ~/.profile:&lt;/p&gt;
&lt;pre&gt;function vg {
  if [ -z "$1" ]; then
    echo "Usage: vg  [gem version]"
  fi
  opts="--install-dir=vendor/gems --no-rdoc --no-ri --ignore-dependencies"
  if [ -n "$2" ]; then
    opts="--version $2 $opts"
  fi
  gem install $1 $opts
}&lt;/pre&gt;</description><link>http://snippets.freerobby.com/post/500893855</link><guid>http://snippets.freerobby.com/post/500893855</guid><pubDate>Tue, 06 Apr 2010 11:43:42 -0400</pubDate><category>bash</category><category>ruby</category><category>gems</category></item><item><title>Remove merged branches in git</title><description>&lt;p&gt;Here&amp;#8217;s a bash function to help you keep your git repository clean.&lt;/p&gt;
&lt;p&gt;It removes all branches, local and remote, that have been merged into your current branch. Simply run &amp;#8220;rmb&amp;#8221; from the command line. Don&amp;#8217;t worry - prompt safeguards are in place to show you what you&amp;#8217;ll be removing before you commit to deleting anything. And it won&amp;#8217;t let you delete &amp;#8220;master.&amp;#8221; :-)&lt;/p&gt;
&lt;p&gt;Add this to your ~/.profile, run &amp;#8220;source ~/.profile&amp;#8221; and you&amp;#8217;re good to go.&lt;/p&gt;
&lt;pre&gt;function rmb {&lt;br/&gt;  current_branch=$(git branch --no-color 2&amp;gt; /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')&lt;br/&gt;  if [ "$current_branch" != "master" ]; then&lt;br/&gt;    echo "WARNING: You are on branch $current_branch, NOT master."&lt;br/&gt;  fi&lt;br/&gt;    echo "Fetching merged branches..."&lt;br/&gt;  git remote prune origin&lt;br/&gt;  remote_branches=$(git branch -r --merged | grep -v '/master$' | grep -v "/$current_branch$")&lt;br/&gt;  local_branches=$(git branch --merged | grep -v 'master$' | grep -v "$current_branch$")&lt;br/&gt;  if [ -z "$remote_branches" ] &amp;amp;&amp;amp; [ -z "$local_branches" ]; then&lt;br/&gt;    echo "No existing branches have been merged into $current_branch."&lt;br/&gt;  else&lt;br/&gt;    echo "This will remove the following branches:"&lt;br/&gt;    if [ -n "$remote_branches" ]; then&lt;br/&gt;      echo "$remote_branches"&lt;br/&gt;    fi&lt;br/&gt;    if [ -n "$local_branches" ]; then&lt;br/&gt;      echo "$local_branches"&lt;br/&gt;    fi&lt;br/&gt;    read -p "Continue? (y/n): " -n 1 choice&lt;br/&gt;    echo&lt;br/&gt;    if [ "$choice" == "y" ] || [ "$choice" == "Y" ]; then&lt;br/&gt;      # Remove remote branches&lt;br/&gt;      git push origin `git branch -r --merged | grep -v '/master$' | grep -v "/$current_branch$" | sed 's/origin\//:/g' | tr -d '\n'`&lt;br/&gt;      # Remove local branches&lt;br/&gt;      git branch -d `git branch --merged | grep -v 'master$' | grep -v "$current_branch$" | sed 's/origin\///g' | tr -d '\n'`&lt;br/&gt;    else&lt;br/&gt;      echo "No branches removed."&lt;br/&gt;    fi&lt;br/&gt;  fi&lt;br/&gt;}&lt;/pre&gt;</description><link>http://snippets.freerobby.com/post/491644841</link><guid>http://snippets.freerobby.com/post/491644841</guid><pubDate>Fri, 02 Apr 2010 15:15:00 -0400</pubDate><category>git</category><category>unix</category><category>bash</category></item></channel></rss>

