<?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>CommitBlog</title>
	<atom:link href="http://blog.laaz.org/tech/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.laaz.org/tech</link>
	<description>Programming, technology and IT-survival</description>
	<lastBuildDate>Tue, 23 Apr 2013 09:56:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>GIT merge-svn</title>
		<link>http://blog.laaz.org/tech/2013/04/23/git-merge-svn/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://blog.laaz.org/tech/2013/04/23/git-merge-svn/#comments</comments>
		<pubDate>Tue, 23 Apr 2013 09:52:28 +0000</pubDate>
		<dc:creator>Laas</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rest of the World]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[git-svn]]></category>
		<category><![CDATA[merge]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://blog.laaz.org/tech/?p=616</guid>
		<description><![CDATA[How to use GIT to merge two SVN branches TL;DR: Download the git-merge-svn script here I&#8217;ve been using git for years now but had to start using SVN for some projects. I found that GIT is good enough Subversion client &#8230;<p class="read-more"><a href="http://blog.laaz.org/tech/2013/04/23/git-merge-svn/">Read more &#187;</a></p>
Related posts:<ol>
<li><a href='http://blog.laaz.org/tech/2010/08/23/git-reset-merge/' rel='bookmark' title='Git reset &#8211;merge'>Git reset &#8211;merge</a></li>
<li><a href='http://blog.laaz.org/tech/2011/08/10/inkscape-csv-merge/' rel='bookmark' title='Inkscape CSV merge'>Inkscape CSV merge</a></li>
<li><a href='http://blog.laaz.org/tech/2012/12/17/rails-3-merge-scopes/' rel='bookmark' title='Rails 3: Merge scopes'>Rails 3: Merge scopes</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<h1>How to use GIT to merge two SVN branches</h1>
<p>TL;DR: <a href="https://gist.github.com/borgand/5441827">Download the <strong>git-merge-svn</strong> script here</a></p>
<p>I&#8217;ve been using git for years now but had to start using SVN for some projects. I found that GIT is good enough Subversion client too, especially as I retain the ability to commit often and rebase my work on top of commits from other devs (on the SVN side).</p>
<p>The only question arose &#8211; <strong>can I merge two SVN branches so that GIT log will show the merge?</strong></p>
<p>The <a href="https://www.kernel.org/pub/software/scm/git/docs/git-svn.html">git-svn manual</a> states that one should avoid all <code>git clone|merge|pull|push</code> activity when using <code>git-svn</code>.</p>
<p>But <code>git log</code> does show merge history that was created in Subversion &#8211; how does it do that?</p>
<h2>svn:mergeinfo</h2>
<p>Subversion does not support actual merge of branches (more like <em>cherry-picking</em>), but since version 1.5 Subversion supports the <a href="http://www.open.collab.net/community/subversion/articles/merge-info.html">svn:mergeinfo property</a> that is used to track what has been merged into this folder previously.</p>
<p>Digging some more into the matter, I found out that GIT supports setting <code>svn:mergeinfo</code> property on the SVN branch when <code>dcommit</code>&#8216;ing:</p>
<pre><code>git svn dcommit --mergeinfo "/branches/somebranch:1-3"
</code></pre>
<p><strong>NB!</strong> the <code>svn:mergeinfo</code> is <strong>overwritten</strong> with whatever is given on the command-line, so be careful to list <em>previous merges too</em>.</p>
<p>While more recent git version added the config parameter to automatically set this property:</p>
<pre><code>config key: svn.pushmergeinfo
</code></pre>
<p>I had some troubles with the automatic mergeinfo &#8211; for one reason or the other GIT calculated it wrong and I couldn&#8217;t get it to work.</p>
<h2>SOLUTION: git-merge-svn</h2>
<p>To automate the process, I wrote a shell script <code>git merge-svn</code> which can be used to merge two SVN branches with correct <code>svn:mergeinfo</code> set on the dcommit.</p>
<p>The script handles both situations:</p>
<ul>
<li>the branch is not merged in git &#8211; will do <code>git merge</code> beforehand</li>
<li>the branches have been already merged in git (but not in SVN) &#8211; will traverse until previous ancestor for the merged commit revisions.</li>
</ul>
<p><strong><a href="https://gist.github.com/borgand/5441827">Download the git-merge-svn script here</a></strong></p>
<h2>Example usage</h2>
<p>With this script I was able to produce these merges solely on git-side and retain the merge info so that GIT graph shows the log nicely:</p>
<p><img src="http://i.stack.imgur.com/uXa2u.png" alt="git-merge-svn result" /></p>
<ol>
<li>Make some commits on <em>devel6</em></li>
<li><code>dcommit</code> <em>devel6</em> to SVN (<strong>required</strong> to get SVN revision numbers for the commits)</li>
<li>check out <em>testtunk6</em> &#8211; yes, I know I made a typo in the name <img src='http://blog.laaz.org/tech/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </li>
<li><code>git merge-svn devel6</code></li>
</ol>
<p>The last commant outputs:</p>
<pre><code>% git merge-svn devel6
About to do an SVN merge: devel6 -&gt; testtunk6

* NEW MERGE COMMIT
|\
| * devel6 [7b71187] (r102)
* | testtunk6 [0682a45] (r101)
 \|
  * [273d6d6] (r100)

STEP 1: GIT merge
Executing:
  git merge devel6

Continue? (y/n) [n]: y
Merge made by the 'recursive' strategy.
 testfile | 1 +
 1 file changed, 1 insertion(+)

STEP 2: SVN dcommit

executing:
git svn dcommit --mergeinfo
/idp/branches/devel:9-32,35-41 /idp/branches/devel6:89 /idp/branches/devel6:94 /idp/branches/devel6:93 /idp/branches/devel6:96 /idp/branches/devel6:97 /idp/branches/devel6:99 /idp/branches/devel6:100 /idp/branches/devel6:102

Continue? (y/n) [n]: y
Committing to https://my.svn.host/svn/auth/idp/branches/testtunk6 ...
  M testfile
Committed r103
  M testfile
Found merge parent (svn:mergeinfo prop): 7b71187fc371d3f86658c5850009e63be88157ac
r103 = 87759323cbadd38bac78087d57b6870a926287e7 (refs/remotes/svn/testtunk6)
No changes between 3fb2168cfbbe605fbd810d76513443203a85a549 and refs/remotes/svn/testtunk6
Resetting to the latest refs/remotes/svn/testtunk6
</code></pre>
<p>Related posts:<ol>
<li><a href='http://blog.laaz.org/tech/2010/08/23/git-reset-merge/' rel='bookmark' title='Git reset &#8211;merge'>Git reset &#8211;merge</a></li>
<li><a href='http://blog.laaz.org/tech/2011/08/10/inkscape-csv-merge/' rel='bookmark' title='Inkscape CSV merge'>Inkscape CSV merge</a></li>
<li><a href='http://blog.laaz.org/tech/2012/12/17/rails-3-merge-scopes/' rel='bookmark' title='Rails 3: Merge scopes'>Rails 3: Merge scopes</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.laaz.org/tech/2013/04/23/git-merge-svn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Safari New Window</title>
		<link>http://blog.laaz.org/tech/2013/03/21/safari-new-window/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://blog.laaz.org/tech/2013/03/21/safari-new-window/#comments</comments>
		<pubDate>Thu, 21 Mar 2013 11:51:37 +0000</pubDate>
		<dc:creator>Laas</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.laaz.org/tech/?p=591</guid>
		<description><![CDATA[Previously I have written AppleScripts to open new windows for TextMate, Sublime Text 2 and also Safari. But the latter was somehow corrupt when using with Mac OS X 10.8.3, so I rewrote it based on previous two, adding features &#8230;<p class="read-more"><a href="http://blog.laaz.org/tech/2013/03/21/safari-new-window/">Read more &#187;</a></p>
Related posts:<ol>
<li><a href='http://blog.laaz.org/tech/2010/11/27/bettertouchtool-and-safari/' rel='bookmark' title='BetterTouchTool and Safari'>BetterTouchTool and Safari</a></li>
<li><a href='http://blog.laaz.org/tech/2012/06/25/sublime-text-2-new-window-via-applescript/' rel='bookmark' title='Sublime Text 2 New Window (via AppleScript)'>Sublime Text 2 New Window (via AppleScript)</a></li>
<li><a href='http://blog.laaz.org/tech/2012/03/01/textmate-2-new-window-via-applescript/' rel='bookmark' title='TextMate 2 New Window (via AppleScript)'>TextMate 2 New Window (via AppleScript)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.laaz.org/tech/wp-content/uploads/2013/03/safari_new_window_icon-300x300.png" alt="Safari New Window icon" title="Safari New Window" width="200" height="200" class="alignright size-medium wp-image-599" /></p>
<p>Previously I have written AppleScripts to open new windows for <a href="http://blog.laaz.org/tech/2012/03/01/textmate-2-new-window-via-applescript#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">TextMate</a>, <a href="http://blog.laaz.org/tech/2012/06/25/sublime-text-2-new-window-via-applescript#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">Sublime Text 2</a> and also <a href="http://blog.laaz.org/tech/2010/11/27/bettertouchtool-and-safari/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">Safari</a>. But the latter was somehow corrupt when using with Mac OS X 10.8.3, so I rewrote it based on previous two, adding features in the process:</p>
<ol>
<li>Checks if Safari is already running and creates new window (<em>without switching spaces</em>)</li>
<li>Activates Safari if it&#8217;s not running yet.</li>
</ol>
<p>The full source code is here:</p>
<pre><code>-- quickly check if app is running.
-- Thanks https://discussions.apple.com/message/13184433#13184433
on appIsRunning(appName)
    tell application "System Events" to (name of processes) contains appName
end appIsRunning

property appName : "Safari"

-- Open new windows or If app is not already running, start it
if appIsRunning(appName) then
    tell application appName
        make new document
        activate
    end tell
else
    tell application appName to activate
end if
</code></pre>
<p>Go a head and download the updated script here:</p>
<p> </p>
<p><style type="text/css">a.maxbutton-3 { text-decoration: none; color: #ffffff; font-family: Arial; font-size: 14px; font-style: normal; font-weight: bold; padding-top: 15px; padding-right: 25px; padding-bottom: 15px; padding-left: 25px; background-color: #98ba40; background: linear-gradient(#98ba40 45%, #618926); background: -moz-linear-gradient(#98ba40 45%, #618926); background: -o-linear-gradient(#98ba40 45%, #618926); background: -webkit-gradient(linear, left top, left bottom, color-stop(.45, #98ba40), color-stop(1, #618926)); border-style: solid; border-width: 1px; border-color: #618926; border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px; text-shadow: -1px -1px 0px #618926; box-shadow: 0px 0px 2px #333333; -pie-background: linear-gradient(#98ba40 45%, #618926); position: relative; behavior: url("http://blog.laaz.org/tech/wp-content/plugins/maxbuttons/pie/PIE.htc"); } a.maxbutton-3:visited { text-decoration: none; color: #ffffff; } a.maxbutton-3:hover { text-decoration: none; color: #ffffff; background-color: #2270df; background: linear-gradient(#2270df 45%, #12295d); background: -moz-linear-gradient(#2270df 45%, #12295d); background: -o-linear-gradient(#2270df 45%, #12295d); background: -webkit-gradient(linear, left top, left bottom, color-stop(.45, #2270df), color-stop(1, #12295d)); border-color: #0f2557; text-shadow: -1px -1px 0px #12295d; box-shadow: 0px 0px 2px #333333; -pie-background: linear-gradient(#2270df 45%, #12295d); position: relative; behavior: url("http://blog.laaz.org/tech/wp-content/plugins/maxbuttons/pie/PIE.htc"); }</style><a class="maxbutton-3" href="http://blog.laaz.org/tech/wp-content/uploads/2012/06/Safari-New-Window.zip"  >Download Safari New Window</a>  </p>
<p> </p>
<p>Related posts:<ol>
<li><a href='http://blog.laaz.org/tech/2010/11/27/bettertouchtool-and-safari/' rel='bookmark' title='BetterTouchTool and Safari'>BetterTouchTool and Safari</a></li>
<li><a href='http://blog.laaz.org/tech/2012/06/25/sublime-text-2-new-window-via-applescript/' rel='bookmark' title='Sublime Text 2 New Window (via AppleScript)'>Sublime Text 2 New Window (via AppleScript)</a></li>
<li><a href='http://blog.laaz.org/tech/2012/03/01/textmate-2-new-window-via-applescript/' rel='bookmark' title='TextMate 2 New Window (via AppleScript)'>TextMate 2 New Window (via AppleScript)</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.laaz.org/tech/2013/03/21/safari-new-window/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails redirect_back_or_default</title>
		<link>http://blog.laaz.org/tech/2012/12/27/rails-redirect_back_or_default/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://blog.laaz.org/tech/2012/12/27/rails-redirect_back_or_default/#comments</comments>
		<pubDate>Thu, 27 Dec 2012 13:57:13 +0000</pubDate>
		<dc:creator>Laas</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.laaz.org/tech/?p=576</guid>
		<description><![CDATA[In a recent project I found myself writing recirect_to :back alot, and then found myself worrying that what if for some reason there is no :back. Drawing inspiration from this blog, I wrote two helpers in my application_controller.rb. The store_location &#8230;<p class="read-more"><a href="http://blog.laaz.org/tech/2012/12/27/rails-redirect_back_or_default/">Read more &#187;</a></p>
Related posts:<ol>
<li><a href='http://blog.laaz.org/tech/2012/12/17/rails-3-merge-scopes/' rel='bookmark' title='Rails 3: Merge scopes'>Rails 3: Merge scopes</a></li>
<li><a href='http://blog.laaz.org/tech/2012/04/02/ruby-on-rails-toolchest-for-windows-users/' rel='bookmark' title='Ruby (on Rails) toolchest for Windows users'>Ruby (on Rails) toolchest for Windows users</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>In a recent project I found myself writing <code>recirect_to :back</code> alot, and then found myself worrying that what if for some reason there is no <code>:back</code>.</p>
<p>Drawing inspiration from <a href="http://joshsharpe.com/archives/redirect-back-or-default-youre-probably-doing-it-wrong">this blog</a>, I wrote two helpers in my <code>application_controller.rb</code>.</p>
<p>The <strong>store_location</strong> stores current URI (or referer URI in case of non-GET request) into <code>session[:return_to]</code> for later usage:</p>
<pre class="brush: ruby; notranslate">def store_location
  session[:return_to] = if request.get?
    request.request_uri
  else
    request.referer
  end
end
</pre>
<p>And <strong>redirect&#95;back&#95;or_default</strong> tries its best to redirect the user to somewhere, in the following order:</p>
<ol>
<li>previously stored <code>session[:return_to]</code></li>
<li>Referer URI</li>
<li>Given default URI</li>
<li>or <code>root_url</code> if all else fails</li>
</ol>
<p>The code itself</p>
<pre class="brush: ruby; notranslate">def redirect_back_or_default(default = root_url, options)
  redirect_to(session.delete(:return_to) || request.referer || default, options)
end
</pre>
<p>I&#8217;ve found that when rewriting <code>redirect_to :back, notice: 'something'</code> into <code>redirect_back_or_default</code>-call, adding this alias helps:</p>
<pre class="brush: ruby; notranslate">alias_method :redirect_to_back_or_default, :redirect_back_or_default
</pre>
<p>But of course, if you are testing your code (and you should be), it&#8217;s better to stick to one variant of above and use tests to catch all erroneous incarnations.</p>
<p>Related posts:<ol>
<li><a href='http://blog.laaz.org/tech/2012/12/17/rails-3-merge-scopes/' rel='bookmark' title='Rails 3: Merge scopes'>Rails 3: Merge scopes</a></li>
<li><a href='http://blog.laaz.org/tech/2012/04/02/ruby-on-rails-toolchest-for-windows-users/' rel='bookmark' title='Ruby (on Rails) toolchest for Windows users'>Ruby (on Rails) toolchest for Windows users</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.laaz.org/tech/2012/12/27/rails-redirect_back_or_default/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails 3: Merge scopes</title>
		<link>http://blog.laaz.org/tech/2012/12/17/rails-3-merge-scopes/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://blog.laaz.org/tech/2012/12/17/rails-3-merge-scopes/#comments</comments>
		<pubDate>Mon, 17 Dec 2012 20:22:28 +0000</pubDate>
		<dc:creator>Laas</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.laaz.org/tech/?p=565</guid>
		<description><![CDATA[I run into a case where I had User.search method and I wanted the GroupMember model be searchable by the user&#8217;s attributes. The most DRY way to accomplish this in Rails 3 is to merge scopes. In the User model: &#8230;<p class="read-more"><a href="http://blog.laaz.org/tech/2012/12/17/rails-3-merge-scopes/">Read more &#187;</a></p>
Related posts:<ol>
<li><a href='http://blog.laaz.org/tech/2010/08/23/git-reset-merge/' rel='bookmark' title='Git reset &#8211;merge'>Git reset &#8211;merge</a></li>
<li><a href='http://blog.laaz.org/tech/2013/04/23/git-merge-svn/' rel='bookmark' title='GIT merge-svn'>GIT merge-svn</a></li>
<li><a href='http://blog.laaz.org/tech/2012/12/27/rails-redirect_back_or_default/' rel='bookmark' title='Rails redirect_back_or_default'>Rails redirect_back_or_default</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I run into a case where I had <code>User.search</code> method and I wanted the <code>GroupMember</code> model be searchable by the user&#8217;s attributes. The most DRY way to accomplish this in Rails 3 is to <strong>merge scopes.</strong> In the User model:</p>
<pre class="brush: ruby; notranslate"># user.rb
class User &lt; ActiveRecord::Base
  has_many :memberships, :class_name =&gt; "GroupMember", :foreign_key =&gt; "user_id"

  def self.search(search)
    if search.present?
      query = []
      params = []
      %w(uid email name).each do |field|
        # The field name must be fully qualified to merge scopes
        query &lt;&lt; "#{self.table_name}.#{field} LIKE ?"
        params &lt;&lt; "%#{search}%"
      end
      query = query.join(" OR ")
      where(query, *params)
    else
      scoped
    end
  end
end
</pre>
<p><strong>NB!</strong> It&#8217;s important to have the User&#8217;s field names fully qualified so that they won&#8217;t be applied to the GroupMember table. And in the GroupMember model:</p>
<pre class="brush: ruby; notranslate"># group_member.rb
class GroupMember &lt; ActiveRecord::Base
  belongs_to :user
  belongs_to :group

  def self.search(search)
    if search.present?
      # We search GroupMembers by the user attributes
      scoped.joins(:user).merge(User.search(search))
    else
      scoped
    end
  end
end
</pre>
<p>Now it&#8217;s possible to search for GroupMembers by the User attributes:</p>
<pre class="brush: ruby; notranslate">group = Group.find 1
group.group_members.search('david')
</pre>
<p>This results in SQL query:</p>
<pre class="brush: sql; notranslate">SELECT "group_members".* FROM "group_members" INNER JOIN "users"
ON "users"."id" = "group_members"."user_id" WHERE "group_members"."group_id" = 1
AND (users.uid LIKE '%david%' OR users.email LIKE '%david%'
OR users.name LIKE '%david%')
</pre>
<p>Related posts:<ol>
<li><a href='http://blog.laaz.org/tech/2010/08/23/git-reset-merge/' rel='bookmark' title='Git reset &#8211;merge'>Git reset &#8211;merge</a></li>
<li><a href='http://blog.laaz.org/tech/2013/04/23/git-merge-svn/' rel='bookmark' title='GIT merge-svn'>GIT merge-svn</a></li>
<li><a href='http://blog.laaz.org/tech/2012/12/27/rails-redirect_back_or_default/' rel='bookmark' title='Rails redirect_back_or_default'>Rails redirect_back_or_default</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.laaz.org/tech/2012/12/17/rails-3-merge-scopes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sublime Text 2 New Window (via AppleScript)</title>
		<link>http://blog.laaz.org/tech/2012/06/25/sublime-text-2-new-window-via-applescript/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://blog.laaz.org/tech/2012/06/25/sublime-text-2-new-window-via-applescript/#comments</comments>
		<pubDate>Mon, 25 Jun 2012 13:31:16 +0000</pubDate>
		<dc:creator>Laas</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[Sublime Text 2]]></category>

		<guid isPermaLink="false">http://blog.laaz.org/tech/?p=543</guid>
		<description><![CDATA[Building upon my older post on opening new window in Text Mate 2, I now threw together small script to do the same in Sublime Text 2. While Sublime Text 2 is superb text editor, it is not Mac native, &#8230;<p class="read-more"><a href="http://blog.laaz.org/tech/2012/06/25/sublime-text-2-new-window-via-applescript/">Read more &#187;</a></p>
Related posts:<ol>
<li><a href='http://blog.laaz.org/tech/2012/03/01/textmate-2-new-window-via-applescript/' rel='bookmark' title='TextMate 2 New Window (via AppleScript)'>TextMate 2 New Window (via AppleScript)</a></li>
<li><a href='http://blog.laaz.org/tech/2013/03/21/safari-new-window/' rel='bookmark' title='Safari New Window'>Safari New Window</a></li>
<li><a href='http://blog.laaz.org/tech/2012/05/15/mount-partitions-like-a-boss-applescript/' rel='bookmark' title='Mount partitions like a boss (AppleScript)'>Mount partitions like a boss (AppleScript)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.laaz.org/tech/wp-content/uploads/2012/06/Sublime-Text-2-New-Window.png#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed"><img class="alignright size-medium wp-image-544" title="Sublime Text 2 New Window" src="http://blog.laaz.org/tech/wp-content/uploads/2012/06/Sublime-Text-2-New-Window-300x300.png" alt="" width="180" height="180" /></a>Building upon my older post on <a href="http://blog.laaz.org/tech/2012/03/01/textmate-2-new-window-via-applescript/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed" target="_blank">opening new window in Text Mate 2</a>, I now threw together small script to do the same in <a href="http://www.sublimetext.com/2" target="_blank">Sublime Text 2</a>.</p>
<p>While Sublime Text 2 is superb text editor, it is not Mac native, thus it&#8217;s even less probable that a new Mac-style Dock icon menu will appear in near future, that allows opening new window quickly. Thus a helper application is in order.</p>
<h1>SublNewWindow</h1>
<p>Based on the original TMNewWindow code, only small modifications were needed. One unexpected behavior was with detecting working state of the application. For whatever reason the original script gave errors when run against Sublime Text 2.</p>
<p><a href="http://blog.laaz.org/tech/wp-content/uploads/2012/06/SublNewWindow-screenshot.png#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed"><img class="alignnone size-medium wp-image-545" title="SublNewWindow screenshot" src="http://blog.laaz.org/tech/wp-content/uploads/2012/06/SublNewWindow-screenshot-300x76.png" alt="" width="300" height="76" /></a></p>
<p>Again, the AppleScript application is linked below and feel free to send me updates and patches if needed.</p>
<p>&nbsp;<br />
<style type="text/css">div.maxbutton-2-container { } a.maxbutton-2 { text-decoration: none; color: #ffffff; font-family: Arial; font-size: 16px; font-style: normal; font-weight: bold; padding-top: 15px; padding-right: 25px; padding-bottom: 15px; padding-left: 25px; background-color: #98ba40; background: linear-gradient(#98ba40 45%, #618926); background: -moz-linear-gradient(#98ba40 45%, #618926); background: -o-linear-gradient(#98ba40 45%, #618926); background: -webkit-gradient(linear, left top, left bottom, color-stop(.45, #98ba40), color-stop(1, #618926)); border-style: solid; border-width: 1px; border-color: #618926; border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px; text-shadow: -1px -1px 0px #618926; box-shadow: 0px 0px 2px #333333; -pie-background: linear-gradient(#98ba40 45%, #618926); position: relative; behavior: url("http://blog.laaz.org/tech/wp-content/plugins/maxbuttons/pie/PIE.htc"); } a.maxbutton-2:visited { text-decoration: none; color: #ffffff; } a.maxbutton-2:hover { text-decoration: none; color: #ffffff; background-color: #2270df; background: linear-gradient(#2270df 45%, #12295d); background: -moz-linear-gradient(#2270df 45%, #12295d); background: -o-linear-gradient(#2270df 45%, #12295d); background: -webkit-gradient(linear, left top, left bottom, color-stop(.45, #2270df), color-stop(1, #12295d)); border-color: #0f2557; text-shadow: -1px -1px 0px #12295d; box-shadow: 0px 0px 2px #333333; -pie-background: linear-gradient(#2270df 45%, #12295d); position: relative; behavior: url("http://blog.laaz.org/tech/wp-content/plugins/maxbuttons/pie/PIE.htc"); }</style><div class="maxbutton-2-container"><a class="maxbutton-2" href="http://blog.laaz.org/tech/wp-content/uploads/2012/06/SublNewWindow.zip"  >&#x25BC; Download SublNewWindow</a></div><br />
&nbsp;</p>
<p>Related posts:<ol>
<li><a href='http://blog.laaz.org/tech/2012/03/01/textmate-2-new-window-via-applescript/' rel='bookmark' title='TextMate 2 New Window (via AppleScript)'>TextMate 2 New Window (via AppleScript)</a></li>
<li><a href='http://blog.laaz.org/tech/2013/03/21/safari-new-window/' rel='bookmark' title='Safari New Window'>Safari New Window</a></li>
<li><a href='http://blog.laaz.org/tech/2012/05/15/mount-partitions-like-a-boss-applescript/' rel='bookmark' title='Mount partitions like a boss (AppleScript)'>Mount partitions like a boss (AppleScript)</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.laaz.org/tech/2012/06/25/sublime-text-2-new-window-via-applescript/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>uses of Ruby&#8217;s Object#tap</title>
		<link>http://blog.laaz.org/tech/2012/06/14/uses-of-rubys-object-tap/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://blog.laaz.org/tech/2012/06/14/uses-of-rubys-object-tap/#comments</comments>
		<pubDate>Thu, 14 Jun 2012 18:39:31 +0000</pubDate>
		<dc:creator>Laas</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.laaz.org/tech/?p=534</guid>
		<description><![CDATA[Ruby 1.9&#8242;s Object#tap method has always seemed useful to me, but until now I hadn&#8217;t met the chance to use it. Every other time it seemed like abusing it in some way. Now I came to an old code. Consider &#8230;<p class="read-more"><a href="http://blog.laaz.org/tech/2012/06/14/uses-of-rubys-object-tap/">Read more &#187;</a></p>
No related posts.]]></description>
			<content:encoded><![CDATA[<p>Ruby 1.9&#8242;s <a href="http://ruby-doc.org/core-1.9.3/Object.html#method-i-tap">Object#tap</a> method has always seemed useful to me, but until now I hadn&#8217;t met the chance to use it. Every other time it seemed like abusing it in some way.</p>
<p>Now I came to an old code. Consider this:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="ruby" style="font-family:monospace;">cgi.<span style="color:#9900CC;">text_field</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#996600;">&quot;name&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;myfield&quot;</span>,
                <span style="color:#996600;">&quot;value&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> value,
                <span style="color:#996600;">&quot;size&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">20</span>,
                <span style="color:#996600;">&quot;maxlength&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> maxlength
              <span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p>I needed to turn that <code>maxlength</code> into a conditional attribute (omiting it if it&#8217;s nil).<br />
One way would have been extracting the attributes into a separate variable:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="ruby" style="font-family:monospace;">attrs = <span style="color:#006600; font-weight:bold;">&#123;</span>
          <span style="color:#996600;">&quot;name&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;myfield&quot;</span>,
          <span style="color:#996600;">&quot;value&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> value,
          <span style="color:#996600;">&quot;size&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">20</span>
        <span style="color:#006600; font-weight:bold;">&#125;</span>
attrs<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'maxlength'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = maxlength <span style="color:#9966CC; font-weight:bold;">if</span> maxlength
cgi.<span style="color:#9900CC;">text_field</span><span style="color:#006600; font-weight:bold;">&#40;</span> attrs <span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p>But this separates visually the cgi.text_field() call from it&#8217;s arguments, which I don&#8217;t like. Tap to the resque:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="ruby" style="font-family:monospace;">cgi.<span style="color:#9900CC;">text_field</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#123;</span>  <span style="color:#996600;">&quot;name&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;myfield&quot;</span>,
                  <span style="color:#996600;">&quot;value&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> value,
                  <span style="color:#996600;">&quot;size&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">20</span>
                <span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">tap</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>attrs<span style="color:#006600; font-weight:bold;">|</span> 
                  attrs<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'maxlength'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = maxlength <span style="color:#9966CC; font-weight:bold;">if</span> maxlength
                <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p>Now, isn&#8217;t that nice! (OK, maybe it isn&#8217;t, but at least it is encompassed in the method call and makes it easy to spot all attributes).</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.laaz.org/tech/2012/06/14/uses-of-rubys-object-tap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Restore DBD::MySQL::Database#quote method</title>
		<link>http://blog.laaz.org/tech/2012/05/29/restore-dbd-mysql-quote-method/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://blog.laaz.org/tech/2012/05/29/restore-dbd-mysql-quote-method/#comments</comments>
		<pubDate>Tue, 29 May 2012 15:33:47 +0000</pubDate>
		<dc:creator>Laas</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ruby-dbd-mysql]]></category>
		<category><![CDATA[ruby-dbi]]></category>

		<guid isPermaLink="false">http://blog.laaz.org/tech/?p=532</guid>
		<description><![CDATA[For whatever reason, Ruby DBI and DBD have axed the quote method from their midst, breaking compatibility with previous versions. Sadly I couldn&#8217;t find any clues as to why it was removed (actually, bluntly commented out). Fortunately I was able &#8230;<p class="read-more"><a href="http://blog.laaz.org/tech/2012/05/29/restore-dbd-mysql-quote-method/">Read more &#187;</a></p>
No related posts.]]></description>
			<content:encoded><![CDATA[<p>For whatever reason, Ruby DBI and DBD have axed the <code>quote</code> method from their midst, breaking compatibility with previous versions. Sadly I couldn&#8217;t find any clues as to why it was removed (actually, <a href="https://github.com/raphaelcosta/rails-dbd-mysql/blob/master/lib/dbd/mysql/database.rb#L275">bluntly commented out</a>).</p>
<p>Fortunately I was able to unearth some hints <a href="http://rubyforge.org/forum/message.php?msg_id=67441">how to restore this method</a> and with an added fix to NilClass, the result seems to be working fine:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># For some unknown reason quote method is commented out at:</span>
<span style="color:#008000; font-style:italic;">#   https://github.com/raphaelcosta/rails-dbd-mysql/blob/master/lib/dbd/mysql/database.rb</span>
<span style="color:#008000; font-style:italic;"># </span>
<span style="color:#008000; font-style:italic;"># Restoring it for b/w compliance</span>
<span style="color:#9966CC; font-weight:bold;">module</span> <span style="color:#6666ff; font-weight:bold;">DBI::DBD::Mysql</span>
  <span style="color:#9966CC; font-weight:bold;">class</span> Database <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">DBI::BaseDatabase</span>
    <span style="color:#9966CC; font-weight:bold;">def</span> quote<span style="color:#006600; font-weight:bold;">&#40;</span>value<span style="color:#006600; font-weight:bold;">&#41;</span>
        <span style="color:#9966CC; font-weight:bold;">case</span> value
        <span style="color:#9966CC; font-weight:bold;">when</span> <span style="color:#CC0066; font-weight:bold;">String</span>
          <span style="color:#996600;">&quot;'#{@handle.quote(value)}'&quot;</span>
        <span style="color:#9966CC; font-weight:bold;">when</span> <span style="color:#6666ff; font-weight:bold;">DBI::Binary</span>
          <span style="color:#996600;">&quot;'#{@handle.quote(value.to_s)}'&quot;</span>
        <span style="color:#9966CC; font-weight:bold;">when</span> <span style="color:#CC00FF; font-weight:bold;">TrueClass</span>
          <span style="color:#996600;">&quot;'1'&quot;</span>
        <span style="color:#9966CC; font-weight:bold;">when</span> <span style="color:#CC00FF; font-weight:bold;">FalseClass</span>
          <span style="color:#996600;">&quot;'0'&quot;</span>
        <span style="color:#9966CC; font-weight:bold;">when</span> <span style="color:#CC0066; font-weight:bold;">Array</span>
          value.<span style="color:#9900CC;">collect</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>v<span style="color:#006600; font-weight:bold;">|</span> quote<span style="color:#006600; font-weight:bold;">&#40;</span>v<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;, &quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
        <span style="color:#9966CC; font-weight:bold;">when</span> DBI::<span style="color:#CC00FF; font-weight:bold;">Date</span>, DBI::<span style="color:#CC00FF; font-weight:bold;">Time</span>, <span style="color:#6666ff; font-weight:bold;">DBI::Timestamp</span>, ::<span style="color:#CC00FF; font-weight:bold;">Date</span>
          <span style="color:#996600;">&quot;'#{value.to_s}'&quot;</span>
        <span style="color:#9966CC; font-weight:bold;">when</span> ::<span style="color:#CC00FF; font-weight:bold;">Time</span>
          <span style="color:#996600;">&quot;'#{value.rfc2822}'&quot;</span>
        <span style="color:#9966CC; font-weight:bold;">when</span> <span style="color:#CC00FF; font-weight:bold;">NilClass</span>
          <span style="color:#996600;">&quot;NULL&quot;</span>
        <span style="color:#9966CC; font-weight:bold;">else</span>
          value.<span style="color:#9900CC;">to_s</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>Just place this in some file and require it in your code.</p>
<p>&nbsp;</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.laaz.org/tech/2012/05/29/restore-dbd-mysql-quote-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mount partitions like a boss (AppleScript)</title>
		<link>http://blog.laaz.org/tech/2012/05/15/mount-partitions-like-a-boss-applescript/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://blog.laaz.org/tech/2012/05/15/mount-partitions-like-a-boss-applescript/#comments</comments>
		<pubDate>Tue, 15 May 2012 07:23:45 +0000</pubDate>
		<dc:creator>Laas</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[diskutil]]></category>
		<category><![CDATA[mac os x]]></category>
		<category><![CDATA[mount partition]]></category>

		<guid isPermaLink="false">http://blog.laaz.org/tech/?p=525</guid>
		<description><![CDATA[How to quickly mount partitions when the need arises? A small AppleScript to help you out. The need No good comes without little drawbacks. When I swapped ODD with HDD, I noticed that it was quite a bit noisier than &#8230;<p class="read-more"><a href="http://blog.laaz.org/tech/2012/05/15/mount-partitions-like-a-boss-applescript/">Read more &#187;</a></p>
Related posts:<ol>
<li><a href='http://blog.laaz.org/tech/2012/06/25/sublime-text-2-new-window-via-applescript/' rel='bookmark' title='Sublime Text 2 New Window (via AppleScript)'>Sublime Text 2 New Window (via AppleScript)</a></li>
<li><a href='http://blog.laaz.org/tech/2012/03/01/textmate-2-new-window-via-applescript/' rel='bookmark' title='TextMate 2 New Window (via AppleScript)'>TextMate 2 New Window (via AppleScript)</a></li>
<li><a href='http://blog.laaz.org/tech/2010/04/13/macfusion-workaround/' rel='bookmark' title='MacFUSION workaround'>MacFUSION workaround</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>How to quickly mount partitions when the need arises? A small AppleScript to help you out.</p>
<h2>The need</h2>
<p>No good comes without little drawbacks. When I <a href="http://blog.laaz.org/tech/2012/04/20/macbook-pro-bidrive-or-diy-optical-bay-hdd-caddy/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">swapped ODD with HDD</a>, I noticed that it was quite a bit noisier than SSD and even compared to similar MBP with HDD in original bay (probably because ODD bay has a slot that lets noise out easily). So, now I tend to eject the secondary disk when I don&#8217;t need it, so my Mac can spin it down. All nice and dandy, but reattaching it when needed was a bit tedious.</p>
<h2>The Script</h2>

<div class="wp_syntax"><table><tr><td class="code"><pre class="applescript" style="font-family:monospace;"><span style="color: #ff0033; font-weight: bold;">set</span> partList <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#123;</span><span style="color: #009900;">&quot;Meedia&quot;</span>, <span style="color: #009900;">&quot;BOOTCAMP&quot;</span><span style="color: #000000;">&#125;</span>
<span style="color: #0066ff;">choose <span style="color: #ff0033; font-weight: bold;">from</span> list</span> partList <span style="color: #ff0033; font-weight: bold;">with</span> prompt <span style="color: #009900;">&quot;Choose partitions&quot;</span> <span style="color: #ff0033; font-weight: bold;">with</span> multiple selections allowed
<span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #0066ff;">result</span> <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #ff0033;">not</span> <span style="color: #ff0033;">equal</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">false</span> <span style="color: #ff0033; font-weight: bold;">then</span>
	<span style="color: #ff0033; font-weight: bold;">repeat</span> <span style="color: #ff0033; font-weight: bold;">with</span> part <span style="color: #ff0033; font-weight: bold;">in</span> <span style="color: #0066ff;">result</span>
		<span style="color: #0066ff;">do shell script</span> <span style="color: #009900;">&quot;diskutil mount &quot;</span> <span style="color: #000000;">&amp;</span> part
		<span style="color: #0066ff;">display dialog</span> <span style="color: #009900;">&quot;Volume &quot;</span> <span style="color: #000000;">&amp;</span> part <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; mounted&quot;</span>
	<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span>
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span></pre></td></tr></table></div>

<p>This script asks for which of the partitions to mount and then iterates with diskutil through the selection.</p>
<p><a href="http://blog.laaz.org/tech/wp-content/uploads/2012/05/Mount-Partitions-Dialog.png#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed"><img class="alignnone size-medium wp-image-526" title="Mount Partitions Dialog" src="http://blog.laaz.org/tech/wp-content/uploads/2012/05/Mount-Partitions-Dialog-300x219.png" alt="" width="300" height="219" /></a></p>
<h2>Download</h2>
<p>You can copy-paste the above script to AppleScript Editor and adjust it to your needs, or you can download this as a ready to use application.</p>
<h4><a href="http://blog.laaz.org/tech/wp-content/uploads/2012/05/MountPartitions.zip#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">MountPartitions.zip</a></h4>
<p>&nbsp;</p>
<p>Related posts:<ol>
<li><a href='http://blog.laaz.org/tech/2012/06/25/sublime-text-2-new-window-via-applescript/' rel='bookmark' title='Sublime Text 2 New Window (via AppleScript)'>Sublime Text 2 New Window (via AppleScript)</a></li>
<li><a href='http://blog.laaz.org/tech/2012/03/01/textmate-2-new-window-via-applescript/' rel='bookmark' title='TextMate 2 New Window (via AppleScript)'>TextMate 2 New Window (via AppleScript)</a></li>
<li><a href='http://blog.laaz.org/tech/2010/04/13/macfusion-workaround/' rel='bookmark' title='MacFUSION workaround'>MacFUSION workaround</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.laaz.org/tech/2012/05/15/mount-partitions-like-a-boss-applescript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Windows 7 on MacBook Pro without SuperDrive</title>
		<link>http://blog.laaz.org/tech/2012/04/24/installing-windows-7-on-macbook-pro-without-superdrive/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://blog.laaz.org/tech/2012/04/24/installing-windows-7-on-macbook-pro-without-superdrive/#comments</comments>
		<pubDate>Tue, 24 Apr 2012 21:54:10 +0000</pubDate>
		<dc:creator>Laas</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Boot Camp]]></category>
		<category><![CDATA[SuperDrive]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://blog.laaz.org/tech/?p=513</guid>
		<description><![CDATA[Right after I swapped my SuperDrive to second internal HDD I was graving to move my 20 GB Boot Camp partition to the other drive and make it bigger, so that I don&#8217;t have to carry another USB disk for my &#8230;<p class="read-more"><a href="http://blog.laaz.org/tech/2012/04/24/installing-windows-7-on-macbook-pro-without-superdrive/">Read more &#187;</a></p>
Related posts:<ol>
<li><a href='http://blog.laaz.org/tech/2012/04/02/ruby-on-rails-toolchest-for-windows-users/' rel='bookmark' title='Ruby (on Rails) toolchest for Windows users'>Ruby (on Rails) toolchest for Windows users</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" title="Boot Camp" src="http://images.apple.com/support/assets/images/products/bootcamp/hero_bootcamp.jpg" alt="" width="180" height="180" /></p>
<p>Right after I <a href="http://blog.laaz.org/tech/2012/04/20/macbook-pro-bidrive-or-diy-optical-bay-hdd-caddy/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed" target="_blank">swapped my SuperDrive to second internal HDD</a> I was graving to move my 20 GB Boot Camp partition to the other drive and make it bigger, so that I don&#8217;t have to carry another USB disk for my games.</p>
<p><!-- more --></p>
<p><strong>UPDATE:</strong> From the comments it seems that on Mountain Lion 10.8.2 you do <strong>NEED rEFIt</strong> for the Windows partition to be visible in Boot Menu.</p>
<p><strong>UPDATE 2:</strong> I have confirmed lately that the official Boot Camp Assistant method does work on MacBook Pro Retina (Mid 2012) with OS X 10.8.2 (12C3012) on it. So if your Mac came without SuperDrive from the Factory, try the official method first.</p>
<p><strong>UPDATE 3:</strong> @Jorge_Rui posted <a href="#comment-5074#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">excellent step-by-step instructions down in the comments</a> on how he got it working. Take a look.</p>
<h1>What didn&#8217;t work</h1>
<p>You can skip to Success Story if you are not curious. Also, YMMV, so if my method does not work, you can try one of these and see if you have success with them.</p>
<h2>USB-booting installer</h2>
<div id="attachment_519" class="wp-caption alignnone" style="width: 310px"><br />
<img class="size-medium wp-image-519" title="Boot Camp Assistant" src="http://blog.laaz.org/tech/wp-content/uploads/2012/04/Boot-Camp-Assistant-300x213.png" alt="" width="300" height="213" /><p class="wp-caption-text">Boot Camp Assistant warning that I need optical drive</p></div>
<p>First I tried to <a href="https://discussions.apple.com/message/16840167#16840167" target="_blank">fake Boot Camp Assistant to create bootable USB stick</a>, but that did not boot for some reason. Also, booting from USB-DVD did not work. Then I used Virtual Box to fully install Windows on physical partition and that did not show up in the boot menu either. With all of these options I also combined <a href="http://refit.sourceforge.net/" target="_blank">rEFIt</a> to no avail.</p>
<h2>EFI, rEFIt and File Vault 2</h2>
<p>Intel Macs have been using <a href="http://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface" target="_blank">EFI</a> instead of <a href="http://en.wikipedia.org/wiki/BIOS" target="_blank">BIOS</a> for booting up the system since the beginning. If Boot Camp dual-booting is not enough for you, there is the rEFIt alternative boot manager that gives you more power over boot options. But it turns out that although rEFIt installs without any complaints, it fails to load from <strong>File Vault 2 encrypted</strong> partition, which is understandable as I haven&#8217;t yet provided my passkey.</p>
<p>So, running out of options, I decided to decrypt my partition, which I&#8217;d have had to do anyway sometime to be able to resize the encrypted partition over the previous Boot Camp partition (Disk Utility is not able to resize encrypted partitions). I still had rEFIt installed and I retried some of previous failed attempts, including booting from USB, but still no effect. Finally I noticed that I had actually <strong>two</strong> boot loaders &#8211; Mac&#8217;s own <em>Option</em>-key triggered menu and then the rEFIt that was installed on the primary Mac OS X partition. While most of the time Mac menu didn&#8217;t show me anything besides primary partition and Recovery HD, rEFIt showed me Windows partition (sometimes two of them pointing to the same partition), but was not able to boot from them (giving different errors from EFI failures to Windows complaining that <a href="http://social.technet.microsoft.com/Forums/en-US/itprovistasetup/thread/1b2045b9-7fef-47f0-aea3-1e185fb7544c/" target="_blank">winload.exe is missing or corrupt</a>). In the end I removed rEFIt altogether.</p>
<h1>The Success Story</h1>
<p>OK, enough of the failures. What ended up working was a variant of the <a href="http://www.andrewsavory.com/blog/2011/2156" target="_blank">Virtual Machine method</a>, that used Virtual Box to make the partition bootable and then copy over the installation files to that partition. Unfortunately I can not find the original post that lead me to the idea, but it was probably somewhere in <a href="http://forums.macrumors.com/showthread.php?t=631901&#038;page=5" target="_blank">this thread</a>.</p>
<p><strong>Note:</strong> At this point I had tried multitude of setups already and I can&#8217;t be sure that all of the steps below are necessary nor that all of the required steps are listed. If you find some errors, please comment on them.</p>
<h2>Create partition</h2>
<p>Create a partition in some way. You can use Boot Camp Assistant to shrink existing HFS+ partition and create a FAT32 partition or you can do it yourself via Disk Utility or <code>diskutil</code> command line tool. I had my partition left over from one of the tries with Boot Camp Assistant and USB DVD-drive. Using Boot Camp for this step has the side effect that it gives you the option to download latest Boot Camp drivers for windows (just have a USB stick ready to store them).</p>
<div id="attachment_520" class="wp-caption alignnone" style="width: 310px"><img class="size-medium wp-image-520" title="Boot Camp Assistant Support Software" src="http://blog.laaz.org/tech/wp-content/uploads/2012/04/Boot-Camp-Assistant-Support-Software-300x221.png" alt="" width="300" height="221" /><p class="wp-caption-text">Let Boot Camp Assistant download latest support software</p></div>
<h2>Set up Virtual Box guest</h2>
<p>Now eject your Boot Camp partition so that it can be remounted elewhere. (Thanks, Bill, for <a href="#comment-546#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">pointing out</a> that I had omitted this step). I used Oracle&#8217;s excellent (and free) <a href="https://www.virtualbox.org/" target="_blank">Virtual Box</a> virtualization tool. To get Virtual Box to use your physical Boot Camp partition, you have to make a raw disk image that is bound to your physical disk. In my case it was the <code>disk1</code> and I partition number 3 (<code>disk1s3</code> as seen from Disk Utility&#8217;s Info). To create the image, change directory to some good enough place to hold the file and enter (<strong>NB!</strong> adapt to your needs):</p>
<pre class="brush: bash; notranslate">sudo VBoxManage internalcommands createrawvmdk -rawdisk /dev/disk1 -filename bootcamp.vmdk -partitions 3
</pre>
<p>Next, give yourself access to the physical disk and the just created image files:</p>
<pre class="brush: bash; notranslate">sudo chmod 777 /dev/disk1s3
sudo chown $USER bootcamp*.vmdk
</pre>
<p>Last thing is to actually set up Virtual Box Guest OS. There is nothing special there, except that you specify your * bootcamp.vmdk* as the startup disk, instead of creating new one.</p>
<h2>Installing Windows</h2>
<p>Install Windows to the Virtual Box guest as usual. I shut down the Virtual Box client at the &#8220;<em>Setting up Windows for first use</em>&#8221; step, but according to some posts (links to which I again have misplaced), you could stop even at the first reboot, though it didn&#8217;t seem to work in my case.</p>
<p>Now you should have a <strong>partition</strong> that is visible to the Mac Boot menu, but not a working Windows installation.</p>
<p>Next step is to restart the install, only this time on the real hardware. To accomplish this, mount the Boot Camp partition, <em>delete everything and copy over all files from the installer ISO</em>. NB! You probably need to have some kind of NTFS driver, either <a href="http://www.tuxera.com/community/ntfs-3g-download/" target="_blank">NTFS-3G</a> (see my blog on <a href="http:///tech/2011/07/23/macfuse-and-mac-os-x-lion/">how to get NTFS-3g working in Lion</a>) or some commercial driver like the <a href="http://www.paragon-software.com/home/ntfs-mac/">Paragon NTFS for Mac OS X</a> I have installed.</p>
<p>After you copy over the files, reboot your Mac and hold down <em>Option</em>-key to access the Windows partition. Now install windows as you would if you had with optical disk attached.</p>
<h1>Conclusion</h1>
<p>Now that I have finally managed to jump through all those hoops to get Windows installed, I can only wish that Virtualization advances enough that I could play those old Call of Duty games without even rebooting into Windows. Until then, I hope to preserve my newly installed Windows. <img src='http://blog.laaz.org/tech/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Related posts:<ol>
<li><a href='http://blog.laaz.org/tech/2012/04/02/ruby-on-rails-toolchest-for-windows-users/' rel='bookmark' title='Ruby (on Rails) toolchest for Windows users'>Ruby (on Rails) toolchest for Windows users</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.laaz.org/tech/2012/04/24/installing-windows-7-on-macbook-pro-without-superdrive/feed/</wfw:commentRss>
		<slash:comments>69</slash:comments>
		</item>
		<item>
		<title>MacBook Pro bidrive or DIY optical bay HDD Caddy</title>
		<link>http://blog.laaz.org/tech/2012/04/20/macbook-pro-bidrive-or-diy-optical-bay-hdd-caddy/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://blog.laaz.org/tech/2012/04/20/macbook-pro-bidrive-or-diy-optical-bay-hdd-caddy/#comments</comments>
		<pubDate>Fri, 20 Apr 2012 07:35:04 +0000</pubDate>
		<dc:creator>Laas</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[hdd odd]]></category>
		<category><![CDATA[macbook pro]]></category>
		<category><![CDATA[optibay]]></category>

		<guid isPermaLink="false">http://blog.laaz.org/tech/?p=493</guid>
		<description><![CDATA[If you ever run out of disk space on your laptop you might have wondered if you could replace your Optical Disc Drive which you rarely use anymore with another HDD. Turns out that of course you can and there &#8230;<p class="read-more"><a href="http://blog.laaz.org/tech/2012/04/20/macbook-pro-bidrive-or-diy-optical-bay-hdd-caddy/">Read more &#187;</a></p>
Related posts:<ol>
<li><a href='http://blog.laaz.org/tech/2012/04/24/installing-windows-7-on-macbook-pro-without-superdrive/' rel='bookmark' title='Installing Windows 7 on MacBook Pro without SuperDrive'>Installing Windows 7 on MacBook Pro without SuperDrive</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="wp-caption alignright" style="width: 260px"><img class=" " title="OptiBay" src="http://www.mcetech.com/images/obreversewdrive090601.jpg" alt="" width="250" height="176" /><p class="wp-caption-text">OptiBay</p></div>
<p>If you ever run out of disk space on your laptop you might have wondered if you could replace your Optical Disc Drive which you rarely use anymore with another HDD. Turns out that of course you can and there are plenty of manufacturers out there who sell kits to do that. One of the most famous in Mac community is the <a href="http://www.mcetech.com/optibay/">MCE Technologies OptiBay</a> pictured right.</p>
<p>But I live in Estonia and of course I wanted it NOW, so I went out for a little adventure to see if I can fit one of those <em>el cheapo</em> <a href="http://www.akasa.co.uk/update.php?tpl=product/product.detail.tpl&amp;no=181&amp;type=Enclosures&amp;type_sub=2.5%20Enclosure&amp;model=AK-OA2SSA-BK">Akasa N.Stor HDD to ODD cases</a> found in local PC store.</p>
<p>For the imatient: <strong>yes I can</strong>.</p>
<p><span id="more-493"></span></p>
<h1>The Slim SuperDrive</h1>
<p>I went out and bought myself the aforementioned Akasa ODD bay case, but failed to notice that it had markings for both 12.5 and 9.5 mm HDD-s. What this means is, of course, the case itself is <strong>12.5 mm</strong> thick, which is 3 mm too much to fit in place of the SuperDrive. So if you can find a 9.5 mm case, your in luck. I had to be a bit more creative, but more on that later.</p>
<div id="attachment_494" class="wp-caption alignnone" style="width: 235px"><a href="http://blog.laaz.org/tech/wp-content/uploads/2012/04/opticalbay_hdd_1.jpg#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed"><img class="size-medium wp-image-494" title="Akasa N.Stor" src="http://blog.laaz.org/tech/wp-content/uploads/2012/04/opticalbay_hdd_1-225x300.jpg" alt="" width="225" height="300" /></a><p class="wp-caption-text">Akasa N.Stor 12.5 mm bay</p></div>
<div id="attachment_496" class="wp-caption alignnone" style="width: 310px"><a href="http://blog.laaz.org/tech/wp-content/uploads/2012/04/opticalbay_hdd_2.jpg#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed"><img class="size-medium wp-image-496" title="Akasa N.Stor unpackaged" src="http://blog.laaz.org/tech/wp-content/uploads/2012/04/opticalbay_hdd_2-300x225.jpg" alt="" width="300" height="225" /></a><p class="wp-caption-text">Akasa N.Stor unpackaged</p></div>
<p>&nbsp;</p>
<h1>What&#8217;s in the belly</h1>
<p>First things first &#8211; unscrew your MacBook and take of the bottom. Note, that the bottom is held in place from the center by two clips and at first it seems that you missed some screws. Just gently pull on the bottom cover to release the clips one by one.</p>
<div id="attachment_497" class="wp-caption alignnone" style="width: 310px"><a href="http://blog.laaz.org/tech/wp-content/uploads/2012/04/opticalbay_hdd_3.jpg#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed"><img class="size-medium wp-image-497" title="MacBook Pro uncovered" src="http://blog.laaz.org/tech/wp-content/uploads/2012/04/opticalbay_hdd_3-300x225.jpg" alt="" width="300" height="225" /></a><p class="wp-caption-text">To access the ODD, first remove Wireless chip screws (RED arrows) and then either (a) release the antenna wires (GREEN arrows) or the connection ribbon (BLUE arrow).</p></div>
<p>Now behold all of the glory inside your MacBook. More precisely pay attention to the Wireless chip that blocks access to ODD. You have to unscrew it (<span style="color: #ff0000;">RED</span> arrows) and then you have the option which of the wires to unplug. Either (a) release the antenna wires (<span style="color: #00ff00;">GREEN</span> arrows) or the connection ribbon (<span style="color: #3366ff;">BLUE</span> arrow). I opted for the antenna, because it seemed a bit less prone to break. (Though later on I learned that the ribbon reattaches a bit easier than the antenna wires, so pick your poison).</p>
<h1>Take out SuperDrive</h1>
<p>Now you can access the SuperDrive.</p>
<div id="attachment_498" class="wp-caption alignnone" style="width: 310px"><a href="http://blog.laaz.org/tech/wp-content/uploads/2012/04/opticalbay_hdd_4.jpg#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed"><img class="size-medium wp-image-498" title="MacBook Pro Superdrive" src="http://blog.laaz.org/tech/wp-content/uploads/2012/04/opticalbay_hdd_4-300x225.jpg" alt="" width="300" height="225" /></a><p class="wp-caption-text">Take out SuperDrive</p></div>
<p>First unscrew the 3 screws (marked <span style="color: #ff0000;">RED</span>) that hold it in place and then gently pull on the ribbon cable that connects it to the motherboard (marked <span style="color: #3366ff;">BLUE</span>) and remove the drive.</p>
<p>If you ever plan to replace the ODD into your MacBook (maybe when you&#8217;re selling it off), your are going to need those screws, so better <strong>screw them back in now</strong>, before they don&#8217;t get lost.</p>
<p><strong>UPDATE:</strong> After I received my <a href="http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&amp;item=160736136688">excellent SuperDrive external closure</a>, I found out that I should&#8217;ve unscrewed one additional fixing from the SuperDrive. In the above picture, it is the rightmost <span style="color: #ff0000;">RED</span> screw holder is itself attached to the SuperDrive with 2 screws. That won&#8217;t fit in the external closure, so instead of taping it inside the closure as I did, you could screw it back in the laptop for future use.</p>
<h1>The Creative Part</h1>
<p>Now we come to the part where I found out that the Akasa N.Stor was 3 mm too thick for the bay. Fortunately, after I dismantled the N.Stor case (BTW, one screw was behind a sticker), it turned out that the additional 3 mm were added with protruding stands that could easily chopped off (or so I hoped).</p>
<div id="attachment_499" class="wp-caption alignnone" style="width: 310px"><a href="http://blog.laaz.org/tech/wp-content/uploads/2012/04/opticalbay_hdd_5.jpg#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed"><img class="size-medium wp-image-499" title="Make N.Stor 9.5 mm" src="http://blog.laaz.org/tech/wp-content/uploads/2012/04/opticalbay_hdd_5-300x225.jpg" alt="" width="300" height="225" /></a><p class="wp-caption-text">In the process of chopping off 3 mm of plastic from the N. Store</p></div>
<p>In the picture the <span style="color: #ff0000;">RED</span> arrows point to some of the stands that need to be chopped off. That part was easy &#8211; a sharp pocket knife and a steady hand.</p>
<p>The more tricky part was to thin up the inner rectangle. But I found that small wire-cutters followed up by knife and then a file did the job pretty well.</p>
<div id="attachment_500" class="wp-caption alignnone" style="width: 310px"><a href="http://blog.laaz.org/tech/wp-content/uploads/2012/04/opticalbay_hdd_6.jpg#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed"><img class="size-medium wp-image-500" title="Hacked N.Store compared to SuperDrive" src="http://blog.laaz.org/tech/wp-content/uploads/2012/04/opticalbay_hdd_6-300x225.jpg" alt="" width="300" height="225" /></a><p class="wp-caption-text">Hacked N.Store compared to SuperDrive</p></div>
<p>To avoid dust getting into the computer I washed the case thoroughly and then dried it off.</p>
<h1>Stuff it in</h1>
<p>Fitting the disk with the remains of the N.Store was easy enough but the problem was that the SuperDrive had screw-holes that the N.Store didn&#8217;t. So how would I secure the disk in place?</p>
<div id="attachment_501" class="wp-caption alignnone" style="width: 310px"><a href="http://blog.laaz.org/tech/wp-content/uploads/2012/04/opticalbay_hdd_7.jpg#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed"><img class="size-medium wp-image-501" title="foam" src="http://blog.laaz.org/tech/wp-content/uploads/2012/04/opticalbay_hdd_7-300x225.jpg" alt="" width="300" height="225" /></a><p class="wp-caption-text">Cabling foam</p></div>
<p>I found in my drawer some pieces of foam that was wrapped around a VGA cable. That looked like something I could use.</p>
<p>The N.Stor did have a plastic piece that was supposed to hold the HDD in place, but it did not seem to do it&#8217;s job that good, so I decided to stuff the HDD too from two sides and then fix the whole thing from two adjoining sides so that it was gently pressed against ODD bay walls.</p>
<div id="attachment_502" class="wp-caption alignnone" style="width: 310px"><a href="http://blog.laaz.org/tech/wp-content/uploads/2012/04/opticalbay_hdd_8.jpg#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed"><img class="size-medium wp-image-502" title="Stuff it in" src="http://blog.laaz.org/tech/wp-content/uploads/2012/04/opticalbay_hdd_8-300x225.jpg" alt="" width="300" height="225" /></a><p class="wp-caption-text">Stuff foam around the HDD and the casing</p></div>
<p>The frame that held Wireless chip proved to be in the ideal position, so I reattached that first and then stuffed foam between that and the N.Stor case. Another roll of foam was put between the case and the DVD slot.</p>
<h1>The Result</h1>
<div id="attachment_503" class="wp-caption alignnone" style="width: 310px"><a href="http://blog.laaz.org/tech/wp-content/uploads/2012/04/opticalbay_hdd_9.jpg#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed"><img class="size-medium wp-image-503" title="ODD HDD final result" src="http://blog.laaz.org/tech/wp-content/uploads/2012/04/opticalbay_hdd_9-300x225.jpg" alt="" width="300" height="225" /></a><p class="wp-caption-text">Final result</p></div>
<p>The last piece was the insulator shield from the N.Store that completed the design. Reattach the back cover and you are done. <strong>Viola!</strong></p>
<p>I was a bit nervous when booting the Mac up, but everything worked nicely and now I have a bidrive MacBook Pro with SSD and HDD totalling 750 GB storage &#8211; should enough for some time. <img src='http://blog.laaz.org/tech/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>At the end it cost me 16 € compared to $90 for the OptiBay (35 € even in the aftermarket here). OK, the OptiBay comes with a free USB case for the SuperDrive which I don&#8217;t have, but it turns out that I can get one of those for another 10 €, totalling in 26 € for me. And a bit of exitement from accomplishing something myself.</p>
<p>Related posts:<ol>
<li><a href='http://blog.laaz.org/tech/2012/04/24/installing-windows-7-on-macbook-pro-without-superdrive/' rel='bookmark' title='Installing Windows 7 on MacBook Pro without SuperDrive'>Installing Windows 7 on MacBook Pro without SuperDrive</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.laaz.org/tech/2012/04/20/macbook-pro-bidrive-or-diy-optical-bay-hdd-caddy/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
