Thursday, 10 August 2017

BINARY TREE ALL IN ONE



A binary tree is either empty or consists of a node called the root together with two binary trees called the left subtree and the right subtree.
        root
     /       \
  left      right
 /    \      /  \

SOME FACTS:

  • If h = height of a binary tree,
  • max # of leaves = 2h
  • max # of nodes = 2h + 1 – 1
  • Total number of binary trees having n nodes
    • = number of stack-realizable permutations of length n
    • = number of well-formed parentheses (with n left parentheses and n right parentheses)
    • =(1/n+1)(2n C n) [Catalan Number]A binary tree with height h and 2h + 1 – 1 nodes (or 2h leaves) is called a full binary tree
  • A binary tree with n nodes is said to be complete if it contains all the first n nodes of the following numbering scheme
        1
    /      \
    2      3
    / \     /
    4  5  6
  • .Following is not complete binary tree
       4
    /   \
    2     7
    / \     \
    1   3     9
  • In a (balanced) binary tree with m nodes, moving from one level to the next requires one comparison, and there are log_2(m) levels, for a total of log_2(m) comparisons.
  • In contrast, an n-ary tree will require log_2(n) comparisons (using a binary search) to move to the next level. Since there are log_n(m) total levels, the search will require log_2(n)*log_n(m) = log_2(m) comparisons total. So, though n-ary trees are more complex, they provide no advantage in terms of total comparisons necessary.
  • The reason that binary trees are used more often than n-ary trees for searching is that n-ary trees are more complex, but usually provide no real speed advantage.

BINARY TREE TRAVERSAL:

1. Preorder
Visit root, visit left subtree in preorder, visit right subtree in preorder
2. Postorder
Visit left subtree in postorder, right subtree in postorder, then the root
3. Inorder
Visit left subtree in inorder, then the root, then the right subtree in inorder
<strong>Example 1:</strong>
 1
  /    \
2       3

Pre: 123 (root, left, right)
In : 213 (left, root, right)
Post : 231 (left, right, root)
<strong>Example 2 :</strong>
1
  \
   2
      \
        3

Pre: 123 (root, left, right)
In : 123 (left, root, right)
Post : 321 (left, right, root)

PROGRAMMING PERSPECTIVE

A binary tree is a structure comprising nodes, where each node has the following 3 components:
  1. Data element: Stores any kind of data in the node
  2. Left pointer: Points to the tree on the left side of node
  3. Right pointer: Points to the tree on the right side of the node
As the name suggests, the data element stores any kind of data in the node.
The left and right pointers point to binary trees on the left and right side of the node respectively.
If a tree is empty, it is represented by a null pointer.
Commonly-used terminologies
  • Root: Top node in a tree
  • Child: Nodes that are next to each other and connected downwards
  • Parent: Converse notion of child
  • Siblings: Nodes with the same parent
  • Descendant: Node reachable by repeated proceeding from parent to child
  • Ancestor: Node reachable by repeated proceeding from child to parent.
  • Leaf: Node with no children
  • Internal node: Node with at least one child
  • External node: Node with no children

