Skip to content

Instantly share code, notes, and snippets.

View masahitojp's full-sized avatar
🎯
Focusing

Masato Nakamura masahitojp

🎯
Focusing
View GitHub Profile
@masahitojp
masahitojp / gist:1392628
Created November 25, 2011 01:44
arguments.calleeの代わりに名前付き関数を使う
(function test(n){
"use strict";
if(n==0){
return 1;
}else{
// return arguments.callee(n-1); <= strictモードではエラー
return n* test(n-1); // 名前付き関数を使う。
}
})(2);
@masahitojp
masahitojp / gist:1392669
Created November 25, 2011 02:21
strict-mode で arguments.callee.caller.arguments の代わりになる方法を考察中。だれか他の手段があれば教えて!!
var hoge = function hogehoge(n){
"use strict";
fuga(n-1,Array.prototype.slice.call(arguments));
fuga(n-1,null);
};
var fuga = function fugafuga(n, args){
"use strict";
console.log("--start--");
@masahitojp
masahitojp / httprequest_multiprocessing.py
Created November 30, 2011 07:54
multiprocessing.Poolを使ってHTTPリクエストを多重に投げる。(スクレイピングとかには絶対使わないこと)
import json
import urllib2
import httplib2
import multiprocessing
url='url'
data = json.dumps({'id':'username', 'password':'password'})
def start_process():
print 'Starting', multiprocessing.current_process().name
@masahitojp
masahitojp / buildout.cfg
Created December 12, 2011 03:27
windows用sphinx環境づくり
[buildout]
parts = app docutils
versions = versions
extensions = buildout.locallib
locallibs = locallibs
locallibs_check = false
[app]
recipe = z3c.recipe.scripts
@masahitojp
masahitojp / gist:1485039
Created December 16, 2011 08:03
play! でのPattern Matchの使い方
import static play.libs.F.Matcher.*;
public class matcher_Test extends UnitTest {
@Test
public void test_matcher_object() {
String value = "Foobar";
for (String s : String.and(StartsWith("Foo")).match(value)) {
value = s.toUpperCase();
}
thread 120
Throughput: 163795.39 [#/sec]
Throughput: 160400.20 [#/sec]
Throughput: 161411.85 [#/sec]
epoll f2
Throughput: 137671.49 [#/sec]
Throughput: 149201.28 [#/sec]
@masahitojp
masahitojp / add_data.js
Created January 10, 2012 14:03
http://code.google.com/p/jcvl/ に後から任意の要素を足す
// 追加する要素のpush
cl.list.data[0].data[0].data[0].data.push(
{data:[], hasChildren:false, name:"test", value:"foo"}
);
// クリックしたときに動作するように変更
cl.list.data[0].data[0].data[0].hasChildren=true;
// "●"を表示(クリックできるときには、itemの右端に表示する)
$("#cl1-column-list-col2-item0 div.cvl-column-item-indicator").css("display","inline")
/* pyuv.h */
#if PY_VERSION_HEX >= 0x03000000
#define PY3
#define PyInt_FromSsize_t PyLong_FromSsize_t
#define PyInt_FromLong PyLong_FromLong
/* pending start */
#define PyString_FromString PyBytes_FromString
#define PyString_AsString PyBytes_AsString
#define PyString_FromStringAndSize PyBytes_FromStringAndSize
@unittest.skipIf( sys.platform.startswith('linux'),
"not required Linux")
def test_fsevent_basic(self):
self.errorno = None
@masahitojp
masahitojp / gist:1625814
Created January 17, 2012 09:18
Jenkins
# service running on Jenkins
BUILD_ID=allow_to_run_as_daemon LANG=ja_JP.UTF-8 sh /etc/init.d/ssb_server start