<?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>kahfei</title>
	<atom:link href="http://www.kahfei.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.kahfei.com</link>
	<description>A place for my personal musings, about programming, design or whatever come across my mind</description>
	<lastBuildDate>Wed, 15 May 2013 05:12:46 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>why attr_accessor</title>
		<link>http://www.kahfei.com/?p=379</link>
		<comments>http://www.kahfei.com/?p=379#comments</comments>
		<pubDate>Wed, 15 May 2013 03:57:26 +0000</pubDate>
		<dc:creator>kahfei</dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.kahfei.com/?p=379</guid>
		<description><![CDATA[I keep bump into this problem, where I pick up some basic long ago, after a while, get too used to it and forgot the reason why something is done in a particular way. If I have written about it, then I have a better understanding and longer memory. Like the collection_select method which I [...]]]></description>
				<content:encoded><![CDATA[<p>I keep bump into this problem, where I pick up some basic long ago, after a while, get too used to it and forgot the reason why something is done in a particular way.</p>
<p>If I have written about it, then I have a better understanding and longer memory. Like the <a href="http://www.kahfei.com/?p=23">collection_select</a> method which I drawn a illustration and post about it sometimes ago, it stuck in my memory till now.</p>
<p>This idea is not really new, <a href="http://ninjasandrobots.com/those-who-teach">you learn by teaching</a>, or at least write or blog about it. All that help to clarify your thought.</p>
<p>And so, to help me internalized the reason behind attr_accessor, I quickly googled and read thru this from <a href="  http://stackoverflow.com/questions/4370960/what-is-attr-accessor-in-ruby ">stackoverflow</a>, yet, am gonna write about it as a process of internalization. Ha.</p>
<p>You keep writing attr_accessor, one day you totally forgot why we did attr_accessor at the first place. Why attr_accessor?</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> Human
  <span style="color:#9966CC; font-weight:bold;">def</span> name=<span style="color:#006600; font-weight:bold;">&#40;</span>str<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0066ff; font-weight:bold;">@name</span> = str
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> name
    <span style="color:#0066ff; font-weight:bold;">@name</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>You do that to assign variable to a value, then call the value. This is common repetitive task. Programming is all about eliminating repetitive tasks. So you can do this in ruby</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> Human
  attr_reader <span style="color:#ff3333; font-weight:bold;">:name</span>
  attr_writer <span style="color:#ff3333; font-weight:bold;">:name</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>where attr_reader replace name method part, and attr_writer replace the name=(str) method. Still, often attr_writer and attr_reader often come in pair, why not just do it in one step.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> Human
  attr_accessor <span style="color:#ff3333; font-weight:bold;">:name</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>I created a diagram hopefully could better illustrate this in one glance.</p>
<div id="attachment_381" class="wp-caption alignnone" style="width: 313px"><a href="http://www.kahfei.com/wp-content/uploads/2013/05/attr_accessor.png"><img class="size-full wp-image-381" alt="Evolution of attr_accessor" src="http://www.kahfei.com/wp-content/uploads/2013/05/attr_accessor.png" width="303" height="428" /></a><p class="wp-caption-text">Evolution of attr_accessor</p></div>
<p>That is it. Already felt that now this tie deeper into my memory. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.kahfei.com/?feed=rss2&#038;p=379</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A marathon, not short sprint</title>
		<link>http://www.kahfei.com/?p=369</link>
		<comments>http://www.kahfei.com/?p=369#comments</comments>
		<pubDate>Tue, 14 May 2013 05:18:39 +0000</pubDate>
		<dc:creator>kahfei</dc:creator>
				<category><![CDATA[life]]></category>

		<guid isPermaLink="false">http://www.kahfei.com/?p=369</guid>
		<description><![CDATA[I wish by now I have something positive to write as a fitting part 2 to the post wrote last year, you know, happy ending or something like that. The sad fact is, after numerous try, despite seemingly getting closer each time; I am still here one year later, still looking every possible ways to [...]]]></description>
				<content:encoded><![CDATA[<div id="attachment_370" class="wp-caption alignnone" style="width: 757px"><a href="http://www.kahfei.com/wp-content/uploads/2013/05/run.jpg"><img class="size-full wp-image-370  " alt="A marathon, not short sprint" src="http://www.kahfei.com/wp-content/uploads/2013/05/run.jpg" width="747" height="500" /></a><p class="wp-caption-text">A marathon, not short sprint.<br />Image from stock.xchng, author cienpies.net.</p></div>
<p>I wish by now I have something positive to write as a fitting part 2 to the<a href="http://www.kahfei.com/?p=242"> post wrote last year</a>, you know, happy ending or something like that. The sad fact is, after numerous try, despite seemingly getting closer each time; I am still here one year later, still looking every possible ways to work with rails or web development work, full-time, oh, actually even part-time (So <a href="mailto:me@kahfei.com">ping me</a> if you have any web development works, especially ruby or ruby on rails stuff)</p>
<p>I have Interviewed for 4-5 opportunities, learned a lot, and got to meet some local startup people, developers, etc *but* none of that lead to anything, so far.</p>
<p>My first ever rails freelance gig was developing a simple web apps for a client. It was cancelled like 3 weeks into development. The client decided to look for a local developer instead. He said it is not my problem just that he preferred to work with a developer from local. One year down the road, the site is still not up. I guess the client decided not to pursue with his idea anymore.</p>
<p>Then another freelance gig come knocking, I was required to sign a NDA even. I was so thrilled with the opportunity, their idea is cool, it is like another facebook in the making. The core teams were working on the main features, and I was told that I would involve real soon. Now it is almost a year later, nothing happen still, haven&#8217;t heard any news from the team, their site haven&#8217;t changed for months. Not sure if they still working on the project.</p>
<p>Finally a local startup opening for Rails, not freelance gig but a chance of full-time employment, wow! So off I go for interview, we overcome the usual stumbling block by cutting down my salary (of course, not before serious discussion with the stakeholder &#8211; my wife, always grateful for her understanding), I offer to work with them for a few weekends in advance, so both sides can see if we are a fit. Think you can guess the outcome by now. 2 weekends down, and I got a sorry message, it is not something to do with me, but their internal decision. That is what I&#8217;ve been told at least. They did offer to pay up for my time, though I rejected.</p>
<p>There are one or two more freelance opportunities in between, that didn&#8217;t materialized. The common theme here is, &#8220;It is not your problem really&#8221;. The project just got cancelled, or stagnant, or fading out, or because of some internal decision I was not hired. But I refuse to buy the &#8220;It is not your problem&#8221; statement. There is no benefit in believing it is just plain bad luck, there is no benefit in believing it is just some internal decision to not hire. That is like admit defeat and say, okay, there is nothing I can do with it now. I can only work on things that I can control, which is *me*. I haven&#8217;t made myself so good, that there is no excuse at all not to hire me, of course that is my problem.</p>
<p>Stay positive, working on my own projects, writing even more codes, reading even more codes. Keep doing all that. This is a marathon, not short sprint. Even if no one <a href="http://bijansabet.com/post/44870687156/who-took-a-chance-on-you">take a chance on me</a>, the effort I put in will lead me to somewhere.</p>
<p>I have to believe in that, cause there aren&#8217;t any other options anyway. Ha.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kahfei.com/?feed=rss2&#038;p=369</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Uploaded images go missing in heroku</title>
		<link>http://www.kahfei.com/?p=363</link>
		<comments>http://www.kahfei.com/?p=363#comments</comments>
		<pubDate>Mon, 13 May 2013 05:40:01 +0000</pubDate>
		<dc:creator>kahfei</dc:creator>
				<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://www.kahfei.com/?p=363</guid>
		<description><![CDATA[No doubt heroku is the greatest thing since sliced bread, with easy deployment and stuff, and it is free to start with. Perfect for stingy developer like me. So I am working on a rails apps, deployed to heroku, with paperclip for image upload. Things work fine, except images I uploaded keep on missing. I [...]]]></description>
				<content:encoded><![CDATA[<p>No doubt <a href="http://www.heroku.com/">heroku</a> is the greatest thing since sliced bread, with easy deployment and stuff, and it is free to start with. Perfect for stingy developer like me. So I am working on a rails apps, deployed to heroku, with <a href="https://github.com/thoughtbot/paperclip">paperclip</a> for image upload. Things work fine, except images I uploaded keep on missing. I thought heroku wouldn&#8217;t store image for free user, ha. </p>
<p>A quick search around internet, sure enough it is stackoverflow come with an <a href="http://stackoverflow.com/questions/10425843/everytime-push-to-heroku-images-is-not-showed-paperclip">answer</a> top in the list. It turn out that only images in the commit and pushed to heroku are kept, example logo or icon used in the apps. Uploaded images will be removed with each push to heroku, clearly images uploaded via paperclip fall into the latter category. </p>
<p>Solution is to use a 3rd party storage, like <a href="http://aws.amazon.com/s3/">Amazon Simple Storage Service</a>. Of course, aws is free to start with as well, a free account includes 5Gb storage, 20k Get requests, 2k put request, yada yada, another great thing for stingy developer, hurray!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kahfei.com/?feed=rss2&#038;p=363</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Autorun mess up bundle install</title>
		<link>http://www.kahfei.com/?p=330</link>
		<comments>http://www.kahfei.com/?p=330#comments</comments>
		<pubDate>Mon, 11 Feb 2013 14:16:48 +0000</pubDate>
		<dc:creator>kahfei</dc:creator>
				<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://www.kahfei.com/?p=330</guid>
		<description><![CDATA[I still feel like working with rails in Linux feel easier and faster. What&#8217;s with all the homebrew thing in Mac, feel like you have to go through a lot of troubles just to complete something simple. But working with rails in Windows is another story altogether. Initiatives like Railsinstaller and Devkit help a lot [...]]]></description>
				<content:encoded><![CDATA[<p>I still feel like working with rails in Linux feel easier and faster. What&#8217;s with all the homebrew thing in Mac, feel like you have to go through a lot of troubles just to complete something simple. But working with rails in Windows is another story altogether.  Initiatives like <a href="http://railsinstaller.org/">Railsinstaller</a> and <a href="https://github.com/oneclick/rubyinstaller/wiki/development-kit">Devkit</a> help a lot to get Windows to be less of a pain, but still&#8230;</p>
<p>So I have install railsinstaller, and Devkit come installed with it. And I have things running pretty normal, till lately I try to create a new rails apps, doing a bundle install lead to error saying</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">Gem files will remain installed <span style="color: #000000; font-weight: bold;">in</span> C:<span style="color: #000000; font-weight: bold;">/</span>RailsInstaller<span style="color: #000000; font-weight: bold;">/</span>Ruby1.9.3<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.9</span> .1<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>json-1.7.6 <span style="color: #000000; font-weight: bold;">for</span> inspection. 
Results logged to C:<span style="color: #000000; font-weight: bold;">/</span>RailsInstaller<span style="color: #000000; font-weight: bold;">/</span>Ruby1.9.3<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>1.9.1<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>json-<span style="color: #000000;">1.7</span>. <span style="color: #000000;">6</span><span style="color: #000000; font-weight: bold;">/</span>ext<span style="color: #000000; font-weight: bold;">/</span>json<span style="color: #000000; font-weight: bold;">/</span>ext<span style="color: #000000; font-weight: bold;">/</span>generator<span style="color: #000000; font-weight: bold;">/</span>gem_make.out An error occured <span style="color: #000000; font-weight: bold;">while</span> installing json <span style="color: #7a0874; font-weight: bold;">&#40;</span>1.7.6<span style="color: #7a0874; font-weight: bold;">&#41;</span>, and Bundler cannot continue. Make sure that gem <span style="color: #c20cb9; font-weight: bold;">install</span> json <span style="color: #660033;">-v</span> <span style="color: #ff0000;">'1.7.6'</span> succeeds before bundling.</pre></td></tr></table></div>

<p>I tried to reinstall railsinstaller, and manually install Devkit. No working. Then tried to uninstall railsinstaller, and have ruby installer manually, then Devkit, make sure Devkit path is under ruby root, still the problem persist. Finally I found the solution in <a href="http://stackoverflow.com/questions/3018166/failed-to-build-gem-native-extension-extconf-rb-not-found">stackoverflow</a>, from a link in <a href="http://teamtreehouse.com/forum/error-installing-json-176-with-native-extensions">treehouse&#8217;s blog </a>. The thing is Devkit doesn&#8217;t work with Autorun interfaces, so if you have previously have this setup, in my case it was the I setup for syntax highlighting in command prompt, then you will have to remove it.</p>
<p>Just type this into command prompt</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">REG QUERY <span style="color: #ff0000;">&quot;HKCU\Software\Microsoft\Command Processor&quot;</span>
REG QUERY <span style="color: #ff0000;">&quot;HKLM\Software\Microsoft\Command Processor&quot;</span></pre></td></tr></table></div>

<p>Should get something like below</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">HKEY_CURRENT_USER\Software\Microsoft\Command Processor
    CompletionChar        REG_DWORD    0x9
    DefaultColor          REG_DWORD    0x0
    EnableExtensions      REG_DWORD    0x1
    PathCompletionChar    REG_DWORD    0x9</pre></td></tr></table></div>

<p>These columns actually stand for Key, Type and Value. If there is a Key named AutoRun, then this could be the root cause of the problem. In my case, I think the Autorun key was set when I setup <a href="https://github.com/adoxa/ansicon">ansicon</a>.<br />
Run this to remove it,</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">REG DELETE <span style="color: #ff0000;">&quot;HKCU\Software\Microsoft\Command Processor&quot;</span> <span style="color: #000000; font-weight: bold;">/</span>v AutoRun</pre></td></tr></table></div>

<p>Close command prompt, and bundle install again in a new command prompt session, things should work.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kahfei.com/?feed=rss2&#038;p=330</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Futnotes running locally</title>
		<link>http://www.kahfei.com/?p=323</link>
		<comments>http://www.kahfei.com/?p=323#comments</comments>
		<pubDate>Tue, 05 Feb 2013 23:24:48 +0000</pubDate>
		<dc:creator>kahfei</dc:creator>
				<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://www.kahfei.com/?p=323</guid>
		<description><![CDATA[Redo the whole process. Clone repo again, bundle install now work right away, as all the prerequisites are there. Instead of running rake tasks separately, which fail previously with long list of errors rake db:create:all rake db:migrate rake db:seed I will just do this, which is a shortcut for rake db:create; rake db:schema:load, and rake [...]]]></description>
				<content:encoded><![CDATA[<p>Redo the whole process. Clone repo again, bundle install now work right away, as all the prerequisites are there.<br />
Instead of running rake tasks separately, which fail previously with long list of errors</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">rake db:create:all
rake db:migrate
rake db:seed</pre></td></tr></table></div>

<p>I will just do this, which is a <a href="http://help.codeschool.com/discussions/rails-for-zombies-2/304-rake-dbmigrate-vs-rake-dbsetup">shortcut</a> for rake db:create; rake db:schema:load, and rake db:seed</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">rake db:setup</pre></td></tr></table></div>

<p>And it work!</p>
<p>Precompile Assets,</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">rake assets:precompile</pre></td></tr></table></div>

<p>lead to an error saying &#8220;Segmentation fault while running &#8216;rake assets procompile&#8217;&#8221;. A <a href="http://stackoverflow.com/questions/13569890/rails-s-return-bug-segmentation-fault">suggestion in stackoverflow</a> saying that the rootcause might be execjs, change to therubyracer gem should solve the problem. Even though there is no execjs gem dependency in the gemfile, I still add in therubyracer gem, bundle install again, now rake assets:precompile just work, and I have futnotes running locally. Now off to get the test done </p>
]]></content:encoded>
			<wfw:commentRss>http://www.kahfei.com/?feed=rss2&#038;p=323</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Futnotes &#8211; setting up the repo</title>
		<link>http://www.kahfei.com/?p=310</link>
		<comments>http://www.kahfei.com/?p=310#comments</comments>
		<pubDate>Sun, 03 Feb 2013 09:46:03 +0000</pubDate>
		<dc:creator>kahfei</dc:creator>
				<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://www.kahfei.com/?p=310</guid>
		<description><![CDATA[Cloning the repo git clone https://github.com/Futnotes/dev_test-2.git devtest Mixtures of errors doing bundle install though First it is capybara Using capybara &#40;1.1.2&#41; Installing capybara-webkit &#40;0.12.1&#41; with native extensions Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. According to these sources thoughtbot and stackoverflow qt need to be installed first, before install capybara. To install qt, you must [...]]]></description>
				<content:encoded><![CDATA[<p>Cloning the repo</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git clone</span> https:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>Futnotes<span style="color: #000000; font-weight: bold;">/</span>dev_test-<span style="color: #000000;">2</span>.git devtest</pre></td></tr></table></div>

<p>Mixtures of errors doing bundle install though<br />
First it is capybara</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">Using capybara <span style="color: #7a0874; font-weight: bold;">&#40;</span>1.1.2<span style="color: #7a0874; font-weight: bold;">&#41;</span> 
Installing capybara-webkit <span style="color: #7a0874; font-weight: bold;">&#40;</span>0.12.1<span style="color: #7a0874; font-weight: bold;">&#41;</span> with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.</pre></td></tr></table></div>

<p>According to these sources <a href="https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit">thoughtbot</a> and <a href="http://stackoverflow.com/questions/11642971/unable-to-install-capybara-webkit">stackoverflow</a> qt need to be installed first, before install capybara.<br />
To install qt, you must link to libpng, simply link to linpng will fail due to permission,</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">Error: Could not symlink file: <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>Cellar<span style="color: #000000; font-weight: bold;">/</span>libpng<span style="color: #000000; font-weight: bold;">/</span>1.5.13<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>pkgconfig<span style="color: #000000; font-weight: bold;">/</span>libpng15.pc
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>pkgconfig is not writable. You should change its permissions.</pre></td></tr></table></div>

<p>To fix that</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-R</span> kahfei <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>pkgconfig</pre></td></tr></table></div>

<p>then only follow by command below</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">brew update
brew <span style="color: #c20cb9; font-weight: bold;">link</span> libpng
brew <span style="color: #c20cb9; font-weight: bold;">install</span> qt</pre></td></tr></table></div>

<p>bundle install still fail though</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">An error occurred <span style="color: #000000; font-weight: bold;">while</span> installing rmagick <span style="color: #7a0874; font-weight: bold;">&#40;</span>2.13.1<span style="color: #7a0874; font-weight: bold;">&#41;</span>, and Bundler cannot continue.
Make sure that <span style="color: #000000; font-weight: bold;">`</span>gem <span style="color: #c20cb9; font-weight: bold;">install</span> rmagick <span style="color: #660033;">-v</span> <span style="color: #ff0000;">'2.13.1'</span><span style="color: #000000; font-weight: bold;">`</span> succeeds before bundling.</pre></td></tr></table></div>

<p>It seems that lot of people <a href="https://coderwall.com/p/wnomjg">having</a> <a href="https://github.com/mxcl/homebrew/issues/16625">this</a> <a href="http://flaviomuniz.com/blog/how-to-fix-rmagick-2-13-1-cant-find-magickwand-h.html">same</a> <a href="http://stackoverflow.com/questions/11676844/issue-with-installing-imagemagick-and-rmagick-on-mountain-lion">problem</a>. Some of the suggestion work for some people, but none of it fixed my problem. Apparently this is a rmagick bug, as it does not support the newer version of ImageMagick. rmagick has not been updated for two years, so if there is an option, change to other gem to work with image, like <a href="https://github.com/minimagick/minimagick">minimagick</a></p>
<p>After hours of scouring the internet, and trying a few different approaches, using the <a href="https://github.com/maddox/magick-installer">magick-installer</a> to install ImageMagick, then</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">bundle <span style="color: #c20cb9; font-weight: bold;">install</span></pre></td></tr></table></div>

<p>work again. No actually I lie,  bundle install yield another error</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">ERROR: While executing gem … <span style="color: #7a0874; font-weight: bold;">&#40;</span>ArgumentError<span style="color: #7a0874; font-weight: bold;">&#41;</span> marshal data too short</pre></td></tr></table></div>

<p>There are suggestions to remove ~./gem folder altogether and reinstall all the gem. But in my case, bundle install work on other rails apps, just not this one. So I clone again the repo to a new folder, now bundle install work!</p>
<p>Now creating development, testing and production environment. I already have postgresql installed locally, so I will use postgresql, my database.yml looks something like this</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="ruby" style="font-family:monospace;">development:
adapter: postgresql
encoding: unicode
database: futnotes_development
pool: <span style="color:#006666;">5</span>
username: kahfei
password: 
test:
adapter: postgresql
encoding: unicode
database: futnotes_test
pool: <span style="color:#006666;">5</span>
username: kahfei
password: 
&nbsp;
production:
adapter: postgresql
encoding: unicode
database: futnotes_production
pool: <span style="color:#006666;">5</span>
username: kahfei
password:</pre></td></tr></table></div>

<p>now to create them</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">rake db:create:all</pre></td></tr></table></div>

<p>All three database created</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">rake db:migrate</pre></td></tr></table></div>

<p>with a long list of errors, it start with something like this</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">PG::Error: ERROR:  column <span style="color: #ff0000;">&quot;position&quot;</span> does not exist
LINE <span style="color: #000000;">1</span>: ...RE <span style="color: #ff0000;">&quot;competitions&quot;</span>.<span style="color: #ff0000;">&quot;name&quot;</span> = <span style="color: #ff0000;">'Premiership'</span> ORDER BY position, ...</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.kahfei.com/?feed=rss2&#038;p=310</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>require file from same directory in ruby</title>
		<link>http://www.kahfei.com/?p=304</link>
		<comments>http://www.kahfei.com/?p=304#comments</comments>
		<pubDate>Sat, 15 Dec 2012 17:47:16 +0000</pubDate>
		<dc:creator>kahfei</dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.kahfei.com/?p=304</guid>
		<description><![CDATA[Requiring a file sitting in the same directory wouldn&#8217;t work with this require 'something' Seems like Ruby 1.9 remove current directory from load path as I read from Stackoverflow To make it work you could require './something' or use require_relative, require_relative 'something' The thing is, load 'something.rb' still work. So does that mean load and [...]]]></description>
				<content:encoded><![CDATA[<p>Requiring a file sitting in the same directory wouldn&#8217;t work with this</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'something'</span></pre></td></tr></table></div>

<p>Seems like Ruby 1.9 remove current directory from load path as I read from <a href="http://stackoverflow.com/questions/9750610/ruby-require-error-cannot-load-such-file">Stackoverflow</a></p>
<p>To make it work you could</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'./something'</span></pre></td></tr></table></div>

<p>or use require_relative,</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="ruby" style="font-family:monospace;">require_relative <span style="color:#996600;">'something'</span></pre></td></tr></table></div>

<p>The thing is,</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">load</span> <span style="color:#996600;">'something.rb'</span></pre></td></tr></table></div>

<p>still work. So does that mean load and require have different load path?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kahfei.com/?feed=rss2&#038;p=304</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Great advise</title>
		<link>http://www.kahfei.com/?p=295</link>
		<comments>http://www.kahfei.com/?p=295#comments</comments>
		<pubDate>Fri, 09 Nov 2012 00:17:03 +0000</pubDate>
		<dc:creator>kahfei</dc:creator>
				<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.kahfei.com/?p=295</guid>
		<description><![CDATA[]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.kahfei.com/wp-content/uploads/2012/11/advice.jpg"><img class="alignnone size-medium wp-image-296" title="advice" src="http://www.kahfei.com/wp-content/uploads/2012/11/advice-300x242.jpg" alt="" width="300" height="242" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kahfei.com/?feed=rss2&#038;p=295</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Closing the gap</title>
		<link>http://www.kahfei.com/?p=292</link>
		<comments>http://www.kahfei.com/?p=292#comments</comments>
		<pubDate>Sun, 01 Jul 2012 00:19:08 +0000</pubDate>
		<dc:creator>kahfei</dc:creator>
				<category><![CDATA[design]]></category>

		<guid isPermaLink="false">http://www.kahfei.com/?p=292</guid>
		<description><![CDATA[Ira Glass on Storytelling from David Shiyang Liu on Vimeo. Love this&#8230;]]></description>
				<content:encoded><![CDATA[<p><iframe src="http://player.vimeo.com/video/24715531" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
<p><a href="http://vimeo.com/24715531">Ira Glass on Storytelling</a> from <a href="http://vimeo.com/thedak">David Shiyang Liu</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>Love this&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kahfei.com/?feed=rss2&#038;p=292</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Regex hammer time</title>
		<link>http://www.kahfei.com/?p=284</link>
		<comments>http://www.kahfei.com/?p=284#comments</comments>
		<pubDate>Tue, 29 May 2012 04:03:25 +0000</pubDate>
		<dc:creator>kahfei</dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.kahfei.com/?p=284</guid>
		<description><![CDATA[When you have a hammer, you see everything as nails. A very true message from Dive into Python 3, Regular expressions are extremely powerful, but they are not the correct solution for every problem. You should learn enough about them to know when they are appropriate, when they will solve your problems, and when they [...]]]></description>
				<content:encoded><![CDATA[<p>When you have a hammer, you see everything as nails.<br />
A very true message from <a href="http://getpython3.com/diveintopython3/regular-expressions.html">Dive into Python 3</a>,</p>
<blockquote><p>Regular expressions are extremely powerful, but they are not the correct solution for every problem. You should learn enough about them to know when they are appropriate, when they will solve your problems, and when they will cause more problems than they solve.</p></blockquote>
<p>But it is easy to fall into the trap of using regex for everything.<br />
I need to find the last string from a path, where</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="ruby" style="font-family:monospace;">path = <span style="color:#996600;">&quot;d:/some/directory-with dash-and space&quot;</span></pre></td></tr></table></div>

<p>So here is how I try to get the last string in a path, with regex</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="ruby" style="font-family:monospace;">path.<span style="color:#9900CC;">match</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>\w<span style="color:#006600; font-weight:bold;">*</span>$<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p>trying to capture any word characters at the end of the string with \w*$, but only captured the last word &#8220;space&#8221;, not good.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="ruby" style="font-family:monospace;">path.<span style="color:#9900CC;">match</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#40;</span>\s<span style="color:#006600; font-weight:bold;">|</span>\w<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">*</span>$<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span></pre></td></tr></table></div>

<p>to match either whitespace (\s) or word characters (\w) at the end of the string, the result is &#8220;and space&#8221;, dashed is not captured, not good.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="ruby" style="font-family:monospace;">path.<span style="color:#9900CC;">match</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#91;</span>^\<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">*</span>$<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p>[^\/] to take in everything except &#8220;/&#8221;, result is &#8220;directory-with dash-and space&#8221;, it works!</p>
<p>Only later I found out there is a really simple way to do this</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">basename</span><span style="color:#006600; font-weight:bold;">&#40;</span>path<span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p>will actually give you &#8220;directory-with dash-and space&#8221;. Plus, it will ignore ending slash if there is any.<br />
Duh!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kahfei.com/?feed=rss2&#038;p=284</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
