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
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
options.scan(/\w+=\w+/).inject({}) { |h,opt| kv = opt.split('='); h[kv.first] = kv.last; h }
@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
require 'net/http'
require 'uri'
class ScreenShooter
SCREEN_SHOOTER_URL = 'http://www.browsrcamp.com/'
class << self
def screenshot_for(url)
returning new(url) do |shooter|
shooter.shoot
end
@kastner
kastner / gist:545
Created July 22, 2008 01:00 — forked from anonymous/gist:543
Joe's meta-programing for testing private stuff in PHP
<?php
class Foo
{
protected $user = null;
public function __construct($user)
{
$this->user = $user;
}