I am starting to build out some custom tool holders for my tool box, and using gridfinity. This is a super handy reference guide for spec’ing out the bases.
Posts tagged: thought
All posts with the tag "thought"
Today I was running some sqlmodel queries through the sqlalchemy orm. Admittedly I’ve not done enough orm queries before, and I’ve done quite a bit of raw sql. I was trying to get objects from two separate models that had relationships setup.
session.query(User, Images).where(User.id == 3).all()
It is incredibly slow, and gives me the following warning.
SELECT statement has a cartesian product between FROM element(s)
What I learned from the SQLModel docs is that you should give it a join to correct this and go much faster.
html code generated by my jinja templates generally look half garbage because of indents and whitespace all over the place. I just learned about these pesky Whitespace Control characters that can get rid of the whitespace added from templating.
You can also strip whitespace in templates by hand. If you add a minus sign (-) to the start or end of a block (e.g. a For tag), a comment, or a variable expression, the whitespaces before or after that block will be removed:
I just learned that if you can exec into the container running minecraft with the itzg/minecraft container you can run rcon-cli to get command access to the server. You need to set the RCON_PASSWORD if you want to access rcon remotely, but if you have not already done this and have access to the server you can just run rcon-cli when you are in.
Theo’s response puts a lot of my feelings about unit testing into words. It’s crazy how cargo culty it becomes that the echo chamber of twitter can bring in beliefs that we think we believe, but have not experienced enough or put enough thought in to form our own opinion.
This video made me think so much that it turned into it’s own blog post
Mastadon.py is a python api client for mastadon that makes it easy to cross post to mastadon.
bunny.net looks like an interesting cloudflare alternative.
This is a sick guided site to validate indieweb tags on your site. It makes it much easier than trying to do it yourself.
After struggling to get dependencies inside of middleware I learned that you can make global dependencies at the app level. I used this to set the user on every single route of the application without needing Depend on getting the user on each route.
This page shows how to customize your fastapi 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.
Setting an additional log handler to the uvicorn logger for access logs in fastapi was not straightforward, but This post was very helpful.
Setting tags in your fastapi endpoints will group them in the docs. You can also set some metadata around the tags to get nice descriptions.
Here is a full example from the post.
Most bloggers on my twitter blog right into a file that goes on git. I kinda expected to have more database folk. I have my blog in markdown on git and the editing experience is top notch. I can just find files edit them in MY EDITOR, push them and I got a post. I am running thoughts in a sqlite database with a fastapi backend, and holy crap the instant nature of posting feels so much better. Both sides have good points.
I often want to reach for non existing list comprehensions in jinja 2, Here are a few nice equivalents.
Environment:
I fixed my missing macro recording indicator that I lost and was never quite sure why. (because I forgot that I set cmdheight=0).
...
DataDog ddqa is building out a textual app and deploying it with pyapp. They have CI setup to fully build and cross compile their textual tui into github releases that you can just download from their releases page. This is something I am looking at for markata. This would be pretty sweet to be able to make it just work on places like windows. It would also be interesting to try to build a full desktop app with pyapp.
Full list of imagemagick color names.
I’m going to give this trick a shot on my sites, and see how I like it.
* { min-width: 0 }
Down in the comments @adamwathan goes on to say.
Basically every layout overflow bug ever boils down to some flex or grid child needing min-width: 0 😄
Oh and @ryanflorence also says in the comments.
...
Nice message by @tusharsadhwani.
Write it down.
You had to dig deeper than face value at something.
Write it down.
...
Excluding routes from fastapi docs, can be done from the route configuration using `include_in_schema`. This is handy for routes that are not really api based or duplicates.
From the Docs #
from fastapi import FastAPI app = FastAPI() @app.get("/items/", include_in_schema=False) async def read_items(): return [{"item_id": "Foo"}] trailing slash #
I’ve had better luck just routing both naked and trailing slash routes in fastapi. I’ve had api’s deployed as a subroute to a site rather than a subdomain, and the automatic redirect betweens them tended to always get messed up. This is pretty easy fix for the pain is causes just give vim a yyp, and if you don’t want deuplicates in your docs, ignore one.
...