Sunday, January 14, 2018

File Descriptors on steroids
Introduction: Data Structures for persisting and organizing data on disk has remained the same as desktops evolved from mainframes. However, as more and more data migrate from the desktop to the cloud storage, the operating system artifacts for the desktop seem woefully inadequate to meet the features of the cloud such as elasticity, redundancy, availability, aging, deduplication, conversion, translation, parsing, sealing extents, IO scheduling and finally, replication. While some of these may be mitigated by higher level applications and services, it brings in players and vendors that have different areas of emphasis. A retail company wanting to own a business specific service at cloud scale starts relying on more technological notions and disparate systems while not addressing the minimal requirement of an in-process compute and storage requirements. Instead if the service were given primitives that looked and behaved the same as they do at an individual compute resource level, then they can also work with resources at cloud scale so long as the primitives are made smarter.
Implementation: We have solved the problem of communications via peer to peer networking and message queuing to not just multicast but implement publisher subscriber models. Moreover, we have made networking and concurrency into libraries that expand on the definition of their corresponding primitives and can be hosted in process. We offer notions of background processing with libraries like Celery that application developers and enterprise architects use to offload intensive processing away from end customers. They however end up creating fatter servers and dumb clients that can work anywhere on any device. If we contrast this model, we can have more uniform processing in peer nodes and on-demand basis if there were operating system primitives that supported the existing and new functionalities for cloud from the operating system notion of a process itself.
Conclusion: Enhanced File descriptors transcend clouds and bring the cloud capabilities in process.
#codingexercise
Find the JacobsthalLucas number
uint GetJacobsthalLucas(uint n)
{
if (n == 0) return 2;
if (n == 1) return 1;
return GetJacobsthalLucas(n-1) + 2 * GetJacobsthalLucas(n-2);
}
0 1 1 3 5 11 ...
While Pascal's triangle forms from diagonal bands of Fibonacci numbers, Jacobsthal Lucas numbers also forms computed values from adjacent numbers along the diagonals.
Jacobsthal and Jacobsthal Lucas numbers are part of Lucas series.

Saturday, January 13, 2018

Today we resume our discussion on the AWS papers in software architecture which suggests five pillars:
- Operational Excellence for running and monitoring business critical systems.
- Security to  protect information, systems, and assets with risk assessments and mitigation strategies.
- Reliability to  recover from infrastructure or service disruptions
- Performance Efficiency to ensure efficiency in the usage of resources
- Cost Optimization  to help eliminate unneeded cost and keeps the system trimmed and lean.
The guidelines to achieve the above pillars include:
1. Infrastructure capacity should be estimated not guessed
2. Systems should be tested on production scale to eliminate surprises
3. Architectural experimentation should be made easier with automation
4. There should be flexibility to evolve architectures
5. Changes to the architecture should be driven by data
6. Plan for peak days and test at these loads to observe areas of improvement
In AWS, the architecture is set by individual teams that demonstrate best practice. These guidelines are driven by data to build systems at internet scale  and shared with virtual team of principal engineers who peer review each other's designs and showcase them. This is re-inforced with the following:
First, the practices focus on enabling each team to have this capability
Second, the mechanisms that carry out the automated checks ensure that the intentions are met
Third the culture works backs from the value to the customer across all roles.
The internal review processes and the mechanisms to enforce compliance are widely adopted
We will start reviewing the guidelines in greater detail but let us take a moment to take note of the push back encountered for such initiatives:
Teams often have to get ready for a big launch so they don't find time
Even if they did get all the results in from the mechanisms, they might not be able to act on it
Sometimes the teams don't want to disclose the internal mechanisms.
In all of the above, the shortcomings are fallacious.
#codingexercise
Find the Jacobsthal number
uint GetJacobsthal(uint n)
{
if (n == 0) return 0;
if (n == 1) return 1;
return GetJacobsthal(n-1) + 2 * GetJacobsthal(n-2);
}
0 1 1 3 5 11 ...
While Pascal's triangle forms from diagonal bands of Fibonacci numbers, Jacobsthal numbers also forms computed values from adjacent numbers along the diagonals.

Friday, January 12, 2018

Today we will take a break from AWS architecture papers to discuss wire framing tools.
UI Customizations: 

