Skip to content

Instantly share code, notes, and snippets.

View Nooshu's full-sized avatar

Matt Hobbs Nooshu

View GitHub Profile
@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.
/** @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 / terraform.json
Created June 19, 2024 13:20
Example of compression terraform
{
name = "nfdiv"
custom_domain = "nfdiv.perftest.platform.hmcts.net"
dns_zone_name = "perftest.platform.hmcts.net"
mode = "Prevention"
backend_domain = ["firewall-nonprodi-palo-cft-perftest.uksouth.cloudapp.azure.com"]
disabled_rules = {
SQLI = [
"942100",
"942150",
Yesterday evening (14 June), at around 8:55pm, we received reports that a cow was running loose in Staines-upon-Thames. The cow was running loose throughout the evening on a number of main roads and during this time, we received numerous calls from the public reporting a car being damaged and it running at members of the public. Given these reports, officers were extremely concerned about the public's safety, and over a period of a number of hours tried a number of options to safely capture the cow.
Unfortunately, these were unsuccessful, and the decision was made to stop it using a police car. This matter has been referred to our Professional Standards Department. The Independent Office for Police Conduct (IOPC) has been notified and a voluntary referral will be made in due course.
With support from a member of the public, the cow was moved to a nearby farm in the early hours of this morning (15 June). The owner has been located and the cow's injuries have been assessed by a vet. The cow sustained a large
@Nooshu
Nooshu / index.html
Last active January 26, 2023 11:12
Example service worker file that uses Workbox
<body>
<!-- ..... -->
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
// Scope will be restricted to the path where the service-worker-example.js file is located
navigator.serviceWorker.register('/service-worker-example.js', {scope: '/'}).then(registration => {
console.log('Service Worker registered: ', registration)
}).catch(registrationError => {
console.log('Service Worker registration failed: ', registrationError)
@Nooshu
Nooshu / keybase.md
Created November 9, 2022 23:28
Keybase verification

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 / worker-head-body-scripts.js
Created March 2, 2021 00:57
Easily adding multiple scripts to the head and body of a HTML page.
// 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-elements.js
Created March 1, 2021 22:44
Get a CF Worker to remove selected elements from a pages HTML
// 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 / simplified-wpt-font-injection.js
Created February 23, 2020 03:32
Simplified script for injecting fonts into WebPageTest
(function(){
// this will trigger a font load
var customFont1 = new FontFace('custom font name', 'url([FONT_URL_HERE])', {
display: 'block', // display setting to test here
weight: '700' // font-weight
// other font properties here
});
// IMPORTANT: add the font to the document
document.fonts.add(customFont1);
@Nooshu
Nooshu / chrome-cli-command.txt
Created February 17, 2021 23:41
Example Cloudflare Worker script to add preloads to the `<head>` of a page and enable priority hints
// add this command to the CLI to enable priority hints
--enable-experimental-web-platform-features
@Nooshu
Nooshu / failed.txt
Created August 9, 2020 22:16
Chrome headers for WOFF2 fonts, failed and successful.
:status: 200
content-type: binary/octet-stream
content-length: 67900
date: Tue, 21 Apr 2020 21:50:57 GMT
last-modified: Tue, 21 Apr 2020 14:32:51 GMT
etag: "f38ad40456df126d75363b9d7b12c979"
cache-control: max-age=315360000,immutable
accept-ranges: bytes
server: AmazonS3
x-cache: Hit from cloudfront