Blog Spot!


Simple vanilla JavaScript ajax

function ajaxGet(url, cb){
    var req = new XMLHttpRequest();

    req.onload = function() {
        cb(req.status, req.response);
    };

    req.open("GET", url);
    req.send();
}

ajaxGet('https://httpbin.org/get', function(status, res) {
    console.log(status , JSON.parse(res));
})

Added on 23.Jul.2018
Tags: ajax js vanilla javascript simple

Delete files older than X days

stackoverflow

find is the common tool for this kind of task:

find ./my_dir -mtime +10 -type f -delete

EXPLANATIONS

  • ./my_dir your directory (replace with your own)
  • -mtime +10 older than 10 days
  • -type f only files
  • -delete no surprise. Remove it to test your find filter before executing the whole command!

And take care that ./my_dir exists to avoid bad surprises!

Added on 19.Jun.2018
Tags: bash shell terminal linux delete logs files

Laravel Equivalent In JavaScript - as of 2017

We have 3 major JavaScript alternatives to Laravel:

article

Added on 06.Jun.2018
Tags: js javascipt laravel mvc framework

Enable SSH after fresh Apache2 or LAMP install

To achieve this, ssl module has to be enabled and apache needs to be told, how to handle traffic from port 443, this is done by enabling default-ssl site.

$ sudo a2enmod ssl
$ sudo a2ensite default-ssl
$ sudo service apache2 restart

Firewall

If you have firewall enabled, you should allow incoming TCP connection on port 443.

$ sudo ufw allow 443/tcp

article

Added on 11.May.2018
Tags: apache ssh server linux ssl

Limit swap wear

Linux's inclination to use the swap, is determined by a setting. The lower the setting number, the more system load is required before your Linux starts using the swap.

On a scale of 0-100, the default setting is 60. Which is much too high for normal desktop use, and only fit for servers. For SSD's, it's just crazy.

A detailed explanation can be found here (link dead? Then download this PDF file with the same content).

Now the how-to:

a. Check your current swappiness setting. Type in the terminal (use copy/paste):

cat /proc/sys/vm/swappiness

Press Enter.

The result will probably be 60.

b. Now type in the terminal (use copy/paste):

sudo xed /etc/sysctl.conf

Press Enter.

c. Add the following blue lines, at the very end of the existing text in that file (use copy/paste to avoid errors):

# Sharply reduce the inclination to swap
vm.swappiness=1

d. Save the file and close it. -> reboot

Taken from section Limit swap wear in here

Added on 27.Apr.2018
Tags: linux swap swappiness

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