Skip to content

Instantly share code, notes, and snippets.

View martinschierle's full-sized avatar

Martin Schierle martinschierle

View GitHub Profile
@martinschierle
martinschierle / readme.md
Last active May 3, 2018 07:46
Cache warmup page

Simple cache warmup file with the most common dependencies of websites out there

@martinschierle
martinschierle / initialRender.js
Created May 7, 2018 12:29
Small puppeteer script to find out how much content of the first viewport is loaded and rendered just with initial html response
const puppeteer = require('puppeteer');
const devices = require('puppeteer/DeviceDescriptors');
const pixelmatch = require('pixelmatch');
var fs = require('fs');
const phone = devices['Nexus 5X'];
var first = true;
async function writeScreenshot(url, filename, initial) {
const browser = await puppeteer.launch();
@martinschierle
martinschierle / ctaComplete.js
Created June 22, 2018 20:22
New Perofrmance Metric - last time the CTA changed
const puppeteer = require('puppeteer');
const devices = require('puppeteer/DeviceDescriptors');
const pixelmatch = require('pixelmatch');
const extractDomain = require('extract-domain');
var fs = require('fs');
//we'll simulate a nexus 5x for this
const phone = devices['Nexus 5X'];
/**
Will be called after page is loaded to find the CTA and return some info about it,
@martinschierle
martinschierle / checkGPay.js
Created July 16, 2018 07:21
Small JS snippet to use via console to check gpay availability
var e = document.createElement("script");
e.src = "https://pay.google.com/gp/p/js/pay.js";
document.head.appendChild(e);
e.onload = function(){
var paymentsClient = new google.payments.api.PaymentsClient({environment: 'TEST'});
var allowedPaymentMethods = ['CARD', 'TOKENIZED_CARD'];
const puppeteer = require('puppeteer');
const lighthouse = require('lighthouse');
const devices = require('puppeteer/DeviceDescriptors');
const pixelmatch = require('pixelmatch');
const {URL} = require('url');
var fs = require('fs');
var first = true;
const phone = devices['Nexus 5X'];
/** Small puppeteer script to calculate lines of code as used by a website,
* to use in infogrphics like this:
* https://informationisbeautiful.net/visualizations/million-lines-of-code/
**/
'use strict';
const puppeteer = require('puppeteer');
const fs = require('fs');
var htmlparser = require("htmlparser2");
@martinschierle
martinschierle / layout_stability.js
Created June 27, 2019 07:19
Use puppeter to automatically derive a website layout stability score using the new layout instability API (see https://web.dev/layout-instability-api). Currently the feature is still behind experimental feature flag, which might not always work right depending on the Chrome you test with.
const puppeteer = require('puppeteer');
const devices = require('puppeteer/DeviceDescriptors');
const Good3G = {
'offline': false,
'downloadThroughput': 1.5 * 1024 * 1024 / 8,
'uploadThroughput': 750 * 1024 / 8,
'latency': 40
};
const puppeteer = require('puppeteer');
const devices = require('puppeteer/DeviceDescriptors');
const Good3G = {
'offline': false,
'downloadThroughput': 1.5 * 1024 * 1024 / 8,
'uploadThroughput': 750 * 1024 / 8,
'latency': 40
};
const puppeteer = require('puppeteer');
const devices = require('puppeteer/DeviceDescriptors');
const Good3G = {
'offline': false,
'downloadThroughput': 1.5 * 1024 * 1024 / 8,
'uploadThroughput': 750 * 1024 / 8,
'latency': 40
};
@martinschierle
martinschierle / zombiegame.ino
Last active October 28, 2019 22:19
Small game - inspired by the esp8622 'SpyGame' (humans vs. zombies), but newly written for M5Stick, using its display
#include <WiFi.h>
#include <M5StickC.h>
int team = 0;
String teamnames[2] = { "Human", "Zombie"};
int zombieTeam = 1;
int humanTeam = 0;
int colors[2] = { GREEN, RED};
int hideTime = 30; // in seconds