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
| 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 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
| <!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 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
| 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 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
| function isStrict() { | |
| try { | |
| arguments.callee; | |
| } catch (_) { | |
| return true; | |
| } | |
| return false; | |
| } |
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
| @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 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 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 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 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 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
| 'hoge'.charAt(3); // => 'e' | |
| 'hoge'[3]; // => 'e' | |
| 'hoge'.charAt(4); // => '' | |
| 'hoge'[4]; // => undefined |
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
| String.prototype.title = function () { | |
| return this.replace(/[A-Za-z]+/g, function (m) { | |
| return m[0].toUpperCase() + m.slice(1).toLowerCase(); | |
| }); | |
| }; |
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
| String.prototype.n文字ごとに文字列を挿入する = function (n, str) { | |
| if (n == null || str == null) { | |
| return String(this); | |
| } | |
| return this.replace(new RegExp('.{' + n + '}', 'g'), function (m) { | |
| return m + str; | |
| }); | |
| }; |