This file contains 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 java.util.LinkedList; | |
import jp.ac.kyushu_u.icpc2011.game.*; | |
import jp.ac.kyushu_u.icpc2011.game.GameInfo.Direction; | |
import jp.ac.kyushu_u.icpc2011.game.GameInfo.Handle; | |
import jp.ac.kyushu_u.icpc2011.game.GameInfo.Speed; | |
import jp.ac.kyushu_u.icpc2011.game.model.*; | |
import jp.ac.kyushu_u.icpc2011.gameAPI.*; | |
import jp.ac.kyushu_u.icpc2011.gameAPI.PlayerAction.*; |
This file contains 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/python | |
# coding: utf-8 | |
import sys | |
import fileinput | |
def read_ints(f): | |
return map(int, f.readline().strip().split()) | |
def read_line(f): |
This file contains 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 | |
"""myprofiler - Casual MySQL Profiler | |
https://github.com/methane/myprofiler | |
""" | |
import os | |
import sys |
This file contains 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
00s000 | |
110000 | |
100000 | |
g0000g | |
敵の移動力を10とした時、左のゴールへ移動するのにかかる時間は44、 | |
右のゴールへ移動するのにかかる時間は42なので、右のゴールに進むはず。 | |
だが、履歴を確認すると敵は左のゴールへ移動していた。 |
This file contains 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 flask | |
app = flask.Flask(__name__) | |
@app.before_request | |
def setup(): | |
This file contains 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
http://developer.mixi.co.jp/appli/spec/mob/validate-oauth-signature/ を Python で検証してみる。 | |
In [85]: key | |
Out[85]: '79e0a55cde43e7dc86fd1e1366d6bd6ac7771db8&' | |
In [86]: raw | |
Out[86]: 'GET&http%3A%2F%2Fexample.com%2Ffoo%2F&oauth_consumer_key%3Dbc906fac81f581c3c96a%26oauth_nonce%3D9dc8fbca0e51842e7449%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1254282755%26oauth_version%3D1.0%26opensocial_app_id%3D123%26opensocial_owner_id%3Dxxxxxxxx' | |
In [87]: import hmac | |
In [88]: from hashlib import sha1 | |
In [89]: hmac.new(key, raw, sha1).digest().encode('base64') | |
Out[89]: 'cv87UdLBj/Jlt0hkqvQ6m2d9XxY=\n' |
This file contains 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 | |
"""mystatus - Casual MySQL status check | |
""" | |
import os | |
import sys | |
import re | |
from time import sleep, strftime |
This file contains 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
"""Flask extension utility.""" | |
from flask.sessions import SessionInterface, SessionMixin | |
from werkzeug.contrib.cache import MemcachedCache | |
import memcache # Use https://code.launchpad.net/~songofacandy/python-memcached/mixin-threading | |
def setup_cache(app): | |
""" | |
Setup ``app.cache``. |
This file contains 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]: class C(object): | |
...: def m(self): | |
...: pass | |
...: | |
In [2]: c=C() | |
In [3]: f=c.m | |
In [4]: f() |
This file contains 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]: def loop(): | |
...: for i in xrange(10**5 * 30): | |
...: pass | |
...: | |
In [2]: %timeit loop() | |
10 loops, best of 3: 56.8 ms per loop |