Skip to content

Instantly share code, notes, and snippets.

View scttnlsn's full-sized avatar

Scott Nelson scttnlsn

View GitHub Profile
@scttnlsn
scttnlsn / mqtt_relay.py
Created January 18, 2018 16:12
ESP8266 + MQTT relay
import machine
import network
import ubinascii
from umqtt.simple import MQTTClient
SSID = ''
PASSWORD = ''
BROKER = ''
TOPIC = ''
@scttnlsn
scttnlsn / README.md
Created March 10, 2018 21:00
Enable USB mass storage on Raspberry Pi Zero

Create new filesystem:

sudo dd if=/dev/zero of=/usb.bin bs=512 count=51200
sudo mkdosfs /usb.bin
  • Add dwc2 to /etc/modules-load.d/modules.conf
  • Add dtoverlay=dwc2 to /boot/config.txt
  • reboot
@scttnlsn
scttnlsn / gateway.py
Last active April 16, 2020 21:49
Raspberry Pi RFM69 to MQTT gateway
# pip install spidev RPI.GPIO
# git clone https://github.com/etrombly/RFM69.git
#
# 19 MOSI
# 21 MISO
# 23 SCK
# 22 DI00
# 24 NSS
import time
@scttnlsn
scttnlsn / migrations.sql
Created April 4, 2019 20:12
Pure SQL migrations
--------------------------------------------------
--- SETUP
--------------------------------------------------
\set ON_ERROR_STOP true
CREATE TABLE IF NOT EXISTS migrations (
name CHAR VARYING PRIMARY KEY,
timestamp TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT now()
);
### Keybase proof
I hereby claim:
* I am scttnlsn on github.
* I am scttnlsn (https://keybase.io/scttnlsn) on keybase.
* I have a public key ASB9vyD2EVSPOPFZSG40S9RvkY9urio90LlnLsBacf9Z5go
To claim this, I am signing this object:
@scttnlsn
scttnlsn / chat.rs
Created November 15, 2019 20:26
Rust chat server
use std::collections::hash_map::{Entry, HashMap};
use std::io::{self, BufRead, BufReader, Write};
use std::net::{TcpListener, TcpStream, ToSocketAddrs};
use std::sync::{
Arc,
mpsc::{self, Sender, Receiver},
};
use std::thread::{self};
#[derive(Debug)]