Veerpal Brar

ABOUT   BLOG   PROJECTS   CAREER   RSS


How to Run a Program or Script Hourly on macOS

Do you have a program or bash script that needs to run continuously or on a specific time interval on your Mac? The solution lies in using launchd, an Apple-recommended approach and an open-source service management framework.


Solving Top K Frequent Objects with Count-Min Sketch

A recent system design problem I came across is how to calculate top-K items at a high scale. For instance, determining the top 100 videos on a streaming site.


Connecting Applications In Minikube

Over the past few months, I’ve been learning about Kubernetes through a side project. As I work with Minikube to run a local cluster with multiple services, I find myself just scratching the surface of Kubernetes. In this blog post, I aim to document my current understanding of the various ways applications in Minikube can connect to each other, the host machine, and the outside world.


Using A Bash Function To Push A Docker Image

I’ve been learning a bit about docker and found myself repeating the same commands over and over again to push a docker image. I decided to see if I could create an alias for multiple commands in bash.


Dependency Management With Bundler

The venv module in python isolates packages of one python project from another project. I remember trying to install flask and running into dependency conflicts until I learned about venv. Recently, I started wondering why I don’t run into the same issues when working with rails. This led me down the rabbit hole of learning about bundler and dependency isolation.


Database Updates Using A Quorum

This past week I learned how to have consistent read and writes in a distributed database using a quorum algorithm.


Fix N+1 Queries When Using Validates_associated With Has_many

This month, I ran into a interesting N+1 query problem caused by using validates_associated on a has_many model.


Include, Extend, And Prepend In Ruby

This month, I took the time to go back to basics and try to understand how include, extend and prepend work in ruby.


Consistent Hashing

This month I started looking into adding a cache to your application and came across the problem of adding and removing cache instances from your application efficiently.


Scaling Applications With Message Queues

This month I started looking into system design patterns for scaling and application. I started off by learning about message queues: what are they and why are the useful?


Understanding Rspec Best Practices

This past month, I looked at “best practices” for writing RSpec tests. Sites like betterspecs and the RSpec style guide offer simple rules to follow. Yet, they do not elaborate on why they suggest the practices they do. Therefore, I decided to spend some time better understanding their recommendations.


Debugging Ruby

This month I looked into debugging ruby code. While I usually can figure out the source of bugs, I’ve been thinking about how to debug code more efficiently. When I debug in ruby, I tend to rely on printing variables to the terminal. If the code is more complex, I step through the code with byebug or binding.pry. During this past month, I’ve been learning techniques that let me level up these skills.


Inheritance Vs Composition

When I first learned object-oriented programming, I saw inheritance as a useful way for objects to share functionality. Yet, I often hear programmers say they prefer “Composition over inheritance”. This is an idea that I’ve been thinking about a lot as I’ve been reading books on object-oriented programming and design patterns. In this blog post, I attempt to summarize what I’ve understood about the benefits and drawbacks of inheritance.


Questions Answered #5: Implementing A Domain Specific Language In Ruby

Over the last few months, I’ve been reading about metaprogramming in Ruby and how it works. This month, I wanted to apply what I’ve learned and create a domain specific language (DSL) in Ruby.


Questions Answered #4: Singleton Methods In Ruby

In my last blog post on Structs and OpenStructs, I referenced how OpenStruct uses define_singleton_method to add methods to a single instance of OpenStruct during run time. In this blog post, I want to dig deeper into the mechanics of the ruby that make this possible.