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
KT.namespace("fun"); | |
KT.fun.tree = (function () { | |
"use strict"; | |
return function (height) { | |
var row = 1; | |
return (isNaN(height) || height <= 0) ? '' : new Array(height).join('.').split('.').map(function () { | |
return new Array(height - row + 1).join(" ") + new Array(row++ * 2).join("*"); | |
}).join('\n'); |
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
KT.namespace("algo"); | |
KT.algo.fizzBuzz = { | |
getValue: function (input) { | |
return ((input % 3 && !(input + '').match(/3/i)) ? (input % 5 && !(input + '').match(/5/i)) ? input : "" : "fizz") + | |
((input % 5 && !(input + '').match(/5/i)) ? "" : "Buzz"); | |
} | |
}; |
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 reverse(string) { | |
return (typeof string !== "string") ? "" : string.split('').reverse().join(''); | |
} |
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
KT.namespace("algo"); | |
KT.algo.romanNumberals = (function () { | |
"use strict"; | |
function getKeyValueObject(number, romanNumber) { | |
return { | |
"part": number, | |
"romanNumber": romanNumber | |
}; |
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 foo = { | |
t: { | |
s: function () { | |
console.log("bar"); | |
} | |
} | |
}, | |
bar = foo && foo.t && foo.t.s; | |
if (bar) { |
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
defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}' | |
killall Dock |
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://dmitrysoshnikov.com/ecmascript/chapter-2-variable-object/ | |
*/ | |
alert(x); // function | |
var x = 10; | |
alert(x); // 10 | |
x = 20; |
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
#!/bin/sh | |
awk '{ print strftime("%Y-%m-%dT%H:%M:%S"), $0; fflush(); }' |
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
bunzip2 < serverdb.sql.bz2 | mysql -h example.com -P 3306 -u USERNAME -p DATABASE_NAME |
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
#!/bin/sh | |
# COPY of http://pastebin.com/zC9HU2pU | |
# Do elasticsearch optimize on logstash previous day index | |
# if $1 = all then optimize all indicies | |
esindex="/opt/elasticsearch/data/elasticsearch/nodes/0/indices" | |
# Grab yesterday's values | |
D=`date +%d -d yesterday` | |
M=`date +%m -d yesterday` |
OlderNewer