Taming a 486MB Git Repo
I recently cloned a repository and noticed it was 486MB . The actual source code? About 6MB . That’s a 98.7% overhead. Here’s how I found the bloat and fixed it.
Recent content on Harisankar P S | Ruby on Rails Developer
I recently cloned a repository and noticed it was 486MB . The actual source code? About 6MB . That’s a 98.7% overhead. Here’s how I found the bloat and fixed it.
At the company where I currently work, we run a multi-brand e-commerce platform with stores in around 60 countries per brand. This year we started moving off AWS to self-hosted bare metal servers that we manage ourselves, spread across multiple providers (Hetzner, OVH, and others) for resilience. We have three regions: EU (primary), AU (Sydney), and SG (Singapore). Reads and writes happen locally…
I’ve been using git for years, but to be honest, I wasn’t even aware of git worktree until I started using AI for development. 
 Before this, my workflow for context switching was pretty standard. If I was in the middle of something and needed to check another branch or fix a bug, I’d rely on git stash or git stash -u (to catch those untracked files). Sometimes I’d just…
I haven’t thought about HTML in a long time, but recently came across the usage of picture tag(s). I was so impressed that I wanted to blog about it. This is nothing new, and used a lot by the web already. 
 The picture tag gives us a lot of control over how images are loaded, solving two main problems: efficient formats and responsive sizing. 
 WebP Support 
 We all know WebP…
Design patterns are only useful when they help solve real world problems in ways that feel natural in your language. In Ruby, one such pattern that fits like a glove is the Builder Pattern . 
 You’ll find it everywhere, from constructing HTML forms in Rails to building command-line interfaces or even assembling HTTP requests. 
 📦 What Is the Builder Pattern? 
 In real world…
As I was working on easyclientlog.com , building its invoice system that allows freelancers/consultants to generates PDFs. Working with PDF generating is that, its takes time and CPU cycles. But most of the time
the pdf only needs to be generated once, and the content seldom changes. So rendering the same thing over and over just didn’t feel right. So I used a simple trick that I’ve followed…
Managing context like the current user, store, client, or request ID across controllers, models, jobs, and services in a Rails app has always been a little messy. Before Rails 5.2, you might’ve reached for Thread.current , class_attribute , or even @@class_variables to store this kind of state. But these are not thread-safe and can cause hard-to-debug issues in concurrent environments. 
 Rails…
I live in India, and getting a static IP at home isn’t straightforward. You usually have to go through customer care, sometimes upgrade to a more expensive plan, and even then it’s not always guaranteed. I wanted a simple setup to make one of my apps publicly accessible without paying a lot or dealing with all that. 
 So here’s what I did. I used Tailscale , AWS Lightsail , Docker , and Nginx…
Ruby’s Data class was introduced in Ruby 3.2, offering a convenient way to define value objects. The concept of value objects was popularized by Martin Fowler and Eric Evans through their books and articles. In the real world, we often represent properties like coordinates on a map (x, y) or the speed of a car—using primitives such as integers or strings. While these work, they lack the…
Ruby’s Object#tap is a small but powerful method that often goes unnoticed. It allows you to “tap into” a method chain, perform some operation, and return the original object—regardless of what the block inside returns. This makes it particularly useful for debugging, configuration, or inserting side effects without breaking the flow of your code. 
 A Simple Use Case: Debugging…
What I am suggesting is a method of optimization not just for PostgreSQL but for other similar databases as well. This is a more primitive, hardware-level performance optimization where an exclusive partition or hard disk is dedicated just for the actual data. By doing so, all the read and write operations related to your data happen on that disk, while OS-level and software-level read/write…
I often see articles discussing Tailscale in multi-device setups, but I wanted to share my experience of using Tailscale primarily with a single machine. To clarify, it’s not technically a single device, but a combination of my work computer, phone, and a 10-inch Android tablet. 
 The Problem: Inefficient Remote Access 
 I work from home, and my computer serves as both my personal…
PostgreSQL is a mature, open-source relational database that has been widely adopted by many companies over the years. It has been my go-to database for most of my software career, helping me solve various performance challenges in my projects. Features like JSON generation, materialized views, and others have enabled me to scale APIs to handle millions of requests per second. 
 One effective…
AWS ECS (Elastic Container Service) is a powerful Amazon Web Service that allows you to deploy Docker containers on various infrastructure options, including EC2 instances, Fargate (serverless containers), or even self-hosted servers. Being deeply integrated with AWS, ECS offers a cost-effective and seamless solution for managing containers in the Amazon ecosystem. 
 This guide assumes you are…
Over the past two years since I began using Tailscale, it has become an invaluable tool. Tailscale has enabled me to achieve many tasks that previously required complex setups. One of the most significant achievements was being able to SSH into my home development machine directly from my phone 😄. 
 By connecting my phone to Tailscale and using JuiceSSH, an Android app for SSH access, I could…
