Skip to content

Instantly share code, notes, and snippets.

Avatar

Casey Ransom cransom

View GitHub Profile
View buildthis
#!/usr/bin/env bash
file=$1
shift
nix-build -E "with import <nixpkgs> { }; callPackage ./$file {}" $*
View mosquitto.nix
{
services.mosquitto = {
host = "198.18.1.1";
enable = true;
ssl = {
certfile = "/var/lib/acme/homeassistant.my.domain/fullchain.pem";
cafile = "/var/lib/acme/homeassistant.my.domain/fullchain.pem";
keyfile = "/var/lib/acme/homeassistant.my.domain/key.pem";
};
users = {
View gist:3fe0f550adadb07736806e2b9f0ec338
system: "x86_64-darwin", multi-user?: no, version: nix-env (Nix) 2.2.2, channels(cransom): "darwin, nixpkgs-19.09.809.5000b1478a1", nixpkgs: /Users/cransom/.nix-defexpr/channels/nixpkgs
these derivations will be built:
/nix/store/55062cq3agq3z896p3nzjj0xxcdfpy96-password-store-1.7.3.drv
building '/nix/store/55062cq3agq3z896p3nzjj0xxcdfpy96-password-store-1.7.3.drv'...
unpacking sources
unpacking source archive /nix/store/36dqisv8vdb1dryplh4zxsqif9bsqhl2-password-store-1.7.3.tar.xz
source root is password-store-1.7.3
setting SOURCE_DATE_EPOCH to timestamp 1533267168 of file password-store-1.7.3/tests/t0500-find.sh
patching sources
applying patch /nix/store/k4mklq09ga6jqqjh8ivzcbna42yjwq7k-set-correct-program-name-for-sleep.patch
View catalina.sh
#!/usr/bin/env bash
set -e -o pipefail
if [ "${1:-}" = "-h" ]; then
echo "This prepares a system for macOS Catalina. It takes no options."
exit 1
fi
if [ $(id -u) -ne 0 ]; then
View gist:27ceb144af415b6a8708bf87739a57bd
1ogre:~% p=$(nix-build -E '(import <nixpkgs> {}).writeScriptBin "temprootmagic" "sleep 5"' --no-out-link)
these derivations will be built:
/nix/store/yyqa3qpyzlix54sl04l7w5cxl4brn0jy-temprootmagic.drv
building '/nix/store/yyqa3qpyzlix54sl04l7w5cxl4brn0jy-temprootmagic.drv'...
0ogre:~% $p/bin/temprootmagic & nix-store --delete $p; sleep 6; nix-store --delete $p
[1] 28423
finding garbage collector roots...
removing stale link from '/nix/var/nix/gcroots/auto/aq6gwzvblglasi3znn83pf4mj39fmhr3' to '/tmp/nix-build-26603-0/result'
0 store paths deleted, 0.00 MiB freed
@cransom
cransom / garage.md
Created Sep 27, 2019
If i were to IOT a garage door now...
View garage.md

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 = ''
dhcp-range=::1,::ffff,constructor:eno1.20,ra-names,48h
#and other stuff
'';
};
View downloader
#!/usr/local/bin/bash
if [ -n "$1" ]; then
file=$1
else
file="source"
fi
fetchargs=""
linenumber=0
View irda
#!/bin/sh
killall ircomm >/dev/null
ircomm -d /dev/cuaa1 -y /dev/ptypv -v2
You can’t perform that action at this time.