Skip to content

Instantly share code, notes, and snippets.

View YourFriendCaspian's full-sized avatar
🙃
I'm sure I'll be slow to respond so don't be mad.

yourfriendcaspian YourFriendCaspian

🙃
I'm sure I'll be slow to respond so don't be mad.
View GitHub Profile
@YourFriendCaspian
YourFriendCaspian / replacepi.sh
Created January 31, 2019 05:34
This script will replace the user pi.
#!/bin/sh
## This script will replace the user pi.
## Dependencies Check
sudo bash /etc/piadvanced/dependencies/dep-whiptail.sh
## Simple test if Whiptail is installed.
{ if
which whiptail >/dev/null;
then

Setup USB drive

First find the disk using

sudo fdisk -l

Its probably named /sda1 or similar. Then make ext4 using

sudo mkfs.ext4 /dev/sda1

This closely follows this but also includes the Pi dependencies:

sudo apt-get install swig oss-compat pulseaudio libpulse-dev automake autoconf libtool bison python-dev

Can't use 8-bit...

My benchmarks

homeassistant:
# Name of the location where Home Assistant is running
name: Home
# Location required to calculate the time the sun rises and sets
latitude: 36.0755
longitude: -79.0741
# C for Celsius, F for Fahrenheit
temperature_unit: F
# Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
time_zone: America/New_York
#!/usr/bin/env bash
#
# Caddy Installer Script
#
# Homepage: https://caddyserver.com
# Issues: https://github.com/caddyserver/caddyserver.com/issues
# Requires: curl or wget, tar or unzip
#
# Hello! This is an experimental script that installs Caddy
# into your PATH (which may require password authorization).
import paho.mqtt.client as mqtt
# The callback for when the client receives a CONNACK response from the server.
def on_connect(client, userdata, flags, rc):
print("Connected with result code "+str(rc))
# Subscribing in on_connect() means that if we lose the connection and
# reconnect then subscriptions will be renewed.
client.subscribe("YOURGROUPNAME/location/#")
@YourFriendCaspian
YourFriendCaspian / automation.yaml
Created November 13, 2018 04:46 — forked from LarsBergqvist/automation.yaml
Home Assistant automation based on presence detection
automation:
- alias: Turn on window lights when Lars gets home
trigger:
platform: zone
entity_id: device_tracker.my_iphone
zone: zone.home
event: enter
action:
service: switch.turn_on
entity_id: group.window_lights
@YourFriendCaspian
YourFriendCaspian / stt.py
Created November 13, 2018 04:40 — forked from srli/stt.py
#!/usr/bin/env python
from pocketsphinx.pocketsphinx import *
from sphinxbase.sphinxbase import *
import os
import pyaudio
import wave
import audioop
from collections import deque
@YourFriendCaspian
YourFriendCaspian / GarageClient.ino
Created September 6, 2018 19:56 — forked from LarsBergqvist/GarageClient.ino
MQTT publish of data from two DHT22 sensors
//
// This is an example on MQTT publish from an ESP8266 board
// to an MQTT broker (I have used a local Mosquitto running on a Raspberry Pi)
// This example uses the PubSub client library (https://github.com/knolleary/pubsubclient)
// Install it in the Arduino IDE before compiling the sketch
// Sensor values are fetched from an indoor DHT22 sensor and an outdoor DHT22 sensor
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
@YourFriendCaspian
YourFriendCaspian / GroundFloorClient.ino
Created September 6, 2018 19:53 — forked from LarsBergqvist/GroundFloorClient.ino
Arduino loop of ESP8266 board that measure temperature, humidity and soilmoisture
void loop()
{
if ( firstTime || (millis() - lastTime > SECONDS_BETWEEN_MEASUREMENTS*1000) )
{
firstTime = false;
lastTime = millis();
if (!mqttClient.connected())
{
connectToWiFiAndBroker();