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
/** | |
* Attach function to Array.prototype, with the given implementation. | |
*/ | |
function augmentArrayPrototypeWith(func, impl) { | |
if (typeof Array.prototype[func] !== 'function') { | |
Array.prototype[func] = function() { | |
return impl.apply(this, arguments); | |
}; | |
} | |
} |
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 $(id) { return document.getElementById(id); } | |
function $t(tag, con) { return (con || document).getElementsByTagName(tag); } | |
function $$(expr, con) { return (con || document).querySelectorAll(expr); } |
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 supportsSelector(selector) { | |
var el = document.createElement('div'); | |
el.innerHTML = ['­', '<style>', selector, '{}', '</style>'].join(''); | |
el = document.body.appendChild(el); | |
var style = el.getElementsByTagName('style')[0], | |
ret = !!(style.sheet.rules || style.sheet.cssRules)[0]; | |
document.body.removeChild(el); | |
return ret; | |
} |
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
Array.prototype.chain = function chain(delay) { | |
var tasks = this, pos = 0, delay = delay || 17; | |
setTimeout(function() { | |
tasks[pos++](); | |
if (pos < tasks.length) setTimeout(arguments.callee, delay); | |
}, delay); | |
return this; | |
}; | |
// Usage; |
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
/** | |
* A general-purpose function to enable a function to use memoization. The function must use explicit, string-serializable parameters | |
* @param func {Function} to be memoized | |
* @parma context {Object} the context for the memoized function to execute within | |
*/ | |
function memoize(func, context) { | |
function memoizeArg (argPos) { | |
var cache = {}; | |
return function() { | |
if (argPos == 0) { |
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 getViewportSize() { | |
var windowWidth = document.documentElement.clientWidth || document.body.clientWidth; | |
var windowHeight = document.documentElement.clientHeight || document.body.clientHeight; | |
return [windowWidth, windowHeight]; | |
} |
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
span[style] { | |
/* inheritable-property: inherit !important; */ | |
color: inherit !important; | |
font-size: inherit !important; | |
} |
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 chaining without modifying Array prototype. Not ES5 compatible. | |
* @param functions {Array{Function}} functions to schedule | |
* @param context {Object} for execution | |
*/ | |
function schedule(functions, context){ | |
setTimeout(function(){ | |
var process = functions.shift(); | |
process.call(context); |
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
/* IE6 and below & Mac IE */ | |
* html selector{ prop: value; } | |
/* IE6 and below */ | |
/*\*/ | |
* html selector{ prop: value; } | |
/**/ | |
/* IE7 */ | |
*:first-child+html selector{ prop: value; } | |
*+html selector { prop: value; } | |
/* Mac IE only */ |
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
#!/bin/sh | |
HOST='some.ftp.server' | |
USER='myuser' | |
PASSWD='mypass' | |
FILE='myfile' | |
ftp -n $HOST <<END_SCRIPT | |
user ${USER} ${PASSWD} | |
cd /path/to/something |