- xcode cli tools
- brew
$ brew tap homebrew/dupes
- apple-gcc42
- mysql
- postgres
- redis
class Foo | |
attr_reader :adapter | |
def initialize | |
@adapter = if Rails.env.production? | |
Foo::RealAdapter.new | |
else | |
Foo::StubAdapter.new | |
end |
module PolymorphicQueryHelper | |
class << self | |
def expand_polymorphic_hash(hash) | |
{}.tap do |expanded_hash| | |
for name, object in hash | |
expanded_hash.merge!({ | |
"#{name}_id".to_sym => object.id, | |
"#{name}_type".to_sym => object.class.name | |
}) |
class Order | |
include Stats::Host | |
# The above would mix this in: | |
has_one :stat, class_name: "Order::Stat" | |
after_commit :create_stat, on: :create | |
def create_stat | |
stat.create! |
class Analyzer | |
class << self | |
include ActionView::Helpers::NumberHelper | |
end | |
CACHE_NAMESPACE = "analyzer" | |
CACHE_LIFESPAN = 10.minutes | |
class_attribute :items_to_analyze |
export HEROKU_STG_APP=stg-app-name | |
export HEROKU_PROD_APP=prod-app-name |
/* | |
* Usage: | |
* h1 { | |
* font-size: 2em; | |
* @include media(small) { | |
* font-size: 1.5em; | |
* } | |
* } | |
*/ | |
@mixin media($media) { |
# link_to path | |
user_omniauth_authorize_path(:facebook, origin: request.fullpath) | |
# in ApplicationController | |
def after_sign_in_path_for(resource) | |
stored_location_for(resource) || request.env['omniauth.origin'] || root_path | |
end |
// GitHub already has jQuery loaded, so we can use it for free! | |
titles = []; $(".info-wrapper h3 a").each(function () { number = $(this).closest("td").prev("td.number").text().match(/\d+/)[0]; titles.push("#" + number + " " + $(this).text()) }); titles.join("\n"); |
# Git pull and rebase | |
# Show git log if rebasing finds new changes | |
# You can optionally pass in a remote and branch | |
function gpr { | |
output=`git pull --rebase $1 $2` | |
echo $output | |
if [[ $output != *is\ up\ to\ date\.* ]] then | |
git log -n 3 | |
fi | |
} |