Skip to content

Instantly share code, notes, and snippets.

View initialed85's full-sized avatar
🤦‍♂️

Edward Beech initialed85

🤦‍♂️
View GitHub Profile
@initialed85
initialed85 / lock_test.py
Last active May 19, 2017 03:24
Demonstration of Python threading.RLock
from threading import RLock, Thread
import copy
import datetime
import random
import time
class SharedObject(object):
def __init__(self):
self._shared_variable = None
@initialed85
initialed85 / acea_voltage_percentage.py
Last active November 28, 2018 10:29
Acea's voltage percentage thing
import re
data = """
Charge voltage 3.3V 3.5V 3.6V 3.7V 3.8V 3.9V 4.0V 4.05V 4.1V 4.15V 4.2V 4.25V * 4.3V*
Percentage of 4.2V 0 % 2.9 % 5.0 % 8.6 % 36 % 62 % 73 % 83 % 89 % 94 % 100 % 105 % 106%
"""
# grab only the first real line
interesting = data.strip().split('\n')[0]
@initialed85
initialed85 / app.py
Created December 17, 2018 20:31
Tkinter mock UI test example
import datetime
import traceback
from PyQt5.QtGui import QFontDatabase
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout, QLabel, QTextEdit
_STATE_LABEL_PREFIX = 'State: '
class WoWHMI(object):
@initialed85
initialed85 / ubuntu_16_04_server_for_armv7l_in_QEMU.md
Last active January 30, 2019 18:42
Ubuntu 16.04 server for armv7l in QEMU
@initialed85
initialed85 / private_to_public.sh
Last active July 8, 2019 04:04
Create a public key for an AWS private key
#!/bin/bash
# props to original at https://gist.github.com/zircote/1243501
if [[ "${1}" == "" ]]; then
echo "usage: ${0} some_private_key.pem"
echo ""
echo "The result will be a public key at $(pwd)/some_private_key.pub"
exit 1
@initialed85
initialed85 / something.py
Last active July 8, 2019 10:53
Example of custom Python3 pickling behaviour (should work with Python 2)
from threading import RLock
class Something(object):
def __init__(self, a, b):
self.a = a
self.b = b
self._lock = RLock() # this is not pickleable
@initialed85
initialed85 / pktgen.py
Created January 15, 2020 11:58
Python packet generator
# to simulate DGPS generation
# python pktgen.py tb 3784 1 305
# to receive
# python pktgen.py rb 3784 1 305
# to simulate AMP generation
# python pktgen.py tm 13000 2.77 372
# to receive
# python pktgen.py rm 13000 2.77 372
@initialed85
initialed85 / bsm.txt
Last active February 2, 2020 17:42
V2X safety/awareness message content (SAE BSM and ETSI CAM)
Here's one of SAE's BSMs in XER format (size units are centimetres apparently):
<BasicSafetyMessage>
<coreData>
<msgCnt>33</msgCnt>
<id>FEF0EFD0</id>
<secMark>51333</secMark>
<lat>-419231528</lat>
<long>158945769</long>
<elev>27</elev>
@initialed85
initialed85 / smbus_read_byte_protocol_with_synapse_wireless_snappy.py
Last active June 30, 2020 03:52
SMBus Read Byte protocol w/ Synapse Wireless Snappy
"""
Synapse Wireless RF200 devices use some terribly hobbled version of Python2 coupled with a terribly limited library.
They are in general terrible devices.
Anyway- to read SMBus (a protocol layer on top of i2c- see Page 41 of 85 of http://smbus.org/specs/SMBus_3_0_20141220.pdf) the process is as follows:
- write 2 bytes to i2c
- byte 0 = slave address shifted left by 1 bit, write bit of 0
- byte 1 = command
@initialed85
initialed85 / gnss_test.py
Created January 22, 2020 13:21
Carla GNSS sensor oddities
import glob
import os
import sys
import time
from math import sqrt
from pyproj import Geod, Transformer
try:
sys.path.append(glob.glob('../carla/dist/carla-*%d.%d-%s.egg' % (