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
#!/usr/bin/env python | |
# coding: utf-8 | |
""" | |
./whitening.py ~/Downloads/xxx/ | |
""" | |
from __future__ import unicode_literals | |
from __future__ import print_function | |
import argparse |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
画像がモノクロか判断 | |
""" | |
from __future__ import print_function | |
import numpy |
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
#!/usr/bin/env python | |
# thanks: http://qiita.com/uemura/items/a3a0937f77494e62213c | |
import sys | |
import re | |
import subprocess | |
import datetime | |
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
def find_process_ids(pattern): | |
""" | |
pattern にマッチするプロセスIDを探して返す (自分以外) | |
:rtype: list | |
""" | |
self_pid = os.getpid() | |
try: | |
out = subprocess.check_output(['pgrep', '-f', pattern]) | |
return list(filter( | |
lambda x: x != self_pid, map(int, out.splitlines()))) |
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
<?php | |
/** | |
* 処理結果をインスタンス変数にキャッシュする機能を提供するトレイト | |
* * | |
* python の @cached_property のように使うのを想定。 | |
* | |
* 引数がある関数の場合は基本的に考慮していないが、がんばってキーを作れば機能するだろう。 | |
* | |
* class HogeClass { | |
* |
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
""" | |
キャッシュ時間計測 | |
- ローカル: | |
- FileBased: 21.2 | |
- LocMem: 0.8 | |
- Dev: | |
- FileBased: 4.0 | |
- Redis(Local): 5.4 |
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 time | |
import threading | |
from queue import Queue | |
class ThreadPool(object): | |
def __init__(self, pool_size=10): | |
self.pool_size = pool_size | |
self.jobs = [] | |
self.job_queue = Queue() |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import os | |
import threading | |
try: | |
from django.utils.functional import cached_property | |
except ImportError: | |
cached_property = property |
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 json | |
import textwrap | |
import base64 | |
from Crypto.Signature import PKCS1_v1_5 | |
from Crypto.Hash import SHA | |
from Crypto.PublicKey import RSA | |
class GooglePlayReceiptValidator(object): |
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
#!/usr/bin/env python | |
# -*- coding:utf-8 -*- | |
import time | |
import RPi.GPIO as GPIO | |
GPIO.setmode(GPIO.BOARD) | |
GPIO.setup(12, GPIO.OUT) | |
p = GPIO.PWM(12, 50) # channel=12 frequency=50Hz | |
p.start(0) |