<?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>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>
  <entry>
    <title>Zero to Ruby at OpenTechTalk</title>
    <link href="http://wowkhmer.com/2011/01/16/zero-to-ruby-at-opentechtalk/" rel="alternate"/>
    <id>http://wowkhmer.com/2011/01/16/zero-to-ruby-at-opentechtalk/</id>
    <published>2011-01-16T00:00:00Z</published>
    <updated>2011-01-16T00:00:00Z</updated>
    <author>
      <name>Samnang Chhun</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; My slide is available &lt;a href="http://zero-to-ruby.heroku.com/"&gt;here&lt;/a&gt; and &lt;a href="https://github.com/samnang/zero-to-ruby"&gt;source&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.sharevisionteam.org/opentechtalk/"&gt;OpenTechTalk&lt;/a&gt; is coming on 22th Jan, I will give a talk about &lt;strong&gt;Zero to Ruby&lt;/strong&gt;. Last month, I already gave a talk on &lt;a href="/2010/12/29/why-i-love-ruby-better-than-x/"&gt;Why I love Ruby better than X&lt;/a&gt; at &lt;a href="http://www.sharevisionteam.org/devcamp/"&gt;DevCamp&lt;/a&gt;. Because Ruby communities in Cambodia are not so popular, and many people don&amp;rsquo;t know even it exists. So I decide in the talk, I will give some introduction to Ruby, how to learn it, and some effective ways to learn it&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; My slide is available &lt;a href="http://zero-to-ruby.heroku.com/"&gt;here&lt;/a&gt; and &lt;a href="https://github.com/samnang/zero-to-ruby"&gt;source&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.sharevisionteam.org/opentechtalk/"&gt;OpenTechTalk&lt;/a&gt; is coming on 22th Jan, I will give a talk about &lt;strong&gt;Zero to Ruby&lt;/strong&gt;. Last month, I already gave a talk on &lt;a href="/2010/12/29/why-i-love-ruby-better-than-x/"&gt;Why I love Ruby better than X&lt;/a&gt; at &lt;a href="http://www.sharevisionteam.org/devcamp/"&gt;DevCamp&lt;/a&gt;. Because Ruby communities in Cambodia are not so popular, and many people don&amp;rsquo;t know even it exists. So I decide in the talk, I will give some introduction to Ruby, how to learn it, and some effective ways to learn it.&lt;/p&gt;

&lt;p&gt;See you there together.&lt;/p&gt;

&lt;div style="text-align: center;"&gt;&lt;img src="http://img.skitch.com/20110116-8nafsc7ck9657jhwaa2t3jewp4.preview.jpg" alt="OpenTechTalk" /&gt;&lt;/div&gt;

</content>
  </entry>
  <entry>
    <title>Different ways to define singleton methods in Ruby</title>
    <link href="http://wowkhmer.com/2011/01/15/different-ways-to-define-singleton-methods-in-ruby/" rel="alternate"/>
    <id>http://wowkhmer.com/2011/01/15/different-ways-to-define-singleton-methods-in-ruby/</id>
    <published>2011-01-15T00:00:00Z</published>
    <updated>2011-01-15T00:00:00Z</updated>
    <author>
      <name>Samnang Chhun</name>
    </author>
    <summary type="html">&lt;p&gt;As we know from &lt;a href="http://www.artima.com/intv/rubyP.html"&gt;The Philosophy of Ruby&lt;/a&gt;, Ruby inherited the Perl philosophy of having more than one way to do the same thing. So that, there are many ways to define &lt;a href="http://www.rubyist.net/~slagell/ruby/singletonmethods.html"&gt;singleton methods&lt;/a&gt; in Ruby&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;As we know from &lt;a href="http://www.artima.com/intv/rubyP.html"&gt;The Philosophy of Ruby&lt;/a&gt;, Ruby inherited the Perl philosophy of having more than one way to do the same thing. So that, there are many ways to define &lt;a href="http://www.rubyist.net/~slagell/ruby/singletonmethods.html"&gt;singleton methods&lt;/a&gt; in Ruby.&lt;/p&gt;

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


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

&lt;pre&gt;&lt;code&gt;##############################################
# Different ways to define singleton methods #
##############################################

def test_singleton_method
  animal = 'dog'

  yield animal

  puts animal.speak
end

#=============================================

test_singleton_method do |dog|
  def dog.speak
    "Woof!"
  end
end

test_singleton_method do |dog|
  dog.instance_eval do
    def speak
      "Woof!"
    end
  end
end

test_singleton_method do |dog|
  class &amp;lt;&amp;lt; dog
    def speak
      "Woof!"
    end
  end
end

test_singleton_method do |dog|
  class &amp;lt;&amp;lt; dog
    define_method(:speak) do
      "Woof!"
    end
  end
end

test_singleton_method do |dog|
  class &amp;lt;&amp;lt; dog
    define_method(:speak, lambda { "Woof!" })
  end
end

test_singleton_method do |dog|
  module SpeakableDog
    def speak
      "Woof!"
    end
  end

  class &amp;lt;&amp;lt; dog
    include SpeakableDog
  end
end

test_singleton_method do |dog|
  module SpeakableDog
    def speak
      "Woof!"
    end
  end

  dog.extend SpeakableDog
end

#================ Ruby 1.9.2 ====================

test_singleton_method do |dog|
  module SpeakableDog
    def speak
      "Woof!"
    end
  end

  dog.singleton_class.send(:include, SpeakableDog)
end

test_singleton_method do |dog|
  dog.singleton_class.class_eval do
    def speak
      "Woof!"
    end
  end
end

test_singleton_method do |dog|
  dog.singleton_class.send(:define_method, :speak) do
    "Woof!"
  end
end

test_singleton_method do |dog|
  dog.define_singleton_method(:speak) do
    "Woof!"
  end
end

test_singleton_method do |dog|
  dog.singleton_class.send(:define_method, :speak, lambda { "Woof!" })
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;/noscript&gt;
Do you get any other ways to define singleton methods?&lt;/p&gt;
</content>
  </entry>
</feed>

