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
@zhsj
zhsj / select-class.js
Created August 29, 2013 11:41
select the course whose id is 011X1902 in USTC automatically.
function myfun(tag,actionname,xnxq,kcid,kcbjbh,kclb,kcsx,sjpdm,kssjdm,cxck,zylx,gxkfl,xlh,qsz,jzz){
insertxkgc(xnxq,kcbjbh,kcid,kclb,kcsx,cxck,'01',gxkfl,xlh,sjpdm,kssjdm);
}
function myfun2(){
var xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET",location.href,false);
xmlhttp.send();
var x=xmlhttp.responseText.match("<font color=blue>40</font></a>");
if(x!=null){
@zhsj
zhsj / conky.service
Created June 23, 2015 09:49
Conky systemd user service
# ~/.config/systemd/user/conky.service
[Unit]
Description=Conky
[Service]
Type=simple
ExecStart=/usr/bin/conky
Environment=DISPLAY=:0
@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>
#!/bin/bash
# check deb repo consistency
# by SJ Zhu
test() {
release=$1
start=0
while read line; do
if [[ "$line" = "SHA1:" ]]; then
@zhsj
zhsj / ipinfo.sh
Last active November 5, 2017 12:07
#!/bin/bash
ips=()
while getopts "d:" opt; do
case $opt in
d)
t=$(dig "$OPTARG" +noadditional|awk '/A\t/ {print $5}')
ips+=(${t//$'\n'/ })
;;
esac
done
@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 $@ }
#!/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