Skip to content

Instantly share code, notes, and snippets.

View mig's full-sized avatar

Matthew Swasey mig

  • LivingSocial
  • Washington DC
View GitHub Profile
# outtolunch_template
file 'config/routes.rb', <<-CODE
ActionController::Routing::Routes.draw do |map|
end
CODE
file 'config/initializers/uri_ext.rb', <<-CODE
URI::PATTERN::UNRESERVED.replace("+-_.!~*'()a-zA-Z\\d")
CODE
(function($) {
$.fn.defaultvalue = function() {
// Scope
var elements = this;
var args = arguments;
var c = 0;
return(
elements.each(function() {
$(this).css('color', '#aaa');
@mig
mig / Capfile
Created November 5, 2009 19:42
require 'capistrano/version'
load 'deploy'
# Customize the following variables
set :domain, "host.example.com"
set :user, "username"
set :application, "my_wordpress_blog"
set :deploy_to, "/var/www/apps/#{application}"
# These variables probably don't need to change
@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
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 / 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)
@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 / 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)
(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 / 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 }