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
// Part 1. | |
// Implement a function prototype extension that caches function results for | |
// the same input arguments of a function with one parameter. | |
// | |
// For example: | |
// Make sin(1) have the result of Math.sin(1), but use a cached value | |
// for future calls. | |
var sin = function() { return (arguments.length === 0) ? false : Math.sin(arguments[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
<div id="the_div"> | |
<ul id="the_list"> | |
<li id="the_item">Click me!</li> | |
</ul> | |
</div> | |
<p id="log"></p> | |
<script type="text/javascript" charset="utf-8"> | |
function log(string){ |
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(){ alert('later!'); }).delay(1); | |
// function is called 1 second later ^^ | |
Function.prototype.delay = function(seconds){ | |
setTimeout(this, seconds*1000); | |
}; |
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 forEach(array, method) { | |
var l = {}; | |
for( l.ii = 1; l.ii <= arraylen(arguments.array); l.ii++ ) { | |
method(arguments.array[l.ii]); | |
} | |
} | |
function writeNow(str) { | |
writeOutput(str); | |
writeOutput('+'); |
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
jQuery('#' + form_id).find(':input').each(function(i,e) { | |
// list of types to clear with default values | |
var obj = { | |
'text' : '' | |
, 'select-one': 0 | |
}; | |
if (obj[e.type] !== undefined) { | |
jQuery(e).val(obj[e.type]); | |
} | |
}); |
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
String.prototype.trim = function() { | |
return this.replace(/^\s+|\s+$/g, ''); | |
}; | |
String.prototype.isNumber = function() { | |
return typeof parseFloat(this, 10) === 'number' && isFinite(this) && this.trim().length > 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
// saw this on Forrst, forget who posted it though | |
$('[href$="pdf"],.pdf').live("click", function(){ | |
// get the link attribute and find the filename of the PDF | |
var pdfLink = $(this).attr("href"), | |
pdfLocation = pdfLink.substr(pdfLink.lastIndexOf("/")).replace("/",""); | |
_gaq.push(['_trackPageview', pdfLocation]); | |
}); |
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
info it worked if it ends with ok | |
verbose cli [ 'node', | |
verbose cli '/Users/muloka/src/npm/cli.js', | |
verbose cli 'install', | |
verbose cli '-g', | |
verbose cli '-f' ] | |
info using npm@1.0.26 | |
info using node@v0.5.5-pre | |
verbose config file /Users/muloka/.npmrc | |
verbose config file /Users/muloka/local/node/etc/npmrc |
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
require 'formula' | |
class YoutubeDl <ScriptFileFormula | |
url 'https://github.com/phihag/youtube-dl/raw/master/youtube-dl' | |
homepage 'http://rg3.github.com/youtube-dl/' | |
md5 'a5b92351e8cfa663c888e7d24116477e' | |
version '2011.08.24-phihag' | |
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
SELECT stuff FROM [Product] p | |
JOIN [category] c ON | |
-- collating on the fly #FTW | |
c.[Name] COLLATE SQL_Latin1_General_CP1_CI_AS = p.[Name] COLLATE SQL_Latin1_General_CP1_CI_AS |