Skip to content

Instantly share code, notes, and snippets.

View robertlugg's full-sized avatar

Robert M Lugg robertlugg

View GitHub Profile
@robertlugg
robertlugg / .bash_prompt
Created March 15, 2020 00:36
Bash prompt with conda and git
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch of the current git/mercurial repository
# * the return value of the previous command
# * the fact you just came from Windows and are used to having newlines in
# your prompts.
@robertlugg
robertlugg / DITHER.md
Created September 17, 2023 00:26
A Markdown formatted version of DHALF.TXT
# Source
Original source no longer exists but was apparently:
http://www.efg2.com/Lab/Library/ImageProcessing/DHALF.TXT,
based on a stackoverflow discussion:
https://stackoverflow.com/a/9150427/2184122
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
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
#NEWBIEHACK
RL 03-01-2022
@robertlugg
robertlugg / object_query.js
Created October 31, 2018 07:20
Lens Studio scene object hierarchy
// -----JS CODE-----
function showProps(obj, pre) {
pre = pre || ''
var result = '';
result += pre + "Properties\n";
for (var i in obj) {
if (obj.hasOwnProperty(i)) {
result += pre + ' .' + i + ' = ' + obj[i] + '\n';
}
}
@robertlugg
robertlugg / TF2_datasets_understanding.md
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 tf.data The tf.data 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)
CONV_SIZE = 3
model_name = 'test_model'
def create_model():
@robertlugg
robertlugg / enumerate.py
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="https://asampler1.carrd.co/assets/images/card.jpg?v82476884724951" /><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="https://asampler1.carrd.co" /><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],