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 c1, c2; | |
c1 = console.log; | |
c2 = console.log.bind(console); | |
c1('hoge'); // => TypeError: Illegal invocation | |
c1.call(console, 'hoge'); // => hoge | |
c2('hoge'); // => hoge |
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 rot = (function () { | |
function tr(str, from, to) { | |
return str.replace(new RegExp('[' + from + ']', 'g'), function (key) { | |
return to[from.indexOf(key)] || key; | |
}); | |
} | |
function range(min, max) { | |
var result = ''; |
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
@echo off | |
python -c "import os, random, sys; os.popen('explorer ' + ' & explorer '.join(random.sample(os.listdir('.'), int(sys.argv[1]) if len(sys.argv) > 1 else 1)))" %1 |
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 isStrict() { | |
try { | |
arguments.callee; | |
} catch (_) { | |
return true; | |
} | |
return 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 log10(x) { | |
return Math.log(x) / Math.LN10; | |
} | |
Object.defineProperty(Number.prototype, 'length', { | |
get: function () { | |
return Math.floor(log10(Math.abs(this))) + 1; | |
}, | |
set: function (value) { | |
return value; |
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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Icon</title> | |
<style> | |
body { | |
width: 30em; | |
margin: 0 auto; | |
font-family: Consolas, Meiryo, monospace; |
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 _repeat(str, n) { | |
return Array(n + 1).join(str); | |
} | |
function _zfill(str, n) { | |
return (_repeat('0', n) + str).slice(-n); | |
} | |
function hex(str) { | |
return str.split('').map(function (c) { |
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
Object.defineProperty(Array.prototype, 'has', { | |
value: function (value) { | |
return this.indexOf(value) > -1; | |
}, | |
enumerable: false, | |
configurable: true, | |
writable: false | |
}); | |
Object.defineProperty(Array.prototype, 'contains', |
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
'hogehoge'.replace(/./g, function (c) { | |
return c['to' + ['Lower', 'Upper'][Math.random() * 2 | 0] + 'Case'](); | |
}); |
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
Object.defineProperty(Array.prototype, 'shift', { | |
value: function (n) { | |
return this.slice(n).concat(this.slice(0, n)); | |
}, | |
enumerable: false, | |
configurable: true, | |
writable: false | |
}); | |
//----- |