Blog Spot!


Issue: Updated to PHP7 but now cannot install phpMyAdmin

Under Ubuntu 16.04 this helps:

$ sudo apt-get install php7.0-cli php-seclib php-gettext php7.0-mbstring

Added on 21.Apr.2016
Tags: phpmyadmin php7 php

Arc Is a Gorgeous GTK Theme for Linux Desktops

Arc is a flat theme with a subtle color scheme and transparency in select parts of the window, like GTK Header Bars and the Nautilus sidebar.

The Arc theme supports GTK3 and GTK2 based desktop environments, including GNOME Shell (of course) and the standard Ubuntu Unity desktop.

It also works just dandy with lightweight Budgie and elementary’s Pantheon desktops and should work fine on Cinnamon.

arc-gtk-theme

Added on 14.Apr.2016
Tags: linux theme style

NodeJS MySQL connection pattern

example:

// Variable Initialization, in order of appearance.
var mysql, connOptions01, connOptions02,  dbm, app;

// MySQL Module
mysql = require('mysql');

// MySQL Connections
connOptions01 = {
    host: "127.0.0.1",
    user: "test",
    password: "qwerty",
    database: "test",
    dateStrings: true,
    // trace: true,
    // debug: true
};

connOptions02 = {
    host: "127.0.0.1",
    user: "test",
    password: "qwerty",
    database: "test",
    dateStrings: true,
    // trace: true,
    // debug: true
};

dbm = {};

function handleMysqlDisconnect01() {
    clearInterval(dbm.interval);

    dbm.dbc01 = false;
    dbm.dbm01 = mysql.createConnection(connOptions01);

    try {
        dbm.dbm01.connect(function(err) {              
            if(err) {
                console.log('error: ' + err.stack);
                setTimeout(handleMysqlDisconnect01, 2000);
                return;
            } 
            console.log('app mysql connection id:' + dbm.dbm01.threadId);
            dbm.dbc01 = true;
        });

        dbm.dbm01.on('error', function(err) {
            console.log('error stack: ' + err.stack);
            console.log('error code: ' + err.code);

            if(err.code === 'PROTOCOL_CONNECTION_LOST') {
                handleMysqlDisconnect01();
            } else {
                throw err;
            }
        });

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

function handleMysqlDisconnect02() {
    clearInterval(dbm.interval);

    dbm.dbc02 = false;
    dbm.dbm02 = mysql.createConnection(connOptions02);

    try {
        dbm.dbm02.connect(function(err) {              
            if(err) {
                console.log('error: ' + err.stack);
                setTimeout(handleMysqlDisconnect02, 2000); 
                return;
            }
            console.log('app mysql connection id:' + dbm.dbm02.threadId);
            dbm.dbc02 = true;
        });

        dbm.dbm02.on('error', function(err) {
            console.log('error stack: ' + err.stack);
            console.log('error code: ' + err.code);

            if(err.code === 'PROTOCOL_CONNECTION_LOST') {
                handleMysqlDisconnect02();
            } else {
                throw err;
            }
        });

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

dbm.getMysqlConnection = function() {
    return {
        dbm01:dbm.dbm01,
        dbm02:dbm.dbm02
    };
};

dbm.setapp = function(theapp) {
    app = theapp;

    // MySQL initialize connections
    handleMysqlDisconnect01();
    handleMysqlDisconnect02();
};

module.exports = dbm;

use dbm.getMysqlConnection() to get access to the connection handler!

full example

Added on 13.Apr.2016
Tags: node nodejs js mysql connection pattern

Dump redis database into redis commands or json with redis-dump

We need this package redis-dump

then:

# export
$ redis-dump > dump.txt
$ redis-dump --json > mydb.json

# import
$ cat dump.txt | redis-cli
$ cat mydb.json | redis-dump --convert | redis-cli

!!! for best result always import raw commands

# convert form json
cat mydb.json | redis-dump --convert > mydb.txt

# import
cat mydb.txt | redis-cli

Added on 12.Apr.2016
Tags: redis dump json database

Backup and Restore MySQL Database Using mysqldump

mysqldump is an effective tool to backup MySQL database. It creates a *.sql file with DROP table, CREATE table and INSERT into sql-statements of the source database. To restore the database, execute the *.sql file on destination database. For MyISAM, use mysqlhotcopy method that we explained earlier, as it is faster for MyISAM tables.

backup:

$ mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql

restore:

$ mysql -u root -p[root_password] [database_name] < dumpfilename.sql

full tutorial

MySQL Database Export - Backup Methods:
tutorialspoint


gzip backup:

$ mysqldump -u root -p[root_password] [database_name] | gzip > dump.sql.gz

gzip restore:

$ zcat dump.sql.gz | mysql -u root -p[database_name]

Added on 12.Apr.2016
Tags: sql mysql mysqldump backup restore

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