Month: July 2024

  • [Go] what is a time in go

    [Go] what is a time in go

    Time is an agreement We often take time for granted, considering it as omnipresent and essential as air. Yet, when it comes to programming, handling time can be surprisingly complex. The Go programming language provides a robust time package to manage these complexities efficiently. Let’s take a simple look at the ‘Time’ struct. The wall…

  • [Kubernetes] Probes

    [Kubernetes] Probes

    Probes There are three kinds of probes in Kubernetes(k8s): startup, liveness, and readiness. If the startup probe succeeds, the liveness and readiness probes get started. Containers that takes some time to get started can benefit from startup probe. As long as startup probe is not finished, K8s will never restart the pod. Therefore, the startup…

  • [LeetCode] 271. Encode and Decode Strings

    [LeetCode] 271. Encode and Decode Strings

    Description Design an algorithm to encode a list of strings to a string. The encoded string is then sent over the network and is decoded back to the original list of strings. Machine 1 (sender) has the function: string encode(vector<string> strs) { // … your code return encoded_string; } Machine 2 (receiver) has the function: vector<string> decode(string s)…

  • [LeetCode] 49. Group Anagram

    [LeetCode] 49. Group Anagram

    Description Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. Example 1: Input: strs = [“eat”,”tea”,”tan”,”ate”,”nat”,”bat”] Output: [[“bat”],[“nat”,”tan”],[“ate”,”eat”,”tea”]] Example 2: Input: strs = [“”] Output: [[“”]]…

  • [Leetcode] 217. Contains Duplicate

    [Leetcode] 217. Contains Duplicate

    Problem Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct. Example 1: Input: nums = [1,2,3,1] Output: true Example 2: Input: nums = [1,2,3,4] Output: false Example 3: Input: nums = [1,1,1,3,3,4,3,2,4,2] Output: true Constraints: Explanation The simplest approach involves iterating twice through the array to…

  • [Javascript] Closure

    [Javascript] Closure

    What is a Closure? In simple terms, an inner function captures the context of the outer function. But, what is a context? The context refers to the environment in which a function is declared. This environment includes any variables, parameters, and functions that are within the scope of the function when it is defined. When…

  • [Javascript] Controlling code flow (3)

    [Javascript] Controlling code flow (3)

    try, catch, and finally When we try to handle errors, try-catch statement is a good option. However, it isn’t clear how the error is caught in catch block. Furthermore, it is trickier when finally block is included. We do know that finally block must be executed after try and catch block, but the code flow…

  • [Javascript] Controlling code flow (2)

    [Javascript] Controlling code flow (2)

    Labeled Statement Labeled statements in JavaScript provide a mechanism for identifying and referencing specific statements within your code. While not frequently used, they can be particularly useful in certain scenarios, such as when working with nested loops or when you need to break out of multiple control structures. Why Do We Need Labels? Labels are…

  • [Javascript] Controlling code flow (1)

    [Javascript] Controlling code flow (1)

    Controlling code flow Conditional statement When controlling the flow of our code, we have several options. If we want to execute different blocks of code based on certain conditions, we can use if-else statement. These statements allow us to specify which code block should be executed based on carefully defined conditions. Below, we see see…

  • Third Quarter Roadmap

    Docker & K8S (Coming in July) When I first joined the company, my initial task was to set up a Kubernetes (K8S) cluster for the company’s services. It was a challenging, demanding, and exhausting experience, but ultimately very rewarding. I will share the details of what I accomplished and provide a guide on how to…