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 /
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.


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 /
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 /
Created August 5, 2023 22:34
A sortable link list

Sortable Linked List


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

	get value() {
 return this._value;
shovon / base64.ts
Created April 10, 2023 05:23
Base64 encoder decoder in TypeScript
Copyright 2023 Sal Rahman
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the “Software”), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
shovon /
Last active January 26, 2023 23:44

We want to prove that

$$ \left(1+\dfrac{1}{n}\right)^n < e < \left(1+\dfrac{1}{n}\right)^{n+1} $$

We will assume that $n \in \mathbb{N}$, $n &gt; 0$.

Left Side $(1+\dfrac{1}{n})^n &lt; e$

shovon / traversal.ts
Last active November 17, 2022 19:11
Determine if an adjacency list represents a single graph
interface ReadOnlyMapNoGetter<K, V> {
has(key: K): boolean;
entries(): IterableIterator<[K, V]>;
forEach(cb: (value: V, key: K, map: ReadOnlyMapNoGetter<K, V>) => void): void;
keys(): IterableIterator<K>;
values(): IterableIterator<V>;
readonly size: number;
interface ReadOnlyMap<K, V> extends ReadOnlyMapNoGetter<K, V> {
class Trie {
private children: Map<string, Trie> = new Map();
insert(value: string) {
if (value === "") {
const first = value[0];
if (!first) {
throw new Error("Expected the first element to not be an empty string.");
shovon / cons-list.ts
Created March 29, 2022 01:47
Lisp-style cons-based list
type List<T1> = [T1, List<T1> | null];
function* iterateCons<T>([left, right]: List<T>): IterableIterator<T> {
if (right) {
yield* iterateCons(right);
yield left;
const cons = <T1, T2>(left: T1, right: T2): [T1, T2] => [left, right];
type Pipe<T> = {
_<V>(fn: (value: T) => V): Pipe<V>;
readonly value: T;
function start<T>(initial: T): Pipe<T> {
return {
_<V>(fn: (value: T) => V): Pipe<V> {
return start(fn(initial));
export type Listener<T> = (value: T) => void;
export type OperatorFunction<T, V> = (
oberver: IObservable<T>
) => IObservable<V>;
export interface IObservable<T> {
subscribe(listner: Listener<T>): () => void;