Posts tagged: python

All posts with the tag "python"

312 posts latest post 2026-05-06
Publishing rhythm
Jan 2026 | 3 posts

Markata DidYouMean

Coming in Markata 0.9.1 is far better documentation. i.e. Documentation that actually exists for everything. As part of poking around I realized that I often go to look up the docs for a plugin and forget that the path is /markta/plugins/feeds, sometimes I might try /markata/feeds or /plugins/feeds.py or /feeds or I might even forget the plugin name exactly and try something like feed and get a 404. So I added a didyoumean plugin to markata that takes care of this. [1] I made a quick recording of this early feature, pay close attention to the url as it automatically updates to the correct page. markata-didyoumean.mp4 [2] Happy Path # [3] direct forward If you have one post called /markata/plugins/feeds, and it is the only post called feeds, any combination of /markata/feeds or /plugins/feeds or /feeds will all automatically redirect with an html [4] page (not a server 3xx) to the /markata/plugins/feeds post. Here is the snippet that does the redirect. <div class="container ...
2 min read
Models Pydantic Docs · docs.pydantic.dev [1] I came accross from_attributes today it allows creation of pydantic models from objects such as a sqlalchemy Base Model or while nesting pydantic models. I believe in the past I have ran into some inconsistencies with nesting pydantic models and I’ll bet one had from_attributes set and another did not. Arbitrary class instances¶ (Formerly known as “ORM Mode”/from_orm). Pydantic models can also be created from arbitrary class instances by reading the instance > attributes corresponding to the model field names. One common application of this functionality is integration with object-relational mappings (ORMs). To do this, set the from_attributes config value to True (see the documentation on Configuration for more details). The example here uses SQLAlchemy, but the same approach should work for any ORM. Note This post is a thought [2]. It’s a short note that I make about someone else’s content online #thoughts References: [1]: https://docs.pydantic.dev/latest/concepts/models/#rebuilding-model-schema [2]: /thoughts/
Top Python libraries of 2024 Dive into our 10th annual Python Libraries roundup for 2024, now featuring separate curated lists for General Use and AI / ML / Data tools. Discover this year's most innovative additions to the eco... Tryolabs · tryolabs.com [1] Really good listicle of new modern top python libraries from 2024. Very well done article with images, links, and an actually quality listicle with many things I’ve never even heard of. Note This post is a thought [2]. It’s a short note that I make about someone else’s content online #thoughts References: [1]: https://tryolabs.com/blog/top-python-libraries-2024 [2]: /thoughts/
[1] Good overview of seaborn color palettes. They have all sorts of different types, some designed to purposfully give each color the same weight for catecorization. Some designd to give linear differences in value, some have a parabolic feel with a diverging nature. Note This post is a thought [2]. It’s a short note that I make about someone else’s content online #thoughts References: [1]: /static/https://seaborn.pydata.org/tutorial/color_palettes.html [2]: /thoughts/

I fixed lists in my blog

A small improvement to my blog today. I was checking out my /now post and noticed that lists have left padding but no discs or numbers. I popped open my tailwind/app.css added these lines and rebuilt. #post-body li { @apply list-disc; } #post-body ol { @apply list-decimal; } And rebuild, which I actually do with ⭐ casey just [1], but showing the command here for clarity. npx tailwindcss --input tailwind/app.css --output static/app-39.css WHY the applies # [2] Before # [3] [4] After # [5] [6] References: [1]: /casey-just/ [2]: #why-the-applies [3]: #before [4]: https://dropper.waylonwalker.com/api/file/5c48f763-5ef6-49b0-9e8f-5167ab046f05.webp [5]: #after [6]: https://dropper.waylonwalker.com/api/file/0cf1c5d9-0948-444f-9a6c-387d22b9db43.webp
1 min read

nvim-manager

