Skip to content

Instantly share code, notes, and snippets.

View Max95Cohen's full-sized avatar

Max Cohen Max95Cohen

View GitHub Profile
@Max95Cohen
Max95Cohen / prepare-commit-msg
Created February 9, 2023 05:17
prepare-commit-msg git hook to add prefix for commit message
#!/bin/bash
FILE=$1
MESSAGE=$(cat $FILE)
REGEX_ISSUE_ID="^((ISSUE|TASK)\-[0-9]+:\s)"
ISSUE_ID_IN_COMMIT=$(echo $MESSAGE | grep -o -E "$REGEX_ISSUE_ID")
if [[ -z "$ISSUE_ID_IN_COMMIT" ]]; then
BRANCH_NAME=$(git symbolic-ref --short HEAD)
echo "$BRANCH_NAME: $MESSAGE" > $FILE
@Max95Cohen
Max95Cohen / iptables
Last active February 28, 2023 09:18
iptables examples
# show, delete
iptables -t nat -v -L PREROUTING -n --line-number
iptables -t nat -D PREROUTING 5
# forward
iptables -t nat -A PREROUTING -i ens3 -p tcp --dport 33080 -j DNAT --to 10.0.27.67:33080
# Global IP to Local IP Ubuntu
iptables -t nat -A OUTPUT -p all -d 123.45.67.89 -j DNAT --to-destination 127.0.0.1
@Max95Cohen
Max95Cohen / .htaccess
Created January 31, 2023 04:23
.htaccess examples
# http://maq.kz/123/
RewriteRule ^([1-9]+)/$ index.php?article=$1 [L]
## ajax http://maq.kz/dnfksnfsk/scripts/mslmflsmfsl/
RewriteRule ^(.+)/scripts/ scripts.php [L]
## pages http://maq.kz/page/123
RewriteRule ^page/(.*)$ index.php?a=1&b=2&c=$1 [L]
##
@Max95Cohen
Max95Cohen / commit-msg
Created January 27, 2023 18:01
commit-msg git hook
#!/bin/bash
REGEX_ISSUE_ID="^((ISSUE|TASK)\-[0-9]+)"
ISSUE_ID_IN_COMMIT=$(echo $(cat "$1") | grep -o -E "$REGEX_ISSUE_ID")
if [[ -z "$ISSUE_ID_IN_COMMIT" ]]; then
BRANCH_NAME=$(git symbolic-ref --short HEAD)
RED='\033[0;31m'
NC='\033[0m' # No Color
@Max95Cohen
Max95Cohen / pre-commit
Created January 27, 2023 18:00
pre-commit git hook
#!/bin/bash
REGEX_ISSUE_ID="^((ISSUE|TASK)\-[0-9]+)"
ISSUE_ID_IN_BRANCH=$(echo $(git rev-parse --abbrev-ref HEAD) | grep -o -E "$REGEX_ISSUE_ID")
if [[ -z "$ISSUE_ID_IN_BRANCH" ]]; then
RED='\033[0;31m'
NC='\033[0m' # No Color
@Max95Cohen
Max95Cohen / _backup.sh
Created January 21, 2023 19:20
_backup.sh mysql backup script
# mysqldump requires at least the SELECT privilege for dumped tables, SHOW VIEW
# for dumped views, TRIGGER for dumped triggers, LOCK TABLES if the
# --single-transaction option is not used, and (as of MySQL 8.0.21) PROCESS if
# the --no-tablespaces option is not used. Certain options might require other
# privileges as noted in the option descriptions.
# .my.cnf
[mysqldump]
user=backup
password="PASSWORD"
@Max95Cohen
Max95Cohen / apt
Last active January 21, 2023 11:52
apt install command
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install \
git \
vim \
nano \
php8.1 php8.1-{cli,fpm,gd,zip,mbstring,mysql,dom,xml,curl,redis,memcached} \
php7.4 php7.4-{cli,fpm,gd,zip,mbstring,mysql,dom,xml,curl,redis,memcached} \
mysql-server-8.0 \
nginx
@Max95Cohen
Max95Cohen / .bashrc
Last active April 28, 2023 04:22
.bashrc update
wget https://gist.githubusercontent.com/Max95Cohen/7af5c9db2c003cb0c032265c77a14907/raw/1d51080f12a88846e6ff6188cace28c8cae58530/git.sh
wget https://gist.githubusercontent.com/Max95Cohen/e86448c0e258703d604c98992fb5e55d/raw/3c824eddd6f1b42dfc8b888510083e00dfe2b0c4/.vimrc
sed -i 's/ls --color=auto/ls --color=auto --group-directories-first/' .bashrc
sed -i '59i PROMPT_COMMAND="source /home/aibekq/git.sh";' .bashrc
sed -i '60i \ ' .bashrc
echo "PS1='${debian_chroot:+($debian_chroot)}[\e[0;33m\t\e[0m] \e[1;36m\w \e[0;30m\j \e[1;31m$git_branch\n\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\] $ '" >> .bashrc
echo "alias rm='rm -i';" >> .bashrc
echo "eval \$(ssh-agent);" >> .bashrc
@Max95Cohen
Max95Cohen / plugins
Created January 19, 2023 14:02
Sublime Package controll: Install package
A File Icon
Emmet
Auto-save
HTML-CSS-JS Prettify
Pretty JSON
syncviewscroll
Inspired Github Color Theme
@Max95Cohen
Max95Cohen / navigation.js
Last active January 16, 2023 09:39
navigation.js phpmyadmin dist js file
js/navigation.js
$(document).on('keydown', (event) => {
if (event.ctrlKey && event.key === '\\') {
event.data = {'resize_handler': this};
this.collapse(event);
}
});