Caching 🗃️, 💲Shell Scripts ⚙️, Concurrency 🔀, Parallelism ⏸, Product Development 🚀

By Prajwal Haniya

Techletter #55 | January 14, 2024

Caching

Two caching techniques:

LFU (Least Frequently Used) Caching

How to write shell scripts to automate tasks?

Recently I have started writing shell scripts because the number of repositories on which I work got increased, and taking pull from each is not a feasible solution. Why not automate the repetitive tasks? So here are my scripts to get recent changes, script to create build & push it to the specified branch.

Script to pull the latest changes

#!/bin/bash

stash_and_pull() {
    local directory=$1
    cd "$directory" || exit 1
    echo "----"
    echo "INSIDE DIRECTORY $directory"
    currentTime=$(date +"%B%d%Y")
    git stash save -m "$currentTime"
    git switch master
    git pull origin master
    cd - || exit 1
    echo "----"
}

stash_and_pull "DIRECTORY_NAME"

Script to create build & push to a specific repository

#!/bin/bash

build_and_push() {
    local directory=$1;
    cd "$directory" || exit 1
    echo "----"
    echo "INSIDE DIRECTORY $directory"
    currentTime=$(date +%s)
    git stash save -m "$currentTime"
    git switch master
    git pull origin master
    git checkout -b "_build/$currentTime"
    yarn build
    git add .
    git commit -m "Create build"
    git push origin "_build/$currentTime"
}

build_and_push "DIRECTORY_NAME"
package main

import (
  "fmt"
  "time"
)

func count() {
    for i := 0; i < 5; i++ {
      fmt.Println(i)
      time.Sleep(time.Millisecond * 1)
  }
}

func main() {
    go count()
    time.Sleep(time.Millisecond * 2)
    fmt.Println("Hello World")
    time.Sleep(time.Millisecond * 5)
}

Multiple returns possible in Go

package main

import (
  "fmt"
)

func Names() (string, string) {
    return "Foo", "Bar"
}

func main() {
    p1, p2 := Names()
    fmt.Println(p1, p2)

    p3, _ := Names()
    fmt.Println(p3)
}

What is the difference between concurrency & parallelism

Concurrency:

Parallelism:

Feature Concurrency Parallelism
Execution Seemingly at the same time Truly at the same time
Hardware requirement Single CPU Multiple CPUs/cores
Illusion vs. reality Illusion of simultaneous execution True simultaneous execution
Speed improvement Limited improvement Significant improvement

Some of the challenges faced while developing a product

Articles

  1. The product vision roadmap
  2. How to define a product vision