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 / ubiquiti_air_os_scrape.py
Created February 1, 2018 14:18
Example interaction with Ubiquiti AirOS "API"
# Requirements:
#
# Python 2.7
# Requests package (pip install requests)
import pprint
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
USERNAME = 'some_readonly_username'
@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 / 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 / jython_example_magicdraw.py
Last active February 7, 2023 17:37
Example Jython script for NoMagic MagicDraw (Cameo Systems Modeler) metachain navigation
import pprint
def log(thing): # append to a log file
if not isinstance(thing, str):
text = repr(thing)
else:
text = thing
try:
@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 / 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