Skip to content

Instantly share code, notes, and snippets.


Luke Edwards lukeed

View GitHub Profile
lukeed / worktop.cache-kv.ts
Last active May 13, 2021
Demo showing how to integrate with the Cache API and then use custom KV lookup mechanics
View worktop.cache-kv.ts
import { Router } from 'worktop';
import * as Cache from 'worktop/cache';
import { read, write } from 'worktop/kv';
import type { Method } from 'worktop/request';
import type { Handler } from 'worktop';
import type { KV } from 'worktop/kv';
// KV Namespace Binding
declare const SAVED: KV.Namespace;
lukeed / astray-references.js
Created Jul 1, 2020
how to traverse an AST with astray and collect identifier sources + references
View astray-references.js
import * as astray from 'astray';
import { parse } from 'meriyah';
const AST = parse(`
var intro = greeting();
function greeting() {
return 'Hello world!';
lukeed / componenets-App-index.js
Last active Apr 7, 2020
PWA w/ styled-componets extracting CSS
View componenets-App-index.js
import React from 'react';
import { HMR } from '@pwa/preset-react';
import Button from '@components/Button';
import style from './index.css';
class App extends React.Component {
render() {
return (
<div className={ }>
<main className={ style.wrapper }>
View navigator.connection.d.ts
// stick this somewhere in your local @types/** files
interface NetworkInformation extends EventTarget {
readonly downlink: number;
readonly downlinkMax?: number;
readonly effectiveType: 'slow-2g' | '2g' | '3g' | '4g';
readonly rtt: number;
readonly saveData: boolean;
readonly type: 'bluetooth' | 'cellular' | 'ethernet' | 'none' | 'wifi' | 'wimax' | 'other' | 'unknown';
onchange: EventListener;
lukeed /
Last active Mar 6, 2021
TypeScript definitions for `polka@next` – These will be made available as "@types/polka" when 1.0 is ready!
declare module 'polka' {
import { Server } from 'net';
import { IncomingMessage, ServerResponse } from 'http';
import Trouter from 'trouter';
export interface IError extends Error {
message: string;
code?: number;
stack?: string;
status?: number;
View index.html
<!DOCTYPE html>
<meta charset="utf-8" />
<title>Perflink | JS Benchmarks</title>
content="JavaScript performance benchmarks that you can share via URL."
lukeed / micro.js
Created Jan 12, 2018
Polka vs Micro vs Native
View micro.js
const micro = require('micro');
micro((req, res) => {
if (req.url === '/') {
return 'Hello';
if (req.url.indexOf('/user/') === 0) {
// cheating, but ok
return `Hello user ${req.url.substring(6)}`;
lukeed / cached-loops.js
Created Jul 10, 2017
cached vs non-cached perf
View cached-loops.js
const LOOPS = 1e6;
const LEN = 1e3;
function test(fn) {
let i = 0;
const data = new Array(LEN);
const start =;
for (; i < LOOPS; i++) {
lukeed /
Last active Nov 12, 2021
OSX Dock Spacers


Some MacOS users have very cluttered Docks & wish they could organize them without removing any App icons from the mix.

This snippet will add an empty "spacer" that you can drag around and use to separate icons into groups! See example.


Paste this into your Terminal. Run the command for additional placeholders!

lukeed /
Created Feb 9, 2017
Keybase ID Verification

Keybase proof

I hereby claim:

  • I am lukeed on github.
  • I am lukeed ( on keybase.
  • I have a public key whose fingerprint is 34F6 B8EF 7C20 AA3F B07A 441F 18A4 5162 5B88 FB28

To claim this, I am signing this object: