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
// Example | |
document.observe("lol:konami", function() { | |
$(document.body).insert(new Element('h1').update("KONAMI!!!").setStyle({fontWeight: "bold", color: "red"})); | |
}); |
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
(function($, doc) { | |
var getHTML = function getHTML() { | |
return $.String(this.raw.outerHTML); | |
}; | |
if (!('outerHTML' in doc.documentElement)) { | |
var dummy = doc.createElement('html'); | |
getHTML = function getHTML() { | |
dummy.appendChild(this.raw.cloneNode(true)); | |
var result = dummy.innerHTML; |
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
%h1.lol | |
NO U |
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
##### | |
## INITIAL CONFIGURATION | |
##### | |
# Fork sstephenson/prototype on GitHub | |
# Go to this url and click the fork button. This will create a prototype | |
# repository under your GitHub account. | |
http://github.com/sstephenson/prototype |
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
Moved to: http://github.com/gf3/dotfiles/blob/master/bash_prompt |
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
function build(o, p, v){ | |
var k=[],l,m; | |
while (m=/(\w+)\.?/g.exec(p)) k.push(m[1]); | |
for (var i=0; i<k.length; i++) { | |
l=o; | |
o=o[k[i]]; | |
} | |
if (v) l[k[k.length-1]]=v; | |
return v || o; | |
} |
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
Black: 0, 0, 0 | |
Red: 229, 34, 34 | |
Green: 166, 227, 45 | |
Yellow: 252, 149, 30 | |
Blue: 196, 141, 255 | |
Magenta: 250, 37, 115 | |
Cyan: 103, 217, 240 | |
White: 242, 242, 242 |
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
// The CSS property backgroundPosition does not exist in the accessible DOM properties within IE 8. | |
// this monkeypatch retifies that issue | |
// usage: $(elem).css('backgroundPosition'); | |
// ticket: http://dev.jquery.com/ticket/5749 | |
(function($){ | |
var _css = $.fn.css; | |
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
// get the average color of two hex colors. | |
function avgcolor(color1,color2){ | |
var avg = function(a,b){ return (a+b)/2; }, | |
t16 = function(c){ return parseInt((''+c).replace('#',''),16) }, | |
hex = function(c){ return (c>>0).toString(16) }, | |
hex1 = t16(color1), | |
hex2 = t16(color2), | |
r = function(hex){ return hex >> 16 & 0xFF}, | |
g = function(hex){ return hex >> 8 & 0xFF}, | |
b = function(hex){ return hex & 0xFF}, |
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
// everyone's new favorite closure pattern: | |
(function(window,document,undefined){ ... })(this,this.document); | |
// when minified: | |
(function(w,d,u){ ... })(this,this.document); | |
// which means all uses of window/document/undefined inside the closure | |
// will be single-lettered, so big gains in minification. | |
// it also will speed up scope chain traversal a tiny tiny little bit. |