Skip to content

Instantly share code, notes, and snippets.

View redsquirrel's full-sized avatar
🐿️

Dave Hoover redsquirrel

🐿️
  • Flexa, Inc.
  • Evanston, IL
  • 12:04 (UTC -05:00)
  • X @davehoover
View GitHub Profile
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
@redsquirrel
redsquirrel / gist:882117
Created March 22, 2011 21:28
It's annoying that this is valid Ruby and prints "hi mom"
if false
elsif
print "hi "
else
puts "mom"
end
#!/usr/bin/env ruby
# 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
#
@redsquirrel
redsquirrel / gist:824651
Created February 13, 2011 12:37
Dave Hoover's notes from speakerconf
We need to continually discover what great teams do.
Bill Caputo
Let the developers do the hiring.
Fred George
Kill all fear. This enables programmer anarchy.
Fred George
Webbit, by Joe Walnes
def sort(*l)
return l if l.size < 2
eq = l[0]
lt = []
gt = []
l.each do |e|
if e < eq
lt << e
end
if e > eq
@redsquirrel
redsquirrel / gist:737483
Created December 11, 2010 17:22
Dave Hoover's initial world info sources feed list
AL JAZEERA ENGLISH
http://english.aljazeera.net/Services/Rss/?PostingId=2007731105943979989
Asia Times Online
http://www.atimes.com/atimes/atol.rss
Capital Gains and Games
http://capitalgainsandgames.com/rss.xml
FactCheck.org