This file contains hidden or 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
# -*- coding: utf-8 -*- | |
### | |
### benchmark of Tenjin and Mako | |
### | |
### usage: | |
### $ easy_install tenjin | |
### $ easy_install mako | |
### $ easy_install benchmarker | |
### $ python python_template_bench.py -h |
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
## | |
## benchmark script to measure cost of sys._getframe(1) and sys._getframe(1).f_locals | |
## | |
## How to run: | |
## $ easy_install benchmarker | |
## $ python bench_getframe.py -h | |
## $ python bench_getframe.py -n 1000000 -c 5 -X 1 | |
## |
This file contains hidden or 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
$! raise された例外オブジェクト | |
$" require で読み込まれたファイルの配列 | |
$# | |
$$ 現在のプロセス ID | |
$% | |
$& 正規表現にマッチした箇所の文字列 | |
$' 正規表現にマッチした箇所より後ろの文字列 | |
$( | |
$) | |
$* Ruby スクリプトに指定された引数。ARGV と同じ |
This file contains hidden or 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
## | |
## Python | |
## | |
def seq(initial, formula): | |
x = initial | |
while True: | |
yield x | |
x = formula(x) | |
sequence = seq(1, lambda x: x+1) |
This file contains hidden or 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
route "/users/", :GET=>:index, :POST=>:create | |
route "/users/new", :GET=>:new | |
route "/users/:id", :GET=>:show, :PUT=>:update, :DELETE=>:destroy | |
route "/users/:id/edit", :GET=>:edit | |
## or | |
url_path "/users" do | |
route "/", :GET=>:index, :POST=>:create | |
route "/new", :GET=>:new |
This file contains hidden or 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
## | |
## フィボナッチ数列のうち100以下のものを求める | |
## | |
def fibgen(): | |
x, y = 0, 1 | |
while True: | |
yield x | |
x, y = y, x+y |
This file contains hidden or 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
/* | |
* $Release: $ | |
* $Copyright: copyright(c) 2007-2011 kuwata-lab.com all rights reserved. $ | |
* $License: MIT License $ | |
*/ | |
/** | |
* client-side template engine | |
* | |
* usage: |
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
""" | |
pyramid.testing.tearDown()を一度でも実行すると、 | |
pyramid.threadlocal.get_current_registry().settingsが | |
うまくとってこれなくなることを示すサンプル | |
""" | |
import sys | |
import unittest |
This file contains hidden or 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
<?php | |
/// | |
/// benchmark: loop vs array vs generator vs inner iterator vs closure | |
/// | |
function create_datafile($filename, $filesize=1024) { | |
$str = "Haruhi\tFemale\t16\tTeam Leader\n" | |
. "Mikuru\tFemale\t17\tTime Traveler\n" | |
. "Yuki\tFemale\t16\tHumanoid Interface\n" |
This file contains hidden or 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
<?php | |
/// | |
/// generator benchmark | |
/// | |
function create_datafile($filename, $filesize=1024) { | |
$str = "Haruhi\tFemale\t16\tTeam Leader\n" | |
. "Mikuru\tFemale\t17\tTime Traveler\n" | |
. "Yuki\tFemale\t16\tHumanoid Interface\n" |