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 re | |
import sqlite3 | |
class SQLite3DB: | |
_IDENTIFIER_RE = re.compile(r'^[a-zA-Z_]\w*$') | |
def __init__(self, filename): | |
self._con = sqlite3.connect(filename, isolation_level=None) | |
self._con.row_factory = sqlite3.Row |
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
>>> c1 = 1 + 1j | |
>>> c2 = 1 - 2j | |
>>> c1 + c2 | |
(2-1j) | |
>>> c1 * c2 | |
(3-1j) | |
>>> c1 / c2 | |
(-0.2+0.6j) |
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
$ pip install rstr |
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
gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git', :branch => 'bootstrap3' |
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
#-*- encoding: utf-8 -*- | |
# thirdlib | |
import requests | |
BASE_URL = "http://en.wikipedia.org/w/api.php" | |
BLLIMIT = 250 | |
def get_regular_name(q): |
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
# -*- coding: utf-8 -*- | |
def shorten(s, length=80): | |
u""" | |
長い文字列を"abraca ... tabra"のように短く表示 | |
""" | |
if len(s) < length: | |
return s | |
else: | |
if isinstance(s, unicode): |
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
# -*- coding: utf-8 -*- | |
# stdlib | |
import re | |
LEFT_SPACES = re.compile(r'\s+<') | |
RIGHT_SPACES = re.compile(r'>\s+') | |
SCRIPT_TAG = re.compile(r'<script[^>]*>.*?</script>') | |
COMMENT = re.compile(r'<!--[\s\S]*?-->') |
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
# -*- coding: utf-8 -*- | |
# stdlib | |
import sys | |
import traceback | |
def print_exception(func, log_file=sys.stderr): | |
u""" | |
関数実行中に発生した例外を出力 | |
""" |
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
# -*- coding: utf-8 -*- | |
# stdlib | |
import re | |
import datetime | |
# thirdlib | |
from dateutil.parser import parse | |
MONTHS = ( | |
"January", | |
"February", |
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
# -*- coding: utf-8 -*- | |
# stdlib | |
import cPickle as pickle | |
import zlib | |
PROTOCOL = pickle.HIGHEST_PROTOCOL | |
def save_to_str(obj): |