Skip to content

Instantly share code, notes, and snippets.

@gwli
gwli / twiki.vim
Created March 26, 2019 03:31
vim translate twiki to rst
" process the link
"
echohl MatchParen | echo "process the link" | echohl None
%s/\[\[\(.\{-}\)]\[\(.\{-}\)]]/`\2 <\1>`_ /g
" process %IF{ ....}% MACRO afer the list
%s/%IF{.\{-}}%//g
echohl MatchParen | echo "process Headline" | echohl None
%s/+++\zs[^ ]/ &/
" process the Headline ---+++
@gwli
gwli / terminal_css.html
Created March 22, 2019 10:55
css linux terminal
<html>
<body>
</body>
<style>
body {
background-color: black;
background-image: radial-gradient(
rgba(0, 150, 0, 0.75), black 120%
);
height: 100vh;
@gwli
gwli / retry_call.py
Created December 12, 2018 04:56
simple retry call in python
def retry_call(func,*args):
while True:
try:
return func(*args)
except(OSError,IOError) as e:
if e.errno = errno.EINTR:
continue
raise
@gwli
gwli / fork_in_python.py
Created December 12, 2018 04:52
fork in python
func= execve |execve
pid = fork()
if not pid:
try:
if env is None:
func(file,args)
func(file,args,env)
except:
_exit(127)
@gwli
gwli / cpforDedaoMp3.sh
Last active December 9, 2018 13:12
cpforDedaoMp3.sh
mkdir mp3
oIFS=$IFS
IFS=$'\n'
find -type f -iname "*.mp3" | while read -r i; do
mv "$i" mp3/
done
@gwli
gwli / Makefile
Created December 2, 2018 08:40 — forked from lmullen/Makefile
PDF slides and handouts using Pandoc and Beamer
SLIDES := $(patsubst %.md,%.md.slides.pdf,$(wildcard *.md))
HANDOUTS := $(patsubst %.md,%.md.handout.pdf,$(wildcard *.md))
all : $(SLIDES) $(HANDOUTS)
%.md.slides.pdf : %.md
pandoc $^ -t beamer --slide-level 2 -o $@
%.md.handout.pdf : %.md
pandoc $^ -t beamer --slide-level 2 -V handout -o $@
@gwli
gwli / gdb.setup
Created July 19, 2017 02:39
gdb.setup set substitute-path
set substitute-path /srv/blackbird D:/tmp/blackbird
@gwli
gwli / backupQQ.sh
Created July 9, 2017 07:46
backup mysql to rst and send mail
cmd="select content,group_name,nickname from chat_logs where date(create_time) = curdate() order by group_number,qq;"
datafile="im_`date +%Y_%m_%d`.rst"
#mysql -N -B --default-character-set=utf8 -u root -pdevtoolsqa -DIM -e "$cmd" >$datafile
mysql -N --default-character-set=utf8 -u root -pdevtoolsqa -DIM -e "$cmd" >$datafile
pandoc $datafile -t html| mutt -e "set content_type=text/html" -s "$datafile" xxxx@xx
@gwli
gwli / chat_log.sql
Created July 9, 2017 07:45
mysql trigger example
CREATE TABLE `chat_logs` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`content` varchar(255) DEFAULT NULL COMMENT '聊天内容',
`group_number` varchar(255) DEFAULT NULL,
`group_name` varchar(255) DEFAULT NULL,
`qq` varchar(255) DEFAULT NULL,
`nickname` varchar(255) DEFAULT NULL,
`mark` varchar(255) DEFAULT NULL,
PRIMARY KEY (`Id`)
@gwli
gwli / backupQQ.sh
Created July 9, 2017 07:44
backup mysql to rst and send mail
cmd="select content,group_name,nickname from chat_logs where date(create_time) = curdate() order by group_number,qq;"
datafile="im_`date +%Y_%m_%d`.rst"
#mysql -N -B --default-character-set=utf8 -u root -pdevtoolsqa -DIM -e "$cmd" >$datafile
mysql -N --default-character-set=utf8 -u root -pdevtoolsqa -DIM -e "$cmd" >$datafile
pandoc $datafile -t html mutt -e "set content_type=text/html" -s "$datafile" XXX@XXx