Skip to content

Instantly share code, notes, and snippets.

@think49
think49 / eval-calculation-1.0.0.js
Last active October 18, 2023 15:04
eval-calculation.js: 計算式の文字列を評価する
/**
* eval-calculation.js
* evaluate calculation formula.
*
* @version 1.0.0
* @author think49
* @url https://gist.github.com/think49/54b074cab2145efddb48765652c74710
* @license http://www.opensource.org/licenses/mit-license.php (The MIT License)
*/
@think49
think49 / [html,css,javascript]-idname&classname-specification.md
Last active June 2, 2022 07:22
[HTML, CSS, JavaScript] id名/class名に使用できる文字の種類
@think49
think49 / calculator.css
Last active November 11, 2016 05:47
calculator.js: 計算式を表示するシンプルな電卓
/**
* calculator.css
*/
.calc-form {
border-collapse: separate;
border-spacing: 0.2em;
font-style: monospace;
}
@think49
think49 / ReadMe.md
Last active October 4, 2016 08:04
addholdkeyeventlistener.js: 同時に入力されたキー一覧を取得するイベントリスナ(addEventListener 互換)

addholdkeyeventlistener.js

概要

キーボードからキー入力する場合、キーを押して(keydown)した後にキーを離して(keyup)、キー入力を確定させます。 この仕組みを踏まえ、keyup の瞬間に同時に入力されているキー全てを取得するイベントリスナを実現します。

使い方

"addholdkeyeventlistener.js" を外部スクリプトとして読み込めば、第一引数にDOMノードを指定する以外は addEventListener と同等の感覚で使えます。

@think49
think49 / History.md
Last active July 12, 2022 05:36
csv.js: ES5 規定の JSON と同じインターフェースを持つCSVパーサ

更新履歴 (csv.js)

ver 1.0.3 (2016/05/11)

  • CSV.parse() の内部実装を String.prototype.replace から RegExp.prototype.exec に変更した

ver 1.0.2 (2016/05/11)

  • CSV.parse() で第三引数 reviver が指定された場合、配列化する前にセル値を引数にとるコールバック関数 reviver を呼び出すようにした
  • CSV.stringify() で第三引数 replacer が指定された場合、CSV文字列に変換する前に要素値を引数にとるコールバック関数 replacer を呼び出すようにした

ver 1.0.1 (2016/05/10)

@think49
think49 / es6-string-prototype-startswith.js
Last active March 29, 2016 08:51
es6-string-prototype-startswith.js: String.prototype.startsWith の Polyfill (ES6 規定)
/**
* es6-string-prototype-startswith.js
* String.prototype.startsWith (ECMA-262 6th Edition / ECMAScript 2015)
*
*
* @version 1.0.0
* @author think49
* @url https://gist.github.com/think49/908b8d5f08c9945beea7
* @license http://www.opensource.org/licenses/mit-license.php (The MIT License)
* @see <a href="http://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.startswith">21.1.3.18 String.prototype.startsWith – ECMA-262 6th Edition</a>
@think49
think49 / ReadMe.md
Last active February 27, 2016 18:24
increment-by-number-range.js: 範囲指定の数字をインクリメントループする(ex: 5 -> 6 -> 7 -> 5 -> 6 ->...)

increment-by-number-range.js

概要

範囲指定内で数字をインクリメントさせます。 例えば、「5 -> 6 -> 7 -> 5 -> 6 ->...」のようにループします。

HowTo

第一引数から「現在値, 開始値, 終了値」を指定し、関数を返します。

@think49
think49 / jquery.get-classlist.js
Last active February 17, 2016 03:25
jquery.get-classlist.js: jQuery オブジェクトの最初のインデックスとなる要素ノードから classList (HTML5規定) を得る jQuery plugin
/**
* jquery.get-classlist.js
* get a classList of first index's jQuery object.
*
* @version 1.0
* @author think49
* @url https://gist.github.com/think49/c382098fedd9ae7c6661
* @license http://www.opensource.org/licenses/mit-license.php (The MIT License)
*/
@think49
think49 / es6-weakmap.js
Last active July 1, 2017 21:46
es6-weakmap.js: ECMA-262 6th Edition (ECMAScript 2015) WeakMap polyfill
/**
* es6-weakmap.js
* WeakMap (ECMA-262 6th Edition / ECMAScript 2015)
*
*
* @version 0.9.2
* @author think49
* @url https://gist.github.com/think49/283b7374e352e09fc131
* @license http://www.opensource.org/licenses/mit-license.php (The MIT License)
* @see <a href="http://www.ecma-international.org/ecma-262/6.0/#sec-weakmap-constructor">23.3.1 The WeakMap Constructor – ECMA-262 6th Edition</a>
@think49
think49 / debug-code.js
Last active December 9, 2015 16:38
debug-code.js: コードを実行し、評価値or例外エラーをプログラムを強制終了せずに返す
/**
* debug-code.js
*
* @version 1.0.3
* @author think49
* @url https://gist.github.com/think49/bfca562039aa29fa5766
* @license http://www.opensource.org/licenses/mit-license.php (The MIT License)
*/
'use strict';
var DebugCode = (function (Object, keys, defineProperty, String) {