Skip to content

Instantly share code, notes, and snippets.

View tag1216's full-sized avatar
😇

tag1216 tag1216

😇
View GitHub Profile
@tag1216
tag1216 / dynamic_import.py
Created July 14, 2017 12:55
ディレクトリ内のPythonファイルを動的インポート
import os
import sys
from glob import glob
from importlib import import_module
sys.path.append('plugins')
for path in glob('plugins/*.py'):
filename = os.path.basename(path)
print(filename)
mkdir -p mnt
sshfs host:/path/to/dir mnt
fusermount -u mnt
@tag1216
tag1216 / README.md
Last active May 10, 2017 07:53
バッチスクリプトの進捗をコンソールに出力する方法

progress

@tag1216
tag1216 / largesort.py
Created May 7, 2017 07:45
巨大ファイルのソート
import heapq
import os
import re
from argparse import ArgumentParser
from contextlib import contextmanager
from operator import itemgetter
from tempfile import TemporaryDirectory, mktemp
import sys
from typing import IO, Callable, List
@tag1216
tag1216 / 01_thread.py
Created April 2, 2017 12:19
Pythonでconcurrent.futuresを使った並列タスク実行
import time
from concurrent.futures import ThreadPoolExecutor
from logging import StreamHandler, Formatter, INFO, getLogger
def init_logger():
handler = StreamHandler()
handler.setLevel(INFO)
handler.setFormatter(Formatter("[%(asctime)s] [%(threadName)s] %(message)s"))
logger = getLogger()
@tag1216
tag1216 / Dockerfile
Created February 10, 2017 01:29
NEologdコンテナのDockerfile
#https://github.com/neologd/mecab-ipadic-neologd/blob/master/README.ja.md
FROM ubuntu
RUN apt update
RUN apt -y upgrade
RUN apt -y install mecab libmecab-dev mecab-ipadic-utf8 git make curl xz-utils file
# install neologd
RUN mkdir -p /usr/lib/mecab/dic
RUN cd /root; \
@tag1216
tag1216 / docker-compose.yml
Created January 23, 2017 07:24
DjangoをDocker Composeで動かすときにDBが起動するまで待つ
command: ["./wait-for-db.sh", "--", "python", "manage.py", "runserver", "0.0.0.0:8000"]
@tag1216
tag1216 / deleted_calendar.py
Last active January 12, 2017 12:12
Qiita Advent Calendar 2016 で削除されたカレンダー
import re
import requests
import time
def main():
url = "http://qiita.com/sudoyu/items/0a51593b257f419aeb20.md"
print(url)
@tag1216
tag1216 / urls.py
Created December 9, 2016 08:48
DjangoでURLルーティングの階層化
urlpatterns = [
url(r"^mysite/", include([
url(r"^accounts/", include([
url(r"^login/$", auth_views.login, {"template_name": "accounts/login.html"}, name="login"),
url(r"^logout/$", auth_views.logout, name="logout"),
], namespace="accounts", app_name="accounts")),
url(r'^admin/', admin.site.urls),
url(r'^', include('app.urls')),
]))
@tag1216
tag1216 / test.py
Created December 7, 2016 08:03
Python Pillow で透過画像の判定
from PIL import Image
img = Image.open("test.png")
if img.mode == 'RGBA' or "transparency" in img.info:
print("透過画像")