Skip to content

Instantly share code, notes, and snippets.

@think49
think49 / compatible-event.js
Last active September 25, 2015 07:07
compatible-event.js : addEventListener, attachEvent のラッパー関数。addEvent したリスナーは window unload 時に削除される(循環参照対策)。attachEvent でも実行順が保証される。
/**
* compatible-event.js
*
* @version 0.9.4b
* @author think49
* @url https://gist.github.com/882821
*/
'use strict';
@think49
think49 / get-class.js
Created March 9, 2011 12:15
get-class.js : [[Class]] を返す (ECMAScript5準拠)
/**
* get-class.js
*
* @version 1.0.4
* @author think49
* @url https://gist.github.com/862098
*/
function getClass (arg) {
var _class;
@think49
think49 / get-type.js
Created March 9, 2011 12:04
get-type.js : ECMAScript5 準拠のデータ型を返す
/**
* get-type.js
*
* @version 1.0.2
* @author think49
* @url https://gist.github.com/862085
* @license http://www.opensource.org/licenses/mit-license.php (The MIT License)
*/
function getType (value) {
@think49
think49 / NumberString.js
Created March 6, 2011 05:06
NumberString.js : 2-36の基数を持つ数値文字列オブジェクトを生成するコンストラクタ
/**
* NumberString.js
*
* @version 2.0.1
* @author think49
* @url https://gist.github.com/857047
*/
var NumberString;
@think49
think49 / abnf.js
Created February 15, 2011 13:52
abnf.js : RFC5234 規定の ABNF 文字列を ECMAScript5 の RegExp 準拠の文字列に変換する
/**
* abnf.js
*
* [RFC 5234] Augmented BNF for Syntax Specifications: ABNF
* http://www.ietf.org/rfc/rfc5234.txt
* http://www.cam.hi-ho.ne.jp/mendoxi/rfc/rfc5234j.html
*
* @version 0.1
* @author think49
*/
@think49
think49 / print.css
Last active March 1, 2016 01:58
print.js : 指定した要素ノードにテキストを挿入する
@charset "UTF-8";
/**
* print.css
*
* @version 1.0.1
* @author think49
*/
#print { margin: 1em 0; padding: 0.5em; border: 1px solid #999; color: black; background-color: #EFEFEF; font-family: monospace; }
@think49
think49 / percentEncode.js
Created February 1, 2011 04:50
percentEncode.js : RFC3986 規定のパーセントエンコーディング
/**
* percentEncode.js
*
* @version 0.9.2
* @author think49
* @url https://gist.github.com/805428
*/
var percentEncode = (function () {
@think49
think49 / Array.prototype.shuffle.txt
Created January 28, 2011 14:24
array-shuffle.js : "Fisher–Yates shuffle"
----------------------
Fisher–Yates shuffle
----------------------
* Fisher and Yates' original method
1. Write down the numbers from 1 to N.
2. Pick a random number k between one and the number of unstruck numbers remaining (inclusive).
3. Counting from the low end, strike out the kth number not yet struck out, and write it down elsewhere.
4. Repeat from step 2 until all the numbers have been struck out.
@think49
think49 / outerHTML.js
Created January 16, 2011 08:27
outerHTML.js : HTML5 規定の element.outerHTML を定義する。
/**
* outerHTML.js
*
* @version 1.4
* @author think49
*/
if (!('outerHTML' in document.createElement('p')) && 'innerHTML' in document.createElement('p') && (typeof HTMLElement === 'function' || typeof HTMLElement === 'object')) {
(function () {
var _Node = (typeof Node === 'function' || typeof Node === 'object') ? Node : {
@think49
think49 / Twitter-outputHTML-bookmarklet.js
Created January 16, 2011 03:22
Twitter-outputHTML-bookmarklet.js
/**
* Twitter-outputHTML-bookmarklet.js
*
* @version 1.2
* @author think49
*/
if (!('outerHTML' in document.createElement('p')) && 'innerHTML' in document.createElement('p') && (typeof HTMLElement === 'function' || typeof HTMLElement === 'object')) {
(function () {
var _Node = (typeof Node === 'function' || typeof Node === 'object') ? Node : {