BINARY TREE JAVA IMPLEMENTATION :/*
 *  Binary Tree Java Implementation
 *  Includes tree traversal. (Preorder, Postorder, Inorder)
 */

 import java.util.Scanner;

 /* Class BTNode */
 class BTNode
 {  
     BTNode left, right;
     int data;

     /* Constructor */
     public BTNode()
     {
         left = null;
         right = null;
         data = 0;
     }
     /* Constructor */
     public BTNode(int n)
     {
         left = null;
         right = null;
         data = n;
     }
     /* Function to set left node */
     public void setLeft(BTNode n)
     {
         left = n;
     }
     /* Function to set right node */
     public void setRight(BTNode n)
     {
         right = n;
     }
     /* Function to get left node */
     public BTNode getLeft()
     {
         return left;
     }
     /* Function to get right node */
     public BTNode getRight()
     {
         return right;
     }
     /* Function to set data to node */
     public void setData(int d)
     {
         data = d;
     }
     /* Function to get data from node */
     public int getData()
     {
         return data;
     }    
 }

 /* Class BT */
 class BT
 {
     private BTNode root;

     /* Constructor */
     public BT()
     {
         root = null;
     }
     /* Function to check if tree is empty */
     public boolean isEmpty()
     {
         return root == null;
     }
     /* Functions to insert data */
     public void insert(int data)
     {
         root = insert(root, data);
     }
     /* Function to insert data recursively */
     private BTNode insert(BTNode node, int data)
     {
         if (node == null)
             node = new BTNode(data);
         else
         {
             if (node.getRight() == null)
                 node.right = insert(node.right, data);
             else
                 node.left = insert(node.left, data);            
         }
         return node;
     }    
     /* Function to count number of nodes */
     public int countNodes()
     {
         return countNodes(root);
     }
     /* Function to count number of nodes recursively */
     private int countNodes(BTNode r)
     {
         if (r == null)
             return 0;
         else
         {
             int l = 1;
             l += countNodes(r.getLeft());
             l += countNodes(r.getRight());
             return l;
         }
     }
     /* Function to search for an element */
     public boolean search(int val)
     {
         return search(root, val);
     }
     /* Function to search for an element recursively */
     private boolean search(BTNode r, int val)
     {
         if (r.getData() == val)
             return true;
         if (r.getLeft() != null)
             if (search(r.getLeft(), val))
                 return true;
         if (r.getRight() != null)
             if (search(r.getRight(), val))
                 return true;
         return false;        
     }
     /* Function for inorder traversal */
     public void inorder()
     {
         inorder(root);
     }
     private void inorder(BTNode r)
     {
         if (r != null)
         {
             inorder(r.getLeft());
             System.out.print(r.getData() +" ");
             inorder(r.getRight());
         }
     }
     /* Function for preorder traversal */
     public void preorder()
     {
         preorder(root);
     }
     private void preorder(BTNode r)
     {
         if (r != null)
         {
             System.out.print(r.getData() +" ");
             preorder(r.getLeft());            
             preorder(r.getRight());
         }
     }
     /* Function for postorder traversal */
     public void postorder()
     {
         postorder(root);
     }
     private void postorder(BTNode r)
     {
         if (r != null)
         {
             postorder(r.getLeft());            
             postorder(r.getRight());
             System.out.print(r.getData() +" ");
         }
     }    
 }

 /* Class BinaryTree */
 public class BinaryTree
 {
     public static void main(String[] args)
    {          
        Scanner scan = new Scanner(System.in);
        /* Creating object of BT */
        BT bt = new BT();
        /*  Perform tree operations  */
        System.out.println("Binary Tree Test\n");        
        char ch;      
        do  
        {
            System.out.println("\nBinary Tree Operations\n");
            System.out.println("1. insert ");
            System.out.println("2. search");
            System.out.println("3. count nodes");
            System.out.println("4. check empty");

            int choice = scan.nextInt();          
            switch (choice)
            {
            case 1 :
                System.out.println("Enter integer element to insert");
                bt.insert( scan.nextInt() );                    
                break;                        
            case 2 :
                System.out.println("Enter integer element to search");
                System.out.println("Search result : "+ bt.search( scan.nextInt() ));
                break;                                        
            case 3 :
                System.out.println("Nodes = "+ bt.countNodes());
                break;    
            case 4 :
                System.out.println("Empty status = "+ bt.isEmpty());
                break;          
            default :
                System.out.println("Wrong Entry \n ");
                break;  
            }
            /*  Display tree  */
            System.out.print("\nPost order : ");
            bt.postorder();
            System.out.print("\nPre order : ");
            bt.preorder();
            System.out.print("\nIn order : ");
            bt.inorder();

            System.out.println("\n\nDo you want to continue (Type y or n) \n");
            ch = scan.next().charAt(0);                      
        } while (ch == 'Y'|| ch == 'y');              
    }
 }

APPLICATIONS OF BINARY TREES

  • Binary Search Tree – Used in many search applications where data is constantly entering/leaving, such as the map and set objects in many languages’ libraries. These are a data structure in which searching, insertion, and removal are all very fast (about log(n) operations).
  • Binary Space Partition – Used in almost every 3D video game to determine what objects need to be rendered.
  • Binary Tries – Used in almost every high-bandwidth router for storing router-tables.
  • Hash Trees – used in p2p programs and specialized image-signatures in which a hash needs to be verified, but the whole file is not available.
  • Heaps – Used in implementing efficient priority-queues, which in turn are used for scheduling processes in many operating systems, Quality-of-Service in routers, and A* (path-finding algorithm used in AI applications, including robotics and video games). Also used in heap-sort.
  • Huffman Coding Tree – used in compression algorithms, such as those used by the .jpeg and .mp3 file-formats.
  • GGM Trees – Used in cryptographic applications to generate a tree of pseudo-random numbers.
  • Syntax Tree – Constructed by compilers and (implicitly) calculators to parse expressions.
  • Treap – Randomized data structure used in wireless networking and memory allocation.
  • T-tree – Though most databases use some form of B-tree to store data on the drive, databases which keep all (most) their data in memory often use T-trees to do so.
  • a Manipulate hierarchical data
  • Make information easy to search (see tree traversal)
  • Manipulate sorted lists of data
  • Use as a workflow for compositing digital images for visual effects
  • Use in router algorithms

