Blog Spot!


Terminal Command To Get Geeky Weather Reports

Weather Reports

curl -4 http://wttr.in/CityName

Help

curl -4 http://wttr.in/:help

fossbytes

Added on 22.Feb.2016
Tags: weather terminal fun

Test website RPS (requests per second)

How to benchmark your server.

Install apache2-utils

$ sudo apt-get install apache2-utils

Example test:

$ ab -kc 1000 -n 10000 http://www.some-site.cc/tmp/index.php
  • k Use HTTP KeepAlive feature
  • c concurrency Number of multiple requests to make at a time
  • n requests Number of requests to perform

package
benchmark

Added on 19.Feb.2016
Tags: test apache request responce ab rps

PDO Tutorial for MySQL Developers

Added on 18.Feb.2016
Tags: php mysql pdo database tutorial

Test for Empty Values in Javascript

Our JavaScript function is far more precise about what kinds of data can be considered empty:

  • undefined or null
  • a zero-length string
  • an array with no members
  • an object with no enumerable properties
function isEmpty(data) {
    if (typeof(data) == 'number' || typeof(data) == 'boolean') { 
        return false; 
    }

    if (typeof(data) == 'undefined' || data === null) {
        return true; 
    }

    if (typeof(data.length) != 'undefined') {
        return data.length === 0;
    }

    var count = 0, i;
    for (i in data) {

        if(data.hasOwnProperty(i)) {
            count ++;
        }
    }

    return count === 0;
}

sitepoint

Added on 10.Feb.2016
Tags: js function empty

Javascript setInterval - A better implementation

function interval(func, wait, times){
    var interv = function(w, t){
        return function(){
            if(typeof t === "undefined" || t-- > 0){
                setTimeout(interv, w);
                try{
                    func.call(null);
                }
                catch(e){
                    t = 0;
                    throw e.toString();
                }
            }
        };
    }(wait, times);

    setTimeout(interv, wait);
}

The interval function has an internal function called interv which gets invoked automatically via setTimeout, within interv is a closure that checks the the repetition times, invokes the callback and invokes interv again via setTimeout. In case an exception bubbles up from the callback call the interval calling will stop and the exception will be thrown.

This pattern does not guarantee execution on a fixed interval of course, yet it does guarantee that the previous interval has completed before recursing, which I think is much more important.

Usage

interval(function(){
    // Code block goes here
}, 1000, 10);

So to execute a piece of code 5 times with an interval or 10 seconds between each you would do something like this:

thecodeship

Added on 05.Feb.2016
Tags: js function setInterval

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