Skip to content

Instantly share code, notes, and snippets.

@bencrowder
bencrowder / genline.py
Last active Sep 5, 2016
Line generation
View genline.py
#!/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
View Inklang example 1
rule
size 6x9";
# alternates
size letter;
size 210x297mm;
size a4;
font Arno Pro, 10/13pt;
margin 1";
View helm.js
// Bot: Helm
// Ruleset: default
// --------------------------------------------------
var Helm = function() {};
Helm.prototype = new Bot();
Helm.prototype.setup = function() {
this.timer = 0;
@bencrowder
bencrowder / data.yaml
Last active Aug 29, 2015
Home teaching slips
View data.yaml
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"
@bencrowder
bencrowder / watersun.pv
Created Sep 6, 2014
PlotDevice watersun demo
View watersun.pv
# 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 / genealogysparkline.pv
Last active Aug 29, 2015
PlotDevice genealogy sparkline
View genealogysparkline.pv
# 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 / gc_references.py
Last active Jan 27, 2019
Small Python script to scrape LDS General Conference transcripts and output HTML page listing scripture references. Example: http://bencrowder.net/files/gc-references/2013-04
View gc_references.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
import re
import codecs
import requests
import bs4
# Change these
year = 2013
View rss-subscribers.sh
#!/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 ---
@bencrowder
bencrowder / splitimage.sh
Last active Jan 27, 2019
Shell script to split two-spread image into two different images. Uses ImageMagick.
View splitimage.sh
#!/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
@bencrowder
bencrowder / dub.sh
Last active Dec 14, 2015
Batch file renaming for zsh.
View dub.sh
#!/bin/zsh
# Batch rename
# Usage: dub image-X.jpg *.jpg
#
# - First argument is template for renaming
# - The "X" in the template will be replaced with zero-padded numbers
# (e.g., image-001.jpg, image-002.jpg, etc.)
#
# More examples:
You can’t perform that action at this time.