1134Folder Actions in macOS

Folder Actions are the hidden superpowert in macOS. They are triggered when files are added to a folder, they then can execute an action.

The Action can be written in Automator, AppleScript or Javascript.

They are great for repetitive actions.

Problem: I have a Google Sheet that I am exporting as CSV, which in turn is used to contruct a table within Hugo. Downloading the CSV from Sheets puts it on the Desktop.

This action checks the Desktop, if it finds the file, it moves it.

Writing the Action in Automator

Filter Finder Items makes sure only the desired files are affected.

Setting up Folder Action

  • Select your Folder
  • Right-click and say Services -> Folder Actions Setup...

Choose a Script to attach.

Now whenever a file matching the criteria is added to the folder, the Folder Action is executed.

1132Hugo – Minimal Breadcrumbs

A minimal version of breadcrumbs in Hugo, using linkTitle:

{{- range .Ancestors.Reverse }}
  <a href="{{ .RelPermalink }}">{{ if .IsHome }}{{ "Home" }}{{ else }}{{ .LinkTitle }}{{ end }}</a> →
{{- end }}
  <a class="current" href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>

Even more minimal:

{{- range .Ancestors.Reverse }}
  <a href="{{ .RelPermalink }}">{{ .LinkTitle }}{{ end }}</a> →
  <a class="current" href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>

For this to work, make sure to add linkTitle to the FrontMatter:

+++
title     = 'Really long and winding title'
linkTitle = 'short'
draft     = false
+++

...

If linkTitle is not present, title is used instead.

1128is_int & is_numeric and in PHP

is_int returns true only if the variable is an integer.

If you want to check is a variable has a numeric value, use is_numeric.


$a = 123;
$b = "123;

is_int($a); // true
is_int($b); // false

is_numeric($a); // true
is_numeric($b); // false

1126Downloading a Website from archive.org

Sometimes it is necessary to download an archival copy of a complete website, luckily https://web.archive.org crawls the interwebs regularly. Unluckily there is no direct way to download a whole website directly.

One tool that facilitates this is the aptley named Wayback Machine Downloader:

Usage

wayback_machine_downloader https://example.com

I have been running into some issues with the original version:

Downloading https://www.example.com to websites/www.example.com/ 
from Wayback Machine archives.

Getting snapshot pages../Users/abc/.rbenv/versions/3.1.1/lib/
ruby/3.1.0/open-uri.rb:364: in `open_http': 400 BAD REQUEST
(OpenURI::HTTPError)
...

This fork is working:

wayback_machine_downloader https://example.com

Downloading https://example.com to websites/example.com/
from Wayback Machine archives.
Getting snapshot pages from Wayback Machine API...
.. found 6350 snapshots.
Saved snapshot list to websites/example.com/.cdx.json
...

If you want to download only to a certain timestamp, use the --to switch:

wayback_machine_downloader --to 20241231235959 https://example.com

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

Example CSV output

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. Email addresses of participants are shared if the participants are in the same Zoom organisation.

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