Introduction 
The web page of an application is proprietary to it. When the web page is displayed to the user as part of a workflow for another application using HTTP redirects, the pages have to be customized for seamless experience to the user This involves propagating the brand or the logo through the cross domain pages, modifying text and links and user controls on the shared page. A classic example for this is the login page. Many clients want to customize the login page to suit their needs. Consequently, the login provider needs to provide some sort of wireframing tool to help these clients. We discuss the design of one such wireframing tool. 
Design: 
A wire framing tool that enables in browser experience works universally on all devices. Therefore, hosting the wireframed pages and templates as a web application will be helpful to most clients. Additionally, if this web application was in the form of REST based APIs, it will benefit the client to come up with a tool for themselves that doesn't necessarily pose the restrictions that a provider may have. Sample API could involve something like 
GET displays/v1/prototypes/{id}/pages/{id}.json?api_key=client_dev_key 
Here we use json notation to describe the wire-framing artifacts. These include entities for prototypes, pages and layers. A prototype becomes the container for all pages and layers associated with the mockup that the client would like to achieve. It has attributes such as name, version, timestamps etc. A page also has similar attributes but contains elements and might also show layers. A page is the unit of display in a workflow when user navigates from one user interface to another.  A layer is a group of elements that can be shared between pages. It is similar in nature to templates and used in conjunction with a page. 
As with all REST APIs, there is possibility to create, update and delete these pages so that we can let the clients manage their lifetimes. The purpose of organizing this way is to keep the wireframes simpler to compose.  
The styling and scripting are elements that can be added separately or as strings that can be embedded in placeholders. The placeholder itself works with identifiers and therefore can have any text displayed with it as a literal or as an HTML element. Since the wire framing tool renders them, there is full flexibility in custom injection by the clients. 
Workflows are enabled by association pages with controls. Since this is a wireframe only, data from a page is passed to the next page via the association specified. This provides a seamless replay of pages for a workflow. 
Conclusion 
A wireframing tool is useful for user interface customization and can work with different clients for the same shared resource. 


#codingexercise
We were discussing finding the largest sum submatrix in a matrix of integers.
As we evaluated the growing range from column to column, we iterated inwards to outwards but the reverse is more efficient.

The advantage here is that the outer bounds of the entire matrix has the largest possible array to apply Kadane's algorithm which we discussed earlier as the one used for finding the max subarray.

Since we find the maximum subarray (i1,i2) along the rows and (j1,j2) along the columns at the first and last row and column of the matrix, the submatrix with a large sum will lie within (i1,0) (i1, col-max), (i2,0)and (i2,col-max) or within (0,j1),(0,j2), (row-max, j1) and (row-max, j2).We merely refine it with every iteration that shrinks the matrix.

Note that we can use the min common (i-topleft,j-topleft) and (i-bottom-right,j-bottom-right) from the first and last row and column subarray determinations.

In this case we could terminate if the entire bounded subarray contributes to max sum. The idea is that we use row major analysis and column major analysis one after the other and pick the better answer of the two. The notion that linear dimension subarray sum will contribute towards the solution lets us exclude the arrays that won't contribute towards the result. However, since the values can be skewed we have to iterate in steps in one dimension only  and updating the max sum as we go.

Thursday, January 11, 2018

Today we continue discussing the AWS papers on software architecture which suggests five pillars:
- Operational Excellence for running and monitoring business critical systems.
- Security to  protect information, systems, and assets with risk assessments and mitigation strategies.
- Reliability to  recover from infrastructure or service disruptions
- Performance Efficiency to ensure efficiency in the usage of resources
- Cost Optimization  to help eliminate unneeded cost and keeps the system trimmed and lean.
The guidelines to achieve the above pillars include:
1. Infrastructure capacity should be estimated not guessed
2. Systems should be tested on production scale to eliminate surprises
3. Architectural experimentation should be made easier with automation
4. There should be flexibility to evolve architectures
5. Changes to the architecture should be driven by data
6. Plan for peak days and test at these loads to observe areas of improvement
It should be noted that Amazon's take on architecture is that there is no need for centralized decisions as described by TOGAF or the Zachman Framework. TOGAF is a framework that pools in requirements from technology vision, business demands, deployment and operations, implementations, migrations and upgrades to form central recommendations The Zachman framework provides a table with columns such as why, how, what, who, when, and rows as layers of organization so that nothing is left out of the considerations from architecture point of view. There are definitely risks associated with the distributed recommendations where internal teams may not adhere to strict standards. This is mitigated in two ways - there are mechanisms that carry out automated checks to ensure standards are being met and second - a culture that work backwards from the customer focused innovation.
#codingexercise
We were discussing finding the largest sum submatrix in a matrix of integers.
As we evaluated the growing range from column to column, we iterated inwards to outwards but the reverse is more efficient.

The advantage here is that the outer bounds of the entire matrix has the largest possible array to apply Kadane's algorithm which we discussed earlier as the one used for finding the max subarray.

Since we find the maximum subarray (i1,i2) along the rows and (j1,j2) along the columns at the first and last row and column of the matrix, the submatrix with the largest sum will lie within (i1,j1) and (i2,j2). We merely refine it with every iteration that shrinks the matrix.

Note that we can use the min common (i-topleft,j-topleft) and (i-bottom-right,j-bottom-right) from the first and last row and column subarray determinations.

Wednesday, January 10, 2018

