Skip to content

Instantly share code, notes, and snippets.

@bencrowder
bencrowder / dub.sh
Last active February 15, 2022 04:53
Batch file renaming for zsh.
#!/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:
@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
#!/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 / gc_references.py
Last active December 29, 2023 19:48
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
#!/usr/bin/python
# -*- coding: utf-8 -*-
import re
import codecs
import requests
import bs4
# Change these
year = 2013
@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;
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