I recently built a cli application as a nearly-one-shot-app called nvim-manager [1]. It manages your nvim dotfiles install. [2] Why # [3] How is nvim manager any better # [4] nvim-manager allows you to install pinned versions of your dotfiles, your friends dotfiles, and distros in ~/.config. This allows you to have stable versions that will not break installed while you change things. I’m sure most of us have experienced the pain of installing one plugin, only to update all of your plugins and break something. Or, you have small changes on every machine you use, because they are all just a bit different and now you have big merge conflicts to deal with. All of this aside you can install a distro to get you by, or a known working version of your own dotfiles. So all these versions in ~/.config # [5] ya, thats the magic of NVIM_APPNAME, I can boot up any of these intalled working versions in an instant with NVIM_APPNAME=nvim-waylonwalker-v0.0.1 nvim. I can still cowboy up an...

one-shot-s3-cleanup

So I made a mistake in an app I am working on and ended up creating thumbnails of thumbnails, and thumbnails of thumbnails of thumbnails… etc. I was able to delete them all, but I wanted to make a one-shot script to do it. [1] One Shot App # [2] I got the idea of the one shot app from Simon Willison [3] and replicated his setup in a chatgpt project [4] Initial Prompt # [5] a mistake was made in my s3 bucket and I've created a bunch of extra files write a script that deletes all files that contain _thumb_thumb ⬢ [devtainer] ❯ aws s3 ls s3://dropper 2024-12-29 14:32:32 16158 02271f4c-be18-4bea-b23e-d00f9fe42b9f.webp 2025-01-11 14:20:49 2878 02271f4c-be18-4bea-b23e-d00f9fe42b9f_thumb.webp 2025-01-11 14:21:17 2858 02271f4c-be18-4bea-b23e-d00f9fe42b9f_thumb_thumb.webp 2025-01-11 14:21:44 2856 02271f4c-be18-4bea-b23e-d00f9fe42b9f_thumb_thumb_thumb.webp 2025-01-11 14:21:44 2856 02271f4c-be18-4bea-b23e-d00f9fe42b9f_thumb_thumb_thumb_thumb.webp 2024-12-27 10:25:36 2812 06422c09-d0da...
1 min read
GitHub - coderamp-labs/gitingest: Replace 'hub' with 'ingest' in any GitHub URL to get a prompt-friendly extract of a codebase Replace 'hub' with 'ingest' in any GitHub URL to get a prompt-friendly extract of a codebase - coderamp-labs/gitingest GitHub · github.com [1] Gitingest has a python package on pypi that you can run with uvx, and it accepts the same arguments as the web version, right in your terminal ⬢ [devtainer] ❯ uvx gitingest --help Usage: gitingest [OPTIONS] SOURCE Analyze a directory and create a text dump of its contents. Options: -o, --output TEXT Output file path (default: <repo_name>.txt in current directory) -s, --max-size INTEGER Maximum file size to process in bytes -e, --exclude-pattern TEXT Patterns to exclude -i, --include-pattern TEXT Patterns to include --help Show this message and exit. Note This post is a thought [2]. It’s a short note that I make about someone else’s content online #thoughts References: [1]: https://github.com/cyclotruc/gitingest [2]: /thoughts/
External Link X (formerly Twitter) · x.com [1] kitze hating on python packaging in new ways. Python packaging has a lot of quirks that can make it infuriating. Not once have I thought “you know what this needs, quotes and braces” [2] Note This post is a thought [3]. It’s a short note that I make about someone else’s content online #thoughts References: [1]: https://x.com/thekitze/status/1872267874842063223?t=zxq6-kA9atVuXJeWntxfWg&amp;s=09 [2]: https://dropper.waylonwalker.com/api/file/566ff44b-cace-474d-b1bc-62aaf42f419f.webp [3]: /thoughts/
- Great list of 4 tips for running fastapi applications. Keep routes small # [2] Fat routers with all of the logic built in makes them hard to test, hard to refactor, causes lots of duplication, and makes it hard to reuse the business logic code later in something like a cli application. Deploy Early # [3] I really like this advice! He reccommends deploying as early as you can get a healthcheck live in your application. I’ve found too many times developers build something that is really hard, or impossible to deploy, when if they had tried to deploy early they would have spotted some easy to fix issues. This is less important if you are building out of a template that your team commonly deploys from, but very important with new patterns. https://youtu.be/XlnmN4BfCxw?si=ks1wvmgDyoQLgrv2&t=1093 [4] Note This post is a thought [5]. It’s a short note that I make about someone else’s content online #thoughts References: [1]: /fastapi/ [2]: #keep-routes-small [3]: #deploy-early [4]: https://youtu.be/XlnmN4BfCxw?si=ks1wvmgDyoQLgrv2&amp;t=1093 [5]: /thoughts/
Building Python tools with a one-shot prompt using uv run and Claude Projects I’ve written a lot about how I’ve been using Claude to build one-shot HTML+JavaScript applications via Claude Artifacts. I recently started using a similar pattern to create one-shot Python uti... Simon Willison’s Weblog · simonwillison.net [1] This is really interesting, the lazy uv scripts are really becoming quite appealing, especially for something like this to just pop out of an llm ready to run. The article features several examples of these one-shot prompt ideas that I suggest you give a try, and a prompt for creating them. Note This post is a thought [2]. It’s a short note that I make about someone else’s content online #thoughts References: [1]: https://simonwillison.net/2024/Dec/19/one-shot-python-tools/ [2]: /thoughts/
PEP 723 – Inline script metadata | peps.python.org This PEP specifies a metadata format that can be embedded in single-file Python scripts to assist launchers, IDEs and other external tools which may need to interact with such scripts. Python Enhancement Proposals (PEPs) · peps.python.org [1] PEP 723 is what is inspiring all of these lazy self installing python scripts, Authored by the author of hatch and pyapp. This is a really cool thing that uv has picked up and made python packaging just a bit easier.. maybe… dependency resolution still sucks. Note This post is a thought [2]. It’s a short note that I make about someone else’s content online #thoughts References: [1]: https://peps.python.org/pep-0723/ [2]: /thoughts/
Switching from virtualenvwrapper to direnv, Starship, and uv Earlier this week I considered whether I should finally switch away from virtualenvwrapper to using local .venv managed by direnv. I’ve never … treyhunner.com [1] I’ve kinda fallen out of using direnv now that a lot of my projects use hatch, I generally just hatch shell into them. I just need to make sure I go through all of them and make my installer uv. Now I’ve been thinking about making uv my only needed dependency to run a python project and leaning more to something like uv run --with . uvicorn myapp --reload Note This post is a thought [2]. It’s a short note that I make about someone else’s content online #thoughts References: [1]: https://treyhunner.com/2024/10/switching-from-virtualenvwrapper-to-direnv-starship-and-uv/ [2]: /thoughts/
Lazy self-installing Python scripts with uv I frequently find myself writing my own short command-line scripts in Python that help me with day-to-day tasks. It’s so easy to throw together … treyhunner.com [1] I really like Trey’s steps to making an executable python script with uv his old process seems to be the same with a new shebang - Add an appropriate shebang line above the first line in the file (e.g. #!/usr/bin/env python3) - Aet an executable bit on the file (chmod a+x my_script.py) - Place the script in a directory that’s in my shell’s PATH variable (e.g. cp my_script.py ~/bin/my_script) And here is the new format the the shebang followed by the metadata comment block defined in PEP 723. #!/usr/bin/env -S uv run --script # /// script # requires-python = ">=3.12" # dependencies = [ # "ffmpeg-normalize", # ] # /// Note This post is a thought [2]. It’s a short note that I make about someone else’s content online #thoughts References: [1]: https://treyhunner.com/2024/12/lazy-self-installing-python-scripts-with-uv/ [2]: /thoughts/

thoughts 0.0.4

This is such an improvement to the backend of my website it warrants a blog post of celebration. For far too long I’ve been dealing with a tiny ass edit form on thoughts. I tend to not edit them, and try to get them right in one go. This is kinda the point of a thought, its a quick post meant to be the size of a tweet, but sometimes I’m leaving thoughts on a video or long post and want to make sure I have a good save point, but I just keep the thing in draft and hope I don’t loose if for far too long. Results # [1] Let’s see this change in action!! before # [2] This is the tiny ass form nested deeply in the flow of the feed. When I made it I naively just swapped out the post itself with the edit form, and swapped the post back in after edit. [3] thoughts is built with HTMX [4] btw so all html [5] is rendered in the backend and swapped by htmx client side. after # [6] Now the edit is a full page modal with a nice blurry backdrop effect to the rest of the content. This feels p...
Add a healthcheck to your FastAPI app | Nic Payne I'm building a few FastAPI apps to throw in docker and run on my homelab... I wanted to add healthchecks and here's a simple way to do it Make sure to pype.dev [1] Nice example of adding a healthcheck to fastapi [2], and integrating it with docker. Don’t forget to include curl in the install, nice touch. Note This post is a thought [3]. It’s a short note that I make about someone else’s content online #thoughts References: [1]: https://pype.dev/add-a-healthcheck-to-your-fastapi-app [2]: /fastapi/ [3]: /thoughts/
watchfiles Simple, modern and high performance file watching and code reload in python. watchfiles.helpmanual.io [1] Simple, modern and high performance file watching and code reload in python. Note This post is a thought [2]. It’s a short note that I make about someone else’s content online #thoughts References: [1]: https://watchfiles.helpmanual.io/ [2]: /thoughts/
I’ve been playing with 3d printing some items through the slant3d api. I’ve been pricing out different prints by running a slice request through their api. make a project # [1] I’ve been using uv for project management. It’s been working well for quick projects like this while making it reproducible, I’m still all in on hatch for libraries. mkdir slantproject cd slantproject uv init uv venv . ./.venv/bin/activate uv add httpx rich python-dotenv Get an api key # [2] You will need an api key from the slant api, which currently requires a google account and a credit card to create. # .env # replace with your api key from https://api-fe-two.vercel.app/ SLANT_API_KEY=sl-** slicing an stl with teh slant api # [3] Then you can run the python script to price out your print. I’m not exactly sure how this compares to an order, especially when you add in different materials. from dotenv import load_dotenv import httpx import os load_dotenv() stl_url = '' api_key = os.environ["SLANT_API_KEY"] api = httpx.Client(base_url="https://www.slant3dapi.com/api/slicer") res = httpx.post( "https://www.slant3dapi.com/api/slicer", json={"fileURL": stl_url}, headers={"api-key": api_key, "Co...
Production-ready Python Docker Containers with uv Starting with 0.3.0, Astral’s uv brought many great features, including support for cross-platform lock files uv.lock. Together with subsequent fixes, it has become Python’s finest workflow too... Hynek Schlawack · hynek.me [1] Hynek has a sick dockerfile setup for using uv in python projects. Note This post is a thought [2]. It’s a short note that I make about someone else’s content online #thoughts References: [1]: https://hynek.me/articles/docker-uv/ [2]: /thoughts/
Proper handling of None in WHERE condition · Issue #109 · fastapi/sqlmodel First Check I added a very descriptive title to this issue. I used the GitHub search to find a similar issue and didn't find it. I searched the SQLModel documentation, with the integrated search. I... GitHub · github.com [1] SQLModel models ship with an is_, and is_not that you can use to compare to None without pesky linters complaining. This comment summed it up quite well. I believe this is concerned entirely with SQLAlchemy, not with SQLModel, and has to do with the required semantics to construct a BinaryExpression object. Hero.age == None evaluates to a BinaryExpression object which is eventually used to construct the SQL query that the SQLAlchemy engine issues to your DBMS. Hero.age is None evaluates to False immediately, and not a BinaryExpression, which short-circuits the query no matter the value of age in a row. From a cursory search, it does not seem that the is operator can be overridden in Python. This could help explain why the only possibility is by using the == operator, which can be overridden. so rather than using Team.heros == None we can use Team.seros.is_(None) which checks for...