An Adventure in InnoDB Table Compression (for read-only tables)



In my last post about big MySQL deployments, I am quickly mentioning that InnoDB compression is allowing dividing disk usage by about 4.3 on a 200+ TiB dataset.  In this post, I will give more information about this specific use case of InnoDB table compression and I will share some statistics and learnings on this system and subject.  Note that I am not covering InnoDB page compression which is a new feature of MySQL 5.7 (also known as hole punching).

Before talking about the results, I will describe the system where I have implemented InnoDB compression and give the following warning:
The compression statistics shared here are from a very specific system.
Take them with a grain of salt and test to see how compression benefits your systems.
The system where I implemented InnoDB table compression contains more than one million read-only tables.  Some time ago, those tables were stored in a single MySQL instance, without using InnoDB compression (the size was 200+ TiB) and without using MySQL replication.  The storage was external (disk array accessed via a SAN) and was supporting snapshots.  At the very beginning, the amount of data (and tables) was much smaller, it slowly grew to its current size and it is still growing.  Because administration was becoming tedious, the system was sharded on servers with local storage and replication was used for redundancy.  To reduce the number of shards needed to store all this data, I implemented InnoDB table compression.

One particularity of this system is that the data arrives in MySQL in chunks (tables) that are never updated after being stored (after being fully written, the tables are read-only).  In the new sharded system, the data is written on the master in an InnoDB tables (non-compressed) and it reaches slaves via classical MySQL replication.  Once the table is fully written, a cron job running on all nodes of the replication hierarchy compresses the data locally (not writing to binary logs).

The compression script is trying many KEY_BLOCK_SIZE for finding the one resulting in the smallest footprint on disk.  The script works as follows for each table to compress:
  1. it copies the table twice in a temporary schema (let's call those copies A and B),
  2. it compresses table B with KEY_BLOCK_SIZE of 8,
  3. if compression does not succeed, it keeps table A then exits,
  4. if table B (just compressed) is larger than table A, it keeps table A then exits,
  5. it swaps tables A and B,
  6. it goes back to step #2 using KEY_BLOCK_SIZE of 4, 2 and 1.
The compression script stores the compression state of a table and the resulting sizes of each step in a log table having following structure:
> show create table compression_logs\G
*************************** 1. row ***************************
       Table: compression_logs
Create Table: CREATE TABLE `compression_logs` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `schema_name` varchar(64) NOT NULL,
  `table_name` varchar(64) NOT NULL,
  `initial_size` bigint(20) unsigned NOT NULL,
  `state` enum([...]) NOT NULL,
  `copied_size` bigint(20) unsigned DEFAULT NULL,
  `kbs_8_size` bigint(20) unsigned DEFAULT NULL,
  `kbs_4_size` bigint(20) unsigned DEFAULT NULL,
  `kbs_2_size` bigint(20) unsigned DEFAULT NULL,
  `kbs_1_size` bigint(20) unsigned DEFAULT NULL,
  `final_size` bigint(20) unsigned DEFAULT NULL,
  `final_kbs` tinyint(4) DEFAULT NULL
  PRIMARY KEY (`id`)
) ENGINE=InnoDB
1 row in set (0.03 sec)
Note that finding the size on disk of an InnoDB table is not straightforward.  Looking at the size of the ibd file (ls, du or stat) does not work as some data might still be in the Buffer Pool (not yet flushed to disk).  Also, the output of SHOW TABLE STATUS or the content of information_schema.TABLEonly shows an approximation of the data and index lengths.  I used the command FLUSH TABLES ... FOR EXPORT for solving that.  Below is an extract from the manual, which is exactly what we need to be able to use ls, du or stat for getting the table size:
[FLUSH TABLES ... FOR EXPORT] ensures that changes to the named tables have been flushed to disk so that binary table copies can be made while the server is running.
I will come back later below to compression failing and to table size going the wrong direction (growing instead of shrinking after compression).  Now, let's look at the compression statistics.  For this post, I am only looking at a single shard of the new system (I am assuming that all shards have similar behavior).  The query below gives a good overview of the InnoDB table compression benefits on the amount of data on disk:
> SELECT nb_tables, initial_gib, final_gib,
    ->   ROUND(initial_gib/final_gib, 2) AS ratio
    -> FROM (SELECT COUNT(*) AS nb_tables,
    ->              ROUND(SUM(initial_size) / POW(2,30), 2) AS initial_gib,
    ->              ROUND(SUM(final_size)   / POW(2,30), 2) AS final_gib
    ->       FROM compression_logs) AS c;
