Skip to content

Instantly share code, notes, and snippets.

View mig's full-sized avatar

Matthew Swasey mig

  • LivingSocial
  • Washington DC
View GitHub Profile
"192.168.1.1:8000".named_matches(/(?<ip>\d.+):(?<port>\d+)/)
#=> [{"ip"=>"192.168.1.1", "port"=>"8000"}]
@mig
mig / init.el
Created January 18, 2011 21:00
Simple Emacs 24 configuration for Rails development
;; emacs configuration
(push "/usr/local/bin" exec-path)
(add-to-list 'load-path "~/.emacs.d")
(setq make-backup-files nil)
(setq auto-save-default nil)
(setq-default tab-width 2)
(setq-default indent-tabs-mode nil)
(setq inhibit-startup-message t)
@mig
mig / zshrc
Created January 18, 2011 15:14
User zshrc for OpenBSD 4.8
# ZSH config
# Encoding
LANG=en_US.UTF-8
# Path
export PATH=$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:/usr/games:.
# Appearence
# ls colors
@mig
mig / minispec.rb
Created October 31, 2010 21:28
I want to use minitest in a Rails project with spec like syntax (work in progress)
class Object
cattr_accessor :current_test
end
module Minispec
class TestClass
def self.prepare(desc)
name = name_for_class(desc)
Class.new(base_test_class(name)) do
define_singleton_method(:name) { name }
(function ($) {
// Monkey patch jQuery 1.3.1+ css() method to support CSS 'transform'
// property uniformly across Webkit/Safari/Chrome and Firefox 3.5.
// 2009 Zachary Johnson www.zachstronaut.com
function getTransformProperty(element)
{
// Try transform first for forward compatibility
var properties = ['transform', 'WebkitTransform', 'MozTransform'];
var p;
while (p = properties.shift())
@mig
mig / custom.el
Created February 17, 2010 17:16
Ubuntu custom emacs
;; custom for ubuntu
(setq gem_home "/home/mig/.gem")
(setenv "GEM_HOME" gem_home)
;; Swap alt and meta in emacs
; (setq x-super-keysym 'meta)
(setq x-select-enable-clipboard t)
(setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
@mig
mig / custom-keybindings.el
Created December 31, 2009 19:15
OSX emacs custom
;; emacs-key-bindings.el - bindings that make life easier
(global-set-key (kbd "C-c b") 'eval-buffer)
(global-set-key (kbd "C-x f") 'recentf-ido-find-file)
(global-set-key (kbd "M-s") 'save-buffer)
(global-set-key (kbd "M-z") 'undo)
;; set line commenting to textmate style
(global-set-key (kbd "M-/") 'comment-or-uncomment-region)
@mig
mig / color-theme-topfunky.el
Created December 29, 2009 16:01
color-theme-topfunky
;; Experimental theme by Geoffrey Grosenbach
;;
;; SCREENSHOT: http://blog.peepcode.com/tutorials/2009/ruby-emacs-flog
;;
;; USAGE:
;; Copy to your emacs config directory, load it, and activate.
;;
;; ;; Requires the color-theme package:
;; (add-to-list 'load-path (concat dotfiles-dir "/vendor/color-theme"))
;; (require 'color-theme)
module ActiveRecord
class Errors
# Redefine the ActiveRecord::Errors::full_messages method:
# Returns all the full error messages in an array. 'Base' messages are handled as usual.
# Non-base messages are prefixed with the attribute name as usual UNLESS they begin with '^'
# in which case the attribute name is omitted.
# E.g. validates_acceptance_of :accepted_terms, :message => '^Please accept the terms of service'
def full_messages
full_messages = []
@mig
mig / deploy.rake
Created November 9, 2009 22:00
Hot capistrano replacement
task :deploy do
`rsync -rltvz -e ssh . deploy@hostname:/var/www/apps/my_app`
`ssh deploy@hostname touch /var/www/apps/my_app/public/restart.txt`
end