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 œ = function(number) { | |
return { | |
times: { | |
length: number, | |
"do": function(fn) { | |
var len = this.length; | |
for (var i = 0; i < len; i++) { | |
fn(i); | |
} | |
} |
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
// Problem: jQuery's :contains expression does not do an exact match. | |
// Solution: Exact contains `$("div").filter(":econtains(smart)");` | |
$.extend($.expr[":"], { | |
econtains: function(obj, index, meta, stack) { | |
return (obj.textContent || obj.innerText || $(obj).text() || "").toLowerCase() == meta[3].toLowerCase(); | |
} | |
}); |
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
// Use: passing in an object representing a jQuery plugin. The object is expected to have | |
// a name attribute (your plugin name in string form, e.g. name: "accordion") and an init | |
// method. The createPlugin method will take each element in the collection when the | |
// plugin method is called and initialize the plugin individually, writing a data object | |
// to the element with the same name as the plugin and storing the plugin object for | |
// later reference. | |
(function($) { | |
$.createPlugin = function(plugin) { | |
$.fn[plugin.name] = function(opts) { | |
var $els = this, |
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
{ "height":15, | |
"layers":[ | |
{ | |
"data":[79, 80, 95, 96, 79, 80, 95, 96, 79, 80, 95, 96, 79, 28, 60, 61, 62, 30, 95, 96, 95, 96, 79, 80, 95, 96, 79, 80, 95, 96, 79, 80, 95, 28, 76, 77, 78, 30, 79, 80, 79, 80, 95, 96, 79, 80, 95, 96, 79, 80, 95, 96, 79, 28, 76, 15, 78, 30, 95, 96, 95, 96, 79, 80, 95, 96, 79, 80, 95, 96, 79, 80, 95, 28, 76, 16, 78, 30, 79, 80, 79, 80, 95, 96, 79, 80, 95, 96, 79, 80, 95, 96, 79, 28, 76, 31, 78, 30, 95, 96, 95, 96, 79, 80, 95, 156, 157, 158, 95, 96, 79, 80, 95, 28, 76, 32, 78, 112, 13, 13, 79, 80, 95, 96, 79, 172, 173, 144, 158, 80, 95, 96, 79, 28, 76, 47, 48, 61, 61, 62, 95, 96, 79, 80, 156, 143, 138, 160, 190, 96, 12, 13, 13, 111, 76, 16, 15, 16, 31, 78, 13, 13, 14, 96, 172, 138, 173, 174, 79, 80, 44, 45, 45, 127, 92, 93, 93, 93, 93, 94, 109, 110, 30, 80, 188, 189, 189, 190, 95, 96, 79, 80, 95, 44, 45, 45, 45, 45, 45, 45, 141, 142, 30, 96, 79, 80, 95, 96, 79, 80, 95, 96, 79, 80, 95, 96, 79, 80, 95, 96, 45, 45, 46, 80, 95, 96, 79, 80, 95, 96, 79, 80, 95, 96, 79, 80, |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> | |
<script src="toggleText.js"></script> | |
<meta charset=utf-8 /> | |
<title>Character Limit</title> | |
</head> | |
<body> | |
<a href="#" data-alt_text="Unfriend">Add to friends</a> |
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
BinaryObject = function(a, b) { | |
var o = { | |
0: a, | |
1: b, | |
val: function(bool) { return bool ? this[1] : this[0]; } | |
}; | |
return o; | |
}; | |
var bin = new BinaryObject("no", "yes"); |
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
Scene = function(opts) { | |
var instance = { | |
layers: [], | |
renderLayer: function(layer) { | |
// data: [array of tiles, 1-based, position of sprite from top-left] | |
// height: integer, height in number of sprites | |
// name: "string", internal name of layer | |
// opacity: integer | |
// type: "string", layer type (tile, object) | |
// visible: boolean |
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
// Usage: `dom_element.classList.addAll(["foo", "bar"], "baz")` and `dom_element.classList.removeAll("foo", ["bar", "baz"])` | |
// See http://jsbin.com/obenin for demo | |
(function() { | |
var args; | |
var flattenArgs = function(collection) { | |
if (typeof collection === "string") { | |
args.push(collection); | |
return; | |
} | |
collection = Array.prototype.slice.call(collection); |
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
// shadeColor("#f0f0f0", -20) returns "#bdbdbd" | |
function shadeColor(color, percent) { | |
var num = parseInt(color.slice(1), 16), | |
amt = Math.round(2.55 * percent), | |
R = (num >> 16) + amt, | |
B = (num >> 8 & 0x00FF) + amt, | |
G = (num & 0x0000FF) + amt; | |
return "#" + ( | |
0x1000000 + (R < 255 ? R < 1 ? 0 : R : 255) * 0x10000 |
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
$.fn.cssGradient = function(start, end) { | |
end = end || start; | |
if (!start) { return this; } | |
return this.css({ | |
"background-image": "-moz-linear-gradient(100% 100% 90deg, " + end + ", " + start + ")", | |
"background-image": "-webkit-gradient(linear, 0% 0%, 0% 100%, from(" + start + "), to(" + end + "))", | |
"-ms-filter": "progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr=" + start + ", endColorstr=" + end + ")" | |
}); | |
}; |