An inverted Binary Tree is a Binary Tree with left and right children of all non-leaf nodes interchanged.
type Node =
{ Value: int
const sleep = (s) => | |
new Promise((resolve) => | |
setTimeout(() => resolve(s), s * 1000) | |
); | |
const sleepSort = async (arr) => { | |
const res = []; | |
await Promise.all( | |
arr | |
.map(sleep) |
const arr = [1, 4, 4, 54, 56, 54, 2, 23, 6, 54, 65, 65]; | |
const reduceSum = arr => arr.reduce((acc, val) => acc + val); | |
const forEachSum = arr => { | |
let sum = 0; | |
arr.forEach(el => sum += el); | |
return sum; | |
}; | |
const forSum = arr => { | |
let sum = 0; | |
for (let i = 0; i < arr.length; i++ ) sum += arr[i]; |
Relays messages published on a redis channel over Server-Sent Events. |
import mime from "mime"; | |
import { stat } from "node:fs/promises"; | |
import http2, { Http2ServerRequest, Http2ServerResponse } from "node:http2"; | |
import { join } from "node:path"; | |
export type Http2Handler = ( | |
next?: ( | |
req: Http2ServerRequest, | |
res: Http2ServerResponse | |
) => Promise<void> | void |
WITH | |
external_data | |
/* | |
In an external system, we have some episode to series relations. | |
An episode can be in multiple series. | |
The SERIES_ID is monotonically increasing database ID. | |
*/ | |
AS (SELECT 10 SERIES_ID, 1 EPISODE_ID FROM dual UNION ALL | |
SELECT 2 SERIES_ID, 1 EPISODE_ID FROM dual), | |
transformed_data |
#!/usr/bin/env -S dotnet fsi --quiet | |
#r "nuget: JsonSchema.Net" | |
// | |
// This file contains a basic example of json schema validation | |
// | |
open Json.Schema | |
open System.Text.Json | |
let schema = |
Using org-mode and Emacs Lisp to solve Advent of Code.
(org-babel-lob-ingest "./library-of-babel.org")
import { Observable, of } from "rxjs"; | |
import { map, switchMap } from "rxjs/operators"; | |
export class Nullable { | |
static isNotNull<T>(v: T): v is NonNullable<T> { | |
return v != null; | |
} | |
static bind = <T, R>( | |
project: (value: NonNullable<T>, index: number) => R |