My Notes some of this and some of that

Dynamic checklist - Github action

Checkout this action on Github marketplace

Tests are nice, but they are not written for everything, especially when few things seems obvious or like a best practice.

For example, it’s a best practice to close resources in finally block but this is not usually tested through a test case. Experienced developer usually finds this during review, but even they can miss sometimes.

Or may be you are creating index, which is ok if it’s a small table, but it should be created concurrently for big tables so that rows are not locked for long time in production.

This action provides that safety net, or an extra set of eyes.

It will analyze the code for given keywords, given by you and will create a point in the checklist if that keyword is found in the code.

You can have multiple keywords map to same comment.

And that’s the only input for this action. A mapping file which contains mapping of keywords to comments. You can keep this mapping.json at the root of your repo and even name it the way you want. Just ensure to refer it correctly in workflow file.

Example mapping.json

{
  "mappings": [
    {
      "keywords": ["create index", "createIndex"],
      "comment": "Indexes have been created concurrently in big tables"
    },
    {
      "keywords": ["connection", "session", "CloseableHttpClient", "HttpClient"],
      "comment": "Resources have been closed in finally block or using try-with-resources"
    },
    {
      "keywords": ["RequestMapping", "GetMapping", "PostMapping", "PutMapping"],
      "comment": "Endpoint URLs exposed by application use only small case"
    },
    {
      "keywords": ["keyword1", "keyword2"],
      "comment": "Expert comment"
    }
  ]
}

The output of this action is a formatted checklist in md format, like this:

Checklist:

  • Indexes have been created concurrently in big tables
  • Resources have been closed in finally block or using try-with-resources
  • Endpoint URLs exposed by application use only small case
  • Expert comment

This action will analyze the diff of the pull request, and based on the diff and mapping file given by you, will comment on the PR with dynamic checklist, hence the name.

Example to configure it:

name: "Dynamic checklist"

on:
  pull_request:
    branches: [ master ]

jobs:
  checklist_job:
    runs-on: ubuntu-latest
    name: A job to create dynamic checklist
    steps:
      - name: Checkout repo
        uses: actions/checkout@v2
      - name: Dynamic checklist action
        uses: vishalsinha21/dynamic-checklist@v1
        with:
          mappingFile: 'mapping.json'
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

Here is one more example to configure it, and print the output (formatted checklist) of dynamic checklist action

name: "Dynamic checklist"

on:
  pull_request:
    branches: [ master ]

jobs:
  checklist_job:
    runs-on: ubuntu-latest
    name: A job to create dynamic checklist
    steps:
      - name: Checkout repo
        uses: actions/checkout@v2
      - name: Dynamic checklist action
        id: dynamic_checklist
        uses: vishalsinha21/dynamic-checklist@v1
        with:
          mappingFile: 'mapping.json'
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
      - name: Print checklist
        run: echo "The final checklist ${{ steps.dynamic_checklist.outputs.checklist }}"

The path to mapping file is relative to your repo root directory. For example, if you keep your mapping.json file inside a checklist directory inside repo’s root directory then configure path as show below:

        with:
          mappingFile: './checklist/mapping.json'

Logs of this action does not prints the pull request diff by default, it gets printed at debug level. In case you are interested in looking at the pull request diff, and the newly added line then add secret ‘ACTIONS_STEP_DEBUG’ as true in the settings of your repo. More details here

Here is a PR with example of how to add this github action to your repo along with mapping file. It also shows the example of how a comment would be made on the pull request. Since the added mapping file has all the keywords, it adds all possible comments to the checklist.

Here is an example which shows the dynamic checklist which was created based on the changes as part of that pull request. Only 2 comments have been added in this particular instance based on code diff and mapping file in the repo.

How to prepare for AZ-900: Microsoft Azure fundamentals certification

Certification Objectives

As the name conveys, this certification is all about fundamentals. It helps as the stepping stone to establish the fundamentals of cloud services and how those services are provided by Azure.

Main certification page with all details & skills measured

Is it good for me?

Azure and AWS are leading cloud solution providers and any certification in this area would be a good career investment.

It’s good for technical folks who are starting out their journey in Azure to get acquainted, to get the high level overview of Azure capabilities and get experience of the certification environment before appearing for advanced level Azure certifications.

But this is even better for folks in non-technical roles working in pre-sales, sales and delivery. This helps in getting that “30000 foot view” of Azure, helps in understanding clients requirements better and add more weightage to your opinions/suggestions. In my humble opinion, it’s a must for managers of all levels if their account is handling Azure projects.

This certification is not mandatory to appear for advanced level certifications but I would recommend it as the stepping stone and to get familiarity with certification environment. Advantages of certification is pretty subjective and depends on individuals perception. I like it because not only it helps in grasping the concepts but it also really helps me to focus on few details that I would ignore otherwise. And there is always a motivational boost if you clear any industry known certification.

