Blog Spot!


GNU/Linux Screen shortcuts

Key bindings from the article. Short version.

Added on 02.Mar.2023
Tags: screen shortcuts linux terminal

Use .htaccess to redirect to URL provided as a query string

When we hit http://domain1.com/?url=domain2.com server must redirect to http://domain2.com/

.htaccess content

RewriteEngine on
RewriteBase /
RewriteCond %{QUERY_STRING} ^url=(.*)$ [NC]
RewriteRule ^$ http://%1? [NC,L,R]

Added on 01.Dec.2022
Tags: htaccess apache URL redirect

Middleware execution variations

middleware is an Array of fn(req, res, next)

Sequential execution

for (const fn of middleware) {
    await new Promise(r => fn(req, res, () => r(true)))
}

Concurrent execution

return Promise.all(middleware.map(fn => {
    return new Promise(resolve => {
        fn(req, res, () => resolve(true));
    })
}));

Added on 23.Nov.2022
Tags: code middleware js quark sequential concurrent

Command to display Memory usage, Disk Usage and CPU Load

#!/bin/sh
free -m | awk 'NR==2{printf "Memory Usage: %s/%sMB (%.2f%%)\n", $3,$2,$3*100/$2 }'
df -h | awk '$NF=="/"{printf "Disk Usage: %d/%dGB (%s)\n", $3,$2,$5}'
top -bn1 | grep load | awk '{printf "CPU Load: %.2f\n", $(NF-2)}' 

Save the above as a script and run it, you will get:

$ ./foo.sh 
Memory Usage: 4986/7994MB (62.37%)
Disk Usage: 23/68GB (35%)
CPU Load: 0.78
  • Note that the script above is giving the disk usage for the / partition.
  • The details may vary depending on the implementation of these tools in the OS.

stackexchange

Added on 17.Aug.2022
Tags: linux load telemetry bash script

Awesome MQTT

A curated list of MQTT related stuff.

hobbyquaker/awesome-mqtt

Added on 14.Aug.2022
Tags: mqtt documents smart-home iot awesome-list

Search


PHP Libraries


Carbon lib / docs
Idiorm lib / docs
Image Workshop lib / docs
lorenzos/Minixed lib / docs
Parsedown lib / docs
PHP Paginator lib / docs
PHP Redis lib / docs
QrCode lib / docs
Requests lib / docs
Slim lib / docs
Spyc lib / docs
TWIG lib / docs
Upload lib / docs
Validation lib / docs
Zebra Image lib / docs

JS Libraries


AJV lib / docs
BackboneJS lib / docs
Bootstrap Notify lib / docs
C3.js lib / docs
ChartJS lib / docs
FastMD5 lib / docs
HighlightJS lib / docs
jQuery-Storage lib / docs
JS-Cookie lib / docs
Leaflet JS lib / docs
LowDB lib / docs
Marked lib / docs
NeedlyJS lib / docs
ParcelJS lib / docs
RequireJS lib / docs
Swig lib / docs
Toastr lib / docs
Underscore lib / docs
ValidateJS lib / docs
top