Skip to content

Instantly share code, notes, and snippets.

View davidlee's full-sized avatar

David Lee davidlee

  • Melbourne, Australia
View GitHub Profile
@davidlee
davidlee / MNEM spec
Created June 17, 2011 10:05
MNEM - the object database I'd quite like
;; This buffer is for notes you don't want to save, and for Lisp
;; evaluation. If you want to create a file, visit that file with C-x
;; C-f, then enter the text in that file's own buffer.
MNEM
An object database which stores and manipulates simple structures of
data (hashes, arrays, strings, and numbers), knows how to talk JSON,
keeps a copy of everything that has ever been entered, and implements
updates as pull requests.
@davidlee
davidlee / quickfind.rb
Created March 24, 2011 05:30
AR enums
module Quickfind
module ClassMethods
def quick_finder(field)
metaclass = class << self; self; end
klass = self
class_eval do
@@quickfinder = field
end
exportgems() {
export GEMPATH=`gem env gempath | sed 's/:.*$//'`/gems
}
exportgems;
# completion fuction for compdef: just lists the gems folders
_gems() { compadd `cd $GEMPATH; echo *` }
compdef _gems gcd ; gcd() { cd $GEMPATH/$1 }
@davidlee
davidlee / gist:637603
Created October 20, 2010 23:51
autoloads.rb
begin
require 'term/ansicolor'
rescue LoadError
end
module Kernel
def autoloads(lib_dir)
base_dir = File.expand_path File.join(Rails.root, lib_dir)
class Array
def columns(padding=1)
col_sizes = inject([]) do |sizes, row|
row.each_with_index.each do |col, i|
sizes[i] = [sizes[i], col.to_s.length].compact.max
end
sizes
end
out = []
each do |row|
@davidlee
davidlee / Autoload Hax
Created May 27, 2010 00:56
Simple DRY autoloading
# simple, DRY autoloading
require 'active_support'
class Module
def const_missing_with_mojo mod
# HACK ALERT eject if activesupport voodoo is interfering
targ = caller.reject {|x| x =~ /active_?support/ }[0].split(':').first
autoload_path targ
if const_defined? mod
const_get mod
module Spec
module Example
module ExampleGroupMethods
def slow_specs &bl
bl.call() if run_slow_specs?
end
def run_slow_specs?
ENV['SLOW_SPECS']
;;
;; color-theme-sore-eyes.el
;;
;; Made by David Lee
;; Login <[email protected]>
;;
;; Started on Mon Jul 21 12:05:27 2008 David Lee
;; Last update Mon Jul 21 12:05:27 2008 David Lee
;;
(eval-when-compile
;;
;; color-theme-dml.el
;;
;; Made by David Lee
;; Login <[email protected]>
;;
;; Started on Mon Jul 21 12:05:27 2008 David Lee
;; Last update Mon Jul 21 12:05:27 2008 David Lee
;;
(eval-when-compile
Add "+universal" to /opt/local/etc/macports/variants.conf
Uncomment in /opt/local/etc/macports.conf:
variants_conf /opt/local/etc/macports/variants.conf
sudo port -v install git-core +bash_completion +doc
sudo port -v install ImageMagick \
Xft2 \
antiword \
atk \