Skip to content

Instantly share code, notes, and snippets.

View Potherca's full-sized avatar
🤔
I wonder what does this button do?

Ben Peachey Potherca

🤔
I wonder what does this button do?
View GitHub Profile
@Potherca
Potherca / README.md
Last active October 13, 2023 13:11
An automated HTML element overview page. https://gist.pother.ca/0a04271c143bc51862a6cc40a0a74b2f

HTML Element Reference

There are some great resources out there that document HTML elements.

Such as HTML Elements on MDN and htmlreference.io.

However, for me, most of these resources are either too exhaustive (like MDN) or too brief (like htmlreference.io).

What I want is a list of all available HTML elements, to get an idea of what the element is, without having to click through to another page. But also with enough information to know what the element is used for and how it is used.

Creating a real UUIDv4 in JS usually requires a library. The new https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID 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 https://gist.pother.ca/4a2b95623519e74b63d9485a4311ac3c

Copy Button

This gist contains the recipe to make a copy button.

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

<link rel="stylesheet" href="https://gist.pother.ca/33b4d10024f56ba0610f8e70477687cb/copy-button.css">
      <script async src="https://gist.pother.ca/33b4d10024f56ba0610f8e70477687cb/copy-button.js"></script>
Your Text Goes Here

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
Potherca / README.md
Last active August 29, 2023 14:36
Five laws of l̶i̶b̶r̶a̶r̶y̶ ̶s̶c̶i̶e̶n̶c̶e̶ software applications.

Five laws of library science

[The Five laws of Library Science][1] is a theory that S. R. Ranganathan proposed in 1931, detailing the principles of operating a library system.

  • Books are for use.
  • Every person his or her book.
  • Every book its reader.
  • Save the time of the reader.
  • A library is a growing organism.
@Potherca
Potherca / Basic Nextcloud server on Ubuntu.md
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
@Potherca
Potherca / pico8.desktop
Created August 23, 2022 16:28
File to add Pico 8 as a menu item on Linux
# ~/.local/share/applications/pico8.desktop
[Desktop Entry]
Name=Pico8
Comment=Fantasy console for making, sharing and playing tiny games and other computer programs.
GenericName=Fantasy Console
X-GNOME-FullName=Pico-8
Exec=/usr/local/bin/pico8
Terminal=false
Type=Application
Icon=/usr/local/lib/pico-8/lexaloffle-pico8.png
@Potherca
Potherca / README.md
Created June 3, 2022 11:05
Useful resources for learning regular epressions

Learning RegEx

Games

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

Learn

  • Regex Learn Step by step, from zero to advanced.
  • RegexOne Learn Regular Expressions with simple, interactive exercises.
@Potherca
Potherca / README.md
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: