Skip to content

Instantly share code, notes, and snippets.

View coordt's full-sized avatar

Corey Oordt coordt

View GitHub Profile
@coordt
coordt / convert_text_clippings.py
Last active May 7, 2023 14:15
Convert .textClippings into .txt files
"""Convert text clippings to .txt files."""
import os
import re
import subprocess
from pathlib import Path
import plistlib
DEREZ_OUTPUT_RE = re.compile(r"\t\$\"([A-F0-9 ]+)\"\s+/\* (.+?) \*/")
@coordt
coordt / immutable.py
Created May 8, 2023 18:00
Functions to make things immutable
"""Functions to make things immutable."""
from collections import OrderedDict
from collections.abc import Hashable
from typing import Any
from immutabledict import immutabledict
from pydantic import BaseModel
def freeze_data(obj: Any) -> Any:
@coordt
coordt / resolve_name.py
Created June 20, 2023 20:07
Get a key or attr `name` from obj or default value.
def resolve_name(obj: Any, name: str, default: Any = None) -> Any: # NOQA: C901
"""
Get a key or attr ``name`` from obj or default value.
Copied and modified from Django Template variable resolutions
Resolution methods:
- Mapping key lookup
- Attribute lookup
@coordt
coordt / .pre-commit-config.yaml
Last active December 6, 2023 15:34
pre-commit configuration
ci:
autofix_prs: false
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.1.6'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
exclude: test.*
- repo: https://github.com/psf/black