Friday, April 30, 2021

System design: Introduction to AWS Services

April 30, 2021

Here is the link. 

[This is not a hands on exercise. This is overview video for Cloud Practitioners] This video gives the complete overview of various AWS services by designing a sample Application. Ideal for those who are new to AWS and those who want to understand where particular AWS service fits into a sample application architecture Hi All, those interested in understanding AWS Networking in depth may want to enroll for this Udemy course. https://www.udemy.com/course/networki...

AWS global datacenter

  • 20 regions + 5 coming soon
  • 61 availability zones
  • 158 edge locations
  • 11 regional caches
  • 130 + Services
Region and availability zones
region = independent geographic area
Availability zone 



AWS account, users and service scope 

Billing, IAM, Route53

May 1, 2021 10:38 AM





Tax return: Check list | 2021

 April 30, 2021

I like to put together a blog about my tax return, so I can work on return better and more efficiently. 

Here are some highlights:

  1. RRSP - $2640 in total 2020, every month two payments, one is $100 to Scotia US 500 index, one is $120 to Canada index fund. 
  2. T4 
  3. T5 - No T5 form - Scotia saving accounts used to have interest close to $200 in 2019
  4. Simpletax.com free service
I used the feature of SimpleTax to import tax slips from my CRA account, and tax form are filled automatically. 

I spent half hour to go over the filled forms and tax slips. Capital loss is around $700 dollars. 



Reference: 

2019 tax return


I have to learn better to manage myself. I download tax document from Scotiabank.com, but the documents related to my RRSP and T5 are not good enough for me. I need to come out the total amount I deposited.

Here are highlights for my preparation:


  1. Use simpletax software
  2. Download all scotia bank 2019 and 2020 checking account statements;
  3. Manually go over monthly statement and check my RRSP deposit information. 
  4. Enter my T4 information on simpletax.com
  5. My RRSP limit is $52,056.00 based on CRA website
  6. Review my auto deposit information on CRA website
  7. My refund is $1074.25 dollars
  8. Take picture of T4 document and save it on my github
  9. Take picture of my $3000 dollar deposit on RRSP - Scotia Canada index fund statement
  10. My RRSP contribution is $5280, from March to December 2019 is $4620, January to March 2020 is $660.
  11. Download tax return 2019 report from simpletax.com
  12. Find all deposit slips from January 2019 to Dec. 2019. 
  13. Need to check hours worked in total, vacation days in total, sick days in total

Actionable Item


  1. Add T5 $263.22 to my tax return, now tax return is 50 dollar less; $1021.45
  2. I also look up checklist for tax return for Canadian and US residents. 

Vacation: April 27 - May 3, 2021 | My first vacation break - 5 days

May 5, 2021

Introduction

I will return to work this morning. After one week vacation, I felt so much blessed and enjoyed so many things in my life. I like to write a blog to document those good moments. 

Five day vacation

I spent first two days to work on system design study, and I had such good time to learn and this is the first time in my life over 10 years again to regret something. There are so many good and quality content about AWS and training content, AWS tech talk and other good things for me to learn from. I just could not believe that I did not find any of them and I can quickly learn system design. 

As a 55 year old, I do think that it is better for me to learn more than I will use and apply at work first. That can make me a super powerful programmer and enjoy a lot of things in my life. 


Vacation at home | Running outdoor for one hour | Vancouver, BC, Canada

 April 30, 2021

Introduction

It is my vacation day in the city of Vancouver. I just had a busy interview day with Facebook, algorithm interview on April 29, 2021. I like to go out to run and walk around my neighborhood. It is fun to go out and enjoy rain, flowers on the trees, and beauty of nature. 

55 year old | Set priority right | outdoor running | itching, hay fever | Pleasant experience

I like to set priority and make daily exercise highest priority. I should take some time to relax and enjoy outdoor beauty in the city of Vancouver. 

I have to control my weight, right now it is 204 lb. I have to take some anti-histamine pill every day, but I should limit to take only less than two months. 

The pills are made of hormone, and my weight quickly went up from 186 lb to 204 lb. I have to start to run daily, and get used to stay outdoor. 

My selfies

I like to take selfies and also I need to push myself to enjoy outdoor activities alone. I used to run in iRun camp for one month. I got used to run after one month training. 



























My video is here. 



Thursday, April 29, 2021

CNBC: How YouTube Became An Internet Video Giant

April 29, 2021

Here is the link. 

With more than 500 hours of video uploaded every minute and over 1 billion hours watched every day, Google’s YouTube is the world’s second largest search engine. And its meteoric growth hasn’t subsided, over 2 billion users visit the site every month. CNBC takes a look at how the video platform has changed over the past 15 years and if it can stay on top. » Subscribe to CNBC: https://cnb.cx/SubscribeCNBC » Subscribe to CNBC TV: https://cnb.cx/SubscribeCNBCtelevision » Subscribe to CNBC Classic: https://cnb.cx/SubscribeCNBCclassic About CNBC: From 'Wall Street' to 'Main Street' to award winning original documentaries and Reality TV series, CNBC has you covered. Experience special sneak peeks of your favorite shows, exclusive video and more. Connect with CNBC News Online Get the latest news: https://www.cnbc.com/ Follow CNBC on LinkedIn: https://cnb.cx/LinkedInCNBC Follow CNBC News on Facebook: https://cnb.cx/LikeCNBC Follow CNBC News on Twitter: https://cnb.cx/FollowCNBC Follow CNBC News on Instagram: https://cnb.cx/InstagramCNBC #CNBC How YouTube Became An Internet Video Giant

