Skip to content

Instantly share code, notes, and snippets.

View sampotts's full-sized avatar

Sam Potts sampotts

View GitHub Profile
@Westbrook
Westbrook / lit-use-effect-element.js
Last active September 3, 2023 23:18
useEffect() for `LitElement`... because everyone's doing it?
import {LitElement, html} from '@polymer/lit-element';
import {UseEffectMixin} from './use-effect.js';
class MyElement extends UseEffectMixin(LitElement) {
static get properties() {
return {
mood: {type: String},
expression: {type: String}
}
}
const createLogger = (backgroundColor, color) => {
const logger = (message, ...args) => {
if (logger.enabled === false) {
return;
}
console.groupCollapsed(
`%c${message}`,
`background-color: ${backgroundColor}; color: ${color}; padding: 2px 4px;`,
...args
function Mutilator(data, name, context) {
this.n = name || `mutilation-${+new Date()}`;
this.d = data;
this.c = context || window;
this.isArr = function(p) {
return this.d[p].constructor == Array;
};
this.dispatch = function(p, v, t) {
this.c.dispatchEvent(
new CustomEvent(this.n, {
@bendc
bendc / simulate-typing.js
Created September 1, 2017 08:57
Fake typing animation
const trackTime = timing => {
const now = performance.now();
if (!timing.startTime) timing.startTime = now;
const elapsed = now - timing.startTime;
const {duration} = timing;
if (duration != null && duration <= elapsed) timing.startTime = null;
return elapsed;
};
const delay = (callback, duration) => {
@pookjw
pookjw / seedutil.md
Last active July 6, 2023 02:47
Enroll macOS Beta Seed without profile installation

seedutil

Enroll macOS Beta Seed without profile installation

Usage

$ sudo /System/Library/PrivateFrameworks/Seeding.framework/Versions/A/Resources/seedutil 
usage: seedutil enroll SEED_PROGRAM
    seedutil unenroll

seedutil current

@zkat
zkat / index.js
Last active March 10, 2024 14:32
npx is cool
#!/usr/bin/env node
console.log('yay gist')
@stowball
stowball / is-ie.js
Last active June 16, 2017 01:43
Feature detect if the browser is any version of IE (excluding Edge)
const isIE = () => {
const style = document.documentElement.style;
return (('msScrollLimit' in style || 'behavior' in style) && !('webkitFlex' in style));
};
@MarkoCen
MarkoCen / isPromise.js
Created April 24, 2017 19:27
Check if an object is a Promise
function isPromise(object){
if(Promise && Promise.resolve){
return Promise.resolve(object) == object;
}else{
throw "Promise not supported in your environment"
}
}
var i = 1;
var p = new Promise(function(resolve,reject){
@smashism
smashism / previous_shutdown_cause
Created April 6, 2017 20:39
searching for shutdown causes
log show --predicate 'eventMessage contains "Previous shutdown cause"' --last 24h
@mdo
mdo / 00-intro.md
Last active March 24, 2024 08:04
Instructions for how to affix an Ikea Gerton table top to the Ikea Bekant sit-stand desk frame.

Ikea Bekant standing desk with Gerton table top