1120Setting Memory/Buffer Bool for MariaDB

  • OS: Ubuntu
  • DB: MariaDB

innodb_buffer_pool_size defaults to 128M which might not be enought if you have a big database.

MariaDB Documentation: Configure the InnoDB Buffer Pool Size

0. Log in with root via SSH

1. Check Buffer Size

mysql
mysql>
MariaDB>SHOW VARIABLES LIKE 'innodb_buffer_pool_size';

+-------------------------+-----------+
| Variable_name           | Value     |
+-------------------------+-----------+
| innodb_buffer_pool_size | 134217728 |
+-------------------------+-----------+
1 row in set (0.001 sec)

That's 128M default. 128 * 1024 * 1024

2. Add a MariaDB configuration file

cd /etc/mysql/mariadb.conf.d
ls -l

-rw-r--r-- 1 root root  575 Feb 19 00:56 50-client.cnf
-rw-r--r-- 1 root root  231 Feb 19 00:56 50-mysql-clients.cnf
-rw-r--r-- 1 root root  927 Feb 19 00:56 50-mysqld_safe.cnf
-rw-r--r-- 1 root root 3769 Feb 19 00:56 50-server.cnf
-rw-r--r-- 1 root root  570 Feb 19 00:56 60-galera.cnf

nano z-custom-mariadb.cnf

[mysqld]
innodb_buffer_pool_size=2G

3. Restart DB Server

sudo systemctl restart mariadb

Troubleshooting

Q. I updated the value, but the value is not changed on the server.
A. Check that your configuration file ends in .cnf and not in .conf - otherwise it won't be read.

1118Minimal Multilang

Language Switcher

EN JA AT

Language Divs

This is content is English.
このコンテンツは日本語です。

State saved in Cookie

