Skip to content

Instantly share code, notes, and snippets.

View hiboma's full-sized avatar

Hiroya Ito hiboma

View GitHub Profile
@hiboma
hiboma / colorize.pl
Created July 5, 2012 03:26 — forked from Cside/colorize.pl
colorize keywords of logs.
#!/usr/bin/env perl
=head1 Examples
$ tail -f access_log | perl colorize.pl
$ plackup app.psgi 2>&1 | perl colorize.pl
=cut
use strict;
@hiboma
hiboma / gist:3038295
Created July 3, 2012 07:38
cgroup OOM
Jul  3 16:26:47 users999 kernel: Memory cgroup out of memory: Kill process 1822 (perl) score 1000 or sacrifice child
Jul  3 16:26:47 users999 kernel: Killed process 1822, UID 0, (perl) total-vm:153088kB, anon-rss:32596kB, file-rss:52kB
Jul  3 16:27:24 users999 kernel: perl invoked oom-killer: gfp_mask=0xd0, order=0, oom_adj=0, oom_score_adj=0
Jul  3 16:27:24 users999 kernel: perl cpuset=ruby-namahage-1 mems_allowed=0
Jul  3 16:27:24 users999 kernel: Pid: 1837, comm: perl Not tainted 2.6.32-220.13.1.el6.x86_64 #1
Jul  3 16:27:24 users999 kernel: Call Trace:
Jul  3 16:27:24 users999 kernel: [<ffffffff810c2e21>] ? cpuset_print_task_mems_allowed+0x91/0xb0
Jul  3 16:27:24 users999 kernel: [<ffffffff81113b80>] ? dump_header+0x90/0x1b0
@hiboma
hiboma / gist:3033226
Created July 2, 2012 13:19
hello-world.S - nasm on mac osx snow leopard
;;; nasm -f macho mac-nasm.S -o hoge
;;; gcc -Wall -Werror -m32 -mmacosx -version-min=10.6 -o hello hoge
;;; gcc -Wall -Werror -arch i386 -mmacosx -version-min=10.6 -o hello hoge

section .data
msg:        db "hello,world", 10
len:        equ $-msg
@hiboma
hiboma / gist:2996791
Created June 26, 2012 16:14
An Apache module to measure && log the time taken by Apache handlers
/*
** mod_mod_handler_time.c -- Apache sample mod_handler_time module
** [Autogenerated via ``apxs -n mod_handler_time -g'']
**
** To play with this sample module first compile it into a
** DSO file and install it into Apache's modules directory
** by running:
**
** $ apxs -c -i mod_mod_handler_time.c
**
@hiboma
hiboma / quota.c
Created June 24, 2012 13:54
quotactl(2) to get xfs project quota
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/quota.h>
#include <xfs/xfs.h>
#include <xfs/xqm.h>
int main(int argc, const char *argv[]) {
fs_disk_quota_t d;
@hiboma
hiboma / gist:2960430
Created June 20, 2012 15:18
make tpe-lkm on CentOS4
$ make
make -C /usr/src/kernels/2.6.9-103.EL-x86_64 M=/home/hiroya/tpe-lkm modules
make[1]: Entering directory `/usr/src/kernels/2.6.9-103.EL-x86_64'
  CC [M]  /home/hiroya/tpe-lkm/core.o
In file included from /home/hiroya/tpe-lkm/core.c:2:
/home/hiroya/tpe-lkm/module.h:59: error: syntax error before "bool"
/home/hiroya/tpe-lkm/module.h:59: warning: no semicolon at end of struct or union
/home/hiroya/tpe-lkm/module.h:63: error: syntax error before "found"
@hiboma
hiboma / sinatra.rb
Created June 18, 2012 16:12
sinatra - return requested port (SERVER_PORT)
#!/usr/bin/env ruby
require 'sinatra'
get '/' do
sprintf "%d\n", request.port
end
@hiboma
hiboma / gist:2944846
Created June 17, 2012 15:26
lua-nginx-module memo -- variable scope

@{スコープ}

  • ngx.shared.*

  • @複数プロセス

  • すべてのリクエストで共有

  • ワーカー同士で共有可能

  • memcached に似た expire 付きの CRUD で扱う。文字列、数値のみ

  • _G.*

  • @1プロセス

@hiboma
hiboma / reverse_proxy_module.c
Created June 17, 2012 13:17
how to use mod_proxy's "proxy-server" handler in your custom Apache module
#include "httpd.h"
#include "http_config.h"
#include "http_protocol.h"
#include "ap_config.h"
#include "apr_strings.h"
#include "http_request.h"
static int reverse_proxy_handler(request_rec *r)
{
@hiboma
hiboma / nginx.conf
Created June 14, 2012 16:24
lua-nginx-module -- Use http variables as shared vars across requests
server {
listen 1919;
server_name _;
location / {
error_page 500 @fallback;
set $stash "";
content_by_lua '