Skip to content

Instantly share code, notes, and snippets.

View triptych's full-sized avatar
💭
Making web things

Andrew Wooldridge triptych

💭
Making web things
View GitHub Profile
@triptych
triptych / npm.js
Created March 14, 2024 22:28 — forked from josdejong/npm.js
Helper function to load ESM packages from NPM in your browser dev tools console
/**
* Load an ESM package from npm in your JavaScript environment.
*
* Loads packages from https://www.npmjs.com/ via the CDN https://www.jsdelivr.com/
*
* Usage:
*
* const lodash = await npm('lodash-es')
* const lodash = await npm('lodash-es@4')
* const lodash = await npm('lodash-es@4.17.21')
@triptych
triptych / tootski.md
Created December 24, 2022 21:57 — forked from kentbrew/tootski.md
Tootski, a sharing bookmarklet for Mastodon

Tootski, a sharing bookmarklet for Mastodon

Tootski is a bookmarklet that will share the page you're on to your Mastodon instance, including the title, address, and any text you may have selected.

Before You Begin

You need to know the name of your Mastodon instance if it's not mastodon.social. To find it, visit your home page on Mastodon and copy out the part between the second and third slash. My home URL looks like this:

@triptych
triptych / 55-bytes-of-css.md
Created September 26, 2022 06:08 — forked from JoeyBurzynski/55-bytes-of-css.md
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
@triptych
triptych / lit-element-in-browser.html
Created May 9, 2022 22:03 — forked from mcmoe/lit-element-in-browser.html
Using Lit Element without npm directly in the browser
<!-- From: https://gist.githubusercontent.com/sorvell/48f4b7be35c8748e8f6db5c66d36ee29/raw/67346e4e8bc4c81d5a7968d18f0a6a8bc00d792e/index.html -->
<!doctype html>
<html>
<head>
<!-- Polyfills only needed for Firefox and Edge. -->
<script src="https://unpkg.com/@webcomponents/webcomponentsjs@latest/webcomponents-loader.js"></script>
</head>
<body>
<!-- Works only on browsers that support Javascript modules like
Chrome, Safari, Firefox 60, Edge 17 -->
<div>
<marquee>This is an <b>HTML</b> response!</marquee>
<!-- a comment -->
</div>
let x = 5;
let y = 100;
let z = Math.random() * 10;
var storyContent = {"inkVersion":19,"root":[["^The mist of the rich green and brown forest has hardly begun to burn away as the golden bright dawn sun peeks over the mountains in the distance. You sigh as you adjust the straps on your shoulders - holding your trusty backpack - and step through the dewy grass towards the cave entrance. Your leather boots grow cold and wet as the water seeps in, but you don't care. It has been a long journey to get here, and you are glad that it is almost over.","\n","^You look down at your ragged clothing. Your clothes seem like a cross between an out of work mercenary - with leather gear, a shortsword, and some nice fingerless gloves that have tiny studs on the knuckles, and a naturalist, with a green tunic, leggings, and all kinds of little bags of herbs and powders dangling from your waist belt.","\n",["ev",{"^->":"0.4.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","/ev",{"*":"0.c-0","flg":18},{"s":["^turn toward the cave",{"->":"$r","var":true},null]}],["e
class Animal {
constructor(name, gender) {
this.name = name;
this.gender = gender;
}
get label(){
return `${this.name} - ${this.gender}`
}
@triptych
triptych / index.js
Created August 30, 2021 00:48
testing a javascript es6 module
export const sqrt = Math.sqrt;
export function square(x) {
return x * x;
}
export function diag(x, y) {
return sqrt(square(x) + square(y));
}
@triptych
triptych / script.gd
Created August 1, 2021 00:28
godot javascript bridge
extends Node
func _ready():
# Call the JavaScript `new` operator on the `window.Array` object.
# Passing 10 as argument to the constructor:
# JS: `new Array(10);`
var arr = JavaScript.create_object("Array", 10)
# Set the first element of the JavaScript array to the number 42.
arr[0] = 42
# Call the `pop` function on the JavaScript array.