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
<style> | |
.highlight { background-color:yellow; } | |
</style> | |
<script> | |
$("<div />", { | |
text: "click here", | |
click: function() | |
{ | |
$(this).toggleClass("highlight"); | |
} |
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
$('.typeahead').typeahead({ | |
source: function (typeahead, query) { | |
return $.post('/typeahead', { query: query }, function (data) { | |
return typeahead.process(data); | |
}); | |
} | |
}); |
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 template(str) { | |
var orig_settings = _.templateSettings; | |
_.templateSettings = { | |
interpolate : /\{\{([\s\S]+?)\}\}/g | |
}; | |
var t = _.template(str); | |
_.templateSettings = orig_settings; |
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 assert( err,checkThis ) { if( !checkThis ) { throw err; } } | |
// To use (Check js console): | |
assert( 'This will return -nothing.', function() { | |
return true; | |
}); | |
assert('Well, this is an error', false); |
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
<html> | |
<head> | |
<script> ___start___ = new Date; </script> | |
<script> | |
$(function() { | |
var performance = new Date - ___start___; | |
_gaq.push( | |
'_trackEvent', |
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 map(func, array) { | |
var result = []; | |
forEach(array, function (element) { | |
result.push(func(element)); | |
}); | |
return result; | |
} | |
show(map(Math.round, [0.01, 2, 9.89, Math.PI])); |
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
// Extend the function prototype with the method 'unless' (which is naughty...) | |
Function.prototype.unless = function(assert) { | |
if (!assert) { | |
this.call(); | |
} | |
} | |
var doThisTestFunction = function() { | |
console.log('heeeeeeyooooo') | |
} |
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 a = { b: 'c' }, | |
r, | |
brackets, | |
dot, | |
run = 1000, | |
frames = 1000000; | |
console.log("Dot notation, iterations total: ", run * frames) | |
console.time( 'dot notation' ); |
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
/**********************************************/ | |
/* | |
/* Darker Skin by Darcy Clarke - 2011 | |
/* | |
/* For how to install, or more themes, check out: | |
/* http://darcyclarke.me/design/skin-your-chrome-inspector/ | |
/* | |
/* Color scheme is based on Joe Bergantine's Specials Board: | |
/* http://joebergantine.com/werkstatt/seestyle | |
/* |
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 fetch(url,success){ | |
var script=document.createElement('script'); | |
script.src=url; | |
var head=document.getElementsByTagName('head')[0], | |
done=false; | |
// Attach handlers for all browsers | |
script.onload=script.onreadystatechange = function(){ | |
if ( !done && (!this.readyState | |
|| this.readyState == 'loaded' | |
|| this.readyState == 'complete') ) { |
OlderNewer