+-----------+-------------+-----------+-------+
| nb_tables | initial_gib | final_gib | ratio |
+-----------+-------------+-----------+-------+
|    248670 |    20701.84 |   4566.50 |  4.53 |
+-----------+-------------+-----------+-------+
1 row in set (0.14 sec)
What we have here is a very respectable MySQL instance:
  • it contains 248,670 tables,
  • uncompressed, those tables would use 20.21 TiB of disk space,
  • after compression, those tables are using 4.45 TiB of disk space,
  • and the average compression ratio is 4.53.
The results above have been obtained with the default value of innodb_compression_level (6).  Using the highest value (9) might give better results in the general case but the tests I did on that system do not show significant improvements (I might share more about that in another post).  So I kept the default for all the shards of this system.

An average compression ratio of 4.53 is very good but it might vary for different KEY_BLOCK_SIZE.  Let's look at more detailed data with this query (a final_kbs of 16 means no compression):
> SELECT final_kbs, nb_tables, initial_gib, final_gib,
    ->   ROUND(initial_gib/final_gib, 2) AS ratio
    -> FROM (SELECT final_kbs, COUNT(final_kbs) AS nb_tables,
    ->              ROUND(SUM(initial_size) / POW(2,30), 2) AS initial_gib,
    ->              ROUND(SUM(final_size)   / POW(2,30), 2) AS final_gib
    ->       FROM compression_logs GROUP BY final_kbs) AS c;
+-----------+-----------+-------------+-----------+-------+
| final_kbs | nb_tables | initial_gib | final_gib | ratio |
+-----------+-----------+-------------+-----------+-------+
|         1 |     40863 |     1940.72 |    265.15 |  7.32 |
|         2 |    152215 |    14937.60 |   3033.26 |  4.92 |
|         4 |     38862 |     3387.78 |   1048.73 |  3.23 |
|         8 |     13896 |      434.14 |    217.76 |  1.99 |
|        16 |      2834 |        1.60 |      1.60 |  1.00 |
+-----------+-----------+-------------+-----------+-------+
5 rows in set (0.23 sec)
As we see above, we end-up with tables of all KEY_BLOCK_SIZE/final_kbs but at this point, we do not know if compression stopped because ALTER is failing or because the table size grew with the next KEY_BLOCK_SIZE.  The query below is telling us when the next KEY_BLOCK_SIZE resulted in a bigger table:
> SELECT final_kbs, COUNT(final_kbs) AS nb_tables,
    ->   ROUND(SUM(initial_size)         / POW(2,30), 2) AS initial_gib,
    ->   ROUND(SUM(final_size)           / POW(2,30), 2) AS final_gib,
    ->   ROUND(SUM(next_size-final_size) / POW(2,30), 2) AS diff_gib
    -> FROM (SELECT final_kbs, initial_size, final_size,
    ->              CASE final_kbs WHEN 16 THEN kbs_8_size
    ->                             WHEN  8 THEN kbs_4_size
    ->                             WHEN  4 THEN kbs_2_size
    ->                             ELSE         kbs_1_size END AS next_size
    ->       FROM compression_logs WHERE final_kbs <> 1) AS c
    -> WHERE next_size > final_size GROUP BY final_kbs;
