Skip to content

Instantly share code, notes, and snippets.

View Max95Cohen's full-sized avatar

Max Cohen Max95Cohen

View GitHub Profile
@Max95Cohen
Max95Cohen / bash
Last active February 26, 2024 03:59
bash files
#!/bin/sh
nocolor='33[0m';
color0='33[0;30m';
color1='33[0;31m';
color2='33[0;32m';
color3='33[0;33m';
color4='33[0;34m';
color5='33[0;35m';
color6='33[0;36m';
color7='33[0;37m';
@Max95Cohen
Max95Cohen / example.conf
Last active February 16, 2024 13:02
example.conf nginx virtual host config
map $http_origin $allow_origin {
~^https?://(.*\.)?my-domain.com(:\d+)?$ $http_origin;
default "";
}
upstream websocket {
server localhost:3001;
}
server {
@Max95Cohen
Max95Cohen / phpmyadmin
Last active December 14, 2023 04:22
phpmyadmin bash script
echo '.list_container.hide{margin-bottom:50px !important}' >> themes/original/css/theme.css
sed -i 's/#pma_navigation{background:#fff;/#pma_navigation{background:#d00;/g' themes/original/css/theme.css
sed -i 's/#pma_navigation_tree li.selected{color:#000;background-color:#eee}/#pma_navigation_tree li.selected{color:#000;background-color:#b00}/g' themes/original/css/theme.css
sed -i 's/body{font-family:sans-serif;/body{font-family:Ubuntu,sans-serif;/' themes/original/css/theme.css
sed -i '5,9d' templates/login/header.twig
@Max95Cohen
Max95Cohen / ffmpeg
Last active November 3, 2023 05:41
ffmpeg tips
ffmpeg -i input.jpg -vf scale=320:240 output_320x240.jpg
ffmpeg -y -i input.jpg -vf "scale='min(500,iw)':'min(500,ih)'" output_500x500.png
ffmpeg -y -i input.jpg -vf "crop=in_h" output_center.png
ffmpeg -y -i input.jpg -vf "scale=w='min(500,in_h):h=-1'" output_center1.png
ffmpeg -y -i input.jpg -vf "scale=w='min(1000,in_h):h=-1',crop=out_w=in_h,scale=w='min(200,in_h):h=-1" output_center2.png
ffmpeg -i input1.mov -vcodec copy -acodec copy out1.mp4
ffmpeg -i input1.mov -q:v 0 output1.mp4
ffmpeg -i input.mkv -codec copy output.mp4
#ffmpeg -i 1000x1250.jpg -vf scale=w=300:h=300:force_original_aspect_ratio=increase,crop=300:300 temp.jpg -y
@Max95Cohen
Max95Cohen / logrotate.d
Last active October 17, 2023 15:22
logrotate.d mysql script
# /etc/logrotate.d/mysql_general
/var/lib/mysql/platonus.log{
compress
dateext
maxsize 300M
copytruncate
maxage 365
dateformat -%Y%m%d%s
hourly
@Max95Cohen
Max95Cohen / VFS
Last active October 3, 2023 16:14
Kernel Panic - not syncing: VFS: Unable to mount root fs on
https://askubuntu.com/questions/895492/kernel-panic-vfs-cannot-open-root-device-or-unknown-block-error-6
sudo update-initramfs -u -k $(uname -r)
https://askubuntu.com/questions/41930/kernel-panic-not-syncing-vfs-unable-to-mount-root-fs-on-unknown-block0-0
sudo fdisk -l
sudo mount /dev/sda2 /mnt
sudo mount --bind /dev /mnt/dev
sudo mount --bind /dev/pts /mnt/dev/pts
@Max95Cohen
Max95Cohen / exercise-errors.go
Created September 29, 2023 13:54
A tour of Go Exercise: Errors
package main
import (
"fmt"
"math"
)
type ErrNegativeSqrt float64
func (e ErrNegativeSqrt) Error() string {
@Max95Cohen
Max95Cohen / vsftp
Last active September 15, 2023 03:27
vsftp config
listen_port=2221
local_umask=002
pasv_enable=YES
pasv_max_port=50000
pasv_min_port=40000
pasv_address=111.112.11.12
pasv_addr_resolve=NO
listen_ipv6=no
@Max95Cohen
Max95Cohen / update.sh
Last active August 7, 2023 08:18
update.sh apt update script
date
sudo apt update
apt list --upgradable
sudo apt -y upgrade
sudo apt autoclean
sudo apt autopurge
sudo apt autoremove --purge
if [ -f /var/run/reboot-required ]; then
echo 'reboot required'
@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