Skip to content

Instantly share code, notes, and snippets.

View jmb's full-sized avatar
🙃
Procrastinating

Jonathan Batchelor jmb

🙃
Procrastinating
View GitHub Profile
@jmb
jmb / gist:89b7ac0a5c96735f505ba2868ccb3fd9
Created October 3, 2024 13:18
Current Cost Serial to EmonCMS data logger
import serial
import re
import requests
import json
port = "/dev/ttyUSB0"
baudrate = 2400
emon_api_key = "..."
emon_api_url = "http://localhost/input/post"
@jmb
jmb / getChapters.py
Created May 4, 2024 09:17
A Python script to obtain chapter titles and timestamps from a media file (uses ffprobe)
import json, argparse, subprocess
parser = argparse.ArgumentParser()
parser.add_argument('file')
args = parser.parse_args()
output = subprocess.run(["ffprobe", "-print_format", "json", "-show_chapters", "-sexagesimal", args.file], capture_output=True)
print(output)
data = json.loads(output.stdout)
@jmb
jmb / email_addresses.py
Created July 14, 2018 21:58
Script to extract all email addresses from all emails in all folders of an IMAP account.
"""Create a connection to an IMAP server and find ALL email addresses
Original script by abought: https://gist.github.com/abought/15a1e08705b121c1b7bd
References:
http://www.voidynullness.net/blog/2013/07/25/gmail-email-with-python-via-imap/
and
https://yuji.wordpress.com/2011/06/22/python-imaplib-imap-example-with-gmail/
"""
__author__ = 'jmb'
import email
@jmb
jmb / rainbow_all.py
Created September 25, 2016 09:06
A quick and simple demo of the APA102_Pi library which fades the entire LED strip from green through to red then blue and back to green.
#!/usr/bin/python3
import apa102
import signal
from time import sleep
numLEDs = 60
globalBrightness = 5
stepDelay = 0.1
@jmb
jmb / README.md
Last active January 27, 2019 22:25
MQTT Data Subscriber for Dashing

Description

Dashing job to subscribe to MQTT messages.

MQTT is a lightweight publish/subscribe messaging transport. This job allows Dashing to subscribe to these messages and send them as events. There is no associated widget as the data can take any form - commonly numbers, but not necessarily. The script as laid out below sends events with value, current (the same contents) and last values so can be plugged directly into the Numbers or Meter widgets using the data-id in the dashboard file. The send_event could easily be modified if required.

Set up

Add to Gemfile:

@jmb
jmb / README.md
Last active December 8, 2022 08:41
Google Calendar API v3 widget for Dashing

Description

Dashing widget to display the next and some subsequent Google Calendar events using the Google Calendar API v3.

I use this widget to display my shift calendar - see the screenshot below

Set up

This widget works with API v3 and requires a service account to be set up via the Google Developer's Console. Once a project is set up, enable the Calendar API. On the Credentials page create a new OpenID and download the p12 key file - set up the path to this file in the job file and grant the email address access to the relevant calendar.