Skip to content

Instantly share code, notes, and snippets.

View JosephHewitt's full-sized avatar

Joseph Hewitt JosephHewitt

View GitHub Profile
@JosephHewitt
JosephHewitt / jh-uconsole-110.patch
Last active March 28, 2024 15:24
uConsole patch for kernel 5.10.110. This is a modification of https://github.com/clockworkpi/uConsole/tree/master/Code/patch/cm4/20230630 and the patch is based on commit 8e1110a580887f4b82303b9354c25d7e2ff5860e
diff --git a/arch/arm/boot/dts/overlays/Makefile b/arch/arm/boot/dts/overlays/Makefile
index 6fcacdccb608..8e3a0dc87e92 100644
--- a/arch/arm/boot/dts/overlays/Makefile
+++ b/arch/arm/boot/dts/overlays/Makefile
@@ -34,6 +34,12 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
cap1106.dtbo \
chipdip-dac.dtbo \
cma.dtbo \
+ devterm-bt.dtbo \
+ devterm-misc.dtbo \
@JosephHewitt
JosephHewitt / ccparse.py
Created January 21, 2022 16:39
Parse rtl_433 and send CurrentCost power readings to IoTPlotter
import sys
import time
import json
try:
import requests
except:
print("\n\nPlease install Python-requests, this command will work on many systems: 'pip install requests'\n\n")
raise
#Run this script like so: rtl_433 -F json | python3 ccparse.py

Keybase proof

I hereby claim:

  • I am josephhewitt on github.
  • I am jhewitt_net (https://keybase.io/jhewitt_net) on keybase.
  • I have a public key ASDDJXFEDHbW4ea0zVinM_BP0hU27bV6CtJSkRhCeRUBWQo

To claim this, I am signing this object:

@JosephHewitt
JosephHewitt / badexample.py
Created July 3, 2020 13:02
An example of a badly implemented random numerical ID generator based on ord() and os.urandom()
#!/usr/bin/env python3
"""
This code snippet is a deliberate bad implementation of a random numerical ID generator based on ord()
This will generate 150000 random 18-digit IDs and then show the frequency of each digit in the IDs.
You should see more 1s and 2s than other digits.
ord(os.urandom(1)) will return a random number up to 255. If you generate multiple values and concatenate them,
you will get a random code/ID up to the length you want, however, because ord is returning an int which is <255,
you will statistically get more 1s and 2s in your ID.
@JosephHewitt
JosephHewitt / cloudflare_worker.js
Last active November 20, 2021 14:57
Cloudflare Worker JS code to cache Wordpress HTML for logged-out users.
/*I make no guarantees this code will work reliably. Use at your own risk. Please thoroughly test before deploying.
Enabling this on a Cloudflare Worker for a Wordpress site should cache all HTML pages (if your origin headers allow that) but bypass the cache when a user is logged in.
This is tested and working on a Wordpress 5.0.2 installation and the free Cloudflare tier (but I make no guarentees it will work for anyone else).
Sets the `x-cfw-cache` header to indicate the Worker cache status (either HIT, MISS, NO, or BYPASS): `NO` = server has set cookies (won't cache) and `BYPASS` = client has cookies (bypassing cache).
*/
addEventListener('fetch', event => {
event.respondWith(handleRequest(event))