Skip to content

Instantly share code, notes, and snippets.

def blah(input)
if input.class != Array
return [input]
else
return input
end
end
inpatient = @questions["stay_overnight_at_the_hospital_one_or_more_times"]
outpatient = @questions["have_one_or_more_outpatient_hospital_vists"]
emergency = @questions["seek_care_at_the_emergency_room"]
case
when inpatient == 0 && outpatient == 0 && emergency == 0
@draws
when inpatient == 0 && outpatient == 0 && emergency >= 1
top_draws(80)
def sample_array(size, array, new_array = [])
count = 0
while new_array.size < size
new_array << array[count % array.size]
count += 1
end
return new_array
end
#!/bin/sh
# Don't allow console.log() or 'and show me the page' statements to be committed.
console=`git diff --cached | grep -i 'console\.log' | wc -l`
showme=`git diff --cached | grep -i 'and show me the page' | wc -l`
echo "$console console.log() statments"
echo "$showme 'and show me the page' statements"
echo ""
def get_episode_information(filename)
show, season, episode_num = Parser.parse(filename)
puts "#{show} - S#{season} - E#{episode_num}"
@show = @tvdb.fetch_series_from_data(:title => show)
@show.episodes.each do |episode|
if episode.season_number.to_i == season && episode.episode_number.to_i == episode_num
@episode = episode
@episode[:episode_number] = "0" + @episode[:episode_number] if @episode[:episode_number].to_i < 10
break
require 'minitest/spec'
require 'minitest/autorun'
# Integer list generation
listOfInt = [1, 3, 5, 7, 9, 11]
left, right = 0, 1
top, bottom = 2, 3
@dpick
dpick / gist:1699627
Created January 29, 2012 16:58 — forked from anonymous/gist:1699614
pooperz
require 'minitest/spec'
require 'minitest/autorun'
# Integer list generation
listOfInt = [1, 3, 5, 7, 9, 11]
left, right = 0, 1
top, bottom = 2, 3
board = [[nil, nil, nil], [nil, nil, nil], [nil, nil, nil]]
current_player = 'x'
def game_over?
false
end
def make_move(player, row, col)
board[row][col] = player
(fn compose [& funcs]
(fn [args]
(reduce (fn [x y] (x (y args))) funcs)))
def bools(n)
generic(n) { rand > 0.5 }
end
def ints(n)
generic(n) { rand(0..10) }
end
def generic(n = rand * 10)
Enumerator.new do |yielder|