Skip to content

Instantly share code, notes, and snippets.

View jm's full-sized avatar
💫
Livin' life. Or something.

Jeremy McAnally jm

💫
Livin' life. Or something.
View GitHub Profile
def logging_features_deprecated
# Currently not deprecated; change to true when it is deprecated
proc { false }
end
deprecate "file logging", :when => logging_features_deprecated do
# whatever
end
def create_from_string(klass, string = "")
# like calling String.new or something because
# klass is a variable representing the class you passed in
klass.new(string)
end
x = create_from_string(String, "dude")
y = create_from_string(Regexp, "wat")
plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git'
plugin 'open_id_authentication', :git => 'git://github.com/rails/open_id_authentication.git'
plugin 'exception_notifier', :git => 'git://github.com/rails/exception_notification.git'
gem 'mislav-will-paginate'
gem 'ruby-openid'
gem 'rubyist-aasm'
rakefile "bootstrap.rake", <<CODE
namespace :app do
class ShapeController < AC::Base
SHAPES = { 'square' => Shape::Square, 'circle' => Shape::Circle }
def create
s = SHAPES[params[:shape]].create(params)
end
end
[codestuff (master)]$ sudo gem install session
Bulk updating Gem source index for: http://gems.github.com
ERROR: While executing gem ... (Gem::RemoteSourceException)
HTTP Response 403 fetching http://gems.rubyforge.org/yaml
class A
@@foo = "from A"
end
class B < A
@@foo = "from B"
end
# What's the value of @@foo in A now...?
First, rewinding head to replay your work on top of it...
Applying: Improve rewindable input test coverage so tests fail when you remove the middleware
error: actionpack/test/controller/request/multipart_params_parsing_test.rb: does not exist in index
error: actionpack/test/controller/request/url_encoded_params_parsing_test.rb: does not exist in index
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Renaming actionpack/test/controller/request/multipart_params_parsing_test.rb => actionpack/test/dispatch/request/multipart_params_parsing_test.rb
Auto-merging actionpack/test/dispatch/request/multipart_params_parsing_test.rb
CONFLICT (rename/modify): Merge conflict in actionpack/test/dispatch/request/multipart_params_parsing_test.rb
Renaming actionpack/test/controller/request/url_encoded_params_parsing_test.rb => actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb
root@mycomp:/home# gem --version
1.2.0
root@mycomp:/home# gem update --system
Updating RubyGems...
Nothing to update
root@mycomp:/home# gem install rubygems-update --version=1.3.0
root@mycomp:/home# update_rubygems
# Tons of text...
class PostsController < ApplicationController
respond_to :html, :xml
def index
@posts = Post.all
respond_with @posts
end
def show
class Bar
attr_reader :hash
def method_missing(m, *args)
if m.to_s =~ /((set|get)_(.+))/
case $2
when 'set'
self.class.send(:define_method,$1, lambda {|value| @hash ||= {}; @hash[$3] = value})
send($1, args[0])
when 'get'
self.class.send(:define_method,$1, lambda {@hash ||= {}; @hash[$3]})