MariaDB insert on duplicate key update

May 7, 05:15 AM

it appears that ‘insert on duplicate key update’ will actually create some sort of temporary record then delete it. you can see this in the AUTO_INCREMENT value.

https://mariadb.com/kb/en/insert-on-duplicate-key-update/#:~:text=INSERT%20…,API’s%20CLIENT_FOUND_ROWS%20flag%20is%20set.

DROP TABLE IF EXISTS testTable ;

CREATE TABLE testTable
( nameFirst VARCHAR NOT NULL
, nameLast VARCHAR NOT NULL
, addr VARCHAR NULL
, city VARCHAR NULL
, id INTEGER NOT NULL AUTO_INCREMENT
, UNIQUE KEY (nameFirst, nameLast)
, PRIMARY KEY (id)
);

INSERT INTO testTable SET nameFirst = ‘mark’ , nameLast = ‘edwards’ , addr = ’123 swallow lane’ ;

SELECT * FROM testTable;

INSERT INTO testTable SET nameFirst = ‘pete’ , nameLast = ‘robinson’ , addr = ’246 starling’ , city = ‘oceanside’ ON DUPLICATE KEY UPDATE addr = ’123 swallow lane’ , city = ‘oceanside, ca’ ;

SELECT * FROM testTable;

INSERT INTO testTable SET nameFirst = ‘pete’ , nameLast = ‘robinson’ , addr = ’246 starling’ , city = ‘oceanside’ ON DUPLICATE KEY UPDATE city=‘oceanside, ca’ ;

SELECT * FROM testTable;

INSERT INTO testTable SET nameFirst = ‘lori’, nameLast=‘edwards’, addr = ’948 south third’ ON DUPLICATE KEY UPDATE addr = ’123 swallow ln’, city=‘oceanside’ ;

SELECT * FROM mark ;

INSERT INTO testTable SET nameFirst = ‘lori’, nameLast=‘edwards’, addr = ’948 south third’ ON DUPLICATE KEY UPDATE addr = ’123 swallow ln’, city=‘oceanside’ ;

SELECT * FROM testTable ;

INSERT INTO testTable SET nameFirst = ‘marky’, nameLast=‘edwards’, addr = ’123 swallow lane’ ON DUPLICATE KEY UPDATE addr = ’123 swallow lane’, city=‘oceanside, ca’ ;

SELECT * FROM testTable ;

Mark Edwards

,

---

t o r r e n t s on rocky linux 8

May 3, 06:25 AM

easiest to install: qbittorrent:

dnf install epel-release ;
dnf —assumeyes install qbittorrent ;
dnf —assumeyes install qt5-qtsvg ;
dnf —assumeyes install qbittorrent-nox ;
/usr/bin/qbittorrent-nox —webui-port=12345 ; ## this also gives you the default username/password

https://www.qbittorrent.org/

written from: https://www.linuxbabe.com/redhat/install-qbittorrent-centos-8-rhel-8#comment-961469

second easiest: deluge (but this requires snap)

https://deluge-torrent.org/
https://idroot.us/install-deluge-bittorrent-client-centos-8/ (very helpful)
https://www.linuxhelp.com/how-to-install-deluge-in-centos

could not get installed: ruTorrent

this requires some packages that are no longer available on rocky-linux 8
Mark Edwards

,

---

Installing WordPress with SELinux issue

Feb 28, 04:53 AM

REPLACED WITH: https://github.com/edwardsmarkf/selinux-wordpress

## 2023-02-28
## apparently when SELinux was introduced, it caused serious WP installation issues. these steps get around that without
## resorting to setting /etc/selinux/config “SELINUX=permissive”

## written from: https://www.tecmint.com/install-wordpress-rhel-apache/

dnf —assumeyes update ;

dnf —assumeyes install wget unzip ;

dnf —assumeyes install mariadb-server ;
dnf —assumeyes install httpd ;

## php 7.4 installation

dnf —assumeyes install http://rpms.remirepo.net/enterprise/remi-release-8.rpm ;
dnf —assumeyes module reset php ;
dnf —assumeyes module enable php:remi-7.4 ;

dnf —assumeyes install php-fpm php-cli php-common php-zip php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json php-pdo php-mysql ;

systemctl enable —now mariadb.service ; ## —now is a new feature that MIGHT not work!
systemctl start mariadb.service ;

systemctl enable —now httpd.service ;
systemctl start httpd.service ;

systemctl enable —now php-fpm.service ;
systemctl start php-fpm.service ;

