Skip to content

Instantly share code, notes, and snippets.

RAILS_ROOT/app/flex/src/
org/pillowfactory/models/Person.as => Add custom model behavior/properties here.
org/pillowfactory/models/base/PersonBase.as* => Contains properties and model helper methods.
org/pillowfactory/models/base/Base.as => Superclass to all generated models.
org/pillowfactory/models/helpers/Errors.as => Implementation of the ActiveRecord Errors class.
org/pillowfactory/models/helpers/Hash.as => Dynamic class with Ruby Hash-like methods.
# http://drnicutilities.rubyforge.org/map_by_method/
require 'map_by_method'
# Dr Nic's gem inspired by
# http://redhanded.hobix.com/inspect/stickItInYourIrbrcMethodfinder.html
require 'what_methods'
# Pretty Print method
require 'pp'
@pillowfactory
pillowfactory / partials.rb
Created June 9, 2010 03:49 — forked from lenary/partials.rb
Sinatra Partials
# stolen from http://github.com/cschneid/irclogger/blob/master/lib/partials.rb
# and made a lot more robust by me
# this implementation uses erb by default. if you want to use any other template mechanism
# then replace `erb` on line 13 and line 17 with `haml` or whatever
module Sinatra::Partials
def partial(template, *args)
template_array = template.to_s.split('/')
template = template_array[0..-2].join('/') + "/_#{template_array[-1]}"
options = args.last.is_a?(Hash) ? args.pop : {}
options.merge!(:layout => false)
## Error I get when using a validates_presence_of :description in my Special model
durran-validatable-2.0.1/lib/validations/validation_base.rb:61:in `raise_error_if_key_is_dup': key Special/Validatable::ValidatesPresenceOf/description must be unique, provide the :key option to specify a unique key (ArgumentError)
require 'user_app'
map '/user' do
run UserApp
end
autocmd BufWritePre * :%s/\s\+$//e
# Given
class Business
attr_accessor :name, :net_worth
attr_accessor :line_1, :line_2, :city, :state, :zip
end
# Import with CSV Mapper
CsvMapper.import('path_to_file.csv') do
map_to Business
start_at_row 1 # Skip the first row (probably a header row)
function rvm_require_ruby {
if [ "`rvm list | grep $1`" = "" ]
then
echo "ERROR: Requires Ruby Version: $1"
exit
fi
}
function rvm_use {
rvm_require_ruby $1
rvm use $1
function rvm_require_ruby
{
if ! rvm list strings | grep -q "^$1" ; then
echo "ERROR: Requires Ruby Version: '$1'"
return 1
fi
return 0
}
def possessify(word)
result = word.to_s.dup
if word.empty?
result
else
result.ends_with?('s') ? result << "'" : result << "'s"
end
end