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 o = {}; | |
function getIsType(type) { | |
return function (o) { | |
return /* undefined */ typeof o === type || | |
/* null */ o === null && type === "null" || | |
Object.prototype.toString.call(o).match(/\s+(\w+)/)[1].toLowerCase() === 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
// courtesy of http://www.reddit.com/user/itsnotlupus @ | |
// http://bit.ly/upcWxw | |
function printf(msg) { | |
var args = Array.prototype.slice.call(arguments,1), arg; | |
return msg.replace(/(%[disv])/g, function(a,val) { | |
arg = args.shift(); | |
if (arg !== undefined) { | |
switch(val.charCodeAt(1)){ | |
case 100: return +arg; // d | |
case 105: return Math.round(+arg); // i |
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
console.log(NaN == true); // false | |
console.log(NaN == false); // 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
function Node ( val, parent ) { | |
this.value = val; | |
this.setParent( parent ); | |
this.children = []; | |
} | |
Node.prototype = { | |
addChild: function ( val ) { | |
var node = val instanceof Node ? val : new Node( val ); | |
node.setParent( this ); |
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 list = "me.jpg,me.png,me.txt,me.zip,me.apple".split(","); | |
var re = /.+\.(?!jpg|jpeg|gif|png)/i; | |
list.forEach(function (v, i) { | |
console.log(v, re.test(v)); | |
}); |
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
/* | |
* This has essentially turned into Resig's Simple JavaScript Inheritance | |
* with some minor modifications for class names and use strict, | |
* and getters ans setters | |
* http://ejohn.org/blog/simple-javascript-inheritance/ | |
* http://ejohn.org/blog/javascript-getters-and-setters/ | |
*/ | |
(function (window) { | |
"use strict"; |
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
Copyright (c) 2011, Matthew Cobbs | |
Permission is hereby granted, free of charge, to any person obtaining | |
a copy of this software and associated documentation files (the | |
"Software"), to deal in the Software without restriction, including | |
without limitation the rights to use, copy, modify, merge, publish, | |
distribute, sublicense, and/or sell copies of the Software, and to | |
permit persons to whom the Software is furnished to do so, subject to | |
the following conditions: |
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
/** | |
* Anchor - A URL parsing utility | |
* | |
* Copyright 2012, Matthew Cobbs | |
* MIT licensed | |
* | |
* Methods: | |
* | |
* getSearchVars - returns a key-value object with the parameters in the URL search | |
* setSearchVars(o) - sets parameters using a key-value object in the URL search |
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
/** | |
* ngbs.u.anchor - A URL parsing utility | |
*/ | |
/*global ngbs */ | |
var ngbs = ngbs || {}; | |
ngbs.u = ngbs.u || {}; | |
ngbs.u.anchor = (function (window, document, location) { | |
"use strict"; |
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
/** | |
* http://jsbin.com/opibuk/13/edit | |
*/ | |
(function (window) { | |
"use strict"; | |
// shortcuts | |
var location = window.location; | |
var setInterval = window.setInterval; |