Go - Dependancy Injection pattern.

Dependancy injection is a pattern where we pass down dependancies to initializers. This pattern is used to avoid global variables and to make code more testable. For example in go, you can create a service which depends on a repository and pass the repository to the service initializer. Suppose you have a directory like this server ├─entities │ ├─data.go │ └─server.go ├─handler │ └─handler.go ├─service │ └─service.go └─storage └─storage.go main.go suppose you have a User struct in data.go ...

Running Async Tasks in Django using Celery

Django is one of the best web frameworks to build some thing fast which comes with a lot of features. Even if it doesn’t appeal in terms of raw performance, it is one of the fastest frameworks in terms of development iteration. Celery is a distributed task queue that helps us to run tasks asynchronously. It is widely used in Django applications to run background tasks such as sending emails, processing images, etc. ...

Vim Cheatsheet

Vim Cheatsheet Cursor Navigation Vim has several commands for moving the cursor around the file. Here are the basic ones, which work in Normal mode: h: Move cursor left j: Move cursor down k: Move cursor up l: Move cursor right These are some more advanced commands: w: Move to start of next word b: Move to start of previous word e: Move to end of word 0 (zero): Move to start of line ...

Why are we fascinated by AI ?

Why are we fascinated by AI? I’ve been thinking of this for a while now. People are so hyped about AI, especially generative AI. It would be a lie if I said I wasn’t impressed, but behind all the excitement I also paused to analyze the whys. To gain an answer to this, I stepped back and thought about the scenarios where we get fascinated before the AI hype was there. All I could think of was, how a beginner musician get impressed by a skilled musician, how a beginner sportsman gets impressed by a skilled sportsman etc… ...

Some thoughts on Wealth

Some thoughts on Wealth There is being rich and there is being wealthy. The clear line between wealthy and rich can by simplified into two words, Discipline and Lifestyle. Let’s say if we stopped working or doing anything, how long can we survive? If we can survive for a long time, we are wealthy. Wealthy people often may not seem rich as well. Whereas rich people may not last long without working. Rich people might have houses, cars, and other commodities but they might be in debt or have a lot of expenses. ...

CI/CD Setup

Steps I follow to setup a CI CD workflow. Write Dockerfile in the code repo. Write a k8s Manifest file using kustomize template. Following this tree structure. ├── base │ └── app │ ├── deployment.yaml │ ├── kustomization.yaml │ └── service.yaml └── overlay ├── production │ └── kustomization.yaml └── staging └── kustomization.yaml Write a skaffold file ( skaffold init will auto initialize itself ). Build Docker image and Render the k8s manifest using skaffold. skaffold build && \ skaffold render --digest-source='tag' -p staging -o ../path-to/manifest.yml Manually push the rendered k8s to the manifest repository. Setup the k8s to access the private repository kubectl create secret generic <secret-name> \ --from-file=.dockerconfigjson=~/.docker/config.json \ --type=kubernetes.io/dockerconfigjson Update the K8s manifest with spec: template: spec: imagePullSecrets: - name: <secret-name> Setup argo cd in the target k8s cluster. ArgoCD Getting Started kubectl create namespace argocd kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}' kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo Login and Link repository to argocd. Create an app in argocd and configure to access the repository and the cluster to deploy.

Programming

Programming On a high level, Programming is simply writing instructions to a computer on how to compute or process data and give the desired output, in a programming language. Also, the input and output can be nothing. Either way, a program written involves changing the state of a system. A computer is a state machine and all it does is flip 0s and 1s. These details are abstracted from us as computer science has evolved. ...

DBMS - Migration in DBMS

Migration in DBMS In an application, It is quite inevitable to have changes on the database. The changes can be on the structure of data or even the data itself. It is a good idea to apply changes to a database as versioned and reversible set of steps. A representation of changes to be done the database can be called Migration. Two types of migration are Schema and Data migrations. ...

DBMS - Query performance

Query performance in DBMS When we query a database there are certain operations performed, the main operation to consider is the type of scan it would result in. The performance is calculated based on the time taken to do the operations. Various types of operations have different costs based on disk and CPU usage. Cost can be assumed to be the amount of time taken. Therefore, lower the cost better the performance (faster response from DB) ...

Authorization in Software Systems

Authorization in Software Systems As we know that, the concept of Autorization is simply checking if a verified user or application is allowed to do something. It generally comes to authorization policies which would be checked to make this decision. The decision is simple, is person X allowed to access resource R ? This can be further broken up to Create, Read, Update, Delete Access. There are multiple patterns to achieve access control in software systems. But generally, the idea is to filter out data that is only accessible to a user. ...