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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'growl' | |
require 'zendesk-api' | |
require 'tinder' | |
@z = Zendesk::Main.new("", "", "", :format => "json") | |
def count_for_rule(rule) | |
ticket_count = 0 |
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
hey = nil | |
yo = "foo" | |
baz = 3 if false | |
puts hey.inspect | |
puts yo.inspect | |
puts baz.inspect # Nil!! | |
puts spaz.inspect # Name Error |
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
# via jaknowlden: | |
irb(main):001:0> (k, v), *rest = [[1,2], [3,4], [5,6]] | |
=> [[1, 2], [3, 4], [5, 6]] | |
irb(main):002:0> k | |
=> 1 | |
irb(main):003:0> v | |
=> 2 | |
irb(main):004:0> rest | |
=> [[3, 4], [5, 6]] |
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
outside = "foo" | |
classy = Class.new do | |
define_method(:get_thing) do | |
outside | |
end | |
def get_thing_with_def | |
outside | |
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
module Farts | |
def farts | |
"pfft" | |
end | |
end | |
hey = "yo" | |
hey.farts # NoMethodError: undefined method `farts' for "yo":String |
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
context setups | |
+ asserts should only run the setup once | |
+ asserts even with multiple assertions | |
context setups that are nested | |
+ asserts gets run again | |
+ asserts only once per nesting, even with multiple assertions | |
4 passes, 0 failures, 0 errors in 0.000148 seconds |
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
require 'rubygems' | |
require 'riot' | |
context "Something" do | |
setup do | |
D = 8 | |
end | |
asserts("something") { 8==D } | |
asserts("something else") { 8===D } |
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
require 'rubygems' | |
require 'riot' | |
context "Something" do | |
setup do | |
D = 8 | |
end | |
asserts("big") { 8==D } | |
asserts("bigger") { 8===D } |
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
static VALUE | |
rb_ary_shuffle_bang(ary) | |
VALUE ary; | |
{ | |
long i = RARRAY(ary)->len; | |
rb_ary_modify(ary); | |
while (i) { | |
long j = rb_genrand_real()*i; | |
VALUE tmp = RARRAY(ary)->ptr[--i]; |
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
ary = [ | |
{:sort_me => 1, :expected_order => 1}, | |
{:sort_me => 2, :expected_order => 7}, | |
{:sort_me => 2, :expected_order => 8}, | |
{:sort_me => 1, :expected_order => 2}, | |
{:sort_me => 1, :expected_order => 3}, | |
{:sort_me => 1, :expected_order => 4}, | |
{:sort_me => 1, :expected_order => 5}, | |
{:sort_me => 1, :expected_order => 6}, | |
].sort! { |a,b| a[:sort_me] <=> b[:sort_me] } |