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
interface IMap<V> { | |
[key: string]: V | V[]; | |
[index: number]: V | V[]; | |
} | |
type JSONPrimitiveType = number | string | boolean | null; | |
interface JSONObjectType extends IMap<JSONPrimitiveType | JSONObjectType> {}; | |
interface JSONArrayType extends Array<JSONPrimitiveType | JSONObjectType | JSONArrayType> {}; |
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
String.prototype.count = function(substring) { | |
var i = -1, | |
count = 0; | |
if (substring) | |
while ((i = this.indexOf(substring, i + 1)) !== -1) | |
count++; | |
else | |
count = this.length + 1; | |
return count; | |
} |
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
if (typeof String.prototype.format !== "function") { | |
String.prototype.format = function (mappable, filter) { | |
var self = this; | |
return self.replace(/\{([0-9A-Za-z_$]+)\}/g, filter ? | |
function(_, key) { return filter(mappable[key]); } | |
: | |
function(_, key) { return mappable[key]; } | |
); | |
}; | |
} |
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
from sys import stdin | |
from random import randrange | |
def yes_or_no(n, cnt): | |
return randrange(0, cnt) < n | |
def fire(): | |
return yes_or_no(1, 6) | |
def main(): |
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
def generate_urls(elems, attr="href"): | |
""" | |
@param elems: list | |
@param attr: str | |
@description generator to generate urls of elements | |
""" | |
for elem in elems: | |
if getattr(elem, "attrib", None): | |
url = elem.attrib.get(attr) |
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
figlet $@ | sed -n -e 's/\\/\\\\/g;s/`/\\`/g;p' \ | |
| awk '{ printf "echo \"%s\";\n", $0 }' |