Skip to content

Instantly share code, notes, and snippets.

from typing import Sequence, List, NamedTuple, Optional
from pprint import pprint
from os import getenv
import json
import random
import requests
import sys
class Person(NamedTuple):
name: str
@alexander-matz
alexander-matz / run-async.sh
Last active February 11, 2022 12:41
dead simple pure-bash "job scheduler" with configurable number of background processes
#!/bin/bash
run-async() {
local joblist=($(jobs -p))
while (( ${#joblist[*]} >= 4 )); do # set 4 to the maximum number of jobs you want
sleep 0.1
joblist=($(jobs -p))
done
if [[ $# -eq 0 ]]; then # start shell with provided input if no arguments
local code="$(</dev/stdin)"
local ffi = require('ffi')
--local lib = ffi.load('libraylib.2.0.0.dylib')
local lib = ffi.load('libraylib')
ffi.cdef[[
// Vector2 type
typedef struct Vector2 {
float x;
float y;
} Vector2;
@alexander-matz
alexander-matz / graphiq.Rscript
Created October 11, 2018 14:27
Nice Graph Colors from the Graphiq Blog
# Color palettes that actually look good from 1 .. 12 colors
# Taken from: https://blog.graphiq.com/finding-the-right-color-palettes-for-data-visualizations-fcd4e707a283
graphiq <- function (n, option = 'warm') {
if (n < 1 || n > 12) stop('colors only defined for n = 1..12');
if (option == 'warm') {
return(switch(n,
c("#FDB25F"),
c("#FFC96B", "#F47942"),
c("#FFC96B", "#F47942", "#AB412C"),
c("#FFD773", "#F99851", "#EF5833", "#923E2D"),