External Link
stackoverflow.com [1]
Another interesting option for slow count queries in sqlite.
If you haven’t DELETEd any records, doing:
SELECT MAX(ROWID) FROM "table" LIMIT 1;
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://stackoverflow.com/questions/8988915/sqlite-count-slow-on-big-tables
[2]: /thoughts/
Posts tagged: thought
All posts with the tag "thought"
866 posts
latest post 2026-05-25
Publishing rhythm
Optimizing SQLite for servers
SQLite is often misconceived as a "toy database", only good for mobile applications and embedded systems because it's default configuration is optimized for embedded use cases, so most ...
Sylvain Kerkour · kerkour.com [1]
Very interesting article by Sylvain, suggested by Simon Willison.
Definitely some things that I want to come back and try later on.
Here is the TLDR of the whole post
PRAGMA journal_mode = WAL;
PRAGMA busy_timeout = 5000;
PRAGMA synchronous = NORMAL;
PRAGMA cache_size = 1000000000;
PRAGMA foreign_keys = true;
PRAGMA temp_store = memory;
This is interesting, and something I need to consider. I definitely have an application with slow count queries. I am not sure how to make it better as its not a full count(*) so a count table doesn’t work, nor does counting by index.
I might need to have a table of cached results, and if a write matches the counter increase it, or update all counters on write.
COUNT queries are slow
SQLite doesn’t keep statistics about its indexes, unlike PostgreSQL, so COUNT queries are slow, even when using a WHERE clause on an indexed field: SQLite has to scan for all the matching records.
One solution...
-
Inspiring story transitioning into tech from nursing. I also came to tech through a set of circumstances that made it difficult for me to excel at my current job. Looking back it is something that I was always interested in and I was just unsure how to get in, I am so glad that I figured it out, it has been such a great benefit to my family.
I really enjoyed listening to trshpuppy’s journey in through building projects, and choosing tech not based on what she wanted to learn, but what fit the project the best.
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/
Some Git poll results
Some Git poll results
Julia Evans · jvns.ca [1]
great poll of git [2] questions
poll: did you know that in a git merge conflict, the order of the code is different when you do a merge/rebase?
merge:
<<<<<<< HEAD
YOUR CODE
OTHER BRANCH’S CODE
c694cf8aabe
rebase:
«««< HEAD
OTHER BRANCH’S CODE
YOUR CODE
d945752 (your commit message)
This one explains a lot. I think I knew this, I might have seen it somewhere, but I have definitely noticed it go both ways and confuse the crap out of me. Feels very similar to how --ours and --theirs flip flops.
Note
This post is a thought [3]. It’s a short note that I make
about someone else’s content online #thoughts
References:
[1]: https://jvns.ca/blog/2024/03/28/git-poll-results/
[2]: /glossary/git/
[3]: /thoughts/
External Link
sealed-secrets.netlify.app [1]
kubeseal is a pretty simple to get started with way to manage secrets such that they can be stored in a git [2] repo and be picked up by your continuous delivery service.
Sealed Secrets provides declarative Kubernetes Secret Management in a secure way. Since the Sealed Secrets are encrypted, they can be safely stored in a code repository. This enables an easy to implement GitOps flow that is very popular among the OSS community.
Note
This post is a thought [3]. It’s a short note that I make
about someone else’s content online #thoughts
References:
[1]: https://sealed-secrets.netlify.app/
[2]: /glossary/git/
[3]: /thoughts/
-
Great episode covering a seemingly simple topic. What I really benefitted from was hearing all the different use cases, from logging, debugging, to a/b testing, caching, and auth. I hadn’t even thought of it being applied to a router. I thought of it being applied for an entire application. This seems very useful for things like an admin router, all routes would need to have the admin role to get in.
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/
![[None]]
I’ve been using these decorators to modify the behavior of specific routes. It will do things like 404 admin only routes in a way that looks just like fastapi [1]’s default, or only allow certain roles into the route, or redirect unauthenticated users to login.
After listening to yesterday’s syntaxfm I’m now really thinking about middleware and the benefits it might have. middleware would make it easy to apply things like admin to an entire admin router, so you wont forget it on any one admin route. It will look cleaner as the admin checker is only applied once per router, not once per route.
import inspect
import time
from functools import wraps
from inspect import signature
from fastapi import Request
from fastapi.responses import FileResponse, JSONResponse, RedirectResponse
from starlette import status
from fokais.config import get_config
from fokais.models.user import Role
config = get_config()
admin_routes = []
authenticated_routes = []
not_cached_routes = []
cached_routes = []
def not_found(request):
hx_request_header = request.headers.get("hx-request")
user_agent = request.headers.get("user-agent", "").lower()
if "mozilla" in user_agent or "webkit" i...
External Link
X (formerly Twitter) · twitter.com [1]
Huh, so this is just built right into the chrome cli.
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
--headless \
--screenshot=/tmp/shot1.png \
https://simonwillison.net
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://twitter.com/simonw/status/1772043579231445366
[2]: /thoughts/
![[None]]
jinja’s url_for in fastapi [1] does not account for https by default, there is
probably a better way, but this is a way that allows me to configure when I use
http vs https.
@pass_context
def https_url_for(context: dict, name: str, **path_params: Any) -> str:
"""
always convert http to https
"""
request = context["request"]
http_url = request.url_for(name, **path_params)
return str(http_url).replace("http", "https", 1)
def get_templates(config: BaseSettings) -> Jinja2Templates:
templates = Jinja2Templates(directory="templates")
templates.env.globals["https_url_for"] = https_url_for
## only use the default url_for for local development, for dev, qa, and prod use https
if os.environ.get("ENV") in ["dev", "qa", "prod"]:
templates.env.globals["url_for"] = https_url_for
console.print("Using HTTPS")
else:
console.print("Using HTTP")
return templates
Note
This post is a thought [2]. It’s a short note that I make
about someone else’s content online #thoughts
References:
[1]: /fastapi/
[2]: /thoughts/
External Link
X (formerly Twitter) · twitter.com [1]
Damn are one time paid and have it apps making a comeback? Seems like the perfect thing to have someone else automate and not pay a subscription for.
Genius Idea Cassidy!!
Now what do you call this, its not software as a service, is this just sofware?
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://twitter.com/cassidoo/status/1770900985382138291
[2]: /thoughts/
![[None]]
import logging
from typing import List
import strawberry
from fastapi import FastAPI
from strawberry.fastapi import GraphQLRouter
logger = logging.getLogger(__name__)
authors = {}
books = {}
book_authors = {}
authors_books = {}
def get_author_for_book(root) -> "Author":
return authors[book_authors[root.id]]
@strawberry.type
class Book:
id: int
title: str
author: "Author" = strawberry.field(resolver=get_author_for_book)
def get_books_for_author(root) -> List[Book]:
print(f"getting books for {root}")
return [books[i] for i in authors_books[root.id]]
@strawberry.type
class Author:
id: int
name: str
books: List[Book] = strawberry.field(resolver=get_books_for_author)
authors = {1: Author(id=1, name="Michael Crichton")}
books = {1: Book(id=1, title="Jurassic Park")}
# relationships
book_authors[1] = 1
authors_books[1] = [1]
def get_author_by_id(id: int) -> Author:
return authors.get(id)
def get_book_by_id(id: int) -> Book:
return books.get(id)
def get_authors(root) -> List[Author]:
return authors.values()
def get_books(root) -> List[Book]:
print(books)
print(authors)
print(book_authors)
print(authors_books)
return books.values()
@strawberry.typ...
Joining the split keyboards club: a Moonlander story | Carlos Becker
This post will describe my experience with a couple of firsts:
carlosbecker.com [1]
I switched from a 60% vortex pok3r to a 40% corne June, 2021. I can relate to a lot of what Carlos talks about here. I think going from 60%-40% made my journey harder than it needed to be. There’s no going back now, but it took me a really long time to be able to hit all of the numbers and symbols, just figuring out how to do the layout was hard there’s not much space.
I didn’t touch type. I never really used my pinkies, except maybe for ESC, Shift, CTRL, Backspace et al.
I can relate to this, my typing habits were terrible. Shortly before going split ortho I worked on my speed with lots, and lots of practice on keybr and monkeytype. I took my speed from 35wpm to 80wpm with a few months of steady practice. This is one of the best things I did for myself.
Once I got split it dropped down to single digits and slowly rose back up to 80, just barely breaking my PB on monkeytype.
I still feel like I still can’t type at my previous max speed — mostly because I wasn’t used to use my pinky and used the “wrong finger” for a lot of...
My workflow, part 1 | Carlos Becker
I keep getting asked how my setup works, how I use tmux and
nvim over ssh… all that good stuff.
carlosbecker.com [1]
Carlos has a pretty sick setup here, I can relate to mostly, cept the macos part. My main critique is that I don’t think he gave window managers much chance on linux, and they just don’t work on MacOS/Windows.
Most of the time I have a single, maximized window.
I can relate to this. I should really make a full post about my experience with tiling window managers. TLDR, I came for tiling and I stayed for the workspaces.
Multiple Displays
An exception here could be streaming: having multiple displays can help preventing doxing yourself if you only share the screen of one of them. I only did stream like 3 times and that’s what I did, but I’m sure experienced streamers have better workflows (with or without multiple displays).
Accurate, my home machine uses one monitor, and for work I use one monitor+laptop. I pair, screenshare, and present quite a bit at work, and its good to have one screen for sharing, and one for seeing things like the app you are sharing from (chat, cams, etc)
Note
This post is a thought [2]. It’s a sh...
Using Netlify Analytics to Build a List of Popular Posts
Writing about the big beautiful mess that is making things for the world wide web.
blog.jim-nielsen.com [1]
This is a sick feature of Jim’s blog, I am really inspired by this. I am not sure how to do it for my own. I honestly think the easiest non locked in way would be to just use google search console results. It’s definitely a different way to think about it, but most of my traffic is coming from google search, so it would be a pretty good ballpark estimate.
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://blog.jim-nielsen.com/2020/using-netlify-analytics-to-build-list-of-popular-posts/
[2]: /thoughts/
605: Jim Nielsen on Subversive URLs, Blogging + AI, and Design Engineers
Jim Nielsen joins us to about URLs and linking as the new subversive way to maintain the web, paying for news in Canada, should content creators be worried about AI, the case for design engineers, …
ShopTalk · shoptalkshow.com [1]
An absolute fantastic episode about blogging, thinking about a web1.0 kind of world today, and what it means moving forward.
Web 1.0 is robust, you own your own destiny, you own your data, you can do what you want. There is no platform to tell you what you can and cannot do. But the future web is stealing your data to build AI models, spam sites are duplicating your content and stealing your SEO. You may or may not care, but at the end whether you get traffic or now you own your web 1.0 sites.
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://shoptalkshow.com/605/
[2]: /thoughts/
Configure Liveness, Readiness and Startup Probes
This page shows how to configure liveness, readiness and startup probes for containers.
For more information about probes, see Liveness, Readiness and Startup Probes.
Before you begin You need to h...
Kubernetes · kubernetes.io [1]
What is the difference between health, liveness, readiness, and startup? This article does a great job at a full writeup description of how it works in kubernetes, here is my TLDR.
-
health 200 OK - I’m still responding to requests
-
health ERR - something happened and I cant respond to requests
-
liveness 200 OK - I’m ready for more work
-
liveness ERR - I’m still responding to requests, and i’m already working send requests to another pod, or scale up
Z-pages # [2]
These probes are commonly deployed at /healthz and /livez endpoints.
Why the z?
z is a convention that comes from google for meta endpoints to reduce conflict with actual endpoints, and can be deployed to any application.
Note
This post is a thought [3]. It’s a short note that I make
about someone else’s content online #thoughts
References:
[1]: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readin...
External Link
stackoverflow.com [1]
The convention of “z-pages” comes from google and reduces the likelihood of collisions with application endpoints and keep the convention across all applications.
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://stackoverflow.com/questions/43380939/where-does-the-convention-of-using-healthz-for-application-health-checks-come-f
[2]: /thoughts/
Placehold
Placehold is a simple, fast and free image placeholder service to generate SVG, PNG, JPEG, GIF, WebP and AVIF placeholder images for your project.
placehold.co [1]
This is a handy placeholder generator for generating placeholder items like images, and videos.
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://placehold.co/
[2]: /thoughts/
![[None]]
I figured out the killer combination for python lsp servers, ruff and jedi! ruff does all of the diagnostics and formatting, then jedi handles all the code objects like go to definition and go to reference.
local servers = {
ruff_lsp = {},
jedi_language_server = {},
}
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/
Client Challenge
pypi.org [1]
Underrated python library to on board ruff, or just use it on a project where its not the norm. ruff claims that its 99.9% compatible with black and when you read through the known differences they are clearly edge case bugs in black.
See this page for more about the comparison to black https://docs.astral.sh/ruff/faq/#how-does-ruffs-formatter-compare-to-black
oh and I just noticed that it is maintianed by Charlie, and comes straight out of astral.
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/flake8-to-ruff/
[2]: /thoughts/