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}
---
This post sat in draft for months. I stumbled upon it again and found great success returning good error messages based on user preferences. the default remains json, but if a user requests text/html it will be an html [3] response, and text for ...
Posts tagged: thought
All posts with the tag "thought"
871 posts
latest post 2026-06-01
Publishing rhythm
Creating SSH Apps with Charm Wish and Laravel Prompts
Building PHP CLI apps with Laravel Prompts is easy, but how can we share them? Charm to the rescue! Charm Wish is an easy-to-use SSH server that allows users to securely log into your server and us...
Joe Tannenbaum · blog.joe.codes [1]
Joe has a sick cli.labs site for deploying tui applications.
ssh cli.lab.joe.codes
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.joe.codes/creating-ssh-apps-with-charm-wish-and-laravel-prompts
[2]: /thoughts/
white-space CSS property - CSS | MDN
The white-space CSS property sets how white space inside an element is handled.
MDN Web Docs · developer.mozilla.org [1]
html [2] can preserve newline \n characters by styling an element with white-space: pre-wrap;
pre-wrap
Sequences of white space are preserved. Lines are broken at newline characters, at
, and as necessary to fill line boxes.
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://developer.mozilla.org/en-US/docs/Web/CSS/white-space
[2]: /html/
[3]: /thoughts/
htmx ~ The htmx Response Targets Extension Extension
htmx gives you access to AJAX, CSS Transitions, WebSockets and Server Sent Events directly in HTML, using attributes, so you can build modern user interfaces with the simplicity and power of hypert...
htmx.org [1]
The htmx [2] response-targets extension allows me to respond to errors from the backend and do normal htmx swaps.
Note
by default htmx will only swap on 200 and 300 responses
Load the extension in head
<script src="https://unpkg.com/[email protected]/dist/ext/response-targets.js"></script>
Use the extension on an endpoint that might return a 400.
<div hx-ext="response-targets">
<div id="response-div"></div>
<button hx-post="/register"
hx-target="#response-div"
hx-target-5*="#serious-errors"
hx-target-404="#not-found">
Register!
</button>
<div id="serious-errors"></div>
<div id="not-found"></div>
</div>
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://htmx.org/extensions/response-targets/
[2]: /htmx/
[3]: /thoughts/
https://boot.dev/blog/devops/how-to-restart-all-pods-in-a-kubernetes-namespace/
blog.boot.dev [1]
As of kubernetes 1.15 there is an easy way to restart all pods in a deployment.
kubectl -n {NAMESPACE} rollout restart deploy
Thanks Lane give him a follow @wagslane [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://blog.boot.dev/open-source/how-to-restart-all-pods-in-a-kubernetes-namespace/
[2]: https://twitter.com/wagslane
[3]: /thoughts/
Changelog Master Feed
Your one-stop shop for all Changelog podcasts.
Changelog · changelog.com [1]
Jerod (It’s ya boi) and Adam are my favorite tech news nerds, and have the sickest podcasts in tech. Yes plural podcasts they run seven podcasts maybe more. If you want it short and sweet they got the best 15 minutes of tech news each week this is it. My favorite is Ship it, sad to see Gerhard go, but Justin and Autumn are crushing it. Every episode is highly polished and surrounded by the sickest beats in podcasting.
Subscribe to one pod if you want, but I recommend collecting them all with the master feed.
⭐⭐⭐⭐⭐
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://changelog.com/master
[2]: /thoughts/
MarkdownDown
Convert any webpage to a clean markdown w/ images downloaded.
MarkdownDown · markdowndown.vercel.app [1]
Small web app to convert html [2] into markdown. Pretty cool idea. I actually want to look into this for reader and see how well it would work. Right now I am just pulling descriptions, but maybe I can pull full web pages, and keep the full intent of the first 200 words or so in the cards.
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://markdowndown.vercel.app/
[2]: /html/
[3]: /thoughts/
Boston Dynamics’ new humanoid moves like no robot you’ve ever seen
All-electric, 360° joints give the new Atlas plenty of inhuman movements.
Ars Technica · arstechnica.com [1]
Award for the creepiest way to stand up a robot from lying flat.
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://arstechnica.com/gadgets/2024/04/boston-dynamics-debuts-humanoid-robot-destined-for-commercialization/
[2]: /thoughts/
Rug pull, not cool! (Changelog & Friends #40)
If Changelog News had an extended edition, this might be it! Jerod & Adam discuss Hashicorp's Cease and Desist letter, Redis getting forked, Boston Dymanics' scary cool new robot, Justin Searls' ex...
Changelog · changelog.com [1]
Five star episode with Jarod and Adam shootin the crap.
The massive Cease and Desist [2]
Sucks that the guest had to back out, what a wild world 2024 is. Filled with license and pricing changes.
From Vim to Zed [3]
Interesting to hear the journey into zed, way to go Thorston diving all the way into working at zed.
Boston Dynamics’ new Atlas [4]
I later saw this through a YT short, and man does it hold up to the creepy level that they described.
MarkdownDown [5]
This is a legit cool service, that converts html [6] into markdown
Note
This post is a thought [7]. It’s a short note that I make
about someone else’s content online #thoughts
References:
[1]: https://changelog.com/friends/40
[2]: https://opentofu.org/blog/our-response-to-hashicorps-cease-and-desist/
[3]: https://registerspill.thorstenball.com/p/from-vim-to-zed
[4]: https://arstechnica.com/gadgets/2024/04/boston-dynamics-debuts-humanoid...
![[none]]
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: kanboard
namespace: argocd
spec:
project: default
destination:
namespace: kanboard
server: 'https://kubernetes.default.svc'
source:
path: kanboard
repoURL: 'https://github.com/waylonwalker/homelab-argo'
targetRevision: HEAD
syncPolicy:
automated:
prune: true
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/
Manual Upgrades | K3s
You can upgrade K3s by using the installation script, or by manually installing the binary of the desired version.
docs.k3s.io [1]
You can give k3s an install channel to install stable, latest, or specific versions like 1.26. This is handy to make sure that you install the same version on all of your workers.
curl -sfL https://get.k3s.io | INSTALL_K3S_CHANNEL=latest <EXISTING_K3S_ENV> sh -s - <EXISTING_K3S_ARGS>
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.k3s.io/upgrades/manual
[2]: /thoughts/
Devin's Upwork "side hustle" exposed (Changelog News #90)
YouTuber "Internet of Bugs" breaks down why AI "software engineer" Devin is no Upwork hero, Redka is Anton Zhiyanov's attempt to reimplement Redis with SQLite, OpenTofu issues its response to Hashi...
Changelog · changelog.com [1]
Damn 2024 is such a shit show, now Devin seems to be out as a complete scam. It’s really teaching us to have skepticism for what you find on the internet. Turns out that when broken down frame by frame much of the description in the video was a straight up lie. Personally it seemed quite plausible that it was percentage points better than the competition, but I was not holding my breath for it to be a hands off engineer.
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://changelog.com/news/90
[2]: /thoughts/
External Link
stackoverflow.com [1]
I learned about the sqlite_master table from this stack overflow answer. This helps make a lot of sense to how sqlite works. The master table contains all the sqlite objects and the sql to create them.
The .tables, and .schema “helper” functions don’t look into ATTACHed databases: they just query the SQLITE_MASTER table for the “main” database. Consequently, if you used
sqlite3 database.db "SELECT * from sqlite_master;"
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/82875/how-can-i-list-the-tables-in-a-sqlite-database-file-that-was-opened-with-attach#answer-83195
[2]: /thoughts/
Redirecting
15r10nk.github.io [1]
This is a cool snapshot testing tool that automatically creates, and updates test values for you.
Starting with some test code.
from inline_snapshot import snapshot
def something():
return 1548 * 18489
def test_something():
assert something() == snapshot()
now if I run pytest my tests will fail because my assert will fail, but if I run pytest --inline-snapshot=create it will fill out my snapshot values and the file will then look like this.
from inline_snapshot import snapshot
def something():
return 1548 * 18489
def test_something():
assert something() == snapshot(28620972)
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://15r10nk.github.io/inline-snapshot/
[2]: /thoughts/
GitHub - nalgeon/redka: Redis re-implemented with SQL
Redis re-implemented with SQL. Contribute to nalgeon/redka development by creating an account on GitHub.
GitHub · github.com [1]
Redka a sick new redis compatable api, that uses sqlite as its backend datastore. It feels lightweight to use as it is a single small binary. Data does not have to fit into memory as it uses sqlite to store data.
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/nalgeon/redka
[2]: /thoughts/
Arch Linux - News: The xz package has been backdoored
archlinux.org [1]
Check your system to see if you are vulnerable to the xz backdoor.
I found this line most pertanent to me.
The xz packages prior to version 5.6.1-2 (specifically 5.6.0-1 and 5.6.1-1) contain this backdoor.
Also it appears that arch is not vulnerable as it does not directly link openssh to liblzma, so the known attack vecotor is not possible. read to the end of the linked article for more.
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://archlinux.org/news/the-xz-package-has-been-backdoored/
[2]: /thoughts/
![[None]]
Install it
{
"ThePrimeagen/harpoon",
branch = "harpoon2",
dependencies = { "nvim-lua/plenary.nvim" },
config = function()
require("waylonwalker.plugins.harpoon").setup()
end,
},
harpoon config
local harpoon = require("harpoon")
M = {}
M.setup = function()
-- REQUIRED
harpoon:setup()
-- REQUIRED
vim.keymap.set("n", "<F10>", function() harpoon:list():append() end)
vim.keymap.set("n", "<F9>", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end)
vim.keymap.set("n", "<F1>", function() harpoon:list():select(1) end)
vim.keymap.set("n", "<F2>", function() harpoon:list():select(2) end)
vim.keymap.set("n", "<F3>", function() harpoon:list():select(3) end)
-- these are cnext/cprev
-- vim.keymap.set("n", "<F4>", function() harpoon:list():select(4) end)
-- vim.keymap.set("n", "<F5>", function() harpoon:list():select(5) end)
vim.keymap.set("n", "<F6>", function() harpoon:list():select(6) end)
-- Toggle previous & next buffers stored within Harpoon list
vim.keymap.set("n", "<F7>", function() harpoon:list():prev() end)
vim.keymap.set("n", "<F8>", function() harpoon:list():next() end)
-- basic telescope configuration
local conf = require("telescope.config").valu...
-
I found this statement quite intriguing.
multi-cursors are just macros.
This is quite a philisophical video and mostly prime talking about the things that make vim vim, and what prime needs in and editor vs what he can live without.
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/
Use an llm to automagically generate meaningful git commit messages
I
harper.blog [1]
This is pretty sick, I wanted this early on when I was making lockhart. I wanted to do the git [2] hook thing but could not figure it out and did not know that prepare-commit-msg was a hook that I could use.
Git Hooked
Then I remembered! Git hooks! Lol. Why would I have that in my brain - who knows!
I asked claude again, and they whipped up a simple script that would act as a hook that triggers with the prepare-commit-msg event.
This is awesome, cuz if you want to add a git message, you can skip the hook. But if you are lazy, you exclude the message and it will call the LLM.
Simon Willison’s llm cli comes in clutch here, it has such a good intereface to allow a prompt to be piped in, but the system prompt be set by -s.
gpt = "!f() { git diff $1 | llm -s \"$(cat ~/.config/prompts/commit-system-prompt.txt)\" }; f"
I love hacking on projects, but often I am super bad at making commits that make sense.
I completely relate to this statement, and this is why I am trying it.
Note
This post is a thought [3]. It’s a short note that I make
about someone else’s content online #thoughts
Refere...
External Link
stackoverflow.com [1]
Its sad that this is not the accepted answer.
mkdir ~/.npm-global
export NPM_CONFIG_PREFIX=~/.npm-global
export PATH=$PATH:~/.npm-global/bin
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/16151018/how-to-fix-npm-throwing-error-without-sudo#answer-41395398
[2]: /thoughts/