Skip to content

Instantly share code, notes, and snippets.

View arindas's full-sized avatar
:octocat:
Focusing

Arindam Das arindas

:octocat:
Focusing
View GitHub Profile
@arindas
arindas / mocking-tdd-demo.py
Created October 28, 2022 09:28
mocking-tdd-demo
import abc
class Source(metaclass=abc.ABCMeta):
@abc.abstractmethod
def read(self) -> int:
raise NotImplementedError()
class Sink(metaclass=abc.ABCMeta):
@abc.abstractmethod
def write(self, integer: int):
@arindas
arindas / map_image_to_palette.py
Created September 10, 2022 06:48
Maps a given image to the given palette. Image contains only colors from the given palette.
from textwrap import wrap
from scipy.spatial import cKDTree
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
import argparse
from pathlib import Path
def hex_to_rgb(hex: str):
return [int(x, 16) for x in wrap(hex.lstrip("#"), 2)]
@arindas
arindas / .tmux.conf
Created August 21, 2020 18:14
Tmux config for enabling 256 bit colors in terminal.
set -g default-terminal "xterm-256color"
set-option -ga terminal-overrides ",xterm-256color:Tc"
@arindas
arindas / sketch.js
Last active February 4, 2020 07:35
Implementaion of Bresenham Line drawing algorithm in p5.js
function setup() {
createCanvas(400, 400);
}
function drawLine(x0, y0, x1, y1, freq) {
var dx = abs(x1 - x0);
var sx = x0 < x1? 1: -1;
var dy = -abs(y1 - y0)
var sy = y0 < y1? 1: -1
var err = dx + dy
@arindas
arindas / process_f10.bash
Created September 13, 2019 10:59
List parent processes and their children from the output of `ps -ef`
#!/usr/bin/env bash
ps -ef | tail -n 20 > /tmp/10_procs
flag=0
mkdir -p /tmp/procs_folder/
while read -r uuid pid ppid _; do
if [[ flag -eq 0 ]]; then