Skip to content

Instantly share code, notes, and snippets.

View CrystalDave's full-sized avatar

David Ross CrystalDave

View GitHub Profile
@pmeenan
pmeenan / wpt-hints.md
Last active March 18, 2023 16:48
Testing Priority Hints with WebPageTest

Priority Hints is rolling out to Chrome in the 101 release which is currently available in the Dev/Beta channel of Chrome and available in WebPageTest when using the Chrome Canary browser selection.

To make it easier to experiment with priority hints (particularly for LCP images) without making production changes, I set up a couple of public Cloudflare Workers that can be used dynamically with WebPageTest to inject priority hints into existing pages and to preload arbitrary images when combined with WebPageTest's overrideHost script command.

Injecting Priority Hints

There is a cloudflare worker at hint.perf.workers.dev that will take a CSS selector from the x-hint HTTP header and add fetchpriority=high to any elements in the HTML that match the selector. The easiest way to experiment with this is to use Chrome's dev tools locally, identify the element that hosts the imag

@sneakers-the-rat
sneakers-the-rat / clean_pdf.sh
Last active June 24, 2024 18:18
Strip PDF Metadata
# --------------------------------------------------------------------
# Recursively find pdfs from the directory given as the first argument,
# otherwise search the current directory.
# Use exiftool and qpdf (both must be installed and locatable on $PATH)
# to strip all top-level metadata from PDFs.
#
# Note - This only removes file-level metadata, not any metadata
# in embedded images, etc.
#
# Code is provided as-is, I take no responsibility for its use,
@ussjoin
ussjoin / Covid QR.md
Last active October 26, 2021 23:20
Getting your COVID QR code
@HenryHey
HenryHey / blaseballAutobet.js
Last active May 11, 2021 04:40
Blaseball auto bet to the team with the best (probably not) chance of winning
// This bookmarklet will auto bet on the team with highest odds. Or the left team if equal odds.
// I guess this saves around 20 seconds and 30 clicks of your life. You're welcome!
// 1. Create a new bookmark and give it a name
// 2. Paste the following code in the URL field
javascript:(async function () { let goBet=async e=>{length=document.getElementsByClassName("Widget-Button btn btn-success").length;for(let t=0;t<length;t++)try{document.getElementsByClassName("Widget-Button btn btn-success")[t].children[0].click(),await new Promise(t=>setTimeout(t,e)),[...document.getElementsByClassName("ModalForm-Form-Team-Percentage")].filter(e=>parseFloat(e.innerHTML)>=50)[0].click(),document.getElementsByClassName("ModalForm-Form-Inputs-Amount-Max")[0].click(),document.getElementsByClassName("ModalForm-Submit btn btn-success")[0].click(),await new Promise(t=>setTimeout(t,2*e))}catch(t){await new Promise(t=>setTimeout(t,2*e)),await goBet(500)}return"Done!"};await goBet(500); } )();
// 3. Go to https://www.blase
@andydavies
andydavies / cleanPage.js
Created February 9, 2021 15:23
DevTools snippet to remove the document contents and any event handlers on document and window objects
document.documentElement.innerHTML = '';
for (const obj of [document, window]) {
for (const event of Object.values(getEventListeners(obj))) {
for (const {type, listener, useCapture} of event) {
obj.removeEventListener(type, listener, useCapture)
}
}
}
@tkadlec
tkadlec / perf-diagnostics.css
Last active June 8, 2023 17:47
CSS used to highlight potential performance issues
:root {
--violation-color: red; /* used for clear issues */
--warning-color: orange; /* used for potential issues we should look into */
}
/* IMAGES */
/*
* Lazy-Loaded Images Check
* ====
@Neo23x0
Neo23x0 / Base64_CheatSheet.md
Last active July 5, 2024 17:29
Learning Aid - Top Base64 Encodings Table

Base64 Patterns - Learning Aid

Base64 Code Mnemonic Aid Decoded* Description
JAB 🗣 Jabber $. Variable declaration (UTF-16), e.g. JABlAG4AdgA for $env:
TVq 📺 Television MZ MZ header
SUVY 🚙 SUV IEX PowerShell Invoke Expression
SQBFAF 🐣 Squab favorite I.E. PowerShell Invoke Expression (UTF-16)
SQBuAH 🐣 Squab uahhh I.n. PowerShell Invoke string (UTF-16) e.g. Invoke-Mimikatz
PAA 💪 "Pah!" &lt;. Often used by Emotet (UTF-16)
@bluetidepro
bluetidepro / remove-advertisers.js
Last active December 29, 2023 06:27
Auto click "remove" on all facebook advertisers and Twitter interests
// I did this in Chrome...
//
// Go to https://www.facebook.com/ads/preferences/
// Click the "Advertisers" section to open it up.
// Click "See more" once
// Before doing anything else, just keep clicking space bar to trigger the "see more" button
// Do this for a bit until all the advertisers are loaded
// then run this below in the dev tools console...
// (It will take a few minutes, depending how many you have, and your browser may lock up, but once it's done you will see it auto clicked the "remove" X in the top right for all of them)
@anderskig
anderskig / Repo
Created May 18, 2018 07:25 — forked from aridastidar/Repo
Open a project file on GitHub.
#!/bin/bash
#
# Open the specified file on GitHub. It will use the current branch by default:
#
# repo app/controllers/application_controller.rb
#
# Specify a different branch:
#
# repo -b another-branch app/controllers/application_controller.rb