Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View rizkysyazuli's full-sized avatar

Rizky Syazuli rizkysyazuli

View GitHub Profile
@rizkysyazuli
rizkysyazuli / git-commands.sh
Last active July 31, 2023 03:03
[Shell - Git] Obscure but useful Git commands #git #shell
# check repo size
git count-objects -vH
# clone a mirror copy of a repo
git clone --mirror <repo-url>
# git merge dry run
git merge --no-commit --no-ff branch_name
# git export as zip
@rizkysyazuli
rizkysyazuli / dev.sh
Last active November 22, 2022 16:59
[Shell - File Management] Files management utilities #shell
# a typical rsync file transfer upload command
# https://explainshell.com/explain?cmd=rsync+-uavl+--exclude-from%3D%27exclude-list%27+--delete+.%2F+%24USER%40%24HOST%3A%24UPLOAD_PATH
rsync -uavl --exclude-from='exclude-list.txt' --delete ./ user@host:/upload/path
# rsync copy folders
rsync -avzh --exclude=dir/ /source /destination/
# rsync download remote directory
rsync -avzh user@host:/target/path ./destination
@rizkysyazuli
rizkysyazuli / https.sh
Last active November 5, 2022 06:34
[Shell - HTTP] Useful http & web related commands
# Download the SSL certificate from a website
echo | openssl s_client -servername NAME -connect HOST:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > FILENAME.cer
# copy ssh keys to remote server
ssh-copy-id remote_username@server_ip_address
# output recent server log
# https://explainshell.com/explain?cmd=tail+-f+%2Fpath%2Fto%2Flogs%2Ferror.log+%7C+grep+%27string%27
tail -f /path/to/logs/error.log | grep 'string'
cat /path/to/logs/error.log | grep 'string'
@rizkysyazuli
rizkysyazuli / tiff-to-jpg.sh
Last active October 6, 2021 04:19
[Shell - Media] Batch edit image or video #shell #ffmpeg #snippets
#!/bin/bash
IMAGES=~/Images
find "$IMAGES" -name '*.TIF' -exec sh -c 'convert "$0" -resize 1024x768 "${0%%.tif}_1024.jpg"' {} \;
# for debug
# find "$IMAGES" -name '*.TIF' -exec sh -c 'echo "${0%%.tif}_1024.jpg"' {} \;
exit;
@rizkysyazuli
rizkysyazuli / shell-utils.sh
Last active July 5, 2021 16:45
[Shell - Utilities] Useful Linux shell commands & utilities #shell #unix
# check active services
# https://explainshell.com/explain?cmd=ps+aux+%7C+grep+%27string%27
ps aux | grep 'service_name'
ps -ef | grep service_name
# check unix OS
cat /etc/os-release
hostnamectl
lsb_release -a # might not work in every distro
@rizkysyazuli
rizkysyazuli / tail-slack.sh
Last active June 21, 2021 07:56
[Shell - Server Log to Slack] Sends server log entries to Slack via webhook #webhook #slack #apache #nginx #shell
#!/bin/bash
tail -n0 -F "$1" | while read LINE; do
(echo "$LINE" | grep -e "$3") && curl -X POST --silent --data-urlencode \
"payload={\"text\": \"$(echo $LINE | sed "s/\"/'/g")\"}" "$2";
done
# to monitor a single session
# ./tail-slack.sh "/var/log/nginx/access-web.log" "https://hooks.slack.com/services/..." " 500 "
@rizkysyazuli
rizkysyazuli / mac.sh
Last active June 13, 2021 15:20
[Shell - macOS] Useful macOS specific shell commands #shell #mac
# Brew commands
brew cleanup
rm -rf $(brew --cache)
@rizkysyazuli
rizkysyazuli / php.sh
Last active June 10, 2021 17:13
[Shell - PHP] PHP command line utilities #php #shell
# Check loaded config
php --ini
# PHP Info
php -i
# Restart PHP-FPM
systemctl restart php-fpm.service
systemctl restart php5-fpm.service # version specific
@rizkysyazuli
rizkysyazuli / nginx-commands.sh
Last active November 4, 2020 16:58
[Shell - Nginx Commands] #nginx #centos #ubuntu
# Start
sudo systemctl start nginx
sudo service nginx start
# Stop
sudo systemctl stop nginx
sudo service nginx stop
# Restart
sudo systemctl restart nginx
@rizkysyazuli
rizkysyazuli / about.md
Last active August 7, 2020 09:24
US States & Cities select menu

About

What is this?

Example JS for populating select menus with US states and the all the cities in it. The city select will be updated based on the selected state.

Data source