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
import readline, rlcompleter | |
readline.parse_and_bind("tab: complete") | |
def zeropad(n,zeros=3): | |
"Pad number n with zeros. Example: zeropad(7,3) == '007'" | |
nstr = str(n) | |
while len(nstr) < zeros: | |
nstr = "0" + nstr | |
return nstr |
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
/** | |
* Array.prototype.map Polyfill | |
*/ | |
Array.prototype.map = function(fun, thisp) { | |
"use strict"; | |
if (this === void 0 || this === null) { | |
throw new TypeError(); | |
} | |
var t = Object(this); |
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
invoice: 34843 | |
date: "2001-01-23" | |
billTo: &id001 | |
given : Chris | |
family : Dumars | |
address: | |
lines: [ "458 Walkman Dr.", "Suite #292"] | |
city : Royal Oak | |
state : MI | |
postal : 48046 |
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
# Three levels # | |
Personal : Organizational | |
--------------------------- | |
Goals : business objectives | |
Tasks : business processes | |
Tools/Features : employees, vendors & systems | |
# Business Goals # |
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 proplist = _.keys(_); | |
var undef | |
proplist.push(undef); | |
proplist.push(null); | |
proplist = proplist.concat(proplist); | |
// proplist.push(proplist); | |
_.isNewFunction = function (obj) { return typeof obj === 'function' } | |
_.isA = function isA(o,c) {return o==null ? o===c : (o.constructor===c || ( _.isFunction(c) && o instanceof c));} |
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
// Get leaf data | |
// or could iterate over leaf.attributes | |
function show(leaf,ind) { return [leaf.tagName, leaf.getAttribute ? leaf.getAttribute("data") : leaf.textContent]; } | |
function grab(node,indented) { | |
var ind=indented||""; | |
return Array.prototype.slice.call(node).map( function(item) { | |
var others = ""; | |
if (item.childNodes && item.childNodes.length > 0) others = grab(item.childNodes, ind + " "); | |
return ind + show(item).join(": ") +"\n"+ others |
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
/** Adding underscores template to the String object */ | |
// Source: http://github.com/documentcloud/underscore | |
var _ = self._ || {}; | |
// JavaScript templating a-la ERB, pilfered from John Resig's | |
// "Secrets of the JavaScript Ninja", page 83. | |
// Single-quote fix from Rick Strahl's version. | |
_.template = function(str, 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
/** | |
* isType return true if obj is of class klass or a superclass of klass (such as Object). | |
* If type is a Function, will match if obj instanceof type (includes subclasses). | |
* If type is a String, will match if typeof(obj) === type or obj.constructor.name === type, | |
* so if tom is a Horse, which is a subclass of Animal, | |
* then isClass(tom, "Animal") is false but isClass(tom, Animal) is true. | |
* @Param {obj} Object to test | |
* @Param {type} Function or String with name or constructor of object. | |
* @Return {boolean} true if obj is of given type, using typeof, instanceof, or obj.constructor. | |
*/ |
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
Discussion about the "truthfulness" of Objects of the Boolean class. | |
Given some Javascript code of: | |
var bool_examples = [ | |
true == new Boolean(true), | |
true === new Boolean(true), | |
false == new Boolean(false), | |
false === new Boolean(false), | |
! 0, |
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
// Boolean Quiz | |
var bool_examples = [ | |
true == new Boolean(true), | |
true === new Boolean(true), | |
false == new Boolean(false), | |
false === new Boolean(false), | |
! 0, | |
! new Boolean(false), | |
! "", |