-
Great episode covering a seemingly simple topic. What I really benefitted from was hearing all the different use cases, from logging, debugging, to a/b testing, caching, and auth. I hadnāt even thought of it being applied to a router. I thought of it being applied for an entire application. This seems very useful for things like an admin router, all routes would need to have the admin role to get in.
Note
This post is a thought [1]. Itās a short note that I make
about someone elseās content online #thoughts
References:
[1]: /thoughts/
Today I Learned
Short TIL posts
1852 posts
latest post 2026-05-13
Publishing rhythm
![[None]]
Iāve been using these decorators to modify the behavior of specific routes. It will do things like 404 admin only routes in a way that looks just like fastapi [1]ās default, or only allow certain roles into the route, or redirect unauthenticated users to login.
After listening to yesterdayās syntaxfm Iām now really thinking about middleware and the benefits it might have. middleware would make it easy to apply things like admin to an entire admin router, so you wont forget it on any one admin route. It will look cleaner as the admin checker is only applied once per router, not once per route.
import inspect
import time
from functools import wraps
from inspect import signature
from fastapi import Request
from fastapi.responses import FileResponse, JSONResponse, RedirectResponse
from starlette import status
from fokais.config import get_config
from fokais.models.user import Role
config = get_config()
admin_routes = []
authenticated_routes = []
not_cached_routes = []
cached_routes = []
def not_found(request):
hx_request_header = request.headers.get("hx-request")
user_agent = request.headers.get("user-agent", "").lower()
if "mozilla" in user_agent or "webkit" i...
External Link
X (formerly Twitter) Ā· twitter.com [1]
Huh, so this is just built right into the chrome cli.
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
--headless \
--screenshot=/tmp/shot1.png \
https://simonwillison.net
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://twitter.com/simonw/status/1772043579231445366
[2]: /thoughts/
![[None]]
jinjaās url_for in fastapi [1] does not account for https by default, there is
probably a better way, but this is a way that allows me to configure when I use
http vs https.
@pass_context
def https_url_for(context: dict, name: str, **path_params: Any) -> str:
"""
always convert http to https
"""
request = context["request"]
http_url = request.url_for(name, **path_params)
return str(http_url).replace("http", "https", 1)
def get_templates(config: BaseSettings) -> Jinja2Templates:
templates = Jinja2Templates(directory="templates")
templates.env.globals["https_url_for"] = https_url_for
## only use the default url_for for local development, for dev, qa, and prod use https
if os.environ.get("ENV") in ["dev", "qa", "prod"]:
templates.env.globals["url_for"] = https_url_for
console.print("Using HTTPS")
else:
console.print("Using HTTP")
return templates
Note
This post is a thought [2]. Itās a short note that I make
about someone elseās content online #thoughts
References:
[1]: /fastapi/
[2]: /thoughts/
External Link
X (formerly Twitter) Ā· twitter.com [1]
Damn are one time paid and have it apps making a comeback? Seems like the perfect thing to have someone else automate and not pay a subscription for.
Genius Idea Cassidy!!
Now what do you call this, its not software as a service, is this just sofware?
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://twitter.com/cassidoo/status/1770900985382138291
[2]: /thoughts/
![[None]]
import logging
from typing import List
import strawberry
from fastapi import FastAPI
from strawberry.fastapi import GraphQLRouter
logger = logging.getLogger(__name__)
authors = {}
books = {}
book_authors = {}
authors_books = {}
def get_author_for_book(root) -> "Author":
return authors[book_authors[root.id]]
@strawberry.type
class Book:
id: int
title: str
author: "Author" = strawberry.field(resolver=get_author_for_book)
def get_books_for_author(root) -> List[Book]:
print(f"getting books for {root}")
return [books[i] for i in authors_books[root.id]]
@strawberry.type
class Author:
id: int
name: str
books: List[Book] = strawberry.field(resolver=get_books_for_author)
authors = {1: Author(id=1, name="Michael Crichton")}
books = {1: Book(id=1, title="Jurassic Park")}
# relationships
book_authors[1] = 1
authors_books[1] = [1]
def get_author_by_id(id: int) -> Author:
return authors.get(id)
def get_book_by_id(id: int) -> Book:
return books.get(id)
def get_authors(root) -> List[Author]:
return authors.values()
def get_books(root) -> List[Book]:
print(books)
print(authors)
print(book_authors)
print(authors_books)
return books.values()
@strawberry.typ...
Joining the split keyboards club: a Moonlander story | Carlos Becker
This post will describe my experience with a couple of firsts:
carlosbecker.com [1]
I switched from a 60% vortex pok3r to a 40% corne June, 2021. I can relate to a lot of what Carlos talks about here. I think going from 60%-40% made my journey harder than it needed to be. Thereās no going back now, but it took me a really long time to be able to hit all of the numbers and symbols, just figuring out how to do the layout was hard thereās not much space.
I didnāt touch type. I never really used my pinkies, except maybe for ESC, Shift, CTRL, Backspace et al.
I can relate to this, my typing habits were terrible. Shortly before going split ortho I worked on my speed with lots, and lots of practice on keybr and monkeytype. I took my speed from 35wpm to 80wpm with a few months of steady practice. This is one of the best things I did for myself.
Once I got split it dropped down to single digits and slowly rose back up to 80, just barely breaking my PB on monkeytype.
I still feel like I still canāt type at my previous max speed ā mostly because I wasnāt used to use my pinky and used the āwrong fingerā for a lot of...
My workflow, part 1 | Carlos Becker
I keep getting asked how my setup works, how I use tmux and
nvim over ssh⦠all that good stuff.
carlosbecker.com [1]
Carlos has a pretty sick setup here, I can relate to mostly, cept the macos part. My main critique is that I donāt think he gave window managers much chance on linux, and they just donāt work on MacOS/Windows.
Most of the time I have a single, maximized window.
I can relate to this. I should really make a full post about my experience with tiling window managers. TLDR, I came for tiling and I stayed for the workspaces.
Multiple Displays
An exception here could be streaming: having multiple displays can help preventing doxing yourself if you only share the screen of one of them. I only did stream like 3 times and thatās what I did, but Iām sure experienced streamers have better workflows (with or without multiple displays).
Accurate, my home machine uses one monitor, and for work I use one monitor+laptop. I pair, screenshare, and present quite a bit at work, and its good to have one screen for sharing, and one for seeing things like the app you are sharing from (chat, cams, etc)
Note
This post is a thought [2]. Itās a sh...
strawberry-sqlalchemy [1] by strawberry-graphql [2] is a game-changer in its space. Excited to see how it evolves.
A SQLAlchemy Integration for strawberry-graphql
References:
[1]: https://github.com/strawberry-graphql/strawberry-sqlalchemy
[2]: https://github.com/strawberry-graphql
I recently discovered AnyText [1] by tyxsspa [2], and itās truly impressive.
Official implementation code of the paper <AnyText: Multilingual Visual Text Generation And Editing>
References:
[1]: https://github.com/tyxsspa/AnyText
[2]: https://github.com/tyxsspa
Using Netlify Analytics to Build a List of Popular Posts
Writing about the big beautiful mess that is making things for the world wide web.
blog.jim-nielsen.com [1]
This is a sick feature of Jimās blog, I am really inspired by this. I am not sure how to do it for my own. I honestly think the easiest non locked in way would be to just use google search console results. Itās definitely a different way to think about it, but most of my traffic is coming from google search, so it would be a pretty good ballpark estimate.
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://blog.jim-nielsen.com/2020/using-netlify-analytics-to-build-list-of-popular-posts/
[2]: /thoughts/
Iām really excited about full-stack-fastapi-template [1], an amazing project by fastapi [2]. Itās worth exploring!
Full stack, modern web application template. Using FastAPI [3], React, SQLModel, PostgreSQL, Docker, GitHub Actions, automatic HTTPS and more.
References:
[1]: https://github.com/fastapi/full-stack-fastapi-template
[2]: https://github.com/fastapi
[3]: /fastapi/
I came across puter [1] from HeyPuter [2], and itās packed with great features and ideas.
š The Internet OS! Free, Open-Source, and Self-Hostable.
References:
[1]: https://github.com/HeyPuter/puter
[2]: https://github.com/HeyPuter
605: Jim Nielsen on Subversive URLs, Blogging + AI, and Design Engineers
Jim Nielsen joins us to about URLs and linking as the new subversive way to maintain the web, paying for news in Canada, should content creators be worried about AI, the case for design engineers, ā¦
ShopTalk Ā· shoptalkshow.com [1]
An absolute fantastic episode about blogging, thinking about a web1.0 kind of world today, and what it means moving forward.
Web 1.0 is robust, you own your own destiny, you own your data, you can do what you want. There is no platform to tell you what you can and cannot do. But the future web is stealing your data to build AI models, spam sites are duplicating your content and stealing your SEO. You may or may not care, but at the end whether you get traffic or now you own your web 1.0 sites.
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://shoptalkshow.com/605/
[2]: /thoughts/
Configure Liveness, Readiness and Startup Probes
This page shows how to configure liveness, readiness and startup probes for containers.
For more information about probes, see Liveness, Readiness and Startup Probes.
Before you begin You need to h...
Kubernetes Ā· kubernetes.io [1]
What is the difference between health, liveness, readiness, and startup? This article does a great job at a full writeup description of how it works in kubernetes, here is my TLDR.
-
health 200 OK - Iām still responding to requests
-
health ERR - something happened and I cant respond to requests
-
liveness 200 OK - Iām ready for more work
-
liveness ERR - Iām still responding to requests, and iām already working send requests to another pod, or scale up
Z-pages # [2]
These probes are commonly deployed at /healthz and /livez endpoints.
Why the z?
z is a convention that comes from google for meta endpoints to reduce conflict with actual endpoints, and can be deployed to any application.
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://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readin...
External Link
stackoverflow.com [1]
The convention of āz-pagesā comes from google and reduces the likelihood of collisions with application endpoints and keep the convention across all applications.
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://stackoverflow.com/questions/43380939/where-does-the-convention-of-using-healthz-for-application-health-checks-come-f
[2]: /thoughts/
I recently discovered homelab-argocd [1] by Doomlab7 [2], and itās truly impressive.
My ArgoCD app of apps repository
References:
[1]: https://github.com/Doomlab7/homelab-argocd
[2]: https://github.com/Doomlab7
Placehold
Placehold is a simple, fast and free image placeholder service to generate SVG, PNG, JPEG, GIF, WebP and AVIF placeholder images for your project.
placehold.co [1]
This is a handy placeholder generator for generating placeholder items like images, and videos.
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://placehold.co/
[2]: /thoughts/
![[None]]
I figured out the killer combination for python lsp servers, ruff and jedi! ruff does all of the diagnostics and formatting, then jedi handles all the code objects like go to definition and go to reference.
local servers = {
ruff_lsp = {},
jedi_language_server = {},
}
Note
This post is a thought [1]. Itās a short note that I make
about someone elseās content online #thoughts
References:
[1]: /thoughts/
flake8-to-ruff
Convert existing Flake8 configuration to Ruff.
PyPI Ā· pypi.org [1]
Underrated python library to on board ruff, or just use it on a project where its not the norm. ruff claims that its 99.9% compatible with black and when you read through the known differences they are clearly edge case bugs in black.
See this page for more about the comparison to black https://docs.astral.sh/ruff/faq/#how-does-ruffs-formatter-compare-to-black
oh and I just noticed that it is maintianed by Charlie, and comes straight out of astral.
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://pypi.org/project/flake8-to-ruff/
[2]: /thoughts/