Running AI Coder Locally

AI Coding tools like copilot, cody etc.. are becoming very relevant and helpful. But, the problem is that they are not available offline. This became a problem when I wanted to travel and had no internet access. So, I remembered about ollama and was looking for a way to use it for my local development. Ollama Ollama is a tool that allows us to run LLMs locally. You can get it simply by: ...

Go has less features, so I'm more productive

Golang is well known for the simplicity and performance it offers. It follows a procedural programming paradigm and has a very minimalistic syntax. Sometimes, it’s too verbose compared to some enterprise languages like Java, C# and Python. But, it’s the same reason why I’m more productive with Go. Limited but essential features Go allows us to achieve something in one or only limited amount of ways. This itself is a huge productivity booster as there will be limited choices of patterns to choose from, which makes it easier to make decisions. It’s like choosing a flavor of ice cream from a list of 10 flavors vs a list of 100 flavors. It’s easier to choose from 10 flavors than 100. ...

SSH Usage

SSH is an encrypted protocol used to connect between two systems. It’s widely used to gain access to remote server and run shell commands. It is also a common thing we use with VCS like github, gitlab etc. SSH Key Generation Creating ssh key is pretty simple, the CLI generates a public and private key pair. The public key is shared with the server and the private key is kept secret. ...

Python - Multithreaded web crawler

I recently had written a web crawler in Python for crawling through a database website. It was a very interesting experience. I needed to crawl through 6850+ pages and extract data from each page, which required some conditions to be met. I used Python for this task, and it was very easy to write a web crawler in Python. First approach I wanted to make sure it works with a single page ( with 50 links ) properly. I needed the following ...

Blazor - Overview

C# ASP.NET offers a way to build highly interactive web UIs using C# and .NET. Blazor helps us to make the app interactive via different modes such as Static Web Apps Interactive Server ( Blazor Server ) WASM (Web Assembly) A Blazor app is based on Components with .razor extention. It is a combination of C# and HTML. Example: // Counter.razor @page "/counter" @rendermode InterativeServer <PageTitle>Counter</PageTitle> <h1>Counter</h1> <p role="status">Current count: @currentCount</p> <button class="btn btn-primary" @onclick="IncrementCount">Click me</button> @code { private int currentCount = 0; private void IncrementCount() { currentCount++; } } // PageTitle.razor <h3>@ChildContent</h3> @code { [Parameter] public RenderFragment ChildContent { get; set; } } In the above example, <PageTitle> is another component. @code block is used to write the C# code. This block will render a counter and a button to increment the counter. ...

Mirrord - Overview

When we have a large project with a kubernetes cluster, it’s sometimes difficult to debug and test certain parts of the application. Mirrord allows us to bind a local port to a remote server. flowchart TB request --> mirrord subgraph Pod mirrord -.-x|intercepted| live_server:3000 end mirrord -->|db connection| db[(Database db:5000)] mirrord -->|forwarded| local_machiene(local:3000) local_machiene -.-|connects db:5000 via mirrord| db You can run a local server for example on port 3000 and bind it to a remote server. And any request coming to live_server:3000 will be intercepted by mirrord and forwarded to your local machine. We can debug the incoming request, connect to other services etc… Like our local machiene is a part of the kubernetes cluster. ...

Client - Server Patterns

Client-Server is a common architecture pattern in software systems. It is a distributed system architecture that partitions tasks or workloads between the providers of a resource or service, called servers, and service requesters, called clients. There are different patterns in which client and server can communicate with each other. Request-Response The client sends a request to the server and waits for a response. The server processes the request and sends a response back to the client. It is a synchronous communication pattern. It is used in HTTP, RPC, and other synchronous communication protocols. sequenceDiagram participant Client participant Server Client->>Server: Request Server->>Client: Response Short Polling The client sends a request to the server at regular intervals. The server responds with new data if available. It is a synchronous communication pattern with a short interval. sequenceDiagram participant Client participant Server Client->>Server: Request Server->>Client: Response ( no data ) Note left of Client: Wait for some time Client->>Server: Request Server->>Client: Response ( data ready ) Long Polling The client sends a request to the server and waits for a response. The server holds the request until new data is available or a timeout occurs. It is a synchronous communication pattern with a long timeout. sequenceDiagram participant Client participant Server Client->>+Server: Request Note right of Server: Wait Until data is ready Server->>-Client: Response ( delayed ) WebSockets The client and server establish a persistent, two way communication channel. It is used for real-time communication and updates. It is particularly useful for chat applications, online gaming, and financial trading platforms. sequenceDiagram participant Client participant Server Client->>Server: Establish Connection Server->>Client: Establish Connection Client->>Server: Send Message Server->>Client: Send Message Server-Sent Events The server sends updates to the client over a single HTTP connection. Client sends a request and the server uses the response to send updates. Server will not end the response, and will keep sending updates over the established connection. sequenceDiagram participant Client participant Server Client->>Server: Establish Connection Server->>Client: Send Update Server->>Client: Send Update Server->>Client: Send Update Publish-Subscribe The client subscribes to a topic or event on the server. The server publishes messages to the subscribed clients when an event occurs. It’s similar to WebSockets, but the server can send messages to multiple clients and the messages are partitioned by topics. It is an asynchronous communication pattern. sequenceDiagram participant Client participant Server Client->>Server: Subscribe ( establish a connection ) Server->>Client: Publish ( through the connection ) Request-Callback The client sends a request to the server and provides a callback function or URL. The server processes the request and calls the callback function or URL on the client. It is an asynchronous communication pattern. sequenceDiagram participant Client participant Server Client->>Server: Request ( with callback info ) Server->>Client: Invoke the Callback

