<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <link href="http://wowkhmer.com/index.xml" rel="self" type="application/rss+xml"/>
  <title>WowKhmer</title>
  <id>http://wowkhmer.com/</id>
  <updated>2009-01-20T00:00:00Z</updated>
  <author>
    <name>Samnang Chhun</name>
  </author>
  <entry>
    <title>You should invest in Code Reading skills</title>
    <link href="http://wowkhmer.com/2012/05/05/you-should-invest-in-code-reading-skills/" rel="alternate"/>
    <id>http://wowkhmer.com/2012/05/05/you-should-invest-in-code-reading-skills/</id>
    <published>2012-05-05T00:00:00Z</published>
    <updated>2012-05-05T00:00:00Z</updated>
    <author>
      <name>Samnang Chhun</name>
    </author>
    <summary type="html">&lt;p&gt;As you probably didn&amp;rsquo;t realize, you spent 2/3 of your time in doing programming tasks by reading your own codes or somebody else&amp;rsquo;s codes. So you ask why do we spend so much time in reading codes? Because before you do following tasks, you usually have to read and understand of existing codebase first:&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;As you probably didn&amp;rsquo;t realize, you spent 2/3 of your time in doing programming tasks by reading your own codes or somebody else&amp;rsquo;s codes. So you ask why do we spend so much time in reading codes? Because before you do following tasks, you usually have to read and understand of existing codebase first:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add features&lt;/li&gt;
&lt;li&gt;Update requirements&lt;/li&gt;
&lt;li&gt;Refactoring&lt;/li&gt;
&lt;li&gt;Optimization&lt;/li&gt;
&lt;li&gt;Discuss solution with peers(Code Review)&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;So you have to be good at code reading skills to be more productive and become better programmers/developers. Then you ask how you could improve your code reading skills? Different people have different styles in learning, so I share what I usually do for myself:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pick up an open source project. It could be a library or an application that you already used.&lt;/li&gt;
&lt;li&gt;Try to understand what the project is about.&lt;/li&gt;
&lt;li&gt;Try to put very minimum effort to get a very simple example working.&lt;/li&gt;
&lt;li&gt;Go deeper to see how they implemented classes/modules to provide our simple example working.&lt;/li&gt;
&lt;li&gt;Take notes on good parts(code structures, idioms, tricks, &amp;hellip;) while I reading codes.&lt;/li&gt;
&lt;li&gt;Some times I found some questions on why they decided to solve this particular problem in that way? I take note and ask in mailing list or IRC if they have.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Finally, that&amp;rsquo;s what I would like to share with you, but I forget to mention one more thing, there is a free global &lt;a href="http://tinyletter.com/codereading"&gt;code reading study group&lt;/a&gt;. This group has just started, and we are mainly focus on Ruby and JS projects right now, but more to follow. Our first week project is &lt;a href="https://github.com/codereading/rack/issues"&gt;Rack&lt;/a&gt; gem.&lt;/p&gt;

&lt;h3&gt;Useful Resources&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://blog.rubybestpractices.com/posts/gregory/005-code-reading-stdlib.html"&gt;http://blog.rubybestpractices.com/posts/gregory/005-code-reading-stdlib.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.skorks.com/2010/05/why-i-love-reading-other-peoples-code-and-you-should-too/"&gt;http://www.skorks.com/2010/05/why-i-love-reading-other-peoples-code-and-you-should-too/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://c2.com/cgi/wiki?TipsForReadingCode"&gt;http://c2.com/cgi/wiki?TipsForReadingCode&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</content>
  </entry>
  <entry>
    <title>Keep your vimrc concise and Vundle managing dependencies</title>
    <link href="http://wowkhmer.com/2012/04/08/keep-your-vimrc-concise-and-vundle-managing-dependencies/" rel="alternate"/>
    <id>http://wowkhmer.com/2012/04/08/keep-your-vimrc-concise-and-vundle-managing-dependencies/</id>
    <published>2012-04-08T00:00:00Z</published>
    <updated>2012-04-08T00:00:00Z</updated>
    <author>
      <name>Samnang Chhun</name>
    </author>
    <summary type="html">&lt;p&gt;I have been using vimming for a year now, and it became my primary text editor by then. Before that time, I only used it for editing configuration files on ssh server. It worths learning Vim because it is almost used in my day to day freelancing job work for pair programming, and we find out using Vim + Screen GNU/Tmux increase our productivity and reduce friction on development&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;I have been using vimming for a year now, and it became my primary text editor by then. Before that time, I only used it for editing configuration files on ssh server. It worths learning Vim because it is almost used in my day to day freelancing job work for pair programming, and we find out using Vim + Screen GNU/Tmux increase our productivity and reduce friction on development.&lt;/p&gt;

