Using Text Expansion for URL Completion

In my professional life on the web, I tend to visit lots of the same URLs frequently. While I have (most of) them bookmarked in my browser, I usually don’t navigate to the bookmark and click it.

I start typing in the URL field of my browser (Firefox) and since autosuggest also searches the bookmarks, those are often visible. I realized though that this is still often too slow and not straight forward enough: It happens that many URLs are very similar and have the same first part, such as on Github many repos are under the same organization.

So a while ago I started using Alfred’s snippets to expand URLs for me. By using / as a suffix1, this allows for speedy expansion of URLs I visit frequently. A bonus is that the same expansion works in other places where I need the URL, e.g. for linking it in blog posts.

So, for example, I have the snippet g/a/ to expand to https://github.com/akirk/. If I then continue typing fr, my browser can autocomplete much more precisely because I have already entered part of the URL to https://github.com/akirk/friends which I often visit.

Hope this can serve as an inspiration!

  1. Although I natively speak German, I have switched to US (Intl for the inverted-L Enter key, I cannot let got of that one) keyboards a long time ago to benefit from dedicated keys for square and curly brackets, this also means I have a dedicated key for slash ↩︎
Posted in web

Letting ChatGPT Access the Internet

With the new Completions function calling API you can actually enable ChatGPT to access the internet. I did a few quick experiments where I provided it with a function called get_extracted_url_contents. See how it made use of it:

Get News

Script: https://github.com/akirk/cli-chatgpt/blob/main/get-news.php

$ php get-news.php

Prompt: Get some news from a random US news website on the internet.
Fetching https://www.cnn.com by request of ChatGPT.
AI (239 tokens used):
According to CNN, the breaking news is that the former US president has been arraigned on 37 federal charges involving the alleged mishandling of highly classified military documents. This is a historic first.

Or from a German website:

Prompt: Get some news from a random German news website on the internet. Please only respond in English.
Fetching https://www.spiegel.de/international by request of ChatGPT.
AI (1363 tokens used):
Here are some news headlines from SPIEGEL International:

  1. “Ukraine’s President Calls on NATO to Set Clear ‘Red Lines’ for Russia” – Ukrainian President Volodymyr Zelensky has urged NATO to establish clear “red lines” to deter further aggression from Russia. Zelensky made these remarks during a visit to Brussels.
  2. “German Cabinet Approves New COVID-19 Restrictions, Including Nationwide Vaccination Mandate” – The German government has approved new measures to combat the spread of COVID-19, including a nationwide vaccination mandate for certain groups of people. These measures come as Germany faces a surge in COVID-19 cases.
  3. “Turkey Summons German Ambassador Over ‘AfD-Led’ Turkish Ship Inspection” – Turkey has summoned the German ambassador to protest against the inspection of a Turkish ship by a German frigate in the Mediterranean Sea. The inspection was led by a member of the far-right Alternative for Germany (AfD) party.
  4. “European Court of Justice Rules Hungary’s NGO Law Violates EU Law” – The European Court of Justice has ruled that Hungary’s controversial law that restricts the activities of non-governmental organizations (NGOs) violates EU law. The law required NGOs that receive funding from abroad to register as “foreign-funded organizations.”

Please note that these are just a few selected headlines. For more information, you can visit the SPIEGEL International website.

One more try for a specific site:

Prompt: Get some news from ORF. Please only respond in English.
Fetching https://orf.at/ by request of ChatGPT.
AI (1286 tokens used):
Here are some news headlines from ORF:

  1. Document affair: Trump declares “not guilty”
  2. Babler presents his new team
  3. Johnson vs. Sunak: Insults keeping the British on edge
  4. Slovenia wants to keep borders with Croatia open
  5. WKStA secures data in the Chancellor’s Office
  6. Alaba is about to reach the next milestone
  7. Alpine climate in winter is significantly too mild
  8. IAEA “very concerned” about fighting near Zaporizhia nuclear power plant
  9. NATO hopes Ukrainian successes will force Moscow to negotiate

Please note that these are only the headlines and more details can be found on the ORF website.

Summarize URLs

Script: https://github.com/akirk/cli-chatgpt/blob/main/summarize-url.php

$ php summarize-url.php https://alex.kirk.at/2023/02/02/what-is-matrix/
Fetching https://alex.kirk.at/2023/02/02/what-is-matrix/ by request of ChatGPT.
AI (1340 tokens used):
Matrix is an open-source internet-based chat system that operates on a federated model similar to email. It allows users to send and receive messages through homeservers, which maintain up-to-date copies of chat rooms. Matrix rooms can be either unencrypted and openly discoverable or end-to-end encrypted and invite-only, with encryption keys shared between users’ client software. There is a wide selection of Matrix clients available for different platforms, and a WordPress plugin called Chatrix has been developed to embed Matrix into WordPress posts or pages.