+-----------+-----------+-------------+-----------+----------+
| final_kbs | nb_tables | initial_gib | final_gib | diff_gib |
+-----------+-----------+-------------+-----------+----------+
|         2 |    112278 |     9339.80 |   1955.21 |   609.37 |
|         4 |     38862 |     3387.78 |   1048.73 |   137.83 |
|         8 |     13896 |      434.14 |    217.76 |    51.82 |
|        16 |      2834 |        1.60 |      1.60 |     9.17 |
+-----------+-----------+-------------+-----------+----------+
4 rows in set (0.29 sec)
The result above shows that, if we want the smallest footprint on disk, it is important to use the right KEY_BLOCK_SIZE:
  • if using 8 instead of uncompressed (final_kbs of 16), 9.17 GiB is wasted (this might not look like much but it is 5.7 times the initial size),
  • if 4 instead of 8, 51.82 GiB is wasted, which is an increase of 23%,
  • and the increase is 31% for 2 instead of 1.
The attentive reader might have spotted a gap between the two tables above.  In the first tables, we have 152,215 tables that are compressed with a KEY_BLOCK_SIZE of 2 and in the second tables, we have only 112,278 tables.  This is because some tables failed to alter with a KEY_BLOCK_SIZE of 1.  Let's confirm that with the following query.
> SELECT COUNT(final_kbs) as nb_tables,
    ->   ROUND(SUM(initial_size) / POW(2,30), 2) AS initial_gib,
    ->   ROUND(SUM(final_size)   / POW(2,30), 2) AS final_gib
    -> FROM compression_logs
    -> WHERE final_kbs = 2 AND kbs_1_size IS NULL
    -> GROUP BY final_kbs;
+-----------+-------------+-----------+
| nb_tables | initial_gib | final_gib |
+-----------+-------------+-----------+
|     39937 |     5597.80 |   1078.05 |
+-----------+-------------+-----------+
1 row in set (0.18 sec)
So 39,937 tables are failing ALTER with a KEY_BLOCK_SIZE of 1. The manual is saying that compression could fail if a row does not fit in a block, the exact being:
Generally, MySQL requires that each B-tree page in an InnoDB table can accommodate at least two records. For compressed tables, this requirement has been relaxed.  Leaf pages of B-tree nodes (whether of the primary key or secondary indexes) only need to accommodate one record, but that record must fit, in uncompressed form, in the per-page modification log.
However, I know that at least one of those tables has a row size smaller than 1 KiB.  I opened Bug#84439 for that.


I hope above gave you an idea of a real-world use case of InnoDB table compression.  Before ending this post, here are a few additional comments/thoughts on this work:
  • The script compresses table in a temporary schema and swaps the compressed with the original table (note that this is a cross-schema rename operation).  I found Bug#84038 that results in spamming the error log on MySQL restart for each cross-schema rename operation.  This should be fixed in MySQL 5.7.19 (I have not verified myself yet).
  • I already mentioned in a previous post that I tested MyISAM and myisampack and that this is giving a better compression ratio (I wrote a post Why we still need MyISAM about this).
  • Finally, I am curious how MyRocks would compress this data.  I might be able to find time to test this and write about it.

Wednesday, 9 August 2017

GREATEST PROGRAMMERS IN THE WORLD 2017



Coding is not an easy task to be as a normal programmer. But, If you try hard and keep a specific goal in your mind, then it is the simplest thing that makes you great. Let’s see who is in our popular computer programmers in the world for the 2017-2018 year.
So We are going to tell you about the Great Programmers in the World who makes our life more reliable and easy. By Which these worlds are connected to other people. It is very easy to technology by that coder, developer or we can say that Programmer. They are top best Coder of all the time.
The Programmer, like the poet, works only slightly removed from pure thought-stuff. He builds his castles in the air, from air, creating by exertion of the imagination.

MOST POPULAR PROGRAMMERS IN THE WORLD 2017

  • Bill Gates (Microsoft co-founder)
  • James Gosling (Java Creator)
  • Richard Stallman (GNU Project Creator)
  • Bjarne Stroustrup (C++ Creator)
  • Tim Beners-Lee (HTML and WWW inventor)
  • Ken Thompson (UNIX Co-Creator)
  • Linus Torvalds (Linux Kernel Creator)
  • Dennis Ritchie (C Programming language creator)
  • Jack Dorsey (Twitter Creator)
  • Ruchi Sanghvi (FB’s first female engineer)
  • Drew Houston (Dropbox Creator)
  • Mark Zuckerberg (FB Creator)
  • Larry Wall (Perl language)
  • Yukihiro Matsumoto (Ruby interpreter)
  • John Resig (Jquery, Javascript Library)
  • Phil Katz (ZIP format)

BILL GATES (MICROSOFT CO-FOUNDER)

