Skip to content

Instantly share code, notes, and snippets.

@knzm
knzm / cjk.map
Created April 3, 2012 07:40
sphinx latex-pdf
% Takaoフォントファミリー
%% 明朝系
rml H TakaoMincho.ttf
rmlv V TakaoMincho.ttf
rml-jis H TakaoMincho.ttf
%% ゴシック系
gbm H TakaoGothic.ttf
gbm V TakaoGothic.ttf
gbm-jis H TakaoGothic.ttf
# -*- coding: utf-8 -*-
from fractions import Fraction
import unittest
def fraction_from_repeating(period, base=10):
"""
Return a fraction equivalent to the given repeating decimal.
def fix_basic_auth_handler():
# Workaround for http://bugs.python.org/issue9639
if sys.version_info[:2] == (2, 6) and sys.version_info[2] >= 6:
def fixed_http_error_401(self, req, fp, code, msg, headers):
url = req.get_full_url()
response = self.http_error_auth_reqed(
'www-authenticate', url, req, headers)
self.retried = 0
return response
import re
def fix_charref(s):
return re.sub(r'&#(\d+);', lambda m: unichr(int(m.group(1))), s)
.. role:: del
.. role:: new
.. raw:: html
<style>
.del { text-decoration: line-through; }
.new { color: red; }
</style>
$ locale
LANG=ja_JP.UTF-8
LANGUAGE=ja_JP:ja:en_GB:en
LC_CTYPE="ja_JP.UTF-8"
LC_NUMERIC="ja_JP.UTF-8"
LC_TIME="ja_JP.UTF-8"
LC_COLLATE="ja_JP.UTF-8"
LC_MONETARY="ja_JP.UTF-8"
@knzm
knzm / gist:2630124
Created May 7, 2012 20:16
zope.interface memo

summary

provide implement
descriptor
  • classProvides
  • moduleProvides
  • implements
  • implementsOnly
decorator
  • provider
  • implementer
@knzm
knzm / gist:2658098
Created May 11, 2012 07:17
Sphinx が reStructuredStructure をレンダリングするまでの流れ
sphinx/cmdline.py:189, in main
app.build(force_all, filenames)
sphinx/application.py:204, in build
self.builder.build_update()
sphinx/builders/__init__.py:196, in build_update
'out of date' % len(to_build))
sphinx/builders/__init__.py:252, in build
self.write(docnames, list(updated_docnames), method)
sphinx/builders/__init__.py:292, in write
self.write_doc(docname, doctree)
>>> 1 + 2j
(1+2j)
>>> type(1 + 2j)
<type 'complex'>
@knzm
knzm / gist:2843304
Created May 31, 2012 13:06
How to fix a merge commit when using git
# Before:
#
# * 06071d8 fix
# |
# * 75c9b25 merge
# |\
# | * 34f1259 branch-B
# | |
# * | 5db192c branch-A
# | |