Skip to content

Instantly share code, notes, and snippets.

View dsoprea's full-sized avatar
💭
Head in yesterday. Hands in today. Heart in tomorrow.

Dustin Oprea dsoprea

💭
Head in yesterday. Hands in today. Heart in tomorrow.
View GitHub Profile
@dsoprea
dsoprea / photoframe_zip_expander_and_uniquifier
Last active February 12, 2026 12:36
Find all ZIPs in the source path, extract all files, and rename base portion of the output name to be the SHA1 digest of the data of that file. Creates a manifest. Sets all timestamps according to EXIF.
#!/usr/bin/env python3
# Requirements: tqdm
import sys
import os
import argparse
import logging
import zipfile
import tempfile
@dsoprea
dsoprea / diff.py
Last active September 13, 2024 18:12
Tools to diff data
"""
Copyright 2024 Dustin Oprea
MIT LICENSE
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (theSoftware”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@dsoprea
dsoprea / hierarchy.py
Last active September 13, 2024 18:12
Tools to work with hierarchical data
"""
Copyright 2024 Dustin Oprea
MIT LICENSE
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@dsoprea
dsoprea / yaml_load_and_assert_uniqueness.py
Last active October 11, 2024 03:02
Prevent dupicate keys in dictionaries
"""
Copyright 2024 Dustin Oprea
MIT LICENSE
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@dsoprea
dsoprea / group_algorithms.py
Last active December 22, 2024 22:08
Produce all possible groups given a list of items. We provide a box-fitting algorithm. We provide all tests.
"""
https://gist.github.com/dsoprea/ef8b5a1a565427203b5b0897d7283426
Copyright 2024 Dustin Oprea
MIT LICENSE
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@dsoprea
dsoprea / batched.py
Created September 18, 2025 08:17
Yields sublists of a maximum size given an enumerable
def batched_gen(g, n):
"""Break the given iterator into batches of N items. The last group will
have (0 < x <= N) items.
This replicates `itertools.batched()` and enables it to be available for
Python <3.12 .
"""
# Make sure our input is a decaying generator
g = iter(g)