This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! To use this gist: | |
//! | |
//! ```shell | |
//! cargo new remove-nulls | |
//! cd remove-nulls | |
//! cargo add serde serde_json | |
//! ``` | |
//! | |
//! Then paste the contents of this file into src/main.rs. | |
//! Run `cargo build --release` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# Blog post here: | |
# https://aeshirey.github.io/code/2022/07/08/smt-for-scheduling-scouts-in-tents.html | |
# Run this as: | |
# ./scout-camp-gen.py > scout-camp.smt2 | |
# Then check satisfiability with: | |
# z3 scout-camp.smt2 > solved.txt | |
# This will output something like: | |
# ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Algorithm from http://cosinekitty.com/compass.html | |
// 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, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// `probably` crate @ https://github.com/aeshirey/probably/ | |
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fsspec | |
filename = 'adl://path/to/file.csv' | |
adl_auth = { | |
'tenant_id': "<tenant_id>", | |
'client_id': "<client_id>", | |
'client_secret': "PGNsaWVudF9zZWNyZXQ+" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <DHTesp.h> | |
#include "Adafruit_MQTT.h" | |
#include "Adafruit_MQTT_Client.h" | |
#include <ESP8266WiFi.h> | |
#define LOOP_MS 60000 | |
#define DhtPin 14 | |
DHTesp dht; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# maximum allowable delta (°F) before we start the fans | |
TEMP_DELTA = 5.0 | |
def check_temp(): | |
global VENTILATION_STATE | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- id: '1234' | |
alias: ventilate_on | |
trigger: | |
- payload: 'on' | |
platform: mqtt | |
topic: ventilate | |
condition: [] | |
action: | |
- data: | |
entity_id: switch.wind_tunnel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import paho.mqtt.client as mqtt | |
import json | |
import requests | |
BROKER = '192.168.0.1' | |
TOPIC = "weather/renton" | |
URL = "http://api.openweathermap.org/data/2.5/weather?id=5808189&APPID=<your api key goes here>" | |
API_DELAY_SEC = 60 * 10 # every 10 minutes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Code accompanying my blog post on my kegerator setup, found here: | |
// http://www.dingostick.com/2018/12/kegerator-v10.html | |
// 1. https://www.pjrc.com/teensy/td_libs_OneWire.html | |
#include <OneWire.h> | |
// 2. https://github.com/milesburton/Arduino-Temperature-Control-Library | |
#include <DallasTemperature.h> | |
#define LOGGING |
NewerOlder