Skip to content

Instantly share code, notes, and snippets.

View adkdev's full-sized avatar
🎯
Focusing

Adisak P. adkdev

🎯
Focusing
  • Bangkok, Thailand
  • 17:10 (UTC +07:00)
  • X @adkdev
View GitHub Profile
@adkdev
adkdev / update.sh
Created March 15, 2021 10:15
Update all docker images that use latest tags
docker images --format "{{.Repository}}:{{.Tag}}" | grep ':latest' | xargs -L1 docker pull;
@adkdev
adkdev / fix.sh
Created January 19, 2021 09:15
Fix dylib for MySQL on macos
# Fix dylib for MySQL image not load
# Library not loaded: /usr/local/opt/mysql/lib/libssl.1.1.dylib
# Library not loaded: /usr/local/opt/mysql/lib/libcrypto.1.1.dylib
# image not load
ln -s /usr/local/opt/openssl/lib/libssl.1.1.dylib /usr/local/opt/mysql/lib/libssl.1.1.dylib
ln -s /usr/local/opt/openssl/lib/libcrypto.1.1.dylib /usr/local/opt/mysql/lib/libcrypto.1.1.dylib
@adkdev
adkdev / bash_shortcut.txt
Created December 20, 2020 10:08
Bash Shortcut
Shortcut Action
Navigation
Ctrl + a Go to the beginning of the line.
Ctrl + e Go to the end of the line.
Alt + f Move the cursor forward one word.
Alt + b Move the cursor back one word.
Ctrl + f Move the cursor forward one character.
Ctrl + b Move the cursor back one character.
Ctrl + x, x Toggle between the current cursor position and the beginning of the line.
Editing
@adkdev
adkdev / gist:74af3592abb299777a420e50e2eaa738
Created January 7, 2020 08:19
fake smtp server on your local machine
// source : https://stackoverflow.com/a/58406183/1606462
CommandLineFu had this one liner to run an SMTP server on port 25:
sudo python -m smtpd -n -c DebuggingServer localhost:25
This will run a fake smtp server on your local machine. It won't send anything, but will dump it to the console.
@adkdev
adkdev / run_all.sh
Created September 2, 2019 07:32
Bash script for execute all days in a specific year
#!/bin/bash
yy=2018
for m in `seq 1 12`; do
mm=$(printf %02.0f $m)
max_date=$(cal $(date +"${mm} ${yy}") | awk 'NF {DAYS = $NF}; END {print DAYS}')
for d in `seq 1 $max_date`; do
dd=$(printf %02.0f $d)
echo "paht/to/script.sh $yy $mm $dd"
# sleep 1
@adkdev
adkdev / find.sh
Created August 23, 2019 08:01
find string in directory
# method 1 use `find`
find '/path/to/somewhere/' -name '*.txt' -exec grep -e 'pattern' {} \; -print
# method 2 use `grep`
grep -rnw '/path/to/somewhere/' -e "pattern"
@adkdev
adkdev / query.sql
Created January 15, 2019 11:45
find long running query in postgres
SELECT procpid, current_query, waiting, waiting_reason, query_start FROM pg_stat_activity WHERE (now() - pg_stat_activity.query_start) > interval '5 minutes' AND current_query != '<IDLE>' ORDER BY query_start DESC LIMIT 100;
@adkdev
adkdev / kill_all_airflow_tasks.sh
Last active January 14, 2019 14:41
Kill all airflow running task
ps aux | grep "airflow run" | grep -v grep | awk '{print $2}' | xargs kill -9
@adkdev
adkdev / swap.sh
Created July 17, 2018 08:19
List all process that are using swap
#!/bin/bash
# source : https://stackoverflow.com/a/44757040/1606462
(echo "COMM PID SWAP"; for file in /proc/*/status ; do awk '/^Pid|VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | grep kB | grep -wv "0 kB" | sort -k 3 -n -r) | column -t
@adkdev
adkdev / clear_hadoop_tmp.sh
Created July 15, 2018 06:06
Clear Hadoop tmp
find /opt/hadoop/tmp -mmin +360 -exec rm {} \;