Skip to content

Instantly share code, notes, and snippets.

View stephenmathieson's full-sized avatar

Stephen Mathieson stephenmathieson

View GitHub Profile
@stephenmathieson
stephenmathieson / is-person-alive.js
Created March 9, 2022 01:50
Is a well-known person alive?
const { JSDOM } = require('jsdom');
const got = require('got').default;
const WIKIPEDIA_URL = 'https://en.wikipedia.org/wiki';
/**
* Check if the person with `firstName` and `lastName` is currently alive.
*
* @param {string} firstName
* @param {string} lastName
@stephenmathieson
stephenmathieson / slow-frame.js
Last active May 20, 2021 20:06
Little node app with a realllllyyy slow iframe
const http = require('http')
const server = http.createServer((req, res) => {
console.log('%s - %s', req.method, req.url)
if (req.url === '/frame') {
setTimeout(() => {
res.setHeader('Content-Type', 'text/html')
res.write(`
<!DOCTYPE html>
function fillBucket(remainingWeight, piles, n) {
if (n === 0 || remainingWeight === 0) {
return 0;
}
const pile = piles[n - 1];
if (pile.weight > remainingWeight) {
return fillBucket(remainingWeight, piles, n - 1);
}
@stephenmathieson
stephenmathieson / axe-puppeteer-up-lambda.js
Created July 17, 2018 20:32
An up-powered lambda fn for running axe-core
const chromium = require('chrome-aws-lambda');
const puppeteer = require('puppeteer');
const axeCore = require('axe-core');
const { createServer } = require('http');
const { parse: parseURL } = require('url');
const { PORT = 3000 } = process.env;
const analyze = async url => {
let browser;
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.1</version>
<executions>
<execution>
<goals>
@stephenmathieson
stephenmathieson / npm search slugify
Created October 24, 2016 21:42
npm out of memory
∴ npm search slugify
npm WARN Building the local index for the first time, please be patient
⸨░░░░░░░░░░░░░░░░░░⸩ ⠹ : WARN Building the local index for the first time, please be patient
<--- Last few GCs --->
33486 ms: Scavenge 1020.6 (1434.2) -> 1020.5 (1434.2) MB, 3.9 / 0 ms (+ 0.0 ms in 2 steps since last GC) [allocation failure].
33490 ms: Scavenge 1020.5 (1434.2) -> 1020.5 (1434.2) MB, 3.9 / 0 ms [allocation failure].
34443 ms: Mark-sweep 1020.5 (1434.2) -> 1020.4 (1434.2) MB, 952.7 / 0 ms (+ 738.6 ms in 3969 steps since start of marking, biggest step 6.6 ms) [last resort gc].
35417 ms: Mark-sweep 1020.4 (1434.2) -> 1020.4 (1434.2) MB, 974.3 / 0 ms [last resort gc].
@stephenmathieson
stephenmathieson / scaffold.go
Created November 13, 2015 23:29
go by example scaffold thing
package main
import (
"fmt"
"io/ioutil"
"net/http"
"os"
"regexp"
)
@stephenmathieson
stephenmathieson / user.sql
Created October 20, 2015 16:47
stupid stupid stupid
CREATE TABLE "user" (
id uuid DEFAULT uuid_generate_v1mc() NOT NULL,
organization_id uuid,
username character varying(255) NOT NULL,
email character varying(255) NOT NULL,
fancy_username_or_whatever varying(255) NOT NULL,
password character varying(255),
reset_token character varying(255),
reset_expiry timestamp with time zone,
is_admin boolean DEFAULT false NOT NULL,
$ valgrind --leak-check=full ./test
==5801== Memcheck, a memory error detector
==5801== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==5801== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==5801== Command: ./test
==5801==
# Test: parse_simple
OK