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
#!/usr/bin/env node | |
// todo: try to require jshint here, instead of spawning process, then fallback to spawning process. | |
var jshint = nrequire('jshint'); | |
if (jshint) return process.exit(0); | |
// jshint not installed locally, spawn process instead. | |
// basically the same, but less pretty. | |
var exec = require('child_process').exec; |
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
// 'toaster'.toStartUpBand(); | |
String.prototype.toStartUpBand = function () { | |
return this.replace(/[^aeiuo]([aeiuo]{1})[^aeiuo]+$/g, function(m,m1){return m.replace(m1, '')}) + 'ly'; | |
}; |
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 toUnicode(str) { | |
var unicodeStr = '', | |
i = 0, | |
strlen = str.length, | |
theUnicode; | |
for (; i < strlen; i++) { | |
code = str.charCodeAt(i).toString(16).toUpperCase(); | |
while (code.length < 4) { | |
code = '0' + code; | |
} |
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
data:text/html,<textarea contenteditable spellcheck=false ></textarea><button>Save</button><style>body{margin:0; padding:0;}textarea{background%3A%23666%3Bcolor%3A%230F0%3Bheight:100%;width:100%;line-height:1.3;font-size:14px;letter-spacing:1px;padding:10px;}button{position:absolute;color:black;right:20px;top:20px;border:1px solid grey;font-size:14px;padding:6px 14px;border-radius:8px;background%3A%239ECFF5%3B}</style><script>p = document.body.firstChild;p.focus();var val,tabs = 2,spaces = (function (s, t){while (--t) s += s;return s}(' ', tabs));p.onkeydown = function (e) {val = this.value;sstart = this.selectionStart;s = val.substr(0, sstart);n = val.substr(sstart);if (e.which === 9) {this.value = s + spaces + n;this.selectionStart = this.selectionEnd = sstart + tabs;return false;}};document.querySelector('button').onclick = function () {window.location = 'data:application/json,' + val;}</script> |
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
memo = [0, 1] | |
def memofib(n): | |
if n >= len(memo): | |
i = len(memo) | |
while i <= n: | |
memo.append(memo[i-1] + memo[i-2]) | |
i += 1 | |
return memo[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
var Class = function () { | |
this.a = 'abc'; | |
this.b = 666; | |
this.c = function () { | |
return 3 * 3; | |
}; | |
} | |
Class.prototype.d = function () { | |
return 2 + 2; |
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
_=(typeof{});$=[];__=(typeof+$);alert((''+!!+$)[+$]+(''+$[+!+$])[+$]+__[+$]+_[+!+$+!+$+!+$+!+$]+_[+!+$+!+$+!+$+!+$+!+$]+(typeof'')[+!+$+!+$+!+$]+_[+$]+__[+$]) |
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 timeTil(date) { | |
var t = [ | |
[60 * 60 * 24 * 7 * 4 * 12, 'year'], | |
[60 * 60 * 24 * 7 * 4, 'month'], | |
[60 * 60 * 24 * 7, 'week'], | |
[60 * 60 * 24, 'day'], | |
[60 * 60, 'hour'], | |
[60, 'minute'], | |
[1, 'second'] | |
], |
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
//extend native. bad? | |
Function.prototype.curry = function () { | |
var aslice = [].slice, _method = this, args = aslice.call(arguments); | |
if (!args.length) return _method; | |
return function () { | |
var a = args.concat(aslice.call(arguments)); | |
return _method.apply(this, a); | |
} |
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 | |
echo "MySQL User:"; | |
read MYSQLUSER; | |
echo "MySQL Pass:"; | |
read MYSQLPASS; | |
for I in $(mysql -h localhost -u $MYSQLUSER --password=$MYSQLPASS -e 'show databases' -s --skip-column-names); | |
do mysqldump -u $MYSQLUSER -h localhost --password=$MYSQLPASS $I | gzip > "$I.sql.gz"; | |
done |