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
- 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 ;
========================================
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.
## Easy Port Testing
## ON SERVER:
dnf --assumeyes install nmap net-tools ; ## 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 ;
<
>
- 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:
just type cmd, and enter ‘telnet’ – this may be necessary: Enable telnet on windows-11 and REBOOT — 2024-10-01
telnet 123.123.123.123 10000 ; ## should give us the directory (or date) and then the ncat command on the server STOPS
- NOTICE ONLY ONE SPACE BETWEEN IP ## and PORT ### !! (this might just be a m$ thing)
## 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
settings (but not working quite yet)
185.242.5.91 (185.242.5.90 / Protocol: TCP / OpenVpn Port: 443 / OpenConnect Port: 22)
Mark (185.242.5.91 / Protocol: UDP / OpenVpn Port: 443 / OpenConnect Port: 22)
Instructions to run feathers completely from console, no coding!
IMPORTANT: open up a new tab “about:blank”
Click to open a new
about:blank page.
Load the libraries
/* load in libraries */
[ 'https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.4/socket.io.js'
, 'https://unpkg.com/@feathersjs/client@^3.0.0/dist/feathers.js'
].forEach( (src) => {
let script = document.createElement('script');
// script.setAttribute('crossOrigin', 'anonymous' ); /* optional */
script.src = src;
// script.type = 'javascript'; /*optional */
script.src = src;
script.async = false;
document.head.appendChild(script); // or document.getElementsByTagName('script')[0];
});
alternative method:
/usr/bin/cat <<END | ncat --listen 80 ;
<!DOCTYPE html>
<html lang="en-us">
<head>
<script src='https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.4/socket.io.js'></script>
<script src='https://unpkg.com/@feathersjs/client@^3.0.0/dist/feathers.js'></script>
</head>
<body>
fake webserver page. include extra jScript code in the console.
</body>
</html>
END
initialize constants
/* initialize constants */
const app = feathers();
const socket = io(); /* defaults to: const socket = io('ws://localhost:3030'); */
const socket = io('ws://###.###.###.###:3030'); /*if we need to connect to different host */
app.configure(feathers.socketio(socket)); /* PLEASE dont skip this one!! */
/* -- or -- */
app.configure(feathers.socketio(io('ws://###.###.###.###:3030'))); /* just combine the last two lines */
create(POST)
/* create(
POST) */
async function createTiny(name, address) {
let createResult
= await app.service(‘tiny-connect’).create({ name: name, address: address });
console.log(‘createTiny function result: ‘ + JSON.stringify(createResult) );
return createResult;
};
createTiny(‘Mark Edwards’, ’123 Swallow Lane’).then((value) => { /* create(POST) */
console.log(‘createTiny: ‘ + JSON.stringify(value));
})
get(GET) just one using the primary index
/* get(GET) (just one by index) */
async function getTiny(id) { return await app.service(‘tiny-connect’).get(id); };
—- or —-
async function getTiny(id) {
let getResult = await app.service(‘tiny-connect’).get(id);
console.log(‘getTiny function: ‘ + JSON.stringify(getResult) );
return getResult;
};
let getTinyResult = null; let key = 1; // assuming your row ID is one
getTiny(key).then( value => { /* get(GET) */
getTinyResult = value;
console.log(‘getTiny(’ + key + ‘) : ‘ + JSON.stringify(getTinyResult) );
});
/* one line test: */
(async () => { try { let result = await app.service(‘stimword’).get(1) ; console.log(‘the result is: ‘ + JSON.stringify(result)) } catch (e) { console.log(e); } } )() ;
/* or: */
(async () => { let logoutResult = await app.service(‘stimword’).get(2); console.log(logoutResult); })().catch(e => { console.log(e) });
find(GET) all or by query
/* find(GET) (get all or by query) */
async function findTiny(query) {
return await app.service(‘tiny-connect’).find(query);
};
async function findTiny(query) {
console.log(‘Query function using: ‘ + JSON.stringify(query) );
let findResult = await app.service(‘tiny-connect’).find(query);
console.log(‘findTiny function: ‘ + JSON.stringify(findResult) );
return findResult;
};
let findTinyResultAll;
findTiny(null).then((value) => { /* find(GET) (find all) */
findTinyResultAll = value;
console.log(‘findTiny without query: ‘ + JSON.stringify(findTinyResultAll) );
});
let findTinyResultOne; let findDataObject = { ‘query’ :{ id: 0}}; // again, assuming your id is zero!
findTiny(findDataObject).then((value) => { /* find(GET) (with data ) */
findTinyResultOne = value;
console.log(‘findTiny with query: ‘ + JSON.stringify(findTinyResultOne) );
});
/* shortcut examples: */
(async () => { try { let result = await app.service(‘stimword’).find() ; console.log(‘the result is: ‘ + JSON.stringify(result)) } catch (e) { console.log(e); } } ) () ;
(async () => { try { let result = await app.service(‘stimword’).find({‘query’:{‘stimwordWord’:‘horse’}}) ; console.log(‘the result is: ‘ + JSON.stringify(result)) } catch (e) { console.log(e); } } ) () ;
Accessing a KNEX RAW selecxt
SELECT JSON_ARRAYAGG(
JSON_OBJECT(
..........
)
) 'JSON_ARRAYAGG'
.....................................
const result = await knex.raw( sqlStatement, sqlQuery);
return result[0][0].JSON_ARRAYAGG ;
...................................
var newResult;
(async () => { try { let result = await app.service('raw-service').find({query: sqlQuery}) ; newResult = result; } catch (e) { console.log(e); } } )() ;
console.log(JSON.parse(newResult));
patch(PATCH) to update row(s)
/* patch(PATCH) */
async function patchTiny(id, data, params) { /* patch(PATCH) */
let patchResult = await app.service(‘tiny-connect’).patch(id, data, params);
console.log(‘patchTiny function: ‘ + JSON.stringify(patchResult) );
return patchResult;
};
let patchResult = null; let patchKey = 0; let patchData = {address: ’5678 There Street!’ };
patchTiny(patchKey, patchData ).then( value => { /* patch(PATCH) */
patchResult = value;
console.log(‘patchResult: ‘ + JSON.stringify(patchResult));
});
combine create and insert into one promise
async function clientMasterCreate(query) {
return await app.service(‘client-master’).create(query);
};
async function clientMasterFind(query) {
return await app.service(‘client-master’).find( { ‘query’ : query } );
};
clientMasterObj = { ‘layoutName’ : ‘PESL’
, ‘teacherEmail’ : ‘info@englishwithoutaccent.com’
, ‘teacherAutoIncr’ : 385
, ‘clientMasterEmail’ : ‘12yukos@gmail.comX’
};
clientMasterFind(clientMasterObj)
.then( (clientMasterRow) => {
return clientMasterRow
})
.then( (clientMasterRow) => {
if ( clientMasterRow.data.length == 0 ) {
return clientMasterCreate(clientMasterObj)
.then( (clientMasterRow) => {
console.log(‘inserting: ‘ + clientMasterRow.clientMasterAutoIncr );
return clientMasterRow.clientMasterAutoIncr;
})
} else {
return clientMasterRow.data[clientMasterRow.data.length-1].clientMasterAutoIncr;
}
})
.then ((result) => {
console.log(‘clientMasterAutoIncr: ‘ + result)
});