testdisk is an amazing command line utility (interactive tui) that just saved me a hard drive that was filled with data, but every machine that I plugged it into told me that it was completely unpartitioned.
Thoughts
Link based "commentary" style posts, commenting on a web link
I love rich inspect. It’s one of my most often used features of rich. It gives you a great human readable insight into python object instances.
>>> from rich import inspect >>> text_file = open("foo.txt", "w") >>> inspect(text_file)
I have a pyflyby entry for it so that I can just run it ang get automatic imports. To not clash with the standard library inspect, which is quite useful on it’s own, I have aliased it to rinspect.
And this is why we don’t run cdn in prod, respect your users who can’t control where the assets are stored. There are so many fast static hosting providers out there, if you are worried about performance reasons use one of those to self host.
A fantastic overview of the systemd cli.
Hacky solution to get zpool import tank to work on boot right away. This has been an issue that has plagued my system for months and no matter what dependencies I add in it never works, but adding a sleep as ExecStartPre did the trick.
In flask apps I often get a 404 for routes with a trailing slash. This Stack Overflow post shows how to configure flask to allow trailing slashes on some or all routes.
sed can be a tricky beast, I often stumble when trying to pipe into it. Next time I need to use sed, I should reference this article by Nick Janetakis. He makes it looks much easier than my experience has been, and it appears to behave like a vim :%s/ substitution does, or a g/ g command.
Getting request headers in fastapi has a pretty nice stetup, it allows you to get headers values as function arguments,
I was able to use headers to detect if a request was made from htmx or not.
If the request was made from htmx, then we want a html format, otherwise I’m probably hitting the api programatically from something like curl or python
1j01 created a complete working clone of ms paint in the terminal using the textual framework. It’s incredible.
Loved this explanation about all the recent lock down with RHEL from Jeff Geerling.
...
As the title states sqlite-utils now supports plugins. I dug in just a bit and Simon implemented this completely with entrypoints, no framework or library at all.
Great short explaination of session vs token authentication.
Getting form data inside of fastapi was not intuitive to me at first. Everything I had used in fastapi leaned on pydantic models. Form data comes in differently and needs collected differently.
I am creating this post from a desktop app that I created in 3 lines.
sqlalchemy server_defaults end up as defaults in the database when new values are inserted.
A feature of jinja that I just discovered is including sub templates. Here is an example from the docs.
{% include 'header.html' %} Body goes here. {% include 'footer.html' %}
And inside of my thoughts project I used it to render posts.
<ul id='posts'> {% for post in posts.__root__ %} {% include 'post_item.html' %} {% endfor %} </ul>
note that post_item.html automatically inherits the post variable.
A guide to add Jinja2Templates to fastapi.
A complete reference of all of the htmx swapping methods.
I am trying to use htmx on a new fastapi site for my thoughts, and have been hitting this error.
Mixed Content: The page at 'https://front.mydomain.com/#/clients/1' was loaded over HTTPS, but requested an insecure resource 'http://back.mydomain/jobs/?_end=25&_order=DESC&_sort=id&_start=0&client_id=1'. This request has been blocked; the content must be served over HTTPS.
What is happening #
I have an htmx component that gets the current users name, but if they are not logged in the backend redirects to a login form.
<div hx-get='/users/me' hx-trigger='load'> get me </div>
But for some reason when the front end gets this redirect, it tries to do it through http,...
...
On void linux. Under `/etc/containers/` there is a file called `registries.conf`. It is complemented by `man 5 containers-registries.conf`. Change (for me lines 11-12) which say [registries.search] registries = [] to
[registries.search] registries = ['docker.io']
Without the above you won’t be able to use basic Various documentation (redhat blog entries, ... (drawn from https://www.projectatomic.io/blog/2018/05/podman-tls/)
podman functions. You might get errors like:man podman pages) say that dockerhub is a default, but without this step it’s clearly not.Good luck. Feel free to use the comment box below if you have a github account.
Using templates with htmx requires the client-side-templates extension, and the template engine to be loaded in a <script> tag.
example htmx using templates.
Mounting static files in fastapi.
Love the poling example with hx-trigger=‘every 1s’.
Here is a snippet provided by @tiangolo to store the users jwt inside of a session cookie in fatapi. This was written in feb 12, 2020 and admits that this is not a well documented part of fastapi.
It’s already in place. More or less like the rest of the security tools. And it’s compatible with the rest of the parts, integrated with OpenAPI (as possible), but probably most importantly, with dependencies.
It’s just not properly documented yet. 😞
But still, it works 🚀 e.g.
Harlequin is a pretty sweet example of what textual can be used to create. Its a terminal based sql ide for DuckDB.
To persist data in duckdb you need to first make a connection to a duck db database.
con = duckdb.connect('file.db')
Then work off of the connection con rather than duckdb.
duckdb can just query any pandas dataframe that is in memory.
I tried running it against a list of objects and got this error. Great error message that gives me supported types right in the message.
pytest-subtests is a package to register multiple subtests within a similar test function.
A nice codepen reference for dark forms. I am using it for my thoughts chrome extension.
![[None]]
When setting up a new machine, vm, docker image you might be installing command line tools from places like pip. They will often put executables in your ~/.local/bin directory, but by default your shell is not looking in that directory for commands.
WARNING: The script dotenv is installed in '/home/falcon/.local/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
To solve this you need to add that directory to your $PATH.
export PATH=$PATH:~/.local/bin
To make this change permanant add this line to your shell’s init script, which is likely something like ~/.bashrc or ~/.zshrc.
Very inspiring textual project to check out how they set up the ui. Their intro video has a pretty epic dev experience.
wsrepl is an epic websocket repl built in python on the textual framework.
When fetching pydantic models from the database with sqlmodel, and you cannot select your item by id, you probably need to use a where clause. This is the sqlmodel way of doing it.
Here is a snippet of how I am using sqlmodel select and where to find a post by link in my thoughts database.
In order to turn url encoded links back into links that I would find in the database of my thoughts project I need to urldecode them when they hit the api. When anything hits the api it must urlencode the links in order for them to be sent correctly as data and not get parsed as part of the url.
Here is a snippet of how I am using urlib.parse.unquote to un-encode encoded urls so that I can fetch posts from the database.
In order to send data that includes special characters such as / in a url you need to url encode it. You have probably seen these many times in urls with things like %20 for spaces.
I’m working on a chrome extension to make quick blog posts, like thoughts or a persistent bookmark tool with comments. The backend is written in fastapi and when I check to see if I have a post for a page I need to url encode it.
curl -X 'GET' \ 'https://thoughts.waylonwalker.com/link/?link=https%3A%2F%2Fhtmx.org%2Fextensions%2Fclient-side-templates%2F' \ -H 'accept: application/json'
curl example generated from the fastapi swagger docs.
Here is how I used javascript’s
encodeURIComponentto turn my chrome extension into a notification when I already have a post for the current page.
Lately in 2023 I have been leaning on lazyvim for my new setups where I am not necessarily ready to drop my full config. It’s been pretty solid, and comes with a very nice setup out of the box, the docs are pretty fantastic as well.
Prime reviews an article with some hot takes about python being slow and quirky, but good enough for a lot of things. Especially data applications that have libraries written in C.
Such an inspiring clip from Kelsey Heightower. Make good shit that inspires people rather than fake ppts of how things could be.
Next time I’m working with large headers on small screens I need to try this. I always truggle to get them to look good for most text and overflow ridiculously long words correctly or at all.
Enable full-text search in sqlite using sqlite-utils.
I want to like jq, but I think Simon is selling me on sqlite, maybe its just me but this looks readable, hackable, editable, memorizable. Everytime I try jq, and its 5 minutes fussing with it just to get the most basic thing to work. I know enough sql out of the gate to make this work off the top of my head
insert a json array directly into into sqlite with sqlite-utils.
A nice cheat sheet for jq. jq looks so nice, but it so quickly gets overwhelming on how to select what you want. I was able to make a jq contains query.