Skip to content

Instantly share code, notes, and snippets.

# 日本語を使用
export LANG=ja_JP.UTF-8
# パスを追加したい場合
export PATH="$HOME/bin:$PATH"
# 色を使用
autoload -Uz colors
colors
@ujun
ujun / blk_read_pgsql.py
Last active December 16, 2018 14:49
bpf script for block read into shared_buffer
#!/usr/bin/python
from bcc import BPF, USDT
import argparse
import re
import ctypes as ct
import subprocess
examples = """examples:
blk_read_pgsql -p 188 # trace specific PostgreSQL processes
@ujun
ujun / .vimrc
Last active August 20, 2018 08:46
.vimrc
colorscheme hybrid
let mapleader = ","
set completeopt-=preview
call plug#begin('~/.vim/plugged')
if has('nvim')
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
hubs = Userdata.new("hubs").hubs
r = Apache::Request.new()
if hubs.keys.include?(r.uri[1,r.uri.size-1]) then
Apache.rputs(r.uri)
r.handler = "proxy-server"
r.proxyreq = Apache::PROXYREQ_REVERSE
r.filename = "proxy:" + hubs[r.uri]
end
~
module Rack
class WebAPI
include Rack::R3
def call(env)
super({'REQUEST_METHOD' => env["REQUEST_METHOD"], 'PATH_INFO' => env["PATH_INFO"]})
end
def run
engine = if Object.const_defined?(:Nginx)
'nginx'
@ujun
ujun / mruby.conf
Last active October 25, 2015 06:10
<IfModule mod_mruby.c>
mrubyChildInitMiddle /etc/apache2/init.rb
<Location /api>
mrubyTranslateNameMiddle /etc/apache2/proxy.rb
mrubyHandlerMiddle /etc/apache2/requesthub.rb
</Location>
<Location /hub>
mrubyTranslateNameMiddle /etc/apache2/proxy.rb
mrubyHandlerMiddle /etc/apache2/requesthub.rb
</Location>
Userdata.new("req_#{Process.pid}").hubs = Hash.new()
@ujun
ujun / mruby.conf
Last active October 13, 2015 14:17
<IfModule mod_mruby.c>
<Location />
mrubyHandlerMiddle /etc/apache2/webapi.rb
</Location>
</IfModule>
class MyAPI < Rack::WebAPI
get "/hoge/{id}" do |id|
[
200,
{'content-type' => 'text/plain; charset=utf-8'},
["your id is #{id}"]
];
end
<IfModule mod_mruby.c>
<Location />
mrubyHandlerMiddleCode ' \
r = Apache::Request.new ;\
client = Norikra::Client.new("192.168.99.100", "26571") ;\
client.send("access_log", [:time => Time.new.to_s, :method => r.method, :uri => r.uri]) '
</Location>
</IfModule>