Skip to content

Instantly share code, notes, and snippets.

View inchoate's full-sized avatar

Jason Vertrees inchoate

View GitHub Profile
@inchoate
inchoate / sql-model-full-schema-dump.md
Last active March 30, 2025 04:02
Recipe for converting Pydantic models to SQLModel while still supporting the ability to fully emit nested schema and model data.

Emitting Fully Nested Python Schemas and Models with SQLModel

I ran into a problem while developing some cool tools. I had a nested Pydantic structure that I needed to migrate to SQLModel. But, I needed to retain the ability to emit fully nested schema and models -- which was lost. So, I had to write a few helper functions and models.

In the realm of modern web development and data-driven applications, managing complex data structures and their relationships can be a daunting task. SQLModel, a powerful library that bridges the gap between SQLAlchemy and Pydantic, offers an elegant solution for defining and interacting with SQL databases using Python. In this small write up, we dive into a practical demonstration of leveraging SQLModel to emit fully nested Python schemas and models. Surprisingly, this doesn't work out of the box.

Our focus is on a versatile script that illustrates how to dynamically generate and manipulate nested data structures. By defining SQLModel-based types, we can seamlessly map th

If you've instantiated your CrewAI Crew as a class, using the convenient decorators (@agent, @task, for example) as shown in the documentation you probably ended up with something like this:

@crew
def crew(self) -> Crew:
    """Creates the crew"""
    return Crew(
        agents=self.agents,
        tasks=self.tasks,
        process=Process.sequential,
        full_output=True,
@inchoate
inchoate / Azure-CLI-Bugs.md
Created May 12, 2023 21:00
Bugs in the Azure CLI

I found a bug in Azure's az CLI when it parses variables.

I was tagging a lot of resources and initially did this:

export ENV=demo
export VERSION=
export RG=rg-apps-${ENV}${VERSION}
export LOCATION=eastus
export SUBSCRIPTION="my-subscription-id"

Here's my TL;DR on Azure Service Principals, with a full example of creating one to push docker images to Azure Container Registry.

First, you need an Azure Container Registry. So, go make one. And, once you're done go to its page in the UI and click Overview > JSON View. See that Resource ID? Copy that. That will become the scope or the Azure thing we want to give to give our principal access to. Scopes can be at various levels. In this example, I'm very finely scoping down to ONLY this container registry resource. This principal will have no permissions anywhere else. You can go up levels in the scope hierarchy if you want, and say, provide access to all resources in a resource group or even a subscription. My resource ID looks a bit like this: /subscriptions/1d6a...982f/resourceGroups/my-container-registry/providers/Microsoft.ContainerRegistry/registries/registryname. Also, store the name of your registry if you want to push an image to it later.

Second, you need to determine what permissions

@inchoate
inchoate / readme.md
Last active April 8, 2025 16:47
Open clicked URLs into a particular Google Chrome profile

Problem

When I click on links from Slack or Outlook on MacOS they open in seemingly random browser windows/profiles. This is annoying.

Solution

Open links in a particular google chrome profile window. Be less annoyed.

  1. In Chrome, visit chrome://version and find the desired profile name. Mine was Default. Copy that profile's directory name, like Profile 2 or Default, not the profile's vanity name you see when you click on your profile icon in the browser.
  2. Install Finicky: brew install finicky. After install it should be running and you should see the icon in the upper toolbar.
  3. From the Finicky Toolbar Item, click > Config > Create New
  4. Edit the new file ~/.finicky and make it look something like this, filling in your profile name:
@inchoate
inchoate / istio.sh
Created December 5, 2018 17:37
Accessing Istio Dashboards
# Service Graph:
kubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=servicegraph -o jsonpath='{.items[0].metadata.name}') 8088:8088 &
# Kiali:
kubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=kiali -o jsonpath='{.items[0].metadata.name}') 20001:20001 &
# Grafana:
kubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=grafana -o jsonpath='{.items[0].metadata.name}') 3000:3000 &
# Prometheus:
#
# This will build the memtier_benchmark tool from Redis labs and
# run it against a Redis server running on your Mac's localhost.
#
git clone https://github.com/RedisLabs/memtier_benchmark.git
cd memtier_benchmark
docker build -t memtier_benchmark .
docker run --rm -it memtier_benchmark -s host.docker.internal
@inchoate
inchoate / check_media.py
Created June 27, 2017 23:01
Checks remote resources
"""Checks to see if media URIs listed in the given file are valid.
Warning this is untested, shit code.
"Valid" means:
- the file is under 32 megs
- the file exists at the URI
Usage:
# check all URLs in the `your-uri-file.txt` and output failures only.
@inchoate
inchoate / realmassive_ingest.md
Last active July 9, 2020 14:52
JSON Structure to Easily Import Data into RealMassive

RealMassive Simplified Data Ingestion Format

  • Version: v0.0.1-pre. This is a proposal. We encourage feedback.
  • Last Edited: 2017-02-28

Here we document our file format for importing CRE data into RealMassive. Third party data providers will be interested in this because, if they:

  • export their data into this format;
  • provide RealMassive with a publicly accessible file via URI;
  • keep that file up to date
@inchoate
inchoate / zeep_failed_parse_response.log
Created February 27, 2017 15:12
Zeep v1.1.10 fails to parse this response
This file has been truncated, but you can view the full file.
In [7]: %paste
"""
Testing with Berkshire-Hathaway
"""
"""
Colliers API Testing
"""
import zeep