Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Fogleman fogleman

View GitHub Profile
View syncthing.txt
- 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
@fogleman
fogleman / main.cpp
Last active Jul 13, 2019
Gray-Scott Reaction-Diffusion with OpenCL
View main.cpp
#define CL_SILENCE_DEPRECATION
// #if defined(__APPLE__) || defined(__MACOSX)
// #include <OpenCL/cl.hpp>
// #else
// #include <CL/cl.hpp>
// #endif
#include "cl.hpp"
View warp.py
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 / heightmap2stl.py
Created Aug 22, 2018
Heightmap to 3D Mesh
View heightmap2stl.py
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 Jul 30, 2018
How many floats between -1 and 1?
View floats.c
#include <stdint.h>
#include <stdio.h>
typedef union {
uint32_t a;
float b;
} float_or_int;
int main() {
float_or_int u;
View complex.go
package main
import (
"image"
"image/color"
"math"
"math/cmplx"
"github.com/fogleman/fauxgl"
"github.com/fogleman/gg"
@fogleman
fogleman / isoline.go
Created Feb 16, 2018
Heightmap to Isolines
View isoline.go
package main
import (
"fmt"
"image"
"image/draw"
"image/png"
"math"
"os"
@fogleman
fogleman / orient.go
Created Feb 2, 2018
Model Orientation
View orient.go
package main
import (
"fmt"
"math"
"os"
"time"
"github.com/fogleman/fauxgl"
embree "github.com/fogleman/go-embree"
@fogleman
fogleman / astar.py
Created Dec 3, 2017
A* Search in Python
View astar.py
import heapq
def estimated_distance(node, target):
x1, y1 = node
x2, y2 = target
dx, dy = abs(x1 - x2), abs(y1 - y2)
dist = dx + dy
return dist
def shortest_path(graph, source, target, heuristic_func=None):
@fogleman
fogleman / osm.py
Created Nov 28, 2017
AxiDraw + OpenStreetMap
View osm.py
from imposm.parser import OSMParser
from shapely import geometry, ops
import axi
import math
import sys
# put your lat/lng here
LAT, LNG = 0, 0
You can’t perform that action at this time.