We start reading AWS whitepapers. We begin with the AWS well-architected framework.
This is based on five pillars:
Operational Excellence which is the ability to run and monitor systems which are business cirtical and delivering functionality to customers. This pillar also includes all the processes and procedures that come with software support.
Security which is not only a non-functional requirement for a cloud hosted software but also a mandate from users and governance as well. It includes the ability to protect information, systems, and assets with risk assessments and mitigation strategies.
Reliability which is the pillar that safeguards against failures both sporadic and frequent. This is the ability of a system to recover from infrastructure or service disruptions, handling failures by acquiring and seamlessly moving to computing resources to meet demand, and mitigating disruptions that come via say misconfigurations or transient network issues.
Performance Efficiency which is the pillar to make sure there is efficiency in the usage of computing resources to meet system requirements, and to maintain it in the face of business and technology changes.
Cost Optimization  which is the pillar that helps eliminate unneeded cost and keeps the system trimmed and lean.
This paper enforces the guidelines for a sound architecture to be based around the following:
1. Infrastructure capacity should be estimated not guessed
2. Systems should be tested on production scale to eliminate surprises
3. Architectural experimentation should be made easier with automation
4. There should be flexibility to evolve architectures
5. Changes to the architecture should be driven by data
6. Plan for peak days and test at these loads to observe areas of improvement

#codingexercise
We were discussing finding the largest sum submatrix in a matrix of integers.
As we evaluated the growing range from column to column, we iterated inwards to outwards but the reverse is more efficient.

The advantage here is that the outer bounds of the entire matrix has the largest possible array to apply Kadane's algorithm which we discussed earlier as the one used for finding the max subarray.

Since we find the maximum subarray (i1,i2) along the rows and (j1,j2) along the columns at the first and last row and column of the matrix, the submatrix with the largest sum will lie within (i1,j1) and (i2,j2). We merely refine it with every iteration that shrinks the matrix.

Tuesday, January 9, 2018

Graded noise reduction  

Introduction: Devices and applications demand our attention with notifications. Have you ever felt overwhelmed by the notifications from every application including games on your smartphone? Wouldn't it be nice if there was an automated way to turn off notifications depending on your interest level? Sure, we could turn on or off notifications from individual apps but how often do we toggle that. Besides how do we know which applications' notifications do we turn on or off at this time? Instead if there was a single slider that would do this for us the right way each time, wouldn't it be more convenient? This is the purpose of this writeup.  

Description: Consider the number of on-off switches to be one each for every application. Since there can be many applications, this list may run into several pages. Some of these applications may be merely games which are notorious for their notifications. Outlook and Calendar, on the other hand, would only serve reminders if they are configured. All these applications are decided jointly. If we could string through the apps with a single switch, then we could turn off the notifications all at once. Since the applications are decided dynamically, it could choose to include the noisy ones depending on our tolerance levelsTherefore, we have a sliding scale of tolerance and as we move the slider over it, apps will start going silent starting from a few and ending with all. And the greatest benefit is the enhanced control for the region in between. Its takes away the effort involved in figuring out which applications to silence at any given time and learns this dynamically based on users' initial selections and the rate at which notifications are sent by the applications. This articulation of a single control gives us graded silence so we can adjust it instead of resorting to mute our phone all the time which still does not address the cluttered notifications on the screen and the requirement to browse them before dismissing one or all and that too repeatedly. Internally the sliding scale uses a simple weighted average of the number of notifications from the applications in a full day and the severity of the application. Reminders will be considered a high severity application while games and ads will be considered less severe. This easy setting of notifications will also reflect the toggled state before and after the switch is flipped. The applications are then ranked by priority and the threshold set by the user with the help of the slider is used to determine which applications are affected. These applications are then individually silenced. The algorithm to determine this can also use grouping and ranking techniques. Additionally, the means of notification may also be made consistent across all applications.  

Testing: If there is a metric for the number and relevance of the notifications corresponding to the bar set by the slider such as the F1 score, then it is appropriate to grade the sliding scale and check if the notifications permitted match the setting for any and all assortment of applications. 

Conclusion: A single control across all applications that more useful than the mute button on the smartphone has some appeal to improve productivity for the owner.   

#codingexercise 
We were discussing finding the largest sum submatrix in a matrix of integers.
As we evaluated the growing range from column to column, we iterated inwards to outwards but the reverse is more efficient. 

The advantage here is that the outer bounds of the entire matrix has the largest possible array to apply Kadane's algorithm which we discussed earlier as the one used for finding the max subarray.


Monday, January 8, 2018

#codingexercise
We find the maximum number of deletions to make a string palindrome
We can use modified Levenshtein distance to find this number

int GetCount(String A)
{
 String R = A.reverse();
int n = A.Length;
int[,] dp = new int [n+1,n+1];
for (int i = 0; i < =n; i++)
{
dp[0,i] = i;
dp[i,0] = i;
}
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
{
   if (A[i-1] == R[j-1])
        dp[i,j] = dp[i-1,j-1];
   else
        d[[i,j] = 1 + Math.Min(dp[i-1,j], dp[i,j-1]);
}
int res = INT_MAX;
int i = n;
int j = 0;
while (i >= 0)
{
res = Math.Min(res, dp[i,j]);
if ( i < n)
    res = Math.Min(res, dp[i+1,j]);
if (i > 0)
    res = Math.Min(res, dp[i-1,j]);
i--;
j++;
}
return res;
}

"book"
"koob"
dp
0 1 2 3 4
1 2 3 4 3
2 3 2 3 4
3 4 3 2 3
4 3 4 5 6
Minimum value is 2
Courtesy: geeksforgeeks