Skip to content

Instantly share code, notes, and snippets.

View poke1024's full-sized avatar

Bernhard Liebl poke1024

  • Leipzig University
  • Germany
View GitHub Profile
@poke1024
poke1024 / polygon_mask.py
Created November 13, 2019 07:51
create a bitmap mask from a shapely polygon
import numpy
import cairo
def polygon_mask(polygon):
assert polygon.geom_type == 'Polygon'
minx, miny, maxx, maxy = polygon.bounds
minx, miny = numpy.floor([minx, miny]).astype(numpy.int32)
maxx, maxy = numpy.ceil([maxx, maxy]).astype(numpy.int32)
@poke1024
poke1024 / gist:3d8b969c597c851a1c5765ef527bc6af
Created August 1, 2025 10:13
SolidJS inside anywidget (marimo)
import anywidget
import traitlets
import marimo as mo
class ExampleWidget(anywidget.AnyWidget):
_esm = """
import {
createSignal,
onCleanup,
} from "https://cdn.skypack.dev/solid-js";