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
// できないこと | |
// ・演算子(/, /=) の後ろにあるコメントを除去できない | |
// ・演算子(/, /=) の後ろにある正規表現リテラルを無視できない | |
// ・<xml>{0/*消えて*/}/*消えないで*/</xml> | |
function trimComment(str) { | |
// コメント___________________ 文字列リテラル(")_______ 文字列リテラル(')_______ CDATA セクション________ 正規表現リテラル___________________________ | |
return str.replace(/(\/)(?:\*[\s\S]*?\*\/|\/.*)|"(?:\\[\s\S]|[^\\\n"])*"|'(?:\\[\s\S]|[^\\\n'])*'|<!\[CDATA\[[\s\S]*?\]\]>|\/(?:\\.|\[(?:\\.|[^\n\]])*\]|[^\n/])+\/\w*/g, function($0, $1) { | |
return $1 ? '' : $0; | |
}); |
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.prototype.bind = Function.prototype.bind || function bind(thisArg) { | |
var method = this; | |
var args = Array.prototype.slice.call(arguments, 1); | |
return function bound() { | |
var _args = args.concat(Array.prototype.slice.call(arguments)); | |
if (!(this instanceof bound)) | |
return method.apply(thisArg, _args); | |
var __args = []; |
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 Callable() { | |
var self = function Callable() | |
this.__call__.apply(this, arguments); | |
self.__proto__ = Callable.prototype; | |
return self; | |
} | |
Callable.prototype = { | |
constructor: Callable, | |
__proto__: Function.prototype, | |
__call__: function __call__() { |
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 Class(sup, pro) { | |
if (sup && typeof sup === 'object') | |
pro = sup, sup = Object; | |
var con = Object.getOwnPropertyDescriptor(pro, 'constructor'); | |
if (!con) | |
con = {value: Function(), writable: true, configurable: true}; | |
if (con.configurable) { | |
con.enumerable = 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
/* @require Prototype.js | |
var src = new WaveFile(properties).toDataURI(); | |
// properties は WaveFile.prototype を参考に。 | |
*/ | |
Object.extend(Number.prototype, { | |
toLEArray: function toLEArray(length) { | |
var num = this | 0, length = +length, result = []; | |
if (0 < arguments.length && !length) return 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
[p for(p in Iterator(#1={ | |
0: +'', | |
1: -~'', | |
2: -~-~'', | |
3: -~-~-~'', | |
4: -~-~-~-~'', | |
5: -~-~-~-~-~'', | |
6: '$$$$$$'[~''], | |
7: '$$$$$$$'[~''], | |
8: -~''<<-~-~-~'', |
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 Prediction(level) { | |
this.level = +level || 5; | |
this.history = ''; | |
this.recent = ''; | |
this.accum = {}; | |
this.tokens = {}; | |
} | |
Prediction.prototype.add = function add(c) { | |
c = ('' + c).charAt(0); | |
this.tokens[c] = true; |
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> | |
<title>JS1k, 1k demo submission</title> | |
<meta charset="utf-8" /> | |
</head> | |
<body> | |
<canvas id="c"></canvas> | |
<script type="text/javascript" src="innocencer.js1k.js"></script> | |
</body> |
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
// ==UserScript== | |
// @name Hatebu count on Google Reader | |
// @namespace http://twitter.com/xulapp | |
// @include http://www.google.tld/reader/view/* | |
// @include https://www.google.tld/reader/view/* | |
// @author xulapp | |
// @license MIT License | |
// @version 2010/10/11 15:50 +09:00 | |
// ==/UserScript== |
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() { | |
var quote = (function() { | |
var specialCharReg = /[\n\r'\\]/g; | |
var specialCharMap = {'\n': '\\n', '\r': '\\r', '\'': '\\\'', '\\': '\\\\'}; | |
var specialCharRegCb = function(c) { return specialCharMap[c]; }; | |
return function(str) { | |
return '\'' + str.replace(specialCharReg, specialCharRegCb) + '\''; | |
}; | |
})(); |
NewerOlder