LATEST ARTICLES

How to fix error: 504 Gateway Time-out on Nginx

Sometimes, you get the error: 504 Gateway Time-out on Nginx like this figure, how to fix it. This is simple. You edit the file .conf like /etc/nginx/conf.d/default.conf, you will see the content like: server { listen 80; server_name localhost; root /var/www/html; ...

How to create OAuth client ID and client secret for Google APIs

Step 1: log into your Google account then go to the website: https://console.developers.google.com/projectselector/apis/credentials Step 2: Click on the blue button "Create a project". Step 3: click on the button "CREATE". Wait a few seconds then you see the screen: Click on the blue button "Create credentials", you will see 4 options to choose. Step 4: Click on the option: "OAuth client ID", now...

Edge detection with PHP

We do some example with this image : http://static.asiawebdirect.com/m/bangkok/portals/vietnam/homepage/hanoi/pagePropertiesImage/hanoi-guide.jpg Method 1: <?php function detect_edge($input) { $in_im = imagecreatefromjpeg($input); $gx = array(array(-1, 0, 1), array(-2, 0, 2), array(-1, 0, 1)); $gy = array(array(-1, -2, -1), array(0, 0, 0), array(1, 2, 1)); $x = imagesx($in_im); $y = imagesy($in_im); ...

How to create transparent image with PHP

Method 1: use imagecolorallocatealpha and imagesavealpha <?php $width = 200; $height = 200; // create the output image. $img=imagecreatetruecolor( $width, $height ); // Allocate a transparent color and fill the new image with it. // Without this the image will have a black background instead of being transparent. $transparent = imagecolorallocatealpha( $img, 0, 0, 0, 127 ); imagefill( $img, 0, 0, $transparent );...

PHP: how to get content of many websites in the same time

The solution is CURL, this is powerful tool to do it. Here's the plain example, you can know how to get content of many websites in the same time: <?php $contents = array(); $u = 'http://demo.tutorialspots.com/curl/get1.php'; $u2 = 'http://demo.tutorialspots.com/curl/get2.php'; $u3 = 'http://demo.tutorialspots.com/curl/get3.php'; $u4 = 'http://demo.tutorialspots.com/curl/get4.php'; // array of URLs $arURLs = array($u, $u2, $u3, $u4); // init the curl Multi $multi_handles = curl_multi_init(); // create an array...

How to change Mysql root password

Step 1: mysql -u root -p Result: # mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 6 Server version: 5.7.16 Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or 'h' for...

How to know the default root password of MYSQL 5.7

After the installation MySQL-community-server 5.7 on linux, you will need to find the default root password. How to know it? You can find the password you need at /var/log/mysqld.log Or you can use the command: cat /var/log/mysqld.log|grep "A temporary password is generated for" Result: # cat /var/log/mysqld.log|grep "A temporary password is generated for" 2016-11-06T16:12:21.171890Z 1 A temporary password is generated for root@ localhost: oB&Vl>cdm7Fq You can see...

How to install MYSQL on Centos

Step 1: download RMP file, for Centos 6.x 64bits, you can use file: http://repo.mysql.com/yum/mysql-5.7-community/el/6/x86_64/mysql57-community-release-el6-7.noarch.rpm Depend on version of CentOS, you can find your file at here wget http://repo.mysql.com/yum/mysql-5.7-community/el/6/x86_64/mysql57-community-release-el6-7.noarch.rpm Result: # wget http://repo.mysql.com/yum/mysql-5.7-community/e l/6/x86_64/mysql57-community-release-el6-7.noarch.rpm --2016-11-06 15:59:00-- http://repo.mysql.com/yum/mysql-5.7-community/el/6/x86_ 64/mysql57-community-release-el6-7.noarch.rpm Resolving repo.mysql.com... 23.219.134.205 Connecting to repo.mysql.com|23.219.134.205|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 8848 (8.6K) Saving to: `mysql57-community-release-el6-7.noarch.rpm' 100% 8,848 --.-K/s in 0s 2016-11-06...

How to install and use ForeverJS on CentOS

We can install ForeverJS on CentOS with npm command: npm install -g forever Result: # npm install -g forever npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue npm WARN optional dep failed, continuing fsevents@1.0.14 /usr/bin/forever -> /usr/lib/node_modules/forever/bin/forever forever@0.15.2 /usr/lib/node_modules/forever ├── path-is-absolute@1.0.1 ├── object-assign@3.0.0 ├── clone@1.0.2 ├── colors@0.6.2 ├── timespan@2.3.0 ├── nssocket@0.5.3 (eventemitter2@0.4.14, lazy@1.0.11) ├── cliff@0.1.10 (eyes@0.1.8, colors@1.0.3) ├── optimist@0.6.1 (wordwrap@0.0.3, minimist@0.0.10) ├── prettyjson@1.1.3 (colors@1.1.2, minimist@1.2.0) ├── winston@0.8.3...

How to install NodeJS on Centos

In this tutorial, we use Centos 6.8 64bits. Step 1: Install NodeJS v4: curl --silent --location https://rpm.nodesource.com/setup_4.x | bash - Result: # curl --silent --location https://rpm.nodesource.com/setup_4.x | bash - ## Installing the NodeSource Node.js v4.x LTS Argon repo... ## Inspecting system... + rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release | | rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release + uname -m ## Confirming "el6-x86_64" is supported... + curl...