Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
import random
import string
UNAMBIGUOUS_LETTERS = list(set(string.ascii_lowercase) - set('ilou'))
def randid():
"""Creates a random ID space with three modified
base32 characters and one number in random order for
#!/usr/bin/python
import random
import string
UNAMBIGUOUS_LETTERS = list(set(string.ascii_lowercase) - set('ilou'))
def randid_worker(params):
"""PARAMS is a collection of (SET, COUNT) pairs. The function returns
a collection of COUNT_0 + COUNT_1 + ... COUNT_n items, drawn from the
@asciiphil
asciiphil / README.md
Created December 14, 2015 02:25
OpenHAB Alarm Definition

This defines a rule that allows for a "sunrise" style alarm. Basically, you trigger it by setting the Alarm_Trigger item to a value that defines parameters for the alarm:

  • duration gives the length of the alarm in minutes
  • light gives the minimum and maximum brightness values over the course of the alarm, e.g. light=0,75.
  • temp gives the range of color temperatures over the course of the alarm, e.g. temp=2700,5000

Add dimmers to the Alarm_Dimmers group. Add Number items for color temperature to the Alarm_Temps group. Any switches in the Alarm_Switches group will be turned on at the end of the alarm.

The Alarm_Running item serves as a UI element to halt a running alarm. Just turn it OFF while the alarm is running,

@asciiphil
asciiphil / tirex-queue
Last active December 19, 2015 20:09
Script for rerendering all of my tirex tiles.
#!/bin/sh
# Extent of the rendering database; tiles outside this are pointless.
latlon="lon=-125.0841,-66.9251 lat=24.2520,49.3845"
for map in cutouts; do
# rerender everything that's expired.
for z in `seq 2 16`; do
prio=$(calc 70 - $z)
tirex-batch -f 'exists;older(/var/lib/tirex/tiles/planet-import-complete)' -p $prio $latlon map=$map z=$z
@asciiphil
asciiphil / primes.lisp
Last active December 5, 2016 01:16
Common Lisp prime testing
;;;; Needs the iterate package.
(defmacro maybep (&body body)
"Give this a series of forms. It will return the result of the first one that
yields T or NIL. Any other result will cause the next form to be evaluated.
Short-circuits like IF or COND."
(labels ((maybep-expand (forms)
(if (endp forms)
`(error "All evaluated forms yielded MAYBE.")
`(let ((result ,(car forms)))
@asciiphil
asciiphil / well-heads.geojson
Last active May 22, 2017 18:27 — forked from anonymous/overpass.geojson
Well Heads for the Accident Natural Gas Storage Facility
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@asciiphil
asciiphil / tiber_river.geojson
Last active May 29, 2018 14:28
Watershed of the Tiber River
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@asciiphil
asciiphil / weekday_alarm.toml
Created April 11, 2019 18:47
The morning alarm script I use with `oh-set-gradually`.
#### Normal use: start at 6:00 am
[rest]
host = "openhab.example.com"
port = 8080
[monitor]
item = "morning_alarm_running"
initialize = "ON"
stop_on = "OFF"

Keybase proof

I hereby claim:

  • I am asciiphil on github.
  • I am asciiphil (https://keybase.io/asciiphil) on keybase.
  • I have a public key ASCW6U3gAIhc5erYQtWALvg9PRU-kI7YIScI7CzJ4qwPpwo

To claim this, I am signing this object:

@asciiphil
asciiphil / 01 Raw Input
Last active December 23, 2019 02:32
Advent of Code 2019 Day 2 Intcode disassembly and analysis
"1,0,0,3,1,1,2,3,1,3,4,3,1,5,0,3,2,1,6,19,1,19,5,23,2,13,23,27,1,10,27,31,2,6,31,35,1,9,35,39,2,10,39,43,1,43,9,47,1,47,9,51,2,10,51,55,1,55,9,59,1,59,5,63,1,63,6,67,2,6,67,71,2,10,71,75,1,75,5,79,1,9,79,83,2,83,10,87,1,87,6,91,1,13,91,95,2,10,95,99,1,99,6,103,2,13,103,107,1,107,2,111,1,111,9,0,99,2,14,0,0"