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
<html> | |
<body> | |
<h1>Socket.io Test!!! :)</h1> | |
<form id="myForm"> | |
<input id="firstname" type="text"> | |
<input id="lastname" type="text"> | |
<input id="submit" type="submit"> | |
</form> | |
<script src="http://localhost:3001/socket.io/socket.io.js"></script> | |
<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
(function(){ | |
function doComponent(data){ | |
return <div id={data.id}> | |
<h3>{data.title}</h3> | |
<div className="clients">{data.content.clients}</div> | |
<div className="sales"}>{data.content.sales}</div> | |
</div>; | |
} |
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 walkDOM(node, cb){ | |
cb(node); | |
node = node.firstChild; | |
while(node){ | |
walkDOM(node, cb); | |
node = node.nextSibling; | |
} | |
} | |
function walkUp(node, cb){ | |
var parent = node.parentElement; |
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 unboundSlice = Array.prototype.slice; | |
var slice = Function.prototype.call.bind(unboundSlice); | |
function listToArray() { | |
return slice(arguments); | |
} | |
function listToArray2() { | |
return Array.prototype.slice.call(arguments); | |
} |
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 compare(nodeA, nodeB) { | |
if ( !nodeA && !nodeB ) return true; //edge case | |
if ( nodeA.nodeType === nodeB.nodeType && nodeA.tagName === nodeB.tagName && nodeA.nodeValue === nodeB.nodeValue ){ | |
var i = 0; | |
var childA = nodeA.childNodes[i]; | |
var childB = nodeB.childNodes[i]; | |
while(childA && childB){ | |
if (!compare(childA, childB)) return false; //some child is not equal | |
i++; | |
childA = nodeA.childNodes[i]; |
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 desktop($trigger, id){ | |
var $menu = $trigger.find('+ .dropdown-menu'), delay=st.delay, delay2 = ~~delay/3; | |
//bootstrap catches the click event so we need to jump to the link here | |
$trigger.on('click', function(e){ | |
clearTimeout(waiting[id]); | |
if (id === inside){ | |
inside = 0; | |
//we need to trigger click tracking since click event is not fired |
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
<article class="recipe"> | |
<div class="pull-right"> | |
<a href="#"><img data-src="holder.js/161x121/industrial" width="161" height="121" alt=""></a> | |
</div> | |
<header> | |
<h6><a href="#"><b class="key">Chicken</b> Piccata</a></h6> | |
<p>Recipe courtesy of <a href="#">Giada De Laurentiis</a></p> | |
</header> | |
<div class="media"> | |
<div class="pull-left"> |
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
process.stdin.resume(); | |
process.stdin.setEncoding("ascii"); | |
var input = ""; | |
process.stdin.on("data", function (chunk) { | |
input += chunk; | |
}); | |
process.stdin.on("end", function () { | |
// now we can read/parse input | |
var n = parseInt(input, 10); | |
var str = []; |
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 toArray = Function.prototype.call.bind(Array.prototype.slice); |
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
/* | |
wraps the given function p in a try catch | |
so is safer to call it in some contexts. e.g. analytic functions in unit tests. | |
*/ | |
Object.prototype.try = function (p){ | |
var fn = function(){}; | |
if (typeof this[p] === 'function'){ | |
fn = function(){ | |
try { | |
this[p].apply(this, [].slice(arguments)); |