Skip to content

Instantly share code, notes, and snippets.

@rokujyouhitoma
rokujyouhitoma / gist:f41595e7c660bfc2efe4
Created December 24, 2015 07:39
http://techstudy-dena.peatix.com/ に言って質問した話。メモ書き
同期フロー
だいぶ複雑になってしまうけど...
=> 同期って...例えば、何が、どこで、どう当たり判定とって、どう共有して、
共有どうしてる?
フロー図、シーケンス図の類書いてる?
コードベース?
サーバサイド
クライアントの担当者がデバッグしやすいような施策がある?
@rokujyouhitoma
rokujyouhitoma / performance
Last active October 19, 2015 08:37
TinySegmenter.pyをPurePythonとCython(型情報なし、PurePythonコードをCythonでコンパイルしただけ)の速度比較
TinySegmenter.pyを速度改善してみる。
手抜きで、Cythonでコンパイルするだけでいいかなー。と。
TinySegmenter.pyをPurePythonとCython(型情報なし、PurePythonコードをCythonでコンパイルしただけ)の速度比較した。
結論Cythonでコンパイルするだけで速度改善できた。
更に速度したいなら、
1. Cythonで型情報を付与。
2. Cに持ってく。
# http://imagingsolution.blog107.fc2.com/blog-entry-137.html
def x(p1, p2, p3, p4):
s1 = (p4.x - p2.x) * (p1.y - p2.y) - (p4.y - p2.y) * (p1.x - p2.x)
s2 = (p4.x - p2.x) * (p2.y - p3.y) - (p4.y - p2.y) * (p3.x - p3.x)
(x,y) = p1.x + (p3.x - p1.x) * s1 / (s1 + s2), p1.y + (p3.y - p1.y) * s1 / (s1 + s2)
return (x,y)
text = "ab[ffffff]cd[-]ef"
print("length: {0}".format(len(text)))
#print(text[2])
indexes = [0,2,10,12,15,17]
for i in range(0, len(indexes) / 2):
sindex = indexes[i*2]
eindex = indexes[i*2+1]
print("s: {0}".format(sindex))
print("e: {0}".format(eindex))
/* Generated by Cython 0.22 */
/* BEGIN: Cython Metadata
{
"distutils": {}
}
END: Cython Metadata */
#define PY_SSIZE_T_CLEAN
#ifndef CYTHON_USE_PYLONG_INTERNALS
@rokujyouhitoma
rokujyouhitoma / patched.py
Created March 10, 2015 07:41
locust and gevent patch for python2.7.9
#https://github.com/gevent/gevent/issues/477#issuecomment-56292848
# # Re-add sslwrap to Python 2.7.9
import inspect
__ssl__ = __import__('ssl')
try:
_ssl = __ssl__._ssl
except AttributeError:
_ssl = __ssl__._ssl2
@rokujyouhitoma
rokujyouhitoma / gist:173b75f030a1f1f22591
Created September 19, 2014 04:40
PythonでHTTP RequestとResponseの生文字列を確認したい時のモンキーパッチ
def http_connection_send():
import httplib
def patch_send():
old_send= httplib.HTTPConnection.send
def new_send(self, data, *args, **kwargs):
print(data)
body = old_send(self, data, *args, **kwargs)
return body
httplib.HTTPConnection.send = new_send
patch_send()
@rokujyouhitoma
rokujyouhitoma / gist:d736bb68147a93363861
Created September 18, 2014 03:02
ApacheJMeterの結果データをよきように表すやつ
# -*- coding: utf-8 -*-
import pandas
import argparse
parser = argparse.ArgumentParser(description='xxx')
parser.add_argument('csv', type=argparse.FileType('r'))
args = parser.parse_args()
csv = args.csv
while true; do date; curl "http://stocks.finance.yahoo.co.jp/stocks/detail/?code=3632.t" 2>/dev/null | grep 'class="stoksPrice"' | awk 'match($0, /[0-9,]+/) {print substr($0, RSTART, RLENGTH)}'; sleep 60; done;
#!/usr/bin/env python2
# Quick and dirty demonstration of CVE-2014-0160 by Jared Stafford ([email protected])
# The author disclaims copyright to this source code.
import sys
import struct
import socket
import time
import select