Mock Service Worker - Overview

Mock Service Worker (MSW) is a library that helps you mock HTTP requests in your tests. We can use it to define request handlers to respond different mock data mainly for testing. Let’s see how to use MSW in browser environment. Installation Install msw package bun install msw Setup Create a index.js which will be used to setup MSW and ship to browser. import { HttpResponse, http } from "msw"; import { setupWorker } from "msw/browser"; // handlers const userHandler = () => { return HttpResponse....

TypeScript Overview

TypeScript has gained popularity for it’s ability to add type system to Javascript. Typescript code will be transpiled to Javascript code which can be run in any browser. Few things I like about TypeScript are Static Typing: TypeScript provides static typing which helps in catching errors at compile time. Strong Tooling: TypeScript has strong tooling support with features like code completion, refactoring, etc. Community: TypeScript has a large and active community that provides support, libraries, and tools....

Connecting to Consul & Vault using Golang

Consul is a tool for service discovery and configuration. It provides a way to discover services and manage configurations in a distributed system. Vault is a service that help us to manage secrets and protect sensitive data. It provides a secure way to store and access secrets like API keys, passwords, certificates, etc. Both are similar tools provided by HashiCorp Where we can access the services using the HTTP API....

Log Rotate in Linux

Logging is an essential part of any system. It helps us to debug and monitor the system. Log files are a common way to store logs generated by a system or application. When there are a lot of logs generated by the system, it can consume a lot of disk space. To manage the log files, we can use the logrotate utility in Linux. Log rotate configuration Setting up log rotate to manage logs is simple....

Sharing files from SharePoint to Azure Blob Storage using Python

Let’s see how we can share files between two cloud storage solutions - SharePoint and Azure Blob Storage using Python. We will be simply copying all the files from a sharepoint site to an Azure Blob Storage container. Sharepoint sites will have a drive associated with it and we can access the files in the drive using the Graph API. We will be using the requests library to interact with the Graph API....

C - Overview

C is an amazing low-level programming language that has stood the test of time. It was developed by Dennis Ritchie in the early 1970s at Bell Labs and has since become one of the most widely used programming languages. C is known for its efficiency, flexibility, and portability, making it an ideal choice for system programming, embedded systems, and low-level programming. Few things I like about C are The ability to directly manipulate memory and hardware....

Golang Thread Blocking Entities

Golang has good concurrency support using goroutines. Goroutines are lightweight threads managed by the Go runtime. Goroutines are multiplexed to fewer OS threads. Goroutines are non-blocking, and they are not scheduled by the OS. The Go runtime schedules the goroutines. The scheduler uses a technique called M:N scheduling. M goroutines are multiplexed to N OS threads. The scheduler schedules the goroutines to the OS threads. The scheduler uses a technique called work-stealing to schedule the goroutines...

Using Pkl in Go

Pkl is a config managment language developed by Apple. It is a simple language to manage configuration files. It has plugin support for popular editors and support for golang. Sample project Let’s start with a simple go project. go mod init pkl-sample touch main.go package main import ( "fmt" ) func main() { fmt.Println("Hello, World!") } Install pkl First, let’s install pkl using brew. brew install pkl Then, Let’s install pkl-go library in our project....

Swagger Docs in Go

Golang is a very good language to create web api servers. I like gofiber framework for creating web api servers. In this article, we will see how to use Swagger in Go especially with gofiber framework. Install swaggo/swag go install github.com/swaggo/swag/cmd/swag@latest Create a new project go mod init github.com/username/projectname Setup Gofiber and Swagger In the code below, we have created a simple API using gofiber framework. The annotations are used to generate the swagger documentation....

Elixir Overview

Elixir leverages the Erlang VM, known for running low-latency, distributed and fault-tolerant systems, while also being successfully used in web development and the embedded software domain. It’s functional paradigm and immutable data structures make it a great choice for building scalable and maintainable applications. Few things I like about Elixir are The syntax is very clean and easy to read. The built-in support for concurrency and fault-tolerance. The ability to write highly concurrent and distributed systems with ease....