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
Squirrels 04/22 | |
Foxes 05/13 | |
Otters 06/03 | |
Grasshoppers 06/24 | |
Dragonflies 07/15 | |
Nighthawks 08/05 | |
Fireflies 08/26 | |
Coyotes 09/16 | |
Salamanders 10/07 |
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 fib_recursive(i, m = 0, n = 1, count = 0) | |
return m if count == i | |
fib_recursive(i, n, m+n, count+1) | |
end | |
def fib_iterative(i) | |
m, n = 0, 1 | |
i.times do | |
m, n = n, m+n | |
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
############## views/products/_trending.html.erb ############### | |
<% @products.each do |product| %> | |
<div class="product"> | |
<%= link_to (image_tag product.thumbnail), product %> | |
<div class="product-overlay-details"> | |
<%= product.name %>... | |
</div> | |
</div> | |
<% 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
array.each_with_index do |line, index| | |
if line.match(/^<s>/i) | |
start = index | |
splits = line.scan(/<(?:s|c)>\s*/i).map(&:size) | |
end | |
# detect a line that's all dashes and spaces | |
if line.match(/^[\- ]+$/) | |
start = index | |
# scan for dashes followed by a space |
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 'test/unit' | |
def score(*frames) | |
score = roll_count = 0 | |
rolls = frames.flatten | |
frames.each do |frame| | |
if sum(frame) == 10 | |
score += sum(next_three(rolls, roll_count)) | |
else | |
score += sum(frame) |
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
I need a gem. It should have 2 functions. | |
Both functions take a string and a list of words. | |
The first returns the string with all words in the list obfuscated. | |
The second returns data that contains the list of words and their associated frequency. | |
Thanks. |
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
var fork = require('child_process').fork; | |
if (process.argv[2] == 'son') { | |
setTimeout(function() { | |
process.send({ result: 'hi dad' }); | |
process.exit(0); | |
}, 1000); | |
} else { | |
var child = fork(__filename, [ 'son' ]); | |
child.on('message', function(m) { |
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
class Comment < ActiveRecord::Base | |
def after_save | |
Resque.enqueue(Notify, self.id) | |
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
# gem install rspec | |
class Dog | |
attr_reader :height, :distance | |
def initialize(cat) | |
@cat = cat | |
end | |
def jump! |
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
var fs = require("fs"); | |
console.log("about to read, yo!"); | |
describe("your mom", function() { | |
it("is fun to talk about her", function() { | |
fs.readFile("spec/foo-spec.js", function(error, buffer) { | |
console.log("Here's the file!"); | |
console.log(buffer); | |
asyncSpecDone(); // comment this out, and it will hang... cuz it's waiting |