Skip to content

Instantly share code, notes, and snippets.

View wyattdanger's full-sized avatar

Stephen Bush wyattdanger

View GitHub Profile
squareRoot = ( num ) ->
square = ( x ) -> x * x
avg = ( x, y ) -> (x + y) / 2
goodEnough = ( x ) -> Math.abs( square( x ) - num ) < 0.01
improveGuess = ( x ) -> avg( x, num/x )
iter = ( guess ) ->
return guess if goodEnough guess
iter improveGuess guess
iter 1.0
@wyattdanger
wyattdanger / timeouts.js
Created May 25, 2012 19:39
events can be scheduled while code is running, but can't be executed until the runtime is free
var start = new Date();
setTimeout(function () { var end = new Date(); console.log("Timeout 3ms elapsed:", end - start, "ms"); }, 3);
setTimeout(function () { var end = new Date(); console.log("Timeout 2ms elapsed:", end - start, "ms"); }, 2);
setTimeout(function () { var end = new Date(); console.log("Timeout 1ms elapsed:", end - start, "ms"); }, 1);
while( new Date() - start < 2000 ) {}
setTimeout(function () { var end = new Date(); console.log("Timeout 0ms elapsed:", end - start, "ms"); }, 0);
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
begin
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
rvm_lib_path = File.join(rvm_path, 'lib')
#$LOAD_PATH.unshift rvm_lib_path
require 'rvm'
RVM.use_from_path! File.dirname(File.dirname(__FILE__))
rescue LoadError
raise "RVM ruby lib is currently unavailable."
end
@wyattdanger
wyattdanger / plan.js
Created September 20, 2012 23:21
js demo
var Plan = (function() {
// protected
var records = [];
// the Plan constructor
function Plan(id, price) {
this.id = id;
this.price = price;
records.push(this);
@wyattdanger
wyattdanger / linked-list.js
Created September 28, 2012 17:18
simple implementation, does not handle errors
/*
* LinkedList
* Very simple LinkedList implementation
*/
function Node(item, next) {
this.item = item;
this.next = next;
}
{setup:"Our wedding was so beautiful,",punchline:"even the cake was in tiers"},{setup:"I'm reading a book on the history of glue",punchline:"I just can't seem to put it down"},{setup:"What do you call an Argentinian with a rubber toe?",punchline:"Roberto"},{setup:"I am terrified of elevators,",punchline:"I'm going to start taking steps to avoid them"},{setup:"Why do crabs never give to charity?",punchline:"Because they're shellfish."},{setup:"Why don't skeletons ever go trick or treating?",punchline:"Because they have no body to go with"},{setup:"What do you call cheese by itself?",punchline:"Provolone"},{setup:'"Ill call you later."',punchline:"Don't call me later, call me Dad"},{setup:"Dad, I'm hungry.",punchline:"Hello, Hungry. I'm Dad"},{setup:"Where does Fonzie like to go for lunch?",punchline:"Chick-Fil-Eyyyyyyyy"},{setup:"Did you hear about the cheese factory that exploded in France?",punchline:"There was nothing left but de Brie"},{setup:"I knew I shouldn’t have had the seafood",punchline:"I’m feeling
@wyattdanger
wyattdanger / john stevens tournament report
Created March 14, 2025 18:28
archive of tournament report 2000 us amateurs mtg
Here’s the deck so I won’t bore anyone with details that don’t want them (:
Angry Hermit-Less
4 Arc Lightning
2 Sowing Salt (gee you play with 4 ports, how nice)
2 Earthquake (hermit, rebel, etc)
4 Avalanche Riders
4 Plow Under
4 Birds of Paradise
2 Rofellos, Llanowar Emissary
3 Yavimaya Elder (amazing how much damage he can do)