Skip to content

Instantly share code, notes, and snippets.

View sbliven's full-sized avatar
💻
Typing...

Spencer Bliven sbliven

💻
Typing...
View GitHub Profile
@sbliven
sbliven / 99_telegram
Created November 7, 2017 17:33
Raspberry Pi setup to send IP changes via telegram
# /lib/dhcpcd/dhcpcd-hooks/99-telegram
#
# Notify telegram chat of ip changes
# man dhcpcd-run-hooks for variables
TELEGRAM=/home/pi/bin/telegram
if $if_up; then
case "$reason" in
BOUND|BOUND6)
@sbliven
sbliven / show_ip.py
Created December 5, 2017 17:42
Script to show current IP address on SenseHat
from sense_hat import SenseHat
import socket
def get_ip():
# overridden by /etc/hosts, so doesn't work for us
#hosts_ips = [ip for ip in socket.gethostbyname_ex(socket.gethostname())[2] if not ip.startswith("127.")][:1]
# try to connect to google
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(('8.8.8.8', 53))
@sbliven
sbliven / nab2ynab.R
Created December 11, 2017 20:51
Convert bank transaction data from Neue Aargauer Bank CSV files to the format expected by youneedabudget.com
#!/usr/bin/env Rscript
library(readr)
library(dplyr)
library(magrittr)
args = commandArgs(trailingOnly=TRUE)
if (length(args) != 2) {
stop("usage: nab2ynab.R nab.csv ynab.csv", call.=FALSE)
}
@sbliven
sbliven / Lunar Lander.ipynb
Last active January 11, 2022 09:00
Calculations for DanQ's Lunar Lander game (https://danq.me/2018/03/03/lunar-lander/)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sbliven
sbliven / LICENSE.md
Created March 28, 2018 18:36
ODC Public Domain Dedication and Licence (PDDL)

ODC Public Domain Dedication and Licence (PDDL)

A lay explaination of this license is available at https://opendatacommons.org/licenses/pddl/summary/. The full legal text is also available online at https://opendatacommons.org/licenses/pddl/1.0/.

Preamble

The Open Data Commons – Public Domain Dedication & Licence is a document intended to allow you to freely share, modify, and use this work for any purpose and without any restrictions. This licence is intended for use on databases or their contents (“data”), either together or individually.

Many databases are covered by copyright. Some jurisdictions, mainly in Europe, have specific special rights that cover databases called the “sui generis” database right. Both of these sets of rights, as well as other legal rights used to protect databases and data, can create uncertainty or practical difficulty for those wishing to share databases and their underlying data but retain a limited amount of rights under a “some rights reserved” approach to licensing as

@sbliven
sbliven / Sync Calendars.scpt
Created December 17, 2018 11:14
Copies events between calendars in Apple Calendar.app
-- Syncronize several calendars
--
-- The calendars to be synced must be set by UID in the 'targetCalendarIDs' variable.
-- UIDs can be read using the 'Get Calendar' script.
--
-- When run, copies each selected event to other calendars in the target list.
--
-- Author: Spencer Bliven (spencer.bliven@gmail.com)
--
-- Event selection code from http://www.johneday.com/1086/reference-selected-calendar-events-applescript
@sbliven
sbliven / test10.sh
Created February 6, 2019 10:31
Generate evenly-spaced heic file for testing Mac dynamic wallpapers
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
JSONFILE="${1:-wallpapper.json}"
HEICFILE="${2:-wallpapper.heic}"
blocks=()
for ((a=-90;a<=90;a+=10)); do
for ((z=0; z<360; z+=10)); do
@sbliven
sbliven / google-authenticator.rb
Last active March 16, 2024 09:31 — forked from Dan-Q/google-authenticator.rb
Command-line Google Authenticator (TOTP)
#!/usr/bin/env ruby
# frozen_string_literal: true
# encoding: utf-8
#
# TOTP implementation (google authenticator)
#
# Reads ~/.google-authenticator-accounts for account info.
# For security, you should run `chmod 600 ~/.google-authenticator-accounts
#
# Changelog:
@sbliven
sbliven / linelength.py
Created August 30, 2019 13:50
Create histograms of line lengths. Used for https://github.com/biopython/biopython/issues/2008
"""Create distribution of line lengths over files
Example:
find . -regextype egrep -regex './(Bio|Tests)/.*\.py' -type f -exec \
python linelength.py --hist linelengths.png \
--cdf linelengthscumulative.png -v '{}' '+'
"""
import sys
@sbliven
sbliven / circular_types.py
Last active September 11, 2019 06:40
Test a difficult typing case. Python type annotations!
"""Test a difficult typing case.
Inspired by biopython's Bio.PDB.Entity.
https://gist.github.com/sbliven/8fb593f005eeafc0fecef71063f5dc39
"""
import sys
from typing import TypeVar, Union