Blog Spot!


Make meld work as git diff tool

~/.gitconfig

[diff]
    external = /usr/local/bin/git-diff.sh
    tool = meld
[merge]
    tool = meld
[push]
    default = simple

/usr/local/bin/git-diff.sh

#!/bin/bash
meld "$2" "$5" > /dev/null 2>&1

..then use git diff HEAD

Added on 12.Jan.2018
Tags: meld git diff tool

Extending a Linux File System after Resizing the Volume

Expand the modified partition using growpart.

1: sudo growpart /dev/xvdf 1

Use a file system-specific command to resize each file system to the new volume capacity.

For a Linux ext2, ext3, or ext4 file system, use the following command, substituting the device name to extend:

2: sudo resize2fs /dev/xvdf1

full docs.aws

Added on 07.Nov.2017
Tags: amazon aws volume expanded resize linux hdd disk

Calculate percentage

((input - min) * 100) / (max - min)

stackoverflow

Added on 06.Nov.2017
Tags: percentage min max % avarage

Dependency injection container in JavaScript

Good article

Singleton DI Container in JS

var container = {

  dependencies: {},

  register: function(key, value) {
    this.dependencies[key] = value;
  },

  resolve: function(deps, func, scope) {
    scope = scope || {}; scope.container = {};

    for (var i = 0; i < deps.length; i++) {
      scope.container[deps[i]] = this.get(deps[i]);
    }

    return function() {
      func.apply(scope || {}, Array.prototype.slice.call(arguments, 0));
    };
  },

  get: function(dependency) {
    if (this.dependencies[dependency]) {
      return this.dependencies[dependency];
    }
    throw new Error('Unable to find dependency ' + dependency);
  }
};

How to use:

container.register('service', function() {
  return { name: 'Service' };
});

container.register('router', function() {
  return { name: 'Router' };
});

// adding dependencies when registrating dependency
container.register('test', function() {
  this.service = container.get('service');
  console.log(this.service().name === 'Service');
  return 'yo';
});

var start = container.resolve(['service', 'router', 'test'], function(other) {

  try {
    console.log(this.container.service().name === 'Service');
    console.log(this.container.router().name === 'Router');

    console.log(this.container.test());
    console.log('DONE');

  } catch (ex) {
    console.log(ex);
  }
});

start("Other");

Added on 18.Oct.2017
Tags: di dependency injection js

Get total read and total write IOPS in Linux

iostat -d <disk_name> | grep <disk_name> | awk '{ print $2; }' - avarage IOPS

iostat -dx <disk_name> | grep <disk_name> | awk '{ print $4; }' - Reads/sec

iostat -dx <disk_name> | grep <disk_name> | awk '{ print $5; }' - Writes/sec

unix.stackexchange

Added on 14.Sep.2017
Tags: iostat iops reads writes statistics

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