Skip to content

Instantly share code, notes, and snippets.

class FinStMch:
gendct = {}
state = None
def scheduler(self, start):
self.state = start
while 1:
yield self.gendct[self.state].next()
def set_gen(self, **kwds):
class Super:
secret = {}
class Say1(Super):
def __init__(self):
self.secret[0] = 'this is my secret'
print "Say1:", self.secret
class Say2(Super):
def __init__(self):
@tkf
tkf / setup.py
Created September 9, 2009 14:05
"""
- rst2latex : rst2latex
- latex2platex : convert using sed
- platex2pdf : compile .tex -> .dvi -> .pdf
"""
from distutils.cmd import Command
from distutils.errors import *
import os
[rst2latex]
rst2latex-command = c:/Python24/Scripts/rst2latex.py
rst2latex-options = --template=D:\freeware\docutils\docutils\writers\latex2e\default.tex -i utf-8 -o shift_jis
[latex2platex]
sed-command=d:/freeware/winsed12/WINSED.EXE -o $ofile -f $script $ifile
# sed-command=sed -f $script $ifile > $ofile
@tkf
tkf / l2p.sed
Created September 9, 2009 14:06
s/\\usepackage\[.*\]{inputenc}/%& %% for platex/
s/\\usepackage{babel}/%& %% for platex/
# s/\(\\usepackage\[\)\(.*\]{hyperref}\)/\1dvipdfmx,\2/
s/\\usepackage\[.*\]{hyperref}/& \\AtBeginDvi{\\special{pdf:tounicode SHIFT_JIS}}/
# s/\\usepackage\[.*\]{hyperref}/& \\AtBeginDvi{\\special{pdf:tounicode EUC-UCS2}}/
@tkf
tkf / hrst2htmls.py
Created September 23, 2009 06:50
howm を rst2html で変換する
#!/usr/bin/env python
import os
import sys
HOWM_PATH = os.path.join(os.getenv('HOME'), "howm")
HOWM_PUB = os.path.join(os.getenv('HOME'), "misc/pub_memo/howm")
RST2HTML_PATH = '/usr/bin/rst2html.py'
def get_dir_and_file_list(path):
dlst = []
def isint(i):
try:
if int(i) == i:
return True
except:
pass
return False
#!/usr/bin/env python
import pylab
import numpy
t = numpy.arange(0.0, 2.0, 0.01)
s1 = numpy.sin(2*pi*t)
s2 = numpy.exp(-t)
s3 = s1*s2
#!/usr/bin/env python
import matplotlib.pyplot as plt
import numpy
class SublotsForReuse(object):
def __init__(self, *args, **kwds):
self.fig = plt.figure(*args, **kwds)
self.ax = []
#!/usr/bin/env python
import matplotlib.pyplot as plt
import numpy
class SublotsForReuse(object):
def __init__(self, *args, **kwds):
self.fig = plt.figure(*args, **kwds)
self.ax = []