Skip to content

Instantly share code, notes, and snippets.

View travishathaway's full-sized avatar
🐢
Taking it slow and easy

Travis Hathaway travishathaway

🐢
Taking it slow and easy
View GitHub Profile
@travishathaway
travishathaway / thanksgiving_demo.py
Created November 24, 2025 14:06
Thanksgiving Dinner Served with Python and Conda
#!/usr/bin/env python3
"""
🦃 Thanksgiving Dinner Demo 🦃
Because why cook a real Thanksgiving dinner when you can just...
run it with conda or pixi?
How to use?
With conda:
@travishathaway
travishathaway / dayz_off.py
Created October 9, 2025 06:27
Days Off Calculator
"""
I wrote this script because I'm trying to figure out what day
would be the best day to take off if I only want to work four days
a week.
The best day here means I will get the most time off in the year if
I choose this day.
The holidays are German holidays and the extra days are company
holidays.
@travishathaway
travishathaway / file_vs_sqlite.py
Created May 19, 2022 13:13
Storing IDs in a file vs. SQLite
import os
import sys
import sqlite3
import time
import uuid
from functools import wraps
DB_FILE = 'tester.db'
FILE = 'tester.cache'
@travishathaway
travishathaway / sync_vs_async_http_requests.py
Last active February 6, 2022 15:07
Simple python script to show the differences in implementation/speed of synchronous and asynchronous approach for downloading content.
"""
Usage:
python simple_http_example.py [sync|async]
Description:
Simple python script to show the differences in implementation/speed of
synchronous and asynchronous approach for downloading content.
The output will show what was downloaded. The script repeats five
times and prints the average run speed before exiting.
#include <SPI.h>
#include <Adafruit_GPS.h>
//#include <SoftwareSerial.h>
#include <SD.h>
#include <DHT.h>
#include <avr/sleep.h>
// Ladyada's logger modified by Bill Greiman to use the SdFat library
//
// This code shows how to listen to the GPS module in an interrupt
@travishathaway
travishathaway / degree_mins_to_decimal_degrees.py
Created May 23, 2019 01:00
Convert Degree Minutes to Decimal Degrees
def convert_degree_dec_min_to_degree_dec(degree_dec_min: str):
"""
Converts a string that looks like this:
- "12238.2974W"
To this:
- -122.63829
In other words, it converts the "Degrees and Decimal Minutes" format
@travishathaway
travishathaway / mov_to_gif
Created August 3, 2018 16:58
This is a simple script using ffmpeg to convert .mov files to .gif
#! /bin/bash
#############################################################################
# Author: Travis Hathaway #
# #
# Description: #
# This is a simple script used to transform a .mov file to a .gif file #
# #
# Example: #
# mov_to_gif <mov_file> <start_time:seconds> <duration:seconds> #
# mov_to_gif your_movie.mov 5 2.5 #
import sqlite3
from functools import wraps
def sqlite_conn(func):
@wraps(func)
def wrap(self, *args, **kwargs):
conn = getattr(self, 'conn', None)
if not conn:
raise NotImplementedError(
@travishathaway
travishathaway / decorator_presentation.py
Last active June 27, 2018 20:00
This is an example that accompanies a presentation I recently gave on decorators. In this example, I show how to create decorators for managing connections to SQLite3 databases.
from functools import wraps
import sqlite3
CONN_STR = '/tmp/foo.db'
def sqlite_conn(conn_str):
def dec_func(func):
@wraps(func)
@travishathaway
travishathaway / pyscopg2_decorator.py
Last active May 9, 2025 23:49
Postgres Connections with Python Decorators
from functools import wraps
import psycopg2
####################
# Define Decorator #
####################
def psycopg2_cursor(conn_info):
"""Wrap function to setup and tear down a Postgres connection while
providing a cursor object to make queries with.