Peanut butter (and Colibrí) improvements

Published 2025-12-08

tag(s): #meta #programming

Peanut Butter: better paste names

When I was putting together Peanut Butter, I was a bit annoyed that all the pastebin clones I found had features like syntax highlighting[1], login walls, and web-only interfaces.

And then, a breath of fresh air: Cathedral Network's c-paste service.

Even if PB's homepage is way less plain-texty than theirs, a lot of inspiration on how it should work came from this page. Of course they offer a more rounded up service, which supports binary uploads and a way to delete pastes.
But the feature I kept thinking I should implement was their "paste names":

The URL generator uses readable English word combinations that are easy to remember, in case you happen to be physically running between terminals.

Step 0: finding a word list

I searched for word lists until I landed in one generated by the EFF. Going simply for "list of common English words" would include things like "though" and "thought", they are common but easy to mix up.

The brave new world of databases

When I started the website, I decided to save each paste in a text file on disk, so I didn't have to deal with databases: picking one, learning a new library to use them, etc.
It proved a good choice, as the second tool, Image Manipulator, didn't require any data storage.

I always knew I would pick SQLite, though. I have used it in a few Python thingies, and despite being the most deployed database in the world, I still think it is under utilized. That's how much I respect it and how useful I think it is.[2]
After implementing Stack of Links, I had working knowledge of a Common Lisp system to access SQLite. And I knew sooner or later I should move the pastes from files on disk to a DB.

Putting it all together

Screenshot of a tool to save plain text online.
(direct link to image)
Screenshot of the result of saving plain text online.
(direct link to image)

Or, from a terminal:

A terminal window with a curl request and response.
(direct link to image)

Speaking of delaying decisions, the algorithm to generate the paste names is extremely naive. It picks a first word, tries 250 second words until it finds one that hasn't been used already. If it can't find any unused combination, it will try a different first word, again, 250 times.
There's no check for "I already tried this word", or anything like that. Instead, there's a fallback to the old-style IDs generated from the current date.

I also loaded all the previous pastes in the DB, with their original names. I honestly don't know if anyone other than me and maybe some friend used the service, but it felt like the right thing to do. 🤷

Other (internal) improvements

I made a few other changes. I couldn't quite figure out why I stored saved links in SOL[3] by username, instead of user id. When I decided to change it, I realized that I only stored the username in the session. 🙃 Mystery solved.
So I added the id to the session, and updated all links saved for all users. It's not a visible change, and it really doesn't matter much. But just like storing pastes as files on disk, it felt a bit wrong.

There were also a few other errors that I corrected while testing the login and session changes.
The downside of having almost no users other than myself, is that less visited sections of the code can be broken for a while. 👀 These were things that I missed when I moved the HTML generation code to its own package.

Now that I know feel comfortable working with Common Lisp with SQLite and web stuff, and as I find little things that annoy me in FreshRSS, I start thinking more and more about building my own aggregator. Because, why not!

Footnotes
  1. This bothered not so much because I personally abandoned syntax highlighting, but because:
    1. It meant adding some library (with lots of complexity), when you would get your pastes from a Terminal, or open them in your text editor of choice and then you get highlighting from it.
    2. I bet most of these libraries have poor or no support for Common Lisp. Adding insult to injury.
  2. It was an awesome way to test Datum during development. I tested other engines at my different jobs, but the core features were developed locally with SQLite and Chinook.
  3. Stack of Links ==> SOL, doubles as "sun" in Spanish and.. SOL. I am open to better name suggestions, but I guess this is memorable enough.

Share your thoughts (via email)

Back to top

Back to homepage