In Rails applications, ActionMailer is a powerful module used to send emails. It’s essential to configure your ActionMailer settings correctly to ensure that your application can send emails reliably through your chosen SMTP server. Typically, these settings are configured in your environment files (e.g., config/environments/production.rb). However, there may be instances where you need to…
2024 Hacktoberfest has begun, and I decided to dive into some open-source contributions! One project that caught my eye was the Scanner Server . It offers a web interface for using scanners, which seemed pretty interesting. 
 I was eager to contribute but quickly realized I didn’t have a scanner to test it with 😅. Fortunately, Linux’s SANE (Scanner Access Now Easy) software comes to the…
Docker is an efficient way to use command-line tools without needing to install them or their required libraries. Recently, I had a use case where I needed to take an SQL dump of a schema from a PostgreSQL database. The problem was that the PostgreSQL DB was version 16.3, while my local DB was only version 15. Using my local pg_dump to access the remote database resulted in a version…
Amazon Elastic Container Registry (ECR) is a service provided by Amazon for hosting our Docker/container images. The cost of downloading these images to a server or ECS (Elastic Container Service) within the same zone is free. However, downloading or uploading from the public internet incurs costs, as does storage space usage. 
 During the development and deployment of your project, you may…
As someone who has been working with servers for over a decade and a half, I feel embarrassed to admit that I only
recently stumbled upon this setting. Throughout my years of connecting to remote servers over the internet, I’ve
encountered instances where connections freeze or break after a period of inactivity. Sometimes it happens more
frequently, while other times it never…
Recently I been trying to convince my team to write more tests, or some test. One of the arguments I heard during this was - automated test doesn’t remove manual test. Thats true, you still have to manually test it as well. But it avoids the repeated testing, and forgetting to test old features when new modifications are being done. I was thinking more about what to reply to people that says…
Recently I have been working with deploying self hosted application in AWS lightsail for the company that I work for. My strategy for deploying application has been as follows: 
 
 Launch a new ubuntu instance (since my team and I use it a dev machine we are familiar with it). 
 Install Docker 
 Install Docker Compose 
 Run the self hosted app and its requires services using…
I am not going to reiterate the PSA (Public Safety Announcement) of how important it is to write test. You can find enough articles related that online, and most probably you already know and agree to it. This article is how to generate JSON payload using Factory Bot. 
 Factory Bot is a ruby library that is used to create records in the table for testing. It will help generate data to fill and…
This article is about how to add https to a web app running in docker. For this we are using nginx to handle port 80 and port 443 and then reverse proxy the traffic to port 443 to the application port. In this article we are assuming you have credentials for the SSL certificate, another article will be written on how to do it with lets encrypt to create ssl certificates for free. 
 This…
The slowest step (in my experience and opinion) is compiling assets (js/css). Compiling assets takes time and slower when you do it for the first time. So to speed it up its recommended to copy the last compiled assets from the latest image you have of the repo. 
 
 
 1
 2
 3
 4
 
 
 COPY --from = docker-repo.link/image:latest /app/node_modules /app/node_modules…
Sidekiq is the gold standard when it comes to background processing. I have been using since I started working with rails. Sidekiq took care of lot of the complexity of the background processing that allowed developers to concentrate on just there code/business logic. 
 One of the beautiful features of sidekiq was how it handled exit (SIGTERM and SIGKILL). 
 
Source:…
Any program to execute on a machine needs to be in machine code (1s and 0s). In some languages you compile the code directly to machine code, and some they converts it to intermediary code that runs on an virtual machine (which indirectly execute machine code). One of the biggest virtual machines in the world is a web browser. People write HTML,CSS and JS, and execute it by rendering the graphics…
In this article we are sharing how to statically compile a crystal program and then
share the executable inside a docker image. We will create the smallest docker image possible. Smaller images are easier to manage, distribute and boot. 
 Note: The way docker works, each command/line creates a layer (with context). 
 The good news about crystal lang is the they distribute the docker…
Docker is a popular tool to containerize and share images. Recently we ported a POS system into a docker image and had to share it with a client before we setup a private registry. This is how we share the image from my dev machine to clients local server. 
 Dev Machine: Kubuntu, 22.04
Developing and deploying to the cloud has become a mandatory requirement than a nice to have skill. The promise of the cloud is that it abstracts all the complexity of managing a server and you only pay for what you use. If you accept that at face value, then the cloud is 100% legit. You only pay for what you use (just the cost is high), and they do abstract the regular complexity, and create some…
Docker has become a popular tool in recent years for building and deploying applications in a portable and scalable way. However, the build process can sometimes be slow, especially for large applications with many dependencies. In this article, we’ll explore how we can optimize our Dockerfile to speed it up. 
 When building a rails app for production we would need to do the following…
