<?xml version="1.0" encoding="UTF-8"?>
<codes type="array">
  <code>
    <code>module ActionView 
  module Helpers 
    class InstanceTag 
      def to_label_tag_with_i18n(text = nil, options = {}) 
        text ||= object.class.human_attribute_name(method_name) if object.class.respond_to?(:human_attribute_name) 
 
        to_label_tag_without_i18n(text, options) 
      end 
 
      alias_method_chain :to_label_tag, :i18n 
    end 
  end 
end</code>
    <created-at type="datetime">2009-11-22T19:42:31Z</created-at>
    <description>rails 2.3.4 doen't have i18n support in labels  
http://lawrencesong.net/2009/04/i18n-label-in-rails-monkey-patch/</description>
    <id type="integer">206</id>
    <language-id type="integer">39</language-id>
    <privated type="boolean">false</privated>
    <title>i18n in labels</title>
    <updated-at type="datetime">2009-11-22T19:42:31Z</updated-at>
    <user-id type="integer">7</user-id>
  </code>
  <code>
    <code>class MyModel &lt; ActiveRecord::Base
  default_scope :order =&gt; 'created_at desc'
end</code>
    <created-at type="datetime">2009-10-04T16:55:05Z</created-at>
    <description></description>
    <id type="integer">204</id>
    <language-id type="integer">39</language-id>
    <privated type="boolean">false</privated>
    <title>use default_scope to set up default find conditions such as order</title>
    <updated-at type="datetime">2009-10-04T16:55:05Z</updated-at>
    <user-id type="integer">7</user-id>
  </code>
  <code>
    <code>class User &lt; ActiveRecord::Base

  HUMANIZED_ATTRIBUTES = {
    :email =&gt; &quot;E-mail address&quot;
  }

  def self.human_attribute_name(attr)
    HUMANIZED_ATTRIBUTES[attr.to_sym] || super
  end

end</code>
    <created-at type="datetime">2009-08-22T17:00:45Z</created-at>
    <description></description>
    <id type="integer">202</id>
    <language-id type="integer">39</language-id>
    <privated type="boolean">false</privated>
    <title>humanized attributes</title>
    <updated-at type="datetime">2009-08-22T17:00:45Z</updated-at>
    <user-id type="integer">7</user-id>
  </code>
  <code>
    <code>validates_attachment_content_type :image,
  :content_type =&gt; [
    'image/jpeg',
    'image/pjpeg', # for progressive jpeg (IE mine-type for regular jpeg) 
    'image/png',
    'image/x-png', # IE mine-type for PNG
    'image/gif'
]</code>
    <created-at type="datetime">2009-08-16T21:43:37Z</created-at>
    <description></description>
    <id type="integer">191</id>
    <language-id type="integer">39</language-id>
    <privated type="boolean">false</privated>
    <title>paperclip ie validation</title>
    <updated-at type="datetime">2009-08-16T21:43:37Z</updated-at>
    <user-id type="integer">7</user-id>
  </code>
  <code>
    <code>duplicates = User.find( :all,
  :select     =&gt; &quot;email, COUNT(email) AS duplicate_count&quot;,
  :conditions =&gt; &quot;email IS NOT NULL AND email != ''&quot;,
  :group      =&gt; &quot;email HAVING duplicate_count &gt; 1&quot;
)</code>
    <created-at type="datetime">2009-07-18T01:52:55Z</created-at>
    <description>having example in rails. from: http://blog.grayproductions.net/articles/five_activerecord_tips</description>
    <id type="integer">187</id>
    <language-id type="integer">39</language-id>
    <privated type="boolean">false</privated>
    <title>finding duplicates entries</title>
    <updated-at type="datetime">2009-07-18T01:52:55Z</updated-at>
    <user-id type="integer">7</user-id>
  </code>
  <code>
    <code>&gt;&gt; &quot;abb&quot;.succ
