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
def with_hangoff_table(relation_name, opts={}) | |
hangoff_table = reflections[relation_name].table_name | |
foreign_key = reflections[relation_name].foreign_key | |
name_column = opts[:name_column] || :attribute_name | |
value_column = opts[:value_column] || :attribute_value | |
(class << self; self; end).send(:define_method, relation_name) do |params| | |
table_alias = hangoff_table + SecureRandom.hex(4) | |
join_string = "INNER JOIN #{hangoff_table} AS #{table_alias} ON #{table_alias}.#{foreign_key} = #{table_name}.#{primary_key}" |
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
#prompt | |
function parse_git_deleted { | |
[[ $(git status 2> /dev/null | grep deleted:) != "" ]] && echo "-" | |
} | |
function parse_git_added { | |
[[ $(git status 2> /dev/null | grep "Untracked files:") != "" ]] && echo '+' | |
} | |
function parse_git_modified { | |
[[ $(git status 2> /dev/null | grep modified:) != "" ]] && echo "*" | |
} |
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
public static class Memoization { | |
public static Func<T,K> MemoizeFunction<T, K>(this Func<T, K> function) { | |
var table = new Dictionary<T, K>(); | |
return (args) => { | |
if (table.ContainsKey(args)) return table[args]; | |
var result = function(args); | |
table[args] = result; | |
return result; | |
}; | |
} |
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
" Vim color file | |
" Converted from Textmate theme Bespin using Coloration v0.2.5 (http://github.com/sickill/coloration) | |
set background=dark | |
highlight clear | |
if exists("syntax_on") | |
syntax reset | |
endif |
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
switching to jekyll | |
basic nodejs app using express | |
using socketio with nodejs |
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
let g:peepopen_loaded = 1 | |
let g:peepopen_cwd = getcwd() | |
let s:save_cpo = &cpo | |
set cpo&vim | |
function s:LaunchPeepOpenViaVim() | |
let cwd = g:peepopen_cwd | |
silent exe "!open -a PeepOpen " . shellescape(cwd) | |
endfunction |
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
set nocompatible | |
" have command-line completion <Tab> (for filenames, help topics, option names) | |
" first list the available options and complete the longest common part, then | |
" have further <Tab>s cycle through the possibilities: | |
set wildmode=list:longest,full | |
" display the current mode and partially-typed commands in the status line: | |
set showmode | |
set showcmd |
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
set nocompatible | |
" have command-line completion <Tab> (for filenames, help topics, option names) | |
" first list the available options and complete the longest common part, then | |
" have further <Tab>s cycle through the possibilities: | |
set wildmode=list:longest,full | |
" display the current mode and partially-typed commands in the status line: | |
set showmode | |
set showcmd |
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
;; Adam Coffman | |
;; Scheme assignment 3 | |
;; The PARSE function accepts as argument an infix arithmetic expression in the | |
;; form of a list and returns a list representation of the corresponding expresion | |
;; tree. Ex., (parse '(3 + 4))--> (+ (3 4)), | |
;; (parse '(3 + 4 * 5)) --> (+ (3 (* (4 5)))) and | |
;; (parse '( 4 + 3 * ( 5 + 6) - 2)) --> (- ((+ (4 (* (3 (+ (5 6)))))) 2)) | |
;; Note that each element of the list must be one of three things: a number; one of +, -, * | |
;; /; or a sublist (ex., (5 + 6)) |
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
;; Adam Coffman | |
;; Scheme Assignment 2 | |
;; Jugs Problem | |
;;Program to solve the "Jugs Problem" from die hard 3. | |
;;invoked with (Jugs CapacityJugA CapacityJugB GoalFillofA) | |
;;returns a step by step path to the goal. | |
;;IE (Jugs 5 3 4) would return | |
;;((0 0 5 3) (5 0 5 3) (2 3 5 3) (2 0 5 3) (0 2 5 3) (5 2 5 3) (4 3 5 3)) | |
;;Suporting Functions |