CNBC: How Google And Gmail Dominated Consumer Email

 April 29, 2021

Here is the link. 

When Gmail was released to the public on April 1, 2004, many people thought it was a prank. Gmail offered one gigabyte of storage and robust email search. These features, among others, have helped to make Gmail the most used email service in the world with 1.5 billion users. Gmail has come a long way since its inception. It stands as the most dominant online email service with more than 1.5 billion global active users. It has gone from a small experiment to an important piece of Google's G Suite lineup. But the road to the top hasn't been without a few bumps, including a rocky start. By the time Google started working on the service in 1999, Yahoo Mail already had 12 million active users and Microsoft's Hotmail had about 30 million. Paul Buchheit, who was employee No. 23 at Google, fought for the online email service, but executives didn't understand how a search company could benefit from online email. Some executives pushed back at the time, according to multiple reports. Buchheit created the service as a "20%" project, which is an informal program Google has sometimes offered employees to work on projects of their choosing. When Gmail actually launched, people thought it was a joke -- literally. Becaase it was announced on April Fool's Day 2004, people wondered whether the company was pulling one over them. But once users realized it was real, it became one of a number of free email services alongside Microsoft's Hotmail and Yahoo Mail, which were some of the first to introduce web-based email in the 1990s. Monetizing Gmail has been a point of contention within the company. Some people argued that in order for Gmail to have the most reach, it needed to be supported by advertising, rather than user subscription fees. The ad model won out but, even before it launched to the general public in 2007, Google got heat for scanning Gmail emails and using the contents for targeted advertising. The company drew scrutiny again in 2018 after Google admitted to allowing app developers scan Gmail accounts for ad targeting. It would come up again through 2019 as Congress grilled Google alongside other tech companies over privacy. Over the summer, the company admitted to keeping a list of items users purchase using Gmail. Even though the email service didn't start doing exceedingly well compared to competition until 2012, it continues to innovate. The company still aggressively targets both consumer and enterprise users. It also continues to add innovative new features such as Smart Compose, which uses artificial intelligence to predict responses. » Subscribe to CNBC: https://cnb.cx/SubscribeCNBC » Subscribe to CNBC TV: https://cnb.cx/SubscribeCNBCtelevision » Subscribe to CNBC Classic: https://cnb.cx/SubscribeCNBCclassic About CNBC: From 'Wall Street' to 'Main Street' to award winning original documentaries and Reality TV series, CNBC has you covered. Experience special sneak peeks of your favorite shows, exclusive video and more. Connect with CNBC News Online Get the latest news: https://www.cnbc.com/ Follow CNBC on LinkedIn: https://cnb.cx/LinkedInCNBC Follow CNBC News on Facebook: https://cnb.cx/LikeCNBC Follow CNBC News on Twitter: https://cnb.cx/FollowCNBC Follow CNBC News on Instagram: https://cnb.cx/InstagramCNBC #CNBC #Google #Gmail How Google And Gmail Dominated Consumer Email

CNBC: The Rise Of TikTok

April 20, 2021

Here is the link. 

TikTok is the most downloaded app of 2020, as quarantines have spurred more and more users to hop onboard and learn about the latest dance trends and memes. But the app also faces a slew of regulatory hurdles, privacy concerns, and allegations of censorship, issues experts say will be new CEO Kevin Mayer’s top priority. » Subscribe to CNBC: https://cnb.cx/SubscribeCNBC » Subscribe to CNBC TV: https://cnb.cx/SubscribeCNBCtelevision » Subscribe to CNBC Classic: https://cnb.cx/SubscribeCNBCclassic About CNBC: From 'Wall Street' to 'Main Street' to award winning original documentaries and Reality TV series, CNBC has you covered. Experience special sneak peeks of your favorite shows, exclusive video and more. Connect with CNBC News Online Get the latest news: https://www.cnbc.com/ Follow CNBC on LinkedIn: https://cnb.cx/LinkedInCNBC Follow CNBC News on Facebook: https://cnb.cx/LikeCNBC Follow CNBC News on Twitter: https://cnb.cx/FollowCNBC Follow CNBC News on Instagram: https://cnb.cx/InstagramCNBC #CNBC The Rise Of TikTok


What is ByteDance? | CNBC Explains

April 29, 2021

Here is the link. 

ByteDance is known as China’s most famous consumer app factory. The company is behind social media apps like international sensation TikTok, Douyin, and AI-powered news aggregator Toutiao. CNBC’s Nessa Anwar explores the meteoric rise of the Chinese tech giant.

