RSSAmplifier

Blog

Just Being

A blog about Programming, living in Nature and, random thoughts.

bshankar.pages.devRSS feed ↗17 posts

Latest posts

Why I don't use full disk encryption

After diving into the rabbit hole of encrypting my entire disk, I decided it is not worth it. These are my reasons: High app launch delay: Cloudflare benchmarked dm-crypt encrypted disks to be 2-7 times slower . It means apps start at snail's pace; imagine a web browser opening in 5s instead of 0.7s. Impact on battery life and RAM: Encrypting, decrypting bytes, and juggling them across the…

A weird algorithm for sharing coins

Here's a memorable problem from Project Euler: There are 7 ways to separate 5 coins into piles (as shown). How about 100 coins? OOOOO OOOO O OOO OO OOO O O OO OO O OO O O O O O O O O Solution In number theory, it is known as the partition function : $p(k)$. So $p(5) = 7$. A simple formula for $p(n)$ is currently unknown but, we can calculate it recursively. The key insight is how we break…

Self-existing objects of time travel

Jinn particle is a mind boggling yet simple concept from theoretical physics that has been explored in fiction. To understand what it is, imagine meeting an old man who gifts you a book. Leaving, he says "Do not open the book until you know who I am." Decades pass by and you forget the book in the corner of a closet. Looking in the mirror, one day, you realize that you are starting to appear…

A puzzle led me to a curious world of numbers

A seemingly simple puzzle took me down a rabbit hole. Find a number that grows exactly $\frac{3}{2}$ times when the first digit becomes the last digit. For example, turning first digit into the last digit looks like this: 1 234 → 234 1 . For brevity, let's call it rotating the number. Solving with Brute force The first idea that comes to mind. After all, the computer can check millions of…

Unexpected life lessons near the Tibet border

What I saw passing through a military guarded area, will stay with me to the end. The incident A short middle-aged man, wearing muddy, torn clothes was throwing stones at the army officers. His facial features indicated down's syndrome . Clearly, he had the intelligence of a child. His flings were weak. Most stones missed and a few landed near their boots. A young officer furious, held his…

Four stories for honing mental toughness

If you suffer from difficult emotions like me, this post can help. After exploring pragmatic beliefs , I long to share these four stories. These tales are a refuge during turbulent times. So, they are close to my heart. Most of these are extracted from discourses given by the Buddha . Ruminations of a dying king A king goes hunting in a forest and is shot with a poisoned arrow. His men rush him to…

A simple setup for distraction free writing

I am at peace after purging Instagram, WhatsApp, and YouTube. Life is slower and incredibly mindful. I am settling comfortably into books, the small web and crafting this blog . Chosen tools for writing Worn down by configuration fatigue induced by abusing Emacs, Vim, and window managers for years, I am in search for simple tools that get things done. They have to be: Zero config - should have…

CSS tips: Gentle image filters for dark mode

Viewing images in dark mode can hurt your eyes. This is because, while text is optimised for reading in low light reading automatically, images are often neglected. So, a bright image in the middle of prose causes discomfort. I mulled over this issue. Here are some solutions I came up with: Illustrations Diagrams, illustrations, comics, cartoons etc whose colors aren't constrained by reality…

Strange paradoxes of recursive universes

I couldn't believe my own answer to this puzzle. After thinking hard to disprove it, I finally understood it. Imagine being in a large box with your box lying on the floor beside you. Your box contains a smaller copy of you and a smaller box inside and so on ad infinitum. You reach your hand into your box and pull out the smaller box. As you do this, you see a bigger hand coming from above…

Sudoku solver in 100 lines of Rust

Sudoku is an addictive number placement puzzle that is logic-based. To win, you should fill the missing cells such that all rows, columns and each of the nine 3x3 boxes contain all numbers from 1 to 9. A well-posed Sudoku has only one solution. After conquering basic algorithms, a Sudoku solver feels like a rite of passage to be a good coder. So, let's write a program that can solve any…

Moving my family to conversations (XMPP)

Conversations is really awesome. It is a secure, private and decentralized chat app. There is no privacy invading ads company like meta running the service. I was sold and wanted to try it out with my family. Only one small issue - conversations costs ₹550 in the play store. People don't like paying for software in our country. They would say: "I can eat for a week with 500 rupees. Let meta…

Easy math puzzle with an unbelievable answer

The answer to this puzzle is so surprising that it has lingered in my mind for decades. Try to solve it before looking at the answer. How would you explain the solution intuitively? In a class of 500 students, 99% are right-handed. How many right-handers should leave the class to make it 98%? Solution The class has 99% right-handers. So, the number of right-handed students (S_r) is: S_r = 500…

Designing effective types in Rust

We use type systems to minimize the subset of valid inputs to an API. That's it. Nothing more. Thoughts are non-linear and messy. So, we make mistakes while turning our thoughts into code which needs to be precise. Using this guiding principle, we can often arrive at the best types for business logic. Diving into an example Let's say we are writing a university management software. We…

Being a chicken in a farm

Consider a thought experiment that says a lot about the human condition: Imagine waking up as a chicken in a farm. You don't have any memories as a human, but you are intelligent. Observing the world around you, you start wondering about the meaning of your existence. You see a fence beyond which you cannot leave. There is a really powerful being (a human) taking care of you. Let's call…

Meditation changes everything

"The mind is the forerunner of all things." -- The Dhammapada This post is my ode to the ancient practice of meditation and mindfulness. Thank you for showing how deep the mind's conditioning and perceptual habits go. The mind does create your world. Much gratitude for changing everything . If you don't believe me, here's what science has to say: Physical effects Dramatic reduction…

The teachers who made me

Sometimes by luck or destiny we meet extraordinary teachers. They imbue us with confidence and encourage us to learn and pursue interests that we would never do. In this process we will transform into a different people. My story is also a bit like that. So, in this post, I want to express my gratitude for all such teachers. I will address them as sir/madam like we do in our native language.…

Why start another blog?

I started many blogs when I was young but all of them have somehow disappeared. Either I forgot about them or lost motivation to keep them updated. This begs the question of why did I return to something that I am so prone to failing at? The earliest known cave paintings date back to 50,000 BC. Some people during that time decided to take some time off their struggles to survive and draw paintings…