Skip to content

Instantly share code, notes, and snippets.

# glitch_eventsub.gleam
websocket_message.NotificationMessage(metadata, payload) -> {
// process.send(state.websocket_message_mailbox, message)
io.println("")
io.println("eventsub client - notification message")
io.debug(payload)
io.println("")
let assert Ok(subject) =
export function mockFromArbitrary<T>(arbitrary: Arbitrary<T>): T {
return fc.sample(arbitrary, 1)[0];
}
export function mockArrayFromArbitrary<T>(
arbitrary: Arbitrary<T>,
count?: number,
): T[] {
return fc.sample(arbitrary, count);
}
return {
{
"rcarriga/nvim-notify",
keys = {
{
"<leader>un",
function()
require("notify").dismiss({ silent = true, pending = true })
end,
desc = "Dismiss All Notifications",
@dmmulroy
dmmulroy / foobar.ts
Last active March 22, 2024 21:04
pure ts module based programming example
// Your module (i.e. file is for providing and working with one main type)
export type FooBar = {
foo: string;
bar: number;
then: (fn: (foobar: FooBar) => FooBar) => FooBar;
map: <T>(fn: (foobar: FooBar) => T) => T;
};
function make({ foo = "", bar = 0 }: Readonly<{ foo?: string; bar?: number }>) {
const foobar: FooBar = {
@dmmulroy
dmmulroy / gleam_ts_gen.d.ts
Created March 14, 2024 01:05
Generating TypeScript declaration files with Gleam
import type * as $io from "../gleam_stdlib/gleam/io.d.mts";
import type * as _ from "./gleam.d.mts";
export class User extends _.CustomType {
constructor(id: string, username: string, role: Role$);
id: string;
username: string;
role: Role$;
}
@dmmulroy
dmmulroy / flake.nix
Last active February 21, 2024 23:11
Nix flake for a simple Node and TypeScript DevShell
{
description = "Nix flake for a simple Node and TypeScript DevShell";
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = inputs @ {flake-parts, ...}:
flake-parts.lib.mkFlake {inherit inputs;} {
return {
{
"mfussenegger/nvim-dap",
-- lazy = true,
dependencies = {
{
"rcarriga/nvim-dap-ui",
config = function()
require("dapui").setup()
end,
@dmmulroy
dmmulroy / app.ml
Created January 31, 2024 04:30
melange-json-test
module Color = struct
type t = Red | Green | Blue
let to_string = function Red -> "red" | Green -> "green" | Blue -> "blue"
let of_json json =
Json.Decode.(
field "kind" string json |> function
| "red" -> Red
| "green" -> Green
@dmmulroy
dmmulroy / shell_benchmark.md
Created January 16, 2024 05:41
Profiling my shells startup time

Shell Benchmarking

Initial

$SHELL -i -c exit  0.42s user 0.10s system 63% cpu 0.821 total
$SHELL -i -c exit 0.42s user 0.10s system 65% cpu 0.792 total
$SHELL -i -c exit  0.42s user 0.10s system 60% cpu 0.861 total
$SHELL -i -c exit 0.42s user 0.10s system 65% cpu 0.795 total
$SHELL -i -c exit  0.42s user 0.09s system 61% cpu 0.838 total
@dmmulroy
dmmulroy / melange-ffi.d.ts
Created January 5, 2024 16:43
Melange ffi js ideas
export as namespace melange_js_ffi;
export namespace Brand {
const BRAND: unique symbol;
type t<_T, B> = { [BRAND]: B };
}
export function curry(fn: Function): Function;
export namespace Option {