mysql —verbose <<END ; CREATE DATABASE `wpDb`; GRANT ALL ON `wpDb`.* TO ‘wpUser’@‘localhost’ IDENTIFIED BY ‘wpPassword’; FLUSH PRIVILEGES;
END

  1. to test:
    mysql —user=wpUser —password=wpPassword wpDb < SHOW databases;
    SELECT VERSION;
    exit
    END

cd /var/www/html ;

firewall-cmd —zone=public —permanent —add-service=http ; firewall-cmd —reload ;

echo ‘‘ > phpinfo.php ; ## visit http://IP#/phpinfo.php to test

wget https://wordpress.org/latest.zip ;
unzip /var/www/html/latest.zip ;

mv —verbose ./wordpress/* /var/www/html/ ;
rmdir —verbose ./wordpress ;

/usr/bin/chown —recursive —verbose apache:apache /var/www/html/ ; ## omitted wordpress
/usr/bin/chcon —recursive —verbose —type=httpd_sys_rw_content_t /var/www/html/ ;

find /var/www/html -type d -exec chmod —verbose 755 {} ; ; find /var/www/html -type f -exec chmod —verbose 644 {} ; ;

/usr/sbin/semanage fcontext —add —type httpd_sys_rw_content_t “/var/www/html(/.*)?” ;
/usr/sbin/restorecon -R -v /var/www/html/ ;

echo “rebooting – be sure to go to http:/###.###.###.###/ and install wordpress!” ; /usr/sbin/shutdown —reboot now ;

Mark Edwards

,

---

jscript debounce

Feb 21, 05:20 AM

========================================

2022-03-09: better example from https://www.freecodecamp.org/news/javascript-debounce-example/

=================

Debounce?!
A recent increasing popular technique in web applications is an interestng one. It is so called “debounce”. Debouncing in JavaScript is used to limit the rate at which a function can fire. It works by delaying the execution of a function until a certain amount of time has passed without it being called. This can be useful in cases where a function is called multiple times in a short period of time, such as when a user is typing into an input field, and you only want to perform an action after they have finished typing.

A real world analogy
A real world analogy of debounce is to a physical button, once is pressed, it remains in the pressed state (.e.g stays in the housing socket) for a number period of time, during which cannot be pressed again since it is already in pressed down position, before it “bounces” back that can be pressed again.

Javascript implementation
To implement debouncing in JavaScript, you can use a function that sets a timer whenever it is called. If the function is called again before the timer has expired, the timer is cleared and reset, delaying the execution of the function until the timer has expired.

Here is an example of a debounced function in JavaScript:

function debounce(fn, delay) { let timer; return function() { clearTimeout(timer); timer = setTimeout(() => { fn.apply(this, arguments); }, delay); };
}​
In this example, we have a debounce function that takes two arguments: a callback function fn and a delay time delay. It returns a new function that sets a timer whenever it is called, and calls the callback function only if the timer has expired and no further calls have been made to the returned function.

You can use this debounced function as a wrapper for any function that you want to limit the rate of execution.

const debouncedFunction = debounce(myFunction, 1000);​

This code creates a new debounced function that calls the myFunction once per second at most.

Mark Edwards

,

---

easy port test with optional webserver

Jan 23, 05:49 AM

## easy port test:

## ON SERVER:

dnf —assumeyes install nmap ; ## in case this has not yet been installed! systemctl stop firewalld.service ; ## or make the particular port available! ls -l | /usr/bin/ncat —listen 10000 ; date | /usr/bin/ncat —listen 3030 ;

<>

  1. https://www.cyberciti.biz/faq/unix-linux-check-if-port-is-in-use-command/
    lsof -i -P -n | grep LISTEN ; ## make sure ports are listening
    netstat -tulpn | grep LISTEN ; ## another way to make sure ports are listening

## ON CLIENT:

telnet 123.123.123.123 10000 ; ## should give us the directory (or date) and then the ncat command on the server STOPS

## working fake webserver test:

https://jameshfisher.com/2018/12/31/how-to-make-a-webserver-with-netcat-nc/

these did NOT work for me:

(this one requires ‘screen’ whatever that is)
https://support.cpanel.net/hc/en-us/articles/4403282341143-How-to-use-ncat-netcat-as-a-mini-webserver-to-diagnose-network-connectivity-related-issues

https://stackoverflow.com/questions/16640054/minimal-web-server-using-netcat

Mark Edwards

,

---

« Older Newer »

Manage