Research

Script: https://github.com/akirk/cli-chatgpt/blob/main/research.php

Here it required several runs to get the right response since it tried to access a lot of invalid URLs. But it eventually managed.

$ php research.php
Prompt: Research on the internet who won the ATP French Open 2023 but don’t use a search engine.
Fetching https://en.wikipedia.org/wiki/2023_French_Open by request of ChatGPT.
AI (1085 tokens used):
According to the information on the Wikipedia page for the 2023 French Open, Novak Djokovic won the ATP Men’s Singles championship.

Things also worked out in the end when I gave it the ability to do multipel requests:

$ php research.php
Prompt: Research on wikipedia who won the (both men’s and women’s) ATP French Open 2023. If you cannot find a result, ask for a subsequent a function call.
Fetching https://en.wikipedia.org/wiki/2023_French_Open_%E2%80%93_Men%27s_Singles by request of ChatGPT.PHP Warning: file_get_contents(https://en.wikipedia.org/wiki/2023_French_Open_%E2%80%93_Men%27s_Singles): Failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found

Fetching https://en.wikipedia.org/wiki/2023_French_Open_%E2%80%93_Women%27s_Singles by request of ChatGPT.PHP Warning: file_get_contents(https://en.wikipedia.org/wiki/2023_French_Open_%E2%80%93_Women%27s_Singles): Failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
Fetching https://en.wikipedia.org/wiki/2023_French_Open by request of ChatGPT.
AI (1630 tokens used):
The winner of the men’s singles ATP French Open 2023 is Novak Djokovic, and the winner of the women’s singles ATP French Open 2023 is Iga Świątek.

This has been just a quick exploration following OpenAI’s announcement. Curious how we’ll leverage this better in future!

Posted in web

CLI ChatGPT Client in PHP

For my personal use, I created a CLI ChatGPT client a few months ago. It has been very useful for me to have it available in the CLI quickly whenever I needed it (caveat, you need an API key!).

Unfortunately, for larger responses it can feel very slow, whereas the web version feels quite fast. But this is perceived speed because it shows you each word as it arrives and not just the whole response when finished (after all it is a completion AI that generates the response word by word).

So now, I have added streaming support to it. It now feels almost too fast :) The CLI has a few nice things such as readline support (i.e. you can go back to old queries with the up key) and it keeps all of your conversation in a text file. All of this in only 100 lines of PHP.

Posted in web

What is Matrix?

I am working on bringing Matrix to the WordPress community (see also the WP Tavern post) and part of this is also to explain what Matrix actually is, so I wrote up a few paragraphs that I’d like to share here:

Matrix is an internet-based chat system like Slack or Microsoft Teams with a few key differences:

Open Source

It is open source (Apache License 2.0). Thus it includes the four freedoms (run it for any purpose, modify it, distribute it or a modified version).

Federated

There is no centrally controlled server, similar to e-mail (or ActivityPub): to send and receive e-mail, you need to have an account on a mail server. In Matrix, these servers are called homeservers.

When you send messages, these messages are first sent from your client (computer or phone) to the server, from the server to the recipients’ servers (in e-mail, you manually list them, in Matrix, these are all other people in the room), and then the messages are delivered to the individual participant’s clients. The benefit of this is that the client (like a mobile phone app) doesn’t need to be connected when the server receives the message and can catch up when it comes back online. 

For this reason, Matrix account addresses look similar to e-mail (or Mastodon) addresses but they have the format @username:server.tld. Starting when a member of a homeserver joins a room, their homeserver will maintain a full, up-to-date copy of the chat room. Any message sent by others in the room will be sent to every participating homeserver. For this reason, joining a room can take a while because the server needs to (partially) populate its local copy from other homeservers. Because of the real-time nature of chat, the messages are exchanged very quickly between the homeservers as soon as that connection has been established.

A Matrix server can also be run in unfederated mode where it will not communicate with other servers on the internet, thus enabling a closed community. This decision can also be made on a room-by-room basis.

Encryption

Matrix rooms can be either unencrypted and openly discoverable, or end-to-end encrypted and invite-only. Because the server has no knowledge of contents or encryption keys, the latter need to be shared between the individual client software of a user. This is established through a verification step in which you use your other/old client to establish trust with the new one. Until this has happened, any encrypted communication is inaccessible.

Open Protocol

The Matrix protocol (and all of its updates, called MSC) is publicly available and can be implemented by any software. There are a couple of server implementations with best known ones by Element themselves, called Synapse (Python based) and Dendrite (Go based). Clients are easier to implement through Matrix provided SDKs that do the heavy lifting of encryption and protocol communication.

Free Choice of Clients

