Skip to content

Instantly share code, notes, and snippets.

I wonder what this button does…

Ben Peachey Potherca

I wonder what this button does…
View GitHub Profile

Creating a real UUIDv4 in JS usually requires a library. The new can be used in the browser.

But how hard is it to create a valid UUIDv4? As it turns out, not very!

The following is all that is needed for a version 4 UUID (including correctly setting the so called M and N bits):

const generateUUID = () => "10000000-1000-4000-8000-100000000000".replace(/[018]/g, s => (s ^ Math.random() * 256 & 15 >> s / 4).toString(16));

This can be seen in action at


This gist contains the recipe to make a copy button.

It is activated by adding data-js="add-to-page" to an element and including the CSS and JS files.

<link rel="stylesheet" href=""&gt
<script async src=""></script&gt
<pre data-js="copy">Your Text Goes Here</pre>

It used to be hard to Base64 encode an image. Most often, a server-side component was used.

Nowadays, with FileReader readAsDataURL it can be easily done, 100% in the browser.

    const file =  // the contents of the image goes here

    const reader = new FileReader();

    reader.onload = (event) => {
Potherca /
Last active November 9, 2022 20:06
Five laws of l̶i̶b̶r̶a̶r̶y̶ ̶s̶c̶i̶e̶n̶c̶e̶ software applications.

Five laws of library science software applications.

The five laws of library science is a theory that S. R. Ranganathan proposed in 1931, detailing the principles of operating a library system.

These laws, addpted to software applications are:

  • Books are Software is for use.
  • Every person his or her** book Software.
  • Every book Software its reader user.
  • Save the time of the reader user.
Potherca / Basic Nextcloud server on
Last active September 30, 2022 08:11 — forked from michielbdejong/Basic Nextcloud server on Ubuntu
Steps to setting up a Nextcloud server from scratch using an Ubuntu-based VPS
View Basic Nextcloud server on
Potherca / pico8.desktop
Created August 23, 2022 16:28
File to add Pico 8 as a menu item on Linux
View pico8.desktop
# ~/.local/share/applications/pico8.desktop
[Desktop Entry]
Comment=Fantasy console for making, sharing and playing tiny games and other computer programs.
GenericName=Fantasy Console
Potherca /
Created June 3, 2022 11:05
Useful resources for learning regular epressions

Learning RegEx


  • Slash\Escape The first and only slasher themed text based RegEx learning game.


  • Regex Learn Step by step, from zero to advanced.
  • RegexOne Learn Regular Expressions with simple, interactive exercises.
Potherca /
Last active May 11, 2023 13:41
Markdown Template for Daily Scrum meetings

Daily Scrum Template

When taking part of a Daily Scrum as Scrum Master, I find it handy to take notes. This makes sure I can hand over the role, if need be. It also means I don't have to rememeber everything as I can look things up in my notes later.

Below is the structure I use as format or "template" for taking notes.

Some things of importance:

Potherca /
Last active March 20, 2022 10:49
Emoji Popularity per Year

For a project at my employers we are working with the PHP Easy RDF library.

In order to help other developers understand how to do some basic things in Easy RDF, I have created an example that shows how to read a RDF file, find a node, remove that node or a property from that node and write the result back to the file, using Flysystem.

The Turtle document used in this example is an edited version of the test fixture used in the Solid Link Metadata Tests Suite.

A static HTML has been provided, as well as some quick-and-dirty PHP with a live example (also used to generate the HTML output).

To see the HTML visit