Skip to content

Instantly share code, notes, and snippets.

View Nooshu's full-sized avatar

Matt Hobbs Nooshu

View GitHub Profile
@Nooshu
Nooshu / results.json
Created November 29, 2018 14:05
GOV.UK Pay
{
"userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/69.0.3497.81 Safari/537.36",
"environment": {
"networkUserAgent": "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/69.0.3497.81 Mobile Safari/537.36 TreoWorker/3.2.1",
"hostUserAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/69.0.3497.81 Safari/537.36",
"benchmarkIndex": 942
},
"lighthouseVersion": "3.2.1",
"fetchTime": "2018-11-29T13:34:25.809Z",
"requestedUrl": "https://www.payments.service.gov.uk/",
@Nooshu
Nooshu / latency.markdown
Created December 9, 2018 22:02 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@Nooshu
Nooshu / cloudfront-test-command.sh
Last active September 7, 2019 14:03
Testing the OCSP stapling of Cloudfront and Fastly
# cloudfront test
# requires: https://github.com/rcoh/angle-grinder
while true; do bash -c 'echo hello | openssl s_client -connect www.digitalmarketplace.service.gov.uk:443 -tls1_2 -tlsextdebug -status -servername www.digitalmarketplace.service.gov.uk 2>&1 | grep -q "OCSP Response Status: successful" ; echo $?'; sleep 0.5; done | agrind '* | parse "*" as code | count by code'
# Is OCSP stapling used?
# code _count
# --------------------------
# 1 (no) 151
# 0 (yes) 49
@Nooshu
Nooshu / wpt-font-injection.js
Created February 20, 2020 00:25
Modify `font-display` settings via WPT script injection
(function(){
// create our custom link tag for the stylesheet
var url = "https://www.example.com/static/app.css"; // IMPORTANT: this is the CSS that contains your @font-face rules
var head = document.getElementsByTagName('head')[0];
var link = document.createElement('link');
link.type = "text/css";
link.rel = "stylesheet"
link.href = url;
// append the stylesheet to the head
@Nooshu
Nooshu / test-page-script.js
Created February 23, 2020 03:36
Simple sample script to test the font load modificaion technique
// Test Page: https://keen-northcutt-3190bd.netlify.com/standard-load.html
// Paste below into the WPT Inject Script textarea.
(function(){
var montserratBold = new FontFace('montserratbold_italic', 'url(fonts/montserrat-bolditalic-webfont.woff2)', {
display: 'swap', // test the page using 'swap'
weight: '700'
});
document.fonts.add(montserratBold);
@Nooshu
Nooshu / curl-format.txt
Created July 30, 2020 21:05
cURL format for timing information
time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_pretransfer: %{time_pretransfer}\n
time_redirect: %{time_redirect}\n
time_starttransfer: %{time_starttransfer}\n
----------\n
time_total: %{time_total}\n
@Nooshu
Nooshu / full-schema.txt
Created September 30, 2020 21:21
WebPageTest API 'schema'
id
url
summary
testUrl
location
from
connectivity
bwDown
bwUp
latency
@Nooshu
Nooshu / inner-structure.json
Created September 30, 2020 22:33
WebPageTest inner API run data structure
{
"Colordepth": "number",
"Dpi": "string",
"Images": "string",
"LastInteractive": "number",
"LayoutShifts": "array",
"PerformancePaintTiming.first-contentful-paint": "number",
"PerformancePaintTiming.first-paint": "number",
"Resolution": "string",
"SpeedIndex": "number",
@Nooshu
Nooshu / connection-metrics.jq
Created October 7, 2020 22:05
Extract connection information from the WebPageTest API and format as a CSV
#!/usr/bin/env jq -rMf
# Filter to extract DNS, Connect, SSL metrics from WebPageTest run JSON
# Headers for resulting CSV
["DNS", "Connect", "SSL"],
# drill down into the runs data
(
.data.runs
# convert the run data into an object and drill down into the run request data
@Nooshu
Nooshu / other-run-metrics-filtered.jq
Last active October 8, 2020 13:51
Extract data from WebPageTest and filter out the obvious broken results
#!/usr/bin/env jq -rMf
# Extract other metrics from the run data
# Headers for resulting CSV
["TTFB", "First Contentful Paint", "Start Render", "DOM Complete" , "Fully Loaded"],
# drill down into the runs data
(
.data.runs
# convert the run data into an object and drill down into the run request data