How to prepare

  • AZ-900: Microsoft Azure Fundamentals Exam Prep -2020 Edition by Scott Duffy (Udemy)
    3 hours concise course which covers all topics related to this certification. There are other lengthy courses on Udemy for AZ-900, but I found this course just to be of the right length and instructor explains all concepts in simple language. It also has 1 practice test of 50 questions.

  • AZ-900: Microsoft Azure Fundamentals Original Practice Tests by Scott Duffy (Udemy)
    3 practice tests of 50 questions each

  • Official learning path
    This path includes exhaustive coverage of all topics, creating free account, gives walk-through of the portal and has some simple hands-on exercise. This should take 10-12 hours to complete.

This should be enough to achieve the objectives of this certification. Go through course and material again until you feel comfortable with the fundamentals. If you are able to score consistently above 95% in all practice tests and complete a test under 20 minutes then you are more than ready.

How to schedule for exam

The link to schedule exam with Pearson Vue is on the main certification page. There is option to take it from exam center or online (home/office). It’s very important to check that your system meets the requirements to take the exam online, before scheduling one.

All details related to online exams are here

Download OnVue software on your system and check-in to get acquainted with the check in process needed before exam. It can be done anytime and you can appear for one sample exam (1 random unrelated question).

You will be redirected to Pearson Vue to accept terms & conditions, language and select date/time slot for exam. This exam costs USD 99.

Exam experience

Check in process requires you to take photos of yourself, your identification (passport/driving license) and the photos of the room from where you would be attempting this exam. You will be prompted if photos are too dark/bright or blurred and then you will have to retake and re-submit. I started check-in 20 minutes before the actual appointment time, and was comfortably done with check in 15 min.

I waited for 5 minutes, and the exam started right on time. All other running applications would be closed and its very important that you remain visible from your laptop camera all the times and no one enters your room, else it might lead to termination.

Total exam time is 90 minutes which includes 5 minutes for terms and conditions and 10 minutes for feedback on questions after exam. I got 32 questions to be completed in 60 minutes (this can vary), so don’t assume that you will get all 90 minutes for the exam.

The passing score is 700. I was able to score 900 with the preparation I mentioned above. I was able to identify some topics which deserves more attention (mentioned in next section) and with little more focus on them you should be able to score even better.

32 questions is bit misleading because many questions has sub-questions. Some questions were really short but some have multiple sub-questions. For example: some questions had 3 statements to choose yes/no, or multiple statements with drag and drop options. Drag and drop question mentions that each choice can be used 0 to n times, so be careful.

60 minutes is still a lot of time for this exam. I was able to attempt all questions in 30 minutes, devoting ample amount of time to each question.

Topics that deserves more attention

Below topics deserves more attention to details and for removing any kind of ambiguity.

Aspects applicable to free account
Azure monitor vs Azure event hubs
Availability zone vs availability set
Azure advanced threat protection vs Azure premium identity protection
Different support levels

Summary

It’s been 6 months since I have started working on Azure. The project has got me some experience on Terraform, Kubernetes, Helm and Azure DevOps, but preparing for this certification has given me a very good overview of the many Azure fundamentals, core services and capabilities. This helps in broadening your horizon when proposing cloud solutions to customers/clients, and also helps to get acquaintance for the more advanced level certifications on Azure.

I did my research when preparing for this certification, and I think I took longer to prepare than I should have as I didn’t find all the information readily enough. I hope that sharing all this information at one place would help anyone aspiring to appear for this certification with just the right amount of preparation. I hope you will find this article useful and will do well in your exam. All the best!

How to clear PSM 1

Recently, I cleared PSM 1 with 95% on first attempt, so I thought of sharing my experience and how I prepared for the same. Many thanks to everyone whose tips helped me. I am trying to share the summary of those tips and what worked for me.

Preparation Material

  • Scrum Guide Scrum Guide is the most important artifact. Get very, very familiar with it. Each and every sentence is worth it’s weight in gold. I read this around 10 times. Try to understand it really well. You can also try and create notes for it in Q&A format. I found that very useful way to learn and remember things.

  • Nexus Guide
    Nexus is about scaling scrum. You need to get familiar with this, at least to the level of clearing Nexus Open assessment.

  • Scrum Glossary
    Few of the terms stated in glossary are not in Scrum Guide but shows up in actual exams like Burn Down Chart, Technical Debt etc

Few more topics, which can be read in detail on Internet:

  • Burn Up/Down Charts
  • Cone of Uncertainty
  • Velocity
  • Technical Debt

Assessments

Start with assessments first without going through any preparation material to see where you stand, and create a baseline for yourself.
Then go through the cycle of going through preparation material and then attempting these assessments to see how you are improving.
Your goal should be to get 100% in these assessments taking under 5 min for open assessments and under 20 min for Mikhail Lapshin preparation quiz. You should be able to get 100% scores consistently on multiple attempts.
Few of the questions from assessments do show up in the real assessments and since time is of essence, getting comfortable and quick with these questions would help you to get that extra edge and devote more attention to other questions.

