This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gitconfig() { | |
git config user.name "piaoger" | |
git config user.email "[email protected]" | |
} | |
rev=$(git rev-parse --short HEAD) | |
depot=https://github.com/piaoger/playground-rust.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get public ipv4 | |
# http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html | |
# http://stackoverflow.com/questions/14594151/methods-to-detect-public-ip-address-in-bash | |
AMI_ID=$(curl --connect-timeout 5 "http://169.254.169.254/latest/meta-data/ami-id") | |
if [[ $AMI_ID == ami-* ]] ; | |
then | |
IPV4=$(curl --connect-timeout 5 "http://169.254.169.254/latest/meta-data/public-ipv4") | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# from http://unix.stackexchange.com/questions/69167/bash-script-that-print-cpu-usage-diskusage-ram-usage | |
FREE_DATA=`free -m | grep Mem` | |
CURRENT=`echo $FREE_DATA | cut -f3 -d' '` | |
TOTAL=`echo $FREE_DATA | cut -f2 -d' '` | |
echo CPU: `top -b -n1 | grep "Cpu(s)" | awk '{print $2 + $4}'`% | |
echo RAM: $(echo "scale = 2; $CURRENT/$TOTAL*100" | bc)% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#md5 generation | |
# linux: md5sum file >md5file | |
# mac: md5 -r file >md5file | |
#Md5 comparison | |
# linux: md5sum -c md5file | |
# mac: manual check ? | |
function find_md5sum() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# list *.js files in directory | |
for file in ./*.js | |
do | |
if [[ -f $file ]]; then | |
echo $file | |
fi | |
done | |
# list child dirs except hidden ones |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for compress time and size, | |
# it seems that we can get the balance with "-1", i.e compress faster | |
ZIP_FOLDER="Utils./Users/piaoger/Box/*" | |
ZIP_OUTPUT=output.zip | |
FROM_TIME1=$(date) | |
zip -r output.zip Utils./Users/piaoger/Box/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# https://www.blackmoreops.com/2014/10/28/delete-clean-cache-to-free-up-memory-on-your-slow-linux-server-vps/ | |
sync | |
sudo sh -c "sync; echo 3 > /proc/sys/vm/drop_caches" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"net/http" | |
"net/http/httputil" | |
"net/url" | |
) | |
type handle struct { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// borrowed from http://www.cnblogs.com/duanhuajian/p/4485106.html | |
// change: use utc time instead | |
function formatDate (date, fmt) { | |
var o = { | |
"M+" : date.getUTCMonth()+1, | |
"d+" : date.getUTCDate(), | |
"h+" : date.getUTCHours()%12 == 0 ? 12 : date.getUTCHours()%12, | |
"H+" : date.getUTCHours(), | |
"m+" : date.getUTCMinutes(), | |
"s+" : date.getUTCSeconds(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this_script=$(cd ${0%/*} && echo $PWD/${0##*/}) | |
this_dir=$(cd ${0%/*} && echo $PWD) |