Skip to content

Instantly share code, notes, and snippets.

@hideaki-t
hideaki-t / sqlite_fts_tokenizer.py
Created August 18, 2012 20:59
a proof of concept implementation of SQLite FTS tokenizers in Python
# coding: utf-8
"""
a proof of concept implementation of SQLite FTS tokenizers in Python
"""
from __future__ import print_function, unicode_literals
import sys
import ctypes
from ctypes import POINTER, CFUNCTYPE
import struct
@hideaki-t
hideaki-t / compare_size.py
Created July 28, 2012 04:11
comparing index size by indexing method
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from whoosh import query
from whoosh.fields import *
from whoosh.filedb.filestore import RamStorage
import whooshjp
from whooshjp.IgoTokenizer import IgoTokenizer
import igo.Tagger
@hideaki-t
hideaki-t / Main.java
Created March 28, 2012 02:03
possible resource leak in try-with-resources
import java.io.*;
public class Main {
public static void main(String[] args) {
try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("hoge")))) {
// use buffered reader ...
} catch (IOException e) {
e.printStackTrace();
}
}
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> print unichr(ord(u'生') & ord(u'死'))
from itertools import izip, tee
def ntuple(it, n):
its = tee(it, n)
for c, i in enumerate(its):
for j in range(c): i.next()
return izip(*its)
@hideaki-t
hideaki-t / gist:1979829
Created March 5, 2012 17:48
rstblogger test

rst2bloggerのテスト

rst2blogger というのがあったので試してみます。 その名前の通りreStructuredTextで書いた文章をbloggerの記事にしてくれるものです。 この記事は rst2blogger を使って投稿してみています。

ドキュメント をみると引数はreSTファイルだけでよくて、ドラフトに突っ込んでくれるようで、 タイトルが同じであれば、同じエントリの更新になるので直したら普通にアップロードしなおせば良いようです。

@hideaki-t
hideaki-t / Test.java
Created March 5, 2012 17:44
Kuromoji(will be included in lucene 3.6) test w/java7
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.ja.JapaneseAnalyzer;
import org.apache.lucene.analysis.ja.tokenattributes.BaseFormAttribute;
import org.apache.lucene.analysis.ja.tokenattributes.InflectionAttribute;
import org.apache.lucene.analysis.ja.tokenattributes.PartOfSpeechAttribute;
import org.apache.lucene.analysis.ja.tokenattributes.ReadingAttribute;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.util.Version;
import java.io.IOException;
@hideaki-t
hideaki-t / OMakefile
Created February 4, 2012 07:50
valid/invalid examples of OMakefile using lualatex
# valid
USEPDFLATEX=true
PDFLATEX=lualatex
LaTeXDocument(main, main)
.DEFAULT: main.pdf
@hideaki-t
hideaki-t / gist:1614517
Created January 15, 2012 05:39
testing japanese text in networkx
# coding: utf-8
import networkx
G=networkx.Graph()
from matplotlib import pyplot
G.add_edge(u'池袋', u'新宿')
G.add_edge(u'新宿', u'代々木')
G.add_edge(u'代々木', u'品川')
G.add_edge(u'品川', u'東京')
G.add_edge(u'東京', u'神田')
@hideaki-t
hideaki-t / checkversion.hta
Created December 18, 2011 02:28
check JScript engine version and functionality in HTA environment
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=8 ; IE=9" />
<title>chcek JavaScript engine version</title>
</head>
<body>
</body>
<script>