Skip to content

Instantly share code, notes, and snippets.

Avatar
⛩️
Enjoying Kyoto.

Shotaro Tanaka yubessy

⛩️
Enjoying Kyoto.
View GitHub Profile
View file0.txt
>>> 'あいう'
'\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86'
@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 corenlp_example.py
import pprint
import json
import corenlp
# パーサの生成
corenlp_dir = "/usr/local/lib/stanford-corenlp-full-2013-06-20/"
parser = corenlp.StanfordCoreNLP(corenlp_path=corenlp_dir)
# パースして結果をpretty print
result_json = json.loads(parser.parse("I am Alice."))
@yubessy
yubessy / file0.txt
Last active Aug 29, 2015
PythonでExcelファイルを作成 + similarity matrix ref: http://qiita.com/yubessy/items/a39a565cdc2c5872cce9
View file0.txt
$ pip install xlsxwriter
@yubessy
yubessy / Default (OSX).sublime-keymap
Last active Aug 29, 2015
Sublime Text 2でコマンドパレットのコマンドにショートカットキーを割り当てる ref: http://qiita.com/yubessy/items/546fc167e6c6c248415b
View Default (OSX).sublime-keymap
[
{
"keys": ["command+_"],
"command": "run_emmet_action",
"args": {
"action": "merge_lines"
}
}
]
View sql_style1.py
sql_stmt = "CREATE TABLE Test(" \
"id INTEGER PRIMARY KEY, " \
"val TEXT NOT NULL)"
@yubessy
yubessy / mycompress.py
Last active Aug 29, 2015
Pythonのオブジェクト圧縮・展開
View mycompress.py
# -*- coding: utf-8 -*-
# stdlib
import cPickle as pickle
import zlib
PROTOCOL = pickle.HIGHEST_PROTOCOL
def save_to_str(obj):
@yubessy
yubessy / mydatex.py
Created Jun 29, 2014
Wikipediaの各年ページの日付をパース
View mydatex.py
# -*- coding: utf-8 -*-
# stdlib
import re
import datetime
# thirdlib
from dateutil.parser import parse
MONTHS = (
"January",
"February",
@yubessy
yubessy / myerr.py
Created Jun 29, 2014
簡単なエラーメッセージ出力
View myerr.py
# -*- coding: utf-8 -*-
# stdlib
import sys
import traceback
def print_exception(func, log_file=sys.stderr):
u"""
関数実行中に発生した例外を出力
"""