&lt;p&gt;After I read some posts on &lt;a href="http://vimuniversity.com/"&gt;Vim University&lt;/a&gt;, and especially a post on &lt;a href="http://vimuniversity.com/posts/dont-be-proud-of-an-empty-vimrc"&gt;Don&amp;rsquo;t be proud of an empty vimrc&lt;/a&gt;, then it helps me to think about revising my vimrc configuration. I have switched to use &lt;a href="https://github.com/gmarik/vundle"&gt;Vundle&lt;/a&gt; for managing vim plugins because I don&amp;rsquo;t have to use &lt;a href="https://github.com/tpope/vim-pathogen/"&gt;pathogen.vim&lt;/a&gt; with using git submodules or writing a Rake task to mange plugins. Vundle helps us to manage plugin as easy as you never though of:&lt;/p&gt;

&lt;script src="https://gist.github.com/2338370.js?file=vimrc"&gt;&lt;/script&gt;


&lt;p&gt;&lt;noscript&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;" Let Vundle manage Vundle
Bundle 'gmarik/vundle'

Bundle 'tpope/vim-rails'
Bundle 'tpope/vim-rake'
Bundle 'tpope/vim-fugitive'
Bundle 'tpope/vim-surround'
Bundle 'tpope/vim-endwise'
Bundle 'scrooloose/nerdtree'
Bundle 'kien/ctrlp.vim'
Bundle 'msanders/snipmate.vim'
Bundle 'ervandew/supertab'
Bundle 'mileszs/ack.vim'
Bundle 'scrooloose/nerdcommenter'
Bundle 'scrooloose/syntastic'
Bundle 'Raimondi/delimitMate'
Bundle 'mattn/zencoding-vim'
Bundle 'vim-scripts/IndexedSearch'
Bundle 'vim-scripts/L9.git'
Bundle 'vim-scripts/matchit.zip'
Bundle 'godlygeek/tabular'
Bundle 'git://gist.github.com/287147.git'

Bundle 'tpope/vim-cucumber'
Bundle 'tpope/vim-haml'
Bundle 'pangloss/vim-javascript'
Bundle 'kchmck/vim-coffee-script'
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;/noscript&gt;&lt;/p&gt;

&lt;p&gt;Of course, I also revised my &lt;a href="https://github.com/samnang/dotfiles/blob/master/vimrc"&gt;vimrc&lt;/a&gt; configuration, and I also kept only minimum configuration that I understand and use it for my day to day job. I deleted some settings that I stole and didn&amp;rsquo;t understand them from vary sources. At the end of the day, I have managed my vimrc has only about 100 lines. How is about yours?&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Send Email Notifications in Rails Development</title>
    <link href="http://wowkhmer.com/2011/10/02/send-email-notifications-in-rails-development/" rel="alternate"/>
    <id>http://wowkhmer.com/2011/10/02/send-email-notifications-in-rails-development/</id>
    <published>2011-10-02T00:00:00Z</published>
    <updated>2011-10-02T00:00:00Z</updated>
    <author>
      <name>Samnang Chhun</name>
    </author>
    <summary type="html">&lt;p&gt;When there are features in your application that deal with sending email to users(eg. account activation, forget password). When you would like to test those features in your Rails development environment, then you probably go to running server&amp;rsquo;s log to copy generated links in the sending email, and how about when your managers would like to test them as well, then do they know how to go to the log to copy the links? And some other people use their real email addresses(eg. gmail) to receive the emails. Would you ever though any easier solution?&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;When there are features in your application that deal with sending email to users(eg. account activation, forget password). When you would like to test those features in your Rails development environment, then you probably go to running server&amp;rsquo;s log to copy generated links in the sending email, and how about when your managers would like to test them as well, then do they know how to go to the log to copy the links? And some other people use their real email addresses(eg. gmail) to receive the emails. Would you ever though any easier solution?&lt;/p&gt;

&lt;h2&gt;1. &lt;a href="https://github.com/sj26/mailcatcher"&gt;MailCatcher&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;MailCatcher is a Ruby gem from Samuel Cochran. MailCatcher runs a super simple SMTP server which catches any message sent to it to display in a web interface.&lt;/p&gt;

&lt;h3&gt;How&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;$ gem install mailcatcher
$ mailcatcher -f
Starting MailCatcher
==&amp;gt; smtp://127.0.0.1:1025
==&amp;gt; http://127.0.0.1:1080
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then set the delivery method in &lt;code&gt;config/environments/development.rb&lt;/code&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { :host =&amp;gt; "localhost", :port =&amp;gt; 1025 }
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;2. &lt;a href="https://github.com/ryanb/letter_opener"&gt;Letter Opener&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;Letter Opener is a Ruby gem from Ryan Bates who run the awesome railscasts. Letter Opener previews emails in the browser instead of sending it.&lt;/p&gt;

