Skip to content

Instantly share code, notes, and snippets.

Avatar
🙃
:outside_you:

Amane Katagiri amane-katagiri

🙃
:outside_you:
View GitHub Profile
@amane-katagiri
amane-katagiri / email-protection.py
Created Mar 13, 2017
Implementation of "https?://some.domain.under.cdn.cloudflare.example.com/cdn-cgi/l/email-protection#{encoded_email_address}".
View email-protection.py
def protect_email(key: int, data: bytes) -> bytes:
return bytes([x ^ (key % 256) for x in b"\x00" + data])
def deprotect_email(data: bytes) -> bytes:
return bytes([x ^ data[0] for x in data[1:]])
def main():
import argparse
@amane-katagiri
amane-katagiri / SlackHandler.py
Last active Mar 15, 2017
Slack handler for the logging package for Python.
View SlackHandler.py
"""Slack handler for the logging package for Python."""
import json
from logging import DEBUG
from logging import Formatter
from logging import getLogger
from logging.handlers import HTTPHandler
class SlackHandler(HTTPHandler):
View keybase.md

Keybase proof

I hereby claim:

  • I am amane-katagiri on github.
  • I am amane (https://keybase.io/amane) on keybase.
  • I have a public key whose fingerprint is 75CB B604 4ABF 0EA0 C15C 38E8 5642 D37E E532 097E

To claim this, I am signing this object:

View lgtm.sh
ffmpeg -i input.mp4 -filter_complex "drawtext=fontfile=/usr/share/fonts/truetype/mplus/mplus-1p-bold.ttf:text=LGTM:x=(w-text_w)/2:y=(h-text_h-line_h)/2:fontcolor=white:fontsize=200" output.mp4
View emoji_generator.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
r"""
Generate emoji list json file for mdx_unimoji(https://github.com/kernc/mdx_unimoji).
You can convert emoji_strategy.json on emojione (https://github.com/emojione/emojione) into
`{"ENTITY1": ["NAME1"], "ENTITY2": ["NAME2", "ALTERNAME2", ...], ...}`.
Usage:
$ ./emoji_generator.py https://raw.githubusercontent.com/Ranks/emojione/master/emoji_strategy.json
@amane-katagiri
amane-katagiri / cmake.sh
Last active Aug 9, 2017
Cmake flags for opencv and python3
View cmake.sh
mkdir release
cd release
cmake -DCMAKE_BUILD_TYPE=RELEASE -DWITH_TBB=YES -DWITH_EIGEN=YES -DBUILD_NEW_PYTHON_SUPPORT=ON -DBUILD_opencv_python3=ON \
-DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
-DCMAKE_INSTALL_PREFIX=~/usr/software/opencv_build \
-DPYTHON_EXECUTABLE=~/.pyenv/versions/mlc/bin/python3 \
-DPYTHON_LIBRARY=~/.pyenv/versions/3.5-dev/lib/libpython3.so ..
make -j8
make install
@amane-katagiri
amane-katagiri / run.sh
Last active Aug 9, 2017
foregroundize script (useful in docker)
View run.sh
#!/bin/sh
trap 'echo "reload command"' HUP
trap 'echo "stop command"' EXIT
trap 'echo "stop command"; trap EXIT; exit 0' TERM INT
echo "start command which launches a background service and returns immediately"
while true; do sleep 3600 & wait; done
@amane-katagiri
amane-katagiri / ahaha.py
Last active Aug 9, 2017
"あは ぎょうざ あはは" one-liner.
View ahaha.py
print(" ".join(["あはは" + "は" * __import__("random").randint(0, 3) for x in range(int(abs(__import__("random").normalvariate(0, 2)) * 10 + 1))]), "あは ぎょうざ あはは")
View twdel.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
from requests_oauthlib import OAuth1Session
CK = "CONSUMER_KEY"
CS = "CONSUMER_SECRET"
AT = "ACCESS_TOKEN"
AS = "ACCESS_SECRET"
View ejdic-hand-utf8.txt
This file has been truncated, but you can view the full file.
@ 単価…で/…につき
104 通信で用いられる『了解』の意を表す語
A answer / ampere
a. about / acre[s] / adjective
Triassic period (地質の年代で)三畳紀の / 二畳紀
A,a 〈C〉英語アルファベットの第1字 / 〈U〉(音階の)イ音,イ調 / 〈C〉《米》(学校の成績の)A
A.A. =AA / antiaircraft
a,an 《oneの弱い意味で》『一つの』,一人の / 《日本語では表現しない場合》 / 《日本語でも表現する場合》 / 『ある』(a certain) / 《同種類のものを代表してany, eachの弱い意味で》…『というもの[は]』,いずれの,どの / 《単位を表す語につけて》…『につき』,毎…(per) / 《しばしばof, atなどの後で》同じ(the same) / 《固有名詞につけて》…のような人,…という名の人,…家の人;…の作品(製品) / 《固有名詞の性格・特徴などを強調するとき》 / 《andで結んだ二つ以上の名詞につけて》 / 《名詞が同一の人・物をさす場合》…でも~でもある人(物) / 《名詞が別個の人・物をさす場合》…つきの,一組の…と~ / 《物質名詞につけて》一種の,一つの / 《抽象名詞につけその具体例・種類・行為などを表して》 / 《have,give,make,takeなどに続く動詞と同形の名詞につけて》1回の
A.B. B.A.