Skip to content

Instantly share code, notes, and snippets.

View RustingSword's full-sized avatar
🤦‍♂️

RustingSword

🤦‍♂️
View GitHub Profile
@RustingSword
RustingSword / inotifywait.md
Last active February 24, 2017 12:37
use inotify in a for loop

Initially, I tried to run inotifywait in monitor mode, like this:

for i in $(seq 1 3)
do
    echo "stage $i"
    train_model &
    pid=$!
    inotifywait -mq -e close_write --format '%f' $MODEL_SAVE_PATH | while read FILE
    do
 echo "[`date "+%F %T"`] new model: $FILE"
@RustingSword
RustingSword / get_date_diff.sh
Last active November 4, 2016 05:37
计算日期
DATE=08/16/2015
DIFF=$(( ( $(date +%s) - $(date -d "$DATE" +%s ) ) / (24*60*60) ))
echo $DIFF
echo $(date -d "$DIFF days ago" +%Y%m%d)
# -----------------------
FIRST_DAY=20161023
LAST_DAY=20161103
@RustingSword
RustingSword / restore_doumail.js
Last active August 29, 2015 14:21
将“私信”恢复成“豆邮”
// ==UserScript==
// @name 驱逐私信,恢复豆邮
// @namespace http://fanfou.com/lzgxd
// @description 将“私信”恢复成“豆邮”
// @include http://*.douban.com/*
// @version 0.1
// @grant none
// ==/UserScript==
// via http://stackoverflow.com/a/1512889
@RustingSword
RustingSword / pm-template.latex
Created February 26, 2015 14:36
chinese template for generating pdf file using pandoc
\documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$lang$,$endif$$if(papersize)$$papersize$,$endif$]{$documentclass$}
\usepackage{geometry} % 設定邊界
\geometry{
top=1in,
inner=1in,
outer=1in,
bottom=1in,
headheight=3ex,
headsep=2ex
}
@RustingSword
RustingSword / .vimperatorrc
Created January 5, 2015 08:23
vimperatorrc + zotero
"3.8.2 (created: 2014/02/13 23:52:43)
map <C-c> :stop<Return>
map <lt> <C-6>
map p <C-z>
map v <C-v>
map <C-s> :stop<Return>
nmap <F5> :set<Space>gui=navigation<Return>
nmap <C-F5> :set<Space>gui=nonavigation<Return>
noremap j 5j
IE 6 and 7: 2
IE 8: 6
IE 9: 6
IE 10: 8
IE 11: 8
Firefox 2: 2
Firefox 3: 6
Firefox 4 to 17: 6
Opera 9.63: 4
Opera 10: 8
@RustingSword
RustingSword / fitPlane.py
Created September 7, 2014 12:33
least square plane fitting of 3d points
import numpy as np
import scipy.optimize
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.gca(projection='3d')
def fitPlaneLTSQ(XYZ):
#!/usr/bin/python
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
import sys
#plt.rc('text', usetex=True)
#plt.rc('font', **{'family':'monospace','monospace':['Ubuntu Mono'], 'size':16})
#mpl.rcParams['legend.fontsize'] = 10
@RustingSword
RustingSword / dtw.c
Created August 6, 2014 06:31
constrained dtw
typedef struct point{
double x;
double y;
} point;
double get_distance(const point a, const point b)
{
double xdiff = a.x - b.x;
double ydiff = a.y - b.y;
return xdiff*xdiff + ydiff*ydiff;