Skip to content

Instantly share code, notes, and snippets.

View kastner's full-sized avatar
🕳️
actively choosing...

Erik Kastner kastner

🕳️
actively choosing...
View GitHub Profile
module Bob
def a
"in bob "
end
end
class A
include Bob
def a
super + (yield).to_s
@kastner
kastner / gist:16288
Created October 11, 2008 16:22 — forked from queso/gist:16284
########## 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
options.scan(/\w+=\w+/).inject({}) { |h,opt| kv = opt.split('='); h[kv.first] = kv.last; h }
<?php
require_once("DatabaseClass.php");
Class Customer {
// Member Variables
var $dbHandle;
// Methods
function Customer($dbName = "corked") {
$this->dbHandle = new Database($dbName);
}
<?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()) {
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]
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
user www-data www-data;
worker_processes 4;
events {
worker_connections 1024;
use epoll;
}
http {
user www-data www-data;
worker_processes 4;
events {
worker_connections 1024;
use epoll;
}
http {