Ken Mayer kmayer

View trustctime.rb
1 2 3 4 5
# http://www.git-tower.com/blog/make-git-rebase-safe-on-osx/
execute "mistrust ctime" do
command "git config --global core.trustctime #{node['git']['trustctime'].to_s }"
user node['current_user']
end
View fizzbuzz.rb
1 2 3 4 5 6 7 8 9 10
# How to use and experiment
# $ irb -I. -rfizzbuzz
# => fb = FizzBuzz.new
# => fb.enumerator_with_array_indices.take(30) == FizzBuzz.EXPECTATIONS
# => true
 
class FizzBuzz
EXPECTATIONS=[1, 2, "Fizz", 4, "Buzz", "Fizz", 7, 8, "Fizz", "Buzz", 11, "Fizz", 13, 14, "FizzBuzz", 16, 17, "Fizz", 19, "Buzz", "Fizz", 22, 23, "Fizz", "Buzz", 26, "Fizz", 28, 29, "FizzBuzz"]
 
def shortest # 100 chars of ruby
View sidekiq.rb
1 2 3 4 5 6 7 8 9 10
module NewRelic
class SidekiqException
def call(worker, msg, queue)
begin
yield
rescue => exception
NewRelic::Agent.notice_error(exception, :custom_params => msg)
raise exception
end
end
View player.rb
1 2 3 4 5 6 7 8 9 10
Command = Struct.new(:method, :direction)
 
class Command
def initialize(m, *args)
@method = m
@direction = args
end
def perform(warrior)
warrior.send(@method, *@direction)
View heuristics.rb
1 2 3 4 5 6 7 8 9
module Heuristics
TARGET_PRIORITY = {
RubyWarrior::Units::Archer => 1,
RubyWarrior::Units::Wizard => 2,
RubyWarrior::Units::ThickSludge => 3,
RubyWarrior::Units::Sludge => 4,
RubyWarrior::Units::Captive => 999,
RubyWarrior::Units::Warrior => 999,
}
View SpecRunner.html
1 2 3 4 5 6 7 8 9
<!DOCTYPE html>
<html>
<head>
<title>Jasmine Spec Runner</title>
 
<link rel="shortcut icon" type="image/png" href="jasmine-1.3.1/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="jasmine-1.3.1/jasmine.css">
<script type="text/javascript" src="jasmine-1.3.1/jasmine.js"></script>
<script type="text/javascript" src="jasmine-1.3.1/jasmine-html.js"></script>
View object_creation_methods.diff
1 2 3 4 5 6 7 8 9 10
private
 
- def method_missing(method, *args)
- if method.to_s =~ /^create_(.+)$/
- send("new_#{$1}", *args).tap(&:save!)
- else
- super
- end
+ def self.included(base)
+ ObjectCreationMethods.public_instance_methods(false).each do |new_method_name|
View object_creation_methods.diff
1 2 3 4 5 6 7 8 9 10
- def create_user(overrides = {})
- new_user(overrides).tap(&:save!)
- end
-
private
+ def method_missing(method, *args)
+ if method.to_s =~ /^create_(.+)$/
+ send("new_#{$1}", *args).tap(&:save!)
View object_creation_methods.rb
1 2 3 4 5 6 7 8 9 10
module ObjectCreationMethods
def new_user(attributes = {})
defaults = {
email: "user#{counter}@example.com",
password: "password",
}
User.new { |user| apply(user, defaults, overrides) }
end
 
def create_user(attributes = {})
View gist:3869451
1 2 3 4 5 6 7 8 9 10
# Extensions to heroku_san tasks
# Never runs on Heroku
 
if Rails.env.development?
STAGES = %w[ci acceptance staging production]
 
require 'auto_tagger'
 
def create_and_push(stage)
auto_tag = AutoTagger::Base.new(stages: STAGES, stage: stage, verbose: true, push_refs: false, refs_to_keep: 100)
Something went wrong with that request. Please try again.