Blog Spot!


Record and play "wav" file in linux terminal

Record: -d duration

arecord -d 5 test-mic.wav

Play:

aplay test-mic.wav

Added on 12.Mar.2017
Tags: linux termina wav

How do you add swap to an EC2 instance or how to make a swap space from file

Paging works by creating an area on your hard drive and using it for extra memory, this memory is much slower than normal memory however much more of it is available.

sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
sudo /sbin/mkswap /var/swap.1
sudo chmod 600 /var/swap.1
sudo /sbin/swapon /var/swap.1

If you need more than 1024 then change that to something higher.

To enable it by default after reboot, add this line to /etc/fstab:

/var/swap.1 swap swap defaults 0 0

stackoverflow

Added on 25.Feb.2017
Tags: swap linux terminal memory

Chmod files/directory only in all subdirectories

find . -type f -exec chmod 644 {} +
find . -type d -exec chmod 744 {} +

Added on 11.Feb.2017
Tags: bash terminal linux chmod

Get actual memory usage as a percent

function memoryUsage(cb) {
    var spawn, proc, str, lines, i, total, free, used;

    spawn = require('child_process').spawn;
    proc  = spawn('free',  ['-m']);

    proc.stdout.setEncoding('utf8');
    proc.stdout.on('data', function (data) {
        str   = data.toString();
        lines = str.split(/\n/g);

        for (i = 0; i < lines.length; i++) {
            lines[i] = lines[i].split(/\s+/);
        }

        total = parseInt(lines[1][1]);
        free  = parseInt(lines[2][2]);
        used  = parseInt(lines[2][3]);
    });

    proc.on('close', function (code) {
        cb({
            unit: "megabytes",
            total: total,
            free: free,
            used: used,
            percent: {
                free: parseInt((free / total * 100))
            }
        });
    });
}

memoryUsage(function(memmory) {
    console.log(memmory);
});

stackoverflow

Added on 31.Jan.2017
Tags: node nodejs js linux

How to get total Read and write IOPS in linux

In Short:

iostat is part of the sysstat package, which is able to show overall iops if desired, or show them separated by reads/writes.

Run iostat with the -d flag to only show the device information page, and -x for detailed information (separate read/write stats). You can specify the device you want information for by simply adding it afterwards on the command line.

Try running iostat -dx and looking at the summary to get a feel for the output. You can also use iostat -dx 1 to show a continuously refreshing output, which is useful for troubleshooting or live monitoring.

More Information unix.stackexchange

Added on 19.Jan.2017
Tags: iops linux benchmark measure

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