Skip to content

Instantly share code, notes, and snippets.

View Nooshu's full-sized avatar

Matt Hobbs Nooshu

View GitHub Profile
@Nooshu
Nooshu / keybase.md
Created November 9, 2022 23:28
Keybase verification
View keybase.md

Keybase proof

I hereby claim:

  • I am nooshu on github.
  • I am nooshu (https://keybase.io/nooshu) on keybase.
  • I have a public key ASBCRLMxl43e97uxrIel2AGJe3YogjGesCXWclMgF3SZfwo

To claim this, I am signing this object:

@Nooshu
Nooshu / webmention.js
Created September 6, 2021 22:55
Copy of the webmention.js file modified when migrating domains from GH Pages to Netlify and Cloudflare.
View webmention.js
/** @preserve Based heavily on the work by Keith Grant (keithjgrant.com) **/
// IIFE to restrict global namespace
(function(){
// link to the anonymous avatar
const ANON_AVATAR = '/images/app-shell/mm.png';
// cloudinary app code (remember to restrict to set domains in settings)
const CLOUD_CODE = 'dffhrhuy4';
// var to store the built HTML
@Nooshu
Nooshu / iphone-versions.txt
Created June 18, 2021 08:16
Extracting iPhone versions from GA using DataStudio. Create a new field, use it as the breakdown dimension.
View iphone-versions.txt
CASE
when Screen Resolution IN ("320x480") THEN "iPhone 1-4"
when Screen Resolution IN ("320x568") THEN "iPhone 5, SE, 5C, 5S"
when Screen Resolution IN ("375x667") THEN "iPhone 6, 6S, 7, 8, SE 2020"
when Screen Resolution IN ("414x736") THEN "iPhone 6+, 6S+, 7+, 8+"
when Screen Resolution IN ("375x812") THEN "iPhone X, XS, 11 Pro"
when Screen Resolution IN ("414x896") THEN "iPhone 11, XR, XS Max, 11 Pro Max"
when Screen Resolution IN ("390x844") THEN "iPhone 12, 12 Pro"
when Screen Resolution IN ("360x780") THEN "iPhone 12 Mini"
when Screen Resolution IN ("428x926") THEN "iPhone 12 Pro Max"
@Nooshu
Nooshu / worker-css.js
Created March 15, 2021 09:14
Changing the font family of the BBC News website using a cloudflare worker.
View worker-css.js
const site = 'www.bbc.co.uk';
const subdomain1 = 'm.files.bbci.co.uk';
addEventListener('fetch', event => {
const request = event.request
event.respondWith(handleRequest(request))
});
async function handleRequest(request) {
const url = new URL(request.url);
@Nooshu
Nooshu / worker-css.js
Created March 11, 2021 23:43
Changing the font family of the BBC News website using a cloudflare worker.
View worker-css.js
// what are the domains we are wanting to modify
const site = 'www.bbc.co.uk';
const subdomain1 = 'm.files.bbci.co.uk';
// do this on a fetch
addEventListener('fetch', event => {
const request = event.request
event.respondWith(handleRequest(request))
});
@Nooshu
Nooshu / worker-remove-resource-hints.js
Created March 2, 2021 23:21
Simple example of how to remove resource hints from the HTML in the `<head>`
View worker-remove-resource-hints.js
// set the site we are modifying
const site = 'www.example.com';
// do this on a fetch
addEventListener('fetch', event => {
const request = event.request
const url = new URL(request.url)
event.respondWith(handleRequest(request))
});
@Nooshu
Nooshu / worker-remove-header.js
Created March 2, 2021 23:05
Simple example of using a CF Worker to remove a resource hint header.
View worker-remove-header.js
// set the site we are modifying
const site = 'www.example.com';
// do this on a fetch
addEventListener('fetch', event => {
const request = event.request
const url = new URL(request.url)
event.respondWith(handleRequest(request))
});
@Nooshu
Nooshu / worker-head-body-scripts.js
Created March 2, 2021 00:57
Easily adding multiple scripts to the head and body of a HTML page.
View worker-head-body-scripts.js
// set the site we are modifying
const site = 'www.example.com';
// do this on a fetch
addEventListener('fetch', event => {
const request = event.request
const url = new URL(request.url)
event.respondWith(handleRequest(request))
});
@Nooshu
Nooshu / worker-defer-async.js
Created March 2, 2021 00:30
Using a CF Worker to add `async` or `defer` to a script tag in the page
View worker-defer-async.js
// set the site we are modifying
const site = 'www.example.com';
// do this on a fetch
addEventListener('fetch', event => {
const request = event.request
const url = new URL(request.url)
event.respondWith(handleRequest(request))
});
@Nooshu
Nooshu / worker-inline-scripts.js
Created March 2, 2021 00:01
Use a CF Worker to add an inline script to the page
View worker-inline-scripts.js
// set the site we are modifying
const site = 'www.example.com';
// do this on a fetch
addEventListener('fetch', event => {
const request = event.request
const url = new URL(request.url)
event.respondWith(handleRequest(request))
});