This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type CancellationSubscriber = (err: Error) => void; | |
export type Unsubscribe = () => void; | |
export interface CancellationToken { | |
subscribe(subscriber: CancellationSubscriber): Unsubscribe; | |
} | |
export class CancellationError extends Error { | |
public readonly name = "CancellationError"; | |
public readonly message = "The operation was cancelled"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
REDIS_URL=$(heroku config:get REDIS_URL $@) | |
REDIS_USERNAME_AND_PASSWORD=$(echo $REDIS_URL | cut -d@ -f1) | |
REDIS_HOSTNAME_AND_PORT=$(echo $REDIS_URL | cut -d@ -f2) | |
REDIS_HOSTNAME=$(echo $REDIS_HOSTNAME_AND_PORT | cut -d: -f1) | |
REDIS_PORT=$(echo $REDIS_HOSTNAME_AND_PORT | cut -d: -f2) | |
REDIS_PASSWORD=$(echo $REDIS_USERNAME_AND_PASSWORD | cut -d: -f3) | |
# redis-dump -h $REDIS_HOSTNAME -p $REDIS_PORT -a $REDIS_PASSWORD > redis.dump |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as Maybe from "./maybe"; | |
import { caseOf } from "./one-of"; | |
const square = (n: number) => n * n; | |
// serializable as plain js arrays | |
console.log(Maybe.of(42)); // [ 'Just', 42 ] | |
// supports exhaustive pattern matching | |
caseOf(Maybe.map(Maybe.of(3), square), { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<style> | |
body { width: 100%; } | |
table { margin: auto; border-spacing: 1rem; } | |
button { padding: 1rem; } | |
</style> | |
</head> | |
<body> | |
<table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright (c) 2022 Chris Baker | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to | |
* deal in the Software without restriction, including without limitation the | |
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | |
* sell copies of the Software, and to permit persons to whom the Software is | |
* furnished to do so, subject to the following conditions: | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright (c) 2022 Chris Baker | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to | |
* deal in the Software without restriction, including without limitation the | |
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | |
* sell copies of the Software, and to permit persons to whom the Software is | |
* furnished to do so, subject to the following conditions: | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright (c) 2022 Chris Baker | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to | |
* deal in the Software without restriction, including without limitation the | |
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | |
* sell copies of the Software, and to permit persons to whom the Software is | |
* furnished to do so, subject to the following conditions: | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef struct { | |
unsigned short line; | |
} coroutine_t; | |
#define COROUTINE_LINE_NONE ((unsigned short) 0) | |
#define COROUTINE_LINE_DONE ((unsigned short) -1) | |
#define coroutine_init(co) (co)->line = COROUTINE_LINE_NONE | |
#define coroutine_done(co) ((co)->line == COROUTINE_LINE_DONE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface ArrayOfSchema<T> { | |
readonly type: "arrayOf"; | |
readonly payload: T; | |
} | |
function arrayOfSchema<T>(payload: T): ArrayOfSchema<T> { | |
return { type: "arrayOf", payload }; | |
} | |
export interface BooleanSchema { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type KeysOfParams<S extends string> = | |
S extends `${infer Before} :${infer Name} ${infer After}` | |
? KeysOfParams<Before> | Name | KeysOfParams<After> | |
: S extends `:${infer Name} ${infer After}` | |
? Name | KeysOfParams<After> | |
: S extends `${infer Before} :${infer Name}` | |
? KeysOfParams<Before> | Name | |
: S extends `:${infer Name}` | |
? Name | |
: never; |
NewerOlder