Skip to content

Instantly share code, notes, and snippets.

@aabiji
aabiji / apollonian_gasket.py
Last active December 10, 2024 02:25
Simple script to generate an apollonian gasket
import math, cmath
import pygame
class Circle:
def __init__(self, x, y, curvature):
self.center = complex(x, y)
self.curvature = curvature
self.radius = abs(1 / curvature)
def descartes_theorem(k1, k2, k3):
@aabiji
aabiji / generate.py
Created November 8, 2024 03:55
A prototype color by number template generator
import cv2
import numpy as np
import random
class SVG:
def __init__(self, width, height):
self.width = width
self.height = height
self.elements = []
@aabiji
aabiji / yt.py
Last active December 27, 2024 06:29
Youtube video downloader
"""
A tiny youtube video downloader.
usage: yt.py [-h] [--only-audio] [--num_retries NUM_RETRIES] [--output OUTPUT] video_url
Inspried by this blog post: https://tyrrrz.me/blog/reverse-engineering-youtube-revisited
Note that the get_video_info function will be subject to change when Youtube changes their api.
Also note that ffmpeg and ffmpeg-python are required dependencies.
"""
import argparse
@aabiji
aabiji / tinytest.h
Last active October 20, 2023 16:21
Single header, C++ testing library.
/* Tinytest -- a tiny testing library under the MIT liscense.
* Should compile with std=c++17
* Example usage:
```
#include "tinytest.h"
int main() {
Tinytest::test("Test example", [](){
const char *a = "hello";
const char *b = "hello";
@aabiji
aabiji / sha256.c
Created July 19, 2023 03:20
A SHA256 implementatoin written in C.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
// K[0] to K[63] are initialized as the first 32 bits of the fractional
// parts of the cube roots of the first 64 primes
const uint32_t k[64] = {
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,