Skip to content

Instantly share code, notes, and snippets.

for (var i=0; i<arr1.length && i<arr2.length; i++) {
if (arr1[i] != arr2[i]) {
return false;
}
return true
}
def to_json(data = nil)
format_testfile(data ||= @data)
end
private
# block definitions
def format_testfile(data)
format_chunk(nil, data, &method(:format_loan_type))
class Bob
# man, that multi-line made these uglier and more brittle. sad.
MATCHERS = {
/^ *\Z/ => "Fine. Be that way!", # silence
/^[^a-z]+!$/ => "Woah, chill out!", # shouting, no lowercase
/^[A-Z ]+\??$/ => "Woah, chill out!", # speaking loudly, still rude.
/\?\Z/ => "Sure.", # questions
/.*/ => "Whatever." # fallthrough, everything else
}
class AddLondisteExtension < ActiveRecord::Migration
def up
load_postgres_extension("londiste") do
verify "pgq"
verify "pgq_node"
verify "londiste"
end
end
def down
class Bob
def hey(input)
if(input.empty? || input.strip.empty?)
'Fine. Be that way!'
elsif(upcase(input))
"Woah, chill out!"
elsif(question(input))
'Sure.'
else
'Whatever.'
class Bob
# man, that multi-line made these uglier and more brittle. sad.
MATCHERS = {
/^ *\Z/ => "Fine. Be that way!", # silence
/^[^a-z]+!$/ => "Woah, chill out!", # shouting, no lowercase
/^[A-Z ]+\??$/ => "Woah, chill out!", # speaking loudly, still rude.
/\?\Z/ => "Sure.", # questions
/.*/ => "Whatever." # fallthrough, everything else
}

Robot Name

Write a program that manages robot factory settings.

When robots come off the factory floor, they have no name.

The first time you boot them up, a random name is generated, such as RX837 or BC811.

Every once in a while we need to reset a robot to its factory settings, which means that their name gets wiped. The next time you ask, it gets a new name.

class DiceStats
attr_accessor :stats, :die
def initialize(args = {})
@die = args[:die] || 6
@tests = args[:tests] || [10, 100, 1_000, 10_000, 100_000, 1_000_000]
@format = args[:format] || generate_default_format
@stats = {}
run_experiments
<input id="generator" type="button" value="Generate!" />
<p>Locus options here:</p>
<select name="theMenu" id = "setMenu">
<option selected value="real">Real Set</option>
<option value="real1">Real + Fake Set 1</option>
<option value="real2">Real + Fake Set 2</option>
<option value="real1_2">Real + Fake Set 1 and 2</option>
</select>
class HackGame
attr_reader :options
DIFFICULTIES = {
very_easy: { word_size: 4, word_count: 5 },
easy: { word_size: 7, word_count: 8 },
medium: { word_size: 10, word_count: 10 },
hard: { word_size: 12, word_count: 13 },
very_hard: { word_size: 15, word_count: 15 },
}