----- Subscribe to us on YouTube: http://cnb.cx/2wuoARM Subscribe to CNBC International TV on YouTube: https://cnb.cx/2NGytpz

Like our Facebook page: https://www.facebook.com/cnbcinternat... Follow us on Instagram: https://www.instagram.com/cnbcinterna... Follow us on Twitter: https://twitter.com/CNBCi


Leetcode discuss: 124. Binary Tree Maximum Path Sum

 April 29,  2021

Here is the link. 

C# | optimal time complexity O(N) | post order traversal | bottom up | April 29, 2021

April 29, 2021

  1. Binary Tree Maximum Path Sum

Introduction
It is tough to perform best when I felt stressed. I rememberd how to write an optimal solution using time complexity O(N) whereas N is total number of nodes. But under stress, I took the approach to call applyPostOrderTraversal() for each node instead of preprocessing and save all node's maximum path sum from root to leaf node, and made it work first. And I noticed that time complexity is O(N^2), and redundant calculation should be avoided.

Optimal solution
I quickly wrote the solution in the following code, and then the code passes online judge. The time complexity is O(N), space complexity is O(N) as well.

Performance challenge
When I design the algorithm, I should consider to apply post order traversal once, and then calculate each node's maximum path sum from root to leaf node. And also it is important to apply preprocess technique, save into C# Dictionary<TreeNode, int>.

It will be very easy to call TreeNode and get it's maximum path sum from root to leaf, and then apply brute force to all nodes in the tree, which is the topest node close to root node in a path.

Time schedule
I do think that it is easy to explain the post order traversal using a few simple tree test case, and explain how it works. It will take me at most five to 10 minutes.

Next it takes me another 5 to 10 minutes to explain idea to apply brute force, maximum path sum cross the root node.

The hard level algorithm should be solved in less than 25 minutes. I should push myself hard to make sure the algorithm is designed with optimal time complexity.

Case study
Given a simple tree like the following, what is maximum path sum:
image

One function call of applyPostOrderTraversal to apply post order traversal, bottom up, root node to leaf node maximum path sum is calculated.

First step is to review post order, the node is visted in the order of a, b, c, d, e.
image

The sum is calculated from root node to leaf node maximum path sum.
image

C# Dictionary<TreeNode, int> variable map is populated with the following:
map[TreeNode9] = 9, the path is node 9 itself.
map[TreeNode 15] = 15, the path is node 15 itself.
map[TreeNode 7] = 7, the path is node 7 itself.
map[TreeNode 20] = 35, the path is d-> b
map[TreeNode -10] = 25, the path is e->d->b.

Next step is to go over all nodes in the tree as topest node in the path close to root node, so maximum path sum cross the node is the following:
Node -10: -10 + 35 = 25, the path is e->d->b
Node 9: 9
Node 20: 20 + 15 + 7 = 42, the path is b -> d -> c
Node 15: 15
Node 7: 7
So the maximum path is the one to cross node 20, the maximum path sum is 42.

/**
 * Definition for a binary tree node.
 * public class TreeNode {
 *     public int val;
 *     public TreeNode left;
 *     public TreeNode right;
 *     public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) {
 *         this.val = val;
 *         this.left = left;
 *         this.right = right;
 *     }
 * }
 */
public class Solution {
    public int MaxPathSum(TreeNode root) {
        if(root == null)
            return 0; 
        
        var map = new Dictionary<TreeNode, int>(); 
        applyPostOrderTraversal(root, map);
        
        var crossPathSum = Int32.MinValue;
        
        foreach(var item in map.Keys)
        {
            var sum = item.val;
            
            if(item.left != null)
            {
                var left = map[item.left];    
                if(left > 0)
                    sum += left;
            }
            
            if(item.right != null)
            {
                var right = map[item.right];
                if(right > 0)
                    sum += right; 
            }
            
            crossPathSum = Math.Max(crossPathSum, sum);             
        }
        
        return crossPathSum;        
    }
    
    /// apply post order traversal
	/// map - key - TreeNode, value - root node to leaf node maximum path sum
	///
    /// Time complexity: O(N), N is total number of nodes
	/// Test case 1: Tree, root node 1, left child 2, right child 3
	/// return should be 4, path is root node and then right child node. 
	/// Test case 2: Tree, root node 1, left child 2, right child is -3, 
	/// return should be 3, path is root node and left child
	/// Test case 3: Tree, root node -3, left child -2, right child -3, 
	/// return should be -3, kind of greedy, do not take left child subtree path, skip right child subtree path 
    private int applyPostOrderTraversal(TreeNode root, Dictionary<TreeNode, int>map)
    {
        if(root == null)
            return 0; 
        
        var value = root.val; 
        var maxRootToLeaf = value; 
        
        var left  = applyPostOrderTraversal(root.left, map);
        var right = applyPostOrderTraversal(root.right, map);
        
        if(left > 0)
        {
            maxRootToLeaf += left; 
        }
        
        if(right > 0)
        {
            maxRootToLeaf = Math.Max(maxRootToLeaf, value + right);
        }
        
        map.Add(root, maxRootToLeaf);
        
        return maxRootToLeaf; 
    }
}