Skip to content

Instantly share code, notes, and snippets.

View domtronn's full-sized avatar
🔥

Dom Charlesworth domtronn

🔥
View GitHub Profile
@domtronn
domtronn / readme.md
Created November 23, 2023 12:39
INP Inlined debugger

This script is designed to be used within BrowersStack as a "quick" way to get the WebVitals reporting on INP for mobile devices

It uses the web-vitals library and provides a slimmed down version of the official web-vitals chrome extension

Usage

@domtronn
domtronn / index.html
Last active May 13, 2022 08:45
HTML Page to test the support for CWV reporting
<html>
<head>
<style>
body { font-family: sans-serif; width: 100%; }
div,body { text-align: center; }
h1,h2,h3,button { color: #2a2a2a; font-family: sans-serif; margin: 0; }
#browser.success,.success { color: #0bce6b; }
.failure { color: #ff4e42; }
.hide { color: rgba(0,0,0,0); }
#!/usr/bin/env bash
# This script compares the different compression & download times of a cdn using the `Accept-Encoding` header
# It will compare Brotli, Gzip, and uncompressed responses
#
# ./compare-compress.sh https://my-url.com
set -euo pipefail
URL=$1
@domtronn
domtronn / background.js
Created June 3, 2021 07:33
Background chrome script to download cookies for a domain
const DOMAIN = 'calendar.google.com'
const FILENAME = 'gcal-cookies.txt'
/** --------
This background chrome extension script will download all cookies
for a page into a file periodically when you visit, useful for if
you can't generate your own API Access tokens or service accounts
but want to use your logged in cookies to read from a service,
e.g. google calendar
@domtronn
domtronn / representative-sitemap.js
Last active March 20, 2020 11:44
Generate representative URLs of your IA from a sitemap
/*
* You will need to run
* npm install xml2json node-fetch
*
* Run this script using
* SITEMAP_DOMAIN=... SITEMAP_PATH=... node index.js
*/
var fetch = require('node-fetch')
var p = require('xml2json')
@domtronn
domtronn / switch.js
Created February 13, 2020 11:24
A functional cond/case switch statement in js
/**
* @typedef {Function} CaseFunction
* @param {...*} [args] - List of args provided to anonymous function
*/
/**
* @typedef {Function} SwitchFunction
* @param {string} [c='default'] - case string to match
* @param {...*} [args] - args to pass to matched SwitchFunction
* @returns {*} - Result of matching case in SwitchMap either CaseFunction called with args, or value
@domtronn
domtronn / itunes.el
Created January 22, 2020 14:21
A package to control iTunes from Emacs using Applescript
;;; .itunes.el --- Package to interact with iTunes & Apple music from within Emacs
;;; Commentary:
;;
;;; Code:
(require 'dash)
(defvar -itunes-playlist "Emacs - temporary"
"The name of the playlist to create for temporary housing tracks.")
@domtronn
domtronn / init_vec_ints.cpp
Last active August 29, 2015 14:27
A quick remainder on the easiest way to initialise a vector of integers pre C++11.
int ints[] = {1,2,3,4,5};
vector<int> vec (ints, ints + sizeof(ints) / sizeof(ints[0]) );