Skip to content

Instantly share code, notes, and snippets.

@asciiphil
asciiphil / tirex-queue
Last active Dec 19, 2015
Script for rerendering all of my tirex tiles.
View tirex-queue
#!/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 / MPL115A2.py
Last active Apr 10, 2021
Python class for communicating with a MPL115A2 I2C digital barometer/temperature sensor. Uses the Adafruit_I2C class from the Adafruit Raspberry Pi Python Code: https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code .
View MPL115A2.py
#!/usr/bin/python
# Author: Phil! Gold <phil_g@pobox.com>
# License: CC0 Waiver http://creativecommons.org/publicdomain/zero/1.0/
import time
from Adafruit_I2C import Adafruit_I2C
class _MPL115A2_Register:
View randspace.py
#!/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
View randspace.py
#!/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 Dec 14, 2015
OpenHAB Alarm Definition
View README.md

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 / primes.lisp
Last active Dec 5, 2016
Common Lisp prime testing
View primes.lisp
;;;; 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 — forked from anonymous/overpass.geojson
Well Heads for the Accident Natural Gas Storage Facility
View well-heads.geojson
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
Watershed of the Tiber River
View tiber_river.geojson
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 Apr 11, 2019
The morning alarm script I use with `oh-set-gradually`.
View weekday_alarm.toml
#### Normal use: start at 6:00 am
[rest]
host = "openhab.example.com"
port = 8080
[monitor]
item = "morning_alarm_running"
initialize = "ON"
stop_on = "OFF"
View keybase.md

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: