Skip to content

Instantly share code, notes, and snippets.

View dyllanwli's full-sized avatar
🎸
Focusing

DY-L dyllanwli

🎸
Focusing
View GitHub Profile
@dyllanwli
dyllanwli / gist:5c76fe5a285700acc052a79e61e264ec
Created May 13, 2019 02:42
Get Stuff From Fine Print Stdout
$(<command> | grep <something I want to grep> | awk '{print <the line I wants to get, e.g. $1>}')
@dyllanwli
dyllanwli / gist:37a9ca3d3085087cc59d0f62809cd0a2
Last active May 13, 2019 02:45
Docker SwitchDaemon on Windows
cd "C:\Program Files\Docker\Docker"
./DockerCli.exe -SwitchDaemon
# I should switch back if I still needs the original Daemon
@dyllanwli
dyllanwli / single_convert.sh
Created May 13, 2019 03:28
Libreoffice headless convert doc to pdf
echo "hello world" > a.txt
soffice --headless --invisible --nodefault --nofirststartwizard \
--nolockcheck --nologo --norestore --convert-to pdf --outdir $(pwd) a.txt
# to run multiple convert just use * as a selector
@dyllanwli
dyllanwli / copyfile.sh
Created May 13, 2019 08:26
Some linux command
# linux command . Copy a file one hundred times
for n in {001..100}; do
cp file.jpg file-$n.jpg
done
@dyllanwli
dyllanwli / s3.sh
Last active June 5, 2019 07:19
aws s3 command
aws --version
# aws-cli/1.15.30 Python/3.6.5 Darwin/17.6.0 botocore/1.10.30
# move or rename bucket
aws s3 mb s3://[new-bucket]
aws s3 mv s3://old-bucket s3://new-bucket --recursive
# or
aws s3 mb s3://[new-bucket]
aws s3 sync s3://[old-bucket] s3://[new-bucket]
@dyllanwli
dyllanwli / setReplica.sh
Created December 23, 2019 05:52
Mongodb set replica set
# start mongodb with --replSet rs
# the rs means replica set name
# if MONGO_INITDB_ROOT_USERNAME was set, then use those init db root username and password
mongo -u <your user name> --authenticationDatabase admin -p <your passowrd>
rs.initiate()
@dyllanwli
dyllanwli / .bashrc
Last active April 26, 2020 00:08
hprc .bashrc
alias activatejupyter='module load Anaconda/3-5.0.0.1 ; source activate jupyterlab_2.0.1'
alias rm='trash' # to avoid wrong delete
# use \rm -rf is you still want to delete all file
# make symbolic link to avoid disk file count usage
# ln -s <the short cut that you want to link (may not be exist)> <the real folder path(must exist)>
@dyllanwli
dyllanwli / reset.sh
Created June 4, 2020 15:09
Reset your iptables
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
# https://serverfault.com/questions/200635/best-way-to-clear-all-iptables-rules
# To answer your question succinctly, no: there would not be any "leftover" rules after flushing every table. In the interest of being thorough however, you may want to set the policy for the built-in INPUT and FORWARD chains to ACCEPT, as well
iptables -P OUTPUT ACCEPT
iptables -t nat -F
iptables -t mangle -F
iptables -F
iptables -X
@dyllanwli
dyllanwli / clear.sh
Created July 28, 2020 17:46
Clear local branch not exists in remote
git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -D
@dyllanwli
dyllanwli / colabcode.sh
Created November 30, 2020 22:27
Run VScode on colab
!curl -fsSL https://code-server.dev/install.sh | sh
!pip install -qqq pyngrok
from pyngrok import ngrok
url = ngrok.connect(port=9000)
print(url)
!nohup code-server --port 9000 --auth none &