Programming Leftovers
-
Xe's Blog ☛ Function calling in large language models
This was a full-length (20m) talk at the React/Remix meetup in San Francisco in early June 2024. It's taken me a bit to get this uploaded here because I've been busy with work and other things.
-
Aadi Desai ☛ Go-Chat, adding chat history
Adding a SQL database was immediately the easiest option, there are various great guides on using SQL in Go, and I had previously used a database to store long-lived application state in nanobot. For such a simple and lightweight program, spinning up a PostgreSQL container would be massively overkill. Enter SQLite: "a small, fast, self-contained, high-reliability, full-featured, SQL database engine". In other words, an easy way for the server binary itself to read/write to a database file on-disk with little overhead.
-
James G ☛ Pattern: Software hooks
A hook API allows you to run code before or after defined parts of a system. A famous implementation of hooks can be found in the Git version control system. In Git, you can define a range of hooks that run at different times (i.e. pre-commit, pre-push, post-commit). For example, pre-commit hook runs before your code has been committed to a repository. You may use a pre-commit hook to automatically run a linter on a codebase.
-
James G ☛ My (new) website build process
When I started building my new static site generator, I had a few goals in mind, including: (i) to use the knowledge I had learned in the years since my last attempt at building a generator to make something that was easier to understand, and; (ii) to make my site generate as fast as possible.
I have spent hours optimising my code to make my site generate quickly. It takes under five seconds for my site to build in full. With that said, generating my site is only one part of the story: with a generated site, I need to get the content on a web server. Indeed, I needed to think not only of the speed of my program, but the speed of the pipeline to publish my website.
-
Olaf Alders ☛ One Line Fuzzy Find for Git Worktree
I’ve written on fuzzy matching with fzf before. I’ve covered adding tab completion to an existing command, using fzf to get a file preview windows and combining tab completion and preview windows to improve an existing command.
Those are helpful things to do and I use them all the time, but today I’d like to cover a much simpler use case – a one-liner to allow you to use fuzzy matching to navigate git worktrees. If you’d like to read up on why you may want to use worktrees in git, I’ve covered that in 4 Strategies for Context Switching in Git.
-
Max Sommer ☛ maxsommer.de blog | «Sometimes it's about what you don't build»
I find the game of „Jenga” to be a good analogy for a lot of software in this world: [...]
-
Medium ☛ Tamnjong Larry Tabeh: Understanding “Leading Questions” in Usability Research.
I’m in my internship's 3rd and 4th week, “conducting a series of short user research exercises using a mix of research methods”. Today, I want to talk about “leading questions,” a term that fascinated and confused me.
-
Python
-
University of Toronto ☛ Understanding a Python closure oddity
The first thing that is going on in this Python code is that while 'number' is only used in the for loop, it is an ordinary function local variable. We could set it before the loop and look at it after the loop if we wanted to, and if we did, it would be '9' at the end of the for loop. The consequence and the corollary is that every closure returned in the 'for' loop is using the same 'number' local variable.
-
James Stanley ☛ Secrets of the ChatGPT Linux system
Have you noticed that ChatGPT sometimes writes out Python code and somehow executes it? How does that work? What kind of environment is it using? Can we co-opt it for our own ends? Let's find out!
-
James G ☛ TIL: Visualising memory usage in Python
This weekend, I have been working on my static site generator, Aurora. Aurora stores many objects in memory to achieve high performance. For example, metadata from all posts on my blog are stored into memory while Aurora generates my website. This allows any page to enumerate posts and access attributes from them without the data being a read from a disk cache.
I asked myself: how much memory is Aurora using? I wanted a tool that would plot a chart showing memory use over time. With such a tool, I could see: [...]
-