&lt;h3&gt;How&lt;/h3&gt;

&lt;p&gt;First add the gem to your development environment and run the bundle command to install it.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;gem "letter_opener", :group =&amp;gt; :development
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then set the delivery method in &lt;code&gt;config/environments/development.rb&lt;/code&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;config.action_mailer.delivery_method = :letter_opener
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; While I write this article, there are some people face an issue with nothing happen when sending email out. I found the problem because of Launchy dependency gem version. Because @ryanb hasn&amp;rsquo;t specified version of Launchy dependency gem in gemspec file, then it won&amp;rsquo;t install the new Launchy version if there is any old versions in local gems. I already sent a pull request, and hope it will fix soon.&lt;/p&gt;

&lt;h2&gt;3. &lt;a href="http://mocksmtpapp.com/"&gt;MockSMTP&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;The third option that I haven&amp;rsquo;t tried myself either is MockSMTP. MockSMTP is a native Mac application that embeds its own SMTP server.&lt;/p&gt;

&lt;h3&gt;HOW&lt;/h3&gt;

&lt;p&gt;There is &lt;a href="http://mocksmtpapp.com/help"&gt;a help page&lt;/a&gt; to tell you how to could configure your Rails applications to use with MockSMTP.&lt;/p&gt;

&lt;h2&gt;UPDATE&lt;/h2&gt;

&lt;p&gt;&lt;a href="http://twitter.com/dushyanth_m"&gt;Dushyanth Maguluru&lt;/a&gt; has added in his comment a couple of other ways by using ActionMailer interceptor or by writing your own mail delivery classes:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://asciicasts.com/episodes/206-action-mailer-in-rails-3"&gt;http://asciicasts.com/episodes/206-action-mailer-in-rails-3&lt;/a&gt;
&lt;a href="https://github.com/DushyanthMaguluru/custom_mail_delivery"&gt;https://github.com/DushyanthMaguluru/custom_mail_delivery&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>My last day at Yoolk</title>
    <link href="http://wowkhmer.com/2011/09/25/my-last-day-at-yoolk/" rel="alternate"/>
    <id>http://wowkhmer.com/2011/09/25/my-last-day-at-yoolk/</id>
    <published>2011-09-25T00:00:00Z</published>
    <updated>2011-09-25T00:00:00Z</updated>
    <author>
      <name>Samnang Chhun</name>
    </author>
    <summary type="html">&lt;p&gt;I almost couldn&amp;rsquo;t believe it, but on Friday, September 23rd was my last day at &lt;a href="http://www.yoolk.com/"&gt;Yoolk&lt;/a&gt;. I joined to work at Yoolk since July, 2007. Since then I really enjoyed in learning and was a part of the team. I would say it&amp;rsquo;s a place that not only changes my career in software development, but also the place that I first heard ideas about Agile Software Development, Scrum, XP, Pair Programming, Unit Testing, Design Patterns, etc. I started my career as a .NET developer(MCTS), but for the last three years Yoolk decided to make a transition from .NET to Rails development platform instead, after I wrote some codes in Ruby and used Rails for a while and I like the communities, then I decided to move my career from .NET to Ruby/Rails development since then&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;I almost couldn&amp;rsquo;t believe it, but on Friday, September 23rd was my last day at &lt;a href="http://www.yoolk.com/"&gt;Yoolk&lt;/a&gt;. I joined to work at Yoolk since July, 2007. Since then I really enjoyed in learning and was a part of the team. I would say it&amp;rsquo;s a place that not only changes my career in software development, but also the place that I first heard ideas about Agile Software Development, Scrum, XP, Pair Programming, Unit Testing, Design Patterns, etc. I started my career as a .NET developer(MCTS), but for the last three years Yoolk decided to make a transition from .NET to Rails development platform instead, after I wrote some codes in Ruby and used Rails for a while and I like the communities, then I decided to move my career from .NET to Ruby/Rails development since then.&lt;/p&gt;

&lt;p&gt;Yoolk Team is awesome, you guys are smart. Everyone has different skills set. I learned from you guys a lot, and I would like to say thanks for all of you. And I still thinking you guys always be a leading software team in Cambodia.&lt;/p&gt;