=&gt; &quot;abc&quot;
&gt;&gt; &quot;1&quot;.succ
=&gt; &quot;2&quot;
&gt;&gt; &quot;1999zzz&quot;.succ
=&gt; &quot;2000aaa&quot;
&gt;&gt; 
</code>
    <created-at type="datetime">2009-07-01T20:59:21Z</created-at>
    <description>from: http://www.ruby-doc.org/core/classes/String.html#M000795</description>
    <id type="integer">184</id>
    <language-id type="integer">39</language-id>
    <privated type="boolean">false</privated>
    <title>succ method</title>
    <updated-at type="datetime">2009-07-01T20:59:21Z</updated-at>
    <user-id type="integer">7</user-id>
  </code>
  <code>
    <code>&gt;&gt; require 'hirb'
=&gt; []
&gt;&gt; Hirb.enable
=&gt; nil
&gt;&gt; Exam.find(:all, :limit =&gt; 5)
+----+----------+----------+----------+----------+---------+----------+------+
| id | title    | exam     | creat... | updat... | user_id | categ... | hits |
+----+----------+----------+----------+----------+---------+----------+------+
| 1  | Simul... | Simul... | 2009-... | 2009-... | 1       | 1        | 152  |
| 2  | Simul... | Simul... | 2009-... | 2009-... | 1       | 1        | 143  |
| 3  | Espec... | Espec... | 2009-... | 2009-... | 1       | 1        | 1089 |
| 4  | Espec... | Espec... | 2009-... | 2009-... | 1       | 1        | 80   |
| 5  | Espec... | Espec... | 2009-... | 2009-... | 1       | 1        | 40   |
+----+----------+----------+----------+----------+---------+----------+------+
5 rows in set
&gt;&gt;</code>
    <created-at type="datetime">2009-07-01T20:20:37Z</created-at>
    <description>to install: 
gem install cldwalker-hirb --source http://gems.github.com</description>
    <id type="integer">183</id>
    <language-id type="integer">39</language-id>
    <privated type="boolean">false</privated>
    <title>hirb example</title>
    <updated-at type="datetime">2009-07-01T20:20:37Z</updated-at>
    <user-id type="integer">7</user-id>
  </code>
  <code>
    <code>@files = Dir.glob(&quot;public/files/*&quot;)

for file in @files
    puts file
end</code>
    <created-at type="datetime">2009-06-28T00:02:54Z</created-at>
    <description></description>
    <id type="integer">182</id>
    <language-id type="integer">39</language-id>
    <privated type="boolean">false</privated>
    <title>listing files in a directory with rails</title>
    <updated-at type="datetime">2009-06-28T00:02:54Z</updated-at>
    <user-id type="integer">7</user-id>
  </code>
  <code>
    <code>validates_format_of :email, 
:with =&gt; /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/, 
:message =&gt; &quot;is invalid&quot; </code>
    <created-at type="datetime">2009-06-21T21:30:36Z</created-at>
    <description></description>
    <id type="integer">180</id>
    <language-id type="integer">39</language-id>
    <privated type="boolean">false</privated>
    <title>email regex </title>
    <updated-at type="datetime">2009-06-21T21:30:36Z</updated-at>
    <user-id type="integer">7</user-id>
  </code>
  <code>
    <code>require 'rubygems'
require 'google_translate'

tr = Google::Translate.new

# from English to Spanish
tr.translate :from =&gt; &quot;en&quot;, :to =&gt; &quot;es&quot;, :text =&gt; &quot;Hello, World!&quot;
 =&gt; Hola, Mundo!</code>
    <created-at type="datetime">2009-04-20T00:56:54Z</created-at>
    <description>install:
sudo gem install google_translate</description>
    <id type="integer">169</id>
    <language-id type="integer">39</language-id>
    <privated type="boolean">false</privated>
    <title>Google::Translate, A Simple API In Ruby</title>
    <updated-at type="datetime">2009-04-20T00:56:54Z</updated-at>
    <user-id type="integer">7</user-id>
  </code>
</codes>
