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 / 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 / OpenJupyterLab.bat
Created April 15, 2020 15:56
[Batch File to Open Jupyter Lab] #batch #Jupyter #Anaconda
set root=C:\Users\user\Anaconda3
call %root%\Scripts\activate.bat %root%
call activate py37
call cd "C:\Users\TNiederhauser\Dropbox (Medic)\MedicData\Floor Scale"
call jupyter lab
@travis23
travis23 / create_data_directory.py
Created January 23, 2020 20:43
[Create Data Directory with Meaningful Name] #directory #python #pendulum
import os
import pendulum
def create_data_directory(
data_kind, # 'VolCal'
data_source_id,
timezone,
parent_directory
):
@travis23
travis23 / read_csv.py
Created January 9, 2020 19:23
[Read csv with Python] #python #csv #null
# See https://stackoverflow.com/questions/7894856/line-contains-null-byte-in-csv-reader-python
with open(path_to_csv_file) as f:
reader = csv.reader((x.replace('\0', '') for x in f), delimiter=',') # Handle null values
while True:
try:
line = next(reader)
except StopIteration:
break
print(line) # process lines
@travis23
travis23 / ranges_in_between_ranges.py
Created September 24, 2019 15:42
[Boundaries Between Range Boundaries] #endpoints #numpy #classify #pandas
def get_ranges_in_between_ranges(df, start_name, stop_name):
"""
Get range boundaries in between range boundaries arranged to be strictly increasing.
For example if we had three range boundaries where the range start and stop values
are found in two separate columns in a dataframe,
start, stop
-----------
0, 5
7, 8