Skip to content

Instantly share code, notes, and snippets.

inflect.plural /^(movie_data)$/, '\1'
inflect.singular /^(movie_data)$/, '\1'
Thanks for the pull request! Before I can pull it though, two things need changed:
Tests! A lot of people are using MongoMapper, so we want to make sure we don't break this in the future.
I don't like manually deleting the options for the connection string. What do you think about having driving options nested with the other connection settings? Something like:
MongoMapper.config = {'development' => {:port => 12345, :options => {:pool_size => 5}}
$ cap deploy
* executing `deploy'
* executing `deploy:update'
** transaction: start
* executing `deploy:update_code'
updating the cached checkout on all servers
executing locally: "git ls-remote [email protected]:SomePerson/SomeProject.git master"
command finished in 1280ms
* executing "if [ -d $HOME/sites/some_project/shared/cached-copy ]; then cd $HOME/sites/some_project/shared/cached-copy && git fetch origin && git fetch --tags origin && git reset --hard c06a130a7a20364a5de5c0bdbaa4bdec8c5f2519 && git clean -d -x -f; else git clone [email protected]:SomePerson/SomeProject.git $HOME/sites/some_project/shared/cached-copy && cd $HOME/sites/some_project/shared/cached-copy && git checkout -b deploy c06a130a7a20364a5de5c0bdbaa4bdec8c5f2519; fi"
@RyanScottLewis
RyanScottLewis / user_dsl.rb
Created December 8, 2011 19:11
Simple User Dsl
class User
class DSL
def self.dsl_attr_accessor (*names)
names.each do |name|
name = name.to_sym
define_method(name) do |value=nil|
@result[name] = value unless value.nil?
@result[name]
US East (Northern Virginia) Region
Amazon EC2 running Linux/UNIX
$0.34 per Large Instance (m1.large) instance-hour (or partial hour) 81 Hrs 27.54
Amazon EC2 EBS
$0.10 per GB-month of provisioned storage 0.860 GB-Mo 0.09
$0.10 per 1 million I/O requests 730,931 IOs 0.07
ryguy@RyBook ~/Code/Ruby/Scratchpad/slop-test $ gem list slop
*** LOCAL GEMS ***
slop (3.1.1)
ryguy@RyBook ~/Code/Ruby/Scratchpad/slop-test $ cat test.rb
require 'slop'
opts = Slop.new do
@RyanScottLewis
RyanScottLewis / spec_helper.rb
Created May 1, 2012 10:47
Rspec: clear terminal before suites in OSX
# omitted...
RSpec.configure do |config|
# omitted...
config.before(:suite) do
if RUBY_PLATFORM =~ /darwin/
# Focus on Terminal
system %{osascript -e 'tell application "Terminal" to activate'}
# Send CMD+K to clear
/Users/Ryguy/.rvm/gems/ruby-1.9.2-p318@proctor/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:503:in `load_missing_constant': Expected /Users/Ryguy/Code/Ruby/Gems/proctor/app/models/client.rb to define Client (LoadError)
from /Users/Ryguy/.rvm/gems/ruby-1.9.2-p318@proctor/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:192:in `block in const_missing'
from /Users/Ryguy/.rvm/gems/ruby-1.9.2-p318@proctor/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:190:in `each'
from /Users/Ryguy/.rvm/gems/ruby-1.9.2-p318@proctor/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:190:in `const_missing'
from /Users/Ryguy/.rvm/gems/ruby-1.9.2-p318@proctor/gems/activesupport-3.2.3/lib/active_support/inflector/methods.rb:229:in `block in constantize'
from /Users/Ryguy/.rvm/gems/ruby-1.9.2-p318@proctor/gems/activesupport-3.2.3/lib/active_support/inflector/methods.rb:228:in `each'
from /Users/Ryguy/.rvm/gems/ruby-1.9.2-p318@proctor/gems/activesupport-3.2.3/lib/active_support/infle
@RyanScottLewis
RyanScottLewis / _schema.rb
Created June 22, 2012 05:45
SpineJS User's Name helper + showing off getters/setters in Spine
ActiveRecord::Schema.define(:version => 00000000000000) do
create_table "users", :force => true do |t|
t.string "username", :default => "", :null => false
t.string "email", :default => "", :null => false
t.string "encrypted_password", :default => "", :null => false
# Devise fluff here...
t.string "first_name", :default => "", :null => false
@RyanScottLewis
RyanScottLewis / cacheable_attr.rb
Created June 25, 2012 05:55
Cacheable attributes
module CacheableAttr
def cacheable_attr(*attributes)
opts = { ttl: 60 }
opts = opts.merge(attributes.pop) if attributes.last.is_a?(Hash)
attributes.each do |attribute|
define_method attribute do
if !instance_variable_defined?("@#{attribute}_updated_at") || (opts[:ttl] != nil && Time.now >= instance_variable_get("@#{attribute}_updated_at") + opts[:ttl])
value = send("#{attribute}_uncached")