<commit_before>import * as http from 'http';
import * as util from 'util';
import * as express from 'express';
import * as puppeteer from 'puppeteer';
import * as _mkdirp from 'mkdirp';

const mkdirp = util.promisify(_mkdirp);

const { exec } = require('yargs').argv;

const margin = 0.4; /** inches */
const port = 5000;

export const run = async () => {
  const app = express();
  app.use(`/`, express.static(`public`));
  const server = await new Promise<http.Server>(resolve => {
    const newServer = app.listen(port, `0.0.0.0`, () => resolve(newServer));
  });
  const browser = await puppeteer.launch();
  try {
    const page = await browser.newPage({args: ['--no-sandbox', '--disable-setuid-sandbox']});
    await page.goto(`http://127.0.0.1:${port}/`, {
      waitUntil: 'networkidle',
      networkIdleTimeout: 5000,
    });
    await mkdirp(`public/download/`);
    await page.pdf({
      path: `public/download/Michael-Nigh.pdf`,
      printBackground: true,
      margin: {
        top: `${margin}in`,
        right: `${margin}in`,
        bottom: `${margin}in`,<commit_msg>workaround for webfonts not loading in pdf<commit_after>import * as http from 'http';
import * as util from 'util';
import * as express from 'express';
import * as puppeteer from 'puppeteer';
import * as _mkdirp from 'mkdirp';

const mkdirp = util.promisify(_mkdirp);

const { exec } = require('yargs').argv;

const margin = 0.4; /** inches */
const port = 5000;

export const run = async () => {
  const app = express();
  app.use(`/`, express.static(`public`));
  const server = await new Promise<http.Server>(resolve => {
    const newServer = app.listen(port, `0.0.0.0`, () => resolve(newServer));
  });
  const browser = await puppeteer.launch();
  try {
    const page = await browser.newPage({args: ['--no-sandbox', '--disable-setuid-sandbox']});
    await page.goto(`http://127.0.0.1:${port}/`, {
      waitUntil: 'networkidle',
      networkIdleTimeout: 5000,
    });
    // wait for first render - may be necessary for web fonts to load
    // https://github.com/GoogleChrome/puppeteer/issues/422
    await page.screenshot();
    await mkdirp(`public/download/`);
    await page.pdf({
      path: `public/download/Michael-Nigh.pdf`,
      printBackground: true,
      margin: {
        top: `${margin}in`,
        right: `${margin}in`,
        bottom: `${margin}in`,
{'fraction_non_alphanumeric': 0.1730118443316413, 'fraction_numerical': 0.018189509306260575, 'mean_word_length': 3.315693430656934, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '471193', 'n_tokens_mistral': 798, 'n_tokens_neox': 775, 'n_words': 198}