&lt;p&gt;Then, what will I do next? It&amp;rsquo;s not kidding that I would say I will stay at home :) I have been doing freelancing with remote jobs since beginning of this year when I completed &lt;a href="http://university.rubymendicant.com/"&gt;Mendicant University&lt;/a&gt;(former as Ruby Mendicant University). I will do more freelancing and consulting to support paying bills. The main reason is I would like to improve my software development skills by working with more people, then I could learn from them. I would like to be an apprentice again, and I hope I could find a mentor that could guide me to find my path. I also would like to be a part of communities, especially contributing OSS and building local communities.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Unobtrusive AJAX with Rails 3.1</title>
    <link href="http://wowkhmer.com/2011/09/19/unobtrusive-ajax-with-rails-31/" rel="alternate"/>
    <id>http://wowkhmer.com/2011/09/19/unobtrusive-ajax-with-rails-31/</id>
    <published>2011-09-19T00:00:00Z</published>
    <updated>2011-09-19T00:00:00Z</updated>
    <author>
      <name>Samnang Chhun</name>
    </author>
    <summary type="html">&lt;p&gt;Since Rails 3.0 release, Unobtrusive Javascript has introduced in building Rails application. It&amp;rsquo;s a technique for separating the behavior of a web application from its content. It helps us to implement a web application that works for clients with and without enabled javascript. If users don&amp;rsquo;t have enabled javascript, then it works just traditional web application&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;Since Rails 3.0 release, Unobtrusive Javascript has introduced in building Rails application. It&amp;rsquo;s a technique for separating the behavior of a web application from its content. It helps us to implement a web application that works for clients with and without enabled javascript. If users don&amp;rsquo;t have enabled javascript, then it works just traditional web application.&lt;/p&gt;

&lt;p&gt;AJAX with Rails, if you have some experiences with RJS in previous versions of Rails, then you will not see many differences when you implement AJAX in Rails 3.1. One different is you create template in javascript or coffee-script instead of RJS. Let&amp;rsquo;s see how we implement application below:&lt;/p&gt;

&lt;p&gt;&lt;img src="https://img.skitch.com/20110918-rga8gjep56nrs24kq5c1d8esc8.png" alt="Unobtrusive AJAX with Rails 3.1" /&gt;&lt;/p&gt;

&lt;p&gt;Add js respond format to comments controller &lt;code&gt;app/controllers/comments_controller.rb&lt;/code&gt;&lt;/p&gt;

&lt;script src="https://gist.github.com/1225377.js?file=comments_controller.rb"&gt;&lt;/script&gt;


&lt;p&gt;&lt;noscript&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# app/controllers/comments_controller.rb    
class CommentsController &amp;lt; ApplicationController
  respond_to :html, :js

  def index
    @comments = Comment.all
  end

  def create
    @comment = Comment.new(params[:comment])

    @comment.save

    respond_with @comment, :location =&amp;gt; comments_url
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;/noscript&gt;&lt;/p&gt;

&lt;p&gt;Implement views &lt;code&gt;app/views/comments/index.html.erb&lt;/code&gt; with remote form&lt;/p&gt;

&lt;script src="https://gist.github.com/1225377.js?file=index.html.erb"&gt;&lt;/script&gt;


&lt;p&gt;&lt;noscript&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# app/views/comments/index.html.erb
&amp;lt;% title "Comments for Ajax in Rails 3.1" %&amp;gt;

&amp;lt;div id="comments_count"&amp;gt;&amp;lt;%= comments_count %&amp;gt;&amp;lt;/div&amp;gt;

&amp;lt;div id="comments"&amp;gt;
  &amp;lt;%= render @comments %&amp;gt;
&amp;lt;/div&amp;gt;

&amp;lt;h3&amp;gt;Add your comment:&amp;lt;/h3&amp;gt;

&amp;lt;%= form_for Comment.new, :remote =&amp;gt; true do |f| %&amp;gt;
  &amp;lt;%= f.error_messages %&amp;gt;
  &amp;lt;p&amp;gt;
    &amp;lt;%= f.label :name %&amp;gt;&amp;lt;br /&amp;gt;
    &amp;lt;%= f.text_field :name %&amp;gt;
  &amp;lt;/p&amp;gt;
  &amp;lt;p&amp;gt;
    &amp;lt;%= f.label :content, "Comment" %&amp;gt;&amp;lt;br /&amp;gt;
    &amp;lt;%= f.text_area :content, :rows =&amp;gt; '12', :cols =&amp;gt; 35 %&amp;gt;
  &amp;lt;/p&amp;gt;
  &amp;lt;p&amp;gt;&amp;lt;%= f.submit %&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;% end %&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;/noscript&gt;&lt;/p&gt;

&lt;script src="https://gist.github.com/1225377.js?file=_comment.html.erb"&gt;&lt;/script&gt;


