Skip to content

Instantly share code, notes, and snippets.

@zhsj
zhsj / C.sublime-build
Last active December 17, 2015 21:49
to build and run C program in sublime text 2 and use xterm instead of its own console so that user can input in the program.
//C.sublime-build
//A sublime build system configuration file for C.
//Run C program in xterm
{
"cmd": ["gcc", "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c",
"variants":
@zhsj
zhsj / rename_mp3.sh
Created August 3, 2013 04:07
rename mp3 file
for i in *.mp3;do
a=`mid3v2 -l "$i" |grep "^TIT2"`
b=`mid3v2 -l "$i" |grep "^TPE1"`
if [ ! -z "$a" ] && [ ! -z "$b" ]; then
c=`echo $a|awk -F "=" '{print $2}'`
d=`echo $b|awk -F "=" '{print $2}'`
mv "$i" "$d - $c.mp3"
echo "$i mv to $d - $c.mp3"
fi
done
#!/bin/bash
# check deb repo consistency
# by SJ Zhu
test() {
release=$1
start=0
while read line; do
if [[ "$line" = "SHA1:" ]]; then
#!/bin/bash
# check deb repo consistency
# by SJ Zhu
set -e
test() {
release=$1
start=0
@zhsj
zhsj / vimrc
Created May 25, 2016 08:35
vimrc
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
@zhsj
zhsj / iptables-handle.c
Last active September 26, 2016 04:04
gmond module - port traffic
/**
* @author SJ Zhu
* @license GPL-3.0
* @date 2015-11-19
*/
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <stdio.h>
@zhsj
zhsj / kern.log
Created September 26, 2016 18:10
Sep 26 22:16:05 mirrors kernel: [81670.133508] INFO: task kswapd0:103 blocked for more than 120 seconds.
Sep 26 22:16:05 mirrors kernel: [81670.133530] Tainted: G C 3.16.36-ustclugsigned+deb8u1 #1
Sep 26 22:16:05 mirrors kernel: [81670.133544] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
Sep 26 22:16:05 mirrors kernel: [81670.133560] kswapd0 D 0000000000000000 0 103 2 0x00000000
Sep 26 22:16:05 mirrors kernel: [81670.133563] ffff880233cc15b0 0000000000000046 0000000000013400 ffff880233cc7fd8
Sep 26 22:16:05 mirrors kernel: [81670.133565] 0000000000013400 ffff880233cc15b0 ffff880233cc15b0 ffff880233cc7810
Sep 26 22:16:05 mirrors kernel: [81670.133567] ffff880234190ae8 ffff880234190b00 ffff880234190000 ffff8800142dc058
Sep 26 22:16:05 mirrors kernel: [81670.133570] Call Trace:
Sep 26 22:16:05 mirrors kernel: [81670.133580] [<ffffffff81530a35>] ? rwsem_down_read_failed+0xf5/0x140
Sep 26 22:16:05 mirrors kernel: [81670.133586] [<ffffffff811aa92
@zhsj
zhsj / venv.elv
Last active October 11, 2016 15:48
_old_virtual_rprompt=$le:rprompt
fn detect_venv [path]{
p=[$path/.*/bin/activate $path/*/bin/activate]
if == 0 (count $p); then
fail "Can't find a virtual env in "$path
fi
put (path-abs (path-dir $p[0])/../)
}
@zhsj
zhsj / rc.elv
Last active October 11, 2016 15:49
Oh My Elvish~
# alias
fn ... { cd ../.. }
fn .... { cd ../../.. }
fn ls { e:ls --color=auto $@ }
fn l { ls -alh $@ }
fn grep { e:grep --color $@ }
fn mtr { e:mtr --curses $@ }
fn gst { git status $@ }
fn gc { git commit -v $@ }
fn gca { git commit -v -a $@ }
@zhsj
zhsj / app.js
Created December 4, 2016 16:18
vue-learn
Vue.component('post-list', {
template: `
<div>{{ posts }} </div>
<div class="post" v-for="post in posts" :key="post.date">
<h2>{{ post.name }}</h2>
<div class="info">Date: {{ post.date }}</div>
</div>
`,
data: function() {
return {