This file contains hidden or 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 'work_queue' | |
wq = WorkQueue.new(5) | |
i = 1 | |
%w{foo bar baz bun}.each do |file| | |
i2 = i | |
wq.enqueue_b do | |
#move file to another directory | |
ImportFile.new(file, i2).run | |
end |
This file contains hidden or 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
var Querystring = require('querystring'); | |
var data = { | |
person: { | |
first_name: 'Test', | |
last_name: 'Person' | |
} | |
} | |
// returns 'person=' |
This file contains hidden or 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
class Array | |
def self.i_want_a_goddamn_array thing | |
if thing.kind_of? Hash | |
[thing] | |
else | |
Array(thing) | |
end | |
end | |
end |
This file contains hidden or 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
>> Array([]) | |
=> [] | |
>> Array(nil) | |
=> [] | |
>> Array([{foo: 'bar'}]) | |
=> [{:foo=>"bar"}] | |
>> Array([{foo: 'bar'}, {bar: 'baz'}]) | |
=> [{:foo=>"bar"}, {:bar=>"baz"}] | |
>> Array({foo: 'bar'}) | |
=> [[:foo, "bar"]] |
This file contains hidden or 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
# This takes a bracket size and generates the loser's bracket side of a double-elimination tournament | |
class TreeSolver | |
attr_reader :size | |
def initialize options = {} | |
@size = options[:size] || 32 | |
@levels = 0 | |
calculate_levels | |
@starting_point = options[:starting_point] || 2 | |
end |
This file contains hidden or 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
>> recipe = Brewscribe::Recipe.new File.read './spec/support/recipe.bsmx' ; nil | |
=> nil | |
>> recipe.parse_ingredients ; nil | |
=> nil | |
>> recipe.ingredients.grains[0] | |
=> #<Brewscribe::Grain:0x007fcacb859ba0 @original_data={:last_modified=>"1978-12-31", :name=>"Pale Malt (2 Row) US", :origin=>"US", :supplier=>nil, :type=>"0", :in_recipe=>"1", :inventory=>"0.0000000", :amount=>"32.0000000", :color=>"2.0000000", :yield=>"79.0000000", :late_extract=>"0.0000000", :percent=>"12.1212121", :order=>"1", :coarse_fine_diff=>"1.5000000", :moisture=>"4.0000000", :diastatic_power=>"140.0000000", :protein=>"12.3000000", :ibu_gal_per_lb=>"0.0000000", :add_after_boil=>"0", :recommend_mash=>"1", :max_in_batch=>"100.0000000", :notes=>"Base malt for all beer styles", :boil_time=>"60.0000000", :price=>"0.0800000", :convert_grain=>"Pale Liquid Extract"}, @last_modified="1978-12-31", @name="Pale Malt (2 Row) US", @origin="US", @supplier=nil, @type="0", @in_recipe="1", @inventory="0.0000000", @amount="32.0000000", @color="2.0000000", @yiel |
This file contains hidden or 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 'ostruct' | |
require 'nokogiri' | |
module Brewscribe | |
class Recipe | |
attr_reader :raw_data, :hash | |
def initialize raw_data | |
@raw_data = raw_data | |
parse_raw_data |
This file contains hidden or 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
# Rank an array of members in the leaderboard. | |
# | |
# @overload rank_members([[member, score], ...]) | |
# Rank an array of members in the leaderboard. | |
# @param [String] member the member to score | |
# @param [Fixnum] score the score of member | |
def rank_members(*members_and_scores) | |
rank_members_in(@leaderboard_name, *members_and_scores) | |
end |
This file contains hidden or 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 'dnode' | |
Client = { | |
temp: ->(cb) { | |
tempC = (20.0 + rand() * 10 - 5).round | |
cb.call(tempC) | |
} | |
} | |
DNode.new(Client).connect(8188) do |remote, conn| | |
remote.f2 ->(degF) { |
This file contains hidden or 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
class SeqAct_TMTSetCoinsNeeded extends SequenceAction; | |
var() int NumCoins; | |
DefaultProperties | |
{ | |
ObjName="Set Coins Needed" | |
ObjCategory="Tomato" | |
HandlerName="SetCoinsNeeded" | |
NumCoins=0 |