Skip to content

Instantly share code, notes, and snippets.

# This command helps you to create pyenv virtualenv and activate that after creation.
# NOTE: I checked this works on zsh
vec() {
PWD=`pwd`
DNAME=`basename $PWD`
pyenv virtualenv 3.7.3 $DNAME
pyenv local $DNAME
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/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 October 6, 2016 06:13
orelang python impl
# -*- 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 June 4, 2016 01:51
get url, query string, path in bottle
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 September 24, 2015 10:05
python file output logging sample
# -*- 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 September 24, 2015 09:59
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 September 17, 2015 07:34
json-lines dumper of leveldb
# -*- 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 August 29, 2015 14:26
mean calculation benchmark
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 August 29, 2015 14:20
sqlitedict vs plyvel(LevelDB)
# -*- coding: utf-8 -*-
import time
import hashlib
import os
from contextlib import contextmanager
import shutil
import plyvel
from sqlitedict import SqliteDict