Skip to content

Instantly share code, notes, and snippets.

View liuxd's full-sized avatar
🗿
Hi, there.

Allen Liu liuxd

🗿
Hi, there.
  • Tax Traders
  • Auckland, New Zealand
View GitHub Profile
@liuxd
liuxd / strtotime.rb
Created September 7, 2017 01:00
strtotime.rb
require 'time'
# time like "2014-08-31 12:33:32" conver to unix timestamp.
def strtotime(date_str)
return Time.strptime(date_str, "%Y-%m-%d %H:%M:%S").to_i
end
@liuxd
liuxd / add_create_time.sh
Created September 7, 2017 01:00
add_create_time.sh
#!/usr/bin/env bash
# Add create date to markdown files.
markdown_path=/Users/liuxidong/Github/liuxd.github.io/markdown/index/英语
if [ ! -n $1 ];then
markdown_path=$1
fi
cd $markdown_path
@liuxd
liuxd / check_php_syntax_in_svn.sh
Created September 7, 2017 01:01
check_php_syntax_in_svn.sh
#!/usr/bin/env bash
#
# Check the modified php file's syntax in a subversion repository.
function _cecho {
case $2 in
info )
color=33;;
error )
color=31;;
@liuxd
liuxd / daemon-keeper.sh
Last active September 7, 2017 01:01
daemon-keeper.sh
#!/bin/bash
function _current_path {
SOURCE=${BASH_SOURCE[0]}
DIR=$( dirname "$SOURCE" )
while [ -h "$SOURCE" ]
do
SOURCE=$(readlink "$SOURCE")
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
@liuxd
liuxd / fork-bomb.sh
Created September 7, 2017 01:02
fork-bomb.sh
:(){:|:&};:
#这就是个fork 炸弹的实例。
#具体操作是:
# 通过定义一个名为 ‘:‘的函数。
# 它会调用自己两次,一次在前台另一次运行在后台。
# 它会反复的执行下去直到系统崩溃。
@liuxd
liuxd / fozu.sh
Created September 7, 2017 01:02
fozu.sh
#!/bin/bash
# 用法:将代码保存为shell脚本,执行即可。
echo -ne "\033[0;33m"
cat<<EOT
_oo0oo_
088888880
88" . "88
(| -_- |)
0\ = /0
@liuxd
liuxd / fswatch-rsync.sh
Created September 7, 2017 01:02
fswatch-rsync.sh
#!/usr/bin/env sh
#
# Description:
# Make your local folder to remote server synchronization.
# Requirements:
# brew install fswatch
SRC=/Users/liuxd/Documents/guess_cheat_new/
DES=liuxidong@172.16.0.37:/home/liuxidong/project/cheat/
EXCLUDE=/Users/liuxd/Downloads/rsync-exlcude.txt
@liuxd
liuxd / iconv-all.sh
Created September 7, 2017 01:03
iconv-all.sh
#!/bin/bash
SRC_PATH="/Users/liuxd/SpiderOak Hive/Book/holdme1234"
DES_PATH="/Users/liuxd/Downloads/tmp"
ls $SRC_PATH |grep txt|while read file
do
iconv -f GB18030 -t UTF-8 "$SRC_PATH/$file" > "$DES_PATH/$file"
done
@liuxd
liuxd / progress.sh
Created September 7, 2017 01:03
progress.sh
#!/bin/sh
b=''
for ((i=0;$i<=100;i+=1))
do
printf "progress:[%-50s]%d%%\r" $b $i
sleep 0.1
b=#$b
done
@liuxd
liuxd / say.sh
Created September 7, 2017 01:03
say.sh
# 脚本执行完通过语音来提示。仅限Mac OS。
#
# exec.sh 是你要执行的脚步。
exec.sh || say failed && say success