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
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 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
require 'rubygems' | |
require 'parslet' | |
class Mini < Parslet::Parser | |
root(:lines) | |
rule(:lines) { line.repeat } | |
rule(:line) { (title | ingredient | step) >> newline.maybe } |
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
<html> | |
<head> | |
<style type="text/css"> | |
div.ex | |
{ | |
/* for firefox, safari, chrome, etc. */ | |
-webkit-transform: rotate(-15deg); | |
-moz-transform: rotate(-15deg); | |
/* for ie */ | |
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=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
before(:each) do | |
@key = "0111111101001001110000101000001100011100000011101111010011101001".split("").map { |i| i.to_i } | |
@text = "0101010101010101010101010101010101010101010101010101010101010101".split("").map { |i| i.to_i } | |
@text_bitfield = BitField.new(@text) | |
@right = @text_bitfield.right | |
@left = @text_bitfield.left | |
@keys = KeySchedule.sub_keys(@key) | |
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
user.restaurants << Restaurant.new(:name => params[:name]) unless user.restaurants.inject { |bool, rest| bool ||= true if rest.name == params[:name] } |
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
key_length = key_length_guess(ciphertext) | |
dot_values, shift_values = [ ], [ ] | |
1.upto(key_length).each do |start_letter| | |
letter_frequency_array = ciphertext.every_nth_letter(key_length, start_letter).letter_frequencies | |
dot_values << letter_frequency_array.dot_product(ENGLISH_FREQUENCIES) | |
1.upto(ENGLISH_FREQUENCIES.size - 1).each do |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
# Print the vaportrail of a ruby file in a git repo, i.e., | |
# the complexity level at each commit. | |
# | |
# Requires: >= bash ?.? | |
# >= git 1.7.1 | |
# >= ruby 1.9.2 | |
# >= flog 2.5.0 | |
# >= gruff 0.3.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
Dir.glob("vendor/*").each { |gem| $LOAD_PATH.unshift "#{gem}/lib" } |