Skip to content

Instantly share code, notes, and snippets.

View shovon's full-sized avatar
💻
Working on my own projects

Sal Rahman shovon

💻
Working on my own projects
View GitHub Profile
@shovon
shovon / aboutme.txt
Last active September 4, 2025 19:02
- I'm a software engineer
- I refuses to believe in magic, but I somehow want to make magic happen to those who believe it, even if it's not magic; without proper scrutiny, it feels like magic, but it isn't. Even though I don't like being around people who believe in magic, nevertheless, there is wisdom in having people believe in magic, and it's that they are busy with their lives, and their lives are chaos, and they need that chaos managed. Anyone who can help them is—in their eyes—practicing witchcraft. But deep down inside, I know that it isn't witchcraft; I just know how the world works, so deeply, that I can find where their problems lie, and where and how to solve it. The analogy of magic is fitting. Although a large part of what a magician practices is the art of deception and illusion, but at its essence, it's the information asymmetry. Although, I deeply believe in empowering people to be highly knowledgeable, that said, in the end of the day, the parallel to be drawn between me and that magician, i
@shovon
shovon / main.tsx
Last active July 23, 2025 06:29
A graph represented using an associative array, keyed by the number, and an array key-value pair
type Graph<K, V> = Map<K, [K, V][]>;
type BinaryTreeNode<T> = {
left?: [T] | null | undefined;
right?: [T] | null | undefined;
};
type BinaryTree<K> = Map<K, BinaryTreeNode<K>>;
const bst: BinaryTree<number> = new Map();
@shovon
shovon / base-node.ts
Last active May 13, 2025 07:14
Some zod schema utilities for creating a Zod schema for a recursive structure
import { z } from "zod";
export type BaseNode<T extends string = "children"> = {
[K in T]?: BaseNode<T>[];
};
/**
* Creates a schema for a node that forms a directed tree.
*
* Usage:
@shovon
shovon / gist:93960e4240fabd184150f441a4d3533e
Last active June 19, 2025 15:13
Frontend coding guidelines at my company

Some Common Sense

  • Murphy's rule: whatever can go wrong, will go wrong
    • Expect the unexpected
  • Be liberal in what you accept, and conservative in what you give out
    • Never trust client data
      • Validate it
    • Allow clients to send whatever
    • Things shouldn't crash
  • Fail gracefully

America's Protein Obsession: What's Driving It---and How to Navigate It Safely

In the United States, protein isn't just a macronutrient---it's a cultural symbol. Whether it's emblazoned on snack bars at the checkout line or fueling Instagram influencers' morning routines, protein has become the star of the nutritional show. But what's behind this fixation, and how should health-conscious individuals navigate it?

How Protein Became a Cultural Icon

Protein has long been associated with strength and vitality, but in recent decades, that connection has evolved into a full-blown obsession. Starting with the bodybuilding boom of the 1970s and later amplified by the low-carb craze of the 1990s and 2000s, protein earned a reputation as the "clean" nutrient---unlike fats, which were demonized, or carbs, which still struggle under the shadow of dietary suspicion.

Today, the narrative goes beyond physical health. A high-protein, mea

import * as bigintConversion from "bigint-conversion";
const extendedGcd = (
a: bigint,
b: bigint
): { result: bigint; x: bigint; y: bigint } => {
if (a === 0n) return { result: b, x: 0n, y: 1n };
const { result, x: x1, y: y1 } = extendedGcd(b % a, a);
return { result, x: y1 - (b / a) * x1, y: x1 };
};
@shovon
shovon / README.md
Last active July 10, 2024 22:52
A terminal emulator in Go

A terminal-based terminal emulator

Run a terminal from inside your terminal.

The purpose of this code is to demonstrate how to have applications running in a PTY (psedoterminal) environment.

Usage

Be sure to have Go installed.

@shovon
shovon / README.md
Created May 24, 2024 05:45
A dummy React clone

Kawaii: a dumb little JSX front-end library, purely created for educational purposes

I wrote this to teach myself on how React and other JSX library work behind the scenes.

Usage

First, you will need a bundler that doesn't exclusively work with React. Unfortunately, how to configure it is beyond the scope of this README file, since every bundler has their own way of converting JSX to JavaSript.

That said, there are some tutorials on how to do that.

@shovon
shovon / README.md
Last active September 4, 2023 20:09

Bounded Variable

Think of a bounded variable no different than a bounded queue to solve the consumer—producer problem.

A very common use case is for me is to push to a single variable from one producer, and pull from that single variable from one consumer.

Go has a very simple solution: channels.

But I was curious: can we improve the performance?

@shovon
shovon / README.md
Created August 5, 2023 22:34
A sortable link list

Sortable Linked List

Usage

class ComparableNumber implements Comparable<number> {
	constructor(private _value: number) {}

	get value() {
 return this._value;