Thoughts

Link based "commentary" style posts, commenting on a web link

858 posts latest post 2026-05-13
Publishing rhythm
May 2026 | 12 posts
External Link dotesports.com [1] Damn this button had me stuck for way too long. It definitely looks like a button once I see it, but I don’t recall coming into contact with many buttons in the game, I tried to set it ablaze, pull it, fly it, nothing. 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://dotesports.com/hp/news/hogwarts-legacy-argyllshire-map-what-does-the-button-do [2]: /thoughts/
How can I add my YouTube videos via RSS? You can share your videos or other people SocialBee Help Documentation · help.socialbee.com [1] YouTube makes finding rss feeds way too hard. Hats off to them for still supporting it, allowing you to find content outside the algorithm, and consuming content you asked for. But i had no idea you had to search the source code to get it. 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://help.socialbee.com/article/129-how-can-i-add-my-youtube-videos-via-rss [2]: /thoughts/
External Link stackoverflow.com [1] Another interesting option for slow count queries in sqlite. If you haven’t DELETEd any records, doing: SELECT MAX(ROWID) FROM "table" LIMIT 1; 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/8988915/sqlite-count-slow-on-big-tables [2]: /thoughts/
Optimizing SQLite for servers SQLite is often misconceived as a "toy database", only good for mobile applications and embedded systems because it's default configuration is optimized for embedded use cases, so most ... Sylvain Kerkour · kerkour.com [1] Very interesting article by Sylvain, suggested by Simon Willison. Definitely some things that I want to come back and try later on. Here is the TLDR of the whole post PRAGMA journal_mode = WAL; PRAGMA busy_timeout = 5000; PRAGMA synchronous = NORMAL; PRAGMA cache_size = 1000000000; PRAGMA foreign_keys = true; PRAGMA temp_store = memory; This is interesting, and something I need to consider. I definitely have an application with slow count queries. I am not sure how to make it better as its not a full count(*) so a count table doesn’t work, nor does counting by index. I might need to have a table of cached results, and if a write matches the counter increase it, or update all counters on write. COUNT queries are slow SQLite doesn’t keep statistics about its indexes, unlike PostgreSQL, so COUNT queries are slow, even when using a WHERE clause on an indexed field: SQLite has to scan for all the matching records. One solution...
- Inspiring story transitioning into tech from nursing. I also came to tech through a set of circumstances that made it difficult for me to excel at my current job. Looking back it is something that I was always interested in and I was just unsure how to get in, I am so glad that I figured it out, it has been such a great benefit to my family. I really enjoyed listening to trshpuppy’s journey in through building projects, and choosing tech not based on what she wanted to learn, but what fit the project the best. 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/
Some Git poll results Some Git poll results Julia Evans · jvns.ca [1] great poll of git [2] questions poll: did you know that in a git merge conflict, the order of the code is different when you do a merge/rebase? merge: <<<<<<< HEAD YOUR CODE OTHER BRANCH’S CODE c694cf8aabe rebase: «««< HEAD OTHER BRANCH’S CODE YOUR CODE d945752 (your commit message) This one explains a lot. I think I knew this, I might have seen it somewhere, but I have definitely noticed it go both ways and confuse the crap out of me. Feels very similar to how --ours and --theirs flip flops. 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://jvns.ca/blog/2024/03/28/git-poll-results/ [2]: /glossary/git/ [3]: /thoughts/
External Link sealed-secrets.netlify.app [1] kubeseal is a pretty simple to get started with way to manage secrets such that they can be stored in a git [2] repo and be picked up by your continuous delivery service. Sealed Secrets provides declarative Kubernetes Secret Management in a secure way. Since the Sealed Secrets are encrypted, they can be safely stored in a code repository. This enables an easy to implement GitOps flow that is very popular among the OSS community. 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://sealed-secrets.netlify.app/ [2]: /glossary/git/ [3]: /thoughts/
- 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/
![[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...
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/
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/
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/
![[None]] First I need to fetch my thoughts from the api, and put it in a local sqlite database using sqlite-utils. fthoughts () { # fetch thoughts curl 'https://thoughts.waylonwalker.com/posts/waylonwalker/?page_size=9999999999' | sqlite-utils insert ~/.config/thoughts/database2.db post --pk=id --alter --ignore - } Now that I have my posts in a local sqlite database I can use sqlite-utils to enable full text search and populate the full text search on the post table using the title message and tags columns as search. sthoughts () { # search thoughts # sqlite-utils enable-fts ~/.config/thoughts/database2.db post title message tags # sqlite-utils populate-fts ~/.config/thoughts/database2.db post title message tags sqlite-utils search ~/.config/thoughts/database2.db post "$*" | ~/git/thoughts/format_thought.py | bat --style=plain --color=always --language=markdown } alias st=sthoughts Now I am ready to search my thoughts, which is a tiny blog format that I created mostly for leaving my own personal comment on web pages, so most of them have a link to some other online content, and their title is based on the authors title. [1] [2] Note This post is a thought [3]. It...
[1] This is the best tree I have ever built in minecraft. It took at least 4 stacks of logs and leaves despite what it looks like. It is placed where Welscraft’s island in the hermitcraft season 10 seed, but on our own server we call lonecraft. We started this server a few weeks after hermitcraft season 10 started, and play on it a few times per week. It has a pretty successful day one iron farm that took us way more than one day to complete, and the farm behind this is our first ever villager driven farm. Somehow potatoes got cross contaminated and now its pumping out potatoes and some bread, but no carrots or beat roots. World Seed: 5103687417315433447 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://screenshots.waylonwalker.com/lonecraft.png [2]: /thoughts/
Formatting codes – Minecraft Wiki Formatting codes (also known as color codes) add color and modifications to text in-game. Minecraft Wiki · minecraft.wiki [1] Minecraft MOTD and server names have formatting codes so that you can get colors, bold, underlined, italics, in your message of the day or server name. See the article for all the cods. 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://minecraft.wiki/w/Formatting_codes [2]: /thoughts/
GitHub - jesseduffield/lazydocker: The lazier way to manage everything docker The lazier way to manage everything docker. Contribute to jesseduffield/lazydocker development by creating an account on GitHub. GitHub · github.com [1] I’ve been using this for a few weeks now and it’s fantastic. It’s reminds me of lazygit, it gives a nice quick interface into the things I need and it just works. Yes I can git [2] status to see what changed, then diff the files, then commit hunks, but lazygit can do that in just a few keystrokes. lazydocker does this for docker. It gives me a nice view into whats running, what’s eating up disk space, and the networks I have. And if I see I have a bunch of exited containers, there is a bulk command righ there to clean them up. tldr docker ps on steroids [3] Note This post is a thought [4]. It’s a short note that I make about someone else’s content online #thoughts References: [1]: https://github.com/jesseduffield/lazydocker [2]: /glossary/git/ [3]: https://github.com/jesseduffield/lazydocker/blob/master/docs/resources/demo3.gif?raw=true [4]: /thoughts/
- Go is feeling more and more like something I could throw in my tool belt as a python dev. I really like that it’s garbage collected and has great error management. I am just not sure how to work it in without it being the main thing. The thing that is so cool is the ability to ship tiny pre-compiled binaries that just work, and the raw speed. these binaries just get up and working without any warm up. writing any cli in python I’m going to be using something like typer, and it takes half a second just to warm up, so even hello world cannot be faster than half a second. 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/
- Great example from Anthony showing how easy it is to practice building database orm models and playing with them in a repl. This is good practice even if you are in a big code base to be able to test and learn in a simplified code base that does not have a mountain of other code around atuh, permissions, security, and other complex things that come into real production code bases that might make it hard to focus on what you are trying to do. Note Anthony uses backref here, thats legacy, use back_populates on both parent and child. 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/
External Link stackoverflow.com [1] Today I came across some sqlalchemy models that created some relationships, some used backref some used back_populates. I was stumped why, I had never came accross backref before and I felt skill issues sinking in. backref is considered legacy # [2] https://docs.sqlalchemy.org/en/14/orm/backref.html As stated in the sqlalchemy docs, backref is a legacy feature. Its shorthand to creating relationships between parent and child, but only adding it to the parent. While this is simpler it introduces some invisible magic. 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://stackoverflow.com/questions/51335298/concepts-of-backref-and-back-populate-in-sqlalchemy#answer-59920780 [2]: #backref-is-considered-legacy [3]: /thoughts/
2.5 Admins 180: Email 777 – 2.5 Admins 2.5admins.com [1] How do you pronounce URL, is it U.R.L or Earle? I’m about 50/50, mostly when I am in a hurry I use Earle as it is one syllable and easy to say. I picked this up from MPJ of fun fun function, who took over Dev Tips. In this episide Jim uses Earle and they make fun of him. If it’s good enough for Jim, I am done with my 50/50 and I’m going all in on Earle. Episode also included a fastinating corrdinated attack that used Ars Technica profile photos communicate directions for the next attack via query parameters in the image url. 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://2.5admins.com/2-5-admins-180/ [2]: /thoughts/
- This really makes me want to try Dolphin Mixtral with ollama now. It looks very impressive from this video. The ability to keep adding features before becoming confused is though with a lot of these llms. Being chat based, this is not a co pilot replacement. I was really hoping for an in line co pilot like tool that I can run locally. I have not used co pilot yet, but I have had great luck with codeium. 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/
- Great take on low code. I have definitely felt the pressure of being presented low code options, “look it does almost everything you need, and you can do it without code.” Granted there are tons of great low code environments that serve their markets well (things like zapier). As pointed out here when they fall short rather than being hard, it goes to nearly impossible. As Theo points out here many applications follow an 80/20 rule. 80% of the app is really easy to put together, and takes about 20% of the time, probably less. What no code does is it takes that 80% that is already easy, makes it even easier ( pitches it as faster whether or not that is true ), and makes the last 20% of the project impossibly hard to create and maintain, so you just should have picked a tool that had the capability of doing the whole thing from the start anyways. 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/
- I’ve heard prime say just give it the one eyed fighting kirby so many times, and execute it few times, and there is no way to find it online, so this will be the link that I will come to, when I need to remember what @theprimeagen means when he says Give it the one eyed fighting kirby. :s/\(.*\);/console.log(\1) So what is this? # [1] This is a vim substitute comand to replace text in the buffer. the one eyed fighting kirby is a regex capture group to capture everything between matches, and assign it a value to place back in after the match. substitute in a nutshell, :s/<what you want to replace>/<what you want to replace with> More examples # [2] Here is a contrived example of text. here there from here go there here = some_fuction(there) Now for some reason I want to switch all of the words here and there. I can do that with three capture groups, \1 is here, \2 is everything between, \3 is there. :%s/\(here\)\(.*\)\(there\)/\3\2\1 Just give it the one eyed fighting kirby ~Prime still struggling # [3] I thought this explaination from phind was good and more verbose than mine. --- describe this vim substitute regex :%s/(here)(.)(there)/\3\2\1 ANSWER | PHIND V9 M...
Java - ArchWiki wiki.archlinux.org [1] Today I learned that arch has a helper script archlinux-java to set the version of java. archlinux-java status archlinux-java set <JAVA_ENV_NAME> 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://wiki.archlinux.org/title/java#Switching_between_JVM [2]: /thoughts/
GitHub - charmbracelet/mods: AI on the command line AI on the command line. Contribute to charmbracelet/mods development by creating an account on GitHub. GitHub · github.com [1] This is a pretty sweet interface into llms. I used it a bit with my son tonight while he was asking me for datapack ideas. ❯ mods -f 'I am trying to have fun on my minecraft server and am creating a minecraft datapack send me some load.mcfuncions that will make it fun' You can continue the conversation with a -C ❯ mods -C -f 'I like where you are going with number 4, can you make it so that it runs when a player opens a door' You can pass it some data curl https://waylonwalker.com/thoughts-on-unit-tests/ | mods -f 'summarize this post' 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/charmbracelet/mods [2]: /thoughts/
GitHub - charmbracelet/mods: AI on the command line AI on the command line. Contribute to charmbracelet/mods development by creating an account on GitHub. GitHub · github.com [1] This is a pretty sweet interface into llms. I used it a bit with my son tonight while he was asking me for datapack ideas. ❯ mods -f 'I am trying to have fun on my minecraft server and am creating a minecraft datapack send me some load.mcfuncions that will make it fun' You can continue the conversation with a -C ❯ mods -C -f 'I like where you are going with number 4, can you make it so that it runs when a player opens a door' !!! note This post is a <a href="/thoughts/" class="wikilink" data-title="Thoughts" data-description="These are generally my thoughts on a web page or some sort of url, except a rare few don&#39;t have a link. These are dual published off of my..." data-date="2024-04-01">thought</a>. It's a short note that I make about someone else's content online #thoughts References: [1]: https://github.com/charmbracelet/mods
Gridfinity The modular, open-source grid storage system. Gridfinity · gridfinity.xyz [1] I am starting to build out some custom tool holders for my tool box, and using gridfinity. This is a super handy reference guide for spec’ing out the bases. 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://gridfinity.xyz/specification/ [2]: /thoughts/
Read a Range of Data - LIMIT and OFFSET - SQLModel SQLModel, SQL databases in Python, designed for simplicity, compatibility, and robustness. sqlmodel.tiangolo.com [1] Today I was running some sqlmodel queries through the sqlalchemy orm. Admittedly I’ve not done enough orm queries before, and I’ve done quite a bit of raw sql. I was trying to get objects from two separate models that had relationships setup. session.query(User, Images).where(User.id == 3).all() It is incredibly slow, and gives me the following warning. SELECT statement has a cartesian product between FROM element(s) What I learned from the SQLModel docs is that you should give it a join to correct this and go much faster. session.query(User, Images).join(Images).where(User.id == 3).all() 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://sqlmodel.tiangolo.com/tutorial/limit-and-offset/ [2]: /thoughts/
Template Designer Documentation — Jinja Documentation (3.1.x) jinja.palletsprojects.com [1] html [2] code generated by my jinja templates generally look half garbage because of indents and whitespace all over the place. I just learned about these pesky Whitespace Control characters that can get rid of the whitespace added from templating. You can also strip whitespace in templates by hand. If you add a minus sign (-) to the start or end of a block (e.g. a For tag), a comment, or a variable expression, the whitespaces before or after that block will be removed: {% for item in seq -%} {{ item }} {%- endfor %} 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://jinja.palletsprojects.com/en/3.0.x/templates/#whitespace-control [2]: /html/ [3]: /thoughts/
Intro - Minecraft Server on Docker (Java Edition) Documentation for Minecraft Server on Docker docker-minecraft-server.readthedocs.io [1] I just learned that if you can exec into the container running minecraft with the itzg/minecraft container you can run rcon-cli to get command access to the server. You need to set the RCON_PASSWORD if you want to access rcon remotely, but if you have not already done this and have access to the server you can just run rcon-cli when you are in. 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://docker-minecraft-server.readthedocs.io/en/latest/ [2]: /thoughts/
- Theo’s response puts a lot of my feelings about unit testing into words. It’s crazy how cargo culty it becomes that the echo chamber of twitter can bring in beliefs that we think we believe, but have not experienced enough or put enough thought in to form our own opinion. This video made me think so much that it turned into it’s own blog post Thoughts on Unit Testing [1] 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://waylonwalker.com/thoughts-on-unit-tests [2]: /thoughts/
Mastodon.py — Mastodon.py 2.2.1 documentation mastodonpy.readthedocs.io [1] Mastadon.py is a python api client for mastadon that makes it easy to cross post to mastadon. from mastodon import Mastodon Mastodon.create_app( 'pytooterapp', api_base_url = 'https://mastodon.social', to_file = 'pytooter_clientcred.secret' ) from mastodon import Mastodon mastodon = Mastodon(client_id = 'pytooter_clientcred.secret',) mastodon.log_in( '[email protected]', 'incrediblygoodpassword', to_file = 'pytooter_usercred.secret' ) mastodon.toot('Tooting from Python using #mastodonpy !') 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://mastodonpy.readthedocs.io/en/stable/ [2]: /thoughts/
bunny.net - The Global Edge Platform that truly Hops Hop on bunny.net and speed up your web presence with the next-generation Content Delivery Service (CDN), Edge Storage, and Optimization Services at any scale. bunny.net · bunny.net [1] bunny.net looks like an interesting cloudflare alternative. 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://bunny.net/ [2]: /thoughts/
IndieWebify.Me - a guide to getting you on the IndieWeb indiewebify.me [1] This is a sick guided site to validate indieweb tags on your site. It makes it much easier than trying to do it yourself. 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://indiewebify.me/ [2]: /thoughts/
External Link stackoverflow.com [1] After struggling to get dependencies inside of middleware I learned that you can make global dependencies at the app level. I used this to set the user on every single route of the application without needing Depend on getting the user on each route. from fastapi import Depends, FastAPI, Request def get_db_session(): print("Calling 'get_db_session(...)'") return "Some Value" def get_current_user(session=Depends(get_db_session)): print("Calling 'get_current_user(...)'") return session def recalculate_resources(request: Request, current_user=Depends(get_current_user)): print("calling 'recalculate_resources(...)'") request.state.foo = current_user app = FastAPI(dependencies=[Depends(recalculate_resources)]) @app.get("/") async def root(request: Request): return {"foo_from_dependency": request.state.foo} 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/72243379/fastapi-dependency-inside-middleware#answer-72480781 [2]: /thoughts/
Handling Errors - FastAPI FastAPI framework, high performance, easy to learn, fast to code, ready for production fastapi.tiangolo.com [1] This page shows how to customize your fastapi [2] errors. I found this very useful to setup common templates so that I can return the same 404’s both programatically and by default, so it all looks the same to the end user. from fastapi import FastAPI, Request from fastapi.responses import JSONResponse class UnicornException(Exception): def __init__(self, name: str): self.name = name app = FastAPI() @app.exception_handler(UnicornException) async def unicorn_exception_handler(request: Request, exc: UnicornException): return JSONResponse( status_code=418, content={"message": f"Oops! {exc.name} did something. There goes a rainbow..."}, ) @app.get("/unicorns/{name}") async def read_unicorn(name: str): if name == "yolo": raise UnicornException(name=name) return {"unicorn_name": name} 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://fastapi.tiangolo.com/tutorial/handling-errors/ [2]: /fastapi/ [3]: /thoughts/
External Link github.com [1] Setting an additional log handler to the uvicorn logger for access logs in fastapi [2] was not straightforward, but This post was very helpful. @app.on_event("startup") async def startup_event(): logger = logging.getLogger("uvicorn.access") handler = logging.StreamHandler() handler.setFormatter(logging.Formatter("%(asctime)s - %(levelname)s - %(message)s")) logger.addHandler(handler) 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://github.com/tiangolo/fastapi/issues/1508 [2]: /fastapi/ [3]: /thoughts/
External Link stackoverflow.com [1] Setting tags in your fastapi endpoints will group them in the docs. You can also set some metadata around the tags to get nice descriptions. Here is a full example from the post. from fastapi import FastAPI tags_metadata = [ {"name": "Get Methods", "description": "One other way around"}, {"name": "Post Methods", "description": "Keep doing this"}, {"name": "Delete Methods", "description": "KILL 'EM ALL"}, {"name": "Put Methods", "description": "Boring"}, ] app = FastAPI(openapi_tags=tags_metadata) @app.delete("/items", tags=["Delete Methods"]) @app.put("/items", tags=["Put Methods"]) @app.post("/items", tags=["Post Methods"]) @app.get("/items", tags=["Get Methods"]) async def handle_items(): return 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/63762387/how-to-group-fastapi-endpoints-in-swagger-ui#answer-63762765 [2]: /thoughts/
External Link X (formerly Twitter) · twitter.com [1] Most bloggers on my twitter blog right into a file that goes on git [2]. I kinda expected to have more database folk. I have my blog in markdown on git and the editing experience is top notch. I can just find files edit them in MY EDITOR, push them and I got a post. I am running thoughts in a sqlite database with a fastapi [3] backend, and holy crap the instant nature of posting feels so much better. Both sides have good points. Note This post is a thought [4]. It’s a short note that I make about someone else’s content online #thoughts References: [1]: https://twitter.com/_WaylonWalker/status/1734387536716308693 [2]: /glossary/git/ [3]: /fastapi/ [4]: /thoughts/