Skip to content

Instantly share code, notes, and snippets.

blueprint:
name: Send actionable notifications for Android with Camera Snapshot
description: >
Send actionable notifications to an Android device. Customized from vorion's blueprint.
Changes
- Remove notify_device integration requirement to allow notify groups to be used.
- Removed trigger_entity domain input_boolean requirement. Removed reset of input_boolean from actions. (For use in detecting doorbell rings from sensor)
- Added camera snapshot for doorbell capture (required).
For each action, you can open an URL, an application on the device or load a lovelace view/dashboard.
@jterrace
jterrace / xvfb
Created June 11, 2012 18:46
xvfb init script for Ubuntu
XVFB=/usr/bin/Xvfb
XVFBARGS=":1 -screen 0 1024x768x24 -ac +extension GLX +render -noreset"
PIDFILE=/var/run/xvfb.pid
case "$1" in
start)
echo -n "Starting virtual X frame buffer: Xvfb"
start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS
echo "."
;;
stop)
@jterrace
jterrace / calendar2eink.js
Last active December 10, 2023 20:12
node-red code to pull calendar and push to eink
// Formats the given Date and returns map with format string parts.
const makeTimeFormatMap = function(date) {
const tz = Intl.DateTimeFormat().resolvedOptions().locale;
const dateTimeFormat = new Intl.DateTimeFormat(tz, {
month: 'short',
day: 'numeric',
weekday: 'short',
hour: 'numeric',
minute: 'numeric',
hour12: true,
@jterrace
jterrace / shaper.sh
Created February 23, 2012 21:13
A utility script for traffic shaping with tc
#!/bin/bash
#
# shaper.sh
# ---------
# A utility script for traffic shaping using tc
#
# Usage
# -----
# shape.sh start - starts the shaper
# shape.sh stop - stops the shaper
@jterrace
jterrace / git-annex-gcs.sh
Last active September 8, 2021 22:09
An example of how to use Google Cloud Storage with git-annex
# Initialize git and git-annex
$ mkdir annex-gcs-test
$ cd annex-gcs-test/
$ git init
Initialized empty Git repository in /Users/jterrace/annex-gcs-test/.git/
$ git annex init "my machine"
init my machine ok
(Recording state in git...)
# Set up AWS credentials
@jterrace
jterrace / gist:1823320
Created February 14, 2012 03:42
Automatically log in user after django-registration activation
from registration.signals import user_activated
from django.contrib.auth import login, authenticate
def login_on_activation(sender, user, request, **kwargs):
"""Logs in the user after activation"""
user.backend = 'django.contrib.auth.backends.ModelBackend'
login(request, user)
# Registers the function with the django-registration user_activated signal
user_activated.connect(login_on_activation)
@jterrace
jterrace / distribute_chips.py
Created September 20, 2018 04:10
Programmatically determine how to distribute your chips for Take Your Chances game
import sys
DICE_SIDES = 6
distribution = [0] * DICE_SIDES
for d1 in range(1, DICE_SIDES + 1):
for d2 in range(1, DICE_SIDES + 1):
delta = abs(d1 - d2)
distribution[delta] += 1
distribution = [
@jterrace
jterrace / python IndexedList
Created March 30, 2011 19:34
Class that combines a list and a dict into a single class given a list of properties of the objects in the container
class IndexedList(list):
"""
Class that combines a list and a dict into a single class
- Written by Hugh Bothwell (http://stackoverflow.com/users/33258/hugh-bothwell)
- Original source available at:
http://stackoverflow.com/questions/5332841/python-list-dict-property-best-practice/5334686#5334686
- Modifications by Jeff Terrace
Given an object, obj, that has a property x, this allows you to create an IndexedList like so:
L = IndexedList([], ('x'))
o = obj()
@jterrace
jterrace / disk-vs-internet.py
Created August 30, 2012 18:54
Creates a graph comparing disk read throughput to Internet speeds over time
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import rc
rc('text', usetex=True)
rc('font', family='sans-serif')
rc('font', size='16')
# source: http://download.broadband.gov/plan/fcc-omnibus-broadband-initiative-(obi)-technical-paper-broadband-performance.pdf
@jterrace
jterrace / debug.py
Created July 19, 2012 16:37
Drops python to a debugger on unhandled exceptions
"""Import this module to make python drop to the debugger
when an undhandled exception is raised.
Original script from:
http://code.activestate.com/recipes/65287/
"""
import sys
__old_excepthook__ = sys.excepthook