Postgresql generated columns

Stored create table example ( id bigint generated always as identity, a integer , b integer , c integer GENERATED ALWAYS AS (CASE WHEN ((a IS NOT NULL) AND (b IS NOT NULL) AND (b > 0)) THEN floor(((a / b))::double precision) ELSE NULL::double precision END) STORED ) create table example ( id bigint generated […] →Czytaj dalej

MySQL 8 Group Replication

SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE Command NOT LIKE 'Sleep' AND USER != 'system user'; SELECT * FROM performance_schema.replication_group_members; SELECT * FROM performance_schema.replication_group_member_stats; SELECT * FROM performance_schema.replication_connection_status; SELECT * FROM performance_schema.replication_applier_status_by_worker; SELECT * FROM performance_schema.replication_applier_status_by_coordinator; SELECT * FROM performance_schema.replication_applier_status; →Czytaj dalej

Merge two videos into one

Horizontal: ffmpeg -i left.mp4 -i right.mp4 -filter_complex hstack output.mp4 Vertical ffmpeg -i left.mp4 -i right.mp4 -filter_complex vstack output.mp4 →Czytaj dalej

MySQL Blackhole engine

show engines; INSTALL PLUGIN blackhole SONAME 'ha_blackhole.so'; SELECT @@sql_mode; SET @@sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'; – disabled engine blackhole SET @@sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO'; – enabled engine blackhole create table table_name ( column_1 int null ) engine='BLACKHOLE'; alter table table_name engine='BLACKHOLE'; →Czytaj dalej

Postgresql – partitoned tables

CREATE TABLE "tbl" ( "id" bigint NOT NULL GENERATED ALWAYS AS IDENTITY, "user_id" bigint NOT NULL, "date" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, ) PARTITION BY HASH (user_id); CREATE TABLE tbl_p01 PARTITION OF tbl FOR VALUES WITH (MODULUS 4, REMAINDER 0); CREATE TABLE tbl_p02 PARTITION OF tbl FOR VALUES WITH (MODULUS 4, REMAINDER 1); CREATE TABLE […] →Czytaj dalej

Unbuffered pipe stream

unbuffer -p ./a | tee output.txt tdbuf –output=L ./a | tee output.txt →Czytaj dalej

Verify max USB speed

$ lsusb -t /: Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 10000M $ sudo lshw | grep -A 10 -i usb configuration: driver=hub slots=4 speed=10000Mbit/s →Czytaj dalej

Docker host IP from inside container

version: '3.7' services: xxxx: image: yyyy command: ping host.docker.internal extra_hosts: – host.docker.internal:host-gateway →Czytaj dalej

MySQL – grants

Show grants for user: SHOW GRANTS FOR user@'%' Grant privileves for user: GRANT ALL PRIVILEGES ON *.* to user@'%' Grant privileves for user with allow set grants: GRANT ALL PRIVILEGES ON *.* to user@'%' WITH GRANT OPTION →Czytaj dalej

Allow Virtualbox mount usb on linux

sudo usermod -aG vboxusers $USER →Czytaj dalej