Harisankar P S | Ruby on Rails Developer
https://hsps.in/
Recent content on Harisankar P S | Ruby on Rails DeveloperHugoenHarisankar P SSat, 21 Mar 2026 11:56:26 +0530Taming a 486MB Git Repo
https://hsps.in/post/taming-a-486mb-git-repo/
Sat, 21 Mar 2026 11:56:26 +0530https://hsps.in/post/taming-a-486mb-git-repo/<p>I recently cloned a repository and noticed it was <strong>486MB</strong>. The actual source code? About <strong>6MB</strong>. That’s a 98.7% overhead. Here’s how I found the bloat and fixed it.</p>How a European DNS Server Added 1 Second to Every Page Load in Australia
https://hsps.in/post/european-dns-server-added-1-second-to-every-page-load-in-australia/
Thu, 05 Mar 2026 13:18:25 +0530https://hsps.in/post/european-dns-server-added-1-second-to-every-page-load-in-australia/<p>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 on the server closest to each user.</p>
<p>I was tasked to investigate our AU server randomly being slower compared to EU. Not always, just sometimes. The same pages that rendered in under 100ms on EU would take over a second on AU.</p>Git Worktree: Scaling Your AI Workflow
https://hsps.in/post/git-worktree-ai-workflow/
Sun, 07 Dec 2025 19:15:00 +0530https://hsps.in/post/git-worktree-ai-workflow/<p>I’ve been using <code>git</code> for years, but to be honest, I wasn’t even aware of <code>git worktree</code> until I started using AI for development.</p>
<p>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 <code>git stash</code> or <code>git stash -u</code> (to catch those untracked files). Sometimes I’d just commit what I had, knowing I would eventually “Squash and Merge” my Pull Requests anyway, so a few messy “WIP” commits didn’t really matter.</p>
<p>But recently, I found a new bottleneck: <strong>I have more ideas than I have open AI contexts.</strong></p>
<p>We often treat AI as a faster pair programmer, but we still tend to work sequentially. We ask Cursor or Claude Code to do X, watch it generate code, review it, and then move to Y.</p>
<p>But what if you could implement Idea A, Idea B, and Fix C all at the same time?</p>
<p>Enter <code>git worktree</code>.</p>Mastering the HTML Picture Tag: Responsive Images, WebP, and AVIF
https://hsps.in/post/html-picture-tag/
Sun, 07 Dec 2025 08:19:13 +0530https://hsps.in/post/html-picture-tag/<p>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.</p>
<p>The <code>picture</code> tag gives us a lot of control over how images are loaded, solving two main problems: efficient formats and responsive sizing.</p>
<h2 id="webp-support">WebP Support</h2>
<p>We all know WebP images are smaller and faster to load, but not every browser supported them initially (though support is great now). The <code>picture</code> tag allows us to serve WebP to browsers that support it, while falling back to PNG or JPEG for others.</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-html" data-lang="html"><span class="line"><span class="cl"><span class="p"><</span><span class="nt">picture</span><span class="p">></span>
</span></span><span class="line"><span class="cl"> <span class="p"><</span><span class="nt">source</span> <span class="na">srcset</span><span class="o">=</span><span class="s">"image.webp"</span> <span class="na">type</span><span class="o">=</span><span class="s">"image/webp"</span><span class="p">></span>
</span></span><span class="line"><span class="cl"> <span class="p"><</span><span class="nt">source</span> <span class="na">srcset</span><span class="o">=</span><span class="s">"image.jpg"</span> <span class="na">type</span><span class="o">=</span><span class="s">"image/jpeg"</span><span class="p">></span>
</span></span><span class="line"><span class="cl"> <span class="p"><</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">"image.jpg"</span> <span class="na">alt</span><span class="o">=</span><span class="s">"My Image"</span><span class="p">></span>
</span></span><span class="line"><span class="cl"><span class="p"></</span><span class="nt">picture</span><span class="p">></span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>The browser parses the <code><source></code> tags from top to bottom. The first one with a supported <code>type</code> is chosen. If none match, it falls back to the standard <code><img></code> tag.</p>đď¸ Understanding the Builder Pattern with Ruby Examples
https://hsps.in/post/object-or-software-builder-pattern-in-ruby/
Tue, 05 Aug 2025 10:57:22 +0530https://hsps.in/post/object-or-software-builder-pattern-in-ruby/<p>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 <strong>Builder Pattern</strong>.</p>
<p>You’ll find it everywhere, from constructing HTML forms in Rails to building command-line interfaces or even assembling HTTP requests.</p>
<h2 id="-what-is-the-builder-pattern">đŚ What Is the Builder Pattern?</h2>
<p>In real world projects, we often model things as objects. The idea is that objects are instances of a common blueprint, sharing the same structure but differing in a few properties like name, age, etc. However, when there are many properties to configure and you need more control over how the final object is built, that’s where the Builder pattern becomes useful. It helps construct complex objects step by step without cluttering your code with long initializers or deeply nested logic.</p>
<p>The <strong>Builder Pattern</strong> is used to construct complex objects step-by-step. Rather than stuffing all parameters into a huge constructor, you build an object one piece at a time, usually using a <strong>fluent interface</strong> (method chaining).</p>Caching Rendered PDFs in Rails with Active Storage
https://hsps.in/post/using-file-upload-to-cache-serving-pdf-files/
Sat, 26 Jul 2025 21:47:37 +0530https://hsps.in/post/using-file-upload-to-cache-serving-pdf-files/<p>As I was working on <a href="https://easyclientlog.com">easyclientlog.com</a>, 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 in many of my prior Rails apps: upload the PDF on first render, store it using Active Storage, and reuse that file on the next access.</p>
<h2 id="the-idea-cache-on-first-render">The Idea: Cache on First Render</h2>
<p>When the PDF is generated the first time, we attach it to the record using Active Storage. This could be an invoice, report, or any other object. The next time we need to show or download the PDF, we skip the rendering step and simply serve the uploaded file.</p>
<p>This avoids unnecessary rendering and speeds up response times, especially for large documents or when generating in bulk.</p>A Complete Guide to Rails.current_attributes (ActiveSupport::CurrentAttributes)
https://hsps.in/post/rails-current-attributes/
Tue, 08 Jul 2025 18:31:49 +0530https://hsps.in/post/rails-current-attributes/<p>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 <code>Thread.current</code>, <code>class_attribute</code>, or even <code>@@class_variables</code> to store this kind of state. But these are not thread-safe and can cause hard-to-debug issues in concurrent environments.</p>
<p>Rails 5.2 introduced a clean solution: <code>ActiveSupport::CurrentAttributes</code>.</p>
<p>This article covers what it is, why it exists, how it works internally, how to use it safely across web and background jobs, and how to test it properly.</p>
<hr>
<h2 id="-a-quick-history">đ A Quick History</h2>
<p><code>ActiveSupport::CurrentAttributes</code> was introduced by DHH in Rails 5.2 to simplify access to per-request or per-job context in a thread-safe way. It replaced older, hackier methods like:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-ruby" data-lang="ruby"><span class="line"><span class="cl"><span class="no">Thread</span><span class="o">.</span><span class="n">current</span><span class="o">[</span><span class="ss">:current_user</span><span class="o">]</span> <span class="o">=</span> <span class="n">user</span>
</span></span><span class="line"><span class="cl"><span class="no">ApplicationRecord</span><span class="o">.</span><span class="n">class_attribute</span> <span class="ss">:current_client</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>These approaches were shared across threads â fine in development, dangerous in production.</p>
<p><code>CurrentAttributes</code> changed that by giving you a dedicated, Rails-friendly API for storing context thatâs isolated per request/job.</p>How I Use Tailscale to Host a Public App From My Laptop
https://hsps.in/post/how-i-host-public-apps-using-tailscale/
Wed, 18 Jun 2025 23:09:32 +0530https://hsps.in/post/how-i-host-public-apps-using-tailscale/<p>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.</p>
<p>So hereâs what I did. I used <strong>Tailscale</strong>, <strong>AWS Lightsail</strong>, <strong>Docker</strong>, and <strong>Nginx Proxy Manager</strong> to expose my laptop to the internet, safely and securely. And right now, I’m running <a href="https://easyclientlog.com">https://easyclientlog.com</a> - next.js application and <a href="https://api.easyclientlog.com">https://api.easyclientlog.com</a> - ruby on rails application, using this exact setup.</p>
<h2 id="getting-a-static-ip">Getting a Static IP</h2>
<p>I signed up on AWS and went to Lightsail. Picked Mumbai as the region and selected the cheapest Ubuntu server. AWS gives you a static IP for free (in lightsail) as long as itâs attached to a running instance, and the server itself is free for the first three months.</p>
<p>This server acts like a relay. Itâs the public-facing machine. I donât run the actual app on it, it just receives the request and forwards it to my laptop at home.</p>Ruby `Data` Class â A Convenient Way to Create Value Objects
https://hsps.in/post/intro-to-ruby-data-and-comparable/
Mon, 02 Jun 2025 11:50:45 +0530https://hsps.in/post/intro-to-ruby-data-and-comparable/<p>Ruby’s <code>Data</code> 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 <code>(x, y)</code> or the speed of a carâusing primitives such as integers or strings. While these work, they lack the semantic clarity and behavior of custom types. This is where value objects shine. They encapsulate meaning and behavior around a set of values.</p>
<p>Ruby’s <code>Data</code> class was created to provide a native way to represent such concepts. Struct does fullfil this requirement, except the part of immutability. Ruby Structs are mutable. Some example of use case for value objects are to represent money, email address, co-ordinates, etc.</p>
<p>Lets now explore ruby Data, keeping in my the characteristics of a value object as shared by Marin Fowler. A value object
should have:</p>
<ul>
<li>No Identity</li>
<li>Immutable</li>
<li>Equality by Value</li>
<li>Small and Simple</li>
<li>Reusable</li>
</ul>
<p>Let’s explore how Ruby’s <code>Data</code> class supports these characteristics.</p>
<h3 id="class-data">class Data</h3>
<p><code>Data</code> is a core Ruby class, so no external gems are needed.</p>
<p>Here’s a simple example:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-ruby" data-lang="ruby"><span class="line"><span class="cl"><span class="no">MarsRover</span> <span class="o">=</span> <span class="no">Data</span><span class="o">.</span><span class="n">define</span><span class="p">(</span><span class="ss">:name</span><span class="p">,</span> <span class="ss">:x</span><span class="p">,</span> <span class="ss">:y</span><span class="p">)</span>
</span></span></code></pre></td></tr></table>
</div>
</div>Understanding Rubyâs `tap` â A Powerful Debugging and Configuration Tool
https://hsps.in/post/ruby-tap-method/
Sat, 19 Apr 2025 20:13:34 +0530https://hsps.in/post/ruby-tap-method/<p>Rubyâs <code>Object#tap</code> 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.</p>
<h2 id="a-simple-use-case-debugging">A Simple Use Case: Debugging</h2>
<p>Take the following example:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-ruby" data-lang="ruby"><span class="line"><span class="cl"><span class="n">n</span> <span class="o">=</span> <span class="o">[</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="o">].</span><span class="n">map</span> <span class="p">{</span> <span class="n">_1</span> <span class="o">%</span> <span class="mi">2</span> <span class="p">}</span><span class="o">.</span><span class="n">map</span> <span class="p">{</span> <span class="n">_1</span> <span class="o">*</span> <span class="mi">10</span> <span class="p">}</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>This returns <code>[10, 0, 10]</code>. But what if thatâs not what you expected? You might want to inspect the result of the first <code>map</code>:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-ruby" data-lang="ruby"><span class="line"><span class="cl"><span class="n">n</span> <span class="o">=</span> <span class="o">[</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="o">].</span><span class="n">map</span> <span class="p">{</span> <span class="n">_1</span> <span class="o">%</span> <span class="mi">2</span> <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="nb">puts</span> <span class="n">n</span><span class="o">.</span><span class="n">inspect</span>
</span></span><span class="line"><span class="cl"><span class="n">n</span> <span class="o">=</span> <span class="n">n</span><span class="o">.</span><span class="n">map</span> <span class="p">{</span> <span class="n">_1</span> <span class="o">*</span> <span class="mi">10</span> <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="nb">puts</span> <span class="n">n</span><span class="o">.</span><span class="n">inspect</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>Using <code>tap</code>, we can make this more elegant:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-ruby" data-lang="ruby"><span class="line"><span class="cl"><span class="n">n</span> <span class="o">=</span> <span class="o">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="o">].</span><span class="n">map</span> <span class="p">{</span> <span class="n">_1</span> <span class="o">%</span> <span class="mi">2</span> <span class="p">}</span>
</span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="n">tap</span> <span class="p">{</span> <span class="nb">puts</span> <span class="n">_1</span><span class="o">.</span><span class="n">inspect</span> <span class="p">}</span>
</span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="n">map</span> <span class="p">{</span> <span class="n">_1</span> <span class="o">*</span> <span class="mi">10</span> <span class="p">}</span>
</span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="n">tap</span> <span class="p">{</span> <span class="nb">puts</span> <span class="n">_1</span><span class="o">.</span><span class="n">inspect</span> <span class="p">}</span>
</span></span></code></pre></td></tr></table>
</div>
</div>Storing PostgreSQL Data in a Different Partition for Performance
https://hsps.in/post/storing-postgresql-data-in-a-different-partition-for-performance/
Wed, 15 Jan 2025 18:20:19 +0530https://hsps.in/post/storing-postgresql-data-in-a-different-partition-for-performance/<p>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 operations happen on another disk. This approach also makes it easier to handle failure, monitor disk health, and isolate workloads effectively.</p>
<h2 id="why-store-postgresql-data-in-a-separate-partition">Why Store PostgreSQL Data in a Separate Partition?</h2>
<p>Separating the data directory from the root filesystem has several advantages:</p>
<ol>
<li><strong>Improved Disk I/O Performance:</strong> Storing data on a dedicated partition ensures that database read/write operations are isolated from the OS and application processes, avoiding competition for disk I/O.</li>
<li><strong>Efficient Disk Usage Management:</strong> By placing the data in a separate partition, you can allocate specific disk space for the database and prevent it from filling up the root partition.</li>
<li><strong>Better Backup and Restore Control:</strong> Storing data in a dedicated location simplifies backup processes and makes restoring data more efficient.</li>
<li><strong>Optimized Disk Types:</strong> Different types of storage media (e.g., SSD for faster reads/writes or HDD for archival data) can be used based on database needs.</li>
<li><strong>Isolation for Security and Resilience:</strong> A dedicated partition reduces the risk of system failure in case of database corruption or storage issues.</li>
</ol>Tailscale for Single User Single Host
https://hsps.in/post/tailscale-for-single-user-single-host/
Wed, 08 Jan 2025 18:55:49 +0530https://hsps.in/post/tailscale-for-single-user-single-host/<p>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.</p>
<h2 id="the-problem-inefficient-remote-access">The Problem: Inefficient Remote Access</h2>
<p>I work from home, and my computer serves as both my personal and work machine. There have been many times when Iâve needed to assist colleagues or push changes while away from my desk. In emergencies, I used to rely on AnyDesk to remote into my computer via my phone or tablet. While AnyDesk and similar tools like TeamViewer provide visual control over the desktop, they often suffer from lag, disconnections, and poor responsiveness on weaker connections, making simple tasks like opening a terminal or editing a file feel like a chore. The lag becomes especially pronounced when navigating large projects or deploying code, turning a few-minute task into a frustrating, time-consuming ordeal.</p>Setup Read Replica (master-slave) Database on Postgresql 17
https://hsps.in/post/setup-master-slave-database-on-postgresql-17/
Thu, 24 Oct 2024 10:19:48 -0700https://hsps.in/post/setup-master-slave-database-on-postgresql-17/<p>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.</p>
<p>One effective strategy to improve the performance of web applications is to create a read-only replica of the primary database. This allows you to direct read-only queries (e.g., <code>SELECT</code> queries) to the replica, while write operations continue to target the primary database. Note that PostgreSQL doesnât support multiple primary (or master) databases natively, but it does support multiple read replicas.</p>
<p>Although you can achieve distributed primary databases via schema or table sharding, that topic is beyond the scope of this article.</p>Running Rails Migrations in AWS ECS Using AWS CLI
https://hsps.in/post/run-rails-db-migrate-on-ecs-task-aws/
Thu, 10 Oct 2024 00:05:58 -0700https://hsps.in/post/run-rails-db-migrate-on-ecs-task-aws/<p>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.</p>
<p>This guide assumes you are familiar with ECS and already have a task definition set up for your Rails application. Additionally, it assumes you know how to find your subnet ID and security group ID, as these will be required when running containers in your specific environment.</p>Setup on Demand Tailscale Exit Node Using Terraform and DigitalOcean
https://hsps.in/post/setup-on-demand-tailscale-exit-node-using-terraform-and-digital-ocean/
Tue, 08 Oct 2024 20:11:58 -0700https://hsps.in/post/setup-on-demand-tailscale-exit-node-using-terraform-and-digital-ocean/<p>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 đ.</p>
<p>By connecting my phone to Tailscale and using JuiceSSH, an Android app for SSH access, I could SSH into my home machine, deploy applications, and run maintenance scriptsâall from my phone. Peaceful trips away from my desk.</p>
<h2 id="remote-development-made-simple">Remote Development Made Simple</h2>
<p>Tailscale has also made remote development seamless. By installing Tailscale on a laptop, I was able to use VS Code’s Remote Development feature to access my home development machine via SSH. This setup allowed me to work from any laptop without the need to install databases or development tools locally. Even a basic Chromebook or an ultra-light laptop turned into a powerful development workstation, as all the actual computing happened on my home machine over SSH.</p>
<p>I even took it a step further by installing <a href="https://github.com/coder/code-server">code-server</a> on my dev machine. This allowed me to access a full-fledged development environment from my samsung tablet via Tailscale.</p>
<h2 id="what-is-tailscale">What is Tailscale?</h2>
<p>For those unfamiliar, Tailscale is a VPN software based on WireGuard. It allows you to create a secure network between your devices effortlessly. All you need to do is install Tailscale on your device, start the program, and your device joins the networkâno advanced configuration required. Itâs an easy-to-use, straightforward VPN solution.</p>
<p>By connecting my devices and home lab to this VPN, I gained the ability to access my computers remotely from anywhere.</p>
<h2 id="using-an-exit-node-for-secure-browsing">Using an Exit Node for Secure Browsing</h2>
<p>Tailscale allows you to set up one of your devices as an exit node. This means that when you’re using another device, you can route all your internet traffic through the exit node. For example, when Iâm traveling, I set up my home computer as an exit node, ensuring that my internet traffic behaves as if I’m accessing it from home. This not only secures my browsing but also obscures my activities from public networks like those at hotels, cafes, or Airbnbs, as all they see is traffic going to Tailscaleâs network, fully encrypted.</p>
<blockquote>
<p><strong>Note:</strong> Tailscale attempts to establish direct connections between devices. When thatâs not possible, it uses relay servers.</p>
</blockquote>Change Action Mailer Settings From Rails Console
https://hsps.in/post/change-action-mailer-settings-from-rails-console/
Mon, 07 Oct 2024 21:09:36 -0700https://hsps.in/post/change-action-mailer-settings-from-rails-console/<p>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 override these settings temporarily through the Rails consoleâfor example, when testing a custom configuration or troubleshooting email delivery issues.</p>Test Scanner (scanner emulator) in SANE - Linux
https://hsps.in/post/test-scanner-in-sane/
Fri, 04 Oct 2024 02:11:12 -0700https://hsps.in/post/test-scanner-in-sane/<p>2024 <a href="https://hacktoberfest.com/">Hacktoberfest</a> has begun, and I decided to dive into some open-source contributions! One project that caught my eye was the <a href="https://github.com/CoolCat467/Scanner-Server">Scanner Server</a>. It offers a web interface for using scanners, which seemed pretty interesting.</p>
<p>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 rescue! It includes a feature that lets you select a test scanner model. With this, you always have a virtual scanner called âtestâ available. While it only scans a black image, it behaves just like a real scanner for all practical purposes.</p>Using Docker to export & import data from Amazon RDS
https://hsps.in/post/using-docker-postgres-to-take-sql-dump-from-aws-rds/
Mon, 23 Sep 2024 04:38:52 -0700https://hsps.in/post/using-docker-postgres-to-take-sql-dump-from-aws-rds/<p>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 <code>pg_dump</code> to access the remote database resulted in a version incompatibility error. To fix this, I would either need to upgrade <code>pg_dump</code> or have both versions installed simultaneously on my machine. I didn’t want to do either. This is where Docker came to the rescue.</p>AWS ECR Lifecycle Policy
https://hsps.in/post/aws-ecr-lifecycle-policy/
Sat, 06 Apr 2024 06:21:43 -0700https://hsps.in/post/aws-ecr-lifecycle-policy/<p>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.</p>
<p>During the development and deployment of your project, you may find yourself building images as frequently as every 30 minutes. This frequency reflects my own experience. Whenever new code is merged with the master branch, it triggers a code build pipeline. This pipeline ultimately pushes the latest image to ECR, typically tagged as “latest.” Consequently, the previous image remains in the repository but becomes untagged. While retaining a few versions of older deployments facilitates easy rollbacks, after a day or two, they tend to become redundant. At this juncture, they serve no purpose other than incurring storage costs.</p>Handle SSH Idle Connections Freezing shell or Getting Disconnected
https://hsps.in/post/handle-ssh-idle-connections-handing-or-getting-disconnected/
Thu, 04 Apr 2024 03:13:24 +0530https://hsps.in/post/handle-ssh-idle-connections-handing-or-getting-disconnected/<p>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 occurs at all. When I was in the US connecting to Amazon servers, there were
occasions when the connection remained stable for days on end. This led me to believe that the issue might be related
to the internet or the complexity of the network routing required to reach the server.</p>Argument for Writing Test and TDD
https://hsps.in/post/argument-for-writing-test-and-tdd/
Wed, 30 Aug 2023 15:48:25 -0700https://hsps.in/post/argument-for-writing-test-and-tdd/<p>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 this, when it dawn to me that. People who say “automated testing won’t replace manual testing” are the similar to people who say “Software cannot replace manual work”.</p>Using Ansible to Install Docker and Docker Compose on New Lightsail Instance
https://hsps.in/post/ansible-to-install-docker-and-docker-compose-on-new-lightsail-instance/
Sun, 06 Aug 2023 21:59:35 -0700https://hsps.in/post/ansible-to-install-docker-and-docker-compose-on-new-lightsail-instance/<p>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:</p>
<ul>
<li>Launch a new ubuntu instance (since my team and I use it a dev machine we are familiar with it).</li>
<li>Install Docker</li>
<li>Install Docker Compose</li>
<li>Run the self hosted app and its requires services using docker.</li>
<li>Run nginx reverse proxy to serve the app over https</li>
</ul>
<p>I am pretty much managing the whole app through files. Its just the initial setup that I am doing manually. I thought of creating a base linux image for the new servers, which would have docker and docker-compose pre installed. But lightsail didn’t seem to have the option to use custom images, like EC2 servers.</p>
<p>Thus I decided to use ansible.</p>
<p>Ansible is an open source automation tool that is used for configuration management, deployment and task automation. It automates the steps that I do manually. It can run this command on multiple servers without having us do anything manually. We can also automate weekly maintenance check to login to all the servers, ensures all the security updates are installed, cache files are cleared, etc.</p>
<p>The thing I found most interesting about ansible compared to chef (another automation tool) is that it is agentless. That is it doesn’t expect anything to be running on the new server other open ssh. Chef on the other hand requires an agent to be running on the server. There are its own advantages of having an agent running on the server, it can do updates much faster and keep everything in sync. But since that is not a requirement for me at the moment, I decide to use ansible. I will write another article on how to do this using chef.</p>Create JSON Payload for API Test Using Factory Bot
https://hsps.in/post/create-json-payload-for-api-test-using-factory-bot/
Sat, 05 Aug 2023 23:06:27 -0700https://hsps.in/post/create-json-payload-for-api-test-using-factory-bot/<p>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.</p>
<p><a href="https://github.com/thoughtbot/factory_bot">Factory Bot</a> is a ruby library that is used to create records in the table for testing. It will help generate data to fill and prepare records, before the test execution.</p>Setup HTTP(s) and Reverse Proxy to Docker Web App
https://hsps.in/post/setup-https-and-reverseproxy-to-docker-web-app/
Thu, 03 Aug 2023 22:31:40 -0700https://hsps.in/post/setup-https-and-reverseproxy-to-docker-web-app/<p>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.</p>
<p>This article assume you know about ssl key files, docker and docker-compose. And for the sake of this article we are setting up <code>uptime-kuma</code>.</p>Rails Copy Assets bundler Cache to Speed Up Build
https://hsps.in/post/rails-copy-assets-bundler-cache-to-speed-up-build/
Tue, 01 Aug 2023 17:01:37 -0700https://hsps.in/post/rails-copy-assets-bundler-cache-to-speed-up-build/<p>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.</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-Dockerfile" data-lang="Dockerfile"><span class="line"><span class="cl"><span class="k">COPY</span> --from<span class="o">=</span>docker-repo.link/image:latest /app/node_modules /app/node_modules<span class="err">
</span></span></span><span class="line"><span class="cl"><span class="err"></span><span class="k">COPY</span> --from<span class="o">=</span>docker-repo.link/image:latest /app/public /app/public<span class="err">
</span></span></span><span class="line"><span class="cl"><span class="err">
</span></span></span><span class="line"><span class="cl"><span class="err"></span><span class="k">RUN</span> bundle <span class="nb">exec</span> rails assets:precompile<span class="err">
</span></span></span></code></pre></td></tr></table>
</div>
</div><p>Now since the prior assets are in the new image, it won’t compile the assets from scratch and the build will be faster.</p>Sidekiq Graceful Shutdown in Fargate ECS
https://hsps.in/post/sidekiq-graceful-shutdown-in-fargate-ecs/
Sun, 30 Jul 2023 00:10:21 -0700https://hsps.in/post/sidekiq-graceful-shutdown-in-fargate-ecs/<p>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.</p>
<p>One of the beautiful features of sidekiq was how it handled exit (SIGTERM and SIGKILL).</p>
<p><img src="https://turnoff.us/image/en/dont-sigkill-2.png" alt="Dont Sigkill">
Source: <a href="https://turnoff.us/geek/dont-sigkill-2/">https://turnoff.us/geek/dont-sigkill-2/</a></p>
<p>When sidekiq received the sigterm commands it stops accept new jobs, and just focus on finishing the job it is doing now and incase it can’t finish, it will requeue the job to another available worker or keep it in the queue for another worker (or the same worker) to pick it up when available.
This was working so well for years on rails app I was working on, that I didn’t even care about it. The mina command would trigger a sidekiq restart allowing sidekiq to gracefully exit and then respawn with the new code.</p>
<p>The above app was running on two linux servers everything manually configured, but recently to keep up with the growth of the app we moved to amazon ECS. The app was containerized to a docker image, and made to run on about 12 Fargate Instances with ability to auto scale to 36 based on CPU and RAM usage. We grouped instances for various purposes 2 for heavy jobs, 2 for faster (more memory jobs), 2 for file processing, 4 for web, 2 for API.</p>About Web Assembly. Example for Ruby Web Assembly
https://hsps.in/post/ruby-wasm/
Fri, 19 May 2023 21:12:50 -0700https://hsps.in/post/ruby-wasm/<p>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 and executing code on your machine. The browser have become so advanced that it takes care of security and safety so well. Thus being able to covert your program code or binary file into JS allows you to run your code on the browser and any machine that has a browser.</p>
<p>Now the idea of web assembly support in ruby (or any language) is not about writing website using ruby, though we can do that if we wanted to. The idea is to make a program or library that we have already existing in one language available for the web. If you can run ruby interpreter on your browser, then you can run any ruby code on your browser.</p>
<p>The things people doing with web assembly have been getting crazier. People are building more and more proof of concept ideas and apps in web assembly. The most exciting thing that impressed me recently was <a href="https://webvm.io/">webvm.io</a>. A virtual machine is running on your browser with linux. You can run linux commands, execute a python program, etc. This is a full fledged virtual machine (the one you run using docker), running on your browser. There are more projects that does that now:</p>
<ul>
<li><a href="https://bellard.org/jslinux/vm.html?url=alpine-x86.cfg&mem=192">https://bellard.org/jslinux/vm.html?url=alpine-x86.cfg&mem=192</a></li>
<li><a href="https://copy.sh/v86/">https://copy.sh/v86/</a></li>
</ul>
<p>You can host a web server or a rails app inside an image, which will then run on your browser serving the content. (Note: networking is still not native, so most use web sockets to emulate a network and make internet available inside the container).</p>
<p>The potential for this is huge, you can technically turn any machine that can run a web browser (Chrome or firefox) into a server.</p>Statically Compile Crystal Program and Distribute as docker Image
https://hsps.in/post/static-compile-crystal-lang-code-in-docker-and-create-a-small-image/
Sun, 02 Apr 2023 20:22:46 -0700https://hsps.in/post/static-compile-crystal-lang-code-in-docker-and-create-a-small-image/<p>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.</p>
<p>Note: The way docker works, each command/line creates a layer (with context).</p>
<p>The good news about crystal lang is the they distribute the docker image with all the libraries so that we can build static compiled executable(s). Attaching the docker file I wrote to statically compile a crystal language program.</p>
<p>Note: The program uses the Kemal web framework, so this could also be considered an article on how to statically compile and distribute a kemal web app.</p>Share Docker Images as Files
https://hsps.in/post/share-docker-images-as-files/
Sun, 26 Mar 2023 21:27:35 -0700https://hsps.in/post/share-docker-images-as-files/<p>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.</p>
<p>Dev Machine: Kubuntu, 22.04</p>Reduce Cost of Aws Bill - Part 1
https://hsps.in/post/reduce-cost-of-aws-bill-part-1/
Sun, 19 Mar 2023 19:52:42 -0700https://hsps.in/post/reduce-cost-of-aws-bill-part-1/<p>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 new complexity to worry about. There is a reason why AWS offers certificate programs. AWS Certified Cloud Practitioner/Architect/SysOps Admin/Developer/Solution Architect/Dev Ops Engineer all these shouldn’t be there if all the complexity were truly abstracted.</p>
<p>Now that I have finished writing my frustration about cloud, lets return to the main topic of this article. Recently I was tasked with reducing our AWS bill. Our general approach to reduction in system performance have been to increase the server spec or DB spec. Looking at which resource was maxing out. DB or Server.</p>Speed Up Docker Build using cache
https://hsps.in/post/speed-up-docker-build-using-cache/
Fri, 10 Mar 2023 20:04:50 -0800https://hsps.in/post/speed-up-docker-build-using-cache/<p>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.</p>
<p>When building a rails app for production we would need to do the following steps in the docker file</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">COPY . .
</span></span><span class="line"><span class="cl">bundle install
</span></span><span class="line"><span class="cl">yarn install
</span></span><span class="line"><span class="cl">bundle <span class="nb">exec</span> rails assets:precompile
</span></span></code></pre></td></tr></table>
</div>
</div><p>Docker after building each step it will cache that step. If the instructions/context of that steps or steps before haven’t change then docker will use the cache.</p>
<p>So we need to make docker understand that there is no change, hence we can use the cache instead of rebuilding it.</p>Enable Docker Remote Api on Docker Host
https://hsps.in/post/enable-docker-remote-api-on-docker-host/
Tue, 06 Sep 2022 20:21:42 -0700https://hsps.in/post/enable-docker-remote-api-on-docker-host/<p>Docker engine has inbuild API service that allows you to control & modify your docker engine and docker instance using HTTP.</p>Setup NFS Server on Ubuntu
https://hsps.in/post/setup-nfs-server-on-ubuntu/
Mon, 05 Sep 2022 18:29:12 -0700https://hsps.in/post/setup-nfs-server-on-ubuntu/<p>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 replicas it will be running on more than one node. So local storage on the server is out of the question.</p>
<p>With NFS we can directly mount the folder in the container. We can control everything from the configuration file. And thanks to the NFS storage we can increase and reduce node without worries as well.</p>Wildcard Domain in Pi Hole
https://hsps.in/post/wildcard-domain-in-pi-hole/
Sun, 04 Sep 2022 11:36:43 -0700https://hsps.in/post/wildcard-domain-in-pi-hole/<p>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.</p>
<p>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 encrypt.But PiHole doesn’t have a wildcard domain setting, hence after i set or before i set a domain my nginx proxy I need to add it to PiHole.</p>Validating YAML Files in Ruby
https://hsps.in/post/validating-yaml-files-in-ruby/
Mon, 22 Aug 2022 21:27:34 -0700https://hsps.in/post/validating-yaml-files-in-ruby/<p>YAML stands for “YAML Ain’t Markup Language”. YAML is a data serialization language that is often used for writing configuration files.</p>
<p>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 Obvious Minimal Language).</p>
<p>In a static language (like crystal) you need to define the structure of a YAML or JSON file. Defining the structure also act as validation of its schema. Validating the schema is a good idea because it ensure’s that all the required data is present. Its better to know data is missing when your program starts rather than while it is running.</p>
<p>For dynamic language like ruby you can load a yaml file, and ruby will dynamically initialize it. It does make your life easier as a programmer. You don’t need to define the schema, and remember to update the schema when you add a new variable to your file.</p>
<p>But defining the schema has its benefits -</p>
<ol>
<li>For the User: It reminds then to have the configuration filled before running their program</li>
<li>For the Developer: It helps us to eliminate the configuration file as a possible reason for the program not running.</li>
</ol>Which Language Should I Build This Software In
https://hsps.in/post/which-language-should-build-this-software-in/
Mon, 22 Aug 2022 17:43:43 -0700https://hsps.in/post/which-language-should-build-this-software-in/<p><strong>Which Language Should I Build This Software In?</strong> or <strong>Which language should I have this software developed In?</strong></p>
<p>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:</p>
<p>If you had an idea for a novel? or a poem? which language will you write it in. Italian, Tamil, Bengali? Would you try to learn a new language because there are a lot of similar novels (anime) in Chinese or Japanese.</p>
<p>The best language to write your novel is the language you know the most.</p>Getting Started With ESP 32 Development
https://hsps.in/post/getting-started-with-esp-32-linux/
Thu, 04 Aug 2022 00:42:04 -0700https://hsps.in/post/getting-started-with-esp-32-linux/<p>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 direction in which SoC’s are going.</p>
<p>The ESP 32 is really low cost it cost like 350 in India, and less than 10$ in the US. Now when you buy this you don’t buy the chip alone, but a chip on a development board. There are several articles (<a href="https://makeradvisor.com/esp32-development-boards-review-comparison/">https://makeradvisor.com/esp32-development-boards-review-comparison/</a>) on that. The board that I bought from amazon was this <a href="https://www.amazon.com/dp/B0718T232Z?psc=1&ref=ppx_yo2ov_dt_b_product_details">https://www.amazon.com/dp/B0718T232Z?psc=1&ref=ppx_yo2ov_dt_b_product_details</a>, i also bought one with OLED display as well <a href="https://www.amazon.com/dp/B07DKD79Y9?psc=1&ref=ppx_yo2ov_dt_b_product_details">https://www.amazon.com/dp/B07DKD79Y9?psc=1&ref=ppx_yo2ov_dt_b_product_details</a>.</p>
<p>In this article I will be talking about how to get started. We will basically will be setting up Aurdino IDE in linux, followed by flashing few sample programs like:</p>Amazing Emoji Keyboard in Linux
https://hsps.in/post/amazing-emoji-keyboard-in-linux/
Mon, 01 Aug 2022 18:59:18 -0700https://hsps.in/post/amazing-emoji-keyboard-in-linux/<p>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 thing that I missed the most was the emoji keyboard, with easy to launch shortcut.</p>
<p>My usage of emoji was at its peak during macOS days, I used emoji for my communications, commits, function name and
even terminal aliases. đ Not everyone was a fan of my emoji usages, but I loved it.</p>Running Migrations From Console
https://hsps.in/post/running-migrations-from-console/
Tue, 19 Jul 2022 23:15:19 -0700https://hsps.in/post/running-migrations-from-console/<p>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.</p>
<p>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 hasn’t ran the migration, but rest of the schemas has it, rails thinks it has already ran the migration. Rails look at the main / default schema to know if it has ran the migrations and then follow up on the rest.</p>Access History in IRB
https://hsps.in/post/access-history-in-irb/
Sun, 17 Jul 2022 13:15:49 -0700https://hsps.in/post/access-history-in-irb/<p>Accessing the list of commands you have ran in your <code>irb</code> or <code>rails console</code>.</p>
<p>Running the following command in your console <code>Readline::HISTORY.to_a</code> 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.</p>Remote Coding Using Tailscale and Code Server
https://hsps.in/post/remote-coding-using-tailscale-and-code-server/
Sun, 03 Jul 2022 13:52:46 -0700https://hsps.in/post/remote-coding-using-tailscale-and-code-server/<p>This tutorial or concept uses two softwares to make remote coding on your home machine possible.</p>
<ol>
<li>Tailscale</li>
<li>code-server</li>
</ol>
<p><a href="https://tailscale.com">Tailscale</a> 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.</p>
<p>So you can build a secure connection between your two computers over the internet. These two computers can be across the world, and they will be as if they are on a same network.</p>Adding New Key per User to AWS EC2 Instance
https://hsps.in/post/adding-new-key-per-user-to-aws-ssh/
Fri, 01 Jul 2022 22:58:41 -0700https://hsps.in/post/adding-new-key-per-user-to-aws-ssh/<p>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.</p>
<ul>
<li>Generate new key for each member of your team or ask each member for there public keys</li>
<li>Add it to the authorized_keys list in your servers <code>.ssh</code> folder</li>
</ul>HTOP for GPU in Linux
https://hsps.in/post/htop-for-gpu-in-linux/
Sun, 12 Jun 2022 17:02:57 -0700https://hsps.in/post/htop-for-gpu-in-linux/<p>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.</p>
<p>Note: I am talking about tools i tested in Ubuntu/Debian Linux</p>How I Setup Dark Theme in My Blog
https://hsps.in/post/how-i-setup-dark-theme-in-my-blog/
Sun, 12 Jun 2022 10:49:39 -0700https://hsps.in/post/how-i-setup-dark-theme-in-my-blog/<p>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 background is made black, it emits less light. Now not all displays are the same, each display creates the dark color in different ways. Like:</p>
<ul>
<li>On an <strong><code>LCD screen</code></strong>. The liquid crystal elements block the white light from the backlight. And this results in a dark (almost black) pixel.</li>
<li>On an <strong><code>OLED screen</code></strong>. The pixel is turned off, no light is emitted, this produces a deep black.</li>
<li>On a <strong><code>CRT screen</code></strong>. The electron beam is turned off as it passes the pixel. Producing no phosphorescent glow.</li>
<li>On an <strong><code>e-Ink screen</code></strong>. Little spherical beads which are half black/half white, are rotated so their black side is facing outwards.</li>
</ul>
<p>Regardless as you can see, darker colors results in less lights being emitted and leading to less strain to the eye. As a person who spend more time in front of a screen, I cannot fathom how useful this is. I have been a huge advocate of using night color/night mode in computer to improve developer health. Hence this article and why my blog has a dark mode now.</p>Append to File using Bash
https://hsps.in/post/append-to-file-using-bash/
Wed, 08 Jun 2022 14:47:32 -0700https://hsps.in/post/append-to-file-using-bash/Hire me
https://hsps.in/contact/
Sun, 05 Jun 2022 15:22:34 -0700https://hsps.in/contact/<h1 id="contact--hire-me">Contact / Hire me</h1>
<p>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.</p>
<p>Reach out to me at <a href="mailto:[email protected]">[email protected]</a></p>
<p>I am more active over email, than any other mediums.</p>Projects | Open Source and Others
https://hsps.in/projects/
Sun, 05 Jun 2022 15:22:34 -0700https://hsps.in/projects/<h1 id="projects">Projects</h1>
<p class="projects-intro">Link to projects I worked on over the years. There are more in <a href="https://github.com/coderhs" target="_blank" rel="noopener">Github</a>.</p>
<div class="projects-grid">
<!-- Wifi QR -->
<div class="project-card">
<div class="project-header">
<h3><a href="https://wifi-qr.hsps.in" target="_blank" rel="noopener">Wifi-QR</a></h3>
<div class="project-tech">Next.js</div> <div class="project-tech">Vercel</div>
</div>
<div class="project-description">
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.
</div>
<div class="project-links">
<a href="https://wifi-qr.hsps.in" target="_blank" rel="noopener" class="project-link demo">Live Demo</a>
<a href="https://github.com/coderhs/wifi-qr" target="_blank" rel="noopener" class="project-link code">GitHub</a>
</div>
</div>
<!-- Column to Array -->
<div class="project-card">
<div class="project-header">
<h3><a href="https://hsps.in/column_to_array/" target="_blank" rel="noopener">Column to Array</a></h3>
<div class="project-tech">Ruby</div> <div class="project-tech">WebAssembly</div>
</div>
<div class="project-description">
Convert column copied from a spreadsheet to array. The site runs on web assembly executing ruby in your browser.
</div>
<div class="project-links">
<a href="https://hsps.in/column_to_array/" target="_blank" rel="noopener" class="project-link demo">Live Demo</a>
<a href="https://github.com/coderhs/column_to_array" target="_blank" rel="noopener" class="project-link code">GitHub</a>
</div>
</div>
<!-- CSVSqlWeb -->
<div class="project-card">
<div class="project-header">
<h3><a href="https://hsps.in/csvsqlweb/" target="_blank" rel="noopener">CSVSqlWeb</a></h3>
<div class="project-tech">Web Assembly</div> <div class="project-tech">Javascript</div>
</div>
<div class="project-description">
Run SQL queries on your CSV file from the web.
</div>
<div class="project-links">
<a href="https://hsps.in/csvsqlweb/" target="_blank" rel="noopener" class="project-link demo">Live Demo</a>
<a href="https://github.com/coderhs/csvsqlweb" target="_blank" rel="noopener" class="project-link code">GitHub</a>
</div>
</div>
<!-- Step Counter -->
<div class="project-card">
<div class="project-header">
<h3><a href="https://step-counter.hsps.in/" target="_blank" rel="noopener">Step Counter</a></h3>
<div class="project-tech">Next.js</div> <div class="project-tech">Vercel</div>
</div>
<div class="project-description">
Count the number of steps you need to walk to lose weight.
</div>
<div class="project-links">
<a href="https://step-counter.hsps.in/" target="_blank" rel="noopener" class="project-link demo">Live Demo</a>
<a href="https://github.com/coderhs/step_counter" target="_blank" rel="noopener" class="project-link code">GitHub</a>
</div>
</div>
<!-- Easy Client Log -->
<div class="project-card">
<div class="project-header">
<h3><a href="https://easyclientlog.com" target="_blank" rel="noopener">Easy Client Log</a></h3>
<div class="project-tech">Next.js</div> <div class="project-tech">Ruby on Rails - 8</div> <div class="project-tech">PostgreSQL</div>
</div>
<div class="project-description">
A simple CRM, Task, Scheduling and Invoice tool for entrepreneurs.
</div>
<div class="project-links">
<a href="https://easyclientlog.com"" target="_blank" rel="noopener" class="project-link demo">Live</a>
</div>
</div>
<!-- PgDeploy -->
<div class="project-card">
<div class="project-header">
<h3><a href="https://pgdeploy.com" target="_blank" rel="noopener">PgDeploy</a></h3>
<div class="project-tech">Next.js</div> <div class="project-tech">Go/Gin</div> <div class="project-tech">PostgreSQL</div>
</div>
<div class="project-description">
Manage self hosted PostgreSQL in different cloud provider.
</div>
<div class="project-links">
<a href="https://pgdeploy.com"" target="_blank" rel="noopener" class="project-link demo">Live</a>
</div>
</div>
<div class="project-card">
<div class="project-header">
<h3><a href="https://chromewebstore.google.com/detail/new-tab-reminder/mcgmfombdolcfpnbcefghclidgbdabih?hl=en-GB&authuser=0" target="_blank" rel="noopener">New Tab Reminder</a></h3>
<div class="project-tech">Vue.js</div> <div class="project-tech">Google Chrome</div>
</div>
<div class="project-description">
Todo in your browser
</div>
<div class="project-links">
<a href="https://chromewebstore.google.com/detail/new-tab-reminder/mcgmfombdolcfpnbcefghclidgbdabih?hl=en-GB&authuser=0" target="_blank" rel="noopener" class="project-link demo">Chrome Store</a>
<a href="https://github.com/coderhs/new-tab-reminders" target="_blank" rel="noopener" class="project-link code">GitHub</a>
</div>
</div>
<div class="project-card">
<div class="project-header">
<h3><a href="https://chromewebstore.google.com/detail/new-tab-motivational-quot/ajojhjckmhdpjggiodlhhjkahfnbapfh?hl=en-GB&authuser=0" target="_blank" rel="noopener">New Tab Motivational Quote</a></h3>
<div class="project-tech">Javascript</div> <div class="project-tech">Google Chrome</div>
</div>
<div class="project-description">
Motivational quote on new tab
</div>
<div class="project-links">
<a href="https://chromewebstore.google.com/detail/new-tab-motivational-quot/ajojhjckmhdpjggiodlhhjkahfnbapfh?hl=en-GB&authuser=0" target="_blank" rel="noopener" class="project-link demo">Chrome Store</a>
<a href="https://github.com/coderhs/WeeklyMotivationalQuotes" target="_blank" rel="noopener" class="project-link code">GitHub</a>
</div>
</div>
<!-- UPI QR Generator -->
<div class="project-card">
<div class="project-header">
<h3><a href="https://upi-qr.hsps.in/" target="_blank" rel="noopener">UPI QR Generator</a></h3>
<div class="project-tech">Next.js</div> <div class="project-tech"> Vercel </div>
</div>
<div class="project-description">
Instantly generate UPI QR codes for payments.
</div>
<div class="project-links">
<a href="https://upi-qr.hsps.in/" target="_blank" rel="noopener" class="project-link demo">Live Demo</a>
<a href="https://github.com/coderhs/upi-qr" target="_blank" rel="noopener" class="project-link code">GitHub</a>
</div>
</div>
</div>
<style>
.projects-intro {
font-size: 1.1em;
color: #666;
margin-bottom: 2rem;
font-style: italic;
}
.projects-grid {
display: flex;
flex-direction: column;
gap: 1.25rem;
margin-top: 1.5rem;
}
.project-card {
border: 1px solid #e1e5e9;
border-radius: 6px;
padding: 1rem;
background: #ffffff;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
transition: all 0.3s ease;
position: relative;
}
.project-card:hover {
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
transform: translateY(-2px);
}
.project-header {
margin-bottom: 0.75rem;
}
.project-header h3 {
margin: 0 0 0.3rem 0;
font-size: 1.1em;
}
.project-header h3 a {
color: #333;
text-decoration: none;
}
.project-header h3 a:hover {
color: #007acc;
}
.project-tech {
font-size: 0.75em;
color: #007acc;
font-weight: 500;
background: #f0f8ff;
display: inline-block;
padding: 0.15rem 0.4rem;
border-radius: 3px;
margin-right: 0.3rem;
}
.project-description {
line-height: 1.5;
margin-bottom: 1rem;
font-size: 0.9em;
}
.project-links {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
}
.project-link {
text-decoration: none;
padding: 0.4rem 0.8rem;
border-radius: 4px;
font-size: 0.8em;
font-weight: 500;
transition: all 0.2s ease;
border: 1px solid;
}
.project-link.demo {
color: white;
border-color: #007acc;
}
.project-link.demo:hover {
background: #005fa3;
border-color: #005fa3;
}
.project-link.code {
background: transparent;
color: #333;
border-color: #ddd;
}
.project-link.code:hover {
background: #f5f5f5;
border-color: #bbb;
}
/* Dark mode support */
@media (prefers-color-scheme: dark) {
.project-card {
border-color: #4a5568;
}
.project-header h3 a {
color: #e2e8f0;
}
.project-description {
}
.project-tech {
background: #2a4a6b;
color: #90cdf4;
}
.project-link.code {
color: #e2e8f0;
border-color: #4a5568;
}
.project-link.code:hover {
background: #4a5568;
border-color: #718096;
}
}
/* Mobile responsiveness */
@media (max-width: 768px) {
.projects-grid {
gap: 1rem;
}
.project-card {
padding: 0.75rem;
}
.project-links {
justify-content: center;
}
}
</style>Subscribe
https://hsps.in/subscribe/
Sun, 05 Jun 2022 15:22:34 -0700https://hsps.in/subscribe/<script
async
data-uid="a65a4a5f09"
src="https://coderhs.kit.com/a65a4a5f09/index.js"
></script>Video
https://hsps.in/videos/
Sun, 05 Jun 2022 15:22:34 -0700https://hsps.in/videos/<p>Link to videos of my talks.</p>
<ul>
<li><a href="https://www.youtube.com/watch?v=zJnFepGZWME&ab_channel=RubyConfTaiwan">Ruby Conf Taiwan, 2016 - Using database to pull your applications weight</a></li>
<li><a href="https://www.youtube.com/watch?v=zFHRyHjYhrw&feature=emb_title&ab_channel=DeccanRubyConf2017">Deccan Ruby Conf, 2017 - Using databases to pull your application weight </a></li>
<li><a href="https://www.youtube.com/watch?v=NG2NHVflg_g&list=PLAe40eo3BfWB30ZduNQaI66mdCWQKU92Y&index=19&ab_channel=PostgreSQLIndia">PostgreSQL Conf India, 2017 - Using databases to pull your application weight</a></li>
<li>South Easy Ruby, 2017 (Nashville, USA)</li>
<li><a href="https://www.youtube.com/watch?v=F7_jbT8g3Qw&ab_channel=BryanBibat">Ruby Conf Philippines, 2018 - Embracing Failures to Avoid Meltdown</a></li>
<li><a href="https://www.youtube.com/watch?v=3hYlghzakow&feature=emb_title&ab_channel=Confreaks">Rails Conf 2018, Pittsburgh, USA - Using databases to pull your application weight</a></li>
<li><a href="https://www.youtube.com/watch?v=jLf3SxF-7o4&ab_channel=RubyConfTaiwan">Ruby/Elixir Conf Taiwan, 2018 - Embracing failures to prevent meltdown</a></li>
</ul>Using String in Active Record(Rails) Enum
https://hsps.in/post/using-string-as-active-record-enum/
Tue, 31 May 2022 20:10:36 -0700https://hsps.in/post/using-string-as-active-record-enum/<p>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 primitive data types, they are pretty much like enum where the values it can hold is defined already by the language. Ruby dynamic type system does hide all this complexity for us while we develop.</p>
<p>Enum is quite useful when you want to make sure that only a specified list of values are saved for a field.</p>PHP + MySql a Deadly Combination: My introduction to the real world
https://hsps.in/post/php-plus-mysql-deadly-combination-there-was/
Sat, 21 May 2022 20:52:57 -0700https://hsps.in/post/php-plus-mysql-deadly-combination-there-was/<p>I am currently a senior Ruby on Rails programmer. This article is my tribute to PHP the language that introduced me to the real world.</p>
<p>I have been programming or aspiring to program (former/recovering imposter syndrome addict) since I was a child. You can say I was programming as well if you consider lego programming and hello world in turbo c as programming. During upper primary and high school I spend my time learning Java, C and C++. Creating a lot of command line applications, and being appreciated for how good and fast I was at implementing them, solving small problems and writings algorithms.</p>GIN: Generalized Inverted iNdex (on text)
https://hsps.in/post/generalized-inverted-index-gin-postgresql/
Thu, 19 May 2022 21:01:23 -0700https://hsps.in/post/generalized-inverted-index-gin-postgresql/<p>Indexes are an integral part of any production database. It improves the speed of your query, and which in tern speeds up your application. The faster you get your data, faster you can provide the result to your user, faster you can move on to your next user. Knowing different type of indexes allows you to choose which is the best for your data. As there is no silver bullet.</p>
<p><em><strong>PostgreSQL is the DB refereed to in this article</strong></em></p>
<p>This article is my humble attempt to explain and simplify what is Gin.</p>Count How Many Routes You Have
https://hsps.in/post/count-how-many-routes-you-have/
Tue, 17 May 2022 17:21:51 -0700https://hsps.in/post/count-how-many-routes-you-have/<p>It start with one, then two and it keeps on growing. The number of routes in your ruby on rails project can be a reflection of how complex your project is becoming. And if you are curious like me to know how many routes your project has, just run the following command in your rails console.</p>Books I Read 2021
https://hsps.in/post/books-i-read-2021/
Thu, 17 Feb 2022 10:03:49 -0800https://hsps.in/post/books-i-read-2021/<p>As a followup on my 2020 article on the list of books I have read in 2020. Here is 2021 version. I aimed to read at least one book a month in 2021. During some months I was able to achieve more than one book a month, but sadly I couldn’t keep it up for the whole year. 2022 is another year, hope to be able to do one book a month minimum this year.</p>Consequences of saying NO
https://hsps.in/post/no/
Sat, 24 Apr 2021 08:31:46 -0700https://hsps.in/post/no/<p>Disclaimer: This article is not against saying No. One should exercise no to protect ones individual wishes, freedom and mental health.</p>
<p>This article is about consequence of saying no or frequent no to your colleague(s), child or partner for something they want to do.</p>
<p>When you tell no, three things can happen.</p>
<ol>
<li>
<p><strong>You say No they don’t do it</strong>, but it lingers in there mind.</p>
</li>
<li>
<p><strong>You say No, they do it. And the bad thing you why they shouldn’t do it happens</strong>. Following this the person can learn to appreciate you, or just hate you still. (Well humans are like that)</p>
</li>
<li>
<p>This is the thing one should fear the most. <strong>You say No, they do it and everything went fine</strong>. With that they stop asking you for permission and even loosing respect to your advice.</p>
</li>
</ol>
<p>The above situation can be a good example of game theory, where the result of your advice or decision of saying No. Depends on how the other person react to it and its result.</p>Right vs Wrong (Part 1)
https://hsps.in/post/right-vs-wrong-part-1/
Sun, 28 Mar 2021 01:24:05 -0700https://hsps.in/post/right-vs-wrong-part-1/<p>There is no better examples of evolving definition (during the lifetime of person) than the definition of right or wrong.</p>
<p>When we are little the definition of Right and Wrong is absolute. The adults define them (especially our parents). What the show as Right is Right and what they treat as Wrong is Wrong. That is the time when everyone see right and wrong as binary, the simpler times which our mind will ache for in future. Telling lies are wrong, stealing is wrong.</p>
<p>As we grow right around the time we start school, we learn that right and wrong are relative. There are little lies and big lies, little truths and honest truth. We learn to navigate this world with our friends and young foolish loves. This relative truths are based on the absolute truth from which we grew. Where in the absolute world a lie is wrong. In the relative world, simple and small lie here and there is fine. As long as it doesnât hurt anyone, and it makes your life simpler.</p>Books I Read 2020
https://hsps.in/post/books-i-read-2020/
Sat, 13 Feb 2021 15:04:42 -0800https://hsps.in/post/books-i-read-2020/<p>I have seen many people write about the favorite books that they read in (2020, 2019, etc). I have a friend who has been posting regularly for almost a decade. Feeling inspired from this, here is my list of books that I read in 2020. I do like reading books, but I haven’t been able to keep up with as much as I would have loved to read. 2020 allowed me to catch up a bit, and hope to continue that.</p>
<p>PS: Unlike most others who write their favorites, mine is pretty much just a list of books I read.</p>What You Learn From Binge Watching
https://hsps.in/post/what-you-learn-from-binge-watching/
Sun, 13 Sep 2020 18:42:35 -0700https://hsps.in/post/what-you-learn-from-binge-watching/<p>Binge Watching or Marathon watching is the practice of watching multiple episodes of a television program in rapid succession, typically by means of DVDs or digital streaming (Source: Oxford Dictionary). It has become a more common pass time or activity for the common people. It has become something that is planned and prepared to do alone or as a group. The availability of shows on demand through streaming service is the reason behinds huge growth of this activity, from a casual reference here and there to a more common social activity.</p>
<p>There is the joy of waiting for each episode, per week. Discussing theories for the next episode and reviews of the previous one with friends or other fans. This is still there even when you binge watch. Just that instead of the next episode you are discussing about the next season.</p>
<p>But what I wanted to write is not about what binge watching is or how it is (or it is not) good. What I wanted to talk about is, what I learned or noticed binge watching old TV shows or a long 10/11 season TV shows. The good points that I feel like is good to know or keep in mind in ones life. The one here is me of course đ.</p>About
https://hsps.in/about/
Sat, 29 Aug 2020 15:22:34 -0700https://hsps.in/about/[TIL] Starting Ruby Method With Capital Letter
https://hsps.in/post/til-what-happens-when-you-start-ruby-method-with-capital-letters/
Sun, 01 May 2016 00:00:00 +0530https://hsps.in/post/til-what-happens-when-you-start-ruby-method-with-capital-letters/<p>Last day while I was browsing through some Java code online, I noticed that some method has names starting with capital letters. I Method names are written in small letters in ruby. This Java code made me wonder if there was anything preventing us from using method names starting with capital letter, in ruby. So I started my irb and wrote the following code.</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-rb" data-lang="rb"><span class="line"><span class="cl"><span class="k">def</span> <span class="nf">Test</span>
</span></span><span class="line"><span class="cl"> <span class="nb">puts</span> <span class="s1">'testing 123'</span>
</span></span><span class="line"><span class="cl"><span class="k">end</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>And when I ran to call the method Test in the irb i got the following error.</p>Review on Rail 4.3.0 Beta
https://hsps.in/post/review-on-rail-4.3.0-beta/
Wed, 20 Aug 2014 00:00:00 -0530https://hsps.in/post/review-on-rail-4.3.0-beta/<p>Active Job, deliver later will give us a lot of abstraction. One will have to move the business logic present in workers to models or services, but that would make our system more maintainable. If the Active Job is a simple plug and play then in future projects one can use delayed_job when the load is light and when the load increases they can shift to redis based resque or sidekiq. Thinking of migrating from one system to another always give the developers a head ache. This can essentially solve it. Active Job was planned to be a feature in rails 4.0 but later they decided not. I am glad that they are releasing it in 4.2</p>Splat Operator in Ruby
https://hsps.in/post/splat-operator-in-ruby/
Wed, 25 Sep 2013 00:00:00 -0530https://hsps.in/post/splat-operator-in-ruby/<p>Ruby splat operator (*variable) is used to convert an array of elements into an argument list.</p>Convert Short Urls to Long Urls
https://hsps.in/post/convert-short-urls-to-long-urls/
Tue, 11 Jun 2013 00:00:00 -0530https://hsps.in/post/convert-short-urls-to-long-urls/<p>How to get a long/actual url from a short url?</p>
<p>Sometimes when we try to fetch short urls, using curl, we get a blank page as reply or a 301 ERROR. The reason being that there is no html file stored at that location,only a header with details ,on where the person who has opened the url would be redirected to.</p>
<p>So to get the actual url or long url from the short url, we just have to read the location stored in the html header.</p>Open and View the Source Code of a Gem
https://hsps.in/post/open-and-view-the-source-code-of-a-gem/
Thu, 23 May 2013 00:00:00 -0530https://hsps.in/post/open-and-view-the-source-code-of-a-gem/<p>Now this is a small blog post, issued in interest of the beginners. On how to open and video the code of a ruby gem you are using.</p>When My Alarm Was Found to Be Not Working
https://hsps.in/post/when-my-alarm-was-found-to-be-not-working/
Fri, 15 Mar 2013 00:00:00 +0000https://hsps.in/post/when-my-alarm-was-found-to-be-not-working/<p>Due to some unfortunate events</p>
<ol>
<li>Loosing my phone</li>
<li>K-alarm crashing</li>
</ol>
<p>I faced a common problem for many people “No alarm to wake me up in the morning”. Like every single man, I love sleeping. So unless an alarm or person wakes me up, I will continue to enjoy sleeping - until the urge from my second passion (hunger) wakes me up.</p>
<p>Despite the fact that I love sleeping, my team mates at Ruby Kitchen, won’t be happy with me coming late to work. Challenged with such a problem, I did what every computer hacker would do.</p>
<p><strong>Wrote a program to wake me up, at 6:00 AM đ</strong></p>Model Update_attribute Update_attributes
https://hsps.in/post/model-update_attribute-update_attributes/
Wed, 23 Jan 2013 00:00:00 +0000https://hsps.in/post/model-update_attribute-update_attributes/<p>Lot of people might have a confusing between the functionality of update_attribute and update_attributes. The purpose of these functions can be understood from their name itself. the first one update_attribute would update a single attribute of the model</p>Make Self Executing Ruby Scripts Linux
https://hsps.in/post/make-self-executing-ruby-scripts-linux/
Wed, 05 Dec 2012 00:00:00 +0000https://hsps.in/post/make-self-executing-ruby-scripts-linux/<p>To run a ruby program we use the command <code>ruby</code></p>
<p><code>ruby program_name.rb</code>.</p>
<p>Ruby being an interpreter style language, each line is interpreted(read) one after the other and executable object code file is created for reuse like in case of compiler languages C, C++, etc.. To run a ruby code you need a ruby interpreter installed in your system.</p>Setup Postgresql and Its Libraries to Work With Rails
https://hsps.in/post/setup-postgresql-and-its-libraries-to-work-with-rails/
Tue, 27 Nov 2012 00:00:00 +0000https://hsps.in/post/setup-postgresql-and-its-libraries-to-work-with-rails/<p>Recently lot of people have been asking me why they are not able to install the pg (PostgreSQL) gem even after installing PostgreSQL server in their system?</p>
<p>Well the answer is simple, the pg gem, requires the PostgreSQL development libraries to build native extensions to communicate with the PostgreSQL server. Native extensions refer to building ruby extensions or wrappers for existing C or C++ library.</p>
<p>One can install the development libraries of PostgreSQL by installing the libpg-dev package.</p>Install Ruby via Source Ubuntu
https://hsps.in/post/install-ruby-via-source-ubuntu/
Thu, 15 Nov 2012 00:00:00 +0000https://hsps.in/post/install-ruby-via-source-ubuntu/<p>This blog post is for old style programmer who wish to install ruby via compiling the source code, like how I do it. This blog post is written in a just to know basis.</p>
<p>The source code of ruby can be downloaded from rubyâs official website <a href="http://www.ruby-lang.org/en/downloads/">http://www.ruby-lang.org/en/downloads/</a>.</p>
<p>Dependency for Ruby and Ruby on Rails : <em><strong>libreadline, libyaml, libxml, libssl, zlib1g.</strong></em></p>
<p>In ubuntu you can have these libraries installed via the command line ( or if you are so old fashion you may google and find the source code for these packages as well)</p>Store RPM Packages in Cache
https://hsps.in/post/store-rpm-packages-in-cache/
Sun, 29 Jan 2012 00:00:00 -0530https://hsps.in/post/store-rpm-packages-in-cache/<p>Every time you download a RPM package for installation / updation via yum in Centos / Redhat system it gets deleted automatically after the procedure. Its a rather handy process by which your systems does not waste space storing the installation files.</p>
<p>Want to keep those packages in your system, and maybe create a local repository?</p>
<p>Well there are several ways. Simplest of them would be to edit the yum configuration file.</p>Create Your Own Ubuntu
https://hsps.in/post/create-your-own-ubuntu/
Wed, 25 Jan 2012 00:07:30 -0700https://hsps.in/post/create-your-own-ubuntu/<p>Many a times I wanted to create my own customized ubuntu, why???</p>
<p>Well 3 reasons</p>
<ol>
<li>I hate having to download the same set of softwares over and over gain, while I reinstall OS.</li>
<li>Lot of my friends want the same set of softwares that I use, so making an ISO will help those out without a stable and unlimited net connection.
I think its cool.</li>
<li>So I have decided to make my own customized ubuntu with lot of programming tools, documentations and compilers added on to it by default. Its the same Ubuntu itself, no change in the internal structure. (Just that we can have more software at the first installation itself)</li>
</ol>
<p>To build such a version is actually easy, there is a software/tool called Ubuntu Customization Kit. So hackers out there why don’t you give it a shot.</p>puts "Hello World"
https://hsps.in/post/puts-hello-world/
Sat, 14 Jan 2012 00:07:30 -0700https://hsps.in/post/puts-hello-world/<p>Don’t know if it is the best way to start, but here it goes…</p>
<p>I am starting a technical blog, something that I wanted to do for a while…</p>
<p>So wish me luck =)</p>