Skip to content

Instantly share code, notes, and snippets.

@karlrwjohnson
karlrwjohnson / generate_pinch_pot.py
Created December 22, 2017 06:02
Procedural STL file generation in Python
import functools
import numpy
import struct
import svg.path # pip install svg.path==2.2
from typing import List, Dict, Tuple, Callable # kitchen sink?
array=numpy.array
# SVG <path> string describing the undistorted profile of the pot
PATH_DATA='''
m 0,50.916666 9.1801683,0 c 0.8686257,-1.2561 2.0631007,-1.983971 3.2272117,-2.612425 6.345522,-3.425674 6.113453,-5.441741 9.183746,-10.130426 3.920877,-5.987623 6.247456,-11.575049 11.615424,-15.913572 1.361948,-1.10076 2.477231,0.565914 1.236122,1.532279 -5.445873,4.240321 -7.508074,9.124891 -11.047477,15.345625 C 20.372917,44.45 19.05,46.566667 12.975328,49.970155 11.821211,50.616778 10.583333,51.59375 10.583333,52.916667 L 0,52.916667
@karlrwjohnson
karlrwjohnson / message_queue_demo.py
Created November 7, 2017 22:41
PostgreSQL Message Queue Demo
'''
Postgres automatic message queue demo
Wherein a record-insertion trigger notifies a worker to process new table records
Requires:
- Python 3.6
- Postgres 9.6
- Psycopg2
Usage:
@karlrwjohnson
karlrwjohnson / In-SQL Rules Engine Demo.sql
Created September 13, 2017 20:56
In-SQL Rules Engine Demo
---------------------------------------------------------
-- Boilerplate mocking out what we already have today. --
-- Just scroll down to the bottom. --
---------------------------------------------------------
-- Cleanup
drop table if exists
import_log,
my_data_source,
meta_record,
@karlrwjohnson
karlrwjohnson / RewrapLineCommand.py
Last active February 26, 2017 01:26
Sublime plugin that re-wraps plain text so it just fits under 80 characters. Supports indented blocks, too!
# Sublime plugin that re-wraps text blocks so that each line contains the
# maximum number of characters before line 80
# To install (Sublime 3?), find your Packages/User directory by going to
# Preferences Menu > Browse Packages...
#
# Save this file into that directory.
#
# To enable it in the [Ctrl+Shift+P] command palette, create a file called
# "mine.sublime-commands" (exact name before extension doesn't matter),