Latest Posts

Recent Posts

Monday, September 4, 2017

BLOCKCHAIN – THE SOLUTION OF MISTRUST

As a child, my father narrated me a story about two brothers, who used to work in different cities and sent money to their old-age parents living in a village. However, one day the younger brother among the two - under the impression that he would be sending more money than his other brother - started reducing the money being sent to his parents and eventually stopped sending money.

Unaware about his younger brother’s plan, the elder one, due to the same reason as his younger sibling, also started reducing his monthly pay out to parents and brought it down to nil. As money flow reduced, the health of aged parents, who did not have any other source of income and sustained mainly on money sent by their sons, started deteriorating. As days passed, parents’ health deteriorated further leading to their death.

The moral of this story, according to my father, was to not think about others while performing one’s duty and focus solely on the delivery. However, this did not convince me because merely thinking about other’s work should not impact the delivery by a man, who is God’s best creation.

As I grew older and attained knowledge through various means available, it donned on me that the problem was not related to the duty, rather, related to information sharing channel between the two brothers that lead to both brothers deciding to reduce the money being sent. Not just the brothers, but parents also did not have any means to inform their children about the repercussion their act of reducing money not being sent to parents has caused.

In real life too, we come across many such instances, where lack of information leads to mistrust. However in 2009, Satoshi Nakamoto (a person not known to many) designed a system for anonymous fund transfer, popularly known as Bitcoin. This technology guaranteed that the information shared among the users is correct and not tampered with.

The system guaranteed correctness of information by adhering to below principles:


1. All information must have a similar pattern
2. Information is shared among multiple trusted user
3. All the trusted users acts as witness and custodian of the information
4. The group of trusted users is always going to greater than the untrusted user.
5. A collective consciousness mechanism among user for building trust factor

The underlying concept of bitcoin evolved and become Blockchain. Over a period of time Blockchain evolved and many more algorithm were introduce to make conscious among the users like Proof of work, Proof of stake, Delegated Proof of stake et cetera. Based on conscious mechanism, different system were design Bitcoin (Proof of work), Etherium (Proof of stake), Lisk, SHIFT (Delegated Proof of stake).

The brothers would not have started reducing their monthly pay out to their parents, if they had kept transactions between each one of them transparent – the philosophy of bitcoin. Alas! That was not the case with them and they lost their parents. 

In this article, I have thrown some insights on blockchain with a hope it will clear all your doubts.

Keep watching this space for insights on conscious mechanism.

Wednesday, August 30, 2017

Open Source web developer Roadmap

Below you find a set of flow diagrams demonstrating the paths and the technologies that  a person can adopt in order to become a frontend, backend or a devops.
If you think that these can be improved in anyway, please do suggest.
 

:rocket: Introduction


:art: Front-end Roadmap

 The roadmap for front end developer is as below

:alien: Back-end Roadmap

For the backend, personally I would prefer Node.js and PHP 7 for the full time. Plus, I have been experimenting lately with Go and I quite like it. Apart from these, if I have to choose another one, I would go for Ruby. However this is just my personal preference, you can choose any of the shown languages and you will be good.
 

:construction_worker_man: DevOps Roadmap



Tuesday, July 11, 2017

Javascript : Var and Let





