This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Post | |
include Mongoid::Document | |
include Mongoid::Timestamps | |
field :title, :type => String | |
field :content, :type => String | |
field :permalink, :type => String | |
belongs_to :user |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruby-1.9.2-p290@blog: | |
system: | |
uname: "Darwin Vainglory.local 11.0.0 Darwin Kernel Version 11.0.0: Sat Jun 18 12:56:35 PDT 2011; root:xnu-1699.22.73~1/RELEASE_X86_64 x86_64" | |
bash: "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin11)" | |
zsh: "/usr/local/bin/zsh => zsh 4.3.12 (i386-apple-darwin10.7.4)" | |
rvm: | |
version: "rvm 1.6.32 by Wayne E. Seguin ([email protected]) [https://rvm.beginrescueend.com/]" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git branch -r --merged | grep -v 'master$' | sed "s/origin\///" | xargs -I% git push origin :% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def wait_for(klass, objects, assert = Proc.new { |x| x.present? }, retries = 10) | |
retries.times do |i| | |
break if assert.call(klass.send(objects)) | |
sleep i * 0.1 | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For pretty oneliners. It just memoizes on nil, but accepts TrueClass as a value | |
def memoize(&block) | |
key = caller[0][/`.*'/][1..-2] # Get the method name of the caller | |
@_memoized ||= {} | |
@_memoized[key].nil? ? @_memoized[key] = block.call : @_memoized[key] | |
end | |
# memoize do | |
# ExpensiveOperation | |
# end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Thanks to http://superuser.com/questions/558876/how-can-i-make-the-sign-column-show-up-all-the-time-even-if-no-signs-have-been-a | |
autocmd BufEnter * sign define dummy | |
autocmd BufEnter * execute 'sign place 9999 line=1 name=dummy buffer=' . bufnr('') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person | |
def self.get_name | |
persons_name | |
end | |
def self.persons_name | |
"Sam" | |
end | |
private_class_method :persons_name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person | |
def self.get_name | |
persons_name | |
end | |
def self.persons_name | |
"Sam" | |
end | |
private_class_method :persons_name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Hack around the middleware stack a bit to get warden session correctly in | |
config.middleware.delete(ActionDispatch::Cookies) | |
config.middleware.delete(ActionDispatch::Session::CookieStore) | |
config.middleware.insert_before(Rails::Rack::Logger, ActionDispatch::Session::CookieStore) | |
config.middleware.insert_before(ActionDispatch::Session::CookieStore, ActionDispatch::Cookies) | |
# Rotate two files, max 5 mb each | |
config.logger = ActiveSupport::TaggedLogging.new(Logger.new(config.paths['log'].first, 2, 5 * 1024 * 1024)) | |
config.log_tags = [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.use_transactional_fixtures = false | |
config.before(:suite) do | |
DatabaseCleaner.clean_with :truncation | |
end | |
config.before(:each) do | |
DatabaseCleaner.strategy = :transaction | |
end |
OlderNewer