Skip to content

Instantly share code, notes, and snippets.

View shiruilu's full-sized avatar

Shirui Lu shiruilu

View GitHub Profile
@shiruilu
shiruilu / time_it.sh
Created August 4, 2015 03:21
timing my program
#!/bin/bash
STAT=$1
OPT=""
if [ $# -eq 3 ]
then
echo "also arguments"
OPT=$2
fi
@shiruilu
shiruilu / babysitter.sh
Created July 8, 2015 03:24
shake it baby
#!/bin/bash
while [ idx=1 ]
do
eject
eject -t
done
@shiruilu
shiruilu / peakdet.m
Last active August 29, 2015 14:23 — forked from endolith/peakdet.m
function [maxtab, mintab]=peakdet(v, delta, x)
%PEAKDET Detect peaks in a vector
% [MAXTAB, MINTAB] = PEAKDET(V, DELTA) finds the local
% maxima and minima ("peaks") in the vector V.
% MAXTAB and MINTAB consists of two columns. Column 1
% contains indices in V, and column 2 the found values.
%
% With [MAXTAB, MINTAB] = PEAKDET(V, DELTA, X) the indices
% in MAXTAB and MINTAB are replaced with the corresponding
% X-values.
@shiruilu
shiruilu / total.R
Created October 19, 2014 07:58
read data(csv format) from the url, and save as RDS file
# useage: readAQHI(2014, 1)
# TODO: read data(csv format) from the url, and save as RDS file
cleanAQHI <- function(x) {
temp_ans<-gsub("\\*","",x)
temp_ans[temp_ans == "10+"]<-"11"
return(as.numeric(temp_ans))
}
genAQHIurls <- function(year, month) {
if (month <= 0 | month > 12) {