Skip to content

Instantly share code, notes, and snippets.

View fogleman's full-sized avatar

Michael Fogleman fogleman

View GitHub Profile
@fogleman
fogleman / distinct.py
Last active December 1, 2020 05:07
Python Unique / Distinct Elements Iterator
def distinct(iterable, keyfunc=None):
seen = set()
for item in iterable:
key = item if keyfunc is None else keyfunc(item)
if key not in seen:
seen.add(key)
yield item
if __name__ == '__main__':
x = [0, 0, 1, 0, 1, 2, 2, 1, 0]
@fogleman
fogleman / index.html
Created January 1, 2017 03:55
Position, Velocity, Acceleration, Jerk
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>body {padding: 0; margin: 0; overflow: hidden;}</style>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.6.2/dat.gui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.5/p5.min.js"></script>
@fogleman
fogleman / nouns.txt
Created June 17, 2014 15:00
Common Nouns
act
air
ant
arm
art
bag
bat
bed
bee
bit
- Install & launch
$ brew install syncthing
$ brew services start syncthing
- Install it on your Linode or whatever too
- https://apt.syncthing.net/
- Visit local dashboard at http://localhost:8384/
- Click `Add Remote Device` to sync with another machine
import cairocffi as cairo
import numpy as np
import random
def random_coefs(order, sigma):
return [random.gauss(0, sigma) for _ in range(order)]
def random_transform():
y_dx = random_coefs(5, 0.3)
y_dy = random_coefs(5, 0.3)
@fogleman
fogleman / README.md
Last active December 8, 2018 09:32
Roulette (curve)

In the differential geometry of curves, a roulette is a kind of curve, generalizing cycloids, epicycloids, hypocycloids, trochoids, and involutes.

This p5.js sketch implements hypotrochoid and epicycloid roulettes.

@fogleman
fogleman / heightmap2stl.py
Created August 22, 2018 16:45
Heightmap to 3D Mesh
from PIL import Image
from pyhull.delaunay import DelaunayTri
from shapely import geometry
from skimage import measure
from scipy import interpolate
import math
import numpy as np
import struct
import sys
@fogleman
fogleman / floats.c
Created July 30, 2018 13:07
How many floats between -1 and 1?
#include <stdint.h>
#include <stdio.h>
typedef union {
uint32_t a;
float b;
} float_or_int;
int main() {
float_or_int u;
package main
import (
"image"
"image/color"
"math"
"math/cmplx"
"github.com/fogleman/fauxgl"
"github.com/fogleman/gg"
@fogleman
fogleman / isoline.go
Created February 16, 2018 04:11
Heightmap to Isolines
package main
import (
"fmt"
"image"
"image/draw"
"image/png"
"math"
"os"