Skip to content

Instantly share code, notes, and snippets.

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

Ben Peachey Potherca

🤔
I wonder what this button does…
View GitHub Profile
@Potherca
Potherca / RTJ1_cover.webp
Last active August 26, 2024 19:22
Run the Jewels cover randomizer - RTJ(rand)
@Potherca
Potherca / README.md
Last active November 14, 2023 13:58
Scrum commitment

Each artifact contains a commitment to ensure
it provides information that enhances transparency
and focus against which progress can be measured:

  • For the Product Backlog it is the Product Goal.
  • For the Sprint Backlog it is the Sprint Goal.
  • For the Increment it is the Definition of Done.
@Potherca
Potherca / README.md
Last active November 14, 2023 13:51
"Incremental" vs. "Iterative"
@Potherca
Potherca / example.js
Created October 13, 2023 14:11
set search params on an URL in javascript
const url = new URL(document.location)
const search = new URLSearchParams()
const options = {
"foo": "hello",
"bar":"world"
}
Object.entries(options).forEach(([key, value]) => {
@Potherca
Potherca / jwk_with_phpseclib_test.php
Created July 17, 2023 10:28 — forked from sicet7/jwk_with_phpseclib_test.php
Use JWK from JSON with the lcobucci/jwt library through phpseclib. Credit to @whatTool for helping with the implementation
<?php
//REQUIREMENTS!
//"phpseclib/phpseclib": "^3.0"
//"lcobucci/jwt": "^5.0"
require_once __DIR__ . '/vendor/autoload.php';
$json = '{
"keys": [
{
@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.