&lt;p&gt;&lt;noscript&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# app/views/comments/_comment.html.erb
&amp;lt;div class="comment"&amp;gt;
  &amp;lt;strong&amp;gt;&amp;lt;%= comment.name %&amp;gt;&amp;lt;/strong&amp;gt;
  &amp;lt;em&amp;gt;on &amp;lt;%= comment.created_at.strftime('%b %d, %Y at %I:%M %p') %&amp;gt;&amp;lt;/em&amp;gt;
  &amp;lt;%= simple_format comment.content %&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;/noscript&gt;&lt;/p&gt;

&lt;p&gt;Add javascript or coffeescript template, I prefer (&lt;code&gt;app/views/comments/create.js.coffee&lt;/code&gt;) to handle ajax request&lt;/p&gt;

&lt;script src="https://gist.github.com/1225377.js?file=create.js.coffee"&gt;&lt;/script&gt;


&lt;p&gt;&lt;noscript&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# app/views/comments/create.js.coffee   
$('&amp;lt;%= escape_javascript(render(:partial =&amp;gt; @comment))%&amp;gt;')
  .appendTo('#comments')
  .hide()
  .fadeIn()

$('#new_comment')[0].reset()

$('#comments_count').html '&amp;lt;%= comments_count %&amp;gt;'
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;/noscript&gt;
The complete source is on &lt;a href="https://github.com/samnang/ajax_rails31_demo"&gt;Github&lt;/a&gt;. So feel free to checkout and run it to see in action.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Use View Helper Methods in Rails 3 Controller</title>
    <link href="http://wowkhmer.com/2011/09/09/use-view-helper-methods-in-rails-3-controller/" rel="alternate"/>
    <id>http://wowkhmer.com/2011/09/09/use-view-helper-methods-in-rails-3-controller/</id>
    <published>2011-09-09T00:00:00Z</published>
    <updated>2011-09-09T00:00:00Z</updated>
    <author>
      <name>Samnang Chhun</name>
    </author>
    <summary type="html">&lt;p&gt;Sometimes people use &lt;a href="http://apidock.com/rails/ActionController/Helpers/ClassMethods/helper_method"&gt;&lt;code&gt;helper_method&lt;/code&gt;&lt;/a&gt; to turn their controller methods to be able to use in their views. Rails provides a lot of &lt;a href="http://apidock.com/rails/ActionView/Helpers"&gt;view helpers&lt;/a&gt;, and sometimes we would like to use some helper methods that have in helper modules in our controllers instead, for example &lt;code&gt;link_to&lt;/code&gt;, &lt;code&gt;mail_to&lt;/code&gt;, &lt;code&gt;pluralize&lt;/code&gt;, etc. One way to archive this in Rails 3 is to call &lt;a href="http://apidock.com/rails/AbstractController/Rendering/view_context"&gt;&lt;code&gt;view_context&lt;/code&gt;&lt;/a&gt; inside the controller to create a new ActionView instance for a controller, then all helper methods will be available through this instance in the controller&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;Sometimes people use &lt;a href="http://apidock.com/rails/ActionController/Helpers/ClassMethods/helper_method"&gt;&lt;code&gt;helper_method&lt;/code&gt;&lt;/a&gt; to turn their controller methods to be able to use in their views. Rails provides a lot of &lt;a href="http://apidock.com/rails/ActionView/Helpers"&gt;view helpers&lt;/a&gt;, and sometimes we would like to use some helper methods that have in helper modules in our controllers instead, for example &lt;code&gt;link_to&lt;/code&gt;, &lt;code&gt;mail_to&lt;/code&gt;, &lt;code&gt;pluralize&lt;/code&gt;, etc. One way to archive this in Rails 3 is to call &lt;a href="http://apidock.com/rails/AbstractController/Rendering/view_context"&gt;&lt;code&gt;view_context&lt;/code&gt;&lt;/a&gt; inside the controller to create a new ActionView instance for a controller, then all helper methods will be available through this instance in the controller.&lt;/p&gt;

&lt;script src="https://gist.github.com/1205781.js?file=gistfile1.rb"&gt;&lt;/script&gt;


&lt;p&gt;&lt;noscript&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# app/controllers/posts_controller.rb
class PostsController &amp;lt; ActionController::Base
  def show
    # ...
    tags = view_context.generate_tags(@post)
    email_link = view_context.mail_to(@user.email)
    # ...
  end 
end

# app/helpers/posts_helper.rb
module PostsHelper
  def generate_tags(post)
    "Generate Tags"
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;/noscript&gt;&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Sprinkle: Build remote servers in repeatable way</title>
    <link href="http://wowkhmer.com/2011/08/22/sprinkle-build-remote-servers-in-repeatable-way/" rel="alternate"/>
    <id>http://wowkhmer.com/2011/08/22/sprinkle-build-remote-servers-in-repeatable-way/</id>
    <published>2011-08-22T00:00:00Z</published>
    <updated>2011-08-22T00:00:00Z</updated>
    <author>
      <name>Samnang Chhun</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Cloud_computing"&gt;Cloud Computing&lt;/a&gt; helps us be really easy to scale more servers or relaunch new servers when something went wrong. But setting up a new server to be the same as existing one is not easy because we have to remember all installed packages, custom configurations, and commands that you need to run them in order&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Cloud_computing"&gt;Cloud Computing&lt;/a&gt; helps us be really easy to scale more servers or relaunch new servers when something went wrong. But setting up a new server to be the same as existing one is not easy because we have to remember all installed packages, custom configurations, and commands that you need to run them in order.&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;&amp;ldquo; &lt;a href="https://github.com/crafterm/sprinkle/"&gt;Sprinkle&lt;/a&gt; is a software provisioning tool you can use to build remote servers with, after the base operating system has been installed. For example, to install a Rails or Merb stack on a brand new slice directly after its been created. &amp;rdquo;&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;Sprinkle uses Ruby&amp;rsquo;s DSL to define packages/steps that are going to execute on remote servers, so that makes it easy to read and write. Here is an example of package description follows:&lt;/p&gt;

&lt;script src="https://gist.github.com/1160876.js?file=ruby_enterprise.rb"&gt;&lt;/script&gt;


&lt;p&gt;&lt;noscript&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;package :ruby_enterprise do
  description 'Ruby Enterprise Edition'
  version '1.8.7-2011.03'
  REE_PATH = "/usr/local/ruby-enterprise"
  binaries = %w(erb gem irb rackup rails rake rdoc ree-version ri ruby testrb)
  source "http://rubyenterpriseedition.googlecode.com/files/ruby-enterprise-#{version}.tar.gz" do
    custom_install 'sudo ./installer --auto=/usr/local/ruby-enterprise'
    binaries.each {|bin| post :install, "ln -s #{REE_PATH}/bin/#{bin} /usr/local/bin/#{bin}" }
  end

  verify do
    has_directory REE_PATH
    has_executable "#{REE_PATH}/bin/ruby"
    binaries.each {|bin| has_symlink "/usr/local/bin/#{bin}", "#{REE_PATH}/bin/#{bin}" }
  end

  requires :ree_dependencies
end

package :ree_dependencies do
  apt %w(zlib1g-dev libreadline5-dev libssl-dev)
  requires :build_essential
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;/noscript&gt;&lt;/p&gt;

&lt;p&gt;There are few other tools as well like &lt;a href="http://www.opscode.com/chef/"&gt;Chef&lt;/a&gt; and &lt;a href="http://www.puppetlabs.com/"&gt;Puppet&lt;/a&gt;, and they are popular and really good. But after I spent a few hours to try Chef, then I feel it&amp;rsquo;s not so friendly tool for getting started. So that&amp;rsquo;s why I choose Sprinkle instead.&lt;/p&gt;

&lt;h2&gt;Resources&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/crafterm/sprinkle"&gt;https://github.com/crafterm/sprinkle&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.vimeo.com/2888665"&gt;http://www.vimeo.com/2888665&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/uhlenbrock/passenger-stack"&gt;https://github.com/uhlenbrock/passenger-stack&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/asanghi/passenger-stack"&gt;https://github.com/asanghi/passenger-stack&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/thoughtbot/continuous_sprinkles"&gt;https://github.com/thoughtbot/continuous_sprinkles&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</content>
  </entry>
  <entry>
    <title>Review: Zero to Ruby course</title>
    <link href="http://wowkhmer.com/2011/06/19/review-zero-to-ruby-course/" rel="alternate"/>
    <id>http://wowkhmer.com/2011/06/19/review-zero-to-ruby-course/</id>
    <published>2011-06-19T00:00:00Z</published>
    <updated>2011-06-19T00:00:00Z</updated>
    <author>
      <name>Samnang Chhun</name>
    </author>
    <summary type="html">&lt;p&gt;Yesterday, I had a wonderful time in my free Ruby course(&lt;a href="https://github.com/samnang/zero-to-ruby-course"&gt;Zero to Ruby&lt;/a&gt;). There were about 20 participants, and some are having some experiences in Ruby, but some are not. The course started 9:00 to 16:30, so it took about 8 hrs 30 mins&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;Yesterday, I had a wonderful time in my free Ruby course(&lt;a href="https://github.com/samnang/zero-to-ruby-course"&gt;Zero to Ruby&lt;/a&gt;). There were about 20 participants, and some are having some experiences in Ruby, but some are not. The course started 9:00 to 16:30, so it took about 8 hrs 30 mins.&lt;/p&gt;

