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 / 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 \
@davidlee
davidlee / ubuntu-chef-client-install.sh
Created April 27, 2010 05:31
#CHEF ubuntu 9.10 fresh install to registered client - just change the server address
#!/bin/sh
# set up FQDN
echo "you better have a hostname, or shit won't work!"
echo "and, we expect /etc/chef/validation.pem to exist and match the server"
sleep 1
# install packages
apt-get install ruby ruby1.8-dev libopenssl-ruby1.8 rdoc ri irb build-essential wget ssl-cert git-core
How to determine whether to buy a tool for your employee
v = xp + cr
x = total cost of employee (usually approx. double their salary) over
useful lifetime of tool
p = productivity gain provided by tool, expressed as a fraction of x
c = increase in employee retention provided by tool, expressed as a
fraction of 1
r = total cost of hiring and training a replacement to current
module MultiLogger
def also_log_to file, &block
@_original_logger, self.logger = logger, ActiveSupport::BufferedLogger.new(file)
yield
self.logger, @_original_logger = logger, nil
end
end
# in application.rb:
# gem completions
# this is a guess. salt to taste.
export GEM_SEARCH_PATH=`ruby -e 'require "rubygems"; puts Gem.path.first'`/gems
# completion fuction for compdef: just lists the gems folders
_gems() { compadd `cd $GEM_SEARCH_PATH; echo *` }
compdef _gems gemcd ; gemcd() { cd $GEM_SEARCH_PATH/$1 }
compdef _gems gemedit ; gemedit() { mate $GEM_SEARCH_PATH/$1 }
deploy@dvsyd2nxpdev01:/usr/share/emacs/22.2/lisp$ apt-file search zone.elc
emacs-snapshot-common: /usr/share/emacs/23.0.60/lisp/play/zone.elc
emacs-snapshot-common: /usr/share/emacs/23.0.60/lisp/timezone.elc
emacs21-common: /usr/share/emacs/21.4/lisp/play/zone.elc
emacs21-common: /usr/share/emacs/21.4/lisp/timezone.elc
emacs22-common: /usr/share/emacs/22.2/lisp/play/zone.elc
emacs22-common: /usr/share/emacs/22.2/lisp/timezone.elc
xemacs21-basesupport: /usr/share/xemacs21/xemacs-packages/lisp/xemacs-base/timezone.elc