Skip to content

Instantly share code, notes, and snippets.

@dnywh
dnywh / parser.py
Last active June 25, 2023 04:52
Formats Kobo’s annotation text files into Markdown for use in Notion.
# Designed for Kobo highlights and notes.
# Step 1: Copy Kobo annotations TXT file from the Kobo to your Mac
# Step 2: cd into this directory
# Step 3: Rename the TXT file to `input.txt`
# Step 4: Run `python3 parser.py`
# Step 5: See `output.txt` for the results
def parse_txt_file(input_file, output_file):
with open(input_file, "r") as file:
@dnywh
dnywh / artic.py
Created January 3, 2023 00:13
An example of searching the Art Institute of Chicago's API in Python
import requests
import math
limit = 90
fields = "id,image_id,title,artist_id,medium_display"
url = f"https://api.artic.edu/api/v1/artworks/search?limit={limit}&fields={fields}"
headers = {"user-agent": "test-app/[email protected]"}
searchQuery = {
@dnywh
dnywh / dot-grid.py
Created December 25, 2022 07:22
A random design based on Kōhei Sugiura's stamps for the 1972 Olympics, rendered on a Raspberry Pi Pico and Waveshare e-ink display
# A random design based on Kōhei Sugiura's stamps for the 1972 Olympics
# https://commons.wikimedia.org/wiki/File:Stamps_of_Germany_(BRD),_Olympiade_1972,_Blockausgabe_1971,_Markenblock.jpg
from machine import Pin, SPI
import framebuf
import utime
import random
import math
# Display resolution
@dnywh
dnywh / pico_year_progress.py
Last active November 13, 2022 04:20
Showing how many days of the year have passed on a Raspberry Pi Pico and Waveshare e-ink display
# A basic example of showing how many days of the year have passed
# Forked from Waveshare's Pico ePaper-5.83py
from machine import Pin, SPI
import framebuf
import utime
# Display resolution
EPD_WIDTH = 648
@dnywh
dnywh / pico_frame_buffer_images.py
Last active November 12, 2022 04:56
Using MicroPython's FrameBuffer to render images via a byte array and Raspberry Pi Pico to a Waveshare e-ink display
# Forked from Waveshare's Pico_ePaper-5.83.py file
# Resources:
# - Turning PNG, JPEG etc images into byte array format: https://diyusthad.com/image2cpp
# - Making that byte array format exactly what the frame buffer wants: https://forums.pimoroni.com/t/pico-and-ssd1306-bounce-your-own-icons-tutorial/16548
# - Understanding how frame buffer formats work: https://blog.miguelgrinberg.com/post/micropython-and-the-internet-of-things-part-vi-working-with-a-screen
# Waveshare stuff
from machine import Pin, SPI
import framebuf
@dnywh
dnywh / pico_w_network_requests.py
Created November 8, 2022 04:37
A simple network request (or two) from a Raspberry Pi Pico W
# A more complex local network web server from your Raspberry Pi Pico W
# Provides a template for:
# - Connecting to a local network
# - Controlling the Pi's sensors (LED and temperature) from the webpage
# - Making network requests and passing that JSON data
import network # Handles connecting to Wi-Fi
import urequests # Handles making and servicing network requests
from time import sleep
from picozero import pico_led
@dnywh
dnywh / dannys-bash-profile.txt
Created July 28, 2019 15:36
Danny's Bash Profile
# This function builds your prompt. It is called below
function prompt {
# Define some local colors
local RED="\[\033[0;31m\]" # This syntax is some weird bash color thing I never
local LIGHT_RED="\[\033[1;31m\]" # really understood
local CHAR="danny"
# ♥ ☆ ♪ - Keeping some cool ASCII Characters for reference
# Here is where we actually export the PS1 Variable which stores the text for your prompt
export PS1="\[\e]2;\u@\h\a[\[\e[37;44;1m\]\t\[\e[0m\]]$RED\$(parse_git_branch) \[\e[32m\]\W\[\e[0m\]\n\[\e[0;31m\]$CHAR \[\e[0m\]"
@dnywh
dnywh / trello-safari.css
Last active July 27, 2018 20:04
Hide Trello background madness on Safari
/* 1. Open Safari > Preferences... > Advanced */
/* 2. Drop this style sheet into the 'style sheet:' section */
/* 3. Refresh any Trello tabs you might have open */
#classic-body {
background: #2b2b2c !important;
}
.board-header-btn {
color: #ffffff !important;