Skip to content

Instantly share code, notes, and snippets.

Avatar
⛩️
Enjoying Kyoto.

Shotaro Tanaka yubessy

⛩️
Enjoying Kyoto.
View GitHub Profile
@yubessy
yubessy / README.md
Created Jan 15, 2017
Python logging using context
View README.md

cxtlog

Contextual Logger for Python

Usage

>>> logging.basicConfig(level=logging.INFO)
>>> logger = logging.getLogger()
>>> cxtlgr = cxtlog.wrap(logger)
@yubessy
yubessy / Python3
Last active May 14, 2019
Python3の...(Ellipsisオブジェクト)について ref: https://qiita.com/yubessy/items/cc1ca4dbc3161f84285e
View Python3
>>> str(Ellipsis)
'Ellipsis'
>>> str(pass)
File "<stdin>", line 1
str(pass)
^
SyntaxError: invalid syntax
@yubessy
yubessy / file0.txt
Last active Apr 13, 2019
Julia の SparseArrays で協調フィルタリング ref: https://qiita.com/yubessy/items/6e661b5ffb8b260cf51c
View file0.txt
\hat{r}_{u,i} = \bar{r_u} + \frac{1}{|I_u|} \sum\limits_{i' \in I_u} \operatorname{sim}(i, i') (r_{u, i'} - \bar{r_u})
View mytextrank.py
# -*- coding: utf-8 -*-
# third-party lib
import networkx
def blank_split(text):
u"""
半角スペースによる単語分割
"""
return text.split()
@yubessy
yubessy / file0.txt
Last active Jul 14, 2018
MediaWiki APIを使ってWikipediaの情報を取得 ref: https://qiita.com/yubessy/items/16d2a074be84ee67c01f
View file0.txt
http://ja.wikipedia.org/w/api.php?パラメータ1=値1&パラメータ2=値2&...&パラメータn=値n
View decrypt_morse.py
MORSE_SIGNS = {
"a": ".-", "b": "-...", "c": "-.-.", "d": "-..", "e": ".", "f": "..-.",
"g": "--.", "h": "....", "i": "..", "j": ".---", "k": "-.-", "l": ".-..",
"m": "--", "n": "-.", "o": "---", "p": ".--.", "q": "--.-", "r": ".-.",
"s": "...", "t": "-", "u": "..-", "v": "...-", "w": ".--", "x": "-..-",
"y": "-.--", "z": "--..",
}
def decrypt_morse(morse):
@yubessy
yubessy / defaults-main.yml
Last active Sep 12, 2017
Ansible pyenv role
View defaults-main.yml
---
pyenv_root: /opt/pyenv
pyenv_rcfiles: []
pyenv_versions: []
pyenv_global_version: system
pyenv_build_requirements:
# https://github.com/pyenv/pyenv/wiki/Common-build-problems
- zlib-devel
- bzip2
- bzip2-devel
@yubessy
yubessy / defaults-main.yml
Last active Sep 12, 2017
Ansible Python Role
View defaults-main.yml
---
python_version: 3.6.2
@yubessy
yubessy / mecab_wrapper.py
Created Mar 16, 2017
ごく適当なMeCabのPythonラッパー
View mecab_wrapper.py
import re
from collections import namedtuple
import MeCab
Node = namedtuple('Node', [
'surface',
'base',
'reading',
'pos',
@yubessy
yubessy / nyt_example.yaml
Last active Oct 23, 2015
The New York Times Annotated Corpus の各フィールドのデータ例
View nyt_example.yaml
identifier:
guid: "129961"
fileName: "0129961.xml"
url: "http://query.nytimes.com/gst/fullpage.html?res=940DE4D9103CF930A15750C0A96E948260"
alternativeURL:
date:
publicationDate: "2004-09-03T00:00:00Z"
correctDate: "1987-02-04T00:00:00Z"
analyzed_text:
articleAbstract: "Gov James E McGreevey, ..."