Skip to content

Instantly share code, notes, and snippets.

@shirou
shirou / .mo creator for sphinx gettext builder
Created April 18, 2011 05:38
spaces should be replaced to TAB.
.SUFFIXES: .pot .po .mo
LANG=ja
TRANSLATED=translated
OUT=../../$(TRANSLATED)/$(LANG)/LC_MESSAGES
POFILES := ${shell find . -name "*.pot" | sed "s/.pot/.po/"}
MOFILES := $(foreach p, $(POFILES), $(subst .po,.mo,$(p)))
@shirou
shirou / gist:980419
Created May 19, 2011 08:45
PDFImageDraw
Traceback (most recent call last):
File "/home/shirou/Works/VEnvs/sphinx/bin/blockdiag", line 9, in <module>
load_entry_point('blockdiag==0.8.1', 'console_scripts', 'blockdiag')()
File "/home/shirou/Works/VEnvs/sphinx/lib/python2.7/site-packages/blockdiag-0.8.1-py2.7.egg/blockdiag/command.py", line 150, in main
draw.draw()
File "/home/shirou/Works/VEnvs/sphinx/lib/python2.7/site-packages/blockdiag-0.8.1-py2.7.egg/blockdiag/DiagramDraw.py", line 122, in draw
self.node(node, **kwargs)
File "/home/shirou/Works/VEnvs/sphinx/lib/python2.7/site-packages/blockdiag-0.8.1-py2.7.egg/blockdiag/DiagramDraw.py", line 273, in node
font=self.font, badgeFill=self.badgeFill)
File "/home/shirou/Works/VEnvs/sphinx/lib/python2.7/site-packages/blockdiag-0.8.1-py2.7.egg/blockdiag/noderenderer/__init__.py", line 79, in render
@shirou
shirou / Andoroid https+basic auth
Created August 24, 2011 15:22
https+basic auth (but not success)
String test_get(String urlstr) throws Exception
{
final DefaultHttpClient httpClient = new DefaultHttpClient();
httpClient.getCredentialsProvider().setCredentials(
new AuthScope("my.rightscale.com", 443),
new UsernamePasswordCredentials("address", "paaswwword"));
HttpGet request = new HttpGet(urlstr);
@shirou
shirou / gist:1228587
Created September 20, 2011 07:48
argparse subparser
# -*- coding: utf-8 -*-
import argparse
parser = argparse.ArgumentParser()
# トップレベルのparserを作ります
subparsers = parser.add_subparsers(help='sub-command help')
# demo というサブコマンドのparserを作ります
@shirou
shirou / gist:1263303
Created October 5, 2011 00:46
fluent error
%./fluentd (master)[~/fluent]
/home/hoge/fluent/tmp/lib/fluent/ruby/lib/ruby/gems/1.9.1/gems/fluent-0.9.18/bin/fluentd:2:in `<top (required)>': undefined method `export' for main:Object (NoMethodError)
from /home/hoge/fluent/tmp/lib/fluent/ruby/bin/fluentd:19:in `load'
from /home/hoge/fluent/tmp/lib/fluent/ruby/bin/fluentd:19:in `<main>'
%/home/hoge/fluent/tmp/lib/fluent/ruby/bin/ruby --version (master)[~/fluent]
ruby 1.9.2p180 (2011-02-18) [x86_64-freebsd8.1]
% uname -a
FreeBSD 8.1-RELEASE FreeBSD 8.1-RELEASE #0: Mon Jul 19 02:36:49 UTC 2010 [email protected]:/usr/obj/usr/src/sys/GENERIC amd64
@shirou
shirou / Makefile
Created October 20, 2011 04:09
sphinx i18n
# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = build
# Internal variables.
@shirou
shirou / treediag.py
Created November 18, 2011 08:50
make file tree using blockdiag.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
HEADER = """
{
default_shape="textbox";
node_width = 60;
@shirou
shirou / old_fashion_hg.py
Created November 21, 2011 14:56
extract files in the mercurial changesets with timestamp filename.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This script extracts changed files in changesets with timestamp suffix.
#
# Yes, I know timestamp based history management is not the mercurial way.
# but, but, sigh...
#
# license: new BSD
#
@shirou
shirou / python-aalib.py
Created November 25, 2011 04:35
python-aalib
(sphinx)%python blockdiag-aa.py QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ
QQQQQWQW4QWWWWWWWWWWWWWW4WWWQWWW4QWWWWWWWWWWWWWW4WWWQWWW4QWWWWWWWWWWWWWW4WWWQWQQ
QQQQWQWW]QQQQQQQQQQQQQQQ]#WWWQ4Q]QQQQQQQQQQQQQQQ]#WWWQ4Q]QQQQQQQQQQQQQQQ]#WWWQQQ
QQQQQWQW]QQQQQQf)WQQQQQQ:X#W4Q ]QQQQQQf)WQQQQQQ:X#W4Q ]QQQQQfJW]QQQQQQ:X#WQWQQ
QQQQWQWW]QQQQQQ6aWQQQQQQ:3BQ]QaW]QQQQQQ6jQQQQQQQ:3BQ]QaW]QQQQQ6yaaQQQQQQ:3BWQWQQ
QQQQWQWW)???????????????=3WW]QWB)???????????????=3WW]QWB)???????????????=3WWWQQQ
QQQQQWWWXniiiiii|ii|iiiivXBW]QWWXoiiiiiiiiiii|iivXBW]QWWXoiiiii|i|iiiiiivXBWQWQQ
QQQQWQWWWmmqmqmqmmqmmqmqmmWQ]QQWWmmqmqmqmqmqmqmmmmWW]QQW?!"""""!""""""""4mWWQWQQ
QQQQWQWWWWWWWWWWBWWBWWBWWWWQ]QWWWWWWWWWWBWWWWWWmWWWQ]QWW]QQQQQQQQQQQ
@shirou
shirou / build.py
Created December 22, 2011 15:43
sphinx websupport with NGRAM schema
from sphinx.websupport import WebSupport
from sphinx.websupport.errors import DocumentNotFoundError
from sphinx.websupport.search import whooshsearch
from whoosh.fields import Schema, ID, TEXT, NGRAM
import os
import shutil
ROOT = '/absoulte/path/to/sampledoc'