Skip to content

Instantly share code, notes, and snippets.

# Usage
#
# class Rectangle
# include TypeCast
#
# ...
#
# attr_accessor :width, :height, :fill
# type_cast :width, :height, :method => :to_f
# type_cast :fill, :allow_nil => false, :method => lambda { |value| !!value }
@cutalion
cutalion / action.rb
Created July 13, 2011 14:40
action helper for rspec
#
# Put this file into spec/support/ folder.
#
# Helper +action+ allows you to write something like
#
# describe "GET index" do
# action { get :index }
#
# context 'if user signed in' do
# before { sign_in user }
# ./spec/spec_helper.rb
#
# Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f}
#
#
# Usage:
#
# its(:updated_at) { should be_the_same_time_as updated_at }
#
#
@cutalion
cutalion / tray.rb
Created April 17, 2011 11:42
Allows add or remove icons to unity panel white-list, so that they can be show on unity panel
require 'rubygems'
require 'json'
def save_settings(settings)
`gsettings set com.canonical.Unity.Panel systray-whitelist "#{settings.to_json.gsub('"', "'")}"`
end
def current_settings