Skip to content

Instantly share code, notes, and snippets.

Tomotaka Ito tomotaka

Block or report user

Report or block tomotaka

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View datetime_serialize_test.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View bootstrap_pip.sh
#!/bin/sh
curl https://bootstrap.pypa.io/ez_setup.py -o /tmp/ez_setup.py
# install easy_install
python /tmp/ez_setup.py
# install pip
easy_install pip
@tomotaka
tomotaka / orelang.py
Last active Oct 6, 2016
orelang python impl
View orelang.py
# -*- coding: utf-8 -*-
# orelang: http://qiita.com/shuetsu@github/items/ac21e597265d6bb906dc
# dependency: click
import os
import os.path
import sys
import json
import click
@tomotaka
tomotaka / bottleurl.py
Created Jun 4, 2016
get url, query string, path in bottle
View bottleurl.py
import bottle
from wsgiref import simple_server
b = bottle.Bottle()
def test():
path = bottle.request.path
urlargs = bottle.request.url_args
query_string = bottle.request.query_string
url = bottle.request.url
return 'your path = %s, urlargs=%s, qs=%s, url=%s' % (path, urlargs, query_string, url)
@tomotaka
tomotaka / file_output_logging_sample.py
Created Sep 24, 2015
python file output logging sample
View file_output_logging_sample.py
# -*- coding: utf-8 -*-
import logging
import sys
def main():
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
handler = logging.FileHandler('/tmp/aaa.log', mode='ab', encoding='utf-8')
formatter = logging.Formatter('[%(levelname)s] %(message)s (%(filename)s:%(lineno)s)')
@tomotaka
tomotaka / stdout_python_logging_sample
Created Sep 24, 2015
stdout python logging sample
View stdout_python_logging_sample
# -*- coding: utf-8 -*-
import logging
import sys
def main():
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
handler = logging.StreamHandler(sys.stdout)
formatter = logging.Formatter('[%(levelname)s] %(message)s (%(filename)s:%(lineno)s)')
@tomotaka
tomotaka / ldbdump.py
Created Sep 17, 2015
json-lines dumper of leveldb
View ldbdump.py
# -*- coding: utf-8 -*-
import time
# pip install click plyvel simplejson
import click
import plyvel
import simplejson as json
@click.command()
@tomotaka
tomotaka / calc_mean_bench.py
Last active Aug 29, 2015
mean calculation benchmark
View calc_mean_bench.py
import numpy as np
import random
import time
from contextlib import contextmanager
data = []
for i in xrange(300000):
data.append(random.randint(1, 100000000))
@tomotaka
tomotaka / sqlitedict_vs_plyvel.py
Last active Aug 29, 2015
sqlitedict vs plyvel(LevelDB)
View sqlitedict_vs_plyvel.py
# -*- coding: utf-8 -*-
import time
import hashlib
import os
from contextlib import contextmanager
import shutil
import plyvel
from sqlitedict import SqliteDict
@tomotaka
tomotaka / concurrentcrawler.py
Last active Aug 29, 2015
concurrent crawler using gevent
View concurrentcrawler.py
import gevent.queue as gq
class ConcurrentCrawler(object):
def __init__(self, func=crawl_all, concurrency=10, q_max=100):
self._func = func
self._concurrency = concurrency
self._q_max = q_max
self._queue = gq.Queue(maxsize=self._q_max)
self._workers = None
You can’t perform that action at this time.