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/initializers/since.rb | |
| ActiveRecord::Base.class_eval do | |
| [:created, :updated].each do |name| | |
| named_scope "#{name}_since", lambda { |time| { :conditions => ["#{name}_at > ?", time] } } | |
| 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
| class Time | |
| cattr_accessor :frozen_to | |
| class << self | |
| def now_with_freezing | |
| if @@frozen_to | |
| @@frozen_to | |
| else |
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 String | |
| def jammize | |
| gsub(/\s/, '').underscore | |
| end | |
| end | |
| "My Whatevers".jammize #=> "my_whatevers" |
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
| require 'mechanize' | |
| # scrapes Xero for our bank balances and stuff | |
| class XeroScraper | |
| XERO_USERNAME = "xero username" | |
| XERO_PASSWORD = "xero password" | |
| class Account |
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
| >> HashWithIndifferentAccess.new.is_a? Hash | |
| => true |
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
| alias push="rake test && git push" # Cheapskate's CI |
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 has_permission(name) | |
| (p = permissions.detect{|p| p[:name] == name } ) ? p[:active] : false | |
| end | |
| def has_one_of_permissions(ps) | |
| ps = [ps].flatten | |
| ps.each do |p| | |
| return true if has_permission(p) | |
| end | |
| false |
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
| foreach($post_params as $key => $value) { | |
| $sanitized_value = sanitize($value); | |
| $regex = '/\<\$' . $key . '\>/'; | |
| $template_content = preg_replace($regex, $sanitized_value, $template_content); | |
| } | |
| // lol |
NewerOlder