Skip to content

Instantly share code, notes, and snippets.

@anthonyjoeseph
anthonyjoeseph / undo-drizzle-migration-during-merge.ts
Last active June 11, 2025 16:36
undo-drizzle-migration-during-merge.ts
// MIT licensed (© 2024)
// https://opensource.org/license/mit
//
// Source: https://gist.github.com/anthonyjoeseph/102c0e3ea8496fe111029a8b8a95cc3a
// motivation:
// `drizzle-kit generate` has a default behavior that causes headaches
// it will randomly generate names for migration files
// e.g. "0012_swift_rhino.sql"
// this means that migration conflicts across branches are easy to miss
// MIT licensed (© 2024)
// https://opensource.org/license/mit
//
// Source: https://gist.github.com/anthonyjoeseph/6b99beb34d494acd1dfc83a192ed9388/edit
// Original (with bug): https://gist.github.com/gburtini/7e34842c567dd80ee834de74e7b79edd
import fs from "fs";
import config from "../../drizzle.config";
import path from "path";
@anthonyjoeseph
anthonyjoeseph / unjailTest.ts
Created May 12, 2023 17:59
CosmJs Unjail Validator
import {
AminoConverters,
AminoMsgUnjail,
AminoTypes,
SigningStargateClient,
StargateClient,
createDefaultAminoConverters,
defaultRegistryTypes,
makeMultisignedTxBytes,
} from "@cosmjs/stargate";
@anthonyjoeseph
anthonyjoeseph / fireblocksCosmos.ts
Last active April 18, 2024 11:28
RAW signing via fireblocks API
import path from "path";
import fs from "fs";
import { coins, pubkeyToAddress } from "@cosmjs/amino";
import { fromHex, toBase64, toHex } from "@cosmjs/encoding";
import { StargateClient } from "@cosmjs/stargate";
import { encodePubkey, makeSignBytes } from "@cosmjs/proto-signing";
import { EncodeObject, Registry, makeAuthInfoBytes, makeSignDoc } from "@cosmjs/proto-signing";
import { sha256 } from "@cosmjs/crypto";
import { FireblocksSDK, TransactionOperation, TransactionStatus } from "fireblocks-sdk";
import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
@anthonyjoeseph
anthonyjoeseph / 3.9|package.json
Last active April 12, 2022 15:11
Test Multiple Typescript Versions Using TSC
{
"name": "Tests against TS v3.9",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"typescript": "^3.9.2"
}
}
@anthonyjoeseph
anthonyjoeseph / Struct.ts
Last active April 2, 2021 00:22
fp-ts Struct Module
/**
* @since 2.11.0
*/
import { URIS3, Kind3, URIS2, Kind2, URIS, Kind, URIS4, Kind4, HKT } from './HKT'
import * as R from './ReadonlyRecord'
import { Option, fromNullable, fromPredicate, some, Applicative as OptionApplicative } from './Option'
import { Either, right, left } from './Either'
import { Ord } from './Ord'
import { Ord as StringOrd } from './string'
import { Apply4, Apply3, Apply3C, Apply2, Apply2C, Apply1, Apply } from './Apply'
@anthonyjoeseph
anthonyjoeseph / tableColumns.tsx
Last active February 28, 2021 22:00
fp-ts-tree-utils
import { sum } from 'fp-ts-std/Array';
import * as A from 'fp-ts/Array';
import { pipe } from 'fp-ts/function';
import * as O from 'fp-ts/Option';
import * as T from 'fp-ts/Tree';
import React from 'react';
// npm package name: fp-ts-tree-contrib ?
export const isLeaf = <A,>(tree: T.Tree<A>): boolean => tree.forest.length === 0
@anthonyjoeseph
anthonyjoeseph / mapAll.ts
Created February 28, 2021 02:41
mapAll function
const mapAll = <A, B>(vals: {
[K in NonNullable<keyof A>]: (val: A[K]) => B
}) => (a: A): {
[K in NonNullable<keyof A>]: B
} => {
const keys = Object.keys(a) as (NonNullable<keyof A> & string)[]
const mapped = fromFoldableMap(
S.getLastSemigroup<B>(), RA.readonlyArray
)(
keys, (key) => [key, vals[key](a[key])]
@anthonyjoeseph
anthonyjoeseph / tabledemo.tsx
Last active February 28, 2021 08:21
Typesafe Table W/O React Table
import React from 'react'
import * as A from 'fp-ts/Array';
const Table2 = <A,>({
data, order, headerTitles, rowRenderer
}: {
data: A[]
order: NonNullable<keyof A>[]
headerTitles: {
[K in NonNullable<keyof A>]: string
@anthonyjoeseph
anthonyjoeseph / catchErrorExperiment.ts
Last active January 15, 2021 19:13
Catch Error Experiment
import { flow, pipe } from 'fp-ts/function';
import * as E from 'fp-ts/Either'
import * as r from 'rxjs'
import * as ro from 'rxjs/operators'
import * as OB from 'fp-ts-rxjs/lib/Observable'
export const tryCatch = <E, A>(
onErr: (e: unknown) => E
): r.OperatorFunction<A, E.Either<E, A>> => flow(
OB.map(E.right),