Skip to content

Instantly share code, notes, and snippets.

View jstirk's full-sized avatar

Jason Stirk jstirk

View GitHub Profile
@jstirk
jstirk / authentication_helpers.rb
Created January 23, 2013 02:05
Put these in spec/support/ , but not example_request_spec.rb
module AuthenticationHelpers
def log_in_as(model)
login_as(model)
end
end
RSpec.configure do |config|
config.include AuthenticationHelpers, :type => :request
config.include Devise::TestHelpers, :type => :controller
end
@jstirk
jstirk / .vimrc
Created September 19, 2012 02:25
vim whitespace helpers
" ,W to strip all trailing whitespace
nnoremap <leader>W mZ:%s/\s\+$//<cr>:let @/=''<CR>`Z
" Display trailing spaces and tabs differently. In this case,
" show them as dark grey, and with certain characters.
set list listchars=tab:⇀\ ,trail:.
:highlight SpecialKey ctermfg=darkgrey guibg=black
@jstirk
jstirk / .bashrc
Created August 14, 2012 04:42
.bashrc example with branch and RVM info
# Add our current git branch out to our path
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
format_git_branch() {
parse_git_branch | sed -e 's/\(.*\)/(\1)/'
}
rvm_prompt() {
@jstirk
jstirk / policy
Created August 14, 2012 02:36
S3 IAM Additional User has access to bucket
{
"Statement": [
{
"Sid": "Stmt1344909032464",
"Action": [
"s3:*"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::BUCKETNAME",
@jstirk
jstirk / example.rb
Created May 25, 2012 03:17 — forked from mikel/example.rb
Range Fun in Ruby
(-10..-5).include?(-7)
#=> true
(-5..-10).include?(-7)
#=> false
(10..5).include?(7)
#=> false
(5..10).include?(7)
#=> true
# OK, so maybe 10..5 wraps the whole set of integers?
@jstirk
jstirk / aa
Created March 15, 2012 00:41
Growlnotify CLI wrapper
#!/bin/bash
# Author: Jason Stirk (http://griffin.oobleyboo.com)
# Simple growlnotifu wrapper using return values
# Usage:
# aa <command to execute>
#
# If the command returns with a successful return value, growlnotify will
# be executed and will show the command used.
# If the command returns a failure (non-zero) return value, growlnotify will
# show the same message, but will include the "critical" urgency, which will
Rubinius Crash Report #rbxcrashreport
Error: signal �SIGSEGV
[[Backtrace]]
0 rbx 0x00000001090a3b11 _ZN8rubiniusL12segv_handlerEi + 241�
1 libsystem_c.dylib 0x00007fff8e264cfa _sigtramp + 26�
2 ??? 0x00007fff68c85330 0x0 + 140734951346992�
3 libcrypto.0.9.8.dylib 0x00007fff954133e4 CRYPTO_set_ex_data + 36�
4 openssl.bundle 0x000000010c7ef699 ossl_x509store_set_vfy_cb + 57�
@jstirk
jstirk / rescue_from.rb
Created December 9, 2011 02:27
rescue_from tracer
module ActiveSupport::Rescuable::ClassMethods
alias :old_rescue_from :rescue_from
def rescue_from(*k,&b)
Rails.logger.debug "rescue_from!!!!! #{self.name} (#{k.inspect})"
Rails.logger.debug caller.join("\n")
old_rescue_from(*k, &b)
end
end
@jstirk
jstirk / modules.rb
Created July 27, 2011 07:37
TIL 20110727
module AA
module BB
module CC
end
end
end
class Foo
include AA::BB
end
#!/usr/bin/env ruby
# Quick and dirty FSEvent watcher.
# Example:
# rr spec/lib/foo lib/foo 'spec spec/lib/foo/*_spec.rb'
#
# Will watch the spec/lib directory for any changes, and run the given command for each change,
# dumping the output to STDOUT.
require 'rubygems'
require 'rb-fsevent'