Skip to content

Instantly share code, notes, and snippets.

View robertlugg's full-sized avatar

Robert M Lugg robertlugg

View GitHub Profile
robertlugg /
Created September 17, 2023 00:26
A Markdown formatted version of DHALF.TXT
# Source
Original source no longer exists but was apparently:,
based on a stackoverflow discussion:
There are several authors. I am capturing the file because I think it is of great value. However, I am happy to remove it if requested.
The authors are: Lee Daniel Crocker, Paul Boulay, and Mike Morra
robertlugg / LCD Tutorial 1.c
Last active March 2, 2022 21:20
STM32 LCD interfacing
NOTE: This code had a bug which I edited in the browser to fix. UNTESTED.
Code to set up 8 pins for output to an LCD display.
This code sets up the 8 pins and turns on Port C, 6
RL 03-01-2022
robertlugg /
Last active May 19, 2021 21:04
TFRecords: from_tensor vs from_tensor_slices

from_tensors vs. from_tensor_slices

From the manual

TFRecord files using The module also provides tools for reading and writing data in TensorFlow.

Writing a TFRecord file

The easiest way to get the data into a dataset is to use the from_tensor_slices method.

Applied to an array, it returns a dataset of scalars:

from tensorflow import keras
import numpy as np
from IPython import embed
INPUT_SHAPE = (3, 3, 1)
model_name = 'test_model'
def create_model():
robertlugg /
Created July 27, 2020 19:55
Example iterating through multiple lists
list_column_a = [1, 11, 22, 33]
list_column_b = ['one', 'eleven', 'twenty two', 'thirty three']
list_column_c = ['exciting', 'blah', 'somewhat ok', 'fishy']
for idx, a in enumerate(list_column_a):
print(f"{a}, {list_column_b[idx]}, {list_column_c[idx]}")
for a, b, c in zip(list_column_a, list_column_b, list_column_c):
print(f"{a}, {b}, {c}")
<!DOCTYPE HTML><html lang="en"><head><title>Sampler1</title><meta charset="utf-8" /><meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" /><meta name="description" content="A sampler1" /><meta property="og:site_name" content="Sampler1" /><meta property="og:title" content="Sampler1" /><meta property="og:type" content="website" /><meta property="og:description" content="A sampler1" /><meta property="og:image" content="" /><meta property="og:image:type" content="image/jpeg" /><meta property="og:image:width" content="1280" /><meta property="og:image:height" content="800" /><meta property="og:url" content="" /><meta property="twitter:card" content="summary_large_image" /><style>html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,f

{ "editor.insertSpaces": true, "editor.fontFamily": "JetBrains Mono, Cascadia Code PL, Droid Sans Mono", "editor.fontLigatures": true, "editor.minimap.showSlider": "always", "editor.multiCursorModifier": "ctrlCmd", "editor.renderControlCharacters": true, "editor.renderIndentGuides": true, "editor.renderWhitespace": "boundary", "editor.rulers": [100],

robertlugg /
Created April 15, 2020 15:59
Timer that prints on same line. Example of CR without newline.
import time
counter = 0
while counter < 10:
print(f'\r{counter}', end='')
counter += 1
# Fixed version.
# Minimal changes to get it working
my_string = "This is a bunch of words!"
alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
outputStr = ''
for i in my_string:
for idx, j in enumerate(alphabet):