Skip to content

Instantly share code, notes, and snippets.

View jaredh159's full-sized avatar

Jared Henderson jaredh159

View GitHub Profile
@jaredh159
jaredh159 / QuakerBooks.md
Last active December 14, 2020 14:44
Quaker books
@jaredh159
jaredh159 / epub.adoc
Last active August 3, 2018 18:29
Epub Helper

Epub misc info

As of July 2018, it looks like we should be authoring EPUB 3.0.1. 3.1 seems to have been an overreach.

Terms

Rendition

A version of an epub. Like fixed-layout and reflowable. An epub author might want to package both in one epub, and the device could determin which or when to show which rendition. The spec also mentions the idea of multiple translations of a work being renditions of a single epub. It also refers to "…​the ability to move from the same spot in one Rendition to the equivalent spot in another as changes in the reading environment occur."

Package Document
@jaredh159
jaredh159 / lulu.js
Created September 8, 2018 22:25
lulu api node.js create print order
const request = require('request');
const ClientOAuth2 = require('client-oauth2')
const clientId = 'YOUR_CLIENT_ID';
const clientSecret = 'YOUR_CLIENT_SECRET';
var luluAuth = new ClientOAuth2({
clientId,
clientSecret,
@jaredh159
jaredh159 / noop-proxy.js
Created January 10, 2019 20:09
lol no-op object proxy
const noop = new Proxy({}, {
get(target, prop, receiver) {
const fn = () => receiver;
Object.setPrototypeOf(fn, receiver);
return fn;
},
});
// allows you to infinitely call methods and access properties that don't exist:
console.log(noop.foo.baz().bar.jim().jam().lol); // <-- no errors!
@jaredh159
jaredh159 / fl-doc-meta.json
Last active November 4, 2019 19:06
Friends Library Document Meta
{
"en/ambrose-rigge/journal-and-writings/modernized": {
"updated": "2019-07-24T20:04:26.244Z",
"adocLength": 291357,
"numSections": 19,
"pages": {
"s": 256,
"m": 171,
"xl": 147
},
@jaredh159
jaredh159 / swap-file.sh
Created July 24, 2019 20:35
Prevent "Killed" 137 errors on digital ocean by adding 1gb swap file
# hat tip: https://www.digitalocean.com/community/questions/npm-gets-killed-no-matter-what?answer=36609
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon --show
sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
sudo sysctl vm.swappiness=10
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf
@jaredh159
jaredh159 / snippets.md
Last active March 5, 2020 16:03
Useful snippets!

make a one-pixel gif of any color in node.js

function gif(r, g, b) {
  return 'R0lGODlhAQABAIAB' +
    (new Buffer([0, r, g, b, 0, 0])).toString('base64') +
    'ACwAAAAAAQABAAACAkQBADs=';
}
// then use: data:image/gif;base64,R0lGODlhAQABAIABAPLy8gAAACwAAAAAAQABAAACAkQBADs=
@jaredh159
jaredh159 / cloudSettings
Last active December 8, 2020 01:48
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-09-10T19:51:19.703Z","extensionVersion":"v3.4.3"}
@jaredh159
jaredh159 / splitter.ts
Last active May 11, 2020 20:09
Piety Promoted Chapter Splitter (a `fl` cli command)
import fs from 'fs';
const edition = 'original';
export default function handler(): void {
const path = `/Users/jared/fl/en/compilations/youthful-piety/${edition}/02-youthful-piety.adoc`;
const adoc = fs.readFileSync(path).toString();
const parts = adoc
.replace(/\n\n([A-Z]{3,}( [A-Z]+\.?)? [A-Z]{3,})/g, '~~~$1')