Skip to content

Instantly share code, notes, and snippets.

View genki's full-sized avatar

Genki Takiuchi genki

View GitHub Profile
@genki
genki / grn check
Created July 25, 2017 08:43
Groonga DBでトラブル。どのobjectなんだろ。情報足りない...
# grndb check /data/groonga/production
[query_log_flags_get] Can't open object. It's broken. Re-create the object or the database.
[query_log_flags_set] Can't open object. It's broken. Re-create the object or the database.
[query_log_flags_add] Can't open object. It's broken. Re-create the object or the database.
[query_log_flags_remove] Can't open object. It's broken. Re-create the object or the database.
@genki
genki / d
Created February 20, 2017 12:32
#!/bin/sh
while [ "`echo $1 | cut -c1`" = "-" ]; do
OPT="$OPT $1"
shift
done
IMG_TAG=`echo $1 | awk -F\@ '{print $1}'`
CMD=`echo $1 | awk -F\@ '{print $2}'`
IMG=`echo $IMG_TAG | awk -F: '{print $1}'`
TAG=`echo $IMG_TAG | awk -F: '{print $2}'`
if [ -z "$CMD" ]; then
@genki
genki / log.go
Last active February 7, 2017 04:29
Simple golang logger that has 2 different log levels for stdout and stderr.
package main
import (
"fmt"
"os"
"sync"
)
type LogLevel int
#0 __lll_lock_wait_private ()
at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
#1 0x00007f07b472e67a in __GI___libc_malloc (bytes=139671072336672)
at malloc.c:2909
#2 0x00007f07b4f10567 in ?? () from target:/lib64/ld-linux-x86-64.so.2
#3 0x00007f07b4f17412 in ?? () from target:/lib64/ld-linux-x86-64.so.2
#4 0x00007f07b4f12394 in ?? () from target:/lib64/ld-linux-x86-64.so.2
#5 0x00007f07b4f16bd9 in ?? () from target:/lib64/ld-linux-x86-64.so.2
#6 0x00007f07b47ed9bd in do_dlopen (ptr=0x161f640) at dl-libc.c:87
#7 0x00007f07b4f12394 in ?? () from target:/lib64/ld-linux-x86-64.so.2
@genki
genki / gist:3599a506ff605d6e1a037fb098eb0cee
Created February 1, 2017 19:44
なんか最近ruby2.3/glibc周りのクラッシュ増えた気が
*** Error in `ruby2.3': free(): invalid pointer: 0x000000000415b9f0 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7fe58e2da7e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x7fe0a)[0x7fe58e2e2e0a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7fe58e2e698c]
/usr/lib/x86_64-linux-gnu/libruby-2.3.so.2.3(+0x8fcfd)[0x7fe58e6bbcfd]
@genki
genki / gist:7c812037ccc18f20bd0b91570a61276a
Created January 29, 2017 10:03
Example result from pidstat -p <PID>
07:02:22 PM UID PID %usr %system %guest %CPU CPU Command
07:02:23 PM 0 21803 25.00 7.00 0.00 32.00 2 ruby2.3
07:02:24 PM 0 21803 12.00 1.00 0.00 13.00 3 ruby2.3
07:02:25 PM 0 21803 32.00 11.00 0.00 43.00 0 ruby2.3
07:02:26 PM 0 21803 15.00 8.00 0.00 23.00 3 ruby2.3
07:02:27 PM 0 21803 18.00 6.00 0.00 24.00 2 ruby2.3
07:02:28 PM 0 21803 23.00 6.00 0.00 29.00 0 ruby2.3
07:02:29 PM 0 21803 16.00 5.00 0.00 21.00 3 ruby2.3
@genki
genki / tmux_even_pane
Last active January 20, 2017 00:48
Ruby script to balance only siblings of the current pane
#!/usr/bin/env ruby
class Parser
def initialize(input)
@input = input
@s = 0
end
def parse
csum = scan_csum; pick
@genki
genki / tmux_layout_parser.rb
Last active January 19, 2017 22:10
Parser for tmux's layout string (tmux display -p "#{window_visible_layout}")
class Parser
def initialize(input)
@input = input
@s = 0
end
def parse
wid = scan_wid
pick
w, h = scan_wh; pick
The following variables are available, where appropriate:
.Bl -column "XXXXXXXXXXXXXXXXXXX" "XXXXX"
.It Sy "Variable name" Ta Sy "Alias" Ta Sy "Replaced with"
.It Li "alternate_on" Ta "" Ta "If pane is in alternate screen"
.It Li "alternate_saved_x" Ta "" Ta "Saved cursor X in alternate screen"
.It Li "alternate_saved_y" Ta "" Ta "Saved cursor Y in alternate screen"
.It Li "buffer_name" Ta "" Ta "Name of buffer"
.It Li "buffer_sample" Ta "" Ta "Sample of start of buffer"
.It Li "buffer_size" Ta "" Ta "Size of the specified buffer in bytes"
.It Li "client_activity" Ta "" Ta "Integer time client last had activity"
(on_segv+0x7c)[0x402786]
/lib/x86_64-linux-gnu/libc.so.6(+0x36d40)[0x7f8911526d40]
/lib/x86_64-linux-gnu/libc.so.6(_IO_vfprintf+0x1d13)[0x7f891153ba03]
/lib/x86_64-linux-gnu/libc.so.6(__vsnprintf_chk+0x95)[0x7f89115f9235]
/usr/lib/x86_64-linux-gnu/libgroonga.so.0(grn_logger_put+0x173)[0x7f8911c491a3]
/usr/lib/x86_64-linux-gnu/libgroonga.so.0(grn_io_seg_map_+0xa19)[0x7f8911c44c79]
/usr/lib/x86_64-linux-gnu/libgroonga.so.0(grn_io_segment_alloc+0x6d4)[0x7f8911c45ec4]
/usr/lib/x86_64-linux-gnu/libgroonga.so.0(grn_hash_get+0x363)[0x7f8911bfbc53]
/usr/lib/x86_64-linux-gnu/libgroonga.so.0(grn_table_get+0xf0)[0x7f8911b22ed0]