Skip to content

Instantly share code, notes, and snippets.

View jasonwyatt's full-sized avatar
:shipit:
Typing, probably

Jason Feinstein jasonwyatt

:shipit:
Typing, probably
  • Robinhood
  • Seattle, WA
  • 11:34 (UTC -07:00)
  • X @jasonwyatt
View GitHub Profile
// 1: how could you rewrite the following to make it shorter?
bar['doSomething' + (foo ? '' : 'Else')](el);
// 2: what is the faulty logic in the following code?
// It will always print "world" to the console because foo is undefined in the
// anonymous function's closure at the time of the shortcut attempt.
@jasonwyatt
jasonwyatt / willow.js
Created February 3, 2010 19:55
Willow is a magical logging framework that makes the output to console.log be more useful when debugging issues.
/*
* Copyright (c) 2010 Jason Wyatt Feinstein
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
@jasonwyatt
jasonwyatt / livesync.rb
Created January 12, 2010 20:10
Livesync
#!/opt/local/bin/ruby -w
################################################
# Settings
################################################
# Directory to watch
watch_location = "."
# Pattern for files to watch
watch_pattern = "**/*" #all files/subdirectories
/**
* Permanently bind a function to an object.
*
* @param fn (function)
* Function to bind.
* @param object (object)
* Object scope to force the function to run within.
* @return
* New function, where the argument function is forced to
* execute within the scope of object.
@jasonwyatt
jasonwyatt / goodalert.js
Created December 16, 2009 23:48
Tiny javascript snippet/file to overwrite how alert usually works by forcing it to behave like console.log when possible.
/**
* Overwrites the old alert method and chooses to use console.log instead (if it's
* available).
* Author: Jason Feinstein
*/
var oldAlert = alert;
alert = function(){
if(window.console != null){
console.log.apply(null, arguments);
} else {