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 / yaml_apply_context.py
Created April 1, 2022 06:51
Replace tokens into YAML during load
import string
import yaml
def load_yaml(f, context=None):
if context is None:
context = {}
def string_constructor(loader, node):
import os
import json
import requests
_PUBLIC_SECRET = os.environ['KLAVIYO_PUBLIC_SECRET']
_API_ROOT = 'https://a.klaviyo.com/api'
_VALID_EXTRA_ATTRIBUTES = [
@dsoprea
dsoprea / sentry_generate_release_commit_arguments.py
Last active August 15, 2023 22:21
Generate a list of commit arguments from a submodules superproject for a Sentry release
#!/usr/bin/env python3
# MIT LICENSE
#
# Copyright 2023 Dustin Oprea
#
# 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
@dsoprea
dsoprea / assert_yaml_uniqueness.py
Last active January 13, 2024 09:32
Assert Uniqueness In YAML dictionaries using PyYAML
import yaml
def load_and_assert_uniqueness(x):
# We'd like to detect duplicates. Since PyYAML both loads things depth-first
# *and* doesn't give us the parent when processing a child node, we'll index
# of all of the object IDs as we're constructing them, and then see which
# are disappeared from the final hierarchy. Since all we can do is pass a
# class, we need to inline the class in order to load into an index within
# our scope.