Skip to content
View gist:f9e808488229e0576333
class BankAccount < ActiveRecord::Base
# :identifier is a column in "bank_accounts"
delegate :name, to: :balanced_api
private
def balanced_api
@balanced_api ||= begin
Balanced::BankAccount.fetch(identifier)
View gist:a899782e26da3548aa55
{
"status": 201,
"data": {
"bank_name": "SAN MATEO CREDIT UNION",
"_type": "bank_account",
"_uris": {
"debits_uri": {
"_type": "page",
"key": "debits"
},
View trustctime.rb
# 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
# 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
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
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
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
<!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
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
- 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!)
Something went wrong with that request. Please try again.