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
| inada-n@valkryie:~/work/redis$ mkvirtualenv redis # 実験用の独立した環境を容易 | |
| Using real prefix '/usr' | |
| New python executable in redis/bin/python | |
| Installing setuptools............done. | |
| Installing pip...............done. | |
| virtualenvwrapper.user_scripts creating /home/inada-n/.virtualenvs/redis/bin/predeactivate | |
| virtualenvwrapper.user_scripts creating /home/inada-n/.virtualenvs/redis/bin/postdeactivate | |
| virtualenvwrapper.user_scripts creating /home/inada-n/.virtualenvs/redis/bin/preactivate | |
| virtualenvwrapper.user_scripts creating /home/inada-n/.virtualenvs/redis/bin/postactivate | |
| virtualenvwrapper.user_scripts creating /home/inada-n/.virtualenvs/redis/bin/get_env_details |
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 | |
| import socket | |
| class FooClient(object): | |
| def __init__(self, host, port): | |
| self._sock = socket.socket() | |
| self._sock.connect((host, port)) | |
| def say(self): | |
| self._sock.sendall('Foo!\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
| all: | |
| cython --embed mltest.py | |
| gcc -O2 mltest.c `python-config --cflags --ldflags` -fPIC -o mltest | |
| cython --embed mltest2.pyx | |
| gcc -O2 mltest2.c `python-config --cflags --ldflags` -fPIC -o mltest2 |
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
| #!/usr/bin/env python | |
| from watchdog import events, observers | |
| from paver.easy import * | |
| import subprocess | |
| class AutoCompile(events.FileSystemEventHandler): | |
| def compile(self, src): | |
| if src.endswith('.cpp'): | |
| src = path(src) | |
| dst = src.splitext()[0] |
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
| In [1]: import msgpack | |
| In [2]: packed = msgpack.packb([1,2,3]) | |
| In [3]: packed | |
| Out[3]: '\x93\x01\x02\x03' | |
| In [4]: packed *= 3 | |
| In [5]: len(packed) |
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
| NWAY = 4 | |
| LINESIZE_BITS = 4 | |
| LINESIZE = 2 ** LINESIZE_BITS # 64 | |
| CACHESIZE = 4*1024 | |
| NUMLINES = CACHESIZE / LINESIZE | |
| LINES = [(None, None)] * NUMLINES |
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
| from time import sleep | |
| from tornado.httpserver import HTTPServer | |
| from tornado.ioloop import IOLoop | |
| from tornado.web import Application, asynchronous, RequestHandler | |
| from multiprocessing.pool import ThreadPool | |
| _workers = ThreadPool(10) | |
| def run_background(func, callback, args=(), kwds={}): | |
| def _callback(result): |
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
| #!/usr/bin/env python | |
| # coding: utf-8 | |
| from __future__ import print_function | |
| import datetime as dt | |
| import os | |
| import sys | |
| import time | |
| import logging | |
| from ConfigParser import SafeConfigParser |
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
| import gevent | |
| import sys | |
| N = int(sys.argv[1]) | |
| M = int(sys.argv[2]) | |
| def sleeper(n): | |
| for i in xrange(N): | |
| #print(n) | |
| gevent.sleep(0) |
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 | |
| $d = file_get_contents('index.html'); | |
| //$d = htmlspecialchars($d); | |
| $d = strtr($d, array('&'=>'&', '<'=>'<', '>'=>'>')); | |
| for ($i =0; $i < 10000; ++$i) { | |
| strtr($d, array('&'=>'&', '<'=>'<', '>'=>'>')); | |
| } |