This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
### BEGIN INIT INFO | |
# Provides: unicorn | |
# Required-Start: $local_fs $remote_fs $network $syslog | |
# Required-Stop: $local_fs $remote_fs $network $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: starts the unicorn web server | |
# Description: starts unicorn |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set nocompatible | |
let mapleader = "," | |
call pathogen#infect() | |
syntax on | |
filetype plugin indent on | |
color herald |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Given I have the following users: | |
| company | user | | |
| ACME | bob | | |
| ACME | jim | | |
Given /I have the following users/ do |users| | |
users.hashes.each do |user_attributes| | |
company_name = user_attributes.delete('company') | |
company = Company.find_by_name(company_name) || Company.make(:name => company_name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
flatten = (a) -> | |
if a.length is 0 then return [] | |
a.reduce (lhs, rhs) -> lhs.concat rhs | |
divmod = (x, y) -> | |
[(q = Math.floor(x/y)), (r = if x < y then x else x % y)] | |
valid = (number) -> | |
num = ((Number) x for x in number).reverse() | |
num = (2 * x for x in num[1..num.length] by 2).concat( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task "resque:setup" => :environment do | |
# since our priorized job classes are generated dynamically, | |
# we need to explicitly load all jobs to trigger the generation. | |
Dir[Rails.root.join("app/models/jobs/*.rb")].each do |job_defn| | |
require File.expand_path(job_defn) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SalesOrderMailerJob | |
@queue = :critical # you can make this up | |
def self.perform(sales_order_id) | |
SalesOrderMailer.deliver_something(SalesOrder.find(sales_order_id)) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveRecord | |
module ConnectionAdapters | |
class AbstractAdapter | |
protected | |
# Turn: | |
# User Load (6.3ms) SELECT * FROM "users" | |
# Into: | |
# User Load /app/views/_partial.erb:27 (6.3ms) in `_app_views_partial_erb` SELECT * FROM "users" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Toss this in your ~/.irbrc file for a convenient way | |
# to peruse Ruby source code in TextMate. This | |
# only works in Ruby 1.9! | |
# | |
# Use it in irb like so: | |
# | |
# >> require 'active_record' | |
# >> ActiveRecord::Base.source_for_method(:create) | |
class Object |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "appscript" | |
class AppResizer | |
include Appscript | |
# Full screen bounds for all modes. | |
HOME_FULL_SCREEN = [0, 0, 2560, 1440] | |
LAPTOP_FULL_SCREEN = [0, 0, 1440, 900] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pry(main):4> blame_for(Pry.instance_method(:repl)).display | |
John Mair def repl(target=TOPLEVEL_BINDING) | |
John Mair target = Pry.binding_for(target) | |
John Mair target_self = target.eval('self') | |
John Mair | |
John Mair repl_prologue(target) | |
Mon ouïe | |
John Mair # cannot rely on nesting.level as | |
John Mair # nesting.level changes with new sessions | |
John Mair nesting_level = nesting.size |