Skip to content

Instantly share code, notes, and snippets.

@aciceri
aciceri / marchingcube.js
Last active March 31, 2019 17:25
Marching cubes in Javascript
var triTable = [
[-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1],
[3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
@aciceri
aciceri / test.c
Created May 28, 2019 23:25
Personale approccio alla memoizzazione in C usando i puntatori a funzione.
#include <stdio.h>
#include <stdlib.h>
/* Roba relativa alla gestione della memoizzazione, in teoria riutilizzabile per
* diverse funzioni */
#define LUNGHEZZA 1000
struct { //Memoria globale, cioe' vettore di coppie input/output
int in, out;
} memoria[LUNGHEZZA];
@aciceri
aciceri / bf2pyc.py
Last active August 4, 2025 02:58
Brainfuck to Python bytecode compiler
#!/usr/bin/env python3
from sys import exit, stdin
from argparse import ArgumentParser, RawDescriptionHelpFormatter, FileType
from types import CodeType
from dis import dis, opmap
import marshal
from importlib.util import MAGIC_NUMBER
from textwrap import dedent
@aciceri
aciceri / flake.nix
Last active February 19, 2023 18:13
A Nix Flake example for an Haskell application
{
description = "An Haskell application";
inputs = {
nixpkgs.url = github:NixOS/nixpkgs;
flake-utils.url = github:numtide/flake-utils;
easy-hls-src.url = github:jkachmar/easy-hls-nix;
};
outputs = { self, nixpkgs, flake-utils, easy-hls-src }:
{
nixpkgs ? <nixpkgs>,
system ? builtins.currentSystem
}: let
pkgs = import nixpkgs { inherit system; };
inherit (pkgs) lib;
# Bailey–Borwein–Plouffe formula
piDigit = n: pkgs.runCommand "pi-${toString n}" {} ''
n=${toString n}; ${lib.getExe pkgs.python314} -c "