Skip to content

Instantly share code, notes, and snippets.

View samtgarson's full-sized avatar
✌️

Sam Garson samtgarson

✌️
View GitHub Profile
@samtgarson
samtgarson / command.sh
Last active September 24, 2017 09:57
Vue support for prettier
yarn prettier --print-width 80 --no-semi --single-quote --parser parse5 --write example.vue
@samtgarson
samtgarson / book_room_spec.js
Created October 26, 2017 16:20
Cypress Run Bug
describe('Book Room', () => {
before(() => {
cy.server()
})
it('creates a Booking', () => {
cy.visit('/results?number_of_adults=2&number_of_children=0&from=2017-10-28&to=2017-10-30')
cy.get('.rooms .room:first').click()
@samtgarson
samtgarson / encrypt.js
Created July 26, 2018 15:34
Encrypt a message using kbpgp
var kbpgp = require("kbpgp")
const public = `-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: BCPG C# v1.6.1.0
mQENBFtXU7oBCAC1nvlknl749u67IPQEkOYJcZN4pq83w3mQdOIF3uRwpbjWtKmn
fVxckUS/N9KlGjoI26jp1DLrHE1yr1sfDapLHDjiM0w+lnOV3Rukj1O4LIPdZqiS
u1ZPGpaQxlV0jEgUAlANOtGxKDn/uOXx3yk4264/15uvVTLqrKLGTxLJ9jUxJWBs
v6Z2mnQhAC8fvMNMjNxgJBQIi/ij/kgm8eRyh4kzOX8IoyDs2HoM5HTwujYcVsw+
jcAcuu929/ZR73fzBQcYGtBgHZf0ELs3hORQEUuTzaIdvVXyVG+lu17bfAH7/6FD
wC0V3goe3csri7tUzLHoSNy+eneY0iM1XegBABEBAAG0DnRlc3RAZ21haWwuY29t
@samtgarson
samtgarson / index.js
Created September 17, 2019 22:08
Port of sdras' night-owl theme for Blink Shell
black = "#011627"
red = "#EF5350"
green = "#22da6e"
yellow = "#addb67"
blue = "#82aaff"
magenta = "#c792ea"
cyan = "#21c7a8"
white = "#ffffff"
lightBlack = "#575656"
lightRed = "#ef5350"
@samtgarson
samtgarson / tsconfig.json
Created August 4, 2020 15:00
Starter Typescript Config
{
"compilerOptions": {
"target": "es5",
"lib": ["esnext"],
"allowJs": true,
"strict": true,
"strictNullChecks": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
@samtgarson
samtgarson / api.yml
Last active November 30, 2020 12:28
Evidence Platform API Swagger
openapi: '3.0.0'
info:
title: Evidence Platform API
version: 1.0.0
paths:
/document_types:
get:
operationId: get-all-document-types
summary: Returns all recognised document types
responses:
@samtgarson
samtgarson / gist:645ced4dba144b4fdf6536508146be14
Last active February 25, 2021 10:57
ZMK Keyboard issue logs
### LALT ###
[01:14:08.968,811] <dbg> zmk.kscan_gpio_read_0: Sending event at 4,3 state on
[01:14:08.968,841] <dbg> zmk.zmk_kscan_process_msgq: Row: 4, col: 3, position: 0, pressed: true
[01:14:08.968,933] <dbg> zmk.zmk_keymap_apply_position_state: layer: 0 position: 0, binding name: KEY_PRESS
[01:14:08.968,963] <dbg> zmk.on_keymap_binding_pressed: position 0 keycode 0x70029
[01:14:08.968,994] <dbg> zmk.hid_listener_keycode_pressed: usage_page 0x07 keycode 0x29 implicit_mods 0x00 explicit_mods 0x00
[01:14:08.968,994] <dbg> zmk.zmk_hid_implicit_modifiers_press: Modifiers set to 0x00
[01:14:08.969,024] <dbg> zmk.zmk_endpoints_send_report: usage page 0x07
[01:14:09.036,682] <dbg> zmk.kscan_gpio_read_0: Sending event at 4,3 state off
@samtgarson
samtgarson / hydrate.ts
Last active May 3, 2021 11:48
Hydrate JSON dates
import { formatISO, parseISO } from "date-fns"
const dateRegex = /^[0-9]{4}(-[0-9]{2}){2}T[0-9]{2}(:[0-9]{2}){2}/
export function hydrate <T extends unknown>(obj: T): T
export function hydrate (obj: unknown): unknown {
if (Array.isArray(obj)) return obj.map(hydrate)
if (typeof obj !== 'object') return obj
if (!obj) return obj
return Object.entries(obj).reduce((hsh, [k, v]) => ({
[tio 17:38:04] Connected
] <inf> fs_nvs: 8 Sectors of 4096 bytes
[00:00:00.315,338] <inf> fs_nvs: alloc wra: 0, 918
[00:00:00.315,338] <inf> fs_nvs: data wra: 0, 6ec
[00:00:00.323,150] <wrn> usb_cdc_acm: Device not configured or suspended, drop 1 bytes
[00:00:00.329,742] <dbg> zmk.bvd_init: AIN2 setup returned 0
[00:00:00.331,512] <inf> bt_hci_core: No ID address. App must call settings_load()
[00:00:00.332,855] <dbg> zmk.ble_profiles_handle_set: Setting BLE value profiles/5
[00:00:00.332,855] <wrn> zmk: Profile address for index 5 is larger than max of 5
[00:00:00.332,855] <err> settings: set-value failure. key: ble/profiles/5 error(-22)
@samtgarson
samtgarson / get-model-type.spec.ts
Created March 19, 2024 08:57
Custom Safe Reference type in Mobx State Tree
import { types } from 'mobx-state-tree'
import { getModelType, getModelTypes } from './get-model-type'
const TestModel = types.model('models', {
id: types.identifier,
name: types.literal('frodo'),
})
const TestModel2 = types.model('other-models', {
id: types.identifier,