Skip to content

Instantly share code, notes, and snippets.

View phamquocbuu's full-sized avatar
💻

Buu Pham phamquocbuu

💻
View GitHub Profile
@phamquocbuu
phamquocbuu / _0__ssl_certbot_letsencrypt.md
Created September 13, 2022 07:00 — forked from maxivak/_0__ssl_certbot_letsencrypt.md
Let's encrypt SSL certificates using certbot in docker

Directories on host machine:

  • /data/certbot/letsencrypt

  • /data/certbot/www

  • Nginx server in docker container

docker run -d --name nginx \
@phamquocbuu
phamquocbuu / rando.sh
Created September 7, 2022 03:03
Generate Random String in Bash
alias rando="cat /proc/sys/kernel/random/uuid | sed 's/[-]//g' | head -c 20; echo;"
alias randoo="cat /dev/urandom | tr -dc '[a-zA-Z0-9-_+=]\/}{' | fold -w ${1:-20} | head -n 1"
@phamquocbuu
phamquocbuu / .zshrc
Created June 2, 2022 16:10
Custom simple PROMPT
PROMPT="%B%K{7}MBP%k%b %F{70}➜%f %F{39}%~%f "
@phamquocbuu
phamquocbuu / IPTABLES-CHEATSHEET.md
Created July 30, 2021 06:55 — forked from davydany/IPTABLES-CHEATSHEET.md
IP Tables (iptables) Cheat Sheet

IP Tables (iptables) Cheat Sheet

IPTables is the Firewall service that is available in a lot of different Linux Distributions. While modifiying it might seem daunting at first, this Cheat Sheet should be able to show you just how easy it is to use and how quickly you can be on your way mucking around with your firewall.

Resources

The following list is a great set of documentation for iptables. I used them to compile this documentation.

@phamquocbuu
phamquocbuu / clean.sql
Created June 16, 2021 14:43
Auto repeat delete records in MySQL
DELIMITER $$
CREATE PROCEDURE clean_someTable()
BEGIN
REPEAT
DO SLEEP(1);
DELETE FROM xxx_table where status=2 LIMIT 100000;
UNTIL ROW_COUNT() = 0 END REPEAT;
END$$
@phamquocbuu
phamquocbuu / index.html
Created June 3, 2021 07:25
Add dynamic text to canvas image
<html>
<head>
<style>
body {
background: #222;
color: #fff;
position: relative;
text-align: center;
font-size: 1rem;
font-family: sans-serif;
@phamquocbuu
phamquocbuu / mysql-docker.sh
Created May 7, 2021 10:21 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@phamquocbuu
phamquocbuu / .wslconfig
Created January 12, 2021 02:51
Create a %UserProfile%\.wslconfig file and use it to limit memory assigned to WSL2 VM. WSL does use a really low amount of RAM but it is allocated about 4GB by default when it is started. If you think that’s too much and would like to decrease it, Windows Insider Build 18945 brough customizable settings for wsl. https://blog.simonpeterdebbarma.c…
[wsl2]
kernel=<path> # An absolute Windows path to a custom Linux kernel.
memory=<size> # How much memory to assign to the WSL2 VM.
processors=<number> # How many processors to assign to the WSL2 VM.
swap=<size> # How much swap space to add to the WSL2 VM. 0 for no swap file.
swapFile=<path> # An absolute Windows path to the swap vhd.
localhostForwarding=<bool> # Boolean specifying if ports bound to wildcard or localhost in the WSL2 VM should be connectable from the host via localhost:port (default true).
# <path> entries must be absolute Windows paths with escaped backslashes, for example C:\\Users\\Ben\\kernel
# <size> entries must be size followed by unit, for example 8GB or 512MB
@phamquocbuu
phamquocbuu / Code.gs
Created November 11, 2020 04:41 — forked from clayperez/Code.gs
AUTO-Generate Unique IDs in Google Sheets
// AUTO GENERATE SIMPLE UNIQUE ID'S FOR NON-EMPTY ROWS
//
// Author: Carlos Perez, clayperez@gmail.com
//
// Purpose: This Google Sheets script fires when any cell is edited and
// inserts a random (reasonably unique) UID of ID_LENGTH length
// into the specified ID_COLUMN. For instance if the first column in the
// sheet specified by SHEETNAME is the column where you would like the
// UID injected, then ID_COLUMN should be 1.
//
@phamquocbuu
phamquocbuu / multiple_ssh_setting.md
Created October 26, 2020 09:23 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"