About the real assessment

  • Find a quiet place and keep water, pen and notepad handy.
  • Questions cannot be skipped without answering, so if you are not able to make up your mind about the answer then just note down the question number and come back to it later.
  • Better have a attempt at all questions first, marking the ones which needs to be revisited as that would bring in some comfort factor.
  • At the last question, dont hit finish too soon. Look for link to “display all answered questions” and scroll down to see all questions with their preview and numbers. Click on the one you want to revisit and then choose the best possible answer. Repeat this until you have done the same for all questions you wanted to revisit.
  • If you still get time then just re-check the questions you have answered. Utilize all the time you have and do not be in a hurry to hit the finish button.

All the best!

Kadane's Algo

Problem Statement: This is one of my favorite algorithms! Given an array containing both negative and positive integers. Find the contiguous sub-array with maximum sum.

Reference URL: Kadane’s Algo

Example:

Input: 1 2 3 Output: 6

Input: -1 -2 -3 -4 Output: -1

import java.util.Scanner;

//URL: https://practice.geeksforgeeks.org/problems/kadanes-algorithm/0
//Description: Given an array containing both negative and positive integers. Find the contiguous sub-array with maximum sum.
public class Kadane {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int testCases = scanner.nextInt();

        for (int i = 0; i < testCases; i++) {
            int arrLength = scanner.nextInt();
            int[] arr = new int[arrLength];

            for (int j = 0; j < arrLength; j++) {
                arr[j] = scanner.nextInt();
            }

            System.out.println(maxSum(arr));
        }
    }

    public static int maxSum(int[] arr) {
        int sum = 0;
        int maxSum = Integer.MIN_VALUE;

        for (int i = 0; i < arr.length; i++) {
            sum += arr[i];
            //keep track of maximum sum
            maxSum = Math.max(sum, maxSum);

            //if sum is negative then reset sum
            //this ensures that we consider any sub-array which yield positive sum
            if (sum < 0) {
                sum = 0;
            }
        }

        return maxSum;
    }
}

Minimum Window Substring

Problem Statement: Given a string S and text t. Output the smallest window in the string having all characters of the text. Both the string and text contains small case letters.

Reference URL: Minimum Window Substring

Example:

Input: String: “timetopractice”, Pattern: “toc” Output: “toprac”

Input: String: “zoomlazapzo”, Pattern: “oza” Output: “apzo”

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

//URL: https://practice.geeksforgeeks.org/problems/smallest-window-in-a-string-containing-all-the-characters-of-another-string/0
//Description: Given a string S and text t. Output the smallest window in the string having all characters of the text. Both the string and text contains small case letters.
public class SmallestWindow {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int testCases = scanner.nextInt();

        for (int i = 0; i < testCases; i++) {
            String str = scanner.next();
            String text = scanner.next();
            System.out.println(getSmallestWindow(str, text));
        }
    }

    public static String getSmallestWindow(String longString, String pattern) {
        if (pattern.length() > longString.length()) {
            return "-1";
        }

        //left and right pointers to create sliding window
        int left = 0;
        int right = pattern.length();

        String minWindow = "-1";
        int minLen = Integer.MAX_VALUE;

        char[] chars = longString.toCharArray();
        while (right <= chars.length) {
            String substring = longString.substring(left, right);

            //if long string contain pattern, then increment left pointer until pattern is found to find minimum window string
            while (doesStringContainsPattern(substring, pattern)) {

                //keep track of minimum length of window and minimum window string found so far
                if (substring.length() < minLen) {
                    minLen = substring.length();
                    minWindow = substring;
                }
                left++;
                substring = longString.substring(left, right);
            }

            //increment right pointer
            right++;
        }

        return minWindow;
    }

    //to check whether long string contains the pattern, also check count of each character
    private static boolean doesStringContainsPattern(String str, String text) {
        Map<Character, Integer> strMap = getCharCountMap(str);
        Map<Character, Integer> textMap = getCharCountMap(text);

        Set<Character> set = textMap.keySet();

        for (Character ch : set) {
            if (!strMap.containsKey(ch) || strMap.get(ch) < textMap.get(ch)) {
                return false;
            }
        }

        return true;
    }

    //create a map of character counts in the string
    private static Map<Character, Integer> getCharCountMap(String str) {
        Map<Character, Integer> map = new HashMap<>();
        char[] chars = str.toCharArray();

        for (int i = 0; i < chars.length; i++) {
            if (map.containsKey(chars[i])) {
                map.put(chars[i], map.get(chars[i]) + 1);
            } else {
                map.put(chars[i], 1);
            }
        }

        return map;
    }

}