Skip to content

Instantly share code, notes, and snippets.

View injms's full-sized avatar
🦆
is typing...

Ian James injms

🦆
is typing...
View GitHub Profile
@injms
injms / package.json
Created July 28, 2022 10:23
Quick script to get the the breakdown of assets by type for the top 100 pages on GOV.UK
{
"engines" : {
"node" : "18.4.0"
},
"dependencies": {
"puppeteer": "15.5.0"
}
}
@injms
injms / index.js
Last active June 4, 2021 12:12
Screenshot diffr
const playwright = require('playwright')
const Jimp = require('jimp')
const enableJavaScript = true
const domains = {
live: 'https://www.gov.uk',
preview: 'http://collections.dev.gov.uk' // Change this to your development URL
}
require 'nokogiri'
require 'open-uri'
homepage = Nokogiri::HTML(URI.open('https://www.gov.uk/'))
organisations = Nokogiri::HTML(URI.open('https://www.gov.uk/government/organisations/'))
# Homepage selectors to find the number of ministerial departments and agencies
agencies_on_homepage_selector = '[href="/government/organisations#agencies_and_other_public_bodies"] .home-numbers__large'
agencies_on_organisation_page_selector = '#agencies_and_other_public_bodies + .organisations__department-count-wrapper .js-department-count'
{
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36",
"environment": {
"networkUserAgent": "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3694.0 Mobile Safari/537.36 Chrome-Lighthouse",
"hostUserAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36",
"benchmarkIndex": 1302
},
"lighthouseVersion": "5.2.0",
"fetchTime": "2019-10-31T11:39:13.744Z",
"requestedUrl": "https://carbon-gizmo.wwf.org.uk/",
@injms
injms / radio-button-lighthouse-accessibility-audit.json
Created August 31, 2018 15:52
JSON output from a Lighthouse accessibility audit
{
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36",
"lighthouseVersion": "3.0.0-beta.0",
"fetchTime": "2018-08-31T15:50:40.068Z",
"requestedUrl": "https://design-system.service.gov.uk/components/radios/conditional-reveal/index.html",
"finalUrl": "https://design-system.service.gov.uk/components/radios/conditional-reveal/index.html",
"runWarnings": [],
"audits": {
"accesskeys": {
"id": "accesskeys",
@injms
injms / keybase.md
Created July 24, 2018 12:19
Keybase verification.

Keybase proof

I hereby claim:

  • I am injms on github.
  • I am injms (https://keybase.io/injms) on keybase.
  • I have a public key whose fingerprint is A43B 5BD3 9A5A A760 9E3E 483B B6A8 F1FF ACB0 8ACA

To claim this, I am signing this object:

@injms
injms / antispambot.js
Created December 4, 2017 14:56
A port of WordPress's antispambot function from PHP to JavaScript
let getRandomIntInclusive = (min, max) => {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min; //The maximum is inclusive and the minimum is inclusive
}
let zeroise = (number, threshold) => {
if (number.length === threshold) {
return number;
}