Skip to content

Instantly share code, notes, and snippets.

View travis23's full-sized avatar

Travis Niederhauser travis23

View GitHub Profile
@travis23
travis23 / python_checksum.py
Last active January 20, 2023 16:45
[Checksum in Python] #checksum #Python
import numpy as np
def checksum_uint8(vec):
"""
Get uint8 checksum from list-like object
Examples:
checksum_uint8([0, 1, 2, 3, 4, 5]) --> 241
checksum_uint8([10, 50, 36, 200, 210]) --> 6
"""
@travis23
travis23 / advice.md
Last active January 13, 2023 16:20
[advice] #advice #documentation #python #import #module #package #pip #conda #sounds #json #interpolation
@travis23
travis23 / Simulink_Notes.md
Last active August 31, 2022 16:03
[Simulink Notes] #simulink #notes
@travis23
travis23 / DisplayVariableOnHtlm.html
Last active September 9, 2020 17:15
[Display Javascript Variable on HTML Page] #javascript #html
<!-- See https://stackoverflow.com/questions/40858456/how-to-display-a-javascript-var-in-html-body -->
<html>
<head>
<script>
function displayNumber(number) {
document.getElementById("someID").innerHTML = number.toString();
}
</script>
</head>
@travis23
travis23 / JavascriptSetTimeout.html
Created September 9, 2020 15:47
[Javascript wait before carrying out command] #javascript #html #delay #sleep #pause #wait
<head>
<script>
function flashBackground() {
document.getElementById("element").style.background = 'White';
setTimeout(() => {document.getElementById("element").style.background = 'Yellow';}, 100)
}
</script>
</head>
@travis23
travis23 / CallFunction.html
Created September 9, 2020 15:42
[Javascript call function every x msec] #javascript #html #delay #sleep #pause #wait
<head>
<script>
window.setInterval(function() {myFunction()}, 500)
function myFunction() {
/* Do stuff */
}
</script>
</head>
@travis23
travis23 / RunOnLoad.html
Last active September 9, 2020 15:30
[On Loading Page Run Javascript] #html #javascript #onload
<head><script>
function initialize()
/* Initialize the web page */
{
/* Do stuff */
}
</script></head>
<body onload="initialize()">
@travis23
travis23 / remove_nonunique_times.py
Last active July 7, 2020 14:49
[remove points that contain non-unique time values from timeseries] #numpy #values #unique #python #strictly_increasing #timeseries
indices = np.unique(time_arr.values, return_index=True)[1]
time_strict = time_arr.values[indices]
response_strict = response_arr.values[indices]
@travis23
travis23 / levels_to_step_plot.py
Last active June 30, 2020 11:58
[levels_to_step_plot] #python #plot #step_plot
import numpy as np
def levels_to_steps_post(x_vec, y_vec):
"""Provides data like matplotlib.pyplot.step with where set to 'post'"""
x_new = [None] * (len(x_vec) * 2 - 1)
y_new = [None] * (len(x_vec) * 2 - 1)
for i in range(len(x_vec)-1):
x_new[2*i] = x_vec[i]
@travis23
travis23 / verify_path_exists.py
Last active April 30, 2020 20:31
[Verify Path Exists] #os #path #assert #raise #python
def verify_path_exists(path_):
try:
assert os.path.exists(path_)
except (AssertionError,) as error:
print()
print('Path not found')
print(path_)
raise FileNotFoundError