Skip to content

Instantly share code, notes, and snippets.

@Azmisov
Azmisov / set_vs_array.mjs
Last active March 29, 2025 09:43
Benchmark javascript Set vs Array performance for inserting elements
import fs from "node:fs";
import { fileURLToPath } from 'url'
const __filename = fileURLToPath(import.meta.url)
import { Worker, isMainThread, parentPort } from 'node:worker_threads';
import { performance } from "node:perf_hooks";
/** Output filename */
const output_fname = "./results.csv";
/** Use a wrapper around Set, to make the comparison more even for inlined array operations */
const COMPARE_INLINED = true;
@Azmisov
Azmisov / cmap_parser.py
Last active December 15, 2020 20:57
Converts .RGB files into colorscheme strings that can be used in MathGL
""" This searches for an accurate linear approximation of a ".rgb" file gradient.
Run it like so: ``python3 cmap_parser.py path/to/color_map.rgb``
See this site for a list of colormaps
https://www.ncl.ucar.edu/Document/Graphics/color_table_gallery.shtml
"""
import random, sys, re, math
class RGBApproximation: