Skip to content

Instantly share code, notes, and snippets.

View tomoh1r's full-sized avatar
💭
I may be slow to respond.

NAKAMURA, Tomohiro tomoh1r

💭
I may be slow to respond.
View GitHub Profile
@tomoh1r
tomoh1r / ziptest.sh
Created April 18, 2013 10:21
zip test ワンライナー、セミコロン無しバージョン
python -c "with getattr(__import__('zipfile', globals(), locals(), [], -1), 'ZipFile')('hoge.zip', 'r') as zfp: print(not bool(zfp.testzip()))"
@tomoh1r
tomoh1r / README.rst
Last active December 15, 2015 01:49
Buildout 用の hogerecipe。 src/hoge.py というファイルを書き出す。 djangorecipe が簡潔にまとまっていたので参考にした。 template (boilerplate ?) に Jinja2 を利用するとどうかと思い書いた。
@tomoh1r
tomoh1r / hoge.js
Last active December 12, 2015 04:08
1. 「0」を出力する 2. 1秒待つ 3. 「1」を出力する 4. 1秒待つ 5. 「2」を出力する see http://techblog.yahoo.co.jp/programming/js_callback/
'use strict';
(function(seq) {
var hoge = function(seq) {
// timeout の秒数 (ms)
var timeout = 1 * 1000;
// 与えられた配列の length が 0 なら終わり
if (seq.length == 0) return;
@tomoh1r
tomoh1r / gjslint.vim
Created January 23, 2013 01:04
自分用
if exists("current_compiler")
finish
endif
let current_compiler = "gjslint"
if exists(":CompilerSet") != 2 " older Vim always used :setlocal
command -nargs=* CompilerSet setlocal
endif
CompilerSet makeprg=gjslint\ %
@tomoh1r
tomoh1r / test.js
Last active December 11, 2015 11:18
function の解釈のタイミングがミソ
'use strict';
(function() {
var proto = Hoge.prototype;
function Hoge() {
// some implements ...
}
// some implements ...
})();
@tomoh1r
tomoh1r / test_prototype.js
Created December 15, 2012 14:36
プロトタイプに何が設定されているか確認
'use strict';
var Hoge = Object.create(null);
var h = Object.create(Hoge);
console.log(Hoge == Object.getPrototypeOf(h));
// => true
@tomoh1r
tomoh1r / test_inherit.py
Created December 15, 2012 14:04
インスタンスについて、親クラスの変数の値を変えたらどうなるか、インスタンス自身の値を変えたらどうなるかテスト
# coding: utf-8
class Hoge(object):
x = 100
hoge = Hoge()
print(hoge.x)
# => 100
@tomoh1r
tomoh1r / test_prototype.js
Created December 15, 2012 13:59
親の値を変えてあげれば、複数であったとしても、子の値に伝播するテスト
'use strict';
var Hoge = Object.create(null);
Hoge.x = 10;
var h = Object.create(Hoge);
var f = Object.create(Hoge);
console.log(h.x);
// => 10
console.log(f.x);
// => 10
@tomoh1r
tomoh1r / test_prototype.js
Created December 15, 2012 13:55
親の値を変えてあげれば子の値に伝播するテスト
'use strict';
var Hoge = Object.create(null);
Hoge.x = 10;
var h = Object.create(Hoge);
console.log(h.x);
// => 10
Hoge.x = 20;
console.log(h.x);
// => 20
@tomoh1r
tomoh1r / hoge.py
Created August 4, 2012 03:38
__init__ のテスト
class Hoge(object):
def __init__(self, *args, **kwargs):
super(type(self), self).__init__()