Skip to content

Instantly share code, notes, and snippets.

View patrickgwsmith's full-sized avatar

Patrick George Wyndham Smith patrickgwsmith

View GitHub Profile
@patrickgwsmith
patrickgwsmith / example.js
Created September 11, 2021 05:34
`in` as pipeline keyword
// See: https://twitter.com/buildsghost/status/1436394640861646848
envars
|> Object.keys(in)
|> in.map(envar => `${envar}=${envars[envar]}`)
|> in.join(' ')
|> `$ ${in}`
|> chalk.dim(in, 'node', args.join(' '))
|> console.log(in)
@patrickgwsmith
patrickgwsmith / main.md
Last active September 3, 2021 00:21
RxJS Loading Patterns

RxJS Loading Patterns

Observable creators

of(A...) => Observable<A>

Create an observable emitting each item passed in.

from(Promise<A> | Iterable<A>) => Observable<A>

@patrickgwsmith
patrickgwsmith / init.lua
Last active November 20, 2023 03:48
My Hammerspoon config
-- Runs using the open source Mac app https://www.hammerspoon.org
-- Install Hammerspoon, and then copy this Gist into a file at ~/.hammerspoon/init.lua
require("hs.ipc")
hs.ipc.cliInstall()
local math = require("hs.math")
currentSpeech = nil
@patrickgwsmith
patrickgwsmith / actor-protocol.swift
Last active March 31, 2021 00:38
Defining Actors in Swift with Protocols
protocol Actor : AnyObject, Sendable {
associatedtype State
isolated var state: State
}
struct BankAccountState {
var balance: Double
mutating func deposit(amount: Double) {
@patrickgwsmith
patrickgwsmith / soonerorlater.test.ts
Last active February 20, 2021 04:49
Parse natural language date span
import { parse } from "./index";
test("parse()", () => {
test.each([
['Monday', { weekdays: new Set(['monday']) }],
['Wednesday', { weekdays: new Set(['wednesday']) }],
[' Wednesday ', { weekdays: new Set(['wednesday']) }],
['Wednesday and Saturday', { weekdays: new Set(['wednesday', 'saturday']) }],
['Wednesday or Saturday', { weekdays: new Set(['wednesday', 'saturday']) }],
['Wednesday, Saturday', { weekdays: new Set(['wednesday', 'saturday']) }],
const pedestrianStates = {
initial: 'walk',
states: {
walk: {
on: {
PED_COUNTDOWN: 'wait'
}
},
wait: {
on: {
@patrickgwsmith
patrickgwsmith / keybase.md
Created November 7, 2018 13:25
keybase.md

Keybase proof

I hereby claim:

  • I am burntcaramel on github.
  • I am burntcaramel (https://keybase.io/burntcaramel) on keybase.
  • I have a public key ASArnj22CZ7v-9tbcz-52hippT2ZfvGy4dQ3ZoSelHe3lwo

To claim this, I am signing this object:

@patrickgwsmith
patrickgwsmith / 1.ts
Created June 29, 2018 02:02
React state management ideas
interface State {
counter: number
}
const counterModel = {
initial(): State {
return {
counter: 0
};
},
//: Playground - noun: a place where people can play
import Foundation
struct ExampleStruct : Codable {
var title: String
var something: Int
public func encode(to encoder: Encoder) throws {
@patrickgwsmith
patrickgwsmith / Dockerfile
Last active July 12, 2024 02:35
Rails 5.1 Dockerfile
FROM ruby:2.4-alpine
ENV PATH /root/.yarn/bin:$PATH
RUN apk update && apk upgrade && \
apk add --no-cache bash git openssh build-base nodejs tzdata
RUN apk update \
&& apk add curl bash binutils tar gnupg \
&& rm -rf /var/cache/apk/* \