The rich console is themeable, I’ve been a long time user of rich and had no
Idea. You can define your own theme keywords and use them just like you use
normal rich keywords in square brackets like'[bold red]'.
from rich.console import Console
from rich.theme import Theme
custom_theme = Theme({
"info": "dim cyan",
"warning": "magenta",
"danger": "bold red"
})
console = Console(theme=custom_theme)
console.print("This is information", style="info")
console.print("[warning]The pod bay doors are locked[/warning]")
console.print("Something terrible happened!", style="danger")
Posts tagged: python
All posts with the tag "python"
310 posts
latest post 2026-05-06
Publishing rhythm
The adapter pattern in python
The Adapter pattern is a design pattern that allows objects with incompatible interfaces to work together. It provides a way to convert the interface of an object into another interface that client...
Rob Parsons · robp.dev [1]
This has me wondering if I need to really learn more patterns, data structures, and algorithms. This looks particularly useful when trying to combine several objects that you dont have full control over and make them behave similarly.
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://robp.dev/the-adapter-pattern-in-python/
[2]: /thoughts/
I’m trying to replace my usage of google inline search apps with real apps,
today I used a stopwatch to time some things out at work by opening stopwatch.
This was something I just wanted running in a tab on another screen, it was not
timing running code or anything, I was using it as a reminder to check browser
caches every 5 minutes or so for some testing.
So tonight I whipped up a stopwatch [1],
clock [2] and timer [3], all of
which are using the wakelock API to keep the screen on while the app is
running.
// Wake Lock support
let wakeLock = null;
async function requestWakeLock() {
try {
if ('wakeLock' in navigator) {
wakeLock = await navigator.wakeLock.request('screen');
console.log("Wake lock acquired");
}
} catch (err) {
console.error("Wake lock error:", err);
}
}
document.addEventListener("visibilitychange", () => {
if (wakeLock !== null && document.visibilityState === "visible") {
requestWakeLock();
}
});
requestWakeLock();
References:
[1]: https://stopwatch.wayl.one
[2]: https://clock.wayl.one
[3]: https://timer.wayl.one
-
Excited to hear this story, they have so many key players in the trailer this will be fantastic.
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/
m9a devlog 1
It’s sad to see textualize.io close the doors, but textual is still alive and
maintained as a n open source project. I tried to use it very early, and
struggled, this was before docs and tutorials really existed, before a lot of
the widgets and components existed. Then as we all do I got busy and moved on
to other things in life and did not have the capacity to build TUIs.
I like tuis # [1]
I like tuis, I like staying in the terminal. I use
lf [2] daily to move files around when I
want something more than mv and cp. I use
k9s [3] hourly to monitor and manage my
kubernetes cluster.
Are they worth the effort?? # [4]
As awesome as tui’s are, they are more effort to build, and less automatable.
I feel like the first stage into automation of a project really needs to be a
good cli, and this is often good enough for the project and I move on.
m9a (em - nine - ah) # [5]
inspired by k9s
Like I said I really like k9s and use it all the time, It really makes running
kubectl commands a ...
fix feed descriptions
Today I fixed a bug in markata that has been occurring for a few months where
the description for posts come out as None if coming from cache, the issue was
a pretty simple check and pull properly from cache. This fixes all the
descriptions in feeds and metadata on the post.
Better description # [1]
While in there we went ahead and improved our get_description to more
accurately return plain text without escaped characters, remove cutoff words,
and add an elipsis if the description cuts off the text.
More description # [2]
While I was there I made longer form posts, til, blog-post use the super
description of 500 characters instead of the regular 120 character description.
Before # [3]
[4]
After # [5]
[6]
References:
[1]: #better-description
[2]: #more-description
[3]: #before
[4]: https://dropper.waylonwalker.com/api/file/8e9cf8e3-50ab-4e0a-be76-7241fbfe44c5.webp
[5]: #after
[6]: https://dropper.waylonwalker.com/api/file/29f96255-a89f-4ec6-b9e7-f61551366264.webp
I’ve been using ruff to lint my python code for quite awhile now, I was pretty
early to jump on it after release. Some of my projects have had a nice
force-single-line setting and some have not. I dug into the docs and it was
not clear what I needed to make it work.
[tool.ruff]
select = ['I'] # you probably want others as well
[tool.ruff.isort]
force-single-line = true
Turns out I was missing Isort in the select list.
-
Astral is doing great things in the python industry. They are disrupting entire categories of tools with extremely fast, easy to use, and feature rich alternatives that make it really hard to keep using the incumbent. So far I am seeing no signs of evil, sometimes with such a disrupter there is some sort of downside that make it hard to want to do the switch. In the interview they even mention things like leaning on lsp so that it works across all editors rather than building out vscode integrations that work for most developers. As a neovim user I greatly apreciate this.
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/
Playground | ty
An in-browser playground for ty, an extremely fast Python type-checker written in Rust.
types.ruff.rs [1]
ty, has a playground running at types.ruff.rs. You can edit code in there and see what the type checker results would be in browser. This looks good, excited to see it running in my lsp.
Here is an example where a Optional may not be defined.
[2]
Checking for existance before using it resolves the issue.
[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://types.ruff.rs/
[2]: https://dropper.waylonwalker.com/api/file/783e4d9e-8b23-4304-8921-2ae05aebcc8a.webp
[3]: https://dropper.waylonwalker.com/api/file/cc28335c-4130-4bf4-829d-0ff39f2aa32d.webp
[4]: /thoughts/
I was looking back at my analytics [1] page today and wondered what were my
posts about back at the beginning. My blog is managed by markata [2] so I
looked at a few ways you could pull those posts up. Turns out it’s pretty
simple to do, use the markata map with a filter.
from markata import Markata
m.map('title, slug, date', filter='date.year==2016', sort='date')
Note
the filter is python eval that should evaluate to a boolean, all of the
attributes of the post are available to filter on.
Result # [3]
[
('⭐ jupyterlab jupyterlab', 'jupyterlab-jupyterlab', datetime.date(2016, 12, 13)),
('⭐ nickhould tidy-data-python', 'nickhould-tidy-data-python', datetime.date(2016, 12, 9)),
(
'⭐ mikeckennedy write-pythonic-code-demos',
'mikeckennedy-write-pythonic-code-demos',
datetime.date(2016, 11, 22)
),
(
'⭐ mikeckennedy write-pythonic-code-for-better-data-science-webcast',
'mikeckennedy-write-pythonic-code-for-better-data-science-webcast',
datetime.date(2016, 11, 22)
),
('⭐ rajshah4 dlgroup', 'rajshah4-dlgroup', datetime.date(2016, 11, 18)),
('⭐ pandas-dev pandas', 'pandas-dev-pandas', datetime.date(2016, 10, 5))
]
You could use the list command as well right within y...
ty
An extremely fast Python type checker, written in Rust.
PyPI · pypi.org [1]
Astral is working on some great things around python, they have created a high standard for python tooling built on rust that works really well, runs fast and covers everything in the space it resides in. ty appears to be their linter coming soon.
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/ty/
[2]: /thoughts/
portal-platformer-devlog-1
Here is the current state of my platformer yet to really be named, I want to
make something in between hollow knight and portal.
Starting # [1]
I made one once in make code arcace on a pybadge. It was quick and dirty, but
fun to work on. It had the basic of blocks that I could move, blocks i could
put a portal onto, and a goal for each level. Some levels you can just walk
through and some levels required you to really think about where to place the
portal.
History # [2]
So this version of the game is a least 2 years in the making, I open it every
few months give it a day or two and move on. Its mostly something that I work
on with my son. He really likes to jump around on projects so its hard to make
real progress on something, but we are hitting an age where he is able to come
back to projects a little better.
All of this is built in python, and mostly before vibe coding [3] was a thing, its
mostly me trying to get out ideas as quick as my son is spitting out the the
next idea...
hotel_bookings.csv
Discover what actually works in AI. Join millions of builders, researchers, and labs evaluating agents, models, and frontier technology through crowdsourced benchmarks, competitions, and hackathons.
kaggle.com [1]
nice dataset to use for example / test projects. I’m using it to play with duckdb currently.
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://www.kaggle.com/datasets/ahmedsafwatgb20/hotel-bookingscsv?resource=download
[2]: /thoughts/
PyApp
ofek.dev [1]
I think I’m getting really close to having a good workflow setup for using pyapp. Such an amazing project to allow developers to create applications in python without passing on the hassle of python and managing installs to the user.
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://ofek.dev/pyapp/latest/
[2]: /thoughts/
I run tailwind for my personal blog, whenever I update it, pre-commit goes in
and fixes end of file. I’m sick of these things fighting each other, since it
is a generated app it is going to et ignored from pre-commit from now on.
exclude: ^static/app.*\.css$
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
Client Challenge
pypi.org [1]
python bindings for valkey, forked from redis.
one notable difference I see from redis is that you can install with libvalkey to autmatically get faster parsing support.
For faster performance, install valkey with libvalkey support, this provides a compiled response parser, and for most cases requires zero code changes. By default, if libvalkey >= 2.3.2 is available, valkey-py will attempt to use it for response parsing.
pip install "valkey[libvalkey]"
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/valkey/
[2]: /thoughts/
[1]
Migrating from kedro 0.18.4 to the latest version involves handling the deprecated OmegaConf loader. Switching over does not look as bad as I originally thought.
- installing kedro 0.18.5+
- set the CONFIG_LOADER_CLASS in settings.py
- swap out import statements
- config must be yaml or json
- getting values from config must be done with bracket __getattr__ style not with .get
- any Exceptions caught from Templated config loader will need to be swapped to OmegaConfig exceptions, similar to #3
- templated values must lead with an _
- Globals are handled different
- OmegaConfig does not support jinja2 sytax, but rather a ${variable} syntax
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://docs.kedro.org/en/stable/configuration/config_loader_migration.html
[2]: /thoughts/
markata search
A side effect of Markata DidYouMean [1] is that we are able to implement some
rudimentary search based on slug, title, tags, and description.
[2]
I made a video of the early work on using this side effect to search for content on markata.dev.
Replay markata-search-1.mp4 [3]
This was first implemented to solve 404 pages giving users a way to try to find
the page that they tried to access. But it turned out to be a decent way to
search through the docs.
References:
[1]: /markata-didyoumean/
[2]: https://dropper.waylonwalker.com/api/file/50cfa8dc-9d46-4f02-877b-688fa5510a83.png
[3]: https://dropper.waylonwalker.com/api/file/fd677374-5ef1-41c7-8845-6de0e10f224b.mp4
Markata DidYouMean
Coming in Markata 0.9.1 is far better documentation. i.e. Documentation that
actually exists for everything. As part of poking around I realized that I
often go to look up the docs for a plugin and forget that the path is
/markta/plugins/feeds, sometimes I might try /markata/feeds or
/plugins/feeds.py or /feeds or I might even forget the plugin name exactly
and try something like feed and get a 404. So I added a didyoumean plugin
to markata that takes care of this.
[1]
I made a quick recording of this early feature, pay close attention to the url
as it automatically updates to the correct page.
markata-didyoumean.mp4 [2]
Happy Path # [3]
direct forward
If you have one post called /markata/plugins/feeds, and it is the only post
called feeds, any combination of /markata/feeds or /plugins/feeds or
/feeds will all automatically redirect with an html [4] page (not a server 3xx)
to the /markata/plugins/feeds post.
Here is the snippet that does the redirect.
<div class="container ...
Models
Pydantic Docs · docs.pydantic.dev [1]
I came accross from_attributes today it allows creation of pydantic models from objects such as a sqlalchemy Base Model or while nesting pydantic models. I believe in the past I have ran into some inconsistencies with nesting pydantic models and I’ll bet one had from_attributes set and another did not.
Arbitrary class instances¶
(Formerly known as “ORM Mode”/from_orm).
Pydantic models can also be created from arbitrary class instances by reading the instance > attributes corresponding to the model field names. One common application of this functionality is integration with object-relational mappings (ORMs).
To do this, set the from_attributes config value to True (see the documentation on Configuration for more details).
The example here uses SQLAlchemy, but the same approach should work for any ORM.
Note
This post is a thought [2]. It’s a short note that I make
about someone else’s content online #thoughts
References:
[1]: https://docs.pydantic.dev/latest/concepts/models/#rebuilding-model-schema
[2]: /thoughts/