For the above reason, there is a wide selection of clients for mobile and desktop, different operating systems, text based, etc. We have developed a WordPress plugin called Chatrix that allows embedding Matrix inside a WordPress post or page which allows something like we demonstrated in this GIF:

Posted in web

Keeping Family History with WordPress

One thing that I like very much about my family is the anecdotes and stories. One thing that I am bad at, is reciting them.

So I had this idea to create something like a private Wikipedia for my family, where each person has their own page and family members can contribute to the stories, biographical data, and media.

Initially, I set up a MediaWiki, i.e. the same software that Wikipedia uses. It turns out, it’s not that easy to configure. The new Wiki editor is much better than directly editing wiki syntax but the complexity is high for a small project like that. Also, uploading media is quite a pain because of the importance of licensing metadata. In a private wiki, you’ll want the UI to get out of the way.

So, since I work with WordPress a lot, I had the idea to use WordPress for it. There are a number of wiki plugins for WordPress but they all seemed overly complex and not really geared towards a use case of users collaborating on creating a site.

Thus, I created my own WordPress plugin called Family Wiki, available for now at https://github.com/akirk/family-wiki/

WordPress has the advantage that you can set it up very quickly and got many options for setting it up. Plus, when you have already multiple blogs (e.g. for family members) on your domain, it’s easy to just add another blog to your WordPress multisite. The plugin works on a standalone blog, too.

Here are some screenshots that I made as a demo:

Posted in web

Using Jetpack Blocks without a connection to WordPress.com

Recently I wanted to use a Jetpack block for the WordPress Gutenberg editor, specifically the Slideshow Block, which I think is very slim and elegant compared to other Slideshow blocks on the WordPress.org plugin directory.

The one thing I didn’t want to do, though, is to connect my site to WordPress.com. For the most part because I didn’t intend to use any of the functionality that requires the WordPress.com connection.

The difficulty in this: normally, you can’t actually use Jetpack until you connect the site to your WordPress.com account. This behavior is in place so you can enjoy a friction-less experience after the connection is established (i.e. you can activate any of its features whether or not it needs the connection).

In my case, the connection is not needed for using the Slideshow block since it works with the local media library.

So, I present not a hack but an official way to use Jetpack without a WordPress.com connection: it’s called Offline Mode.

You activate it by adding a constant or filter to your wp-config.php, for example:

define( 'JETPACK_DEV_DEBUG', true );

While it is intended for local installs and actually development, it is useful if you just want to use a single feature of Jetpack that doesn’t require the connection.

Many people say that Jetpack is slow because it’s so big. It is indeed huge from a file size and feature perspective, but also it’s very optimized, so that it will only load the PHP or JS code it needs. The other files lay dormant in your file system and don’t contribute to the loading or rendering time of your site.

Posted in web

Reducing Our Dependency On Third-Party Platforms For Our Online Activity

There is something that I feel is not right with today’s web structure. We, as the population of the web, create so much content that ends up on servers of large companies. We could own our data.

Therefore, I’d like to help reduce everyone’s dependency on third party platforms for their online activity.

Vision

You use your own server for publishing and interact with other people’s content on their server.

Since everybody follows this method, your content only reaches the people it is meant for, without involving a third party in the distribution.

You interact using the same means of today: web UI, mobile apps; the difference is that they don’t talk to a third-party server, neither for publishing nor getting and interacting with others’ content.

I am trying to create a solution for this with WordPress and the Friends plugin.

Note: in the following text I use the word “server” somewhat synonymous for the WordPress+Friends setup but it there could be alternative implementations. Also, server doesn’t mean “a dedicated machine somewhere,” you just need web space where you can install WordPress, which doesn’t mean it has to be expensive. For example, wpfriends.at is hosted for €1,90/month incl. domain.

Separation of Content

Today, separate social networks exist for different types of content; for example short content has its home on Twitter, Instagram is for photos. Facebook is a mix of this but allows for private content. Instant messengers like WhatsApp (or Facebook groups) are very clear about who the content or conversation is for.

So, separating content makes for a more homogeneous experience when consuming the content, also you have a good grasp of where (and for whom) you want to publish your content.

On your own server, you can separate out different types of content as well (in WordPress this is called “post formats”). You can also post something privately, only giving access to authenticated users.

Adding a friend and subscribing to multiple platforms on which they publish

The key is to connect the different types appropriately. By fetching the content from your friends and placing them in such “buckets,” you now have the option to view everyone’s content from multiple perspectives: everything from a single friend (or a group) across content types, or everything across friends of just one content type.

By continuing to use specialized apps for different types of content, you keep the benefits but exclude the third-party having full access to the content since they now talk to your own server.

Platforms

The possibility to publish on the Internet by using your own server (most of the time: rented web space) is well-established since blogging was invented. It can become clunky when you interact with others: how do I respond?

