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
http://dribbble.com/jessedodds | |
http://dribbble.com/snootyfox | |
http://dribbble.com/bjango | |
http://dribbble.com/MelDraws | |
http://dribbble.com/zane_david | |
http://dribbble.com/charlessantoso | |
http://dribbble.com/envato | |
http://dribbble.com/tomricci | |
http://dribbble.com/VERG | |
http://dribbble.com/alanvanroemburg |
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
/* | |
* In JavaScript "this" is very finicky. Mostly it tends to get lost whenever | |
* you use a callback. When you assign a function you're literally creating | |
* a function object and then putting it into an object. Whenever the function | |
* is called it works out what it's this is based on how it was called. | |
* | |
* There are several ways to make sure your this stays around. | |
* | |
*/ |
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 widths = $("elements").map(function(i, el){ | |
$(el).width(); | |
}); | |
var max_width = Math.max.apply(Math, widths); |
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 widest_el = null; | |
var width = 0; | |
$("elements").each(function(i, el){ | |
if(el.width() > width){ | |
widest_el = el; | |
width = el.width(); | |
} | |
}); |
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 handler = function(event){ | |
// if the target is a descendent of container do nothing | |
if($(event.target).is(".container, .container *")) return; | |
// remove event handler from document | |
$(document).off("click", handler); | |
// dostuff | |
} |
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
window.System = | |
delay: (num, fn) -> | |
if arguments.length == 1 | |
setTimeout(num, 0) | |
else | |
setTimeout(fn, num) | |
# Use Like # | |
System.delay -> |
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
DEFAULT_NAME = File.open("default_name.txt").read() | |
class Person: | |
def __init__(self, name=None): | |
self.name = name or DEFAULT_NAME |
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 price | |
return @price if @price | |
@price = Money.new(self.cents || 0, self.some_relationship.currency || Money.default_currency) | |
end | |
def price=(new_price) | |
@price = new_price.to_money | |
self.cents = @price.cents | |
self.some_relationship.currency = @price.currency_as_string | |
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
$("#somelink").on("click", function(){ | |
$("#somediv").show(); | |
$("#anotherdiv").hide(): | |
$("#athirddiv").hide(); | |
}); |
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
int maxlen = max(a.length, b.length, c.length); | |
for(int i = 0; i < maxlen; i++){ | |
int ai = max(a.length - i, 0); | |
int bi = max(b.length - i, 0); | |
int ci = max(c.length - i, 0); | |
//dostuff | |
} |