-->
var let
The scope of a variable defined with var is function scope or
Declared outside any function, global.
The scope of a variable defined with let is block scope.
Examples
function varandlet() {
var i = 5;
}
console.log(i);
VM131:1 Uncaught ReferenceError: i is not defined at
function varandlet() {
let i = 5;
}
console.log(i);
VM131:1 Uncaught ReferenceError: i is not defined at
function varandlet() {
For(var i=0;i<10 br="" i=""> console.log(i);
}

Varandlet(); // Output = 10; No error here
function varandlet() {
For(let i=0;i<10 br="" i=""> console.log(i);
}

Varandlet();

VM350:1 Uncaught ReferenceError: i is not defined at varandlet (:1:62)
at :1:1
******** LET has block level scope.
{
var o = p = 10;
}
console.log( o);
console.log( p);
// Output
// O = 10
// P = 10
{
let o = p = 10;
}
console.log( o);
console.log( p);
// Output
// Error O is not defined
// P = 10 // In this case P becomes global variable
for (var i = 0; i < 5; ++i) {
setTimeout(function () {
console.log(i); // output '5' 5 times
}, 100);
}

//Output will be five times 5

The settimeout function works in asynchronous way.
Closure in Loop

for (let i = 0; i < 5; ++i) {
SetTimeout(function () {
console.log(i); // output '5' 5 times
}, 100);
}

//Output will be five times 1 2 3 4 5

let in the loop can re-binds it to each iteration of the loop, making sure to re-assign
t the value from the end of the previous loop iteration, so it can be used to
avoid issue with closures.

How to run wordpress on Ubuntu using nginx server



Introduction

WordPress is the most popular CMS (content management system) in the world. It allows you to easily get your site or blog up and running. After installation, you can manage almost everything in an easy web interface.
In this guide, we will go over how to install WordPress on an Ubuntu 14.04 server. For the web server component, we will use nginx, a powerful and efficient web server that has seen wide adoption due to its performance capabilities.

Prerequisites

Before you begin with this guide, there are a few procedures that you should undertake.
First, you will need a non-root user with sudo privileges. You can run through steps 1-4 in the Ubuntu 14.04 initial server setup guide to create this account.
You will also need a LEMP (Linux operating system, Nginx web server, MySQL database, and PHP processing) stack installed and configured on your server. You can learn how to install and set up the necessary components by following our guide on installing a LEMP stack on Ubuntu 14.04 here.
When you have finished with the steps above, you can continue.

Step One — Create a MySQL Database and User for WordPress

The first thing that we need to do to get started with WordPress is to prepare our database.
We have the MySQL database software installed, but we have not created a database for our WordPress information. We also need to create an account that WordPress can use to access the database we will be creating.
We should begin by logging into an interactive session with our MySQL administrative account like this:
mysql
-u root -p
You will be prompted for the password that you chose for the MySQL root account when you installed the software. You will be given a MySQL command prompt.
Now, we can create a separate database that will be used exclusively by our WordPress application. The name is not important, but it should probably be descriptive so that you can easily recognize it. In this guide, we will call our database wordpress:
CREATE
DATABASE wordpress;
Note the semi-colon (;) that ends the MySQL statement. Each MySQL statement must end with one, so double-check that if you are running into issues.
We have a database now, so we are ready to create a user account. We will then hand over control of the database to this new user so that our application can interact with the database. This system of creating a separate database and user for each application helps keep our data separate from other data being stored by MySQL, which is good for security and data management.
For this guide, we'll pick wordpressuser for our account name. We'll assign it a password of passwordto authenticate with. When you are setting up your own configuration, you should select a more secure password:
CREATE
USER wordpressuser@localhost IDENTIFIED
BY 'password';
Now, we have a database and a user, but we haven't established a relationship between the two yet. We need to tell MySQL that our new user can access and control the database. You can do that with this command:
GRANT
ALL PRIVILEGES ON wordpress.* TO
wordpressuser@localhost;
Everything should be configured correctly now. We need to flush the privileges to disk so that our current instance of MySQL knows about the privilege changes we have made:
FLUSH
PRIVILEGES;
Now, exit the MySQL prompt:
exit
Now we are back in our command prompt, ready to move on.

Step Two — Download WordPress to your Server

Next, we need to download the actual WordPress content onto our server. This is available on the WordPress website.
The latest stable version of the application is always given the same URL, which makes this part easy. We want to download the file to our user's home directory:
wget http://wordpress.org/latest.tar.gz

Our application files have been downloaded as a compressed, archived directory structure stored in a file called latest.tar.gz. We can extract the contents by typing:
tar xzvf latest.tar.gz
This will create a directory called wordpress that contains the site files.
We should take this opportunity to download some additional components that our WordPress instance will need. We can get these directly from Ubuntu's software repositories using apt:
sudo apt-get update
sudo apt-get install php5-gd libssh2-php
These two packages allow you to work with images and install/update plugins and components using SSH respectively.

Step Three — Configure WordPress

We have the files now, so we can start to configure our WordPress instance.
We need to modify the main configuration file located in our new directory. Move into the directory that you extracted in the last section:
cd ~/wordpress
Inside of this directory, we have a sample configuration file called wp-config-sample.php. This has most of the configuration details correct, so we can copy that to use as the base of our config file:
cp wp-config-sample.php wp-config.php
When we open the file, our first order of business will be to adjust some secret keys to provide some security for our installation. WordPress provides a secure generator for these values so that you do not have to try to come up with good values on your own. These are only used internally, so it won't hurt usability to have complex, secure values here.
To grab secure values from the WordPress secret key generator, type:
curl -s https://api.wordpress.org/secret-key/1.1/salt/
You will get back unique values that look something like this:
Warning
It is important that you request unique values each time. Do NOT copy the values shown below!
Output
define('AUTH_KEY',  '1jl/vqfsDONOT COPY THESE VALUES c_j{iwqD^<+c9.k
define('SECURE_AUTH_KEY', 'E2N-h2]Dcvp+aS/p7X DO NOT COPY THESE VALUES{Ka(f;rv?Pxf})CgLi-3');
define('LOGGED_IN_KEY',  'W(50,{W^,OPB%PBDO NOT COPY THESE VALUES 2;y&,2m%3]R6DUth[;88');
define('NONCE_KEY',       'll,4UC)7ua+8DO NOT COPY THESE VALUES #`DXF+[$atzM7 o^-C7g');
define('AUTH_SALT',       'koMrurzOA+|L_lG}kf DO NOT COPY THESE VALUES 07VC*Lj*lD&?3w!BT#-');
define('SECURE_AUTH_SALT','p32*p,]z%LZ+pAu:VY DO NOT COPY THESE VALUES C-?y+K0DK_+F|0h{!_xY');
define('LOGGED_IN_SALT',  'i^/G2W7!-1H2OQ+t$3 DO NOT COPY THESE VALUES t6**bRVFSD[Hi])-qS`|');
define('NONCE_SALT',      'Q6]U:K?j4L%Z]}h^q7 DO NOT COPY THESE VALUES 1% ^qUswWgn+6&xqHN&%');

These are configuration lines that we can paste directly in our configuration file to set secure keys. Copy the output you received now.
Now, open the WordPress configuration file:
nano wp-config.php
Find the section that contains the dummy values for those settings. It will look something like this:
/var/www/html/wp-config.php
define('AUTH_KEY',     'put your unique phrase here');
define('SECURE_AUTH_KEY', 'put your unique phrase here');
define('LOGGED_IN_KEY','put your unique phrase here');
define('NONCE_KEY', 'put your unique phrase here');
define('AUTH_SALT','put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT',  'put your unique phrase here');
define('NONCE_SALT',      'put your unique phrase here');
Delete those lines and paste in the values you copied from the command line:
/var/www/html/wp-config.php

define('AUTH_KEY',        'VALUES COPIED FROM THE COMMAND LINE');
define('SECURE_AUTH_KEY', 'VALUES COPIED FROM THE COMMAND LINE');
define('LOGGED_IN_KEY',   'VALUES COPIED FROM THE COMMAND LINE');
define('NONCE_KEY',       'VALUES COPIED FROM THE COMMAND LINE');
define('AUTH_SALT',       'VALUES COPIED FROM THE COMMAND LINE');
define('SECURE_AUTH_SALT','VALUES COPIED FROM THE COMMAND LINE');
define('LOGGED_IN_SALT',  'VALUES COPIED FROM THE COMMAND LINE');
define('NONCE_SALT',      'VALUES COPIED FROM THE COMMAND LINE');

The file is now suitable for our needs; it is just lacking the information to connect to the database we created. The parameters we need to set are DB_NAMEDB_USER, and DB_PASSWORD.
We can find these parameters in this file and set them up to use the database and user details that we created. My file looks like this:
//** MySQL settings - You can get this info from your web host ** //
/**The name of the database for WordPress */
define('DB_NAME','wordpress');
/** MySQL database username */
define('DB_USER', 'wordpressuser');
/** MySQL database password */
define('DB_PASSWORD','password');
When you have made the changes above, save and close the file.

Step Four — Copy the Files to the Document Root

We have our changes to our config files. The next step is to copy them over to our document root so that our web server can find and serve them.
We will use the rsync utility to do the transfer. This has the advantage of preserving permissions, ownership, and ensuring data integrity.
The location of the default document root of nginx on Ubuntu 14.04 is /usr/share/nginx/html/.
However, we are going to set up our document root in /var/www/html/ to avoid modifying a directory location that is controlled by the nginx package. We will change this in our nginx configuration a bit later.
We can create the new document root directory by typing:
sudo mkdir -p /var/www/html
Now, we can copy the files to this location by typing:
sudo rsync -avP ~/wordpress/ /var/www/html/
This will recursively copy the contents of our ~/wordpress directory into our document root.
Next, let's move over to the document root so that we can adjust some permissions:
cd /var/www/html/
The issue with the directory structure as it stands now is that all of our files have user and group ownership assigned to our regular user. This is fine, except that our web server needs to be able to modify certain directories and files.
We can give this permission without exposing too much of our system by giving the group that our web server runs under group ownership of the files. We can then open up group permissions slightly as needed.
The group that nginx operates under is www-data. For the user portion, enter your user account name. We will demonstrate with an account called demo here:
sudo chown -R demo:www-data /var/www/html/*
This will give our files the necessary ownership.
Before we move on, we should create a new directory for user uploads:
mkdir wp-content/uploads
The new directory should have group writing set already, but the new directory isn't assigned with www-data group ownership yet. Let's fix that:
sudo chown -R :www-data /var/www/html/wp-content/uploads

Step Five — Modify Nginx Server Blocks

We have our files and directories configured. Now we need to modify our nginx configuration to serve the content correctly.
We can use the default nginx server block as a base for our new server block. Copy it over like this:
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/wordpress

Open the new file we made so that we can make some changes:
sudo nano /etc/nginx/sites-available/wordpress
We will want to make the following changes:
server
{        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;
       root /var/www/html;
       index index.php index.html index.htm;
       server_name your_domain.com;
       location / {
                #try_files $uri $uri/ =404;
                try_files $uri $uri //index.php?q=$uri&$args;
        }
       error_page 404 /404.html;
       error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root /usr/share/nginx/html;
        }
        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }
}
A summary of changes that you should be making are:
  • Change the value of the root directive to point to our new document root at /var/www/html.
  • Modify the index parameter to look for an index.php file before the other files.
  • Change the value of the server_name directive to point to your server's domain name or IP address.
  • Adjust the try_files within the location / block to send requests to PHP when they do not exactly match.
Some of these might already be set from your LEMP installation. When you are finished with these changes, save and close the file.
We need to link our new file to the sites-enabled directory in order to activate it. We can do that like this:
sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/
The file we just linked conflicts with our old default file, since it borrowed so much from it. We need to disable the old file:
sudo rm /etc/nginx/sites-enabled/default
Now, restart the web server and PHP processor to enable our changes:
sudo service nginx restart
sudo service php5-fpm restart

Step Six — Complete the Installation through the Web Interface

Now, our WordPress is ready to go and we can finish the installation through our web browser.
Point your browser to your server's domain name or IP address, like this:
http://your_domain.com
If this shows your old default nginx page, you may have to refresh the page without the cache.
You will see the basic WordPress welcome stage. Choose your options (Site name, username, password, and email) and then click the "Install WordPress" button:
WordPress install screen
You will have to log in with the account you just created:
WordPress login
You will be presented with your WordPress dashboard, where you can begin customizing your setup and creating content:
 WordPress dashboard

Conclusion

You should now have your WordPress instance up and running on an nginx web server in Ubuntu 14.04. WordPress is a fairly flexible platform that you can use to customize your site. Experiment with some different plugins, themes, etc. to find out what works best for you.
-->