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 blah(input) | |
if input.class != Array | |
return [input] | |
else | |
return input | |
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
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) |
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 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 |
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
#!/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 "" |
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 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 |
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 'minitest/spec' | |
require 'minitest/autorun' | |
# Integer list generation | |
listOfInt = [1, 3, 5, 7, 9, 11] | |
left, right = 0, 1 | |
top, bottom = 2, 3 |
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 'minitest/spec' | |
require 'minitest/autorun' | |
# Integer list generation | |
listOfInt = [1, 3, 5, 7, 9, 11] | |
left, right = 0, 1 | |
top, bottom = 2, 3 |
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
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 |
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
(fn compose [& funcs] | |
(fn [args] | |
(reduce (fn [x y] (x (y args))) funcs))) |
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 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| |