Skip to content

Instantly share code, notes, and snippets.


Matthew Swasey mig

  • LivingSocial
  • Washington DC
View GitHub Profile
mig / initializable.rb
Created Jun 3, 2014
Benchmark initializer load time
View initializable.rb
# place in railties/lib/rails/initializable.rb
def run_initializers(group=:default, *args)
return if instance_variable_defined?(:@ran)
t0 =
initializers.tsort.each do |initializer|
t =*args) if initializer.belongs_to?(group)
puts("%60s: %.3f sec" % [, - t])
mig /
Created Oct 23, 2014
arch linux install for vmware
# make 2 partitions on the disk.
parted -s /dev/sda mktable msdos
parted -s /dev/sda mkpart primary 0% 100m
parted -s /dev/sda mkpart primary 100m 100%
# make filesystems
# /boot
mkfs.ext2 /dev/sda1
# /
mkfs.btrfs /dev/sda2
mig / gist:4090
Created Aug 5, 2008
methods from serialized attributes
View gist:4090
def attr_serialized_on(column, *attributes)
attributes.each do |a|
class_eval do
define_method(a) { meta(a) }
define_method(a.to_s + "=(value)") { metadata[a] = value }
mig / application.rb
Created Aug 12, 2008
simple authentication
View application.rb
class ApplicationController < ActionController::Base
include Authentication
# The rest of your codes go here
View application.html.erb
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="" xml:lang="en" lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<%= yield_page_info %>
mig / sqlite3_in_memory.rb
Created Dec 14, 2008
sqlite3 in memory test db
View sqlite3_in_memory.rb
# Update: Looks for the SQLite and SQLite3 adapters for
# compatibility with Rails 1.2.2 and also older versions.
def in_memory_database?
if ENV["RAILS_ENV"] == "test" and
(['test']['database'] == ':memory:' or['test']['dbfile'] == ':memory:')
if ActiveRecord::Base.connection.class == ActiveRecord::ConnectionAdapters::SQLite3Adapter
return true
mig / build-emacs-fedora10.rb
Created Dec 24, 2008 — forked from wfarr/build-emacs-osx.rb
build and install osx emacs from source
View build-emacs-fedora10.rb
#!/bin/env ruby
require 'fileutils'
config_opts = ["--with-jpeg=no", "--with-gif=no", "--with-tiff=no", "--with-ns"]
source_dir = "#{ENV['HOME']}/src"
repo_dir = "#{source_dir}/emacs"
#install_dir = "#{repo_dir}/nextstep/"
#install_target = "/Applications/"
View happy_flash.css
div.error {
font-size: 18px;
padding: 15px 10px;
margin-bottom: 10px;
div.notice span,
div.warning span,
mig / font-size.el
Created Jan 9, 2009
font zooming in emacs
View font-size.el
;; font-size.el -- font zoomer
;; code from Ola Bini:
;; replaced fonts with OSX fonts
(defun inc-font-size ()
(let* ((current-font (cdr (assoc 'font (frame-parameters))))
(splitted (split-string current-font "-"))
(new-size (+ (string-to-number (nth 7 splitted)) 1))
(new-font (concat (nth 0 splitted) "-"
View gummy_blue.css
div#Header {
background: #4E9FCF !important;
color:#fff !important;
div.SidebarReminder h2 {
color: #4E9FCF !important;
div#Sidebar div#Pages div.pagesnav a:link,