Skip to content

Instantly share code, notes, and snippets.

View kbaird's full-sized avatar
💭
Homo sapiens... for now.

Kevin C. Baird kbaird

💭
Homo sapiens... for now.
View GitHub Profile
require File.expand_path(File.dirname(__FILE__) + %q[/../spec_helper])
describe ApplicationHelper do
it %q[should flunk] do
violated %q[Auto-flunk]
end
end
colorscheme delek
filetype plugin on
set background=dark
set showcmd
set number
syntax on
" all tab stuff to 2
set tabstop=2
set softtabstop=2
augroup filetypedetect
au! BufRead,BufNewFile *.asd setfiletype lisp
au! BufRead,BufNewFile *.cgi setfiletype ruby
au! BufRead,BufNewFile *.dbk setfiletype xml
au! BufRead,BufNewFile *.rb_txt setfiletype ruby
au! BufRead,BufNewFile *.rbx setfiletype ruby
au! BufRead,BufNewFile *.ly setfiletype tex
augroup END
:abbr teh the
#!/usr/bin/env ruby
# libertarianism_made_easy.rb
module LibertarianismMadeEasy
attr_accessor :is_government
def acceptable_to?(some_action)
not is_government
end
#!/usr/bin/env ruby
# liberal_sort_by.rb
class Array
def liberal_sort
liberal_sort_by { |x| x }
end
def liberal_sort_by(&block)
pertains, others = partition(&block)
pertains.sort_by(&block) + others
#!/usr/bin/env ruby
# vehicle.rb
class Vehicle
MEDIUM = :ground
def self.medium; self::MEDIUM; end
# Using MEDIUM instead of self::MEDIUM makes Aircraft use the ground
end
class Car < Vehicle; end
@kbaird
kbaird / greek_lambda.rb
Created December 20, 2011 20:09
Nerdy syntactic sugar to allow the Greek letter lambda for Procs in Ruby.
# encoding: UTF-8
module Kernel
alias_method :λ, :lambda
end
=begin
Allows code like this, using the actual Greek λ character:
@kbaird
kbaird / git_binary_diff_gist
Created May 10, 2012 16:01
Binary diff setup in .git/config
[diff "bz2"]
binary = true
textconv = /bin/bzcat
[diff "gzip"]
binary = true
textconv = /bin/zcat
[diff "tar"]
binary = true
textconv = tar --to-stdout -xf
[diff "tar-bz2"]
@kbaird
kbaird / inheritance.js
Created August 8, 2012 19:17
Simple JavaScript subclassing
/*
* Simple JS subclassing, shamelessly stolen from
* http://kevinoncode.blogspot.com/2011/04/understanding-javascript-inheritance.html
*/
function Super() {
this.value = 42;
}
function Sub(parent) {