Skip to content

Instantly share code, notes, and snippets.

@hydra35
hydra35 / pathlookup.sh
Created January 7, 2012 04:17
archlinux's basedir aware `which`
pathlookup() {
# a basedir aware 'type -P' (or which) for executables
# $1: binary to find
local path=
local -a paths=
IFS=: read -r -a paths <<< "$PATH"
for path in "${paths[@]}"; do
@hydra35
hydra35 / auto_modules.sh
Created January 7, 2012 04:40
archlinux's modules detection through sysfs
auto_modules() {
# Perform auto detection of modules via sysfs.
local mods=
IFS=$'\n' read -rd '' -a mods < \
<(find /sys/devices -name modalias -exec sort -u {} + |
# delimit each input by a newline, expanded in place
xargs -d $'\n' modprobe -d "$BASEDIR" -aRS "$KERNELVERSION" |
sort -u)
@hydra35
hydra35 / .vimrc
Created January 18, 2012 17:24
vimrc for C programming
set nocompatible
set autoindent
set smartindent
set cindent
set tabstop=4
set shiftwidth=4
set expandtab
set cinoptions=(0,:0,l1,t0
filetype plugin indent on
au FileType make setlocal noexpandtab
@hydra35
hydra35 / wstat.lua
Created January 20, 2012 10:46
retrieve wireless status from OpenWRT then send to tsdb
function main(cmd)
local f = assert(io.popen(cmd, 'r'))
--local f = assert(io.open('a', 'r'))
local cur_station = ''
local result = {}
for line in f:lines() do
fst_char = string.sub(line, 0, 1)
if fst_char == "S" then
@hydra35
hydra35 / batch-strace.sh
Created February 23, 2012 14:31
strace all the php-fpm worker processes
#!/bin/bash
additional_strace_args="$1"
MASTER_PID=$(ps auwx | grep php-fpm | grep -v grep | grep 'master process' | cut -d ' ' -f 6)
while read -r pid;
do
if [[ $pid != $MASTER_PID ]]; then
nohup strace -r -p "$pid" $additional_strace_args >"$pid.trc" 2>&1 &
@hydra35
hydra35 / fqiang.sh
Created February 26, 2012 14:30
Do we successfully climb GFW
(( $(curl -I facebook.com 2>/dev/null | grep -c X-FB-Debug) )) && echo 'succeed' || echo 'failed'
@hydra35
hydra35 / .vimrc
Created May 2, 2012 08:22
vimrc: set by file suffix
syntax on
set tag=~/tags
autocmd! BufNewFile,BufReadPre,FileReadPre *.rb set nu et ts=2 sw=2
autocmd! BufNewFile,BufReadPre,FileReadPre *.coffee so ~/.vim/ftplugin/coffee.vim
@hydra35
hydra35 / run_fio.sh
Created June 27, 2012 10:00
fio testing script
#!/bin/bash
[[ $# -lt 2 ]] && exit 1
DEV="$1"
OUTDIR="$2"
[[ -d $OUTDIR ]] || mkdir -p $OUTDIR
BLOCK_SIZES="512 4K 8K 256K"
@hydra35
hydra35 / run_dd.sh
Created June 28, 2012 06:55
dd testing script
#!/bin/bash
if [ $# -lt 2 ]; then
echo "usage:$0 dev output_dir"
exit 1
fi
DEV="$1"
OUTDIR="$2"
DATASIZE="500" # in MB
@hydra35
hydra35 / omreport.md
Created July 19, 2012 03:51
Dell Open Manage(OM) usage

安装Open Manage

omreport -?

用途:列出帮助

omreport storage controller

用途:查Raid controller model, cache memory size等