Skip to content

Instantly share code, notes, and snippets.

View griffithac's full-sized avatar

Andrew Griffith griffithac

View GitHub Profile
defaults write NSGlobalDomain KeyRepeat -int 1
defaults write NSGlobalDomain InitialKeyRepeat -int 10
@griffithac
griffithac / slim_cloc
Last active August 29, 2015 14:21
cloc alternitive for slim files
find . -name \*.slim -type f -exec cat {} + | sed '/^\s*#/d;/^\s*$/d' | wc -l
@griffithac
griffithac / schedule.rb
Last active December 25, 2015 03:29
Fix issue with timezones and the whenever gem.
# schedule.rb
set :output, "/path/to/log/cron.log"
# Requires that your production server is set to UTC time
# Subclass Time and override self.parse to adjust for timezone offset
class TimeInZone < Time
def initialize
super
end
@griffithac
griffithac / ssh_proxy.md
Last active December 18, 2015 13:39
SSH HTTP Proxy Setup

SSH HTTP Proxy Setup

ssh -C2qTnN -D 8080 gsm
@griffithac
griffithac / ownership.md
Last active October 13, 2015 18:47
Add Ownership to Rails 3 App

Add Modules to Your App

Ownership::Model Ownership::Controller

Include Modules in your Model and Controller

class Post < ActiveRecord::Base
@griffithac
griffithac / setup.md
Last active October 13, 2015 18:18 — forked from georgeredinger/setup.md
Ruby on Rails development setup on Ubuntu 12.04 (gedit, git, rbenv)

Ruby on Rails production setup on Ubuntu 12.04

System update

# change mirror to ubuntu.osuosl.org first
sudo apt-get update

Install common libraries

sudo apt-get install build-essential libreadline-dev libssl-dev zlib1g-dev libxml2-dev libxslt-dev

@griffithac
griffithac / gist:2902563
Created June 9, 2012 20:52
Sum and Average Virtual Attributes in ActiveRecord
class ActiveRecord::Base
# Totals the virtual attributes of a collection
def self.vsum collection, v_attr
total = 0
collection.each { |collect| total += collect.method(v_attr.to_s).call }
return total
end
# Avarages the virtual attributes of a collection