Skip to content

Instantly share code, notes, and snippets.

View jeffrafter's full-sized avatar
You are amazing

Jeff Rafter (he/him) jeffrafter

You are amazing
View GitHub Profile
# Reset
Color_Off='\e[0m' # Text Reset
# Regular Colors
Black='\e[0;30m' # Black
Red='\e[0;31m' # Red
Green='\e[0;32m' # Green
Yellow='\e[0;33m' # Yellow
Blue='\e[0;34m' # Blue
Purple='\e[0;35m' # Purple
@jeffrafter
jeffrafter / .bashrc
Created February 4, 2013 17:21
Basic Bash
export HISTCONTROL=ignoredups
export INPUTRC="~/.inputrc"
export EDITOR='open -a /Applications/MacVim.app -f'
shopt -s checkwinsize
shopt -s cdspell
shopt -s histappend
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
@jeffrafter
jeffrafter / precompile.sh
Created November 15, 2012 10:17
A script that recurses though asset:pipeline style trees, joins and compresses the result
#!/bin/sh
# Make the structure
mkdir -p public/assets/javascripts
mkdir -p public/assets/stylesheets
mkdir -p public/assets/images
# Images - handle these first so that the resulting md5 hashed names can be inserted
" Functions
function! <SID>StripTrailingWhitespaces()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
%s/\s\+$//e
" Clean up: restore previous search history, and cursor position
let @/=_s
@jeffrafter
jeffrafter / .growl
Created July 25, 2012 16:15
Don't Growl, Say.
module Growl
def notify_with_say(message = nil, options = {}, &block)
message = message.gsub(/in\s*[0-9\.]+\s*seconds$/, '')
`say -v Virginie "#{message}"`
return
end
alias_method_chain :notify, :say
module_function :notify
class Center < ActiveRecord::Base
belongs_to :thing
validates :thing_id, :presence => true
end
#----------------------------------------------------------------------
# Vagrant quirks
#----------------------------------------------------------------------
# Vagrant has Ruby in /opt/ruby/bin, but it is not available to `sudo`
# by default. We need to do some sed-fu here in order to enable that.
# This better mimicks production. Ideally, however, we would have a base
# box that exactly mimics production.
if node[:environment] == "development"
node[:sudo][:options] << "!secure_path"
end
*snip*
# The config file format is like
#
# dropbox:
# app_key: YOUR_APP_KEY
# app_secret: YOUR_APP_SECRET
# storage:
# provider: AWS
# aws_access_key_id: YOUR_ACCESS_KEY
# http://unicorn.bogomips.org/SIGNALS.html
God.watch do |w|
w.name = "unicorn"
w.interval = 30.seconds # default
# unicorn needs to be run from the rails root
w.start = "cd #{RAILS_ROOT} && #{BIN_PATH}/unicorn_rails -c #{RAILS_ROOT}/config/unicorn.rb -E #{RAILS_ENV} -D"
# QUIT gracefully shuts down workers
@jeffrafter
jeffrafter / action_mailer_abort.rb
Last active September 30, 2015 07:47
Abortable Action Mailer (no longer needed)
module AbortableMailer
class UndeliverableMailMessage < Mail::Message
def self.deliver
false
end
def self.deliver!
false
end
end