Skip to content

Instantly share code, notes, and snippets.

View tamuhey's full-sized avatar
🏠
Working from home

Yohei Tamura tamuhey

🏠
Working from home
View GitHub Profile
@tamuhey
tamuhey / ja_upper.py
Created November 8, 2019 16:10
拗音を促音に変換する
import string
LOWER = "ぁぃぅぇぉっゃゅょゎァィゥェォッャュョヮ"
UPPER = "あいうえおつやゆよわアイウエオツヤユヨワ"
MAP = str.maketrans(dict(zip(LOWER, UPPER)))
def ja_upper(text: str) -> str:
return text.translate(MAP)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tamuhey
tamuhey / upload_github_release_asset.py
Created October 11, 2019 05:44
upload assets to github release
from pathlib import Path
import os
import re
import subprocess
import fire
import requests
ENDPOINT = "https://api.github.com"
curl -H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: $(file -b --mime-type $FILE)" \
--data-binary @$FILE \
"https://uploads.github.com/repos/$REPO/releases/$RELEASE/assets?name=$(basename $FILE)"
@tamuhey
tamuhey / notify-slack.sh
Last active October 10, 2019 10:36
notify-slack
#!/bin/bash
SLACK_NOTIFY_ICON=":ghost:"
if [ ! -f ~/.notify-slack-cfg ]; then
echo "ERROR: A Webhook URL is required. Create yours here: https://my.slack.com/services/new/incoming-webhook/"
echo "Once you have your KEY, please create a file at ${HOME}/.notify-slack-cfg containng only the KEY. Eg: T02TKKSAX/B246MJ6HX/WXt2BWPfNhSKxdoFNFblczW9"
return
fi
SLACK_MESSAGE="$1"
[tool.poetry]
name = "foo"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]
[tool.poetry.dependencies]
python = "^3.7"
[tool.poetry.dev-dependencies]
@tamuhey
tamuhey / spacy_multiprocess_pipe.ipynb
Last active October 7, 2019 15:07
multiprocessing for spacy nlp.pipe
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
class UnionFind:
def __init__(self, objects):
self.objects = list(objects)
self.weights = {i: 1 for i in range(len(self.objects))}
self.parents = list(range(len(self.objects)))
self.obj2num = {k: i for i, k in enumerate(self.objects)}
def add(self, obj):
self.objects.append(obj)
n = len(self.objects)-1
@tamuhey
tamuhey / combmod.hs
Last active September 8, 2019 16:47
import qualified Data.Vector.Unboxed as U
import Data.Vector.Unboxed ( (!) )
import qualified Data.Vector.Unboxed.Mutable as UM
import Control.Monad.ST
import Control.Monad
base = 10 ^ 9 + 7 :: Int
maxL = 3 * 10 ^ 5 :: Int
n *% m = (n * m) `mod` base
@tamuhey
tamuhey / setup.cfg
Last active October 13, 2019 11:49
minimal setup.cfg
[metadata]
name = {}
home-page = {}
long-description = file: README.md
[options]
zip_safe = false
include_package_data = true
python_requires = >=3.6
packages = {}