Skip to content

Instantly share code, notes, and snippets.

View haruo31's full-sized avatar

Haruo Kinoshita haruo31

View GitHub Profile
@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():
@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 / 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 / determine_dirname.sh
Created July 4, 2016 01:32
posix compliant determining script home directory.
#!/bin/sh
BASE=`dirname $0 | xargs -I\{\} sh -c "cd {}; pwd"`
@haruo31
haruo31 / dvdrip.sh
Created July 18, 2016 11:29
wrapper script that creates ISO file via output of dvdbackup.
#!/bin/sh
set -xe
DRIVE=/dev/sr0
TARGET=`pwd`
TMP=`mktemp -d --suffix=dvdbackup -p $TARGET`
pushd $TMP
dvdbackup -M -i $DRIVE
(:name howm-haruo31
:website "http://howm.sourceforge.jp/"
:description "Write fragmentarily and read collectively."
:type http-tar
:options ("xzf")
:url "http://howm.sourceforge.jp/a/howm-1.4.3.tar.gz"
:build `(("./configure" ,(concat "--with-emacs=" el-get-emacs)) ("make")))
@haruo31
haruo31 / SampleMain.java
Created December 6, 2016 17:21
sample java project
package sample;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.util.Random;
@haruo31
haruo31 / Sample2Main.java
Created December 6, 2016 17:32
sample 2 project
package jp.underthetree;
import java.io.*;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field.Store;
import org.apache.lucene.document.StringField;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
@haruo31
haruo31 / shell command
Created December 14, 2016 16:14
Sum size of files which are found in find command.
$ find . -name '*.m2ts' | xargs stat -c%s | paste -s -d+ | bc