Skip to content

Instantly share code, notes, and snippets.

hubgit /
Created Aug 31, 2020
rsync dry run with stats to summarise a backup of a remote server
rsync -avzh --progress --dry-run --stats -e ssh example:/ . --exclude=/backups --exclude=/boot --exclude=/build --exclude=/dev --exclude=/dump --exclude=/initrd --exclude=/latest --exclude=/lost+found --exclude=/media --exclude=/mnt --exclude=/nonexistent --exclude=/proc --exclude=/run --exclude=/selinux --exclude=/srv --exclude=/sys --exclude=/tmp
hubgit / EditorProvider.ts
Created Aug 28, 2020
A React context provider with undefined default value that exports a hook for accessing the context value
View EditorProvider.ts
import { EditorState } from 'prosemirror-state'
import { EditorView } from 'prosemirror-view'
import React, { createContext, useContext, useEffect, useState } from 'react'
import { Editor } from '../Editor'
const EditorContext = createContext<EditorState | undefined>(undefined)
export const useEditorContext = () => {
const editor = useContext(EditorContext)
hubgit / wikidata-isbn.js
Created Jul 25, 2020
Search Wikidata for a book by ISBN, then use Citation.js to fetch the metadata
View wikidata-isbn.js
const Cite = require('citation-js')
const isbn = '978-1-4088-4564-6'
// search ISBN-13 or ISBN-10 (note hyphens and case-sensitivity)
const sparql = `
?subject wdt:P31 wd:Q7725634.
{ ?subject wdt:P212 '${isbn}'. } UNION { ?subject wdt:P957 '${isbn}'. }
View atypon-logo.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View test.xml
<article xmlns="" xmlns:xsi="" xmlns:mml="" xmlns:xlink="" xsi:schemaLocation="" article-type="research-article">
<journal-id journal-id-type="nlm-ta">BMC Cell Biol</journal-id>
<journal-title>BMC Cell Biology</journal-title>
<issn pub-type="epub">1471-2121</issn>
<publisher-name>BioMed Central</publisher-name>
yarn init -y
yarn add --dev @11ty/eleventy
yarn eleventy --serve
hubgit /
Created Jun 25, 2020
Kubernetes Dashboard user
hubgit / ns-resolver.ts
Last active Jun 24, 2020
Creating a namespace resolver for document.evaluate
View ns-resolver.ts
// from the doc or node being parsed
const namespaceResolver = doc.createNSResolver(doc)
// from XML you control
const namespaceResolverDoc = new DOMParser().parseFromString(
`<TEI xmlns=""/>`,
hubgit / execfile-promise-pipe.js
Created Jun 17, 2020
Pipe input to a promisified execFile command
View execfile-promise-pipe.js
const promise = promisify(execFile)('foo', {
encoding: 'buffer', // remove this to get the output as a string
const { stdout: output } = await promise
You can’t perform that action at this time.