This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Command = Struct.new(:method, :direction) | |
class Command | |
def initialize(m, *args) | |
@method = m | |
@direction = args | |
end | |
def perform(warrior) | |
warrior.send(@method, *@direction) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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!) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = {}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Slows down selenium so you can see what's going on | |
#http://stackoverflow.com/questions/4815516/how-can-i-run-selenium-used-through-capybara-at-a-lower-speed/5150855#5150855 | |
#require 'selenium-webdriver' | |
#module ::Selenium::WebDriver::Remote | |
# class Bridge | |
# def execute(*args) | |
# result = raw_execute(*args)['value'] | |
# sleep 0.1 | |
# result | |
# end |