<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/rss2full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><!-- generator="wordpress/2.3.1" --><rss 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/" version="2.0">

<channel>
	<title>michael galero</title>
	<link>http://devblog.michaelgalero.com</link>
	<description>A developer\'s blog</description>
	<pubDate>Thu, 22 May 2008 07:59:02 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/michaelgalerodevblog" type="application/rss+xml" /><item>
		<title>Metaprogramming Talk</title>
		<link>http://devblog.michaelgalero.com/2008/05/22/metaprogramming-talk/</link>
		<comments>http://devblog.michaelgalero.com/2008/05/22/metaprogramming-talk/#comments</comments>
		<pubDate>Thu, 22 May 2008 07:42:34 +0000</pubDate>
		<dc:creator>mikong</dc:creator>
		
		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[metaprogramming]]></category>

		<category><![CDATA[ruby2ruby]]></category>

		<guid isPermaLink="false">http://devblog.michaelgalero.com/2008/05/22/metaprogramming-talk/</guid>
		<description><![CDATA[
I&#8217;d like to thank everyone who attended the Philippine Ruby Users Group (PHRUG) May &#8216;08 Meetup and listened to my over-2-hour talk on Metaprogramming. Thanks for the patience, for not sleeping (or not making it obvious), and for those wonderful questions. It&#8217;s tough discussing the object model of Ruby when terms are repeated like &#8216;the [...]]]></description>
			<content:encoded><![CDATA[<p>
I&#8217;d like to thank everyone who attended the Philippine Ruby Users Group (PHRUG) May &#8216;08 Meetup and listened to my over-2-hour talk on Metaprogramming. Thanks for the patience, for not sleeping (or not making it obvious), and for those wonderful questions. It&#8217;s tough discussing the object model of Ruby when terms are repeated like &#8216;the superclass of the metaclass of the Ninja class is the metaclass of the Object class&#8217;. I literally had a headache after the talk.
</p>
<h3>Talks</h3>
<p>
As I mentioned, my talk was largely based off of <a href="http://www.infoq.com/presentations/metaprogramming-ruby">Dave Thomas&#8217; &#8220;Metaprogramming&#8221; talk</a> in QCon London &#8216;06 and <a href="http://mwrc2008.confreaks.com/11farley.html">Patrick Farley&#8217;s &#8220;Ruby Internals&#8221; talk</a> in the MountainWest Ruby Conference (MWRubyConf) &#8216;08. Click on the links to see/download their presentations.
</p>
<p>
There are <a href="http://mwrc2008.confreaks.com/">other talks related to metaprogramming in MWRubyConf &#8216;08</a> like those by Giles Bowkett, Jeremy McAnally, and Joe O&#8217;Brien. Or just go to the <a href="http://www.confreaks.com/">Confreaks site</a> to check other cool talks on Ruby.
</p>
<h3>Coding Session</h3>
<p>
I had a problem with Ruby2Ruby.translate at one point in the coding session. I&#8217;ve just confirmed what was pointed out to me. Indeed, Ruby2Ruby couldn&#8217;t translate a class without a method definition. What you all wanted to see was what would this:
</p>
<pre>
  module Taijutsu
    def punch
      puts 'punch'
    end
  end

  class Ninja
    include Taijutsu
  end
</pre>
<p>
look like when Ninja is translated using Ruby2Ruby. Here it is:
</p>
<pre>
  class Ninja &lt; Object
    def punch
      puts 'punch'
    end
  end
</pre>
<p>
Unfortunately, Ruby2Ruby won&#8217;t show an include call, as a lot of you had hoped.
</p>
<h3>Slides</h3>
<p>
I&#8217;ve uploaded the pdf of my slides at the <a href="http://groups.google.com/group/ruby-phil/files">Files section of our PHRUG Google Group</a>. But you might be better off watching the talks I mentioned above.
</p>
<p>
Minor note: I used back quotes in my slides to refer to singleton classes and metaclasses. I thought this was the standard but looks like it&#8217;s not. Patrick Farley used the normal single quotes before the names in his slides. The pickaxe book used single quotes after the class name (for metaclass) and &#8216;anon&#8217; which means anonymous class (to refer to the singleton classes and include classes of modules).
</p>
<h3>Thanks</h3>
<p>
Thanks again! If you enjoyed my talk, you might want to <a href="http://workingwithrails.com/recommendation/new/person/8924-michael-galero">recommend me at Working with Rails</a>. And you might want to check out this article by <a href="http://ola-bini.blogspot.com/2008/05/dynamically-created-methods-in-ruby.html">Ola Bini on Dynamically created methods in Ruby</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://devblog.michaelgalero.com/2008/05/22/metaprogramming-talk/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Ruby 1.9 Hash in Ruby 1.8</title>
		<link>http://devblog.michaelgalero.com/2008/04/03/ruby-19-hash-in-ruby-18/</link>
		<comments>http://devblog.michaelgalero.com/2008/04/03/ruby-19-hash-in-ruby-18/#comments</comments>
		<pubDate>Thu, 03 Apr 2008 08:52:01 +0000</pubDate>
		<dc:creator>mikong</dc:creator>
		
		<category><![CDATA[Open Source]]></category>

		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[metaprogramming]]></category>

		<category><![CDATA[point2]]></category>

		<guid isPermaLink="false">http://devblog.michaelgalero.com/2008/04/03/ruby-19-hash-in-ruby-18/</guid>
		<description><![CDATA[ I&#8217;m learning about Ruby 1.9 features but I realized I won&#8217;t be able to use it in any of my projects. So I thought of an exercise where I learn Ruby metaprogramming by trying to implement some of Ruby 1.9&#8217;s new functionality. Aside from learning metaprogramming and Ruby 1.9, I&#8217;d also end up with [...]]]></description>
			<content:encoded><![CDATA[<p> I&#8217;m learning about Ruby 1.9 features but I realized I won&#8217;t be able to use it in any of my projects. So I thought of an exercise where I learn Ruby metaprogramming by trying to implement some of Ruby 1.9&#8217;s new functionality. Aside from learning metaprogramming and Ruby 1.9, I&#8217;d also end up with a <a href="http://github.com/mikong/point2">library</a> that I can use in my Ruby 1.8 projects.</p>
<p>But first, let me introduce&#8230;</p>
<h3>The new Hash</h3>
<p>We have an alternative hash syntax in Ruby 1.9:</p>
<pre>
  # old way that still works in Ruby 1.9
  my_hash = { :a =&gt; 'apple', :b =&gt; 'banana' }

  # new way
  my_hash = { a: 'apple', b: 'banana' }</pre>
<p>A nice addition in Ruby 1.9 is that the order in which you added the items to a hash is remembered and will be used when the hash is iterated.</p>
<p>There&#8217;s also a new class method try_convert where if you call</p>
<pre>
  Hash.try_convert(myobject)</pre>
<p>myobject&#8217;s to_hash method will be called to return a hash. If there&#8217;s no to_hash, nil will be returned.</p>
<p>And then we have these new instance methods (a few were simply borrowed from the Array class): assoc, compare_by_identity, compare_by_identity?, flatten, key and rassoc.</p>
<h3>Trying Metaprogramming</h3>
<p>Let&#8217;s first try to implement the try_convert class method. Luckily, <a href="http://ozmm.org/posts/try.html">Chris Wanstrath&#8217;s try() article</a> gave us something we could use:</p>
<pre>
class Object
  ##
  #   @person ? @person.name :nil
  # vs
  #   @person.try(:name)
  def try(method)
    send method if respond_to? method
  end
end</pre>
<p>By building on his code above, we could do this:</p>
<pre>
class Hash
  def self.try_convert(obj)
    obj.try(:to_hash)
  end
end</pre>
<p>Looking at that, I&#8217;m starting to think Ruby 1.9 should have included the try() method instead of providing try_convert(). But that&#8217;s beside the point of this exercise.</p>
<p>Let&#8217;s try the simple instance method flatten. The documentation said it converts the hash to an array, then invokes Array#flatten! on the result. So it seems to be simply this:</p>
<pre>
class Hash
  ...
  def flatten
    to_a.flatten!
  end
end</pre>
<p>But looking closer there&#8217;s actually a depth parameter (default is 1 - or so it seems but it behaves like -1 in my version of Ruby 1.9) demonstrated in the documentation&#8217;s example:</p>
<pre>
h = { feline: [ "felix", "tom"], :equine: "ed" }
h.flatten    # =&gt; [:feline, ["felix", "tom"], :equine, "ed"]
h.flatten(1) # =&gt; [:feline, ["felix", "tom"], :equine, "ed"]
h.flatten(2) # =&gt; [:feline, "felix", "tom", :equine, "ed"]</pre>
<p>It turns out that the flatten and flatten! methods in Ruby 1.9 Array has also changed with a new level parameter. The default value of -1 makes it behave like the original (i.e. it recursively flattens the array). A level value of 0 performs no flattening and a level greater than zero flattens only to that depth (like the depth parameter in the Hash#flatten example above).</p>
<p>The flatten method we implemented above works fine. If you want the depth parameter, I&#8217;ve added it by first redefining the flatten method in Array, and then just calling that from the flatten method in Hash. You could head over to my <a href="http://github.com/mikong/point2">GitHub repository</a> to see the code. The simple project also implements some Ruby 1.9 Time class methods (sunday?, monday?, etc) using the method_missing trick. And I&#8217;ll continue to play around with Ruby 1.9 and metaprogramming so you could expect more Ruby 1.9 features in Ruby 1.8. The idea is not to port Ruby 1.9 to Ruby 1.8 (that would be crazy!), but to try stuff so some weird things may also crop up.</p>
]]></content:encoded>
			<wfw:commentRss>http://devblog.michaelgalero.com/2008/04/03/ruby-19-hash-in-ruby-18/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Grails and Rails</title>
		<link>http://devblog.michaelgalero.com/2008/02/12/grails-and-rails/</link>
		<comments>http://devblog.michaelgalero.com/2008/02/12/grails-and-rails/#comments</comments>
		<pubDate>Tue, 12 Feb 2008 18:07:21 +0000</pubDate>
		<dc:creator>mikong</dc:creator>
		
		<category><![CDATA[Rails]]></category>

		<category><![CDATA[datamapper]]></category>

		<category><![CDATA[grails]]></category>

		<category><![CDATA[groovy]]></category>

		<category><![CDATA[hsqldb]]></category>

		<category><![CDATA[java]]></category>

		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://devblog.michaelgalero.com/2008/02/12/grails-and-rails/</guid>
		<description><![CDATA[ I didn&#8217;t like the idea of checking out Grails. I mean if I&#8217;m already a Rails developer, why bother checking a copycat. That&#8217;s why I&#8217;m surprised I found things I liked about it. But will I leave Ruby on Rails for it? This article is about my first impressions of Grails after reading the [...]]]></description>
			<content:encoded><![CDATA[<p> I didn&#8217;t like the idea of checking out <a href="http://grails.org">Grails</a>. I mean if I&#8217;m already a Rails developer, why bother checking a copycat. That&#8217;s why I&#8217;m surprised I found things I liked about it. But will I leave Ruby on Rails for it? This article is about my first impressions of Grails after reading the book <a href="http://www.infoq.com/minibooks/grails">Getting Started with Grails</a>, sections of their <a href="http://grails.org/doc/1.0.x/">online documentation</a> and some Grails-related articles.</p>
<h3>Some Good Stuff</h3>
<p>After you run &#8216;grails run-app&#8217; (the equivalent of &#8217;script/server&#8217; in Rails) you can access your application with the URL http://localhost:8080/app_name and get a &#8216;Welcome to Grails&#8217; page. It&#8217;s a minor thing but I like having the application name in there. When you type your application URL by hand in the address bar and you&#8217;re shown the cached URLs, it looks more organized. Multiple Grails applications can run together without having to reconfigure URLs. The Welcome page also includes links to the index page of each of your controller so that&#8217;s another nice addition. (Note: The URLs to the other pages of a Grails application is accessed by appending controller/action/id to the URL, just like Rails.)</p>
<p>Grails ships with <a href="http://www.hsqldb.org/">HSQLDB</a> which makes playing with simple applications really easy. You can create your app at the start without thinking about the database. Of course, your data won&#8217;t persist this way because HSQLDB stores your data in memory, but I don&#8217;t really care about that when I&#8217;m just playing around. In Rails 2.0.2, the default DB was changed to SQLite3 so you don&#8217;t have to setup your database but you need SQLite3. In Grail&#8217;s HSQLDB, you only need Java which you should already have if you&#8217;re using Grails.</p>
<p>In Grails, models are &#8216;domain classes&#8217;. Grails domain classes remind me of <a href="http://datamapper.org/">DataMapper, the Ruby ORM</a>. You list down the properties of the domain in the class, and the framework generates the table with these columns in the database. So instead of adding a column through a migration, just add a property in your domain class. You won&#8217;t need an Annotate Models plugin here.</p>
<p>And there are other nice things in Grails. Because Grails is on top of Java, you have i18n support out of the box. The Grails tag library is also a clean approach to views.</p>
<h3>Some Bad Stuff</h3>
<p>I have a few issues with Grails defaults. The first problem I had with Grails is that the generated DB columns are required or cannot be NULL. You need to declare in your domain class the columns that are optional. I don&#8217;t really get this because in most of the applications I&#8217;ve worked with, there are more optional columns than required ones. Also, I&#8217;m the type of Rails developer that avoids adding constraints in the DB unless I have to. If my application is the only thing that accesses my database, then I&#8217;ll put my constraints in one place, the application-side.</p>
<p>One of the many little things I like about Rails is if you have created_at and updated_at columns, they are automatically set when you save a record. You also have the timestamps method added in your generated model migration by default that adds these 2 columns. In Grails, you need to specify a createdAt property in your domain class, and set it manually to new Date().</p>
<p>In contrast to Rails, Grails controllers do not extend an application controller by default. It&#8217;s a minor thing but I would probably need to extend it manually for every Grails application I write, hypothetically speaking.</p>
<p>In Grails, you&#8217;re not supposed to need to restart your server when you make changes. But this is not entirely true. When you add static constraints to your domain classes, add new messages, or a new Java class, you still need to restart. For Java developers, it&#8217;s better than having to build and deploy a WAR file every time, but it&#8217;s still a bit irritating to me.</p>
<p>You can mix Java and Groovy in your Grails application. This can be good in a lot of ways but I think it can also be bad. Java developers working on a Grails application may be tempted to use their old, inefficient ways instead of taking the leap to Groovy. Or when Groovy doesn&#8217;t support a Java construct a Java developer is used to, you end up with verbose code, like the search implementation in the Getting Started with Grails book (see Working with Java Classes starting at page 63). This was particularly disturbing and made me think: if Java always has Groovy&#8217;s back, Groovy might depend on Java too much.</p>
<h3>It&#8217;s Really the Syntax</h3>
<p>My issues with Grails so far are minor but the thing for me is: Ruby/Rails syntax is just more beautiful than Java/Groovy/Grails syntax.</p>
<p>Mapping a has_many association in Rails:</p>
<pre>
  has_many :registrations</pre>
<p>In Grails:</p>
<pre>
  static hasMany = [registrations:Registration]</pre>
<p>Adding a before filter in your controller in Rails:</p>
<pre>
  before_filter :auth, :except =&gt; 'search'</pre>
<p>In Grails:</p>
<pre>
  def beforeInterceptor = [action:this.&amp;auth, except:['search']]</pre>
<h3>The end of Rails?</h3>
<p>I won&#8217;t be surprised if Grails becomes more popular than Rails but only because Java is currently the most popular language in the industry (based on <a href="http://www.tiobe.com/tpci.htm">TIOBE</a>). Grails is for Java developers who don&#8217;t want to leave their comfort zone. It offers something a lot better than the current Java web frameworks and that&#8217;s a good thing. But I like Rails better; I might only consider Grails if I have to integrate with Java. And I prefer Ruby over Groovy. Groovy is the dynamic language that looks like Java so that Java developers have an easier transition. That has a cost though, and one may be that it will never be as beautiful as Ruby.</p>
]]></content:encoded>
			<wfw:commentRss>http://devblog.michaelgalero.com/2008/02/12/grails-and-rails/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Web Developer v2</title>
		<link>http://devblog.michaelgalero.com/2007/12/31/web-developer-v2/</link>
		<comments>http://devblog.michaelgalero.com/2007/12/31/web-developer-v2/#comments</comments>
		<pubDate>Mon, 31 Dec 2007 17:03:34 +0000</pubDate>
		<dc:creator>mikong</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://devblog.michaelgalero.com/2007/12/31/web-developer-v2/</guid>
		<description><![CDATA[ As a web developer, it was a year full of changes. My OS for work before was Windows 2000, now it&#8217;s Mac OS X. I used Java and a proprietary web framework and now I mainly program with Ruby and Ruby on Rails. I used a proprietary javascript framework, and now Prototype. I primarily [...]]]></description>
			<content:encoded><![CDATA[<p> As a web developer, it was a year full of changes. My OS for work before was Windows 2000, now it&#8217;s Mac OS X. I used Java and a proprietary web framework and now I mainly program with <a href="http://ruby-lang.org/">Ruby</a> and <a href="http://www.rubyonrails.org/">Ruby on Rails</a>. I used a proprietary javascript framework, and now <a href="http://www.prototypejs.org/">Prototype</a>. I primarily used Eclipse as my IDE, now I use <a href="http://macromates.com/">TextMate</a> (I used emacs for about a month). My database was Oracle, now it&#8217;s <a href="http://dev.mysql.com/">MySQL</a> or <a href="http://www.postgresql.org/">PostgreSQL</a>. From CVS to <a href="http://svnbook.red-bean.com/">SVN</a>, and recently using <a href="http://git.or.cz/">Git</a> on personal projects. That&#8217;s changes to my OS, programming language, web framework, IDE, database and version control system. And here&#8217;s more&#8230;</p>
<p>From the waterfall software development model to agile software development. And from working with large teams (of 20 to 50 or more) for more than a year on each project to a small team (of 1 to 4) working on 2 week iterations (see <a href="http://en.wikipedia.org/wiki/Scrum_(development)">Scrum</a>). And as described in this <a href="http://devblog.michaelgalero.com/2007/11/27/a-journey-with-dvorak-so-far/">older article</a>, I switched my keyboard layout from QWERTY to <a href="http://en.wikipedia.org/wiki/Dvorak_Simplified_Keyboard">Dvorak</a> a few months back.</p>
<p>I didn&#8217;t test a year ago. Instead, I passed my code to software testers. I&#8217;ve heard of JUnit but never used it. Now, I&#8217;m learning <a href="http://behaviour-driven.org/">BDD</a> with <a href="http://rspec.info/">RSpec</a>.</p>
<p>There are also other changes like starting this development blog, participating in the <a href="http://groups.google.com/group/ruby-phil">Philippine Ruby Users Group</a>, and <a href="http://dev.rubyonrails.org/">contributing to Rails</a>. Using newer releases like Ruby 1.9 (only for playing around though) and Rails 2.0 for my new projects. From Ubuntu Dapper to Gutsy (I skipped Edgy Eft and Feisty Fawn). Et cetera.</p>
<p>2007 was fun! And I&#8217;m curious how this article will look like a year from now. <img src='http://devblog.michaelgalero.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://devblog.michaelgalero.com/2007/12/31/web-developer-v2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Learning Ruby 1.9</title>
		<link>http://devblog.michaelgalero.com/2007/12/25/learning-ruby-19/</link>
		<comments>http://devblog.michaelgalero.com/2007/12/25/learning-ruby-19/#comments</comments>
		<pubDate>Tue, 25 Dec 2007 20:25:07 +0000</pubDate>
		<dc:creator>mikong</dc:creator>
		
		<category><![CDATA[Rails]]></category>

		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://devblog.michaelgalero.com/2007/12/25/learning-ruby-19/</guid>
		<description><![CDATA[
I&#8217;m not going to list down &#8220;improve Ruby skills&#8221; on my New Year&#8217;s resolution. With the newly released Ruby 1.9.0 (a development release) and beta book Programming Ruby 3 by Dave Thomas (or simply Pickaxe 3), what better time to dig deeper into Ruby than now?


When I setup Rails on my mac a few months [...]]]></description>
			<content:encoded><![CDATA[<p>
I&#8217;m not going to list down &#8220;improve Ruby skills&#8221; on my New Year&#8217;s resolution. With the <a href="http://www.ruby-lang.org/en/news/2007/12/25/ruby-1-9-0-released/">newly released Ruby 1.9.0</a> (a development release) and <a href="http://pragprog.com/titles/ruby3">beta book Programming Ruby 3 by Dave Thomas</a> (or simply Pickaxe 3), what better time to dig deeper into Ruby than now?
</p>
<p>
When I setup Rails on my mac a few months back (before Leopard and Rails 2.0), I followed <a href="http://hivelogic.com/articles/ruby-rails-mongrel-mysql-osx/">Building Ruby, Rails, Subversion, Mongrel, and MySQL on Mac OS X</a> by <a href="hivelogic.com">Hivelogic</a>. Following the Ruby part of that but updated for Ruby 1.9:
</p>
<pre>
  cd /usr/local
  sudo curl -O  ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.0-0.tar.gz
  sudo tar xzvf ruby-1.9.0-0.tar.gz
  cd ruby-1.9.0-0
  sudo ./configure --prefix=/usr/local/ruby-1.9.0 --enable-pthread --with-readline-dir=/usr/local
  sudo make
  sudo make install
</pre>
<p>
I didn&#8217;t have to run &#8216;make install-doc&#8217; because &#8216;make install&#8217; already installed the documentation. Since I haven&#8217;t upgraded to Leopard yet, this has only been verified on Tiger. Running &#8216;/usr/local/ruby-1.9.0/bin/ruby -v&#8217;, I got
</p>
<pre>
  ruby 1.9.0 (2007-12-25 revision 14709) [i686-darwin8.11.1]
</pre>
<p>
Cool! And I just bought Pickaxe 3 (right after installing). Looking for the first 1.9 feature I can find in the book&#8230; a new hash syntax:
</p>
<pre>
  $ /usr/local/ruby-1.9.0/bin/irb
  irb(main):001:0&gt; inst_section = { cello: 'string', clarinet: 'woodwind' }
  =&gt; {:cello=&gt;"string", :clarinet=&gt;"woodwind"}
  irb(main):002:0&gt; inst_section[:clarinet]
  =&gt; "woodwind"
</pre>
<p>
It works! And let me just add that new hash syntax looks gorgeous. Now I have to end this article and try a 1.9 feature beyond mere syntax updates. <b>Chapter 11: Fibers, Threads, and Processes</b> looks like a good place to start&#8230; <img src='http://devblog.michaelgalero.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>
<b>Update 12/26/2007:</b> I initially installed Ruby 1.9 on /usr/local. It installed rubygems 1.0.1 with it and messed up my gem installation for 1.8.6. I had to reinstall 1.8.6, and then reinstall ruby 1.9 in an isolated directory, /usr/local/ruby-1.9.0. I updated the article to use this directory. For now, I only use 1.9 to try the new features. If you need to work with multiple versions of Ruby, you might want to check out <a href="http://www.dcmanges.com/blog/install-multiple-versions-of-ruby-on-osx-leopard">Dan Manges&#8217; article</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://devblog.michaelgalero.com/2007/12/25/learning-ruby-19/feed/</wfw:commentRss>
		</item>
		<item>
		<title>My Git notes for Rails</title>
		<link>http://devblog.michaelgalero.com/2007/12/17/my-git-notes-for-rails/</link>
		<comments>http://devblog.michaelgalero.com/2007/12/17/my-git-notes-for-rails/#comments</comments>
		<pubDate>Mon, 17 Dec 2007 16:17:45 +0000</pubDate>
		<dc:creator>mikong</dc:creator>
		
		<category><![CDATA[Rails]]></category>

		<category><![CDATA[giston]]></category>

		<category><![CDATA[git]]></category>

		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://devblog.michaelgalero.com/2007/12/17/my-git-notes-for-rails/</guid>
		<description><![CDATA[From Toolman Tim&#8217;s blog entry Setting up a new Rails app with Git (with a few changes, and summarized for personal reference).

$ git init
$ mate .gitignore

Add in .gitignore:

log/*.log
tmp/**/*
.DS_Store
doc/api
doc/app
config/database.yml
db/schema.rb

Back to the command line:

$ cp config/database.yml config/database.yml.example
$ touch log/.gitignore
$ touch tmp/.gitignore
$ git add .
$ git commit -m "Initial commit"

Additional Notes:

Git Tutorial Intro
Git User&#8217;s Manual
Everyday GIT with 20 [...]]]></description>
			<content:encoded><![CDATA[<p>From Toolman Tim&#8217;s blog entry <a href="http://toolmantim.com/article/2007/12/5/setting_up_a_new_rails_app_with_git">Setting up a new Rails app with Git</a> (with a few changes, and summarized for personal reference).</p>
<pre>
$ git init
$ mate .gitignore
</pre>
<p>Add in .gitignore:</p>
<pre>
log/*.log
tmp/**/*
.DS_Store
doc/api
doc/app
config/database.yml
db/schema.rb
</pre>
<p>Back to the command line:</p>
<pre>
$ cp config/database.yml config/database.yml.example
$ touch log/.gitignore
$ touch tmp/.gitignore
$ git add .
$ git commit -m "Initial commit"
</pre>
<h3>Additional Notes:</h3>
<ul>
<li><a href="http://www.kernel.org/pub/software/scm/git/docs/tutorial.html">Git Tutorial Intro</a></li>
<li><a href="http://www.kernel.org/pub/software/scm/git/docs/user-manual.html">Git User&#8217;s Manual</a></li>
<li><a href="http://www.kernel.org/pub/software/scm/git/docs/everyday.html">Everyday GIT with 20 Commands or so</a></li>
<li><a href="http://wiki.sourcemage.org/Git_Guide">SourceMage&#8217;s Git Guide</a></li>
<li>To manage edge rails, use <a href="http://evil.che.lu/2007/11/27/ann-giston-piston-lookalike-for-git">Giston</a> or just delete and re-export (taken from the comments of the blog entry).</li>
<li>Touch empty dirs (thanks to <a href="http://www.midlandswebdesign.com/">Nick Poulden</a>&#8217;s comment):</li>
</ul>
<pre>
  find . \( -type d -empty \) -and \( -not -regex ./\.git.* \) -exec touch {}/.gitignore \;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://devblog.michaelgalero.com/2007/12/17/my-git-notes-for-rails/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Blogging From TextMate, and RubyConf 2007 videos</title>
		<link>http://devblog.michaelgalero.com/2007/12/13/blogging-from-textmate-and-rubyconf-2007-videos/</link>
		<comments>http://devblog.michaelgalero.com/2007/12/13/blogging-from-textmate-and-rubyconf-2007-videos/#comments</comments>
		<pubDate>Thu, 13 Dec 2007 04:48:54 +0000</pubDate>
		<dc:creator>mikong</dc:creator>
		
		<category><![CDATA[Blogging]]></category>

		<category><![CDATA[Rails]]></category>

		<category><![CDATA[confreaks]]></category>

		<category><![CDATA[jottit]]></category>

		<category><![CDATA[markdown]]></category>

		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[rubyconf2007]]></category>

		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://devblog.michaelgalero.com/2007/12/13/blogging-from-textmate-and-rubyconf-2007-videos/</guid>
		<description><![CDATA[This is a test post following an old TextMate screencast demonstrating the blogging bundle.
]]></description>
			<content:encoded><![CDATA[<p>This is a test post following an old <a href="http://macromates.com/screencast/blogging_take_two.mov">TextMate screencast</a> demonstrating the blogging bundle.</p>
<p> <a href="http://devblog.michaelgalero.com/2007/12/13/blogging-from-textmate-and-rubyconf-2007-videos/#more-11" class="more-link">(more&#8230;)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://devblog.michaelgalero.com/2007/12/13/blogging-from-textmate-and-rubyconf-2007-videos/feed/</wfw:commentRss>
<enclosure url="http://macromates.com/screencast/blogging_take_two.mov" length="31736069" type="video/quicktime" />
		</item>
		<item>
		<title>PHRUG’s 2nd Rails Coding Session</title>
		<link>http://devblog.michaelgalero.com/2007/12/07/phrugs-2nd-rails-coding-session/</link>
		<comments>http://devblog.michaelgalero.com/2007/12/07/phrugs-2nd-rails-coding-session/#comments</comments>
		<pubDate>Fri, 07 Dec 2007 19:03:23 +0000</pubDate>
		<dc:creator>mikong</dc:creator>
		
		<category><![CDATA[Rails]]></category>

		<category><![CDATA[conference]]></category>

		<category><![CDATA[datamapper]]></category>

		<category><![CDATA[event]]></category>

		<category><![CDATA[gems]]></category>

		<category><![CDATA[hosting]]></category>

		<category><![CDATA[PHRUG]]></category>

		<category><![CDATA[plugins]]></category>

		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[sinatra]]></category>

		<guid isPermaLink="false">http://devblog.michaelgalero.com/2007/12/07/phrugs-2nd-rails-coding-session/</guid>
		<description><![CDATA[Last Wednesday, I attended the 2nd Rails Coding Session of the Philippine Ruby Users Group (PHRUG). The small, informal gathering was planned for writing Rails apps with plugins like acts_as_solr, memcached, etc. None of us wrote a single line of code. Instead, we discussed several Rails and Ruby topics and gathered ideas for future Rails [...]]]></description>
			<content:encoded><![CDATA[<p>Last Wednesday, I attended the 2nd Rails Coding Session of the Philippine Ruby Users Group (PHRUG). The small, informal gathering was planned for writing Rails apps with plugins like acts_as_solr, memcached, etc. None of us wrote a single line of code. Instead, we discussed several Rails and Ruby topics and gathered ideas for future Rails events.</p>
<p>Some of the topics discussed were:</p>
<ul>
<li><a href="http://topfunky.com/clients/peepcode/REST-cheatsheet.pdf" title="REST cheatsheet pdf from Peepcode">RESTful Rails<br />
</a></li>
<li><a href="http://datamapper.org/" title="DataMapper's official, nice-looking website">DataMapper</a></li>
<li>Rails and Legacy Databases</li>
<li><a href="http://railsenvy.com/2007/10/4/how-i-learned-to-love-testing-presentation" title="a Rails Envy presentation on BDD and RSpec">BDD and RSpec</a></li>
<li><a href="http://sinatra.rubyforge.org/" title="Sinatra's concise website">Sinatra</a></li>
<li>favorite <a href="http://www.workingwithrails.com/browse/rubygems/usage" title="Working with Rails page on Gems popularity">gems</a> and <a href="http://www.workingwithrails.com/browse/railsplugins/usage" title="Working with Rails page on Plugins popularity">plugins</a></li>
<li>Rails hosting experiences, particularly with <a href="http://www.slicehost.com/" title="Slicehost official website">Slicehost</a> and <a href="http://engineyard.com/" title="Engine Yard official website">Engine Yard</a></li>
<li>teaching Rails to college students</li>
</ul>
<p>The future Rails events planned are coding sessions (hopefully with actual coding involved), monthly meetups (with the next meetup probably in January and to be held at either the <a href="http://www.admu.edu.ph/" title="Ateneo de Manila website, see footer for address">Ateneo de Manila University campus</a> or <a href="http://www.stratpoint.com/contact.html" title="Contact page of Stratpoint technologies with address">Stratpoint Technologies office</a>), and possibly a Philippine Rails Conference. Some notable issues covered were the challenges of organizing a large conference (including problems involved with having closed source companies as sponsors), and  problems with matching the level of explanation in your presentations with the knowledge of your audience.</p>
<p>The Rails community in the Philippines is only starting to grow. But I&#8217;m glad that the local Rails events are increasing in both frequency and number of participants. Previous Rails events I&#8217;ve attended are the First PHRUG Meetup last January, Rails Happy Hour last September, Rails Talk with the presentation by Guy Naor last October, and most recently this &#8220;coding session&#8221; (I missed the 1st Rails Coding Session 2 weeks ago).</p>
<p>Before I end this post, I&#8217;d like to thank Rad and the <a href="http://www.developmentex.com/index.jsp" title="Development Executive Group's official website">Development Executive Group</a> for accommodating us for the session.</p>
]]></content:encoded>
			<wfw:commentRss>http://devblog.michaelgalero.com/2007/12/07/phrugs-2nd-rails-coding-session/feed/</wfw:commentRss>
		</item>
		<item>
		<title>A Journey with Dvorak so far</title>
		<link>http://devblog.michaelgalero.com/2007/11/27/a-journey-with-dvorak-so-far/</link>
		<comments>http://devblog.michaelgalero.com/2007/11/27/a-journey-with-dvorak-so-far/#comments</comments>
		<pubDate>Tue, 27 Nov 2007 18:06:34 +0000</pubDate>
		<dc:creator>mikong</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[dvorak]]></category>

		<category><![CDATA[keyboard]]></category>

		<category><![CDATA[layout]]></category>

		<category><![CDATA[productivity]]></category>

		<guid isPermaLink="false">http://devblog.michaelgalero.com/2007/11/27/a-journey-with-dvorak-so-far/</guid>
		<description><![CDATA[About 2 months ago, I switched from QWERTY to using the Dvorak keyboard layout. As an aside, the layout is called Dvorak because it was patented by Dr. August Dvorak - the upper left keys are NOT replaced with D, V, O, R, A, and K as some people have clarified with me (see Wikipedia [...]]]></description>
			<content:encoded><![CDATA[<p>About 2 months ago, I switched from QWERTY to using the Dvorak keyboard layout. As an aside, the layout is called Dvorak because it was patented by Dr. August Dvorak - the upper left keys are NOT replaced with D, V, O, R, A, and K as some people have clarified with me (<a href="http://en.wikipedia.org/wiki/Dvorak_Simplified_Keyboard" title="Wikipedia Article on Dvorak">see Wikipedia article</a>). The Dvorak layout was suggested to me by <a href="http://www.ryantani.com/search/label/dvorak" title="his Dvorak-related articles">a friend</a> who switched months earlier and I agreed after some serious deliberation. But this article is not about the deliberation, rather how well it is going so far&#8230;</p>
<p>Last weekend, I reached over 60 wpm in a typing test. This is still below my QWERTY stats of an average speed of 65 wpm and a burst speed of 95 wpm. But it is going surprisingly well and generally pleasant.</p>
<p>To learn Dvorak, the process I followed was quite simple. For 2 weeks, I trained for about an hour a night by working on the exercises in <a href="http://www.gigliwood.com/abcd/abcd.html" title="A Basic Course on Dvorak site">A Basic Course on Dvorak</a>. I just ran each lesson there twice. Outside the training, I still used QWERTY. After finishing the course, I made the full switch and avoided QWERTY almost entirely. I no longer used training tools, except every weekend to track my improvement.</p>
<p>My typing speed improved steadily until about 50 wpm. At the end of the 2-week training, it was a little over 20 wpm. I reached 30 after a week, 40 after another, and then 48 wpm. It slowed down significantly since then. With 60 wpm today, I improved only by 12 wpm after 4 weeks. But I&#8217;ve reached my targets so far by improving by 10 wpm until 40 wpm, the <a href="http://www.opm.gov/qualifications/SEC-IV/A/GS-CLER.HTM" title="Group Qualification Standards for Clerical and Administrative Support Positions">minimum required typing speed for clerk-typists</a>. I target to reach my old QWERTY average of 65 wpm by the end of the year.</p>
<p>It was only difficult in the beginning, and only frustrating when participating in chat conferences. For some strange reason, I had more chat conferences than usual (more than the 1st 9 months of the year). I also noticed that typing punctuations needed to be exercised to get used to them. Fortunately, punctuations are used regularly in programming. Also, it&#8217;s useful to have the Dvorak keyboard layout wallpaper to cheat. <img src='http://devblog.michaelgalero.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://devblog.michaelgalero.com/2007/11/27/a-journey-with-dvorak-so-far/feed/</wfw:commentRss>
		</item>
		<item>
		<title>ActionController RSpec: stub Time.now</title>
		<link>http://devblog.michaelgalero.com/2007/11/23/actioncontroller-rspec-stub-timenow/</link>
		<comments>http://devblog.michaelgalero.com/2007/11/23/actioncontroller-rspec-stub-timenow/#comments</comments>
		<pubDate>Fri, 23 Nov 2007 18:04:51 +0000</pubDate>
		<dc:creator>mikong</dc:creator>
		
		<category><![CDATA[Rails]]></category>

		<category><![CDATA[actioncontroller]]></category>

		<category><![CDATA[bdd]]></category>

		<category><![CDATA[rspec]]></category>

		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[stub]]></category>

		<guid isPermaLink="false">http://devblog.michaelgalero.com/2007/11/23/actioncontroller-rspec-stub-timenow/</guid>
		<description><![CDATA[So I&#8217;m playing with the mocks and stubs in RSpec and encountered a failing example. I&#8217;m setting the Task.completed_at column to Time.now in my controller like this:

  def complete
    @task = Task.find(params[:id])
    @task.update_attribute :completed_at, Time.now
  end
and this line in my RSpec example fails:

  @task.should_receive(:update_attribute).with(:completed_at, Time.now)
It&#8217;s fairly [...]]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;m playing with the mocks and stubs in RSpec and encountered a failing example. I&#8217;m setting the Task.completed_at column to Time.now in my controller like this:</p>
<pre>
  def complete
    @task = Task.find(params[:id])
    @task.update_attribute :completed_at, Time.now
  end</pre>
<p>and this line in my RSpec example fails:</p>
<pre>
  @task.should_receive(:update_attribute).with(:completed_at, Time.now)</pre>
<p>It&#8217;s fairly obvious that Time.now is the problem. Don&#8217;t let the error message fool you!</p>
<pre>
...
Mock 'Task_1002' expected :update_attribute with (:completed_at, Sat Nov 24 00:43:02 +0800 2007) but received it with (:completed_at, Sat Nov 24 00:43:02 +0800 2007)
...</pre>
<p>The values being compared look the same in the error message, but as stated in the Ruby documentation, &#8220;The [time] object will be created using the resolution available on your system clock, and so may include fractional seconds.&#8221; I created a stub and my RSpec example now looks like this:</p>
<pre>
  it "should tell the Task model to update the task's completed_at to the current time on POST to complete" do
    # Stub
    time_now = Time.now
    Time.stub!(:now).and_return(time_now)

    Task.should_receive(:find).with("1").and_return(@task)
    @task.should_receive(:update_attribute).with(:completed_at, Time.now)
    post 'complete', {:id =&gt; "1"}
  end</pre>
<p>I could have made time_now an instance variable, and moved it to before(:each) so that it can be reused by other RSpec examples. But at the moment, this is the only example that needs it.</p>
<h4>Alternatives?</h4>
<p>I <a href="http://www.google.com/search?complete=1&amp;hl=en&amp;q=Time.now+rspec&amp;btnG=Google+Search" title="Google search Time.now rspec">Googled to check how the others implemented this</a>. <a href="http://rubyforge.org/pipermail/rspec-users/2006-November/000179.html">One of the results</a> showed a year-old mailing list discussion of stubbing Time.now this way:</p>
<pre>
    @time_now = Time.parse("Jan 1 2001")
    Time.stubs(:now).returns(lambda{@time_now})</pre>
<p>The discussion said that&#8217;s supposed to work before but there&#8217;s an error now regarding the number of arguments, and it was mentioned it could be a bug. <a href="http://rubyforge.org/pipermail/rspec-users/2007-February/000701.html">Another</a> suggested defining Time.now in spec_helper. Other results weren&#8217;t in the context of RSpec.</p>
<p>I&#8217;m satisfied with my code for now. I&#8217;ll make a helper in spec_helper if other specifications will need it.</p>
]]></content:encoded>
			<wfw:commentRss>http://devblog.michaelgalero.com/2007/11/23/actioncontroller-rspec-stub-timenow/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
