Skip to content

Instantly share code, notes, and snippets.

@RoyalIcing
RoyalIcing / 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:

@RoyalIcing
RoyalIcing / machine.js
Created January 6, 2021 07:15
Generated by XState Viz: https://xstate.js.org/viz
const pedestrianStates = {
initial: 'walk',
states: {
walk: {
on: {
PED_COUNTDOWN: 'wait'
}
},
wait: {
on: {
@RoyalIcing
RoyalIcing / 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']) }],
@RoyalIcing
RoyalIcing / 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) {
@RoyalIcing
RoyalIcing / 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
@RoyalIcing
RoyalIcing / 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>

@RoyalIcing
RoyalIcing / 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)
@RoyalIcing
RoyalIcing / timing.ts
Last active December 2, 2021 02:59
Debouncing with logical clocks in React
import { DispatchWithoutAction, useEffect, useMemo, useReducer } from 'react';
import type { DependencyList, EffectCallback } from 'react';
/**
* A logical clock.
*
* @returns a tuple with the current clock value, and a stable function that advances the clock.
*/
export function useTicker(): [number, DispatchWithoutAction] {
return useReducer(n => n + 1, 0);
@RoyalIcing
RoyalIcing / 1.js
Last active March 9, 2022 04:23
Mini modules
/**
* Pi to 8 decimal places
*/
export const pi = 3.14159265;
export const dateFormat = "YYYY/MM/DD";
export const isEnabled = true;
export const flavors = ["vanilla", "chocolate", "caramel", "raspberry"];
@RoyalIcing
RoyalIcing / remorse.php
Created January 20, 2022 01:43
Remorse: Focused on web fundamentals and archaic UX
<?php
function loader($request) {
return getProjects();
}
function action($request) {
$form = $request.formData();
return createProject([ "title" => $form.get("title") ]);
}