Skip to content

Instantly share code, notes, and snippets.


Adam Shirey aeshirey

View GitHub Profile
aeshirey /
Last active Dec 19, 2020
Azimuth/Distance calculator
// Algorithm from
// Code ported to Rust by @aeshirey
use core::f64::consts::PI;
#[derive(Debug, Copy, Clone)]
pub struct Location {
latitude: f64,
longitude: f64,
elevation_meters: f64,
aeshirey /
Last active Dec 3, 2020
Parallelized quantile estimation with Greenwald-Khanna
// `probably` crate @
// Use it by specifying probably = "0.2.0" in your Cargo.toml
use probably::quantile::greenwald_khanna;
use std::fs::File;
use std::io::{BufRead, BufReader};
fn main() {
const EPSILON: f64 = 0.001;
const QUANTILE: f64 = 0.5; // median
aeshirey / Read ADL
Created Mar 9, 2020
Code to read an adl:// file in Python
View Read ADL
import fsspec
filename = 'adl://path/to/file.csv'
adl_auth = {
'tenant_id': "<tenant_id>",
'client_id': "<client_id>",
'client_secret': "PGNsaWVudF9zZWNyZXQ+"
# maximum allowable delta (°F) before we start the fans
def check_temp():
c = db.cursor()
# get the last ten minutes of data only
c.execute("SELECT temp, room FROM temps WHERE (julianday('now') - julianday(timestamp))*86400 < 600 ORDER BY timestamp")
inside_temps, outside = [], 0.0
View ventilation.yaml
- id: '1234'
alias: ventilate_on
- payload: 'on'
platform: mqtt
topic: ventilate
condition: []
- data:
entity_id: switch.wind_tunnel
#!/usr/bin/env python
import paho.mqtt.client as mqtt
import json
import requests
TOPIC = "weather/renton"
URL = "<your api key goes here>"
API_DELAY_SEC = 60 * 10 # every 10 minutes
View ESP8266_DHT11.c
#include <DHTesp.h>
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"
#include <ESP8266WiFi.h>
#define LOOP_MS 60000
#define DhtPin 14
DHTesp dht;
View kegerator.c.ino
// Code accompanying my blog post on my kegerator setup, found here:
// 1.
#include <OneWire.h>
// 2.
#include <DallasTemperature.h>
#define LOGGING
View Keybase proof
### Keybase proof
I hereby claim:
* I am aeshirey on github.
* I am adamshirey ( on keybase.
* I have a public key ASBGD1ACCiGZ0YRRZCuMxEAZncMYrJI5_Ima7UdJqXYRogo
To claim this, I am signing this object:
aeshirey / venn.min.js
Created Sep 13, 2018
A minified, publicly available version of
View venn.min.js
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("d3-selection"),require("d3-transition")):"function"==typeof define&&define.amd?define(["exports","d3-selection","d3-transition"],r):r(t.venn={},t.d3,t.d3)}(this,function(t,C,r){"use strict";var w=1e-10;function x(r,t){var n,e=function(t){for(var r=[],n=0;n<t.length;++n)for(var e=n+1;e<t.length;++e)for(var a=k(t[n],t[e]),i=0;i<a.length;++i){var s=a[i];s.parentIndex=[n,e],r.push(s)}return r}(r),a=e.filter(function(t){return function(t,r){for(var n=0;n<r.length;++n)if(R(t,r[n])>r[n].radius+w)return!1;return!0}(t,r)}),i=0,s=0,u=[];if(1<a.length){var o=P(a);for(n=0;n<a.length;++n){var f=a[n];f.angle=Math.atan2(f.x-o.x,f.y-o.y)}a.sort(function(t,r){return r.angle-t.angle});var l=a[a.length-1];for(n=0;n<a.length;++n){var h=a[n];s+=(l.x+h.x)*(h.y-l.y);for(var x={x:(h.x+l.x)/2,y:(h.y+l.y)/2},c=null,g=0;g<h.parentIndex.length;++g)if(-1<l.parentIndex.indexOf(h.parentIndex[g])){var v=r[h.parentIndex[g]],p=Math.atan2(h.x-v.x,h.y-v.y),d=