Skip to content

Instantly share code, notes, and snippets.

View bcomnes's full-sized avatar
👽

Bret Comnes bcomnes

👽
View GitHub Profile
@WebReflection
WebReflection / dom-libraries.md
Last active February 6, 2024 15:50
A recap of my FE / DOM related libraries

My FE/DOM Libraries

a gist to recap the current status, also available as library picker!

Minimalistic Libraries

do one thing only and do it well

  • µhtml (HTML/SVG auto-keyed and manual keyed render)
  • augmentor (hooks for anything)
  • wickedElements (custom elements without custom elements ... wait, what?)
@WebReflection
WebReflection / local-storage-vs-compression.js
Created February 19, 2020 08:59
A benchmark to see how many items can be stored using WebCompressor
const findLimit = async (type, create) => {
console.log(
`%c ${type} benchmark `,
`font-weight:bold;color:white;background-color:black`
);
localStorage.clear();
let i = 0;
let length = 0;
while (true) {
try {
@IanColdwater
IanColdwater / twittermute.txt
Last active April 22, 2024 17:26
Here are some terms to mute on Twitter to clean your timeline up a bit.
Mute these words in your settings here: https://twitter.com/settings/muted_keywords
ActivityTweet
generic_activity_highlights
generic_activity_momentsbreaking
RankedOrganicTweet
suggest_activity
suggest_activity_feed
suggest_activity_highlights
suggest_activity_tweet
@dy
dy / ce-decorators.js
Last active October 26, 2019 00:24
Custom element decorators
export const customElement = (tagName, options) => (classOrDescriptor) => (typeof classOrDescriptor === 'function') ?
legacyCustomElement(tagName, options, classOrDescriptor) :
standardCustomElement(tagName, options, classOrDescriptor);
const standardCustomElement = (tagName, options, descriptor) => {
const { kind, elements } = descriptor;
return {
kind,
elements,
// This callback is called once the class is otherwise fully defined
@kitsonk
kitsonk / bronto.ts
Last active August 10, 2022 12:03
Example Deno Static Server
import {
green,
cyan,
bold,
yellow,
red
} from "https://deno.land/std@v0.20.0/fmt/colors.ts";
import {
Application,
@brianleroux
brianleroux / BeforeExitListener.js
Created September 12, 2019 22:04
Lambda NodeJS 10.x Default Runtime JavaScript
/** Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */
"use strict";
/**
* The runtime has a single beforeExit function which is stored in the global
* object with a symbol key.
* The symbol is not exported.
* The process.beforeExit listener is setup in index.js along with all other
* top-level process event listeners.
*/
@andrewosh
andrewosh / split-drive.js
Created July 29, 2019 09:39
Split hyperdrive content and metadata
```js
const store = corestore(path => {
if (path.indexOf('default') === -1) return raf(`${contentDest}/${path}`)
return raf(`${metadataDest}/${path}`)
})
const drive = hyperdrive(store)
```

Hyperswarm DHT setup

Checking your network for P2Pness

Running a node

Running a dht node is as simple as installing the DHT cli.

npm i -g @hyperswarm/cli
const tracking = new WeakMap()
const clz = 'onload-' + Math.random().toString(36).slice(2)
const observer = new MutationObserver(function (mutations) {
for (let j = 0; j < mutations.length; j++) {
const { addedNodes, removedNodes, target } = mutations[j]
for (let i = 0; i < addedNodes.length; i++) {
if (!addedNodes[i].classList) continue
if (addedNodes[i].classList.contains(clz)) tracking.get(addedNodes[i]).onload(target)