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/python2.6 | |
| # coding: utf-8 | |
| # グラフの可視化ライブラリ | |
| import os | |
| import pydot | |
| # TODO: 疎行列への対応 |
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/python2.7 | |
| # coding: utf8 | |
| from math import sqrt, ceil | |
| def sieve(upper): | |
| n = int( ceil(sqrt(upper)) ) | |
| table = range(upper+1) | |
| table[0] = table[1] = 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
| #! /usr/bin/python2.7 | |
| # coding: utf-8 | |
| import threading | |
| class WatchDog(object): | |
| def __init__(self, interval, callback): | |
| self.interval = interval # second |
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
| print 'hello sublime text gist plugin!' |
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
| /* | |
| O(n^2)のアルゴリズムです。 | |
| 1~(入力される最大の数値)を100個の範囲に分けて、数値nが与えられた時に | |
| 範囲ごとに対応する操作を実行します。 | |
| 範囲1 nに対応する範囲より小さい範囲 | |
| 無視 | |
| 手順2 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
| #! /usr/bin/python2.7 | |
| # coding: utf-8 | |
| import mechanize | |
| import BeautifulSoup | |
| import datetime | |
| def normalize_date(text): | |
| # mm/dd -> yyyy/mm/dd | |
| y = datetime.datetime.now().year | |
| return '%d/%s' % (y, text[:5]) |
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
| def lis(seq, m=0, decrease=False): | |
| # longest increasing subsequence | |
| assert type(seq) is list | |
| seq = [m] + seq | |
| lng = [0] # lis length for index i | |
| ptr = [-1] # lis previous pointer for index i | |
| for i in xrange(1, len(seq)): | |
| js = None | |
| if not decrease: | |
| js = filter(lambda j: seq[j] < seq[i], xrange(i)) |
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 | |
| # | |
| # simple twitter client | |
| # | |
| import sys | |
| import os | |
| import twitterlib |
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/python2.7 | |
| # coding: utf-8 | |
| # | |
| # 毒舌な妹をブロックする | |
| # | |
| import sys | |
| import os | |
| import itertools | |
| import twitterlib |
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/python2.7 | |
| # coding: utf-8 | |
| # monitor appengine api status from 'Quota Details' page on your appengine dashboard. | |
| import urllib | |
| import mechanize | |
| from BeautifulSoup import BeautifulSoup | |