Skip to content

Instantly share code, notes, and snippets.

View jaredh159's full-sized avatar

Jared Henderson jaredh159

View GitHub Profile
@jaredh159
jaredh159 / UserDefaultsBacked.swift
Created August 1, 2022 13:36
user defaults backed property wrapper (credit: john sundell)
import Foundation
public protocol AnyOptional {
var isNil: Bool { get }
}
extension Optional: AnyOptional {
public var isNil: Bool { self == nil }
}
@jaredh159
jaredh159 / postgres-macos-wait.yml
Created October 1, 2021 14:19
wait for macOS postgres to start in github action
- name: start postgres
run: |
brew services start postgresql
echo "Check PostgreSQL service is running"
i=20
COMMAND='pg_isready'
while [ $i -gt 0 ]; do
echo "Check PostgreSQL service status"
eval $COMMAND && break
((i--))
@jaredh159
jaredh159 / log_dict.swift
Created April 13, 2021 20:36
Recursively Log out an NSDictionary
func logDict(_ dict: NSDictionary) {
for (key, value) in dict {
guard let strKey = key as? String else {
os_log("[NSDictionary] unexpected non-string key type=%s", String(describing: type(of: key)))
continue
}
switch value {
case let string as String:
os_log("[NSDictionary] %s = (String) %s", strKey, string)
case let int as Int:
@jaredh159
jaredh159 / gough-1.adoc
Last active December 28, 2021 19:57
asciidoc tables
Counties In the Excheq. In Ecc. Courts Other Courts. In all. Impri-soned. Died Prisoners

Bedfordshire

6

7

1

14

2

0

Berkshire

6

13

1

20

3

0

Buckingh.

11

3

2

16

8

0

Cambridgsh.

12

5

1

18

9

0

Cheshire

1

11

0

12

2

0

Cornwall

12

9

1

22

6

0

@jaredh159
jaredh159 / browser.md
Last active June 11, 2020 13:10
cover old browser problem stats

Bad Covers (English)

  • safari 10 - pretty bad covers (2 users)
  • safari 9 - assuming as bad as 10 or worse (3 users)
  • IE 11 - covers look bad (3 users)
  • IE 8 - covers look bad, probably everything else too (3 users)
  • Total: 1.5% of all users (11/730) have bad looking covers (1.1% if we ignore LOL IE8)

Bad Covers (Spanish)

@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')
@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 / 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=