Skip to content

Instantly share code, notes, and snippets.

View asamofal's full-sized avatar
🇺🇦

Anton Samofal asamofal

🇺🇦
View GitHub Profile
@asamofal
asamofal / schema_redundant_indexes.sql
Created October 16, 2023 21:59
[MySQL] Get redundant indexes
SELECT
RI.table_schema,
RI.table_name,
ROUND(IIS.stat_value * @@innodb_page_size / 1024 / 1024, 2) redundant_index_size_in_mb,
RI.redundant_index_name,
RI.redundant_index_columns,
RI.redundant_index_non_unique,
RI.dominant_index_name,
RI.dominant_index_columns,
RI.dominant_index_non_unique,
@asamofal
asamofal / Download apt repository key as gpg
Last active May 21, 2022 09:38
[gpg] Download PUBKEY and use it in Ubuntu
1. Import key from the keyserver to local registry of gpg.
gpg --keyserver keyserver.ubuntu.com --recv-keys KEY_ID
2.Export key to gpg file.
gpg -a --export KEY_ID | gpg --dearmor > key.gpg
3. To add a key to keyrings for APT - move gpg file to /etc/apt/trusted.gpg.d
sudo mv key.gpg /etc/apt/trusted.gpg/APP_NAME.gpg
sudo chown root:root /etc/apt/trusted.gpg/APP_NAME.gpg
@asamofal
asamofal / Clone MySQL instance with Clone plugin
Created June 2, 2021 10:33
MySQL 8.0.17 Clone Plugin: How to Create a Slave from Scratch
# https://www.percona.com/blog/2019/08/01/mysql-8-0-17-clone-plugin-how-to-create-a-slave-from-scratch/
# install clone plugin (on both instances)
INSTALL PLUGIN clone SONAME 'mysql_clone.so';
# check if plugin is active (on both instances)
SELECT
PLUGIN_NAME,
PLUGIN_STATUS
FROM INFORMATION_SCHEMA.PLUGINS
@asamofal
asamofal / update_bions_lenovo_x1_g6.md
Created April 18, 2020 21:50
Update BIOS on ThinkPad X1 Carbon Gen 6th (Ubuntu 18.04, Legacy mode)

Update BIOS on ThinkPad X1 Carbon Gen 6th (Ubuntu 18.04)

Laptop (ThinkPad) Lenovo X1 Carbon 6th Gen (Type 20KH, 20KG)

If you are using your ThinkPad X1G6 with Linux in "Legacy only" mode, there's only one way how to update BIOS - you should use "BIOS Update (Bootable CD)". So this is a step by step guid how to do it.

Check current BIOS version:

fwupdmgr get-devices

@asamofal
asamofal / nginx.conf
Last active December 9, 2019 11:32 — forked from VirtuBox/ssl.conf
Nginx SSL/TLS configuration with TLSv1.2 and TLSv1.3 - ECDHE and strong ciphers suite (Openssl 1.1.1)
https://angristan.xyz/how-to-enable-tls-13-nginx/
##
# SSL Settings (TLSv1.2 and TLSv1.3)
##
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-256-GCM-SHA384:TLS13-AES-128-GCM-SHA256:EECDH+CHACHA20:EECDH+AESGCM;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:50m;
@asamofal
asamofal / Install php-fpm & all required extensions for Laravel 6.x
Created October 24, 2019 14:51
Install php-fpm & all required extensions for Laravel 6.x
add-apt-repository ppa:ondrej/php
apt install php7.3-fpm php7.3-curl php7.3-mbstring php7.3-xml -y
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-left "[]"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-right "[]"
Settings -> Keyboard:
Disable shortcut for "Lunch terminal"
Add new shortcut:
command: gnome-terminal --geometry=110x34+450+200
MySQL lets you specify which timezone to use in the my.cnf file, using the following config line:
default-time-zone=Europe/Oslo
However, you might find, after you do this, that it ends up failing to restart the service with the following error in the logs:
Fatal error: Illegal or unknown default time zone
Obviously Europe/London is a valid timezone name, so why does it not work?
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://nginx.org/packages/keys/nginx_signing.key | sudo gpg --dearmor -o /etc/apt/keyrings/nginx.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/nginx.gpg] http://nginx.org/packages/ubuntu \
$(lsb_release -cs) nginx" | sudo tee /etc/apt/sources.list.d/nginx.list > /dev/null
sudo apt update
sudo apt install nginx
nginx -v