<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vidun Pallegoda on Medium]]></title>
        <description><![CDATA[Stories by Vidun Pallegoda on Medium]]></description>
        <link>https://medium.com/@vinethdina77?source=rss-f5a27954e73d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*3zkPhr2bUqaEFTfsH0pPww.png</url>
            <title>Stories by Vidun Pallegoda on Medium</title>
            <link>https://medium.com/@vinethdina77?source=rss-f5a27954e73d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 22:44:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vinethdina77/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Builds Are Eating Your VPS Resources. Move Them to GitHub Actions.]]></title>
            <link>https://medium.com/@vinethdina77/builds-are-eating-your-vps-resources-move-them-to-github-actions-709e9869a373?source=rss-f5a27954e73d------2</link>
            <guid isPermaLink="false">https://medium.com/p/709e9869a373</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[cicd-pipeline]]></category>
            <category><![CDATA[deployment]]></category>
            <dc:creator><![CDATA[Vidun Pallegoda]]></dc:creator>
            <pubDate>Tue, 08 Sep 2026 17:13:27 GMT</pubDate>
            <atom:updated>2026-09-08T17:13:27.484Z</atom:updated>
            <content:encoded><![CDATA[<p>#githubactions #deployment #VPS</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PeK41FKRkhO0BQmyXnTiig.png" /></figure><p>Your application runs comfortably on a small VPS. Then you deploy an update.</p><p>CPU usage spikes. Memory gets tight. The same server handling live requests is now installing dependencies, compiling code, and building a container image. If resources run short, the build can fail or the application can become less responsive.</p><p>Before upgrading the VPS, it is worth checking how much of that pressure comes from builds.</p><p><strong>An application can need considerably more resources to build than it needs to run.</strong> If deployment is the main source of resource spikes, moving the build elsewhere can free up capacity for the application you are already serving.</p><p>For a Coolify setup, GitHub Actions provides a practical way to do that.</p><p>Coolify officially supports building an image in GitHub Actions, pushing it to a container registry, and then triggering Coolify to deploy the prebuilt image. <a href="https://coolify.io/docs/applications/ci-cd/github/actions">Coolify’s GitHub Actions guide</a></p><p>The flow is straightforward:</p><p><strong>GitHub Actions → Container registry → Coolify on your VPS</strong></p><p>GitHub-hosted runners handle the build. A registry such as GitHub Container Registry stores the finished image. Coolify pulls that image and starts the application.</p><p>The important change is where the expensive work happens.</p><p><strong>Building on the production VPS</strong></p><p>Your VPS handles everything:</p><ul><li>Installing build dependencies</li><li>Compiling and bundling the application</li><li>Building the container image</li><li>Starting the release</li><li>Serving live users</li></ul><p>Storing published release images requires a separate registry setup.</p><p><strong>Building with GitHub-hosted runners</strong></p><p>The work is distributed across three components:</p><ul><li><strong>GitHub Actions:</strong> Installs dependencies, compiles the application, and builds the container image.</li><li><strong>Container registry:</strong> Stores the finished release images.</li><li><strong>Production VPS:</strong> Pulls the image, starts the release, and serves live users.</li></ul><p>This moves the build workload off your production server, leaving more CPU and memory available for your running applications.</p><p>This becomes particularly useful when several applications share one server. A build for one project can compete with every other workload on that machine. Moving builds off the VPS removes that source of competition.</p><p>It does not remove all deployment overhead. Pulling and unpacking images still uses resources, and a rollout may temporarily run both the old and new containers. Your server still needs enough headroom for those operations.</p><p>There is one configuration detail that makes or breaks this approach: <strong>Coolify must deploy the prebuilt image.</strong></p><p>Building in Actions and then triggering Coolify to rebuild the repository duplicates the work. Configure a Docker Image application, or use Docker Compose with an image: reference instead of a local build: configuration. Coolify documents both approaches. <a href="https://coolify.io/docs/applications/ci-cd/github/actions">Coolify’s deployment setup</a></p><p>Also, use a runner outside the production VPS. Installing a self-hosted GitHub Actions runner on that same VPS keeps the build workload on the machine you are trying to relieve.</p><p>A sensible release workflow would:</p><ol><li>Run the required checks against the commit being released.</li><li>Build and smoke-test the container image on a GitHub-hosted runner.</li><li>Push the image to the registry.</li><li>Point Coolify at the intended release and trigger deployment.</li><li>Verify that deployment completes and the application is healthy.</li></ol><p>The resource benefit comes from moving the build. The workflow also gives you a place to require checks before deployment and retain identifiable release images.</p><p>For example, tag each image with its full Git commit SHA and record its image digest. Commit tags help connect releases to source code; digests identify the exact image content because tags can be overwritten. Keeping those images lets you redeploy an earlier artifact without rebuilding it. <a href="https://docs.docker.com/dhi/explore/security-concepts/digests/">Docker’s image digest documentation</a></p><p>That is useful during a rollback, although database changes still need their own compatibility plan.</p><p>What does this actually save?</p><p><strong>It saves build-related CPU and memory usage on the production VPS.</strong> It can help you stay on an existing server plan longer when builds are the bottleneck. It does not reduce the memory your running application needs, and it does not automatically lower a fixed monthly VPS bill.</p><p>The compute work moves to GitHub’s runners. For private repositories, GitHub Actions includes an allowance based on your plan, with additional usage subject to billing. Check your build frequency, runner usage, and registry costs before assuming the change is free. <a href="https://docs.github.com/en/billing/concepts/product-billing/github-actions">GitHub Actions billing</a></p><p>To judge whether the change is worthwhile, compare peak VPS CPU and memory usage during equivalent deployments before and after moving the build. Check application response times during those deployments too. Those measurements will tell you whether builds were actually competing with live traffic.</p><p>If your VPS struggles mainly when you deploy, moving builds to GitHub Actions is a practical step to evaluate before buying more server capacity. Keep Coolify handling the deployment, and give your live application more room to run.</p><h3>Steps</h3><p><strong>1. Enable Coolify API access</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n9aZxSiFcHWCg-4EyRt6Tw.jpeg" /></figure><p><strong>2. Create a token with deployment permissions</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-iOPdUy1C4QQe1A5TGFFcQ.jpeg" /></figure><p><strong>3. Add deployment credentials to GitHub Actions secrets</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OuVWCMmnZ6h_eDg1lMdzIA.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=709e9869a373" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fail-Safe Design in AI Applications: Build for When AI Gets It Wrong]]></title>
            <link>https://medium.com/@vinethdina77/fail-safe-design-in-ai-applications-build-for-when-ai-gets-it-wrong-25012d5fc20b?source=rss-f5a27954e73d------2</link>
            <guid isPermaLink="false">https://medium.com/p/25012d5fc20b</guid>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ai-design-patterns]]></category>
            <dc:creator><![CDATA[Vidun Pallegoda]]></dc:creator>
            <pubDate>Thu, 02 Jul 2026 06:35:40 GMT</pubDate>
            <atom:updated>2026-07-02T06:35:40.595Z</atom:updated>
            <content:encoded><![CDATA[<p>#failsafedesign #designpatterns #aisystemdesign</p><p>AI applications are exciting because they can reason, summarize, classify, and make decisions faster than humans. But here is the uncomfortable truth: AI can be wrong.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*-YUjG9IBlGxUoa63.gif" /></figure><p>It can hallucinate. It can misunderstand context. It can be overconfident. It can fail silently. And when the application handles sensitive information, fraud detection, finance, healthcare, legal work, or security, one wrong answer is not just a bug. It can become real damage.</p><p>That is where <strong>fail-safe design</strong> matters.</p><p>Fail-safe design means building an AI system that remains safe even when the AI model makes a mistake. Instead of asking, “How do we make the model smarter?”, we also ask, “What happens when the model fails?”</p><p>A good AI system should not blindly trust the model. It should guide the model, limit the model, verify the model, and know when to stop.</p><p>One lesson I learned while working on AI systems for sensitive document analysis is this: <strong>AI should not be the first source of truth. Evidence should be.</strong></p><p>Before asking an AI model to make a decision, the system should collect reliable signals first. That can be rules, metadata, logs, validation checks, file structure, user history, or other deterministic evidence. The AI should then explain and interpret the evidence, not invent the evidence.</p><p>Another important principle is privacy. In a fail-safe AI system, sensitive data should not move around freely just because the AI needs context. The safer approach is to process as much as possible locally, remove personal information, and only send the minimum required summary to external services. Privacy should not be a paragraph in a policy. It should be part of the system pipeline.</p><p>Fail-safe systems also need confidence handling. Not every output should become an automatic decision. Some results should be marked as “low confidence,” “needs review,” or “suspicious but not confirmed.” This is especially important in applications where false positives can hurt trust and false negatives can create risk.</p><p>The human should stay in the loop.</p><p>That does not mean humans must do everything manually. It means the system should give people clear explanations, show why something was flagged, and allow corrections. Over time, those corrections can help the system reduce repeated mistakes.</p><p>A simple fail-safe AI checklist looks like this:</p><ol><li>Do not let the AI see more data than it needs.</li><li>Do not let the AI make final decisions without evidence.</li><li>Do not hide uncertainty.</li><li>Do not store sensitive data unless necessary.</li><li>Always keep logs, explanations, and review paths.</li><li>When something feels risky, fail closed instead of failing open.</li></ol><p>The future of AI is not just about more powerful models. It is about more responsible systems around those models.</p><p>The best AI applications will not be the ones that say, “Trust me, I am intelligent.”</p><p>They will be the ones that say, “Here is the evidence, here is my confidence, here is what I am unsure about, and here is where a human should review.”</p><p>That is what fail-safe AI should feel like.</p><p>Vidun.<br><a href="https://www.linkedin.com/in/vidun-pallegoda/">https://www.linkedin.com/in/vidun-pallegoda/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=25012d5fc20b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Shipping Apps, Start Shipping Data: Why Your Backend Wants to Control Your UI]]></title>
            <link>https://medium.com/@vinethdina77/stop-shipping-apps-start-shipping-data-why-your-backend-wants-to-control-your-ui-3b7c9d3ad63e?source=rss-f5a27954e73d------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b7c9d3ad63e</guid>
            <category><![CDATA[server-driven-ui]]></category>
            <category><![CDATA[ui]]></category>
            <dc:creator><![CDATA[Vidun Pallegoda]]></dc:creator>
            <pubDate>Mon, 01 Jun 2026 17:40:51 GMT</pubDate>
            <atom:updated>2026-06-01T17:40:51.796Z</atom:updated>
            <content:encoded><![CDATA[<p>#SDUI #ServerDrivenUI</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ke6ele1NWwHk2YMdeYaGfQ.png" /></figure><p>Have you ever noticed WhatsApp, TikTok, or Facebook suddenly feels different without you even updating the apps? Surprises me too!!</p><p>One day the buttons are at the bottom, the next day they’ve moved to the top, or a whole new feature magically appears on your home screen. You didn’t open the App Store. You didn’t hit “Update.” It just… changed.</p><p>If you have ever built digital products, you know this feels like dark magic. Traditionally, changing a user interface meant diving back into the code, submitting a new version to Apple or Google, and waiting days for the “Review Gods” to approve it.</p><p>So, how are the tech giants bypassing the App Store waiting game entirely?</p><p>Welcome to the hidden engine of modern apps: <strong>Server-Driven UI (SDUI)</strong>.</p><h4>The “Dumb” Canvas</h4><p>To understand how this works, we have to look at how apps are traditionally built.</p><p>In the old paradigm, the app you download holds all the blueprints. It knows exactly what a button looks like, what color the header is, and where the text goes. When you open it, the app just asks the server for the <em>data</em> (like your messages or today’s news) to fill in the blanks.</p><p>Server-Driven UI flips this entirely.<br>With SDUI, the app downloaded to your phone is essentially a “dumb” blank canvas. It doesn’t know what it’s supposed to look like until it connects to the internet. The server doesn’t just send the data — it sends an <strong>instruction manual</strong>.</p><p>The server tells the app: <em>“Draw a blue button here. Put a video carousel there. Make this text bold.”</em></p><p>We shift from shipping finished apps to shipping instructions. The app becomes the paintbrush, and the server becomes the artist.</p><h4>Why Tech Giants Are Obsessed</h4><p>This isn’t just a cool party trick; it’s a massive competitive advantage. When you are operating at the scale of Uber or Spotify, velocity is everything.</p><ul><li><strong>Total Context:</strong> Lyft uses this to completely reshape your screen based on intent. If you are looking for a bike, the app physically arranges itself differently than if you are booking a ride to the airport.</li><li><strong>The A/B Testing Dream:</strong> Meta and TikTok can test a new layout on a million users on a Tuesday, realize it doesn’t work, and revert it on Wednesday — all without anyone ever downloading an update.</li><li><strong>Platform Harmony:</strong> Airbnb realized that keeping iOS, Android, and Web looking identical was a nightmare. By letting the backend dictate the structure, they write the layout rules once, and all three platforms instantly fall in line.</li></ul><h4>The Catch: It’s Not Magic, It’s Architecture</h4><p>If it’s so great, why isn’t every startup doing it? Because building an SDUI engine is a monumental engineering challenge.</p><p>You aren’t just sending a little JSON; you are building a universal language that your frontend and backend must perfectly agree on. And when it breaks, it breaks hard. If a traditional app has a slow connection, you might get a loading spinner but you still see the app’s skeleton. In a pure SDUI world, if the instruction manual gets lost in transit, the app has no idea what to draw. You get the dreaded “Blank Screen of Death.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/0*EVxKLigQLD7rYvkk.gif" /></figure><p>You also have to manage versioning. If your server tells a two-year-old version of your app to draw a “Glassmorphism Card” that it doesn’t have the code for, the app might just crash.</p><h4>The Future of Building</h4><p>We are moving toward a world where the interface is entirely fluid. As web frameworks like React Server Components bring this philosophy to the browser, the line between what happens on your device and what happens in the cloud is blurring.</p><p>The ultimate dream is “One Schema to Rule Them All” — a single expression of intent from a backend that renders perfectly on an iPhone, a browser, and eventually, whatever device comes next.</p><p>So, the next time your favorite app shape-shifts in your hands, you’ll know the secret. You aren’t just looking at an app; you’re looking at a live broadcast.</p><p>Vidun Pallegoda.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b7c9d3ad63e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Benchmark of UUID v4 vs UUID v7]]></title>
            <link>https://medium.com/@vinethdina77/benchmark-of-uuid-v4-vs-uuid-v7-740c230437fe?source=rss-f5a27954e73d------2</link>
            <guid isPermaLink="false">https://medium.com/p/740c230437fe</guid>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[uuid]]></category>
            <category><![CDATA[database-performance]]></category>
            <category><![CDATA[websocket]]></category>
            <category><![CDATA[phoenix-framework]]></category>
            <dc:creator><![CDATA[Vidun Pallegoda]]></dc:creator>
            <pubDate>Fri, 26 Dec 2025 18:03:30 GMT</pubDate>
            <atom:updated>2025-12-26T18:03:30.279Z</atom:updated>
            <content:encoded><![CDATA[<h4>Why Randomness Kills Database Performance: An Exploration with Elixir &amp; Phoenix technologies you won’t learn in college.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*_kNRRO5NPjZFUKOJa05kHw.gif" /></figure><p>Here is a frustrating reality many of us face: while we are in lecture <br>halls meticulously tracing Bubble Sort algorithms on paper for the hundredth time, the tech industry is out there building Skynet. There is often a massive gap between university computer science curricula and the tools actually driving the modern world. <strong>During my recent internship</strong>, I encountered <strong>incredible technologies</strong> that I never heard mentioned in class, mostly because they weren’t invented in the 90s. Out of frustration; and a desire to help other curious future engineers who are tired of writing “Hello World” in Java, I’m starting this blog series.<strong> I plan to continue writing from time to time about the “hipster vinyl collection” of tech stacks: tools that are unheard of or unpopular in college syllabi, but are absolute powerhouses in the industry.</strong></p><p>Episode one is about a mind-bending ecosystem I stumbled upon: <strong>Elixir</strong> and the <strong>Phoenix Framework</strong>. Elixir is a functional language built on the Erlang VM, which was originally designed for massive telecom systems. You know, the kind of systems that are supposed to have 99.9999999% uptime so your grandmother’s phone call never drops? Phoenix takes that “unkillable” energy to the web. Unlike traditional frameworks where concurrency is a headache managed with complex threading (which usually results in you crying over race conditions), Elixir handles millions of lightweight processes effortlessly. It fundamentally changes how you think about building backend systems. Honestly, using it feels a bit like bringing a flamethrower to a snowball fight; it’s fast, stable, and feels almost unfair to other languages I’ve learned.</p><p>The real superpower here, however, is how Phoenix handles <strong>WebSockets and Data Streaming</strong>. In college, <strong>we mostly learn the standard Request/Response cycle</strong>. The client asks “Do you have data?”, the server says “No.” Five seconds later: “Do you have data now?”, Server: “No.” It’s like a toddler asking “Are we there yet?” for 4 hours.<br><strong>Modern apps need to be alive. This requires WebSockets</strong>, which keep a persistent connection open so the server can just slide into the client’s DMs the moment data arrives. In many stacks, maintaining thousands of these connections turns your server into a toaster. In Phoenix, it’s trivial. This is the same engine behind tools like <strong>Supabase</strong>, and if it’s good enough for them, it’s definitely good enough for my laptop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*PRkK9wz-6kBPeW-Gn0ajww.gif" /></figure><p><em>(For those looking to dive deeper, check out the official </em><a href="https://elixir-lang.org/"><em>Elixir</em></a><em> and </em><a href="https://www.phoenixframework.org/"><em>Phoenix</em></a><em> documentation. I won’t cover installation here, as their guides are excellent, and I trust you can run a terminal command without setting your house on fire.)</em></p><h3>The Core Concept: The Battle of the UUIDs</h3><p>To demonstrate the power of this stack, I built a benchmark app. But first, we need to understand <em>what</em> I am benchmarking: Universally Unique Identifiers (UUIDs).</p><h4>What and Why?</h4><p>In the old days of monolithic applications, simple auto-incrementing integers (1, 2, 3…) worked fine. It was simple, like my high school wardrobe. But in modern distributed systems, where you might have database shards across different continents; coordinating a central counter is a nightmare. It’s like trying to get 50 people to agree on a pizza topping via Zoom. We need a way for different systems to generate unique IDs independently without ever colliding. Enter the UUID: a 128-bit number so unique it probably has its own social security number.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*ftcHqmbfiXeE4t8XVogtRw.gif" /></figure><h4>The Structural Difference: UUID v4 vs. UUID v7</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*bj8_9OOHj321Ptxz.png" /><figcaption>UUID v4 Structure</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*o5-ezZiY4x22xvQ-.png" /><figcaption>UUID v7 Structure</figcaption></figure><p>Not all UUIDs are created equal. The standard for years has been <strong>UUID v4</strong>, which is essentially 122 bits of pure, unadulterated chaos. It’s random. It’s wild. It’s the party animal of identifiers.</p><p>Recently, <strong>UUID v7</strong> has entered the chat. It is still 128 bits, but it changes the recipe. Instead of pure randomness, v7 dedicates the first 48 bits to a UNIX timestamp (milliseconds since 1970), followed by some randomness.</p><p>Because v7 starts with a timestamp, <strong>UUID v7s are time-ordered</strong>. They are the polite older sibling. If you generate two v7s five minutes apart, the second one will politely stand <em>behind</em> the first one in line. A v4 UUID generated later might try to cut in line, scream, and stand wherever it wants.</p><h4>Why Structure Matters: Postgres and Indexing</h4><p>Why does this ordering matter? It comes down to how databases like PostgreSQL store data. Postgres uses an algorithm called a <strong>B-Tree</strong> for its primary key indexes. B-Trees are like strict librarians; they love order.</p><p>When you insert <strong>UUID v7s</strong> (which are sequential), Postgres is happy. It just keeps appending new pages to the end of the B-Tree index. Smooth. Zen.</p><p>When you insert <strong>UUID v4s</strong> (which are completely random), Postgres panics. It has no idea where to put the next ID. It might have to shove it into the middle of an existing, full index page. To make room, the database has to split that page into two. This “page splitting” is expensive; it takes CPU cycles, creates a mess, and leaves your index looking like swiss cheese (fragmented). Basically, v4 makes your database sweat.</p><h4>Industry Standards and Trade-offs</h4><p>Currently, UUID v4 remains the industry standard largely due to inertia; “we’ve always done it this way” is a powerful drug. However, for high-write volume databases, shifting to v7 offers significant performance gains.</p><p>Are there downsides to v7?</p><ol><li><strong>Theoretical Duplication:</strong> If you have multiple nodes generating IDs and the system clock rewinds rapidly (time travel?), a collision is theoretically possible. But you’re more likely to be struck by lightning while winning the lottery.</li><li><strong>Predictability:</strong> Because the first half of a v7 is just a timestamp, they are predictable. You should <strong>never</strong> use UUID v7 for session tokens unless you want hackers to guess your session ID based on what time you ate lunch. For sensitive data like auth or payments, stick to the chaos of v4. For everything else, v7 is the king.</li></ol><h3>The Benchmark: Seeing is Believing</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fqm-ltyvlzaefCKkpFgdSA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V9HHZyOZ7fqLZRkmJWIGpw.jpeg" /><figcaption>Write (1,000,000 Rows) &amp; Read (5000 random rows)</figcaption></figure><p>I combined these concepts to build a real-time benchmarking application. I used Elixir and Phoenix LiveView to create a dashboard that streams logs via WebSockets as it politely hammers a Postgres database with <strong>1,000,000 inserts</strong> using UUID v4, followed by 1,000,000 inserts using UUID v7. It then runs read tests (Select queries) against both sets of data to see how fast we can fetch them back.</p><p>The results were eye-opening. While the raw insertion speed was competitive, the “Read” operations on UUID v7 were consistently more stable because the database index wasn’t a fragmented mess. The dashboard clearly visualizes the write-performance degradation caused by random v4 indexing (crying in the corner) versus the smooth, sequential nature of v7 (doing a victory lap).</p><p>Since I have mentioned the technologies used for the app in the first few paragraphs, you now have a clear idea of what’s happening under the hood. <strong>Go ahead and clone my repository here: </strong><a href="https://github.com/Vidundesu/UUID-Benchmark"><strong>Vidundesu/UUID-Benchmark</strong></a> You will need Postgres running (a Docker container is the easiest way, unless you enjoy manually installing databases, you masochist). Replace the database configurations in config/dev.exs with your local setup, run the Phoenix server, and hit the start button. Watch the numbers go brrr and check the final timings yourself.</p><p>Explore this further and let me know what you find! This blog is a learning journey for me as well. If you are an industry expert reading this and find inaccuracies in my explanation of B-Trees or Elixir, please correct me in the comments. Thank you for reading, and write forward.</p><p>Stay Tuned.<br>Connect with me on Linkedin: <a href="https://www.linkedin.com/in/vidun-pallegoda/">https://www.linkedin.com/in/vidun-pallegoda/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=740c230437fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Actually Free Disk Space on Linux]]></title>
            <link>https://medium.com/@vinethdina77/how-to-actually-free-disk-space-on-linux-without-guessing-or-breaking-things-c7d4381a3c3e?source=rss-f5a27954e73d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c7d4381a3c3e</guid>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[unix-command]]></category>
            <category><![CDATA[linux-os]]></category>
            <dc:creator><![CDATA[Vidun Pallegoda]]></dc:creator>
            <pubDate>Tue, 23 Dec 2025 08:39:47 GMT</pubDate>
            <atom:updated>2025-12-23T13:51:31.219Z</atom:updated>
            <content:encoded><![CDATA[<h4>(Without Guessing or Breaking Things)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RuwKJtc5NGy4-knwsKTVJQ.png" /></figure><p>When a Linux system runs out of disk space, the instinct is to delete old kernels and hope for the best. This sometimes works. Often, it does nothing. At that point, frustration sets in and people start eyeing /usr like it personally betrayed them.</p><p>This guide explains how to free disk space <strong>correctly</strong>, using measurement instead of superstition, and why Linux tends to look innocent while quietly hoarding gigabytes in the background.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*TkABJLx-h0Z8hNehe1S42g.gif" /><figcaption><strong>How Linux be acting while your space running out:</strong></figcaption></figure><h3>Confirm Kernel Reality (Don’t blame the wrong thing)</h3><p>Start by checking which kernel images are actually installed</p><pre>dpkg --get-selections | grep linux-image</pre><p>Entries marked deinstall look scary but take up <strong>zero</strong> disk space. They are basically ghosts. Only kernels marked install matter.</p><p>Best practice:</p><ul><li>Keep the current kernel</li><li>Keep one previous kernel as a safety net</li><li>Delete everything else, not out of anger, but discipline</li></ul><p>Then run</p><pre>sudo apt autoremove --purge</pre><p>If the disk is still full, the kernel is innocent. Move on.</p><h3>Measure First, Judge Later</h3><p>Linux does not hide disk usage. It just refuses to summarize it for you. <br>Run a clean top-level scan:</p><pre>sudo du -xh --exclude=/proc --exclude=/sys --exclude=/run --exclude=/tmp -d1 / | sort -h</pre><p>This immediately shows where space is going. In most cases, three directories stand out:</p><ul><li>/home — your files and questionable downloads</li><li>/usr — system packages doing their job</li><li>/var — where background services quietly accumulate stuff</li></ul><p>When /var is large, you are not “running out of space.” You are <strong>running unattended services</strong>.</p><h3>Open /var and Let It Confess</h3><pre>sudo du -xh -d1 /var | sort -h</pre><p>If /var/lib dominates, congratulations! you’ve found the stash. /var/lib is where well-meaning tools keep data forever, just in case you change your mind in six months.<br>Go deeper:</p><pre>sudo du -xh -d1 /var/lib | sort -h</pre><p>At this point, the filesystem stops being subtle.</p><h3>Identify the Professional Hoarders</h3><p>These directories almost always top the list:</p><ul><li>/var/lib/snapd</li><li>/var/lib/flatpak</li><li>/var/lib/docker</li></ul><p>None of them are bugs. All of them assume disk space is infinite and you are emotionally attached to old versions.<br>They are wrong.</p><h3>Clean Snap (It Will Resist)</h3><p>Snap keeps multiple revisions of each app for rollback. That’s responsible. It’s also expensive.<br>List everything:</p><pre>snap list --all</pre><p>Disabled revisions are inactive and safe to remove. Clean them automatically:</p><pre>for snap in $(snap list --all | awk &#39;/disabled/{print $1, $3}&#39;); do<br>  sudo snap remove $snap<br>done</pre><p>Active snaps remain untouched. Disk space breathes again.</p><h3>Clean Flatpak (It Pretends to Be Minimal)</h3><p>Flatpak keeps unused runtimes and caches because one day you <em>might</em> reinstall something.<br>Remove what isn’t used:</p><pre>flatpak uninstall --unused</pre><p>Clear the cache:</p><pre>rm -rf ~/.cache/flatpak</pre><p>Flatpak becomes significantly smaller and slightly less smug.</p><h3>Clean Docker (It Never Forgets)</h3><p>Docker treats disk space like a historical archive.<br>Check usage:</p><pre>docker system df</pre><p>Remove unused artifacts</p><pre>docker system prune -a</pre><p>Active containers survive. Everything else is finally allowed to rest.</p><h3>Principles Worth Remembering</h3><ul><li>Disk cleanup works top-down, not by deleting random folders</li><li>du tells the truth even when it’s inconvenient</li><li>Package managers optimize for safety, not minimalism</li><li>If you use Snap, Flatpak, or Docker, cleanup is maintenance, not an emergency task</li></ul><h3>Final Thought</h3><p>When Linux says the disk is full, it’s not being dramatic. It’s being literal. The system rarely wastes space, it <strong>stores it carefully and never throws it away unless you explicitly say so</strong>.</p><p>Learn to follow the numbers, and disk space stops being a mystery and starts behaving like a resource you actually control.</p><p>Stay Tuned.<br>Connect with me on Linkedin: <a href="https://www.linkedin.com/in/vidun-pallegoda/">https://www.linkedin.com/in/vidun-pallegoda/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7d4381a3c3e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Keep your vibe start away from risk ; follow these 5 tips or ask Ai agent to follow those!]]></title>
            <link>https://medium.com/@vinethdina77/keep-your-vibe-start-away-from-risk-follow-these-5-tips-or-ask-ai-agent-to-follow-those-e7139784fce6?source=rss-f5a27954e73d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7139784fce6</guid>
            <category><![CDATA[vibe-coding]]></category>
            <category><![CDATA[vulnerability-management]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[ai-coding-assistant]]></category>
            <category><![CDATA[ai-agents-in-action]]></category>
            <dc:creator><![CDATA[Vidun Pallegoda]]></dc:creator>
            <pubDate>Mon, 22 Dec 2025 14:27:36 GMT</pubDate>
            <atom:updated>2025-12-22T14:27:36.458Z</atom:updated>
            <content:encoded><![CDATA[<h3>Keep your vibe start away from risk ; follow these 5 tips or ask Ai agent to follow those!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IxsA7vVdDrsMBeo1" /></figure><p>You can code an app in a weekend with AI, but if you hand over a project that leaks customer data or bankrupts the client via API costs, you won’t get hired again. Security is the difference between a “prototype” and a “product.”</p><h4><em>Here are 5 crucial security layers you (or your AI agent) must implement.</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*ed2qLQ2SYoROp-thKDhSlA.gif" /></figure><h3>Hard coding API keys &amp; pushing env files to GitHub</h3><p><strong>The Danger:</strong> Hardcoding API keys embeds your secret credentials directly into the source code where anyone who views the file can steal them. Attackers constantly scrape public repositories for these patterns to steal resources, potentially costing you thousands of dollars in unauthorized usage fees within minutes. Once a key is exposed in your git history, it is considered compromised forever and must be revoked immediately.</p><p><strong>The Solution (.env files):</strong> An .env file allows you to store sensitive configuration variables in a simple text file that lives only on your local machine or secure server. When your application starts, libraries like dotenv load these variables into the system&#39;s memory (e.g., process.env), keeping them separate from your actual code logic. This ensures that even if you share your code, the secrets remain private and are never written into the codebase itself.</p><p><strong>Git Protection:</strong> You must add .env to your .gitignore file before your very first commit to ensure it is never tracked or pushed to GitHub.</p><p><strong>Modern Management (Dotenvx):</strong> For better security, use dotenvx to encrypt your secrets. This allows you to commit an encrypted .env.vault file safely while keeping the decryption key private.</p><ul><li><strong>Run:</strong> npx dotenvx encrypt (converts your secrets into encrypted strings).</li><li><strong>Deploy:</strong> Set the DOTENV_PRIVATE_KEY on your production server (e.g., Vercel/Netlify) to decrypt secrets at runtime.</li><li><strong>Docs:</strong> <a href="https://dotenvx.com/docs/quickstart/encryption">https://dotenvx.com/docs/quickstart/encryption</a></li></ul><h3>Rate Limiters</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*yQhWy4S7wrvf0QxDu1Om7Q.gif" /></figure><p>Rate limiting is the bouncer for your API. Without it, a single malicious user (or a buggy loop in your frontend code) can hit your API thousands of times per second, crashing your database or racking up a massive bill on usage-based services like OpenAI or Firebase.</p><p><strong>Implementation (Next.js + Supabase/Redis):</strong> The standard way to handle this in the “Vibe Stack” (Next.js) is using Middleware. You intercept the request before it hits your database.</p><p><strong>The “Pro” Way (Upstash):</strong> The easiest implementation uses <em>@upstash/ratelimit</em> because it works perfectly in serverless environments where local memory doesn&#39;t persist.</p><pre>// middleware.ts in Next.js<br>import { NextRequest, NextResponse } from &#39;next/server&#39;;<br>import { Ratelimit } from &#39;@upstash/ratelimit&#39;;<br>import { Redis } from &#39;@upstash/redis&#39;;<br><br>const ratelimit = new Ratelimit({<br>  redis: Redis.fromEnv(),<br>  limiter: Ratelimit.slidingWindow(10, &#39;10 s&#39;), // Allow 10 requests per 10 seconds<br>});<br><br>export default async function middleware(request: NextRequest) {<br>  const ip = request.ip ?? &#39;127.0.0.1&#39;;<br>  const { success } = await ratelimit.limit(ip);<br><br>  if (!success) {<br>    return NextResponse.json({ error: &#39;Too many requests&#39; }, { status: 429 });<br>  }<br>  return NextResponse.next();<br>}</pre><h3>Paginated Data Fetching</h3><p><strong>Why it is crucial:</strong> Pagination is not just a UI feature; it is a security necessity to prevent <strong>Resource Exhaustion Attacks</strong>. If you allow a client to request “all users” or “all transactions” without a limit, an attacker can trigger a single query that attempts to load millions of rows into memory. This will spike your server’s CPU and RAM, causing a Denial of Service (DoS) for everyone else. Always enforce a hard limit on your database queries (e.g., limit 20) regardless of what the frontend asks for.</p><h3>Debounced API calls and Load Balancers</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/427/1*781k0h6OtppPnvC1IepaZA.gif" /></figure><p>These are two different layers of protection that work together to keep your app stable.</p><p><strong>Debouncing (Client-Side):</strong> This protects your API from <em>unintentional</em> spam by legitimate users. For example, if you have a search bar that queries the database, you don’t want to fire a request for every letter typed (“c”, “ca”, “cat”). Debouncing waits until the user stops typing (e.g., 300ms) before sending <strong>one</strong> request.</p><ul><li><em>Tip:</em> Use useDebounce hooks in React or lodash.debounce</li></ul><p><strong>Load Balancers (Infrastructure-Side):</strong> This protects your backend servers from <em>traffic spikes</em>. A load balancer sits in front of your servers and distributes incoming traffic across multiple instances. If one server gets overwhelmed or crashes, the load balancer redirects traffic to the healthy ones.</p><ul><li><em>Note:</em> If you deploy on Vercel or Netlify, they handle basic load balancing for you automatically.</li></ul><h3>Row Level Security (RLS)</h3><p><strong>Why:</strong> This is the most common vulnerability in apps built with “Backend-as-a-Service” tools like Supabase or Firebase. By default, your database might be accessible to anyone with a public API key. “Vibe coders” often turn RLS off to get the app working quickly, leaving the database wide open for anyone to DELETE * FROM users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/327/1*4nwxIPoZ9XQWZScGeEMTSA.gif" /></figure><p><strong>The Fix:</strong> Never turn RLS off. Instead, write policies that explicitly define who can see what.</p><p><strong>Example (Supabase SQL):</strong> Even if a hacker mimics a request, the database engine itself rejects it because the user’s ID doesn’t match the row’s owner ID.</p><pre>-- Enable RLS on the table<br>ALTER TABLE profiles ENABLE ROW LEVEL SECURITY;<br><br>-- Create a policy: &quot;Users can only update their own profile&quot;<br>CREATE POLICY &quot;Users can update own profile&quot;<br>ON profiles<br>FOR UPDATE<br>USING (auth.uid() = user_id);</pre><h3>Fast Code Doesn’t Have to Be Fragile Code</h3><p>The “Vibe Coding” movement is powerful because it breaks down the barrier between <em>having an idea</em> and <em>building it</em>. But remember: <strong>AI is an accelerator, not a safety net.</strong></p><p>When you copy-paste code from an LLM, you are inheriting its logic, but you are also inheriting the responsibility for that logic. Your clients don’t care that you built their MVP in a weekend; they care that their user data didn’t get leaked on Monday morning.</p><p>You don’t need to be a cybersecurity expert to be safe. By simply locking down your environment variables with dotenvx, putting a bouncer at the door with rate limiters, and enabling Row Level Security, you move from being a &quot;script kiddie&quot; to a professional engineer.</p><p><strong>What’s Next? Stop WhatsApping API Keys.</strong> We have all been there — you add a new dev to the team and immediately DM them: <strong><em>“Hey bro, here is the Supabase key, and here is the OpenAI key…”</em></strong></p><p>In my next blog, I’m going to show you a professional workflow for a 3-person “vibe team.” I will walk you through setting up a centralized <strong>Dotenvx Hub</strong> where you can invite members via email. No more copy-pasting secrets in chat; your team will simply clone the repo, run a single decrypt command, and start coding instantly.</p><p>Stay tuned.</p><p>Connect with me on: <a href="https://www.linkedin.com/in/vidun-pallegoda/">https://www.linkedin.com/in/vidun-pallegoda/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7139784fce6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up VIM on your linux machine]]></title>
            <link>https://medium.com/@vinethdina77/setting-up-vim-on-your-linux-machine-3a581ac94954?source=rss-f5a27954e73d------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a581ac94954</guid>
            <category><![CDATA[ide]]></category>
            <category><![CDATA[vim]]></category>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[linux-tutorial]]></category>
            <dc:creator><![CDATA[Vidun Pallegoda]]></dc:creator>
            <pubDate>Fri, 30 May 2025 11:06:51 GMT</pubDate>
            <atom:updated>2025-11-12T04:39:48.137Z</atom:updated>
            <content:encoded><![CDATA[<p>#vim #linux #vimeditor</p><h4>What is Vim</h4><p>Vim (short for Vi IMproved) is a highly configurable, powerful, and efficient text editor built for both command-line and graphical interfaces. Originally created as an enhanced clone of the Unix editor vi, Vim has grown into a tool beloved by developers, system administrators, and power users alike for its speed, customizability, and keyboard-driven interface.</p><p>Unlike typical graphical text editors, Vim doesn’t rely on a mouse — instead, it offers multiple modes for navigation, editing, and command execution, allowing users to perform complex text manipulation with minimal keystrokes. This unique approach may come with a learning curve, but once mastered, Vim can significantly boost your productivity.</p><p>Whether you’re editing configuration files, writing code, or simply want to level up your terminal skills, Vim is a must-have tool in any Linux user’s toolkit.</p><h4>Getting started with Vim: Install Vimtutor</h4><p>The best way to start learning Vim is through an interactive guide called vimtutor. It’s a beginner-friendly tutorial that runs directly in the terminal and walks you through the basic commands and concepts of Vim step by step.</p><p>To install vimtutor on your Linux machine, follow these steps depending on your distribution:</p><pre>sudo apt update<br>sudo apt install vim</pre><p>Once installed, you can launch the tutorial by typing:</p><pre>vimtutor</pre><p>However after you run the above command, your terminal might look blank like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*BzwVJl5KHfYyRU0zKI6Wug.png" /></figure><p>On many Ubuntu systems (especially minimal or default desktop installations), the pre-installed version of Vim is a lightweight package called vim-tiny. While vim-tiny is sufficient for basic text editing and vi-compatibility, it is <strong>compiled without many of Vim&#39;s advanced features</strong>, including <strong>Vim script support</strong> — which vimtutor depends on to function properly.</p><p>That’s why launching vimtutor with vim-tiny results in a blank screen: the command relies on scripting capabilities that simply aren’t there.</p><p>We can solve this by installing one of the more capable Vim variant packages instead:</p><ul><li>Vim-GNOME</li><li>Vim-Athena</li><li>Vim-GTK</li></ul><pre>sudo apt update<br>sudo apt install vim-athena</pre><p>Now check vimtutor on your terminal, it should show lessons and instructions on how to use vim.</p><pre>vimtutor</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*NiEEYOkA2eAOBS630BHwYw.png" /></figure><p>Vim is a powerful editor that can feel intimidating at first — but with the right tools and a bit of guidance, it quickly becomes an invaluable part of your Linux toolkit. Starting with vimtutor is one of the best ways to build a solid foundation in Vim, helping you develop muscle memory for essential commands and editing workflows.</p><p>With vimtutor now up and running, you’re ready to begin your journey into one of the most efficient and customizable text editors ever created. Practice regularly, experiment with commands, and explore Vim’s vast plugin ecosystem as you grow more comfortable.</p><p>Vidun Pallegoda<br><a href="https://medium.com/www.linkedin.com/in/vidun-pallegoda">https://www.linkedin.com/in/vidun-pallegoda/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a581ac94954" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Power of the “What If” Game: A Beginner Developer’s Perspective on Curiosity and Positivity]]></title>
            <link>https://medium.com/@vinethdina77/the-power-of-the-what-if-game-a-beginner-developers-perspective-on-curiosity-and-positivity-945409f24465?source=rss-f5a27954e73d------2</link>
            <guid isPermaLink="false">https://medium.com/p/945409f24465</guid>
            <category><![CDATA[positivity]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[curiosity]]></category>
            <category><![CDATA[entrepreneurship]]></category>
            <dc:creator><![CDATA[Vidun Pallegoda]]></dc:creator>
            <pubDate>Sun, 18 May 2025 20:02:04 GMT</pubDate>
            <atom:updated>2025-05-18T20:02:04.444Z</atom:updated>
            <content:encoded><![CDATA[<p>#what-if #success #curiosity_in_Engineering #positivity</p><p>Lately, I’ve been seeing a lot of quotes and videos about the “What If” game — things like “What if I fail?” or “What if I can’t do that?” <strong>Many people talk about this mindset as something that holds you back</strong>, especially when you’re trying to become an entrepreneur. But as a software developer, I think the “What If” game is actually crucial; not to paralyze you with fear, but to help you build scalable, high-performance systems. The key is how you play the game. You have to focus on the “What If” game positively.</p><p>I want to share how I use the “What If” game as a beginner software developer to improve my applications and, as a self-employed developer, how I apply it positively in the business world.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*NCnz7GKip5NRFi1ZR63gPg.gif" /></figure><h4>The “What If” Game as a Beginner Developer</h4><p>When I first started learning system development and web development, like many others, I built applications exactly the way my instructors taught me. I followed the tutorials step-by-step, and I noticed many people just copied the code without questioning it. I did the same at first.</p><p>But then one day, I caught myself thinking, “What if I implement this differently? What if there’s a better way to handle this logic?” My mind just wouldn’t let me rest. Even now, as a beginner full-stack developer, I’m constantly wondering about alternative approaches, better designs, and more efficient solutions.</p><p>That endless questioning — that “What If” game — has kept me curious. It pushes me to:</p><p>&gt; Find new ways to solve problems<br>&gt; Overcome obstacles by thinking outside the box<br>&gt; Approach development with system pattern thinking</p><p>Honestly, this mindset is what keeps me growing and learning. Every successful engineer I’ve read about or admired shares this trait of curiosity. Nikola Tesla was endlessly curious. Elon Musk’s innovations come from a mindset that questions everything. Henry Ford revolutionized the automobile industry because he kept asking, “What if?”</p><p>In fact, curiosity starts with a “What If” question. So if you want to be a successful engineer or developer, cultivate this curiosity. Never settle for the first solution. Always ask, “<strong>What if there’s a better way?”</strong></p><h4>The “What If” Game in Entrepreneurship</h4><p>On the flip side, if you’re an entrepreneur, the “What If” game can sometimes hold you back , especially if you focus on the negative possibilities.</p><p>When I got my first client, I was terrified. I thought, “What if I’m not good enough? What if I don’t deliver what they want? What if I disappoint them?” These doubts could have frozen me, but I chose to reframe the game positively.</p><p>Instead of dwelling on failure, I asked myself:</p><p>“What if they love my design?”<br> “What if they approve the project?”<br> “What if this leads to more opportunities?”</p><p>This shift from negative “What Ifs” to positive ones helped me take action. It motivated me to do my best work and learn through the process. I realized that focusing on what could go wrong only stops you from trying. But focusing on what could go right propels you forward.</p><h4>How to Use the “What If” Game Positively — My Advice for Beginners</h4><p>To anyone just starting out, whether as a developer or entrepreneur; my advice is simple: Stay curious and use the “What If” game positively.</p><p>🔸When coding, ask “What if I try this approach instead?” or “What if I optimize this function?”</p><p>🔸When solving problems, think “What if there’s a better algorithm?” or “What if I automate this process?”</p><p>🔸When working with clients or building your business, shift from “What if I fail?” to “What if this succeeds?”</p><p>This positive curiosity is a powerful tool. It keeps you learning, improving, and growing. It’s what separates a good developer from a great one. It’s what helps entrepreneurs overcome fear and uncertainty.</p><p>Quote for the day:<br>“<strong>Invest in yourself.</strong> Nobody else will see or point out your potential like you can. Keep grinding, keep asking “What If,” and keep pushing forward.”</p><p>Vidun Pallegoda.<br><a href="https://www.linkedin.com/in/vidun-nethdina/">https://www.linkedin.com/in/vidun-nethdina/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=945409f24465" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Recover Deleted Files from a FAT32 USB Drive Using Hex Analysis : A Deep Dive into File…]]></title>
            <link>https://medium.com/@vinethdina77/how-to-recover-deleted-files-from-a-fat32-usb-drive-using-hex-analysis-a-deep-dive-into-file-b9c8aac7bf15?source=rss-f5a27954e73d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9c8aac7bf15</guid>
            <category><![CDATA[fat32]]></category>
            <category><![CDATA[operating-systems]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[forencisdata]]></category>
            <category><![CDATA[computer-forensics]]></category>
            <dc:creator><![CDATA[Vidun Pallegoda]]></dc:creator>
            <pubDate>Sun, 18 May 2025 15:40:35 GMT</pubDate>
            <atom:updated>2025-05-18T20:10:07.364Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Recover Deleted Files from a FAT32 USB Drive Using Hex Analysis : A Deep Dive into File System Forensics</h3><p>#FAT32 #FAT_File_Structure #OperatingSystems #WindowsOS</p><p>In this blog post, we’ll find how the FAT32 file system works and demonstrate how operating systems manage and store data at the lowest level. Specifically, you’ll learn how to retrieve deleted files from a USB drive image by analyzing the file system’s raw hexadecimal data.</p><p>We’ll walk through the process of reading and interpreting hex values, understanding how deleted file entries are structured, and manually locating file data based on FAT (File Allocation Table) metadata ; a format commonly used in USB drives.</p><p>To follow along smoothly, it helps if you have some basic knowledge of:</p><p>🐧 Linux terminal commands<br>🧠 Bits, bytes, and hexadecimal representation<br>📉 Little endian vs. big endian<br>📦 Sectors and cluster sizes in file systems</p><p>But don’t worry; if these terms feel unfamiliar, I’ll be writing a separate beginner-friendly blog soon to explain all of these concepts clearly.</p><p>So buckle up this tutorial isn’t just about recovering files. It’s about peeking under the hood of how operating systems and storage really work.</p><p>Most operating systems don’t actually “erase” a file when you delete it. They just <strong>mark the space it occupies as unavailable</strong>. As long as that space hasn’t been overwritten, we can often <strong>retrieve the data manually</strong>.</p><p>This is what your activity demonstrates, by interpreting <strong>hex values</strong> directly from the pen drive image.</p><p>For demonstration i used these configuraions:<br><strong><em>Clean &gt; MBR &gt; Format &gt; FAT32 &gt; Partition &gt; Partition name: EDUCATION</em></strong></p><p>Create a folder, Create txt file named Name.txt, write anything you inside it and copy it to the pen drive and then delete it. copy any image you like( in my case i created the folder name: “LNBTI” file name: “target.png”), rename it whatever you like (but remember the file name, file name is crutial to retrieve the file from hex dump). <strong>NOTE: rename the image file before you copy into the folder.</strong></p><pre>Pen Drive<br>├── LNBTI<br>    └── target.png<br>    └── Name.txt</pre><ol><li>Taking image of the pen</li></ol><pre>dd if=\\.\PhysicalDrive1 of=disk.bin bs=4M status=progress</pre><p>if: input file | of: output file | bs: Batch size</p><p>‘ \\.\PhysicalDrive1 ’ means the pen drive that connected to the PC ( in your case drive number may be different, to identify the right drive number of your pen drive; Start &gt; Search diskpart &gt; Run as Administrator &gt; Run command ‘list disk’. <strong>Be careful when selecting or formatting the correct drive</strong>. I will write a separate blog post on how to use Diskpart in Windows OS.</p><p>Run this command in your preferred directory in Command Prompt. After it finishes, you will see a file named disk.bin created in the same directory where you executed the command.</p><p>2. Validating MBR code</p><pre>xxd -s 0 -l 512 disk.bin</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*J7pmms20sWPAjQzwqRHhwg.png" /></figure><p>you will notice the last 2 bytes contains 55AA which means this is the first record and the Master Boot Record (MBR) of the pen drive. <br>by using this hex dump we will be able to analyze important information about the pen drive. such as DOS Partition Table (DPT).</p><p>3. Analyzing DOS Partition Table (DPT)</p><pre>xxd -s 446 -l 64 disk.bin</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*ZXqTyw9rod7VEJpsWwcozg.png" /></figure><p>4. Extracting Partition Hex dump</p><pre>dd if=disk.bin of=part.bin bs=1 skip=2048 count=2097152 status=progress</pre><p>5. Interpretating Partition hex dump</p><pre>xxd -s 0 -l 512 part.bin</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*jv0LQ-D4lFJKtnh5wNXzQw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QLxJcLKEodU6z6HHTvIv1g.png" /><figcaption>interpretation of partition hex dump</figcaption></figure><p>6. Extracting Primary FAT</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*a1wx6EMdeA_WZGdQaQ5M-Q.png" /><figcaption>figure.1</figcaption></figure><p>This is the structure of FAT32 file system. to extract Primary FAT (1st FAT Area; according to image) we have to skip the Reserved Area (Reserved Sectors) which we found while interpreting the Partition hex dump. Also we found out the size of the FAT32 (Sectors per FAT32)</p><p>So to extract Primary FAT run this command,</p><pre>dd if=part.bin of=primaryfat.bin bs=512 skip=4110 count=2041 status=progress</pre><p>Interpret the Primary FAT hex dump</p><pre>xxd -s 0 -l 512 primaryfat.bin</pre><p>if your Primary FAT hex dump looks like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*VfDst0qkj37l1Wx99FAPng.png" /></figure><p>You’ve successfully extracted the Primary FAT hex code. In the FAT32 file structure image I provided (Figure 1), you’ll notice a Secondary FAT located right after the Primary FAT. This Secondary FAT is an exact duplicate of the Primary FAT and serves as a backup.<br>Our next objective is to extract the <strong>Data Area (Root Directory)</strong>. To do this, we need to skip the <strong>Reserved Area</strong>, <strong>Primary FAT</strong>, and <strong>Secondary FAT</strong>.</p><p>Primary FAT skip = 4110<br>Secondary FAT skip = 4110 + 2041<br>Data Area skip = 4110 + 2041 +2041 = 8192</p><p>7. Extracting Root Directory (Data Area)</p><pre>dd if=part.bin of=root.bin bs=512 skip=8192 count=8 status=progress</pre><p>8. Interpretation of Root Directory</p><pre>xxd -s 0 -l 512 root.bin</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*7r_4db-6famVkM6YO_eWTg.png" /><figcaption>figure 2 — root directory hex dump</figcaption></figure><p>As I mentioned earlier, my partition is named EDUCATION, and we have now successfully extracted its root directory. Here, I’ve highlighted the contents of the pen drive: a folder named LNBTI and a file named Name.txt. We will explore the LNBTI folder, and then, let’s retrieve the contents of Name.txt and target.png!</p><p>9. Extracting the LNBTI folder <strong>Cluster </strong>and Understanding the Root Directory Entry <br>Let’s begin by looking at the folder named LNBTI, which is part of the root directory. You’re provided with metadata in hexadecimal format representing this folder’s entry in the file system:</p><pre>First char: 4C<br>Remaining chars: 4E 4254 4920 2020 2020 20<br></pre><p>✅ What this means:<br>*4C in hex = ‘L’ in ASCII.<br>*The following values spell ‘NBTI’, padded with spaces (20 in hex).<br>Together, these form the folder name: LNBTI.</p><p>To extract the LNBTI cluster. First we need to analyze the LNBTI Record hex values in Root Directory Hex dump ( figure 2 ).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*7b_lHLefWaL5oVjCnEZAgA.png" /></figure><p>Analyze the above hex dump using this table. highlighted 0005 is the location of first cluster. This value is important!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*I3H26Hlq2Sz7w7xlvFLrQg.png" /><figcaption>File Record offset table</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v_xIzA_Qnh13mb04Q4Ko7w.png" /><figcaption>Analyzed File Record</figcaption></figure><p>9.1. File Attribute and Timestamps</p><pre>File attributes: 10</pre><p>10 in FAT file systems indicates this entry is a directory (not a regular file).</p><pre>Creation time: EC59<br>Creation date: 7459<br>Access date: 7459<br>Modified time: ED59<br>Modified date: 7459</pre><p>These values are in FAT-specific date/time format and usually decoded to actual timestamps using a parser. But for this activity, you’re only expected to identify them as the creation and modification times.</p><p>9.2. Locating the File Content: First Cluster Calculation</p><pre>Low order bytes of first cluster location: 0500<br>→ 0005</pre><p>So this folder starts at <strong>cluster 5</strong></p><pre>First cluster location = Root Start + Root Size + (Cluster Number - 2) * 32 * 512</pre><p>in my case: <br>(Your skip values may be different. this may vary with your pen Drive)</p><p>= 282,624 + (5–2) * 32 * 512<br>= 282,624 + 3 * 16,384<br>= 282,624 + 49,152<br>= 331,776</p><p>9.3. Extracting LNBTI Folder Cluster</p><pre>dd if=part.bin of=lnbti.bin bs=1 skip=331776 count=16384</pre><p>9.4. Exploring Folder Contents — Reading LNBTI Folder</p><pre>xxd -s 0 -l 512 lnbti.bin</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*nPENPuy4ni7Uf3vzA4sW6g.png" /></figure><p>here target.png entries starting with e5 means the file has been deleted now let’s retrive that enrty and try to retrieve deleted png file.<br>To check which cluster the target.png file is in run this command,</p><pre>xxd -c 2 primaryfat.bin</pre><p>target.png file is in 6th cluster (in my case 👇)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*9wKpwzZOaqGqEf1jozyd1g.png" /></figure><p>= 282,624 + (6–2) * 32 * 512<br>= 282,624 + 4 * 16,384<br>= 282,624 + 65,536<br>= 348,160</p><pre>dd if=part.bin of=target.bin bs=1 skip=348160 count=16384</pre><p>then,</p><pre>xxd target.bin</pre><p>This will output a hex dump like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*jXrqPMZhCu8MKBVLlwcuSA.png" /></figure><p>now we have successfully retrived deleted image file. To view the image let’s compress the hex dump into png file so we can view the deleted image.<br>To do that you have to run this command,</p><pre>dd if=target.bin of=target.png bs=4K status=progress</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tq4BHX2tb8dNJx4B7cQkqg.png" /></figure><p>Viola! Now we have successfully compressed and restored a deleted image file from pen drive. Let’s find out what the name.txt!</p><p>10. Exploring name.txt file and finding its content.</p><p>This process is also same as previous objective. first we need to find the cluster location and then calculate the skip.</p><p>10.1. searching FAT location</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*-GLHnABxPJxFZpLX8mycww.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*In5akp-ZQnbMG9HM_v9_5Q.png" /></figure><pre>First char: 4E → &#39;N&#39;<br>Remaining chars: 41 4D45 2020 2020 5458 54 → NAME.TXT</pre><pre>File attributes: 20 → Regular file<br>First cluster: 0700 → Cluster 7<br>File size: 1100 0000 → 0011 (hex) = 17 bytes</pre><p>🔸The file starts at cluster 7.<br>🔸The size is 17 bytes, so it’s a tiny file.<br>🔸Using the same calculation method, you find the byte offset of cluster 7 and extract those 17 bytes.</p><pre>xxd -c 2 primaryfat.bin</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*DSp08epk25dCzOZ4gMV0vQ.png" /></figure><p>= 282,624 + (7–2) * 32 * 512<br>= 282,624 + 5 * 16,384<br>= 282624 + 5 * 32 * 512<br>= 364,544</p><pre>dd if=part.bin of=name.bin bs=1 skip=364544 count=16384</pre><pre>xxd name.bin</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1009/1*JN442ue6Fuj69gvMWZ6zEw.png" /></figure><p>Yay! we have successfully retrieved the content of name.txt, now let’s compress this into txt file as usual.</p><pre>dd if=name.bin of=name.txt bs=4K status=progress</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bp3EFvJp17lpw8ivPr2FGA.png" /></figure><p>Finally! Now we can rest and take a coffee break.</p><p>Congratulations! 🥳<br>Now you know a little bit about computer forensics!</p><p>Actually, I wrote this blog to give you a peek into how the FAT32 file system works and how operating systems function at the lowest level. This is me sharing the knowledge I gained from my university’s Operating Systems module.</p><p>I know some parts might be a bit tough to understand at first — but my advice is: keep learning the fundamentals of how computers work. It might feel hard now, but with time, it all starts to click. Trust me — anything is possible.<br>I’m planning to write more blogs based on what I’ve learned from the OS module, so stay tuned!</p><p>If you have any questions, feel free to drop a comment below.<br>And if there’s anything you’d like to add to this post, I’d love to hear it too.</p><p>Random Quote;</p><p>Learning is a never-ending road. You may be walking, riding, driving, or flying down that road, but no matter what state you’re in, just keep going… until you grow wings to fly on your learning journey.</p><p>Thank you<br>Vidun Pallegoda,<br><a href="https://www.linkedin.com/in/vidun-nethdina/">https://www.linkedin.com/in/vidun-nethdina/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9c8aac7bf15" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>