Dagger Feels Like Magic
I’ve been working on a Dagger module for interacting with the Bluesky API.
I wrote the first version in Python, using the atproto library. It worked well and was easy to use, but I noticed that none of my links, mentions, or hashtags were showing up. I ignored this for a while, but today decided to investigate this some more since the whole world seems to be showing up on Bluesky this week.
It turns out that there is a separate rich text API that you need to use in order to paste links, mentions, hashtags, and images. Mastodon, Twitter, and LinkedIn seem to figure it all out automatically but Bluesky is special.
I read the python docs on how to do this, and it made sense but in order to get this to work in the real world I would need to first write some sort of parser to identify the different types of elements and then pass them into this TextBuilder
class to create the Bluesky post.
This felt like a lot of work and I am lazy. The good news is that the official Typescript SDK from the Bluesky team has a helper method called detectFacets
that does all of this for you.
I’ve put a lot of work into this module and it includes some examples along with a test suite that runs all of my examples. The test suite was written in Python just like the original module was.
I was able to port the module over from Python to Typescript with a little effort. I started to port the test suite over to Typescript as well but then thought to myself “wait a minute, I don’t need to port this over”.
You see, the test module is just another Dagger module that calls my Bluesky module. Dagger modules can be written in any language and they can call modules written in any other language. Since the API for my Bluesky function did not change in my Python to Typescript port everything just worked.
Sometimes Dagger feels like magic.
Thank you for reading! Share your thoughts with me on mastodon or via email.
Check out some more stuff to read down below.
Most popular posts this month
- Dagger Feels Like Magic
- Now What?
- SQLite DB Migrations with PRAGMA user_version
- 20 Years of Ubuntu
- Types and Roles If Not Exists in PostgreSQL
Recent Favorite Blog Posts
This is a collection of the last 8 posts that I bookmarked.
- We don’t need to use what we make from Derek Sivers blog
- Ubuntu Summit 2024: A joyful experience filled with sorrow from Planet KDE | English
- Sabotage from jwz
- What if My Tribe Is Wrong? from Armin Ronacher's Thoughts and Writings
- It’s the “1998” of the AI Revolution. So Why Can I Safely Ignore It? from The Internet Review
- University & Adversity from Isaak.net
- War on Malaria from Isaak.net
- Serendipity from Armin Ronacher's Thoughts and Writings
Articles from blogs I follow around the net
Ozempic For Sleep
Thanks for key conversations & early feedback: Andrew Payne, Luke Piette, George Church, Michael Retchin, Flora Guo, Merrick Smela, Misha Yagudin, Tyler Cowen, Helena Rosengarten. My favorite family in the world — the Johnsons from Utah. Many of them c…
via Isaak.net November 11, 2024Navigations on the Web
When trying to define the difference between a link (<a>) and a button (<button>), a general rule of thumb is: links are for navigation, buttons are not. That can take you pretty far. However, like most things, there’s nuance and that mental mo…
via Jim Nielsen’s Blog November 11, 2024Too much therapy at work
Many years ago, Jason and I hired a COO at 37signals, but ended up letting them go after just a year (many reasons, another story). This happened not long before one of our company meet-ups, so we thought it fitting to discuss the matter in-person. What…
via David Heinemeier Hansson November 11, 2024Generated by openring