Skip to content

Instantly share code, notes, and snippets.

View phanletrunghieu's full-sized avatar
🏎️
Running

Royce phanletrunghieu

🏎️
Running
View GitHub Profile
@phanletrunghieu
phanletrunghieu / mongoexport-all-collection.sh
Last active July 28, 2018 11:17
import/export all collection in mongodb
#!/bin/bash
DB=$1
COLLECTIONS=$(mongo localhost:27017/$DB --quiet --eval "db.getCollectionNames()" | sed -e 's/[,\["]/ /g;s/ */ /g')
COLLECTIONS=${COLLECTIONS#\[}
COLLECTIONS=${COLLECTIONS%\]}
for collection in $COLLECTIONS; do
echo "Exporting $DB/$collection ..."
mongoexport -d $DB -c $collection -o $collection.json
<ifModule mod_rewrite.c>
#######################################################################
# GENERAL #
#######################################################################
# Make apache follow sym links to files
Options +FollowSymLinks
# If somebody opens a folder, hide all files from the resulting folder list
@phanletrunghieu
phanletrunghieu / ConvertVie.js
Created April 18, 2019 06:17 — forked from hu2di/ConvertVie.js
JavaScript: Chuyển tiếng Việt có dấu sang không dấu
function change_alias(alias) {
var str = alias;
str = str.toLowerCase();
str = str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g,"a");
str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g,"e");
str = str.replace(/ì|í|ị|ỉ|ĩ/g,"i");
str = str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g,"o");
str = str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g,"u");
str = str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g,"y");
str = str.replace(/đ/g,"d");
@phanletrunghieu
phanletrunghieu / iptables-reload.sh
Created April 22, 2019 09:19 — forked from tehmoon/iptables-reload.sh
IPtables and docker reload!
#!/bin/sh
set -e
## SEE https://medium.com/@ebuschini/iptables-and-docker-95e2496f0b45
CWD=$(cd "$(dirname "${0}")"; pwd -P)
FILE="${CWD}/$(basename "${0}")"
chown root:root "${FILE}"
chmod o-rwx "${FILE}"
# eth0 is public network interface
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
# Allow connection RELATED,ESTABLISHED on eth0
iptables -t filter -A INPUT -i eth0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
# Prevent DOCKER chain
iptables -t nat -I PREROUTING -m addrtype --dst-type LOCAL -j RETURN
### Keybase proof
I hereby claim:
* I am phanletrunghieu on github.
* I am hieudeptrai (https://keybase.io/hieudeptrai) on keybase.
* I have a public key ASCl_5aZUQ6cSiyGQLLWd2_g2F-NfPf5dKITHz7trJQWAAo
To claim this, I am signing this object:
@phanletrunghieu
phanletrunghieu / docker-cleanup-resources.md
Created October 1, 2019 09:57 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@phanletrunghieu
phanletrunghieu / generate.sh
Last active August 15, 2020 15:18
ssl key pair
#!/bin/sh
CA_PASS="1234"
SERVER_PASS="4321"
CLIENT_PASS="5678"
cat > "openssl.cnf" << EOF
[v3_req]
subjectAltName = @alt_names
# Alternative names are specified as IP.# and DNS.# for IP addresses and
set-option -ga terminal-override ',rxvt-uni*:XT:Ms=\E]52;%p1%s;%p2%s\007'
set -g mouse on
setw -g mode-keys vi
source-file "${HOME}/.tmux-themepack/powerline/block/cyan.tmuxtheme"
# For binding 'y' to copy and exiting selection mode
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -sel clip -i'
# For binding 'Enter' to copy and not leave selection mode
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe 'xclip -sel clip -i' '\;' send -X clear-selection
@phanletrunghieu
phanletrunghieu / pub
Last active March 11, 2021 15:59
pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC/wLhgLv0KlOIAJ8SJae3LAXFlpuAy0aCaoh4ULn4/rwJD8RrleHViw49iwDK8QXyB/i6TyCVMtuH1S2/b+cNXncrLbkb+EhkW7wuROo5MviOHn01zEhaK8MAnMFzu6bsTCYppUyHAkBLPskmvH2twE987CQf1glE8QWFfEucWQImcmvOoHMWmbHWAsy9eufWoqIfGQnEcCI5MkoUh9oQ6WdxAOKGww0+uhijcb8j8G06BG0bIGlvPLuHuJ4TOOBDvsRwcC+NOXLnjGj+J47yXneIHLg5N08v4a4GrE+cblw4RYY4FQ9+NkPwRsIfVSMsE0IPThlvbkrd2EpG36FJN hieudeptrai@HieuUbuntu