Skip to content

Instantly share code, notes, and snippets.

@jtrim
jtrim / .vimrc
Created September 28, 2015 19:44
function! g:FocusAndDispatchTestLine()
execute "Focus test-unit-runner %:" . line(".") . " -p"
execute "Dispatch"
endfunction
function! g:FocusAndDispatchTestFile()
execute "Focus test-unit-runner % -p"
execute "Dispatch"
endfunction
VCR.configure do |config|
config.cassette_library_dir = "test/fixtures/cassettes"
config.hook_into :webmock
config.default_cassette_options = {
record: :once
}
config.before_record do |i|
if i.response.headers["Content-Type"].any? { |h| h =~ /json/ }
# Try to pretty format json body, rescue and proceed if it's not possible
i.response.body.replace JSON.pretty_generate(JSON.parse(i.response.body)) rescue nil
" Vim compiler file
" Language: RSpec
" Maintainer: Tim Pope <[email protected]>
" URL: https://github.com/vim-ruby/vim-ruby
" Release Coordinator: Doug Kearns <[email protected]>
if exists("current_compiler")
finish
endif
let current_compiler = "rspec"
@jtrim
jtrim / routes
Last active August 29, 2015 14:16
#!/bin/bash
ROUTES_CACHE_FILE="tmp/routes_cache.txt"
if [ "$1" == "clear" ]; then
if [ "$2" != "--yes" ]; then
echo -n "Removing ${ROUTES_CACHE_FILE}: are you sure? [yn] "
read yes
if [ "$yes" != "y" ]; then
echo "Didn't get 'y'. Bailing..."
let theStuff = ["foo", "bar", "baz"]
-- in foldl............................................. vvv is first, vvv is second...
let wtffoldl = foldl iterator "" theStuff where iterator concatedStuffs stuff = concatedStuffs ++ stuff
-- ...but in foldr.......................................vvv and vvv are reversed.
let wtffoldr = foldr iterator [] theStuff where iterator stuff concatedStuffs = stuff ++ concatedStuffs
class Activation
def initialize(user, activation_token)
@user, @activation_token = user, activation_token
end
def activate
if @user.activation_token == hash_token(@activation_token)
@user.update_attributes!({
activated_at: Time.now,
locked_at: nil,
class Activation
# ...initialization...
def activate
if @user.activation_token == hash_token(@activation_token)
@user.update_attributes!({
activated_at: Time.now,
locked_at: nil,
activation_token: nil
})
class Activation
# ...initialization...
def activate
if user.activation_token == hash_token(activation_token)
user.update_attributes!({
activated_at: Time.now,
locked_at: nil,
activation_token: nil
})
class Activation < Struct.new(:user, :activation_token)
def activate
if user.activation_token == hash_token(activation_token)
user.update_attributes!({
activated_at: Time.now,
locked_at: nil,
activation_token: nil
})
end
end
def array_reverse(array)
return array if array.empty?
[array.pop] + array_reverse(array)
end