Skip to content

Instantly share code, notes, and snippets.

View Max95Cohen's full-sized avatar

Max Cohen Max95Cohen

View GitHub Profile
@Max95Cohen
Max95Cohen / linux
Last active February 20, 2023 07:25
Linux
[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx
# A job stop of running process...
$ sudo dpkg-reconfigure tzdata
# install putty tools
sudo apt install putty-tools
# .pem to .ppk convert
puttyget file.pemo -o file.ppk
@Max95Cohen
Max95Cohen / .htaccess
Created February 20, 2023 03:08
.htaccess CMS
# QueryString алып тыстау керек. ?a=b
Route::path() - Route::any('/system/users/:operation/:ID', 'system'); "/system/users" деген жолды алып береді.
RewriteCond %{REQUEST_URI} !-d
RewriteRule ^(.*/\w+[^/])$ /$1/ [L,R]
RewriteCond %{REQUEST_URI} ^/system[^.]
RewriteRule ^(.*)$ index.php?$1 [END,QSA]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ /kz/ [R,END]
RewriteCond %{REQUEST_URI} ^/([a-zA-Z0-9-_]+)\.(css|gif|ico|jpe?g|js|png|woff?2)$ [NC]
RewriteRule ^(.*)$ /public/%2/%1.%2 [END]
@Max95Cohen
Max95Cohen / editor
Created February 15, 2023 12:27
ubuntu default editor
sudo select-editor
sudo update-alternatives --config editor
@Max95Cohen
Max95Cohen / swap
Created February 14, 2023 08:35
swap tips
Show swap
sudo swapon --show
sudo fallocate -l 1G /swapfile
sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo nano /etc/fstab
/swapfile swap swap defaults 0 0
@Max95Cohen
Max95Cohen / mysql
Created February 14, 2023 08:34
mysql tips
Kill sleeped connections
for i in `mysql -u root -e "show processlist" | awk '/Sleep/ {print $1}'` ; do mysql -e "KILL $i;"; done
MYSQL reset password
sudo systemctl stop mysql
sudo systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
sudo systemctl start mysql
sudo mysql -u root
@Max95Cohen
Max95Cohen / git
Created February 14, 2023 08:33
git tips
Local and remote updates
local-pc: git reset --hard HEAD~33
local-pc: git push origin +HEAD:master
remote-pc: git reset --hard HEAD~33
remote-pc: git pull
Reset last push commit
git push -f origin last_known_good_commit:branch_name
@Max95Cohen
Max95Cohen / bind9
Created February 14, 2023 08:33
bind9 dns tips
$ sudo apt install bind9
$ cd /etc/bind
$ sudo vim named.conf.options
forwarders {
192.168.1.1; // Local office modem IP address
8.8.8.8;
};
allow-transfer {
192.168.1.1;
};
@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 / centos
Created February 14, 2023 08:31
centos tips
# Server autologin
cp /lib/systemd/system/getty@.service /etc/systemd/system/getty@tty1.service
[Service]
ExecStart=-/sbin/agetty --autologin root --noclear %I
# Increase LVM size of root folder /
df -h
cp -a /home /home2
umount /dev/mapper/centos-home
@Max95Cohen
Max95Cohen / ubuntu
Last active March 1, 2023 05:17
ubuntu tips
# Ubuntu welcome text disable
sudo chmod -x /etc/update-motd.d/*
# Ubuntu remove/hide user from login screen
/var/lib/AccountsService/users/XXX
[User]
SystemAccount=true
# Ubuntu Server autologin
/etc/systemd/system/getty@tty1.service.d/override.conf