BMI Calculator

Height (in cm)

Weight (in kg)

 

Migrate / Backup Mariadb to Another Server

Export Database

One database

mysqldump -u root -p --opt [database name] > [database name].sql

Or all databases:

mysqldump -u root -p --opt --all-databases > [database name].sql

Import Database

mysql -u root -p newdatabase < /path/to/newdatabase.sql

# or to import multiple databases:
mysql -u root -p < /path/to/newdatabase.sql

# if root does not have a password:
mysql -u root newdatabase < /path/to/newdatabase.sql

Flat File Blog Options

Pico

CMSContent OrganisationLinks to other postsFeatures
Picopage_name.md OR
page_name/index.md
[link](%base_url%/blog/page_name)
Yelowpage_name/page.md
numeric_prefix-page_name.md
[link](page_name)Search
Tags
Gravpage_name/theme_name.md[link](../page_name)Search
Tags
Sidebar
HTMLySearch
Categories
Tags
Online Editor

Update WordPress via command line

Backup

Backup files:

cp -r /var/www/techblog.dudan.ru /var/www/techblog.dudan.ru.backup

Update

Option 1. Manual Update.

Download latest WordPress archive and unzip it:

wget https://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz

Sync new files to the the web site folder:

rsync -avh --progress wordpress/ techblog.dudan.ru/

Option 2. Update using wp-cli

Install wp-cli:

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp

Run update:

wp core update --path=/var/www/techblog.dudan.ru

Mikrotik: How to make your self-hosted web site available both on the WEB and on the LAN

1. Firewall: allow requests to ports 80 and 443

/ip firewall filter
add action=accept chain=forward dst-port=80 in-interface=ether1 protocol=tcp comment="allow requests to port 80 to be forwarded (to web server)"

Repeat for port 443 if needed

2. Configure NAT

Configure port forwarding from WEB to the LAN server:

/ip firewall nat add chain=dstnat in-interface=ether1 protocol=tcp dst-port=80 action=dst-nat to-addresses=192.168.0.9 to-ports=80 comment="forward from wan to web server port 80"

Do the same for 443 port if needed

Configure address substitution (explained here):

/ip firewall nat
add chain=srcnat src-address=192.168.0.0/24 dst-address=192.168.0.9 protocol=tcp dst-port=80 out-interface=ether1 action=masquerade

Do the same for 443 port if needed

Как создать сеть между двумя маршрутизаторами Mikrotik (L2TP VPN)

Исходные данные: есть 2 маршрутизатора, обеспечивающие доступ в интернет для двух отдельных локальных сетей. Например между 2мя офисами:

  • Офис 1. LAN1: 192.168.0.0/24
  • Офис 2. LAN2: 192.168.2.0/24

Задача: обеспечить связь локальных сетей так, чтобы из одной сети можно было “дозвониться” до клиентов другой сети.

1) Настроить мост

На роутере-сервере (офис1):

Включить L2TP сервер

/interface l2tp-server server set enabled=yes

Добавить PPP профиль, который будет использоваться в свойствах учетной записи:

/ppp profile add name=l2tp-bridge only-one=yes use-encryption=yes

Добавим учетную запись:

/ppp secret add name=office2 password=yourpassword local-address=192.168.20.1 remote-address=192.168.20.2 service=l2tp profile=l2tp-bridge

Local-address – это адрес, назначается серверу, а remote-address клиенту. Примечание: адреса должны быть в подсети отличной от LAN1 и LAN2

Создадим интерфейс:

/interface l2tp-server add name=l2tp-in-office2 user=office2

Настройки на роутере-клиенте (офис2)

/interface l2tp-client add name=l2tp-out-office1 connect-to=<IP address> user=office2 password=yourpassword allow=mschap2 disabled=no 

2) Настроить маршруты

Они нужны для того, чтобы клиенты одной сети могли обращаться к клиентам другой сети.

На первом маршрутизаторе:

/ip route add dst-address=192.168.2.0/24 gateway=192.168.20.2 pref-src=192.168.0.1 

На втором:

/ip route add dst-address=192.168.0.0/24 gateway=192.168.20.1 pref-src=192.168.2.1 
  • dst-address – маска удаленной сети (за VPNом)
  • gateway – шлюз доступа к этой сети (VPN адрес удаленного роутера)
  • pref-src – адрес откуда будут идти запросы (локальный адрес маршрутизатора)

Tuning Linux for Snapiness / Responsiveness

Preface

Main causes of low responsiveness are:

  • processor ques
  • I/O ques
  • bad prioritization

Reduce unneccesary I/O

Tune your swappiness and cache pressure settings to avoid page faults when using your foreground applications. It’s a trade-off of performance vs responsiness.

Install The Great Suspender for Chromiun to reduce RAM usage. Or Auto Tab Discard for Firefox. This will reduce the need to use swap. Or (surprise-surprise) buy more RAM.

Use iotop to see if there are processes eating the IO.

Improve scheduling / priotitization

Install the Linux-Zen or Liquorix kernels (depending on your distro) to have access to the better MuQSS process scheduler and BFQ I/O schedulers. If you’re using an SSD you will want to check if you’re using NOOP or Deadline I/O schedulers instead. Also check for TRIM support.

Reduce priority of processes like Dropbox and Tracker (configure them to only run when you are not using the system). It can be done using Ananicy.

Use htop to see if there processes competing for processor time

Links

https://www.akitaonrails.com/2017/01/17/optimizing-linux-for-slow-computers

https://askubuntu.com/questions/126664/why-choose-a-low-latency-kernel-over-a-generic-or-realtime-one

Nextcloud

Move Data Directory

https://help.nextcloud.com/t/howto-change-move-data-directory-after-installation/17170

Tools

Fix permissions

chown -R www-data:www-data /var/www/nextcloud

Scan for file changes

sudo -u www-data php /var/www/nextcloud/occ files:scan --all

Resolving file locks

For anyone having issues with files getting lock while using redis on nextcloud pi. Specially while syncing nodejs apps…

  1. Connect to your redis
    sudo redis-cli -s /var/run/redis/redis.sock
  2. authenticate in your redis with the password for redis found in /var/www/nextcloud/config/config.php
    $> auth “yourpasswordfoundinconfig.php”
    $> flushall
    Your locked files should synchronize now

Convert AVI to MP4

ffmpeg -i input.avi output.mp4                       # Default H.264 codec
ffmpeg -i input.avi -c:v libx265 -c:a aac output.mp4 # Encode video with HEVC and audio with AAC:

FFmpeg options:

-c:a copy        # copy audio without re-encoding
-c:a aac         # convert audio to AAC
-c:v libaom-av1  # video in AV format
-qscale:v N      # Video Quality: N = 1..31 (1 is highest quality)
-qscale:v N      # Audio Quality: N = 1..31 (1 is highest quality)
-strict -2       # turn on experimental features 

Batch Convert

Convert entire folder to MP4

for i in *.avi; do ffmpeg -i "$i" "${i%.*}.mp4"; done

Convert AVI to MP4 – folder with sub-directories:

find . -name "*.avi" -exec sh -c 'f="{}"; ffmpeg -i "$f" "${f%.avi}.mp4"' \;

Links

https://unix.stackexchange.com/questions/35746/encode-with-ffmpeg-using-avi-to-mp4

https://trac.ffmpeg.org/wiki/Encode/H.265