Skip to content

Instantly share code, notes, and snippets.

View RobCranfill's full-sized avatar

Rob Cranfill RobCranfill

View GitHub Profile
# cranfill - udev rules for mapping X10 CM11 device to /dev/cm11, and Vantage data logger to /dev/vantageVue
# Lives in /etc/udev/rules.d
#
# serial to /dev/cm11a
ACTION=="add",SUBSYSTEM=="tty",ATTRS{idVendor}=="067b",ATTRS{product}=="USB-Serial Controller D",SYMLINK+="cm11a",MODE="0777"
# UART to /dev/vantageVue
# ACTION=="add",ATTRS{idVendor}=="10c4",ATTRS{product}=="CP2102 USB to UART Bridge Controller",MODE="0666",SYMLINK+="/sys/dev/vantageVue"
ACTION=="add",ATTRS{product}=="CP2102 USB to UART Bridge Controller",MODE="0666",SYMLINK+="vantageVue"
#!/bin/bash
# livestream the livingroom cam?
raspivid -o - -t 0 -fps 30 -b 6000000 | \
avconv -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h264 -i - \
-vcodec copy -acodec aac -ab 128k -g 50 -strict experimental \
-f flv rtmp://a.rtmp.youtube.com/live2/YOUTUBE-THINGY-HERE
@RobCranfill
RobCranfill / ftpupload.py
Created July 11, 2020 16:01
My weewx mods for sftp and for reducing the frequency of uploads.
#
# Copyright (c) 2009-2020 Tom Keffer <[email protected]>
#
# See the file LICENSE.txt for your full rights.
#
# ** Hacked on by cranfill for sftp, July 2020 - based on weewx v. 4.1.1
#
"""For uploading files to a remove server via FTP or sftp"""
from __future__ import absolute_import
@RobCranfill
RobCranfill / fix-boot-ssd.sh
Created December 16, 2020 19:30
Update RPi boot SSD after kernel update
#!/bin/bash
# (This isn't really a shell script - you can't run 'sudo' in a script, I don't think.)
#
# Boot/kernel problems 19/Oct/2020
# (On pi3, which boots from SD card, but then mounts the SSD to /boot,
# resulting in the wrong partition gettting updated.)
#
# SOLUTION:
# https://www.raspberrypi.org/forums/viewtopic.php?t=262963
@RobCranfill
RobCranfill / showTime.html
Created December 27, 2020 01:34
Simple HTML page showing use of setInterval and mucking with the DOM.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="30">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<link href='https://fonts.googleapis.com/css?family=Stylish' rel='stylesheet'>
#!/bin/bash
# check the weather station's battery by screen-scraping the WeeWX main page
# and send a status email
WX_URL="http://pi4.local/weather"
MAIL="/home/rob/.local/bin/cransend.sh"
EMAIL_TO="[email protected]"
TEMP_FILE="/tmp/checkWxBatt.html"
#!/bin/bash
# compare the boot files on the RPi's SSD with the files on the SD card
sudo mount -r /dev/mmcblk0p1 /mnt/sdboot 2>/dev/null
# SSD BOOT FILES
FILE1="/boot/bcm2710-rpi-3-b.dtb"
# SD CARD BOOT FILES
FILE2="/mnt/sdboot/bcm2710-rpi-3-b.dtb"
@RobCranfill
RobCranfill / extract.py
Created November 18, 2022 04:08
Extract headers from online email and create a CSV file to import all found email addresses as contacts into GMail.
import imaplib
import email
import csv
import sys
"""
Extract headers from online email and create a CSV file
to import all found email addresses as contacts into GMail.
(c)2022 [email protected]
based on https://qr.ae/pvQWFi
@RobCranfill
RobCranfill / display-8x8.py
Created November 25, 2022 20:42
Display a scrolling message on an Adafruit 8x8 LED matrix. For the Adafruit RP2040 Feather board (or any CircuitPython board?).
# Display a scrolling message on an Adafruit 8x8 LED matrix.
# For the Adafruit RP2040 Feather board (or any CircuitPython board?).
#
import board
from adafruit_ht16k33.matrix import Matrix8x8
import time
import font # This is my data for a simple 8x8 font, found in this directory.
# For the given string, create the big list of bit values (columns), left to right.
# TODO: This might display faster if we didn't pack these bits, but just
// Adapted from https://github.com/ambotaku/pico-getLine
// Trivial code change to allow compiling with plain C on Pico.
//
const uint startLineLength = 8; // the linebuffer will automatically grow for longer lines
const char eof = 255; // EOF in stdio.h -is -1, but getchar returns int 255 to avoid blocking
/*
* read a line of any length from stdio (grows)
*
* @param fullDuplex input will echo on entry (terminal mode) when false
* @param linebreak "\r" may be needed for terminals