&lt;p&gt;The course started with letting students go to &lt;a href="http://tryruby.org"&gt;http://tryruby.org&lt;/a&gt; to have some fun with the language, and then go further steps with installation, irb, and using documentation before going to Ruby core classes. After that, we started in the afternoon with code review of students' solution of one exercise from morning, then we went through some importance features in Ruby like Ruby object model, method lookup, duck typing, monkey patching, and basic metaprogramming and DSL. We had some more exercises for afternoon as well, but we didn&amp;rsquo;t have enough for doing them, so I let them to practice on their own time, and send me their solution to let me review it.&lt;/p&gt;

&lt;h2&gt;Course Materials&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://samnang.github.com/zero-to-ruby-course/"&gt;Presentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/samnang/zero-to-ruby-course"&gt;Source of presentation and exercises&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;div align="center"&gt;&lt;object width="550" height="440"&gt; &lt;param name="flashvars" value="offsite=true&amp;lang=en-us&amp;page_show_url=%2Fphotos%2F64218310%40N03%2Fsets%2F72157626996020518%2Fshow%2F&amp;page_show_back_url=%2Fphotos%2F64218310%40N03%2Fsets%2F72157626996020518%2F&amp;set_id=72157626996020518&amp;jump_to="&gt;&lt;/param&gt; &lt;param name="movie" value="http://www.flickr.com/apps/slideshow/show.swf?v=104087"&gt;&lt;/param&gt; &lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;embed type="application/x-shockwave-flash" src="http://www.flickr.com/apps/slideshow/show.swf?v=104087" allowFullScreen="true" flashvars="offsite=true&amp;lang=en-us&amp;page_show_url=%2Fphotos%2F64218310%40N03%2Fsets%2F72157626996020518%2Fshow%2F&amp;page_show_back_url=%2Fphotos%2F64218310%40N03%2Fsets%2F72157626996020518%2F&amp;set_id=72157626996020518&amp;jump_to=" width="550" height="440"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;

</content>
  </entry>
  <entry>
    <title>Zero to Ruby (free course)</title>
    <link href="http://wowkhmer.com/2011/06/12/zero-to-ruby-free-course/" rel="alternate"/>
    <id>http://wowkhmer.com/2011/06/12/zero-to-ruby-free-course/</id>
    <published>2011-06-12T00:00:00Z</published>
    <updated>2011-06-12T00:00:00Z</updated>
    <author>
      <name>Samnang Chhun</name>
    </author>
    <summary type="html">&lt;p&gt;Being a part of Ruby communities, it would be nice to do something interesting, useful, sharing to the communities. So that I decide to run &lt;strong&gt;Zero to Ruby&lt;/strong&gt;(a full day free Ruby course) to help to build and grow local Ruby communities in Cambodia. There are not many Ruby or Rails developers here, but I would like to see it growing&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;Being a part of Ruby communities, it would be nice to do something interesting, useful, sharing to the communities. So that I decide to run &lt;strong&gt;Zero to Ruby&lt;/strong&gt;(a full day free Ruby course) to help to build and grow local Ruby communities in Cambodia. There are not many Ruby or Rails developers here, but I would like to see it growing.&lt;/p&gt;

&lt;h2&gt;Course Overview&lt;/h2&gt;

&lt;p&gt;Date     : Sat 18 Jun 2011, 09:00 &amp;ndash; 17:00&lt;br/&gt;
Fee      : Free&lt;br/&gt;
Location : &lt;a href="http://www.hackerspacepp.org/find-contact-hackerspacepp/"&gt;Hackerspace Phnom Penh&lt;/a&gt;&lt;br/&gt;
Mentor   : Samnang Chhun&lt;/p&gt;

