[0]: https://lxml.de/lxmlhtml.html#creating-html-with-the-e-facto...
[1]: https://ricardoanderegg.com/posts/python-build-html-componen...
4,355 karma · joined March 16, 2020
ricardoanderegg.com
Twitter: [at] ricardoanderegg Contact: hn [at] polyrand [dot] net
[0]: https://lxml.de/lxmlhtml.html#creating-html-with-the-e-facto...
[1]: https://ricardoanderegg.com/posts/python-build-html-componen...
One trick I use[1] is adding certain characters before the section name. e.g:
¡¡ settings
This makes searching and jumping between sections a lot easier.[0]: https://en.wikipedia.org/wiki/Literate_programming
[1]: https://ricardoanderegg.com/posts/write-apps-in-single-file/
I think they are worth for more complex apps (I actually have a draft blog post with some experiments I did using PEX + gunicorn), but for my use case, it's not worth the effort when I only need the standard library.
rsync
chmod +x
"just works". UPDATE ... SET status = 'locked' ... RETURNING message_id
Or you can just use an IMMEDIATE transaction, SELECT the next message ID to retrieve, and UPDATE the row.On top of that, if you want to be extra safe, you can do:
UPDATE Queue SET status = 'locked' WHERE status = 'ready' AND message_id = '....'
To make sure you that the message you are trying to retrieve hasn't been locked already by another worker.[0]: https://github.com/litements/litequeue/
[1]: https://github.com/litements/litequeue/blob/3fece7aa9e9a31e4...
* Desktop app not focusing correctly when opening it
* Browser extension asking to save password even if it's already there
* Log-In suggestions not showing
* Slow and laggy on iOS
* Biometrics log-in breaks half of the times I try to use it
I like the fact it's open-source, although that doesn't make it more secure, and I don't think I would like to self-host.
[0]: Also maintainer of https://github.com/LaurentMazare/tch-rs
Yes, there's overhead in starting a new process to "just call a function", but I think this approach is still underutilized.
[0]: https://github.com/vercel/turbo/blob/c0ee0dea7388d1081512c93...
From the SQLite docs:
When a SAVEPOINT is the outer-most savepoint and it is not within a BEGIN...COMMIT then the behavior is the same as BEGIN DEFERRED TRANSACTION
Internally, the .dump command only runs SELECT queries.[0]: https://github.com/sqlite/sqlite/blob/3748b7329f5cdbab0dc486...
A mix of tutorials and interesting things I learn or discover. Most of the posts involve Python, SQLite or both.
Some of my favourite posts.
- Extending SQLite with Rust. The basics of writing a SQLite extension in Rust.
https://ricardoanderegg.com/posts/extending-sqlite-with-rust...
- Building a remote SQLite explorer. TL;DR: SSH tricks to turn SQLite into a networked DB.
https://ricardoanderegg.com/posts/sqlite-remote-explorer-gui...
- Using SQLite for logging and ad-hoc profiling (SQLite is a powerful JSON database!)
https://ricardoanderegg.com/posts/sqlite-logging-profiling-p...
- Learning about Bloom Filters by creating one. There are a ton of posts about implementing a bloom filter, but it was super fun to write one from scratch.
https://ricardoanderegg.com/posts/understanding-bloom-filter...
And my favourite one:
- Heroku-style deployments with Docker and git tags. I tried to create a deployment system where I could just `git push production`. It covers a bit of everything, git, docker, Caddy, blue-green deployments, git hooks, curl, etc.
https://ricardoanderegg.com/posts/git-push-deployments-docke...
[0]: https://github.com/python/cpython/blob/3fb7c608e5764559a718c...
[1]: https://docs.python.org/3.12/library/sqlite3.html#command-li...
[0]: https://news.ycombinator.com/item?id=34647121
[2]: Even for the languages that support WASM, you usually have to deal with incompatible dependencies, properly configuring your compiler, etc.
> or not GNU flavor not sure
On my macOS laptop
which make
# /usr/bin/make
/usr/bin/make --version
# GNU Make 3.81
> doesn’t support parallel tasks by defaultI haven't verified this. I've checked `make --help` using the built-in make on my Mac (GNU Make 3.81), it mentions the `--jobs` option to run multiple jobs in parallel.
I agree my setup is not simple (or even recommended as the default), that's why I call them "tricks".
> you can wire up your imports and script entry points in poetry, and manage venvs there too. Or just use pyenv-virtualenv if you’re on MacOS to auto-use your per-project venv.
As someone who has tried most of the current Python tools (including poetry and pyenv), I wouldn't say that "wiring up" imports and entry points is much simpler or footgun-free. It also requires using specific tools, which may not be possible depending on the project.
Also, multiple venvs is not equivalent, since you still need to manage those venvs and install the packages (+ dependencies). The `PYTHONPATH` trick can save a lot of time when the dependency tree is complex, and you just want a single venv.
For example, a workflow like:
git worktree add -b feature_one
#
# edit some files
#
BRANCH=feature_one make run-service
# in a different terminal, assuming `master` is also checked-out as a worktree
BRANCH=master make run-service
With the `PYTHONPATH` trick, you can do this in a few seconds. Now you have the same service running two different versions of your package, without having to reinstall anything or caring about using the correct venv.Again, I know this is a hack and it can be very project-specific. But it has worked great for me, and maybe it can be helpful to others.
* It can't run tasks in parallel
* It doesn't handle file dependencies. i.e: it's just a task runner, not a build tool.
* It's another tool you have to install, make comes pre-installed in most UNIX-like operating systems.
I've looked into pydoit multiple times and I would love to try it. There are a few reasons that make me go back to make (no pun intended!).
* It comes pre-installed on most UNIX operating systems. Yes, macOS ships an older version, but it works in most cases. This makes bootstrapping projects easier. * I like how simple it's to get started with a Makefile when you just need a few tasks. Although I admit, big Makefiles can become hard to maintain.
I've recently experimented with using Makefiles as an ETL orchestrator, and it's becoming quite messy. I believe pydoit is the perfect replacement candidate. I just haven't had time to try it.
Edit:
Another thing I like about Makefiles is that you can keep the "hackiness" of shell scripts, manipulate the environment [0], etc. I guess you can do the same with other tools, but I find it easier to reason about those useful "hacks" in Makefiles.
[0]: https://ricardoanderegg.com/posts/makefile-python-project-tr...
https://github.com/duckdb/duckdb/pull/6725
I've been using DuckDB for filtering and post-processing data, specially strings, and this will make writing complex queries easier. By combining nested functions[0] and text functions[1], sometimes I don't even need to go into a Python notebook.
As another "performance" trick, I was using multiple CTEs with the `RETURNING` clause to execute multiple operations in a single query.
Everything was OK when I was working on that app daily. But then I stopped working on it for a few months, and when I came back, I regretted using those tricks. For example, now I need to verify the triggers to make sure that changing a value won't change other tables that I forgot about. Also, I can't compose the SQL queries I wrote because each query does "everything at once". I would have rather paid the cost of doing 3 queries, and in exchange I could have reused some of those queries in different parts of the application [^1].
Of course, the app didn't even get close to the scale at which 1 query vs. 3 queries matter.
I still appreciate and like having some business logic in the DB, specially `CHECK` constraints. But the tooling for regular programming languages makes everything easier. Having the logic in the DB is a double-edged sword.
[^1]: This can become relevant when building an admin interface/CLI, since you may want to execute partial changes vs. the "everything at once" changes in the user-facing application.
[0]: https://www.sqlite.org/src/doc/begin-concurrent/doc/begin_co...