Skip to content

Instantly share code, notes, and snippets.

View redsquirrel's full-sized avatar
🐿️

Dave Hoover redsquirrel

🐿️
  • Flexa, Inc.
  • Evanston, IL
  • 08:53 (UTC -05:00)
  • X @davehoover
View GitHub Profile
@redsquirrel
redsquirrel / 2013_chicago_devbootcamp_mascots.txt
Last active December 12, 2015 08:19
Every @devbootcamp cohort is named after an indigenous animal from that location's state. Here are the mascots for Chicago in 2013.
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
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
@redsquirrel
redsquirrel / _trending.html.erb
Created August 7, 2012 18:20 — forked from tjarmain/_trending.html.erb
Trying to set up rendering of partials within tabs using AJAX
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
@redsquirrel
redsquirrel / bowling_score.rb
Created July 15, 2012 00:43
In which I realize that the scoring logic for strikes and spares are the same. (3 consecutive balls)
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)
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.
@redsquirrel
redsquirrel / gist:2025533
Created March 12, 2012 23:55
A child sending a message to its parent.
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) {
@redsquirrel
redsquirrel / comment.rb
Created March 4, 2012 15:56
Find the race condition...
class Comment < ActiveRecord::Base
def after_save
Resque.enqueue(Notify, self.id)
end
end
@redsquirrel
redsquirrel / dogs_and_cats.rb
Created January 27, 2012 03:27
Here's what we worked on today...
# gem install rspec
class Dog
attr_reader :height, :distance
def initialize(cat)
@cat = cat
end
def jump!
@redsquirrel
redsquirrel / foo-spec.js
Created August 11, 2011 15:23
put this in a directory called 'spec' and then run 'jasmine-node spec/'
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