Skip to content

Instantly share code, notes, and snippets.

@baskaufs
baskaufs / 1979.1185P.json
Created January 23, 2023 20:07
Simple test manifest
{
"@context": "http://iiif.io/api/presentation/2/context.json",
"@id": "https://iiif-manifest.library.vanderbilt.edu/gallery/1979/1979.1185P.json",
"@type": "sc:Manifest",
"label": "Ask Your Dealer For Shoes Like These",
"description": "print by Artist Unknown",
"logo": "https://iiif.library.vanderbilt.edu/iiif/3/vanderbilt_logo.png/full/!100,100/0/default.jpg",
"attribution": "Provided by Vanderbilt University Fine Arts Gallery",
"metadata": [
{
{
"@id": "https://texashistory.unt.edu/ark:/67531/metapth974141/manifest/",
"@context": "http://iiif.io/api/presentation/2/context.json",
"@type": "sc:Manifest",
"label": "[Galveston City Company Records: 1838-1857]",
"description": "Ledger containing meeting minutes, proceedings, and other organizational documentation and records for the Galveston City Company, based in Galveston, Texas, starting in 1838 and ending with minutes for a meeting of the board of directors on October 22, 1857.",
"metadata": [
{
"label": "title.addedtitle",
"value": "Records of the Organization and Proceedings of the Galveston City Company: 1838"
@baskaufs
baskaufs / nested_directories.py
Created September 9, 2022 18:25
Loop throrough directories and subdirectories to access every file
import os
base_path = '.'
directories = os.listdir(base_path + '/')
# directory outer loop
for directory in directories[:3]: # delete the index (square brackets and contents) to do all
if directory =='xml_jsonl_converter-master': # skip this directory, which doesn't have files to be processed
continue
if os.path.isdir(base_path + '/' + directory):
print(directory)
@baskaufs
baskaufs / nested_subdirectories.py
Created September 9, 2022 14:26
loop through nested subdirectories
directories = os.listdir('./')
for directory in directories:
print(directory)
if not '.' in directory:
subdirectories = os.listdir(directory)
for subdirectory in subdirectories:
if not '.' in subdirectory:
print(subdirectory)
files = os.listdir(subdirectory)
for file in files:
@baskaufs
baskaufs / mermaid.md
Last active March 21, 2022 02:00
test of mermaid diagram
  graph TD;
    a[standard proposed]-->b[executive decision];
    b-->c[expert review];
    c-->d[executive decision];
@baskaufs
baskaufs / boot.py
Created February 21, 2022 14:41
boot script for switch-based control of QT Py RP2040 memory read/write
import board
import digitalio
import storage
switch = digitalio.DigitalInOut(board.D0)
switch.direction = digitalio.Direction.INPUT
switch.pull = digitalio.Pull.UP
# Connecting D0 to ground makes switch.value False
storage.remount("/", switch.value)
@baskaufs
baskaufs / code.py
Created February 21, 2022 14:39
Code to store LSM6DS33 accel and gyro data using QT Py RP2040
import time
seconds_to_run = 120
measurements_per_second = 30.6 # determined emprically when running full speed, not imposed by sleep statement
#delay_time = 1/ measurements_per_second # time to delay between multiple measurements
# Set up "board" (QT Py RP2040)
import board
import busio # contains an interface for using hardware-driven I2C communication from your board
i2c = busio.I2C(board.SCL1, board.SDA1)
@baskaufs
baskaufs / ceiling_fan_lsm6ds33.csv
Created February 21, 2022 14:37
ceiling fan data, LSM6DS33 sensor, acc range: 4g, gyro range: 500 deg/s, 50 revolutions per 47 seconds
seconds x_acc y_acc z_acc x_gyro y_gyro z_gyro
0.241211 -0.404387 0.870988 -9.52343 -0.00454929 -0.100756 0.0606358
0.259766 -0.48335 0.872184 -9.68974 -0.00180042 -0.120303 0.057276
0.275391 -0.547956 0.875773 -9.6694 -0.00180042 -0.0176781 0.0536108
0.291016 -0.514457 0.882952 -9.64786 0.000337616 0.0406595 0.0471968
0.307617 -0.491725 0.875773 -9.48994 0.00186478 0.0348563 0.0456696
0.323242 -0.497707 0.835095 -9.63231 0.00064306 0.0641778 0.0429207
0.338867 -0.534796 0.856631 -9.6036 0.000948489 0.0589855 0.0392555
0.426758 -0.491725 0.856631 -9.56172 0.00766799 0.0266097 0.0218459
0.444336 -0.404387 0.850649 -9.55454 0.00675172 0.0104217 0.019097
@baskaufs
baskaufs / code.py
Last active April 1, 2022 13:32
CircuitPython code to use with VCNL 4040 proximity and lux sensor
import time
import board
import busio
import adafruit_vcnl4040
i2c = busio.I2C(board.SCL1, board.SDA1)
sensor = adafruit_vcnl4040.VCNL4040(i2c)
while True:
print("Proximity:", sensor.proximity)
@baskaufs
baskaufs / code.py
Created January 26, 2022 17:31
CircuitPython code to flask LED on QT PY RP2040
import time
import board
import neopixel
pixels = neopixel.NeoPixel(board.NEOPIXEL, 1)
while True:
pixels.fill((255, 0, 0))
time.sleep(0.1)
pixels.fill((0, 0, 0))