Skip to content

Instantly share code, notes, and snippets.

Avatar
🏜️
🚙🛸🌵🛰

Bret bcomnes

🏜️
🚙🛸🌵🛰
View GitHub Profile
View hooks-in-a-nutshell.js
// WARNING: There's much more to know/do around hooks, and
// this is just a simplification of how these work.
// shared references, updated
// per each hook invoke
let execution = null;
let current = null;
let context = null;
let args = null;
View my-libraries-in-bytes.md

Toward better libraries

I am recently re-branding my libraries as µ (micro), refactoring these when necessary, dropping IE < 11 support, improving the logic where possible, or providing a better, more robust, or faster, API.

In few words, on the right there is the modern version of libraries I've used for the last ~5 years in production or for side projects, and I suggest anyone having one of the earlier dependencies, to have a look at their modern, micro, counterpart.

How to read these tables

All sizes are minified, brotli compressed, and representing these two files, when possible:

@dvalfrid
dvalfrid / gist:72a203931a928dbc67e2da568b4c5547
Last active Nov 5, 2020
Control the POE fan with ubuntu
View gist:72a203931a928dbc67e2da568b4c5547

Rasparry PI - how to control your POE-fan in Ubuntu

Check if you have the POE-fan

cat /sys/class/thermal/cooling_device0/type

should give rpi-poe-fan

Create file

sudo vi /etc/udev/rules.d/50-rpi-fan.rules

View useSWR.md

What's SWR?

It's React Hooks for Remote Data Fetching, a hook designed to render data on demand.

import useSWR from 'swr'

function Profile() {
  const { data, error } = useSWR('/api/user', fetcher);
@WebReflection
WebReflection / uce-vs-lit-element.md
Last active Jan 13, 2021
A very simple comparison table between uce and lit-element.
View uce-vs-lit-element.md

uce vs lit-element

A very simple comparison table between these two libraries.

uce lit-element
version 1.11.9 2.4.0
license ISC (simplified MIT) BSD-3-Clause License
language JS w/ TS definition TS w/ JS transpilation
size ( brotli ) 9437b ES5 / 6811b ES2015+ 8634b ES5 / 6708b ES2015+
View hashly.txt
[1: the world as it is today]
regular identities are controlled by corporations:
https://twitter.com/jamieoliver
https://linktr.ee/jamieoliver
https://www.youtube.com/user/JamieOliver
https://www.youtube.com/watch?v=hTn8Uh1m0hg (11-character base 64 hash value)
@tornqvist
tornqvist / example-memo.js
Last active May 19, 2020
A series of examples illustrating a new component API I've been working on in conjunction with changes to nanohtml
View example-memo.js
var { html, render } = require('nanohtml')
var { Component, memo, onupdate } = require('nanohtml/component')
// This example illustrates how memo can be used to maintain form state.
// On first render, getInitialValues is called and read values either
// from the fields argument or from local storage.
// Whenever a field changes its value is persisted to local storage.
var Form = Component(function (fields, values = memo(getInitialValues)) {
var update = onupdate(function (fields, values) {
@WebReflection
WebReflection / local-storage-vs-compression.js
Created Feb 19, 2020
A benchmark to see how many items can be stored using WebCompressor
View local-storage-vs-compression.js
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 Feb 15, 2021
Here are some terms to mute on Twitter to clean your timeline up a bit.
View twittermute.txt
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 Oct 26, 2019
Custom element decorators
View ce-decorators.js
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