Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
"""
Coinflip simulation using OpenAI API to compare batch vs. individual LLM coinflip statistics.
Usage:
- Generate new results and display analysis:
python coinflip_simulation.py
- Generate new results, save them to file, and display analysis:
python coinflip_simulation.py --save
from pymodbus.client.sync import ModbusSerialClient as ModbusClient
import time
# --------------------------------------------------------------------------- #
# configure the client logging
# --------------------------------------------------------------------------- #
import logging
FORMAT = ('%(asctime)-15s %(threadName)-15s '
'%(levelname)-8s %(module)-15s:%(lineno)-8s %(message)s')
logging.basicConfig(format=FORMAT)
log = logging.getLogger()
#! pip install pymodbus==2.5.3
from pymodbus.constants import Endian
from pymodbus.payload import BinaryPayloadDecoder
from pymodbus.payload import BinaryPayloadBuilder
import logging
logger = logging.getLogger()
class UnknownModbusType(Exception):
{
"meta": {"theme": "flat"},
"basics": {
"name": "William Gathright, PhD",
"label": "Customer-Obsessed Technical Leader",
"image": "",
"email": "gathright@gmail.com",
"phone": "(847) 644-9009",
"summary": "I lead technical teams to a scalable product starting from a blank sheet of paper. After synthesizing insights from all stakeholders (customers, users, engineers, vendors, and beyond) I'll reach for just enough technology with a creative but considered touch. My approach to design starts from the business strategy and percolates down to the byte level. A breadth of experience across and outside of tech has given me the vocabulary to communicate between business and technical functions. ",
"location": {
@except-pass
except-pass / byte_word_order_demo.txt
Created July 29, 2022 21:21
Description of byteorder and wordorder
Take the original values:
1659128910
= 0x62e44c4e
= 0b1100010111001000100110001001110
-------------------
With byteorder: Little
And wordorder: Little
1659128910
Which is the original value
But the raw value is
@except-pass
except-pass / bitfield.py
Created June 17, 2022 18:41
bitfield evt1 tester
list_of_outcomes = [
'COMMUNICATION_ERROR',
'OVER_TEMP_ALARM',
'OVER_TEMP_WARNING',
'UNDER_TEMP_ALARM',
'UNDER_TEMP_WARNING',
'OVER_CHARGE_CURRENT_ALARM',
'OVER_CHARGE_CURRENT_WARNING',
'OVER_DISCHARGE_CURRENT_ALARM',
'OVER_DISCHARGE_CURRENT_WARNING',
@except-pass
except-pass / example_shadow.md
Last active November 19, 2021 19:11
example_shadow-sunspec-json_document

A small snippet of a sunspec model is shown here.

{
  "sunspec": {
    "0": {
      "id": 805,
      "fixed": {
        "SoC": 990,
        "V": 510,
 }
@except-pass
except-pass / _vimrc
Created October 7, 2021 14:54
Windows vimrc file
set nocompatible
filetype off
filetype plugin indent on " required
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set autoindent