Skip to content

Instantly share code, notes, and snippets.

View qinshulei's full-sized avatar
🎯
Focusing

Qin Shulei qinshulei

🎯
Focusing
View GitHub Profile
@qinshulei
qinshulei / index.html
Created October 24, 2014 03:06
index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Canvas clock</title>
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" href="css/app.css">
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
<script src="js/app.js"></script>
@qinshulei
qinshulei / h.sh
Last active August 29, 2015 14:15 — forked from fideloper/h.sh
improve history command with grep and percol
#! /bin/bash
function show_usage {
cat <<- _EOF_
Search Bash History using Grep and Percol
Examples:
$ h ssh
$ h 'ssh user@'
@qinshulei
qinshulei / bash-for.sh
Created March 3, 2015 01:49
bash for example,iterate a array
## declare an array variable
declare -a arr=("element1" "element2" "element3")
## now loop through the above array
for i in "${arr[@]}"; do
echo "$i"
# or do whatever with individual element of the array
done
# You can access them using echo "${arr[0]}", "${arr[1]}" also
@qinshulei
qinshulei / send-template-mail.sh
Created March 16, 2015 08:23
send html email use template by bash
#!/bin/bash
TITLE="Mail Title"
CONTENT="Mail Content"
cat <<EOF | mutt -s "${TITLE}" -e 'set content_type="text/html"' -- 527072230@qq.com
<html>
<body>
<h1>${TITLE}</h1>
<p>${CONTENT}</p>
@qinshulei
qinshulei / app.js
Last active August 29, 2015 14:20
Make Twitter Bootstrap navbar link active by js
$('#navcontainer').find('a[href="' + location.pathname + '"]').parents('li').addClass('active');
@qinshulei
qinshulei / open_doc.sh
Created April 27, 2015 07:12
open url through command line through xdotool to quick switch
#!/bin/bash
#: Title : open_doc.sh
#: Usage : open_doc.sh workflow
#: Synopsis : a tool for quick open doc
#: Date : 2015-02-13 11:23:04
#: Author : shulei
#: version : 1.0
#: Description : use xdotool to quick swith to a project relative url
#: Required : target => which target
#: Options : -i
@qinshulei
qinshulei / multi-line-comment.bash
Created July 22, 2015 04:36
bash multi-line comment
:<<!EOF!
!EOF!
@qinshulei
qinshulei / gist:9a5d57bcc42ffecfcb42
Last active August 29, 2015 14:26 — forked from fungusakafungus/gist:1026804
bash retry function
function retry {
local retry_max=$1
shift
local count=$retry_max
while [ $count -gt 0 ]; do
"$@" && break
count=$(($count - 1))
sleep 1
done
@qinshulei
qinshulei / retry.bash
Created July 29, 2015 08:31
retry n times, then failed
for i in 1 2 3 4 5; do command && break || sleep 15; done