This file contains 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 |
This file contains 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 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 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 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 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 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 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 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
~/projects/[project](master) $ git pull | |
Current branch master is up to date. | |
~/projects/[project](master) $ script/plugin install git://github.com/technoweenie/relative_time_helpers.git/ | |
Initialized empty Git repository in /Users/nik/projects/[project]/vendor/plugins/relative_time_helpers/.git/ | |
fatal: bad revision 'HEAD' | |
refusing to pull with rebase: your working tree is not up-to-date |
This file contains 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 Array | |
def detect_index(&block) | |
each_with_index do |e, i| | |
return i if yield e | |
end | |
end | |
end | |
OlderNewer