Skip to content

Instantly share code, notes, and snippets.

Paul Irish paulirish

Block or report user

Report or block paulirish

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@paulirish
paulirish / asciiify-the-canvas.js
Last active Jun 26, 2019
ascii rendering of a canvas
View asciiify-the-canvas.js
// works great on about:dino
// 1. save this file to your snippets.
// 2. load about:dino
// 3. evaluate the snippet
// 4. hit up arrow to trigger the game.
// 5. profit
(function() {
perfnow = performance.now;
View localhost_2018-03-12_17-55-45.lighthouse.report.json
{"userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3358.0 Safari/537.36","environment":{"networkUserAgent":"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36(KHTML, like Gecko) Chrome/66.0.3359.30 Mobile Safari/537.36","hostUserAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3358.0 Safari/537.36","benchmarkIndex":1000},"lighthouseVersion":"4.3.1","fetchTime":"2018-03-13T00:55:45.840Z","requestedUrl":"http://localhost:10200/dobetterweb/dbw_tester.html","finalUrl":"http://localhost:10200/dobetterweb/dbw_tester.html","runWarnings":[],"audits":{"is-on-https":{"id":"is-on-https","title":"Does not use HTTPS","description":"All sites should be protected with HTTPS, even ones that don't handle sensitive data. HTTPS prevents intruders from tampering with or passively listening in on the communications between your app and your users, and is a prerequisite for HTTP/2 and man
@paulirish
paulirish / thing.js
Created May 7, 2018
log the clipboard contents
View thing.js
document.body.innerHTML = 'Paste or drop items onto this page. View results in console.';
function getPayload(item) {
const kind = item.kind;
switch (kind) {
case 'string': return new Promise(res => item.getAsString(res));
case 'file': return Promise.resolve(item.getAsFile());
default: throw new Error('unknown item kind! ' + kind);
}
@paulirish
paulirish / generate_report.js
Last active Aug 20, 2019
hacking on lighthouse report
View generate_report.js
'use strict';
/* eslint-disable */
const fs = require('fs');
const path = require('path');
const ReportGenerator = require('../../lighthouse-core/report/report-generator');
const jsonPath = __dirname + '/../_json/';
@paulirish
paulirish / eqt.js
Last active Mar 17, 2019
Expected Queueing Time metric
View eqt.js
// Expected Queueing Time
// https://docs.google.com/document/d/1Vgu7-R84Ym3lbfTRi98vpdspRr1UwORB4UV-p9K1FF0/edit
// Initial impl by Nicolás Peña (npm), Tim Dresser (tdresser)
// Usage:
// var eqt = EQT.begin();
// // ...
// const {expectedQueueingTime} = EQT.end();
class EQT {
constructor() {
View genesis_public_key
0459bbe48fa3e4591000459ccc8f6a6e0b046f51acbfacd862e9d402b5379d3ff00a6569b94f838772e0362eba4af38f9a856d177b9b8f936615f21cc5607a803e
@paulirish
paulirish / log-the-datatransfer-data.js
Created Feb 15, 2018
log paste and copy event payloads
View log-the-datatransfer-data.js
document.body.innerHTML = 'Paste or drop items onto this page. View results in console.';
function getPayload(item) {
const kind = item.kind;
switch (kind) {
case 'string': return new Promise(res => item.getAsString(res));
case 'file': return Promise.resolve(item.getAsFile());
default: throw new Error('unknown item kind! ' + kind);
}
@paulirish
paulirish / coverage.js
Created Jul 12, 2017
JS coverage profiler data via protocol
View coverage.js
'use strict';
const chromeLauncher = require('chrome-launcher');
const CDP = require('chrome-remote-interface');
const launchChrome = () =>
chromeLauncher.launch({
chromeFlags: ['--disable-gpu', '--headless']
});
@paulirish
paulirish / install_mosh_locally.sh
Last active Jul 22, 2019 — forked from xiaom/install_mosh_locally.sh
install mosh locally (updated june 2017)
View install_mosh_locally.sh
#!/bin/bash
# 2017-06 (paulirish): updated for latest sources
# and incorporated fixes from my comments here: https://gist.github.com/xiaom/8264691#gistcomment-1648455
# 2015-ish (zmil): this script does absolutely ZERO error checking. however, it worked
# for me on a RHEL 6.3 machine on 2012-08-08. clearly, the version numbers
# and/or URLs should be made variables. cheers, zmil...@cs.wisc.edu
set -x
@paulirish
paulirish / server-timing-demo.js
Last active Jul 31, 2018
Demo of server timing values. visualized in chrome devtools
View server-timing-demo.js
// see for screenshot:
// https://twitter.com/paul_irish/status/829090506084749312
const http = require('http');
function requestHandler(request, response) {
const headers = {
'Server-Timing': `
sql-1;desc="MySQL lookup Server";dur=100,
sql-2;dur=900;desc="MySQL shard Server #1",
You can’t perform that action at this time.