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 / requirements.txt
Created March 8, 2012 07:51
gae for python 用 requirements.txt
PIL
MySQL-python
Jinja2
@tomoh1r
tomoh1r / test_flake8.py
Created June 17, 2012 16:23
flake8 をテストで利用する場合のサンプルを作ってみた。あってんのかなー
# -*- coding: utf-8 -*-
'''以下のようなディレクトリ構成を想定する。
├── src
│    ├── fizzbuzz
│       ├── __init__.py
│        └── main.py
└── test
    ├── __init__.py
   ├── test_flake8.py - このテストファイル
  └── test_main.py - main.py 用テスト
@tomoh1r
tomoh1r / hoge.py
Created August 4, 2012 03:38
__init__ のテスト
class Hoge(object):
def __init__(self, *args, **kwargs):
super(type(self), self).__init__()
@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 / 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 / みためはこちらのほうがすき.lsp
Created October 27, 2015 12:56
インデントとかはこちらのほうがすき
(defun fact (n &optional m) (
if (zerop n)
m
(fact (1- n) (if m (* m n) n))
))
@tomoh1r
tomoh1r / some.py
Created November 23, 2015 13:04
decorator でラップされた対象を控えておく
>>> lst = []
>>> def deco(f):
... lst.append(f)
...
>>> @deco
... def main():
... pass
...
>>> print(['{f.__module__}.{f.__name__}'.format(f=f) for f in lst])
['__main__.main']
@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 14:36
プロトタイプに何が設定されているか確認
'use strict';
var Hoge = Object.create(null);
var h = Object.create(Hoge);
console.log(Hoge == Object.getPrototypeOf(h));
// => true
@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 ...
})();