Skip to content

Instantly share code, notes, and snippets.


John Barnette jbarnette

View GitHub Profile
View labmda.swift
@discardableResult func cons(_ x: Any, _ y: Any) -> (((Any, Any) -> Any) -> Any) {
return { m in m(x, y) }
@discardableResult func car(_ z: (((Any, Any) -> Any) -> Any)) -> Any {
return z { p, q in p }
@discardableResult func cdr(_ z: (((Any, Any) -> Any) -> Any)) -> Any {
return z { p, q in q }
jbarnette /
Last active Jan 4, 2016
cd to any repo, cloning if necessary
function gd {
local parent=$(dirname "$1")
local name=$(basename "$1")
local owner=$(basename "$parent")
local nwo="$owner/$name"
local dir="$HOME/src/$nwo"
[ -d "$dir" ] || git clone "$nwo" "$dir"
cd "$dir"
View gist:3809699

On Hats and the Wearing Thereof

Jargon and Connotation

Authority and Responsibility

Failure and Prohibition

Hiring and Consequences

View gist:3802370

A daily glance at what's happening in a high velocity codebase, thanks to @defunkt:{yesterday}...master

Bookmark, share, and enjoy.

View id.h
#ifndef __ID_H
#define __ID_H
struct __closure
_imp_t method;
oop data;
struct __lookup
jbarnette / stupid.rb
Created Mar 22, 2012
Incredibly stupid Ruby tricks. Please add more.
View stupid.rb
# The worst possible way to memoize something.
class X
def value
@value = really_expensive_operation
def value; @value end
View watchable.rb
module Watchable
def events
@events ||= { |h,k| h[k] = [] }
def fire event, *args
events[event].each { |e| e[*args] }
def on event, &block
View ar.rb
class ActiveRecord::Base
attr_accessible nil
def update_attributes *args
raise "Don't call #{}#update_attributes. " +
"Mass assignment is pure evil."
View gist:1934258
require "overlord/searchable"
module Overlord
# Mark an ActiveRecord model as having a state machine. Requires a
# string attribute called `state`. To set the default state for a
# class, set a default column value for `state` in the database.
# Use Symbols for all keys and values in state definitions.
View gist:1772804
require "bundler/setup"
require "rack/streaming_proxy"
warn "Sleeping for a bit before starting gimme."
sleep 3
warn "Starting gimme."
nport = 2727