Time in Computer Systems
Time is a linear monotonically increasing value and to keep track of it, a system has to be powered to take note of every tick. For a microcomputer running an operating system that can go on and off, this means there is a need to constantly update time whenever the computer comes on. That is not the case because of some intelligent mechanisms that computer hardware and operating systems use to keep track of the current time....
Go - constant variables and const keyword
Brief Programming languages have the notion of constants which means “variables that can not be mutated once declared and initialized”. Go also has almost the same meaning, but in a different context. To initialize a variable as a constant with a value of 10, we can do something like this: const DISCOUNT = 10 In Go, constants mean “storing a literal to a variable”, this can be seen as a version of pattern matching in Erlang....
Running Go programs with a specific version
Brief Although Go releases are incremental and follow the Go compatibility promise: unless the change is required for a bug or security fix, the version starting with 1 won’t experience any backward-breaking change to the language or standard library, you can have a reason to use an old version of the language. Is there a clean way to do this? Recommendation I recommend a tool like go version manager that helps to manage a systemwide version of the language....
Node Taint, Toleration and Affinity
Motivation Pod scheduling can be a nightmare in a large Kubernetes deployment with many nodes having different configurations. Consider the configuration below: NODE A: 16vCPU, 10TB SSD Disk Space, 64GB RAM. NODE B: 4vCPU, 100GB HDD Disk Space, 8GB RAM NODE C: 8vCPU, 100GB HDD Disk Space, 8GB RAM, with additional GPU configuration And scheduling a new deployment to the cluster: kubectl create deployment --image=nginx --replicas=3 Kubernetes would schedule the Pods on a random node....
The VIM echo command
As with many other technologies, VIM can echo messages, if you are coming from a contemporary editor, this can hit differently. First, the result of all the echoed messages is visible in the status bar at the bottom of the screen, Secondly, previous messages can be accessed with the :message command. To echo a message, enter the command mode (ESC or CTRL-C), then type the below command: :echo "Hello World" This should print out Hello World to the status bar, but would not preserve the message for later reference....
ConfigMaps in K8s
Motivation Container images often accept Environment Variables for configuring their environments, for example the redis image accepts REDIS_VERSION for a specific redis version. Below command starts a redis container, passing a desired REDIS_VERSION environment variable. crictl run -t redis -e REDIS_VERSION=7.2 redis And to start a redis Pod, imperatively: kubectl run --image=redis --env=REDIS_VERSION=7.2 redis And declaratively: apiVersion: v1 kind: Pod metadata: name: redis label: app: kv-store spec: containers: - name: redis image: redis env: - name: REDIS_VERSION value: 7....
Dynamically lookup a property in deeply nested object
I was solving a challenge and got to a point where I had to implement a store that could hold arbitrarily deeply nested objects. The new me, I need to see what others have done. I found dot-prop npm package, which solves it quite well. But going through this gist, I found this answer. The author said a “functional way to solve it”… And this right here, is an example of declarative programming....
Imparative and Declarative coding?
As a software engineer, I have written a lot of lines of code, and taking hindsight back to the very first day of my career, I have written a log of bad code. I recently published a new version of my react-here-maps library which saw a sprinkle of my improved skill set. I had a coding interview where I was tasked to add functionality to support extra data points of the original response and think about adding weeks, months, and years to data that only returned days....
Byte Masking the ins and out
Byte masking is a deep CS concept reserved for the nerds. Here we will attempt to dissect the topic and provide a relatable experience for everyone. Welcome… Masking and its Relation to CS Masking is a process of concealing information. Take for example having a string "A" but revealing “X” to others such that only those with the information on how to get the hidden value can retrieve it. A byte is a group of bits(1 and 0) usually eight in number....
Ruby - if statement?
In Ruby, the if statement looks like this val = 1 if val == 1 p "Equality Checked!" end And for if else val = 2 if val == 1 p "Equality Checked!" else p "Equality Unchecked!" end And for if, else if, else val = 2 if val == 1 p "Equality Checked!" elsif val == 2 p "Equality Middle Checked!" else p "Equality Unchecked!" end Also, remember that everything in ruby returns a value, so your if statement can return a value that could be stored in another variable....