colored git 29 Nov 2009
Tags: git, config, colors

Want to make your git experience literally colorful? :D Add the following to your global options

plain
>> git config --global color.interactive always
>> git config --global color.diff always
>> git config --global color.status always
>> git config --global color.branch always

To explore other global options,

ruby
>> git config --help

To explore your current global options

plain
>> git config --global --list

check if string is float 29 Nov 2009
Tags: string, initializer

Throw this in an initializer file.

ruby
class String
  def numeric?
    true if Float(self) rescue false
  end
end

delete object errors 26 Nov 2009
Tags: errors, initializer

To delete error messages, add this in an initializer file.

ruby
class ActiveRecord::Errors
  def delete(key)
    @errors.delete(key.to_s)
  end
end

Then you can now

ruby
>> obj = Model.new.valid?  #false, error at :name attribute
>> obj.errors.on :name
   "can't be blank"
>> obj.errors.delete :name
>> obj.errors.on :name
   nil