Paste around

TL;DR

A few tricks about pasting online, learned during the 2021 Advent of Code

Well, actually while lurking in the Solutions Megathreads in Reddit.

The first and foremost is a handy Javascript application that runs directly in the browser. You paste your text in this browser-based application and get a link to it.

What… what? A link to where?!? Well, to the page itself, which will decode most of the URL itself to get the data to show. This is such a neat trick.

The pasted text is compressed using LZMA, then encoded to make it URL safe. Overall a brilliant idea, I wonder whether using Brotli would squeeze things a bit more.

This is so cool because the code isn’t actually pasted anywhere - it’s just all there in the URL, so if you want to back it up just save the link!

The drawback is that you end up with a very long URL. This is hardly a problem, e.g. if you’re using Markdown or other ways to render links with a text of choice. In case, anyway, you can gain a lot more compression using a URL shortener service like bitly. As an example:

This was not the only discovery about pasting stuff though. Thanks to s3aker I discovered glot.io, which not only allows pasting stuff in a variety of syntax-highlighted languages, but also allows executing that code!

Well, it’s about time to pass past this post about pasting! Stay safe!


Comments? Octodon, , GitHub, Reddit, or drop me a line!