Try to change the language and reload the page.
<style>
a        {color: #00f; background: #fff; text-decoration: none; }
a:hover  { color: #fff; background: #00f; }
a:active { color: #00f; background: #00f;}
.active { color: #000; background: #ff0;}
.hidden { display: none; }
</style>

<script>
// Supported languages, first is default
const languages = ['en', 'ja', 'at']

// Read activeLang from Cookie OR init with 'en'
var activeLang = document.cookie.split("; ").find((row) => row.startsWith("lang="))?.split("=")[1] || languages[0];

// Set activeLang & Cookie
function setLang(l) {
  document.cookie = `lang=${l}`
  activeLang = l
  showLang(l)
}

// Show/hide all elements with activeLang class
const languageClasses = languages.map(e=>'.'+e)
const languageIDs = languages.map(e=>'#'+e)
function showLang(l) {
  document.querySelectorAll(languageIDs).forEach(e => e.classList.remove('active'))
  document.querySelectorAll('#'+l).forEach(e => e.classList.add('active'))
  document.querySelectorAll(languageClasses).forEach(e => e.classList.add('hidden'))
  document.querySelectorAll('.'+l).forEach(e => e.classList.remove('hidden'))
}

// Document Ready
document.addEventListener("DOMContentLoaded", (e) => {
  showLang(activeLang)
})
</script>

<div id="lang">
 <a href="" onClick="setLang('ja');return false" id="ja">JA</a>
 <a href="" onClick="setLang('en');return false" id="en">EN</a>
 <a href="" onClick="setLang('at');return false" id="at">AT</a>
</div>

11177z as a Compression/Decompression Utility

7z is an alternative to zip

Create an archive a montior compression progress:

7z a archive.zip my-folder/

a stands for add

Snapshot of the compression progress:

7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=C,Utf16=off,HugeFiles=on,64 bits,1 CPU QEMU Virtual CPU version 1.0 (623),ASM)

Scanning the drive:
1004 folders, 136557 files, 6612288441 bytes (6306 MiB)                        

Creating archive: archive.zip

Items to compress: 137561

 98% 133273 + file/ . /01/12345.jpg   

7z also give you a nice ensurance, that everything is OK, when it's done.

Files read from disk: 136557
Archive size: 6118548821 bytes (5836 MiB)
Everything is Ok

1116Enables SSH/SFTP Access via Plesk

When setting a up a new server via Plesk on a Debian System, one of the first tasks is to enable SSH/SFTP users.

By default & security SSH permissions are off.

ssh user@host.name
Permission denied (publickey).

To change that, log into the server as su - via the Plesk SSH Interface - and update the settings in /etc/ssh/sshd_config

Also a good idea to make a backup, before changing anyting.

cd /etc/ssh/
cp sshd_config sshd_config.back

Change PasswordAuthentication and KbdInteractiveAuthentication to yes

nano sshd_config
...
# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication yes
#PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
KbdInteractiveAuthentication yes
...

The SSH daemon/service needs to be restarted:

sudo systemctl restart ssh

SSH/SFTP log-in should now work!

1093Exporting Participant Data from Zoom

1. Log into your Zoom account and select Reports from the left menu, and then the Usage link from the tabs.

2. Set the report duration.

A list of meetings will be displayed. The Participants column is a link. Click that link.

3. A modal window with more information about the Meeting Participants will be displayed.

4. Check the checkboxes Export with meeting data and Show unique users

5. Click Export

6. A CSV File with the Participant Meeting data will be downloaded.

Stray Observations

  • Particiants can change their name, the orginal name is also exported.
  • When Participants are forced to log-in, their email becomes their ID. Email addresses of participants are neither recorded or shared.

1092Renaming wp-content Directory

In wp-config.php add:


define('WP_CONTENT_FOLDERNAME', 'my_new_content_folder');
define('WP_CONTENT_DIR', ABSPATH . WP_CONTENT_FOLDERNAME);
define('WP_CONTENT_URL', 'https://' . $_SERVER['HTTP_HOST'] . '/' . WP_CONTENT_FOLDERNAME);

Source: https://developer.wordpress.org/advanced-administration/wordpress/wp-config/#moving-wp-content-folder

1088chmod recursive needs capital -R

Changing permissions recursively with chmod:

chmod -R 755 path_to_folder
Works

chmod --recursive 755 path_to_folder
Works

chmod -r 755 path_to_folder
DOES NOT WORK chmod: cannot access '755': No such file or directory

From man chmod:

The perm symbols represent the portions of the mode bits as follows:
r The read bits.

The op symbols represent the operation performed, as follows: - If no value is supplied for perm, the ``-'' operation has no effect. If no value is supplied for who, each permission bit specified in perm, for which the corresponding bit in the file mode creation mask is set, is cleared. Otherwise, the mode bits represented by the specified who and perm values are cleared.

Therefore -r tries to remove the read bits from directory 755, which obviously does not exist and therefore throws an error.

1087screen – Quick Overview

The screen terminal utility allows for the continous running of terminal jobs - even when the user is logged out:

  1. Start a new session with screen.
  2. Dettach screen: control-a, d
  3. List all screens: screen -list
  4. Re-attach screen: screen -r
  • Remove dead screen: screen -wipe

Use case: WP-CLI

1085Tailwind Utility Scripts

Instead of yyping the whole Tailwind command, here are some small scripts:

tailwind_watch

npx tailwindcss -i ./styles/input.css -o ./styles/output.css --watch

tailwind_build

npx tailwindcss -i ./styles/input.css -o ./styles/output.css --build

tailwind_minify

npx tailwindcss -i ./styles/input.css -o ./styles/output.css --minify

Make scripts exectuable with chmod +x scriptname.

Calling the scripts:

./tailwind_watch
./tailwind_build
./tailwind_minify

1082array_merge behaves differently in PHP 7 and PHP 8

The array_merge function produces unexpected results on a PHP 8 server, as compared to a PHP 7 server.

$output = array_merge($array1, $array2);

In PHP 8, if array2 is empty, the $output array is also empty.

In PHP 7, if array2 is empty, the $output array is $array1.

TODO

  • [ ] Make test page.