He is chairman of Microsoft Corp. He has brought the company to continually advance & improve software technology. He has made it easier, more cost-effective & more enjoyable to use computers. Microsoft is now the worldwide leader in software, services and the solutions that help people and business reach full potential.

JAMES GOSLING (JAVA CREATOR)

James Gosling on Apple, Apache, Android  & the Future of JAVA. He is a Canadian computer scientist and also known as the father of the Java programming language. He spends his lot of time for the development of the Java Programming Language.
He created the main frame for Java and implemented the language’s original compiler and virtual machine.

RICHARD STALLMAN (GNU PROJECT CREATOR)

He founded the Free Software Foundation, developed the GNU Compiler Collection. As an operating system developer, he had the right skills for this job. Richard Stallman is the prophet of the free software movement. He understood the dangers of software patents years ago. Now that this has become a crucial issue in the world. He has hugely successful efforts to establish the idea of “Free Software,” Stallman has made a massive contribution to the human condition.

BJARNE STROUSTRUP (C++ CREATOR)

In Bell Lab, he designed and implemented C++. Based on C and inspired by Simula, provides a set of general and flexible abstraction mechanisms that can be mapped directly and efficiently onto computer hardware. The open, flexible research atmosphere encouraged him to consider adapting concepts from Simula, which he had used in his Ph.D. thesis work, to C.
He is quoted as saying: “When I joined, I was basically told to do ‘something interesting

TIM BENERS-LEE (HTML AND WWW INVENTOR)

Sir Tim Berners-Lee is a British computer scientist. He had written the 3 fundamental technologies that remain the foundation of today’s Web (and which you may have seen appear on parts of your Web browser): i.e. HTML, URL, HTTP. Tim also wrote the first Web page editor/browser (“WorldWideWeb.app”) and the first Web server (“httpd“). By the end of 1990, the first Web page was invented on the open internet, and in 1991, people outside of CERN were invited to join this new Web community.

KEN THOMPSON (UNIX CO-CREATOR)

He is notable for his work on the Unix operating system. He also invented the B programming language, the direct predecessor to the C programming language, and was one of the creators

LINUS TORVALDS (LINUX KERNEL CREATOR)

He is the founder and coordinator of Linux, the Unix-like operating system that is beginning to revolutionize the computer industry and possibly much else as well.

DENNIS RITCHIE (C PROGRAMMING LANGUAGE CREATOR)

Everybody in this country should learn how to program a computer… Because it teaches you how to think.
Dennis creates C programming language. The C programming language and its descendants continue to be used to write the software that makes digital devices and networks work while UNIX and UNIX-like operating systems run on a vast range of computing systems.

JACK DORSEY (TWITTER CREATOR)

He is known as a co-founder and CEO of Twitter and as the founder and CEO of Square, a mobile payments company. And also founder and CEO of Square, a mobile payments company.

RUCHI SANGHVI (FB’S FIRST FEMALE ENGINEER)

IFrame

DREW HOUSTON (DROPBOX CREATOR)

He is an American Internet entrepreneur who is best known for being the founder and CEO of Dropbox.

MARK ZUCKERBERG (FB CREATOR)

He is the chairman, chief executive, and co-founder of the social networking website Facebook. Also he is a computer programmer, Internet entrepreneur, and philanthropist.
Mark Zuckerberg

JOHN CARMACK (CO-FOUNDER ID SOFTWARE)

He is a game programmer, aerospace, and the reality engineer. He co-founded Id Software. He also founded Armadillo Aerospace.

LARRY WALL (PERL LANGUAGE)

He is the author of the rn Usenet client and the widely used patch program. Wall Larry developed the Perl interpreter and language while working for System Development Corporation, which later became part of Unisys. He is the author of Perl Programming.

YUKIHIRO MATSUMOTO (RUBY INTERPRETER)

He is a computer scientist and designer of the Ruby programming language and its reference implementation, Matz’s Ruby Interpreter.

JOHN RESIG (JQUERY, JAVASCRIPT LIBRARY)

He is a software engineer. He is the lead developer of the Jquery  Javascript library. He made software projects.

PHIL KATZ (ZIP FORMAT)

He is firstly designed the thought of the file compression. So known as the co-creator of the Zip file format for data compression, and the author of PKZIP, a program for creating zip files that ran under DOS.

Tuesday, 8 August 2017

Running a demo of the Payment Request API on your Android phone