&lt;h2&gt;Course outline&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;TryRuby&lt;/li&gt;
&lt;li&gt;Why you should care learning another programming language&lt;/li&gt;
&lt;li&gt;Installing and running Ruby&lt;/li&gt;
&lt;li&gt;Using and extending the interactive Ruby shell(irb)&lt;/li&gt;
&lt;li&gt;Using Ruby&amp;rsquo;s documentation&lt;/li&gt;
&lt;li&gt;Ruby Core&lt;/li&gt;
&lt;li&gt;Blocks&lt;/li&gt;
&lt;li&gt;Classes and Modules&lt;/li&gt;
&lt;li&gt;Understanding Ruby&amp;rsquo;s method lookup&lt;/li&gt;
&lt;li&gt;Duck Typing and Monkey Patching&lt;/li&gt;
&lt;li&gt;Basic metaprogramming &amp;amp; Domain Specific Language(DSL)&lt;/li&gt;
&lt;li&gt;Code Reading (optional)&lt;/li&gt;
&lt;li&gt;TDD/BDD (optional)&lt;/li&gt;
&lt;li&gt;Fly! Be free!&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Because it&amp;rsquo;s a community course, so you could suggest to change the course&amp;rsquo;s content to match your experiences. See you on that day.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Run only Focus Examples in RSpec like Cucumber</title>
    <link href="http://wowkhmer.com/2011/04/09/run-only-focus-examples-in-rspec-like-cucumber/" rel="alternate"/>
    <id>http://wowkhmer.com/2011/04/09/run-only-focus-examples-in-rspec-like-cucumber/</id>
    <published>2011-04-09T00:00:00Z</published>
    <updated>2011-04-09T00:00:00Z</updated>
    <author>
      <name>Samnang Chhun</name>
    </author>
    <summary type="html">&lt;p&gt;While I am coding using Vim as my editor, I don&amp;rsquo;t know an easy way to run only an example or a group examples of &lt;a href="https://github.com/rspec/rspec-core"&gt;RSpec&lt;/a&gt; that I am working on until RSpec-2 came out. I know we can run &lt;code&gt;spec . -e example&lt;/code&gt; to run only match examples in the previous version, but I feel that&amp;rsquo;s not a friendly way to do it. I like Cucumber&amp;rsquo;s &lt;code&gt;@wip&lt;/code&gt; tag because I can specify on a scenario that I&amp;rsquo;m working on&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;While I am coding using Vim as my editor, I don&amp;rsquo;t know an easy way to run only an example or a group examples of &lt;a href="https://github.com/rspec/rspec-core"&gt;RSpec&lt;/a&gt; that I am working on until RSpec-2 came out. I know we can run &lt;code&gt;spec . -e example&lt;/code&gt; to run only match examples in the previous version, but I feel that&amp;rsquo;s not a friendly way to do it. I like Cucumber&amp;rsquo;s &lt;code&gt;@wip&lt;/code&gt; tag because I can specify on a scenario that I&amp;rsquo;m working on.&lt;/p&gt;

&lt;p&gt;Thank for RSpec team for implementing a cool feature to be able filtering examples that we want to focus on while we are writing with tests.&lt;/p&gt;

&lt;script src="https://gist.github.com/911474.js?file=spec_helper.rb"&gt;&lt;/script&gt;


&lt;p&gt;&lt;noscript&gt;
&lt;code&gt;spec_helper.rb&lt;/code&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# ...

RSpec.configure do |c|
  c.filter_run :focus =&amp;gt; true
  c.run_all_when_everything_filtered = true
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;/noscript&gt;&lt;/p&gt;

&lt;script src="https://gist.github.com/911474.js?file=filtering_examples_spec.rb"&gt;&lt;/script&gt;


&lt;p&gt;&lt;noscript&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;require "spec_helper"

describe "group 1" do
  it "group 1 example 1", :focus =&amp;gt; true do
  end

  it "group 1 example 2" do
  end
end

describe "group 2" do
  it "group 2 example 1" do
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;/noscript&gt;
Run the tests to see the output:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ rspec .
Run filtered using {:focus=&amp;gt;true}
.

Finished in 0.00026 seconds
1 example, 0 failures
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;After you passed the focus example(s), then you will want to run all examples, you could do it by just removing &lt;code&gt;:focus =&amp;gt; true&lt;/code&gt; from you example(s):&lt;/p&gt;

&lt;script src="https://gist.github.com/911474.js?file=examples_spec.rb"&gt;&lt;/script&gt;


&lt;p&gt;&lt;noscript&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;require "spec_helper"

describe "group 1" do
  it "group 1 example 1" do
  end

  it "group 1 example 2" do
  end
end

describe "group 2" do
  it "group 2 example 1" do
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;/noscript&gt;
Then rerun the tests, you will see the output of all tests:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ rspec .
No examples were matched by {:focus=&amp;gt;true}, running all
...

Finished in 0.00048 seconds
3 examples, 0 failures
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I would suggest you take a look at &lt;a href="http://relishapp.com/rspec/rspec-core/v/2-5/dir/command-line/tag-option"&gt;&lt;code&gt;--tag option&lt;/code&gt;&lt;/a&gt; as well.&lt;/p&gt;
</content>
  </entry>
</feed>

