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
module Bob | |
def a | |
"in bob " | |
end | |
end | |
class A | |
include Bob | |
def a | |
super + (yield).to_s |
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
########## Why does the yield output outside the content_tag block? | |
# Method | |
def submit(*args) | |
block_output = yield | |
@template.content_tag(:div, :class => "save_actions") { | |
super(*args) + block_output | |
} | |
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
hi |
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
options.scan(/\w+=\w+/).inject({}) { |h,opt| kv = opt.split('='); h[kv.first] = kv.last; h } | |
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
<?php | |
require_once("DatabaseClass.php"); | |
Class Customer { | |
// Member Variables | |
var $dbHandle; | |
// Methods | |
function Customer($dbName = "corked") { | |
$this->dbHandle = new Database($dbName); | |
} |
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
<?php | |
function findInRange($start, $end, $dbHandle) { | |
$found_ids = array(); | |
$days = (strtotime($end) - strtotime($start)) / 60 / 60 / 24; | |
for($i=0; $i<=$days; $i++) { | |
$day = date("Y-m-d", strtotime($start) + ($i * 60 * 60 * 24)); | |
$query = "SELECT id FROM events WHERE start_date <= '$day' AND '$day' <= end_date"; | |
$sth = $dbHandle->query($query); | |
while ($row = $sth->fetch()) { |
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
named_scope :freebies, :joins => :categories, :conditions => "categories_deals.category_id IN (#{Category.free.map(&:id).join(", ")})" | |
named_scope :past_day, :conditions => ["start_at >= ? AND start_at <= ?", Time.now - 1.day, Time.now] | |
named_scope :never_expire, :conditions => { :does_not_expire => true} | |
named_scope :active1, :conditions => { :status => true } | |
named_scope :started, :conditions => ["start_at <= ? OR start_at IS NULL", Time.now] | |
named_scope :not_ended, :conditions => ["end_at <= ? OR end_at IS NULL", Time.now] | |
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 ActiveRecord::Base | |
@@cache_store = nil | |
def self.cache_store | |
@@cache_store ||= ActionController::Base.cache_store | |
end | |
def self.caches(method_name, key = nil, options = {}, &block) | |
if key.is_a?(Hash) | |
options = key | |
key = nil |
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
user www-data www-data; | |
worker_processes 4; | |
events { | |
worker_connections 1024; | |
use epoll; | |
} | |
http { |
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
user www-data www-data; | |
worker_processes 4; | |
events { | |
worker_connections 1024; | |
use epoll; | |
} | |
http { |