sqlite-utils now supports plugins sqlite-utils 3.34 is out with a major new feature: support for plugins. sqlite-utils is my combination Python library and command-line tool for manipulating SQLite databases. It recently celebrated... Simon Willison’s Weblog · simonwillison.net 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.
Thoughts
Link based "commentary" style posts, commenting on a web link
Publishing rhythm
Great short explaination of session vs token authentication.
Form Data - FastAPI FastAPI framework, high performance, easy to learn, fast to code, ready for production fastapi.tiangolo.com 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.
Column INSERT/UPDATE Defaults — SQLAlchemy 1.4 Documentation docs.sqlalchemy.org sqlalchemy server_defaults end up as defaults in the database when new values are inserted.
Template Designer Documentation — Jinja Documentation (3.1.x) jinja.palletsprojects.com A feature of jinja that I just discovered is including sub templates. Here is an example from the docs. And inside of my thoughts project I used it to render posts. note that post_item. html automatically inherits the post variable.
Templates - FastAPI FastAPI framework, high performance, easy to learn, fast to code, ready for production fastapi.tiangolo.com A guide to add Jinja2Templates to fastapi.
</> htmx ~ Documentation 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 A complete reference of all of the htmx swapping methods.
External Link stackoverflow.com I am trying to use htmx on a new fastapi site for my thoughts, and have been hitting this error. 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. But for some reason when the front end gets this redirect, it tries to do it through http, and flags it as insecure. The solution # To solve this issue, the post directs to set the to ‘*’
gistfile1.txt text [registries.search] registries = ['docker.io'] functions. You might get errors like: Various documentation (redhat blog entries, pages) say that dockerhub is a default, but without this step it’s clearly not. By default podman will not pull images from docker.io and will need setup. This guide worked for me.
External Link htmx.org Using templates with htmx requires the client-side-templates extension, and the template engine to be loaded in a tag. example htmx using templates.
Static Files - FastAPI FastAPI framework, high performance, easy to learn, fast to code, ready for production fastapi.tiangolo.com Mounting static files in fastapi.
#javascript" playlabel="Play: HTMX looks pretty neat #coding #javascript "> Love the poling example with hx-trigger=‘every 1s’.
First-class session support in FastAPI · Issue #754 · fastapi/fastapi Is your feature request related to a problem All of the security schemas currently supported by FastAPI rely on some sort of "client-server synergy", where, for instance, the client is expected to... GitHub · github.com 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.
External Link duckdb.org 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. Then work off of the connection rather than.
Redirecting… duckdb.org 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 unittest subTest() support and subtests fixture PyPI · pypi.org 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 directory, but by default your shell is not looking in that directory for commands. To solve this you need to add that directory to your $PATH. To make this change permanant add this line to your shell’s init script, which is likely something like or.
GitHub - doyensec/wsrepl: WebSocket REPL for pentesters WebSocket REPL for pentesters. Contribute to doyensec/wsrepl development by creating an account on GitHub. GitHub · github.com Very inspiring textual project to check out how they set up the ui. Their intro video has a pretty epic dev experience.
https://t.co/km5m7k6Pb0 #doyensec #appsec #websockets #burpsuite" loading=“lazy”> Doyensec (@Doyensec) on X Announcing wsrepl, the WebSocket testing tool from Doyensec! This intuitive tool is super easy to use and makes automation around WebSockets simple! Check out our blog for the details and download… X (formerly Twitter) · twitter.com wsrepl is an epic websocket repl built in python on the textual framework.
Filter Data - WHERE - SQLModel SQLModel, SQL databases in Python, designed for simplicity, compatibility, and robustness. sqlmodel.tiangolo.com 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.
URL Decoding query strings or form parameters in Python | URLDecoder URL Decode online. URLDecoder is a simple and easy to use online tool for decoding URL components. Get started by typing or pasting a URL encoded string in the input text area, the tool will automa... urldecoder.io 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.
encodeURIComponent() - JavaScript | MDN The encodeURIComponent() function encodes a URI by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will... MDN Web Docs · developer.mozilla.org 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 example generated from the fastapi swagger docs. Here is how I used javascript’s to turn my chrome extension into a notification when I already have a post for the current page.
🛠️ Installation | LazyVim You can find a starter template for LazyVim here lazyvim.org 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.
@changelog) on X — 🗣️ @kelseyhightower on his demos: That happy path gets people out of their chairs. They’re going back to the computer, like: “Yo, I’m gonna try it right now.” Come on… I’d rather have that. And I’ll take the bit of criticism that comes with it." loading=“lazy”> Changelog ( @changelog) on X 🗣️ @kelseyhightower on his demos: That happy path gets people out of their chairs. They’re going back to the computer, like: “Yo, I’m gonna try it right now.” Come on… I’d rat… X (formerly Twitter) · twitter.com Such an inspiring clip from Kelsey Heightower. Make good shit that inspires people rather than fake ppts of how things could be.
@chriscoyier) on X — I was unaware of `text-wrap: pretty;` I knew about the (new/cool) — but sometimes that's a bit… too much. I feel like it's nice on headers but not smaller type. Here's what I mean." loading=“lazy”> Chris Coyier ( @chriscoyier) on X I was unaware of I knew about the (new/cool) — but sometimes that's a bit… too much. I feel like it's nice on headers but not smaller type. Here's w… X (formerly Twitter) · twitter.com 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.
Full-text search - Datasette documentation docs.datasette.io Enable full-text search in sqlite using sqlite-utils.
sqlite-utils command-line tool - sqlite-utils sqlite-utils.datasette.io 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
sqlite-utils command-line tool - sqlite-utils sqlite-utils.datasette.io insert a json array directly into into sqlite with sqlite-utils.
LZone LZone - Cheat Sheets for Sysadmin / DevOps / System Architecture lzone.de 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.