Skip to content

Instantly share code, notes, and snippets.


Casey Ransom cransom

View GitHub Profile
View krainthx
#!/usr/bin/perl -w
# $Id: krainthx,v 1.7 2003/04/14 20:00:33 spy Exp $
# ben
#initialize color map and set counters
@colormap = (4,4, 7,7, 5,5, 8,8, 9,9, 3,3, 10,10, 11,11, 12,12, 2,2, 6,6, 13,13);
my $row = 0;
my $rainstate = 0;
my $badstate = 0;
# setup tmp filE
cransom /
Created Sep 27, 2019
If i were to IOT a garage door now...

My implementation 4 (or more?) years ago was:

  • wemos d1 mini module
  • hc-sr04 ultrasonic distance sensor
  • photo resistor (measure light level from the automatic light or ambient if open)
  • wemos 1ch relay. could have used a transistor, but i am iffy on what kind of voltage the garage button is using. electrical isolation is nice. my button does have couple modes like turning a light on as well if you let some amount of voltage through, but i didn't go there
  • hacked up arduino code using mqtt and some very fiddly json parsing that's frafile if you glance at it weird. the software didn't exist when i hacked mine how i wanted it.
  • homeassistant doing all the home automation things. It hooked into Homeassistant via MQTT sending messages back and forth. The distance sensor could only really tell if you the door is nearly all the way open due to how it was mounted. Knowing closed would be nicer but i would have had to mount it farther away and it's been fine so far.

I 3d printed a case/mount for it to dangle a

View gist:6cf1076e15ab2ac42dd6feac596b945c
[76/440] Linking target src/libpulsecommon-12.99.dylib.
FAILED: src/libpulsecommon-12.99.dylib
/nix/store/hi40vi42w2rnf9pflyhmsalcj5jf2bsv-clang-wrapper-7.1.0/bin/cc -o src/libpulsecommon-12.99.dylib 'src/25a6634@@pulsecommon-12.99@sha/pulse_client-conf.c.o' 'src/25a6634@@pulsecommon-12.99@sha/pulse_fork-detect.c.o' 'src/25a6634@@pulsecommon-12.99@sha/pulse_format.c.o' 'src/25a6634@@pulsecommon-12.99@sha/pulse_json.c.o' 'src/25a6634@@pulsecommon-12.99@sha/pulse_xmalloc.c.o' 'src/25a6634@@pulsecommon-12.99@sha/pulse_proplist.c.o' 'src/25a6634@@pulsecommon-12.99@sha/pulse_utf8.c.o' 'src/25a6634@@pulsecommon-12.99@sha/pulse_channelmap.c.o' 'src/25a6634@@pulsecommon-12.99@sha/pulse_sample.c.o' 'src/25a6634@@pulsecommon-12.99@sha/pulse_util.c.o' 'src/25a6634@@pulsecommon-12.99@sha/pulse_timeval.c.o' 'src/25a6634@@pulsecommon-12.99@sha/pulse_rtclock.c.o' 'src/25a6634@@pulsecommon-12.99@sha/pulse_volume.c.o' 'src/25a6634@@pulsecommon-12.99@sha/pulsecore_authkey.c.o' 'src/25a6634@@pulsecommon-12.99@sha/pulsecore_con
View configuration.nix
#eno1.10 is outside, eno1.20 is inside.
services.dnsmasq = {
enable = true;
resolveLocalQueries = true;
extraConfig = ''
#and other stuff
View downloader
if [ -n "$1" ]; then
View irda
killall ircomm >/dev/null
ircomm -d /dev/cuaa1 -y /dev/ptypv -v2
View sample-timer.nix = {
after = [
path = [ pkgs.rsync ];
#this notifies another unit in case it fails, i get a text to my phone.
onFailure = [
script = ''
View gist:2c06e7e81cefb0b8f143461dbe031234
#10 is wan interface, 20 is lan, 25 is my bench/thing i want to keep away from internal.
#let established flows from bench to lan work
iptables -A FORWARD -i eno1.25 -o eno1.20 -m state --state ESTABLISHED,RELATED -j ACCEPT
#let bench to internet work
iptables -A FORWARD -i eno1.25 -o eno1.10 -j ACCEPT
#let established flows from internet to bench go
iptables -A FORWARD -i eno1.10 -o eno1.25 -m state --state ESTABLISHED,RELATED -j ACCEPT
#drop everything else.
View hnix-failure.txt
[nix-shell:~]$ echo "(import ./default.nix).bar" | hnix -
import ./
View gist:6b039216a85f3e231c98fda36b100b28
nix-repl> builtins.fetchGit { url = ""; ref = "master"; }
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: program 'git' failed with exit code 1