The Payment Request API offers users an easy way to make payments on e commerce websites and apps with one tap. But getting your bosses or clients to buy into its simplicity and ease of implementation can be tricky. I’m going to demonstrate how easy it is to demo Payment Request in DevTools which will hopefully help you convince of its ease. Payments Request API will be implemented in desktop Chrome 61, but in the meantime you can use these tips to demonstrate it on your Android phone.
Connect your Android phone with Developer Mode turned on to your laptop/computer.
Load your website on your Android phone.
Switch back to your laptop’s Chrome and open Developer Tools (View -> Developer -> Developer Tools; or Option+Command+I on Mac).
Inside Developer tools you will find another contextual menu in the upper right, select More tools -> Remote Devices.
Select your phone in the Devices list, then click on “Inspect” on the tab for your site.
This will open a window on your laptop; we want to click the console tab at the bottom.
Copy and paste the code below. Make sure you customize what appears in the Payments Request UI, modify the bold values.
function initPaymentRequest() {
  let supportedInstruments = [{supportedMethods: ['basic-card']}];
  let details = {
    total: {
      label: '<INSERT TITLE>',
      amount: {currency: 'USD', value: '<INSERT TOTAL VALUE>'}
    }
  };
  let options = {};
  return new PaymentRequest(supportedInstruments, details, options);
 }; 
initPaymentRequest().show().catch(function(err) {console.log(err); 
});
Once you press enter you will get the Payments Request API UI like so;
You could set the options to include name, email address and phone number by simply setting the properties to true.
let options = {
  requestPayerName: true,
  requestPayerPhone: true,
  requestPayerEmail: true,
};
And that’s it, these simple triggers allow you to demonstrate the ease of use and implementation of the Payments Request UI. If you would like to find out more about this please visit Web Fundamentals for more details on Payments UX, Implementation and our codelabs.

Friday, 4 August 2017

Use My Hosted AdSense Account To Show Ads On My Own Site


If you signed up for AdSense through a host partner and you’d like to show ads on your own non-host partner website, then you’ll need to provide us with the URL of the site you want to monetize. You can do this via a one-time application form.
Note that if you haven't already verified your address via a Personal Identification Number (PIN), then you'll need to do this before you can apply to show ads on your own site. Learn more about PIN verification.
 
To apply to show ads on your own site:
  1. Sign in to your AdSense account.
  2. In the left navigation panel, click My ads.
  3. Click Other products.
  4. Click Upgrade now and complete the application form.
  5. Finally you need to implement AdSense ad code on the URL that you provided above, on a page that receives traffic.
    To implement AdSense ad code, you first need to generate the ad code. You can learn how to implement it on your non-host partner website by following our code implementation guide. Note that your ad units will remain blank until your request has been approved.
Once your request is approved, you’re welcome to place your ad code on any website that you own without any further approvals. If your application is not approved, be assured that ad serving on your host partner site will not be affected. You can continue to monetize your hosted content as normal.

Thursday, 3 August 2017

How Large Can MySQL Replication Be In Production?

Based on How large can MySQL be in production (article by JF), I have been looking at the awesome Orchestrator visualization of some replication hierarchies.
Names have been removed, but the blue badges indicate some host counts. All of these are installations replicating across multiple Cluster/Data Center Boundaries.
Orchestrator is by far the best tool to discover and manage replication setups like these. You can restructure replication topologies with drag and drop.
If you look inside such a hierarchy, it can be pretty daunting:
What you see is a master server running MySQL 5.7 on the left, in orange. It does replicate to local replicas using instance-fdd8 below, using statement based replication. The local replica then explodes things to a larger number of replicas, also in orange (same DC). Replication lag is slow.
A cross DC-link is indicated above, dotted line. The target DC is rendered in green. Slaves with version numbers and replication lag are being shown. Instance-5a25 is lagging.
The view can be compressed:
Here again, blue badges show counts of servers that have been compressed into one bezel. Note the third cross DC link from green to blue.
Here is a look at the really large hierarchy from the top image. It’s folded and still does not fit:
See the mix of versions: I can spot MySQL 5.6, MySQL 5.7 and one 8.0 (half visible in dark red at the bottom) in the mix.
Topology is really wild, see this part of the diagram:
Again, compressed view – note the server counts in the blue badges. Also see the multitude of cross-cluster connections from the red master to the crowd of orange intermediates. Instance-2835 and children are badly lagging. The rest is fine.