Skip to content

Instantly share code, notes, and snippets.

View shimizukawa's full-sized avatar

Takayuki SHIMIZUKAWA shimizukawa

View GitHub Profile
@shimizukawa
shimizukawa / console
Last active August 29, 2015 14:01
substanced make html log
vagrant@precise64:/tmp$ virtualenv venv
New python executable in venv/bin/python2.7
Also creating executable in venv/bin/python
Installing Setuptools..............................................................................................................................................................................................................................done.
Installing Pip.....................................................................................................................................................................................................................................................................................................................................done.
vagrant@precise64:/tmp$ cd venv/
vagrant@precise64:/tmp/venv$ git clone https://github.com/Pylons/substanced/
Cloning into 'substanced'...
remote: Reusing existing pack: 17699, done.
@shimizukawa
shimizukawa / conf.py
Last active February 11, 2023 07:32
Sphinx column directive extension コラムディレクティブ拡張 for sphinx-1.5 or earlier. LICENSE: CC BY https://creativecommons.org/licenses/by/3.0/deed
# -- directive/role definition ------------------------------------------------>
from docutils.parsers.rst.directives.admonitions import BaseAdmonition
from docutils import nodes
from sphinx.util.compat import make_admonition
class NamedNoteDirective(BaseAdmonition):
node_class = nodes.admonition
css_class = 'note'
from colander import MappingSchema, SchemaNode, String, Invalid
import string
def combined_validator(node, value):
if value.get('name') != value.get('value'):
raise Invalid(node, 'name and value must be identical. {!r}'.format(value))
class Schema1(MappingSchema):
@shimizukawa
shimizukawa / conf.py
Last active January 2, 2016 11:59
Sphinx extension to render local toctree in templates (ex. sidebar). see also: https://groups.google.com/d/msg/sphinx-users/d0dwJ4YiMhs/PjHqUVozriIJ
sys.path.insert(0, os.path.abspath('.'))
extensions = ['localtoc']
html_sidebars = {'somepage': ['localtoc.html']}
@shimizukawa
shimizukawa / config--deploy--vagranttest.rb
Last active December 27, 2015 03:29
capistrano-paratrooper-chef 0.3.0
role :'foo-monitor', 'test-monitor'
role :'foo-log', 'test-log1'
role :'foo-ap', 'test-ap1'
role :'foo-web', 'test-web1'
role :'foo-mysql', 'test-mysql1'
role :'foo-redis', 'test-redis1'
set :user, 'chef'
#!/usr/bin/env python
from docutils import nodes
from sphinx.util.compat import Directive, make_admonition
class writer(nodes.Admonition, nodes.Element):
pass
class writerlist(nodes.General, nodes.Element):
pass
@shimizukawa
shimizukawa / extractword.py
Last active June 6, 2023 02:59 — forked from yono/extractword.py
MeCabの出力結果を基に接頭辞や接尾辞を連結する。fork元のコードと機能は同じ。リファクタリングしました。
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import re
from collections import OrderedDict #python2.7 or later
import MeCab
class DetermineDescriptor(object):
@shimizukawa
shimizukawa / mysql_databases.rb
Last active December 18, 2015 00:29
chef + mysql + grant users to databases.
# Cookbook Name:: myrecipe
# Recipe:: mysql_databases
#
# Copyright 2013, Takayuki SHIMIZUKAWA
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@shimizukawa
shimizukawa / memcached.conf.erb
Last active December 18, 2015 00:29
Chef + CnetOS6 / RHEL6 + memcached + upstart
description "memcached"
start on runlevel [2345]
stop on runlevel [!2345]
#Send KILL after 5 seconds
respawn
respawn limit 5 60
env DAEMON=memcached
env PORT=11211
@shimizukawa
shimizukawa / conf.py
Created May 15, 2013 00:24
Sphinxで書籍作成向け、コラムディレクティブ。ついでにnoteディレクティブがタイトルを受け取れるように変更。columnディレクティブ自体はnoteと同じ実装だけど、columnノードが出来るのでbuilderで出力を変えたり、専用のcss名が付くのでcss追加したりで調整する。
# -- directive/role definition ------------------------------------------------>
from docutils.parsers.rst.directives.admonitions import BaseAdmonition
from docutils import nodes
from sphinx.util.compat import make_admonition
class NamedNoteDirective(BaseAdmonition):
node_class = nodes.admonition
#required_arguments = 1