Skip to content

Instantly share code, notes, and snippets.

View ystros's full-sized avatar

Brian Upton ystros

  • San Francisco, CA
View GitHub Profile

Keybase proof

I hereby claim:

  • I am ystros on github.
  • I am ystros (https://keybase.io/ystros) on keybase.
  • I have a public key whose fingerprint is 3E11 823D 0167 6AEC 4E37 EF54 99AF EBBA 1CB2 984E

To claim this, I am signing this object:

@ystros
ystros / gist:5833519
Created June 21, 2013 19:02
tmux.conf
# action key
set -g prefix C-a
set-option -g default-command "reattach-to-user-namespace -l bash"
# vi keys
set-window-option -g mode-keys vi
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-selection
# windows
@ystros
ystros / safe_mocks_methods.rb
Last active December 16, 2015 03:29
RSpec safe stub
module RSpec
module SafeMocks
class MethodMustExistError < Exception
end
module Methods
def safe_stub(message_or_hash, opts={}, &block)
messages = Hash === message_or_hash ? message_or_hash.keys : Array.wrap(message_or_hash.to_sym)
messages.each do |message|
raise RSpec::SafeMocks::MethodMustExistError, "Stubbed method #{message.inspect} does not exist on #{self.inspect}" unless self.respond_to?(message)
@ystros
ystros / devise_sign_in_uninteded_save_controller.rb
Created October 24, 2012 06:39
Unintentional invalid save when using Devise sign_in
class User
validates :some_attribute, :presence => true
end
class DeviseSignInUnintendedSaveController
def foo
user.update_attributes :some_attribute => nil # returns false; user.some_attribute is not nil in the database
sign_in user # oops! This bypasses validation when saving Devise specific fields, so the invalid change above gets persisted.
end
end