Skip to content

Instantly share code, notes, and snippets.

View ngtrieuvi92's full-sized avatar
🎯
Focusing

Vi Nguyen ngtrieuvi92

🎯
Focusing
View GitHub Profile
@ngtrieuvi92
ngtrieuvi92 / remove-unused-docker-images.sh
Last active October 17, 2021 07:41
Remove all unused docker image
#!/bin/bash
# Remove all exited container
docker rm $(docker ps -q -f status=exited)
# Remove none tag images (image with tag <none>)
docker images | grep "<none>" | awk '{print $3}' |xargs docker rmi -f
# Remove all images that is not using by any running container
# note: docker ps --format {{.Image} -> List all images of running container then set it as grep pattern
sudo fallocate -l 4G /swapfile && \
sudo chmod 600 /swapfile && \
sudo mkswap /swapfile && \
sudo swapon /swapfile && \
sudo swapon -s && \
sudo cp /etc/fstab /etc/fstab.bak && \
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
truncate -s 0 /var/lib/docker/containers/*/*-json.log
# Set vm max
sudo sysctl vm.max_map_count=262144
@ngtrieuvi92
ngtrieuvi92 / Export all databases in mysql.sh
Last active March 5, 2017 02:19
Export all databases in mysql.sh
#!/bin/bash
USER="your_username"
PASSWORD="your_password"
#OUTPUT="/Users/rabino/DBs"
#rm "$OUTPUTDIR/*gz" > /dev/null 2>&1
databases=`mysql -u $USER -p$PASSWORD -e "SHOW DATABASES;" | tr -d "| " | grep -v Database`
@ngtrieuvi92
ngtrieuvi92 / unregister gitlab ci runner.sh
Created March 12, 2017 07:30
unregister gitlab ci runner
sudo gitlab-ci-multi-runner unregister --url https://gitlab.com --token=your_runner_token
@ngtrieuvi92
ngtrieuvi92 / git-checkout--our-all-conflict-file.sh
Created May 17, 2017 08:00
checkout --our all conflict file
git status -s | grep ^U | awk '{print $2}' | xargs git checkout --ours
git status -s | grep ^U | awk '{print $2}' | xargs git add
git commit
@ngtrieuvi92
ngtrieuvi92 / git_find_big.sh
Last active June 4, 2018 03:18
Find big files in git
#!/bin/bash
#set -x
# Shows you the largest objects in your repo's pack file.
# Written for osx.
#
# @see http://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
# @author Antony Stubbs
# set the internal field spereator to line break, so that we can iterate easily over the verify-pack output
@ngtrieuvi92
ngtrieuvi92 / adduser with sudo permission
Last active July 2, 2020 18:07
Adduser with sudo permission
#!/bin/bash
# I. Run this command on your server
# 1. Create new User
adduser your_user
# 2. Add to sudo group
sudo usermod -aG sudo your_user
# 3. Allow to use sudo without password
@ngtrieuvi92
ngtrieuvi92 / .htaccess
Created October 24, 2018 08:47 — forked from alexsasharegan/.htaccess
Apache Config for React Router
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]