Skip to content

Instantly share code, notes, and snippets.

@komeda-shinji
komeda-shinji / twill.encoding.patch
Created January 30, 2015 09:46
twillでの文字エンコーディングを改善する
--- commands.py 2007-12-28 15:45:16.000000000 +0900
+++ commands.py 2013-02-05 22:22:42.000000000 +0900
@@ -231,8 +231,8 @@
For explanations of these, please see the Python re module
documentation.
"""
- regexp = re.compile(what, _parseFindFlags(flags))
- page = browser.get_html()
+ regexp = re.compile(unicode(what), _parseFindFlags(flags))
+ page = browser.get_html().decode(browser._browser.encoding(), 'ignore')
@komeda-shinji
komeda-shinji / extend_encoding.py
Created January 30, 2015 09:50
twill: HTTP のレスポンスヘッダーでエンコーディングが示されていないとき、エンコーディングを強制する拡張モジュール
"""
Extension functions for manipulating the browser charset encoding.
Commands:
getbrowserencoding -- get encoding from meta tag, and set it to browser.
setbrowserencoding <encoding> -- set browser encoding as <encoding>.
"""
import re
@komeda-shinji
komeda-shinji / file0.txt
Created February 13, 2015 12:27
corkscrewをSSLなプロキシに対応させた ref: http://qiita.com/komeda-shinji/items/8a78f07cc7d0d75d37c0
usage: corkscrew [-ssl] <proxyhost> <proxyport> <desthost> <destport> [authfile]
@komeda-shinji
komeda-shinji / file0.diff
Last active August 29, 2015 14:15
ReTextを使ってreStructuredTextで書いたときタイトルとサブタイトルが入らない ref: http://qiita.com/komeda-shinji/items/254442e911f507c65f97
diff -u wpgen/wpgen.py wpgen/wpgen.py
--- wpgen/wpgen.py 2012-04-22 23:52:07.000000000 +0900
+++ wpgen/wpgen.py 2012-04-27 22:00:58.000000000 +0900
@@ -108,7 +109,8 @@
pass
elif ext in (".rst", ".rest") and use_docutils:
parts = publish_parts(text, writer_name='html')
- html = parts['body']
+ #html = parts['body']
+ html = parts['html_body']
@komeda-shinji
komeda-shinji / file0.txt
Created February 28, 2015 13:55
Ansibleで設定ファイルの行を書き換える ref: http://qiita.com/komeda-shinji/items/fafc46e27e0619cade14
- hosts: servers
vars:
httpd_conf: /etc/apache2/apache2.conf
tasks:
- name: grep %{Session}C
command: grep '^LogFormat[[:space:]].*%{Session}C.*[[:space:]]combined' {{httpd_conf}}
register: grep
ignore_errors: True
failed_when: False
changed_when: False
@komeda-shinji
komeda-shinji / rrdcached.init
Created March 2, 2015 06:55
rrdcached.init
#! /bin/bash
#
# rrdcached - start and stop the RRDtool data caching daemon
# http://oss.oetiker.ch/rrdtool/
#
# Based on the collectd init script.
#
# Copyright (C) 2005-2006 Florian Forster <[email protected]>
# Copyright (C) 2006-2009 Sebastian Harl <[email protected]>
#
@komeda-shinji
komeda-shinji / file0.txt
Created March 5, 2015 12:04
Ansibleで設定ファイルの行を書き換える(コンテキスト編) ref: http://qiita.com/komeda-shinji/items/e24fab2ab0f2f5858111
- hosts: servers
vars:
httpd_conf: /etc/apache2/apache2.conf
tasks:
- name: lookup DocumentRoot in VirtualHost
shell: sed -n '/^<VirtualHost \*:80>/,/<\/VirtualHost>/{/DocumentRoot/p; }' {{httpd_conf}}
register: lookup
changed_when: False
- name: change httpd.conf
shell: sed -i$(date +'.%Y-%m-%d@%H:%M~') '/^<VirtualHost \*:80>/,/<\/VirtualHost>/{s/\(DocumentRoot[[:space:]]*\).*$/\1\/var\/www/; }' {{httpd_conf}}
@komeda-shinji
komeda-shinji / gist:764f7c1098e9a158fb65
Created March 10, 2015 13:55
observium config.php
--- config.php.default 2014-11-05 01:14:27.000000000 +0900
+++ config.php 2015-03-03 18:53:06.083227191 +0900
@@ -21,9 +21,40 @@
#$config['poller-wrapper']['alerter'] = TRUE;
// Set up a default alerter (email to a single address)
-$config['alerts']['alerter']['default']['descr'] = "Default Email Alert";
-$config['alerts']['alerter']['default']['type'] = "email";
-$config['alerts']['alerter']['default']['contact'] = "[email protected]";
-$config['alerts']['alerter']['default']['enable'] = TRUE;
@komeda-shinji
komeda-shinji / nagios-plugin-wrapper
Created March 12, 2015 12:18
Zabbixの外部チェックアイテムでNagiosのプラグインを利用すラッパー
#!/bin/sh
ZABBIX_SENDER=/usr/bin/zabbix_sender
ZABBIX_SERVER=localhost
HOSTNAME="$1"; shift
PLUGIN="$1"; shift
CHECK_PLUGIN=/usr/lib/nagios/plugins/"$PLUGIN"
output=$("$CHECK_PLUGIN" "$@" 2>/dev/null)
status=$?
{
for perf in ${output##*|}; do
@komeda-shinji
komeda-shinji / CLineGraphDraw.php
Last active August 29, 2015 14:18
Zabbixのグラデーションラインは値域が負の時のことを考えていない ref: http://qiita.com/komeda-shinji/items/0591f495cda8ff1c9c09
--- CLineGraphDraw.php 2014-12-16 15:38:26.000000000 +0900
+++ CLineGraphDraw.php 2015-04-03 22:04:19.736847627 +0900
@@ -2245,6 +2245,10 @@
}
break;
case GRAPH_ITEM_DRAWTYPE_GRADIENT_LINE:
+ if ($y1 == $y2 && $y1 == $zero)
+ {
+ break;
+ }