Skip to content

Instantly share code, notes, and snippets.

@knzm
knzm / gist:1382715
Created November 21, 2011 14:11
traceback for `make epub`
# Sphinx version: 1.1.2
# Python version: 2.6.6
# Docutils version: 0.8.1 release
# Jinja2 version: 2.5.5
Traceback (most recent call last):
File "***/lib/python2.6/site-packages/Sphinx-1.1.2-py2.6.egg/sphinx/cmdline.py", line 189, in main
app.build(force_all, filenames)
File "***/lib/python2.6/site-packages/Sphinx-1.1.2-py2.6.egg/sphinx/application.py", line 204, in build
self.builder.build_update()
File "***/lib/python2.6/site-packages/Sphinx-1.1.2-py2.6.egg/sphinx/builders/__init__.py", line 196, in build_update
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import re
import csv
import urllib
from StringIO import StringIO
@knzm
knzm / .hgrc
Created December 8, 2011 14:23
My .hgrc
[ui]
username = Nozomu Kaneko <nozom.kaneko@gmail.com>
merge = internal:merge
[extensions]
graphlog =
mq =
color =
rebase =
transplant =
========================================
In defense of zope libraries 翻訳
========================================
Pyramid が Zope ライブラリを使っていることについての非常に長い defence
----------------------------------------------------------------------
freenode の #pyramid IRC チャンネルで、以下のような質問に私は
うんざりするほど多くの時間を割いてきた。
@knzm
knzm / sample.py
Created February 21, 2012 15:26 — forked from podhmo/sample.py
# -*- coding:utf-8 -*-
from mako.template import Template
from mako.lookup import TemplateLookup
def generate_source_mako():
with open("source.mako", "w") as w:
w.write("""
<div id="header">
<%block name="header">
from math import sqrt, floor
__all__ = ['is_prime', 'Prime']
class Prime(object):
def __init__(self):
self._primes = [2, 3, 5]
def is_prime(self, n):
if n < 2:
@knzm
knzm / gist:1891045
Created February 23, 2012 06:18
One-liner to extract Date field from a mail and convert it into ISO 8601 format
formail -c -x Date | python -c 'import sys, datetime; from rfc822 import parsedate; print datetime.datetime(*parsedate(sys.stdin.readline())[:6])'
@knzm
knzm / gist:1909346
Created February 25, 2012 16:24
Windows で Zinnia をスタティックリンクするためのパッチ
Index: mmap.h
===================================================================
--- mmap.h (リビジョン 16)
+++ mmap.h (作業コピー)
@@ -112,7 +112,11 @@
CHECK_CLOSE_FALSE(false) << "unknown open mode:" << filename;
}
- hFile = CreateFile(filename, mode1, FILE_SHARE_READ, 0,
+ size_t len = 0;
@knzm
knzm / gist:1965423
Created March 3, 2012 10:31
Git cheatsheet
How to get a remote branch on my local git repository:
$ git checkout origin/branch-1
$ git checkout -b branch-1
Or, is it a better way?
$ git checkout --track -b branch-1 origin/branch-1
How to add an upstream repository and get it:
@knzm
knzm / gist:1999304
Created March 8, 2012 07:02
kytea patch
diff --git a/src/include/kytea/general-io.h b/src/include/kytea/general-io.h
index bf167cc..c1caadf 100644
--- a/src/include/kytea/general-io.h
+++ b/src/include/kytea/general-io.h
@@ -101,7 +101,7 @@ public:
void openFile(const char* file, bool out, bool bin) {
std::fstream::openmode mode = (out?std::fstream::out:std::fstream::in);
- if(bin) out = out | std::fstream::binary;
+ if(bin) mode = mode | std::fstream::binary;