That’s why there are several reasons why platforms are appealing:

  • It’s easy to connect with others on the same platform.
  • Leveraging network effects is easier since the platform knows who is connected to whom.
  • Spam is usually under control.

Thinking back to the era of blogging, we had lots of interactions with others using comments and pingbacks. What mainly led to its demise was automated spam which reduced everybody’s willingness to be open for interaction. Commenting meant moderating spam.

Core

So one of the core features of the Friends plugin is to solve the authentication problem between people you know and trust.

When you decide “to become friends” with someone, it means that you both get (low privilege) accounts on each other’s servers.

You can give them permission to see your privately published content, or not. When you want to respond to their post, you are automatically authenticated on their side.

This means that you could close comments for unauthenticated users (thus eliminating spam) but keep the discussion open for your friends.

Transitioning

Using your own server still has a learning curve. Getting started with a self-hosted WordPress and installing the Friends plugin is not as trivial as creating an account on a social network.

While it has become considerably easier to register a domain, get webspace connected, and a WordPress installed, there are still many further steps until you really can get started.

So, reality is that your friends likely won’t be migrating off third-party networks. Possibly never.

To still allow yourself to disconnect, the Friends plugin allows you to follow your friends across different (possibly third-party) channels including popular social networks like Twitter.

You can subscribe to someone on Twitter and their messages will be aggregated on your server under their user, in the respective post format.

This means that you can either view all the content (that you follow) for a single friend, or you can view the aggregate type of content, e.g. all the short messages your friends posted across services.

Not only for “real” Friends

Many use social networks to not only follow people they know and trust, but also to follow the news or celebrities. Despite the name of the Friends plugin, it can also do that.

You can subscribe any supported content (some out of the box, for others you can extend it with plugins) but not go into the friendship realm.

Your server takes care of fetching the content from various third-party sources and you can then consume the content in the way you see fit:

  • The local “Friends UI” on your own server,
  • an RSS reader,
  • or more specialized clients like mobile apps.

Ads

One side-effect of this could possibly be that this removes our content from being wrapped in ads and websites trying to have us spend as much time as possible on their site.

We’d all spend a little money for domain and server every month or year for our own gain. We don’t need to put ads to our content.

For journalistic content it is already not uncommon for tech publications to provide an ad-free RSS feed as part of their paid subscription.

More Ideas

You can use your server to store more things, for example:

Your personal bookmark collection and todo lists (I have a work-in-progress for transitioning my previous project called thinkery.me to a WordPress plugin thinkery to host this yourself and use the Android app as a client).

Leverage your aggregated content as your own browser start page (my WordPress plugin called Startpage).

Right now, this is only implemented for WordPress, and the authentication is only leveraged for consuming private content and posting comments. But it doesn’t need to end there.

The authentication could be used for further actions, for example you could give posting permissions to your friends to create a (private) forum, hosted by you or a friend.

The Friendship protocol is a REST API that can be implemented in other software as well.

The Friends plugin is open source and GPL.

Work in Progress

How far along the way is the Friends plugin? It’s already well usuable for your own purposes. Like I said above, you can establish friendships between servers and consume your friends’ content, even from third-party social networks.

There is still a lot to do, especially around commenting and notifications. Better tools are needed for leveraging network effects, like search your friends+ posts and explore their friends (if they allow you to do so).

Posted in web

Pocketbook Color

I read a lot of web articles on my e-reader (often using Push to Kindle which is fantastic). I left the Kindle ecosystem a while ago and Pocketbook (a TouchHD 3) has been a good home so far.

Since my content is often a mix of text and non-text, I was appealed by a color eInk screen. The Pocketbook Color recently came out and I purchased one to test it.

Here are my conclusions after about two weeks of usage:

Pro

  • While limited in their range, colors work well for diagrams, illustrations and screenshots. Photos can look a bit awkward but it’s definitely better than greyscale.
  • Before this e-reader, I haven’t read comics on a device but with color it’s quite fun. The clipping tools in the UI are useful to get rid of white borders around the actual comics.

Con

  • It’s not very suitable for night time reading (which is my main use case), the minimum brightness is high, there is only white backlight.
  • With the strong white backlight it feels like an LCD screen which kind of diminishes the idea behind eInk.
  • The technology seems to use two layers: one “common” 300dpi greyscale, and one around 150dpi color layer. This results in a pattern overlaying the whole screen making the screen less crips when reading text.
  • Pocketbook readers are rather slow. I always wonder how they do scrolling and inertia so much better than Kindles but feel so. slow. navigating through the UI.

Overall, I think color eInk is technology well worth exploring, especially when no backlight is necessary and it doesn’t need any battery power (think photo walls)

I am torn whether I’ll keep the Pocketbook Color as my main reading device because using the reader in the dark is like turning on the light in the room.

Posted in web