Skip to content

Instantly share code, notes, and snippets.

View kwstannard's full-sized avatar

Wolf kwstannard

  • Andros
  • New York City
View GitHub Profile
@kwstannard
kwstannard / foo.bash
Created September 23, 2014 21:05
pro bash rename
find ./ -name rollout_ui | sed 's/\(.*\)/\1\/ \1/' | sed 's/rollout_ui$/lk_rollout_ui/' | xargs -n2 git mv
@kwstannard
kwstannard / ruby.rb
Last active August 29, 2015 14:06
auto disable failing features if they break
#pseudo code
class Rollout
def auto_disable(feature, user, feature_block, old_block)
if active?(feature, user)
begin
yield feature_block
rescue => e
deactivate(feature)
raise e
class UserFinder
def self.find(id)
record = User.find(id)
"#{record.user_type}User".constantize.new(record)
end
end
class User < ActiveRecord::Base
end
class SemiOpenStruct
def initialize(hash={})
@hash = hash
end
def method_missing(method,*args,&block)
@hash[method] ||
__try_hash_setter(method,*args,&block) ||
super
end
@test "tmux is installed and in the path" {
which vim
which derp
}
Uploading /tmp/busser/suites/bats/vim_stuff.rb (mode=0644)
-----> Running bats test suite
0 tests, 0 failures
Finished verifying <default-ubuntu-1204> (0m1.05s).
[4] pry(main)> mod = Module.new
=> #<Module:0x007fa1ac93c650>
[5] pry(main)> mod::Foo = Class.new
=> #<Class:0x007fa1ae5ad7f8>
[6] pry(main)> mod::Foo
=> #<Class:0x007fa1ae5ad7f8>
[7] pry(main)> mod::Foo.parent
=> Object
module Common
module Client
module FaradayConnection
end
end
end
module Pullson
@kwstannard
kwstannard / lookupfailure.rb
Last active August 29, 2015 14:12
Ruby inconsistency in constant lookup
module A
module B
end
end
module C
include A
puts B.inspect # => A::B
@kwstannard
kwstannard / foo.rb
Last active August 29, 2015 14:14
Ruby proxy method
class Proxy
def proxy(context, &blk)
@context = context
@blk = blk
end
def method_missing(method, *args, &blk)
__object.send(method, *args, &blk)
end
@kwstannard
kwstannard / proxy.rb
Created February 3, 2015 15:29
Ruby Proxy
class Proxy
def self.proxy(context, &blk)
p = new(context)
p.__proxy &blk
p
end
def initialize(context)
@context = context
end