Archive for January 2018

Java Convert Integer to String

String.valueOf(Integer);

Simple JSON

$data[’message’] = ‘Simple Message’; $data[’status’] = ‘success’;   header(’Content-Type: application/json’); echo json_encode($data);

Abstract class – is something between a regular class and a pure interface. The purpose of this is to provide a kind of template to inherit from and to force the inheriting class to implement the abstract methods. Interface – is a special case of abstract classes where ALL methods are abstract.

Grep show next or previous line when for matched value

Show next line after matched line grep -A1 searchpattern filename Show next 2 lines after matched line grep -A2 searchpattern filename Show previous line after matched line grep -B1 searchpattern filename

CREATE COPY OF THE TABLE WITH INDEXES

CREATE TABLE newtable LIKE oldtable;

MySQL Iterate method WHILE

CREATE PROCEDURE example1() label1:BEGIN DECLARE rowCount INT DEFAULT 0; DECLARE i INT DEFAULT 0;   SELECT COUNT(*) INTO rowCount FROM my_table;   WHILE (i <= rowCount) DO   SELECT i;   SET i = i+1000; END WHILE; END;

MySQL Iterate method REPEAT

The difference with WHILE is that it execute statement before checking the condition. As a result, it iterates one more time than WHILE does. CREATE PROCEDURE example2() label1:BEGIN DECLARE rowCount INT DEFAULT 0; DECLARE i INT DEFAULT 0;   SELECT COUNT(*) INTO rowCount FROM my_table;   REPEAT   SELECT i;   SET i = i+1000; […]