Skip to content

Instantly share code, notes, and snippets.

@bencrowder
bencrowder / genealogysparkline.pv
Last active August 29, 2015 14:06
PlotDevice genealogy sparkline
# For PlotDevice (plotdevice.io)
# This code is crappy. It's hastily thrown together prototype code and shouldn't
# be used in anything remotely resembling a production environment.
def draw_sparkline(x, y, data, vital_size=1.5, child_size=0.8, marriage_size=1.5):
reset()
translate(x, y)
death_x = data['death'] - data['birth']
@bencrowder
bencrowder / watersun.pv
Created September 6, 2014 15:30
PlotDevice watersun demo
# For PlotDevice (plotdevice.io)
# This code is crappy. It's hastily thrown together prototype code and shouldn't
# be used in anything remotely resembling a production environment.
# Originally modeled after some code in the PlotDevice manual (http://plotdevice.io/tut/Geometry)
CIRCLE_CENTER_X = 200
CIRCLE_CENTER_Y = 200
INNER_CIRCLE_RADIUS = 100
@bencrowder
bencrowder / data.yaml
Last active August 29, 2015 14:14
Home teaching slips
updated_date: "Feb 2015"
districts:
- david-smith
- william-adams
- robert-taylor
people:
- "David | Smith | Elizabeth | 435-131-1414 | 1000 S 1000 E"
- "William | Adams | Sarah | 435-272-2923 | 920 S 700 E"
// Bot: Helm
// Ruleset: default
// --------------------------------------------------
var Helm = function() {};
Helm.prototype = new Bot();
Helm.prototype.setup = function() {
this.timer = 0;
#!/bin/bash
# --- Required variables ---
RSS_URI="/rss"
MAIL_TO="your@email.com"
LOG_FILE="/var/log/httpd/access_log"
LOG_DATE_FORMAT="%d/%b/%Y"
# --- Optional customization ---
rule
size 6x9";
# alternates
size letter;
size 210x297mm;
size a4;
font Arno Pro, 10/13pt;
margin 1";
@bencrowder
bencrowder / genline.py
Last active September 5, 2016 03:30
Line generation
#!/usr/bin/env python
# Code for https://blogs.bencrowder.net/cg/2012/line-art-experiments/
# Uses PIL (pip install pillow)
import random, math
from PIL import Image, ImageDraw
image_size = 4800
@bencrowder
bencrowder / splitimage.sh
Last active January 27, 2019 18:28
Shell script to split two-spread image into two different images. Uses ImageMagick.
#!/bin/sh
# Split two-spread image into two different images (leaving some overlap for safety)
# Usage: splitimage filename.jpg
# ----------------------------------------------------------------------------------
convert $1 -crop 56x100%+0+0 +repage output/`basename $1 .jpg`a.jpg
convert $1 -flop -crop 60x100%+0+0 -flop +repage output/`basename $1 .jpg`b.jpg
// Rust code sample
// This is extracted from a path tracer I wrote for class. I can't
// post the whole thing per the class rules, so you get this redacted
// version instead.
extern crate nalgebra as na;
use super::img::Image;
use super::objects::traits::*;
use super::structs::*;
// Gate is a small web app for quick text entry along with forwarding entered
// text to other endpoints (which I use heavily in my personal workflow). I've
// only done a little coding in Go so far, so I'm sure this code is probably
// not as idiomatic as I'd like. (I'd also ordinarily split this up into
// multiple files. And do several things differently. Hindsight!)
package main
import (
"crypto/md5"