Testing - Finding Errors Early

Errors in software systems are inevitable. They can be caused by a variety of factors, including human error, hardware failure, or software bugs. Testing a software helps in finding errors early, It is important to find errors as early as possible to avoid any sort of issues in production. Let’s explore some checkpoints in which errors can be found early. Build Time Compiler performs a syntax check on the code and reports any errors. It includes type checking to ensure that the types of variables are used correctly. The limitations depends on the language and compiler, on how much it can check. Unit Testing Unit tests are written to test individual units of code. It helps in finding errors in the code logic. Unit tests works like a double entry book keeping system. Integration Testing Integration tests helps to check if different systems are interacting correctly, and if the data is being passed correctly. It is very helpful to find errors in systems which are dynamically typed and the cases of interactions needs to be valid. Load Testing Load tests help us to find errors in the system when it is under heavy load. We verify if the system is able to handle the incoming requests and if it is able to respond within the expected time. It also helps identify the limits of the system. End-to-End Testing End-to-End tests are mostly used to test the entire system from start to finish in a user-like environment. It helps find errors in a user point of view, while using the system. typically for e2e systems, we deploy the whole system and have another software interact with it like a user. It’s a good practice to have a combination of these tests to find errors early in the development process. It becomes crucial to run more tests as the system grows and becomes more complex. ...

Bash - Overview

Bash Scripting is a handy and powerful tool for automating tasks on a Unix-like operating system. It is a command language interpreter that executes commands read from the standard input or from a file. Bash also incorporates useful features from the Korn and C shells (ksh and csh). Variables Variables in Bash are used to store data. They can be used to store strings, numbers, and other types of data. Variables are defined using the = operator. ...

API Patterns

API is a common concept among software systems. Different software systems require to communicate with eachother to invoke some functionality or to exchange data. Since it’s a frequent requirement, it’s important to have a set of standards. There are different patterns and best practices that can be used to design and implement APIs. RESTful API REST APIs are designed around resources, which are any kind of object, data, or service that can be accessed by the client. They are mainly used for CRUD operations (Create, Read, Update, Delete) on resources. They use standard HTTP methods (GET: Read, POST: Create, PUT: Update, DELETE: Delete) and status codes to perform these operations on the resources. REST APIs are stateless, meaning that calls can be made independently of one another, and each call contains all of the data necessary to complete itself successfully. GraphQL GQL is a query language for APIs and a runtime for executing those queries by using a type system you define for your data. Graphql APIs are designed with a schema that defines the types and fields that can be queried. The Client can request only the data it needs, and the server will return only the requested data. The shape of response follows the shape of the request. gRPC It is designed for low latency and high throughput communication between microservices. gRPC is particularly suitable for microservices and between systems written in multiple programming languages due to its support for multiple programming languages. It based on HTTP/2, which is a binary protocol that is more efficient than HTTP/1.1. It uses Protocol Buffers as the Interface Definition Language (IDL) for describing both the service interface and the structure of the payload messages. Webhooks Webhooks are user-defined HTTP callbacks, which are triggered by specific events. When an event occurs, the source site makes an HTTP request to the URL configured for the webhook. They are useful for integrating different systems or for events in asynchronous communication. WebSocket WebSocket provides two-way (full duplex) communication channels over a single TCP connection. It enables interaction between a client and server in a real-time manner. It is particularly useful for applications that require real-time updates, such as chat applications, online gaming, and financial trading platforms. Each of these standards are useful and are best practices for their specific use cases. It’s important to choose the right pattern based on the requirements of the system. ...