Skip to content

Instantly share code, notes, and snippets.

Alf Eaton hubgit

Block or report user

Report or block hubgit

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
View Queue.ts
type QueueItem = () => Promise<void>
export class Queue {
private items: QueueItem[] = []
private running: boolean = false
public add = (item: QueueItem): void => {
this.items.push(item)
@hubgit
hubgit / fetch-wikidata-dump.js
Created Jul 26, 2019
Fetch and decompress a Wikidata dump
View fetch-wikidata-dump.js
const fs = require('fs')
const https = require('https')
const unbzip2Stream = require('unbzip2-stream')
const url =
'https://dumps.wikimedia.org/wikidatawiki/entities/latest-all.json.bz2'
const decompress = unbzip2Stream()
const output = fs.createWriteStream('data/latest.json')
@hubgit
hubgit / muse-merge.js
Last active Jun 25, 2019
Given a Project Muse book id, this will fetch each chapter and merge them into a single PDF.
View muse-merge.js
const fetch = require("node-fetch");
const url = require("url");
const { Parser } = require("htmlparser2");
const hummus = require("hummus");
const BOOK_ID = "66229"; // EDIT THIS
const OUTPUT_FILE = `${BOOK_ID}.pdf`;
const extractURLs = async () => {
View person.json
{
"@context": "https://unwalled.garden/person.jsonld",
"title": "Paul Frazee",
"description": "Beaker guy",
"follows": [
"dat://alice.com",
"dat://bob.com"
]
}
View twitter-archive-viewer.html
<!DOCTYPE html>
<meta charset="utf-8">
<title>Twitter Archive Viewer</title>
<script>window.YTD = { tweet: {} }</script>
<script src="tweet.js"></script><!-- this is loading a file from the archive -->
<style>
.tweet { border: 1px solid #eee; margin: 8px }
.full_text { padding: 8px }
.created_at { padding: 8px; color: #777 }
</style>
View iplayer-clip-with-subtitles.sh
brew install get_iplayer
PID=m00042g3
get_iplayer --subtitles --file-prefix="<pid>" --output=$PWD --pid $PID
ffmpeg -i $PID.mp4 -ss 00:25:26 -t 00:01:59 -vf subtitles=$PID.srt $PID-clip-subtitles.mp4
View generate-xsl.php
<?php
$saxon = new Saxon\SaxonProcessor();
print "{$saxon->version()}\n";
$input = 'schematrons/1.0/jats4r-topic.sch';
$xsl = 'skeleton/iso_schematron_skeleton_for_saxon.xsl';
$output = 'jats4r-topic.xsl';
$processor = $saxon->newXsltProcessor();
@hubgit
hubgit / scripts-package.json
Created Feb 14, 2019
npm scripts for typescript libraries
View scripts-package.json
"scripts": {
"build": "npm-run-all --parallel build:*",
"build:cjs": "tsc --outDir dist/cjs --module commonjs",
"build:es": "tsc --outDir dist/es --declarationDir dist/types --declaration",
"dev": "npm-run-all --parallel \"build:* --watch\"",
"lint": "tslint --project .",
"prebuild": "rimraf dist",
"prettier": "prettier --write \"src/**/*.{ts,tsx}\" \"*.{js,json}\"",
"preversion": "npm-run-all --parallel typecheck lint test",
"test": "jest",
@hubgit
hubgit / docker-env-arg.md
Last active Feb 4, 2019
Sources of variables in docker-compose.yml, Dockerfile, and the applications they start
View docker-env-arg.md

Used in docker-compose.yml

  • environment variables in the shell where docker-compose is run
  • values set in an .env file in the folder where docker-compose is run

Used in Dockerfile

  • build args set in docker-compose.yml (build > args, object) and imported with ARG in Dockerfile
  • values set with ARG in Dockerfile
View just-keep-scrolling.js
window.setInterval(() => window.scrollTo(0, document.body.scrollHeight), 1000)
You can’t perform that action at this time.