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
create or replace function insert_herp_to_derp() | |
returns trigger as $$ | |
begin | |
execute 'INSERT INTO ' || quote_ident('derp_' || NEW.derp_id || '_herps') || ' SELECT ($1).*' using NEW; | |
return null; | |
end; | |
$$ LANGUAGE plpgsql; | |
CREATE TRIGGER insert_herps_trigger BEFORE INSERT ON herps FOR EACH ROW EXECUTE PROCEDURE insert_herp_to_derp(); |
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
create or replace function insert_herp_to_derp() | |
returns trigger as $body$ | |
declare | |
name text := 'derp_' || NEW.derp_id || '_herps'; | |
s text; | |
begin | |
-- check that the needed table exists on the database | |
perform 1 | |
from pg_class, pg_namespace | |
where relnamespace = pg_namespace.oid |
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
kern.sysv.shmmax=1073741824 | |
kern.sysv.shmmin=1 | |
kern.sysv.shmmni=32 | |
kern.sysv.shmseg=8 | |
kern.sysv.shmall=4096 |
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
unbind-key C-b | |
set -g prefix C-a | |
bind-key C-a send-prefix | |
set -g history-limit 7000 |
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
module CoreMixins | |
module ParanoidHash | |
def[](k) | |
fetch(k) | |
end | |
end | |
end | |
class Hash | |
def paranoid! | |
extend(CoreMixins::ParanoidHash) |
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 ChainStub | |
attr_accessor :instance, :result | |
def initialize(instance) | |
@instance = instance | |
@result = Object.new | |
end | |
def method_missing(method_name, *args, &blk) | |
if blk | |
instance.stub(method_name).with(*args) { blk.call } |
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
module CountByInterval | |
def count_by_interval(aggregate_range = 'day', column = "#{self.table_name}.created_at", aggregate_operation = 'count(*)') | |
aggregate_on = "date_trunc('#{aggregate_range}', #{column})" | |
self.select_values = ["coalesce(#{aggregate_operation}, 0) as value", "#{aggregate_on} as date"] | |
ActiveRecord::Base.connection.execute(self.group(aggregate_on).to_sql).collect {|r| r} | |
end | |
end | |
ActiveRecord::Relation.send(:include, CountByInterval) #EWWWWwww |
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
Module.class_eval do | |
def child_classes | |
self.constants.collect do |constant| | |
c = self.const_get(constant) | |
c if c.is_a?(Class) | |
end.compact | |
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
1 echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile | |
2 [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function | |
3 [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function | |
4 [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function | |
5 [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function | |
6 [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function | |
7 [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function | |
8 [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function | |
###.....................FOREVER recursiveness |
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
module Responders | |
class JsonTemplateResponder < ActionController::Responder | |
def to_json | |
render :json => {:html => controller.render_to_string("#{controller.action_name}.html")} | |
end | |
end | |
end |