Docker engine has inbuild API service that allows you to control & modify your docker engine and docker instance using HTTP.
NFS - Network File System is a distributed file system protocol developed by Sun Systems. It facilitates a client computer to have access to file/folder over network like a local folder. This is a easy/simple way to provide persistant storage for your docker-swarm or kubernetes cluster. In both these cases, the container (or pod) run on one of the available nodes (servers), and when we have…
PiHole is a DNS server that will block ads and website on a DNS level. This is an integral part of my homelab as it blocks a lot of ads on my phones and system, and also easily allows us to manage domains for local application. 
 For homelab I have a docker-swarm which is managed using portainer. I have a nginx proxy manager to map the ports to a proper domain, even provide https using lets…
YAML stands for “YAML Ain’t Markup Language”. YAML is a data serialization language that is often used for writing configuration files. 
 In simple terms YAML is like XML or JSON, but for human beings rather than computers. I feel this is getting overlooked a lot, programmers need to understand that. Another human like configuration language I like is TOML (Tom’s…
Which Language Should I Build This Software In? or Which language should I have this software developed In? 
 This is a question that software devs gets asked a lot. By there friends/colleague , usually by who are not part of the software industry. This is my answer to them: 
 If you had an idea for a novel? or a poem? which language will you write it in. Italian, Tamil, Bengali? Would you…
ESP 32 is a series of low-cost, low-power system on chip micro controllers with integrated Wi-FI and Bluetooth. SoC or system on chip is an integrated circuit that integrates all or most of the component of a computer. Example the CPU, RAM, IO interface, GPU, etc. This form is becoming more and more popular thanks to growing smartphone and computing industry. Apple M1 chip is a good example on the…
I am a developer who moved from Windows, to Linux, to macOS, to Linux. A typical developer’s journey 😆. So moving from
windows to Linux was over 13-14 years ago. I didn’t do much from the windows world other than games and single executable
files. But moving from macOS to Linux, has been a bit tough. KDE has been able to provide me with everything I want and
more. The one…
Note: I am using Apartment gem to manage my multi schema database, and this article is written with expectation you know and use that gem. 
 When you have multiple schema in your rails application, it is important for them to remain consistent. Rails migration is run by keeping track of the timestamp prefixed in front of its file name. It stores the database. So when you restore a schema that…
Accessing the list of commands you have ran in your irb or rails console . 
 Running the following command in your console Readline::HISTORY.to_a returns the array of commands you have typed in console. After which you can treat it like any other array in ruby - search, sort, etc.
This tutorial or concept uses two softwares to make remote coding on your home machine possible. 
 
 Tailscale 
 code-server 
 
 Tailscale is basically a VPN using open source wireguard protocol. It creates an encrypted point to point connection so that only your devices can talk to each other. 
 So you can build a secure connection between your two computers over the…
When we create a new server in aws, it allows us to generate a key pair and attach it to the server. Now imagine you want to share access to this multiple people in your team, but you don’t want to share your private key. This is what you need to do. 
 
 Generate new key for each member of your team or ask each member for there public keys 
 Add it to the authorized_keys list in…
htop/top is a useful command that helps users understand how much of there CPU (Different core)/RAM are being used. We would like to see the same for GPU there are tools that provide that, but sadly unlike cpu top/htop the ones for GPU are sadly fragmented. Based on your GPU vendor we have different tools to provide us this graphical info. 
 Note: I am talking about tools i tested in…
Dark mode or night mode is becoming more and more popular these days. As the amount of time we are spending in front of the computer increases, we started to look more into on how to improve our experience. Dark mode/Night mode is one such setting. What it does (mainly) is it makes all the white part of the application to black - major chunk of which would be the background. When the color of the…
Contact / Hire me 
 If you wish to contact me to talk to me about my article, projects, or if you wish to hire me as a consultant, developer
or advisor for your project or team. 
 Reach out to me at reachme@hsps.in 
 I am more active over email, than any other mediums.
Projects 
 Link to projects I worked on over the years. There are more in Github . 
 
 
 
 
 Wifi-QR 
 Next.js Vercel 
 
 
 A simple next.js application hosted on vercel, that will generate a sharable QR code of your wifi connection. Using the mobile camera app one can autojoin to this network without needing to type.
 
 
 Live Demo 
 GitHub…
Link to videos of my talks. 
 
 Ruby Conf Taiwan, 2016 - Using database to pull your applications weight 
 Deccan Ruby Conf, 2017 - Using databases to pull your application weight 
 PostgreSQL Conf India, 2017 - Using databases to pull your application weight 
 South Easy Ruby, 2017 (Nashville, USA) 
 Ruby Conf Philippines, 2018 - Embracing Failures to Avoid Meltdown 
…
Rails model helps you define enum on a database integer field quite easily. The enum method which rails provide in its model is not an interface to the enum datatype available in some databases, but converting or using a integer field as an enum. Enum type or Enumerated type is user defined data type where you define the set of value the data type will have. If you consider regular or basic or…