External Link
askubuntu.com [1]
podman requires qemu-system on
❯ podman machine init
Looking up Podman Machine image at quay.io/podman/machine-os:5.1 to create VM
Extracting compressed file: podman-machine-default-amd64.qcow2: done
Error: exec: "qemu-img": executable file not found in $PATH
The fix to this for me was to install qemu-system before podman machine init.
sudo apt update
sudo apt install qemu-system
References:
[1]: https://askubuntu.com/questions/1490805/how-do-i-install-qemu-on-ubuntu-23-10
Thoughts
Link based "commentary" style posts, commenting on a web link
Publishing rhythm
SVG backgrounds, icons, and other website graphics
👉 Copy-and-paste backgrounds, patterns, icons, and other website graphics directly into projects. All customizable, tiny in file size, and licensed for multi-use.
SVG Backgrounds · svgbackgrounds.com [1]
svgbackgrounds is a really awesome resource for svg things recently featured on https://shoptalkshow.com/618/
References:
[1]: https://www.svgbackgrounds.com/
GitHub - darrenburns/posting: The modern API client that lives in your terminal.
The modern API client that lives in your terminal. - darrenburns/posting
GitHub · github.com [1]
Currently Posting is a super early postman like tui (terminal user interface). It looks so good. Darren is really getting into a groove, and textual is getting to a place that is allowing him to really make these beautiful.
I am so impressed with the progress that he has made so early, it looks so close to postman in the freaking terminal, and the ui is so good. He already has think like jump that give you a way to around the ui like easymotion plugins. Theres themes and a command line, oh man its so good. star it.
References:
[1]: https://github.com/darrenburns/posting
Blogmarks that use markdown
I needed to attach a correction to an older blogmark (my 20-year old name for short-form links with commentary on my blog) today - but the commentary field has always …
Simon Willison’s Weblog · simonwillison.net [1]
Oh I kinda like the name blogmark, as opposed to thoughts like I have chose for the same thing. Aparantly Simon beat me to the punch by 20 years on this one.
References:
[1]: https://simonwillison.net/2024/Apr/25/blogmarks-that-use-markdown/
A Link Blog in the Year 2024
Kellan Elliott-McCrea has started a new link blog: Like many people I’ve been dealing with the collapses of the various systems I relied on for information over the previous decades. …
Simon Willison’s Weblog · simonwillison.net [1]
THIS! is the same reasons that I built thoughts [2]{.hoverlink}. Simon has bee a big inspiration along the way. He defintely changed the format of my posts as I watched him build out his quote posts.
Link blogging is a pleasantly low-pressure way of writing online. Found something interesting? Post a link to it, with a sentence or two about why it’s worth checking out.
Ditto! just make a post.
References:
[1]: https://simonwillison.net/2024/Jun/9/a-link-blog-in-the-year-2024/
[2]: https://thoughts.waylonwalker.com
[1]
Kellan brings some interesting thoughts on where the internet is headed in 2024. Interestingly I see myself headed in a similar direction. Feeling like I know just enough to say fuck it and build my own platform for me to me me, from thoughts [2]{.hoverlink} where I link and make thoughts on posts like this, to reader [3]{.hoverlink} which is my rss reader replacement that I wanted in 2013 when it was killedbygoogle [4]
And particular with the collapse of the social spaces many of us grew up with, I feel called back to earlier forms of the Internet, like blogs, and in particular, starting a link blog.
Ai has really had quite the two sided effect since chatgpt launched and set the world ablaze. Suddenly you can get any answer you want as a custom fit blog post for free without effort, thus killing the traffic to any of these sites.
References:
[1]: /static/https://laughingmeme.org//2024/06/08/a-link-blog-in-2024.html
[2]: https://thoughts.waylonwalker.com
[3]: https://reader.waylonwalker.com
[4]: https://killedbygoogle.com/
How to Configure DNS over TLS (DoT) Using Unbound DNS in OPNsense
Going beyond the basics of home networking
homenetworkguy.com [1]
Setting up DNS overTLS in opnsense has made my dns just a bit more secure and reliable. I recently had an outage of half the internet within my house. This also hit some of my friends and not some. It did not hit my mobile network. What seems to have happened is a dns issue with my isp not resolving some domains. This setup corrected my issue and I was back online more securely.
Note
I did try to setup the family resolver and found it was blocking some sites I am ok with. I decided to drop back to the vanilla resolver and let other services within opnsense control blocking where I can caontrol the whitelist myself.
References:
[1]: https://homenetworkguy.com/how-to/configure-dns-over-tls-unbound-opnsense/
GitHub - argoproj/argo-events: Event-driven Automation Framework for Kubernetes
Event-driven Automation Framework for Kubernetes. Contribute to argoproj/argo-events development by creating an account on GitHub.
GitHub · github.com [1]
Argo events is an event driven automation framework for kubernetes that can create kubernetes objects among other things based on events. I’ve been using native kubernetes cronjobs to kick off jobs based on a cron trigger.
For instance I am running reader.waylonwalker.com every hour, to rebuild the site and re-deploy it. It takes about two minutes to fetch every rss feed, so this is a nice application of a job compared to a web server fetching the feeds live. Now my posts may be up to an hour stale but they load fast.
Argo events takes event drien architecture to the next level allowing to be triggered by many more things, and do many more things than creating a cron job. I’m definitely thinking about dropping this in my homelab [2].
References:
[1]: https://github.com/argoproj/argo-events?tab=readme-ov-file
[2]: /homelab/
GitHub - catppuccin/ulauncher: 🇺 Soothing pastel theme for Ulauncher
🇺 Soothing pastel theme for Ulauncher. Contribute to catppuccin/ulauncher development by creating an account on GitHub.
GitHub · github.com [1]
I am using this theme for Ulauncher in arch and it looks fantastic! One line install (read it first).
python3 <(curl https://raw.githubusercontent.com/catppuccin/ulauncher/main/install.py -fsSL)
References:
[1]: https://github.com/catppuccin/ulauncher
Ulauncher — Application launcher for Linux 🐧
Download Ulauncher for Linux, discover extensions and videos, and support the project.
ulauncher.io [1]
Just discovered this really cool launcher from the DHH distro omakub. github.com/omakub [2]{.hoverlink}.
Ulauncher comes out of the box looking good, supports extensions, and shortcuts like I have a lot of mac launchers have. I installed it plus a theme and in no time It was looking good and launching applications.
In the past I have leaned in on rofi for task launching, it is good. I just felt it was harder to configure to get right or look good.
References:
[1]: https://ulauncher.io/
[2]: https://github.com/basecamp/omakub
[1]
This is a sick steam deck dock! With a corne built in laptop style.
References:
[1]: /static/https://kbd.news/Steam-Deck-dock-2291.html
GitHub - basecamp/omakub: Opinionated Ubuntu Setup
Opinionated Ubuntu Setup. Contribute to basecamp/omakub development by creating an account on GitHub.
GitHub · github.com [1]
This is DHH’s linux startup script. Call it a distro if you want, but he doesn’t. It’s made to take a vanilla ubuntu install and configure everything the way he likes it. There’s a number of great nuggets in here to pick up on.
No need to write bespoke configs for every essential tool just to get started or to be up on all the latest command-line tools. Omakub is an opinionated take on what Linux can be at its best.
Check it out and give it a ⭐ basecamp/omakub [1]{.hoverlink}.
References:
[1]: https://github.com/basecamp/omakub
From the circle to epicycles | Personal Site of Andrei N. Ciobanu
This article will be part of an extensive series in which I plan to explore various aspects of Fourier Mathematics. I will take notes, create some visuals (a good pretext to learn more about graphi...
andreinc.net [1]
This is a really cool animated visual representation of how sine waves work, how they relate to circles, pi, rad, and how to add up a series of waves to make square and sawtooth waves.
References:
[1]: https://www.andreinc.net/2024/04/24/from-the-circle-to-epicycles
External Link
x.com [1]
This looks like a sweet tui postman clone. Darren is really rolling with these tui’s. Cant wait to see where this one goes.
References:
[1]: https://x.com/_darrenburns/status/1797763563270095006
How to Force Dark Mode on Every Website in Google Chrome
Do you like dark mode? Chrome now lets you forcibly enable it for every site on the web. No more blindingly bright websites.
How-To Geek · howtogeek.com [1]
Sometimes I struggle to get my os to report dark mode to chrome, luckily there is a way to force chrome to always use dark mode.
I’ve never really gotten into dark reader and extensions like this. For some reason they all make websites look really weird to me and I don’t really care for it. What I want is websites designed to be in dark/light to always go dark, if the designer didn’t design dark just let it be light.
References:
[1]: https://www.howtogeek.com/446198/how-to-force-dark-mode-on-every-website-in-google-chrome/
xxHash - Extremely fast non-cryptographic hash algorithm
xxhash.com [1]
xxHash is an extremely fast non-cryptographic hash algorithm, working at RAM speed limit. It is proposed in four flavors (XXH32, XXH64, XXH3_64bits and XXH3_128bits). The latest variant, XXH3, offers improved performance across the board, especially on small data.
References:
[1]: https://xxhash.com/
xxhash
Python binding for xxHash
PyPI · pypi.org [1]
I hit an issue with markata where even though a bunch of articles were cached, the site build was still slow because I was hitting hashlib.sha256 so hard for cache keys. I was shocked when this popped up in my profiler as a significant portion of the time spent. I swapped out for xxhash and that issue completely went away.
References:
[1]: https://pypi.org/project/xxhash/
Replicate - Run AI with an API
Run open-source machine learning models with a cloud API
replicate.com [1]
This is so easy compared to self hosting stable diffusion yourself. It even has a nice api that you can hit with curl or python. The pricing seems competitive as well. Bookmarking this to try next time I need something like it.
References:
[1]: https://replicate.com/
How to Deliver Code Every Day
I recently calculated that I merge 0.8 pull requests every day into my team repo. Let’s round up and say I merge about one PR every day, delivering one or more features to production. I like this...
Jake Worth · jakeworth.com [1]
Great set of tips here!
No waiting. No “waiting until tomorrow” or “It’s Friday, let’s wait until Monday” to deploy. If your deploys are so slow that deploying an hour before the end of the day is a risk, that’s a separate problem. If you’re afraid of a Friday deploy, your system is too brittle, or you don’t have foolproof rollback procedures, or you don’t have people you trust on call to resolve it. Each of these is a problem that you can fix.
This one I find interesting I think there are some industries where customers come in large waves over the weekend, and a weekend bug can not only ruin someones day off, take longer to fix, but also cost a lot of money.
Not deploying on Friday is totally what that team should be doing.
Most of us are not that team. Most of us work on small teams supporting some sort of product that Should be able to be tested and rolled back. I completely agree with Jake here, if your not will...
You Have to Get Fast to Get Good at Programming
Great programmers aren’t fast because they’re great. They’re great because they’re fast.
Jake Worth · jakeworth.com [1]
Be Fast, Practice, Hone your craft. There’s a lot to be said here about honing your craft for editing text, picking up a few extra WPM, learning vim shortcuts.
Also just build shit. The more you build new and different things the more not only your text editing will just roll out, your skills to see patterns in code and architecture will flourish.
Read their bios, and the answer is always no. They loved to play, sure. They had some base talent, typically. But they also invested an absurd amount of time into that skill set.
This! is actually what turned me on to Post Malone. I remember hearing his story in how he was just known as the guy with a guitar because he was always playing it between class and everything.
References:
[1]: https://www.jakeworth.com/posts/be-fast/
Zellij (@Zellij_dev) on X
POV your sysadmin rigged your terminal to show this when you ssh into production
X (formerly Twitter) · x.com [1]
This one is too funny. opening a sixel image in the terminal when logging into prod.
References:
[1]: https://x.com/Zellij_dev/status/1574675207935107072
text-decoration-line - Typography
Utilities for controlling the decoration of text.
tailwindcss.com [1]
Tailwind calls strikethrough line-through. This caught me off guard and took me a minute to find.
Control how text is decorated with the underline, no-underline, and line-through utilities.
References:
[1]: https://tailwindcss.com/docs/text-decoration
Digital Gardening for Non-Technical Folks
How to build a digital garden without touching code
maggieappleton.com [1]
Maggie is a fantastic proponent to the digital gardening movement. In this article she proposes 3 ways for someone to start their own digital garden with low friction and no code.
References:
[1]: https://maggieappleton.com/nontechnical-gardening
We have a right to repair! with Kyle Wiens, Founder and CEO at iFixit (Changelog Interviews #582)
This week Adam went solo — talking to Kyle Wiens, Founder and CEO at iFixit, about all things Right to Repair. They discussed the latest win here in the US with Oregon passing an electronics Righ...
Changelog · changelog.com [1]
This is one of my favorite changelog episodes of all time. I had no idea all the work that has gone into the right to repair and ifixit. They talk a lot about apple and its trend to be less repairable from unservicable air pods to serialized components within iphone.
A lot of legal talk that was far more interesting that I thought it would be. Recently winning the right to repair case against John Deere, and creating repairability scores for devices to be placed in stores like energy guide is.
References:
[1]: https://changelog.com/podcast/582
Try Out the Latest Linux Gnome DE With DistroBox
Discover a step-by-step guide to installing and experiencing the latest Linux Gnome desktop environment with DistroBox.
Linux TLDR · linuxtldr.com [1]
Get gnome running in distrobox.
References:
[1]: https://linuxtldr.com/gnome-de-in-distrobox/
STLGears.com
The Free STL Gear Designer For 3D Printing
stlgears.com [1]
This is a pretty nice gear generator. I printed a few gears today and it worked great so far.
References:
[1]: https://www.stlgears.com/generators/3dprint
GitHub - eraser-dev/eraser: 🧹 Cleaning up images from Kubernetes nodes
🧹 Cleaning up images from Kubernetes nodes. Contribute to eraser-dev/eraser development by creating an account on GitHub.
GitHub · github.com [1]
This is kinda sick, its a tool to clean up container images in a k8s cluster.
References:
[1]: https://github.com/eraser-dev/eraser?tab=readme-ov-file
Distrobox
Use any linux distribution inside your terminal.
distrobox.it [1]
distrobox gives you distrobox-host-exec to run commands on the host. This is handy to get access to host level clis that you probably wouldn’t want to run from the container like podman, docker, flatpak.
DESCRIPTION
distrobox-host-exec lets one execute command on the host, while inside of a container.
Under the hood, distrobox-host-exec uses host-spawn a project that lets us execute commands back on the host. If the tool is not found the user will be prompted to install it.
References:
[1]: https://distrobox.it/usage/distrobox-host-exec/
Are We Anti-Cheat Yet?
areweanticheatyet.com [1]
A comprehensive community built index of anti-cheat support for linux very similar to proton, but specific to anticheat support.
References:
[1]: https://areweanticheatyet.com/
GitHub - ublue-os/image-template: Build your own custom Universal Blue Image!
Build your own custom Universal Blue Image! Contribute to ublue-os/image-template development by creating an account on GitHub.
GitHub · github.com [1]
ublue-os makes a github template for making your own git [2] repo with actions that build out your own personal ublue iso.
References:
[1]: https://github.com/ublue-os/image-template
[2]: /glossary/git/
GitHub - ublue-os/obs-studio-portable: OCI container image of OBS Studio that bundles a curated collection of 3rd party plugins
OCI container image of OBS Studio that bundles a curated collection of 3rd party plugins - ublue-os/obs-studio-portable
GitHub · github.com [1]
Distrobox is so interesting and cool, I’ve only recently started realizing how much it can do especially related to hardware and graphics, this is quite an example that runs obs in a distrobox. I had no idea distrobox would let you connect to cameras and gpus so seemlessly, and give you a gui to work from. And with distrobox you can export so that it just looks like an app on your system.
References:
[1]: https://github.com/ublue-os/obs-studio-portable
How Ahrefs gets a Billion dollar-worth infrastructure with a 90% discount
A holistic comparison of on-prem Ahrefs infrastructure with a cloud alternative
Medium · tech.ahrefs.com [1]
2024 has been a wild year for infra with going “back” to on prem being made popular by @dhh [2]. Well it looks like ahrefs saw right through the cloud trends an decided to ride the anti cloud train until it came back around to the station.
Being just a bit critical of the article it is impossible to get an apples to apples without actually running something of this scale and spending too much to find out. I cant imagine raw ec2 and ebs being the cheapest route into aws. They used no serverless tech in their article, but I digress, because I like this own your shit and build good product train.
What about People?!
This follow up does dive into the typical gut reaction that people cost a lot of money, you must account for them. You see when you hire people who are actually good at what they do, and run lean a lot of cost goes away, you have levels of management that disappear, levels of tooling that don’t need to exist, departments of IT don’t need to exist.
Colo’s are the new hotness, and will...
Safer Bash Shebang Recipes - Just Programmer's Manual
just.systems [1]
When using justfiles each line is ran separately from the last, unless you specify the file to be ran by something other than just such as bash. If you want variables to persist you need to set a shebang.
Also if you are using your script i a way that you want it to exit when it fails you need to set -e and -o pipefail. This is critical if you are thinking about using just for production scripts like ci/cd. I’ve hit too bugs where ci passes, but no artifacts were created issues for this exact reason.
foo:
#!/usr/bin/env bash
set -euxo pipefail
hello='Yo'
echo "$hello from Bash!"
References:
[1]: https://just.systems/man/en/safer-bash-shebang-recipes.html?highlight=pipefail#safer-bash-shebang-recipes
Justfile Cheat Sheet
Just is a command runner https://github.com/casey/just
Cheatography · cheatography.com [1]
This is a dope ass cheat sheet for justfiles. It’s filled with good examples that are short and to the point, probably all from the docs, but anyways I need to do some like this for myself.
References:
[1]: https://cheatography.com/linux-china/cheat-sheets/justfile/
A quote from Tim Paul
I’m no developer, but I got the AI part working in about an hour. What took longer was the other stuff: identifying the problem, designing and building the UI, setting …
Simon Willison’s Weblog · simonwillison.net [1]
Damn this Tim Paul quote finishes hard and such a good point. None of the stuff around llms just work. Good ui’s, front end, back end, infrastructure, product. All these things still need to exist, and in fact for ai to be good we need to still go hard on them otherwise everything will die in a heaping pile of ai slop [2]
I’m no developer, but I got the AI part working in about an hour.
What took longer was the other stuff: identifying the problem, designing and building the UI, setting up the templating, routes and data architecture.
It reminded me that, in order to capitalise on the potential of AI technologies, we need to really invest in the other stuff too, especially data infrastructure.
It would be ironic, and a huge shame, if AI hype sucked all the investment out of those things.
— Tim Paul [3]
References:
[1]: https://simonwillison.net/2024/May/13/tim-paul/
[2]: https://simonwillison.net/2024/May/8/slop/
[3]: https://www.timp...
PopSQL - Collaborative SQL Editor - Bring Order to SQL Chaos
PopSQL is a unified SQL collaboration workspace that connects everyone in the data analysis process so you can obtain better insights by asking the right questions, together.
PopSQL · popsql.com [1]
PopSql looks like a very innovative product to bring collaboration to data exploration and visualization in a way you would expect from something like vscode liveshare. This looks far more appealing than a traditional BI data tool.
References:
[1]: https://popsql.com/
Pricing | PopSQL
PopSQL is a unified SQL collaboration workspace that connects everyone in the data analysis process so you can obtain better insights by asking the right questions, together.
PopSQL · popsql.com [1]
interesting pricing model from popsql (pronounces Popsicle). At a glance you pay for data retention, want the abiltiy to recall all the queries you ran within the last year, run at a higher frequency, you jump a pricing tier.
References:
[1]: https://popsql.com/pricing
-
such a sick episode with dax.
SST’s free tier will be free as long as aws allows a free tier, their free tier literally costs them nothing.
They talked about keeping SST small, the limitations that brings, but also the number of problems that just go away when you only have 3 people building. Lots of process disappears, everyone can trust everyone, no one needs to wait for approval, everyone is their own PM and just builds cool shit. They don’t have to worry about big costs and making payroll because they are profitable so much higher than their costs.
If they can get through phase one of just being the go platform for a very specific audience of users, and gain marketshare, the ideas of offerings on top of this are endless.
-
I had no idea that you could just drop an msi installer right in steam. This worked for me, and was much easier to install pokemon tcg live in 05-2024 on ubuntu 22-04. I added the msi to steam from my downloads, hit start, failed right away like he said it would. changed compatability to proton experimental, and it opened right up.
- Download the official installer from pokemon tcg
- Add non steam game
- click show all file types
- navigate to downloaded msi
- click gear icon > compatability > proton experimental
- click play
- profit
Fields
Pydantic Docs · docs.pydantic.dev [1]
exclude=True and repr=False is a good pydantic combination for secret attributes such as user passwords, or hashed passwords. exclude keeps it out of model_dumps, and repr keeps it out of the logs.
from pydantic import BaseModel, Field
class User(BaseModel):
name: str = Field(repr=True)
age: int = Field(repr=False)
user = User(name='John', age=42)
print(user)
#> name='John'
References:
[1]: https://docs.pydantic.dev/2.7/concepts/fields/#field-representation
Hatch v1.10.0 - Hatch
hatch.pypa.io [1]
Hatch be flyin.
This new release of hatch includes support for the new package installer uv which is just mind blowing fast compared to anything else we have in python right now.
[tool.hatch.envs.default]
installer = "uv"
The other features are cool too, check them out. I’ll probably be using the test runner, but I’ve been waiting for the uv support since uv launched.
References:
[1]: https://hatch.pypa.io/latest/blog/2024/05/02/hatch-v1100/
External Link
loggly.com [1]
I had a boot issue on my sons fresh ubuntu 24.04 install and journalctl came in clutch.
journalctl -p 3 -xb
- -p 3 gives me priority 3
- -x gives me extra catalog information when available
- -b gives me the current boot.
References:
[1]: https://www.loggly.com/ultimate-guide/using-journalctl/
Bug #2006590 “gdm3 crashes with SIGTRAP on startup” : Bugs : gdm3 package : Ubuntu
Suddenly this week, my GUI (ubuntu 22.10) does not open, stuck on the console text.
I tried to free some space (by uninstall a app), then to check/update the paquets (dkpg).
ProblemType: Bug
Distr…
Launchpad · bugs.launchpad.net [1]
This Thread saved my son’s ubuntu 24.04 install.
His was failing to start with the following error.
Gdm: GdmSession: no session desktop files installed, aborting...
https://twitter.com/_WaylonWalker/status/1785825677079441482
sudo apt install --reinstall ubuntu-session
References:
[1]: https://bugs.launchpad.net/ubuntu/+source/gdm3/+bug/2006590
GitHub - Alir3z4/html2text: Convert HTML to Markdown-formatted text.
Convert HTML to Markdown-formatted text. Contribute to Alir3z4/html2text development by creating an account on GitHub.
GitHub · github.com [1]
Super neat tool to convert html [2] to markdown
>>> import html2text
>>>
>>> print(html2text.html2text("<p><strong>Zed's</strong> dead baby, <em>Zed's</em> dead.</p>"))
<!--markata-attribution-->
**Zed's** dead baby, _Zed's_ dead.
It even plays nicely with rich.
from rich.markdown import Markdown
from rich.console import Console
import html2text
console = Console()
md = Markdown(html2text.html2text("<p><strong>Zed's</strong> dead baby, <em>Zed's</em> dead.</p>"))
console.print(md)
References:
[1]: https://github.com/Alir3z4/html2text
[2]: /html/
-
Fantastic interview with Uncle Bob, really it was more of a 2 way conversation. So many of Uncle Bob’s takes have been taken out of context, its cool to hear some of the well actuallys, and the experience behind some of the reasoning.
External Link
medium.com [1]
Imagine waking up to a $1,300 for running an example project! That sounds like peanuts for a cloud bill but for an individual trying to learn that hits my monthly budget real hard.
That’s what happened to Marciej, make sure you check out the full article and give them a 👏 on Medium if you have an account.
The more I see things come out about aws, the more it makes me sick, and confirm my feelings that I cannot possibly use them for a side project without some real $$ planning to come out of it.
Yes, S3 charges for unauthorized requests (4xx) as well[1]. That’s expected behavior.
They offer no DDOS protection against 4xx or 5xx requests against your bucket. Absolutely bonkers that you have ZERO control over this.
---
This response just feels absolutely gross.
I notified the AWS security team. I suggested that they restrict the unfortunate S3 bucket name to protect their customers from unexpected charges, and to protect the impacted companies from data leaks. But they were unwilling to address misconfigurations of third-party products.
It sounds like this guy followed some default instructions for an example site, HOW MANY OTHERS have done th...
Media Types
iana.org [1]
A full list of standard Accept types.
This is a handy reference.
References:
[1]: https://www.iana.org/assignments/media-types/media-types.xhtml#text
![https://docs.pydantic.dev/2.7/api/networks/#pydantic [1].networks.EmailStr](/static/https://docs.pydantic.dev/2.7/api/networks/#pydantic [1].networks.EmailStr)
pydantic has a nice built in email validator EmailStr
It requires an optional pydantic dependency
pip install email-validator
Then you can validate email addresses.
from pydantic import BaseModel, EmailStr
class Model(BaseModel):
email: EmailStr
print(Model(email='[email protected]'))
#> email='[email protected]'
References:
[1]: /tags/pydantic/
[1]
This is my go to rich response container for clis written in python. It creates a nice box around the content on the screen and provides some nice separation in the output. It can be overdone, but comes in clutch when looking for that print statement in a long output.
References:
[1]: /static/https://rich.readthedocs.io/en/stable/reference/panel.html
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 ...