Skip to content

Instantly share code, notes, and snippets.

View haruo31's full-sized avatar

Haruo Kinoshita haruo31

View GitHub Profile
@haruo31
haruo31 / pukiwiki_cleaner.py
Created April 1, 2016 19:05
pukiwikiに投稿された英字のみからなるエントリを除去してページとバックアップを再構成するスクリプト wiki/ backup/ を読み込み、 wiki_out/ backup_out/ にフィルタ済み結果を吐き出す。 Text.langs を is_spam 的なメソッドに置換すれば、spam判断をとりこむこともできるかも。
# -*- coding: utf-8 -*-
# -*- eval: (setq flycheck-python-pylint-executable "/home/haruo31/app/caffe/bin/pylint") -*-
from codecs import decode, encode
from datetime import datetime, timedelta
from glob import glob
import gzip
from itertools import chain, repeat, groupby
import json
@haruo31
haruo31 / sample.py
Last active February 14, 2016 17:24
jisxやsjisのコードマッピングから正規表現に使えるレンジリストを生成する
#!/usr/bin/python
# -*- coding: utf8 -*-
# -*- eval: (setq flycheck-python-pylint-executable "/usr/bin/pylint") -*-
"""
This script generates the ranges of unicode character code that is defined in code mapping at unicode.org.
unicode.orgの文字コードマッピングから、unicodeの文字コードのレンジをプリントするスクリプト。
"""
from itertools import groupby
@haruo31
haruo31 / gist:34396b16f6ef4bbe49d9
Created January 25, 2016 01:35
run shell script before run python.
#!/bin/sh
# -*- coding: utf-8 -*-
""":"
exec python $0 $*
"""
import sys
@haruo31
haruo31 / mysqldump_split_insert.py
Last active February 14, 2016 08:20
the short tool will work if you cannot remake mysqldump without extended-insert option.
# -*- coding: utf8 -*-
import sys
BOL, LCOMMENT, INSTMT, INSERT, VALUES, QUOTE_VALUE = range(6)
CHUNK_SIZE = 1024 * 1024 * 1 / 2 # 512k in read
stock = ''
def next():