Tuesday, June 20, 2017

how to fix Got error 'this version of PCRE is compiled without UTF support at offset 0' from regexp

on mysql error:
how to fix Got error 'this version of PCRE is compiled without UTF support at offset 0' from regexp

fix:
1.
install aclocal-1.15 from
https://github.com/gp187/nginx-builder/blob/master/fix/aclocal.sh
2.
./configure --prefix=/opt/lampp --enable-utf8 --enable-unicode-properties && make
make install

install automake 1.15 using aclocal.sh

#!/bin/bash

# run as root only
if [[ $EUID -ne 0 ]] ; then
    echo -e "\e[1;39m[   \e[31mError\e[39m   ] need root access to run this script\e[0;39m"
    exit 1
fi

function install_automake() {
    [ $# -eq 0 ] && { run_error "Usage: install_automake <version>"; exit; }
    local VERSION=${1}
    wget ftp://ftp.gnu.org/gnu/automake/automake-${VERSION}.tar.gz &> /dev/null
    if [ -f "automake-${VERSION}.tar.gz" ]; then
            tar -xzf automake-${VERSION}.tar.gz
            cd automake-${VERSION}/
            ./configure
            make && make install
            echo -e "\e[1;39m[   \e[1;32mOK\e[39m   ] automake-${VERSION} installed\e[0;39m"

        else
            echo -e "\e[1;39m[   \e[31mError\e[39m   ] cannot fetch file from ftp://ftp.gnu.org/gnu/automake/ \e[0;39m"
            exit 1
    fi
}
install_automake 1.15

Monday, June 19, 2017

create database , user , grant privileges and import in mysql

CREATE DATABASE mydb
  DEFAULT CHARACTER SET utf8
  DEFAULT COLLATE utf8_general_ci;

CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON DbName.* TO 'newuser'@'localhost' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON DbName.* TO 'newuser'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
SHOW GRANT FOR 'newuser'@'localhost';
or
DROP USER ‘demo’@‘localhost’;

>mysql -u root -p database_name < database.sql

Tuesday, April 4, 2017

angular example for todo list using form ng-submit

<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body ng-app="myApp" ng-controller="todoCtrl">

<h2>My Todo List</h2>

<form ng-submit="todoAdd()">
    <input type="text" ng-model="todoInput" size="50" placeholder="Add New">
    <input type="submit" value="Add New">
</form>

<br>

<div ng-repeat="x in todoList">
    <input type="checkbox" ng-model="x.done"> <span ng-bind="x.todoText"></span>
</div>

<p><button ng-click="remove()">Remove marked</button></p>

<script>
var app = angular.module('myApp', []);
app.controller('todoCtrl', function($scope) {
    $scope.todoList = [{todoText:'Clean House', done:false}];

    $scope.todoAdd = function() {
        $scope.todoList.push({todoText:$scope.todoInput, done:false});
        $scope.todoInput = "";
    };

    $scope.remove = function() {
        var oldList = $scope.todoList;
        $scope.todoList = [];
        angular.forEach(oldList, function(x) {
            if (!x.done) $scope.todoList.push(x);
        });
    };
});
</script>

</body>
</html>