This file contains hidden or 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
Hello {{name}} | |
You have just won ${{value}}! | |
{{#in_ca}} | |
Well, ${{taxed_value}}, after taxes. | |
{{/in_ca}} |
This file contains hidden or 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
/* | |
* Copyright (c) 2010 Tobias Schneider | |
* This script is freely distributable under the terms of the MIT license. | |
*/ | |
(function(){ | |
var UPC_SET = { | |
"3211": '0', | |
"2221": '1', | |
"2122": '2', |
This file contains hidden or 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
#shadow { | |
-moz-box-shadow: | |
10px 10px 25px rgba(0, 0, 0, 0.25), | |
10px 10px 5px rgba(0, 0, 0, 0.5), | |
0 5px 5px -3px black; | |
-webkit-box-shadow: | |
10px 10px 25px rgba(0, 0, 0, 0.25), | |
10px 10px 5px rgba(0, 0, 0, 0.5), | |
0 5px 5px -3px black; | |
box-shadow: |
This file contains hidden or 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
<canvas id="rect" width="440" height="120"></canvas> | |
<script> | |
var elem = document.getElementById('rect'); | |
context = elem.getContext('2d'); | |
context.fillStyle = "rgb(255,0,0)"; | |
context.fillRect(20, 20, 220, 120); | |
</script> |
This file contains hidden or 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 performance = (function () { | |
var my = {}; | |
// Wrap a function body in this to return a copy that instruments itself | |
// If you want this to be useful, you should give your profiled function a name, | |
// otherwise it will be identified as "", which is less than useful. | |
my.profile = function (func) { | |
return function () { | |
var start = new Date().getTime(), | |
time, |
This file contains hidden or 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
// from @rem's Canvas collaborative drawing demo | |
// http://rem.im/collab-drawing.html | |
ctx.strokeStyle = '#' + (~~(Math.random() * 16777215)).toString(16); |
This file contains hidden or 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 ($) { | |
$.event.special.textchange = { | |
setup: function (data, namespaces) { | |
$(this).bind('keyup', $.event.special.textchange.handler); | |
$(this).bind('cut paste input', $.event.special.textchange.delayedHandler); | |
}, | |
teardown: function (namespaces) { |
This file contains hidden or 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
<!-- This is a Node+WebSocket powered demo to sync videos | |
across different browsers. This file is the client, | |
the other one is the Node server. Powered by Node and | |
http://github.com/miksago/node-websocket-server --> | |
<style> | |
.inactive { display: none; } | |
.active { display: block; } | |
</style> | |
<script> |
This file contains hidden or 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
// Flattens the Array produced by .serializeArray() into an Object | |
// with names as keys and values as their values. | |
(function($) { | |
$.fn.serializeObject = function() { | |
var formData = this.serializeArray(), | |
data = {}; | |
for (var i=0, len=formData.length; i<len; i++) { | |
data[formData[i].name] = formData[i].value; | |
} | |
return data; |
This file contains hidden or 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
// From @izs /via @janl | |
// http://twitter.com/izs/status/17744109574 | |
// JavaScript one-liner to swap two variables: | |
foo = [bar, bar = foo][0]; |