Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Dave Furfero furf

🎯
Focusing
View GitHub Profile
View 0-MockVideoPlayer.html
<rmp-mock-video-controller>
<rmp-muted-toggle ?muted=${boolean('muted', true)}>
<rmp-mute-button id="story.mute" slot="mute-button">
<icon-mute fill></icon-mute>
</rmp-mute-button>
<rmp-unmute-button id="story.unmute" slot="unmute-button">
<icon-volume fill></icon-volume>
</rmp-unmute-button>
</rmp-muted-toggle>
</rmp-mock-video-controller>
View 0-Callbacks.ts
export type Callback<T> = (value: T) => void;
export type Unsubscribe = () => void;
export default class Callbacks<T> {
private callbacks = new Set<Callback<T>>();
subscribe(callback: Callback<T>): Unsubscribe {
this.callbacks.add(callback);
return () => this.unsubscribe(callback);
}
@furf
furf / sleep.html
Created Sep 2, 2020
Detect system sleep and wake events in browser.
View sleep.html
<html>
<head>
<title>sleep.js</title>
</head>
<body>
<h1>sleep.js</h1>
<script src="sleep.js"></script>
@furf
furf / setTimeoutWithThreshold.ts
Last active Jul 22, 2020
Experiments for canceling timeouts when system sleeps.
View setTimeoutWithThreshold.ts
type Timestamp = number;
type Callback = (error: Error | null, timestamp: Timestamp) => void;
/**
* The default number of milliseconds beyond the expected time of execution to
* wait before assuming failure.
*/
const THRESHOLD = 10000;
/**
@furf
furf / timer.js
Last active Jul 9, 2020
A stopwatch-like timer
View timer.js
const Events = new Map();
function startEvent() {
return {
start: Date.now(),
end: null,
};
}
function endEvent(event) {
@furf
furf / index.js
Created Jul 13, 2019
Coding challenge for constructing and traversing (depth-first) trees.
View index.js
// Found at https://www.glassdoor.com/Interview/Reddit-Senior-Software-Engineer-Interview-Questions-EI_IE796358.0,6_KO7,31.htm
// # a list of strings.Each string is a management / report relationship.
// #
// # EXAMPLE INPUT:
// #
// #[
// # 'B,E,F',
// # 'A,B,C,D',
// # 'D,G,I',
View rot13.js
function reduceRot13Cipher(map, c, i, abc) {
const off = 13;
const len = abc.length;
const j = (i + off) % len;
map[c] = abc[j];
return map;
}
const rot13 = (() => {
const abc = 'abcdefghijklmnopqrstuvwxyz';
@furf
furf / 0.reverseList.js
Created Aug 14, 2018
Reverse a Linked List, because why not.
View 0.reverseList.js
function buildList(values) {
return values.reduceRight((next, value) => ({ value, next }), null);
}
function getValues(node) {
const values = [];
while (node) {
values.push(node.value);
node = node.next;
}
@furf
furf / postmortem.md
Created Jun 22, 2018 — forked from mlafeldt/postmortem.md
Example Postmortem from SRE book, pp. 487-491
View postmortem.md

Shakespeare Sonnet++ Postmortem (incident #465)

Date

2015-10-21

Authors

  • jennifer
  • martym
View gist:09b115e96d7dc8498b3136db3760e507
if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () {
var Storage = function (type) {
function createCookie(name, value, days) {
var date, expires;
if (days) {
date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();