Skip to content

Instantly share code, notes, and snippets.

View vshmoylov's full-sized avatar
🤩
Building some great stuff

Victor Shmoilov vshmoylov

🤩
Building some great stuff
View GitHub Profile
@vshmoylov
vshmoylov / create_swap.sh
Created January 31, 2024 09:08
Create and enable swap
#!/bin/bash
# should be run as root
fallocate -l 1G /swapfile && chmod 600 /swapfile && mkswap /swapfile && swapon /swapfile
#!/bin/bash
TIMESTAMP=`date +"%Y-%m-%d %H.%M.%S"`
FILENAME="Backup Name $TIMESTAMP.sql.gz"
BAK_PATH="$HOME/bak"
mysqldump -u user --password=`cat ~/some/path/.env | grep DB_PASSWORD | sed 's/DB_PASSWORD=//'` your_db_name | gzip > "$BAK_PATH/$FILENAME"
echo $FILENAME > "$BAK_PATH/latest_backup"
VOLUME=vol_name_here; ssh your.server "cd `docker volume inspect --format "{{ .Mountpoint }}" $VOLUME`; tar -czf - ." > ${VOLUME}-backup-`date +"%Y-%m-%d_%H.%M.%S"`.tar.gz
@vshmoylov
vshmoylov / ssh-tunnel-local-forwarding.service
Created May 17, 2023 18:04
ssh tunnel as systemd service
[Unit]
Description=Persistent SSH Tunnel from port XXXX on this server, docker ip to port localhost:YYYY on example.com server (local port forwarding)
After=network.target
[Service]
Restart=on-failure
RestartSec=5
ExecStart=/usr/bin/ssh -NTC -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -L 172.17.0.1:XXXX:127.0.0.1:YYYY example.com
[Install]
@vshmoylov
vshmoylov / base64url.ts
Created November 20, 2022 10:41
base64UrlEncode and base64UrlDecode functions in JS/TS
/*
Basically, base64URL is a modification of common base64 standard containing following changes:
* Replaces "+" by "-" (minus)
* Replaces "/" by "_" (underline)
* Does not require a padding character
* Forbids line separators
Considering above, base64url string may be safely used as part of the URL without any further encoding.
For more details please see https://base64.guru/standards/base64url
*/
docker volume inspect --format "{{ .Mountpoint }}" aura_prod_files_storage
@vshmoylov
vshmoylov / copy_files_archived.sh
Created July 21, 2022 20:10
Archive into tgz and transfer data from remote server to local machine as a single ssh command
ssh user@example.com "cd ~/whenewer/you/want/to; tar -czf - ." > files-backup.tar.gz
@vshmoylov
vshmoylov / phpinfo.php
Created May 25, 2022 23:05
Some config testing php files
<? phpinfo();
@vshmoylov
vshmoylov / string_array_join.sh
Created May 12, 2022 20:08
Join array of strings in bash
RESULT=""
for element in $ARRAY ; do
RESULT="$RESULT${RESULT:+,}$element"
done
@vshmoylov
vshmoylov / %USERPROFILE%\.ssh\config
Created May 1, 2022 19:33
[git, windows, intellij] Sample ssh config for git authentication using keys. Particularly is helpful for intellij idea. Source: https://stackoverflow.com/a/60612744
Host github
Hostname github.com
User git
IdentityFile "D:/path/to the/private.key"