Skip to content

Instantly share code, notes, and snippets.

View yteraoka's full-sized avatar

Yoshinori Teraoka yteraoka

View GitHub Profile
@yteraoka
yteraoka / in_tailasis.rb
Last active December 12, 2015 02:09
fluent-agent-lite のように正規表現なしで行をそのまま一つのキーに突っ込んで取り込む fluentd plugin
module Fluent
class AsisTailInput < TailInput
Plugin.register_input('tailasis', self)
def initialize
super
@parser = nil
end
@yteraoka
yteraoka / out_dbi.rb
Last active December 13, 2015 20:08
DBI を使って PostgreSQL でも MySQL にでも出力できる Fluentd Output Plugin https://github.com/yteraoka/fluent-plugin-dbi
# <match dbi.test>
# type dbi
# #dsn DBI:Pg:dbname:127.0.0.1
# dsn DBI:Mysql:dbname:127.0.0.1
# db_user username
# db_pass password
# keys host,time_m,method,uri,protocol,status
# query insert into access_log (host, time, method, uri, protocol, status) values (?, ?, ?, ?, ?, ?)
# </match>
@yteraoka
yteraoka / mod_headers-toenv.patch
Created March 6, 2013 10:27
特定の Response Header の値を環境変数にコピーして Header を削除する機能を mod_headers に追加する patch for Apache 2.4.4
diff -uNr httpd-2.4.4.orig/modules/metadata/mod_headers.c httpd-2.4.4/modules/metadata/mod_headers.c
--- httpd-2.4.4.orig/modules/metadata/mod_headers.c 2012-12-09 22:20:13.000000000 +0900
+++ httpd-2.4.4/modules/metadata/mod_headers.c 2013-02-27 19:37:08.466361782 +0900
@@ -96,7 +96,8 @@
hdr_unset = 'u', /* unset header */
hdr_echo = 'e', /* echo headers from request to response */
hdr_edit = 'r', /* change value by regexp, match once */
- hdr_edit_r = 'R' /* change value by regexp, everymatch */
+ hdr_edit_r = 'R', /* change value by regexp, everymatch */
+ hdr_toenv = 'E' /* copy to subprocess_env and unset */
@yteraoka
yteraoka / puki2doku.pl
Last active December 16, 2015 05:09
PukiWiki から DokuWIki への移行スクリプト (ファイルの埋め込みは未対応) 汚いけど使い捨てだし動けばいいから。 https://github.com/yteraoka/puki2doku に移しました。
puki2doku.pl has moved to https://github.com/yteraoka/puki2doku
@yteraoka
yteraoka / cronolog-symlink.patch
Created May 21, 2013 11:13
EPEL の cronolog に取り込まれていなかった symlink patch
@yteraoka
yteraoka / register_read_type_line.pl
Created May 22, 2013 13:09
CR (Carriage Return) で Cinnamon が期待通りに動作しない件
register_read_type line => sub {
my ($self, $cb, $eol) = @_;
if (@_ < 3) {
# this is more than twice as fast as the generic code below
sub {
$_[0]{rbuf} =~ s/^([^\015\012]*)(\015?\012)// or return;
$cb->($_[0], "$1", "$2");
1
@yteraoka
yteraoka / jpaddr.pl
Last active December 19, 2015 22:29
APNIC の IP Address リストから日本に割り当てられている CIDR のリストを抽出する
#!/usr/bin/perl
#
# http://ftp.apnic.net/stats/apnic/delegated-apnic-latest
#
#
use strict;
use warnings;
print "#" x 78 ."\n";
print "# \$Id\$\n";
@yteraoka
yteraoka / file0.txt
Created August 5, 2013 14:44
標準入力から Bash script を実行する場合に引数を渡す方法 ref: http://qiita.com/yteraoka/items/b592dc147f233564dc24
$ echo 'echo $1; echo $2' | bash hoge fuga
bash: hoge: No such file or directory
@yteraoka
yteraoka / mysqld_spec.rb
Created August 5, 2013 15:22
Ansible Tutorial の ServerSpec 設定例 (mysqld のチェック)
require 'spec_helper'
describe package('mysql-server') do
it { should be_installed }
end
describe service('mysqld') do
it { should be_enabled }
it { should be_running }
end
@yteraoka
yteraoka / wordpress_spec.rb
Last active December 20, 2015 19:49
Ansible Tutorial の ServerSpec 設定例 (WordPress のチェック)
# coding: ascii-8bit
require 'spec_helper'
describe command('/usr/bin/curl -s http://localhost/wp-admin/install.php') do
it { should return_stdout /5分でできる WordPress の有名なインストールプロセスへようこそ/ }
end