# yarn 2
npm install -g yarn
yarn set version berry && yarn set version latest
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 { Prisma } from '@prisma/client' | |
/** | |
** USAGE ** | |
const withTx = async (fn: () => Promise<void>)): Promise<void> => { | |
// get the tx handle | |
const tx = await prisma.$begin() | |
// if fn throws an error, the tx will be rolled back automatically | |
await fn() |
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
const freezeTime = (): Date => { | |
const now = new Date(); | |
jest.useFakeTimers(); | |
jest.setSystemTime(now); | |
return now; | |
}; | |
const unfreezeTime = () => { | |
jest.useRealTimers(); | |
}; |
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
type Foo = { | |
bar: string; | |
baz: string; | |
qux: string; | |
}; | |
// needs to be 'const' / immutable, otherwise ts doesn't know set of values | |
const includeFields = ['bar', 'baz'] as const; | |
// dynamic type to create a union of array values |
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 { DynamoDB } from '@aws-sdk/client-dynamodb'; | |
import { DynamoDBDocument } from '@aws-sdk/lib-dynamodb'; | |
const tableName = 'discography'; | |
const artistAlbumsIndex = 'artist-albums'; | |
const table = { | |
TableName: tableName, | |
BillingMode: 'PAY_PER_REQUEST', | |
AttributeDefinitions: [ | |
{ AttributeName: 'pk', AttributeType: 'S' }, |
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
# https://kotlinlang.org/docs/kotlin-mascot.html | |
,_ _ | |
.H$H$L ╭H$$. | |
|HHHHHHL, ╭$HHHH: | |
|HHHHHHHH$>v$HHHHHH: | |
|HHHHHH .**. .**.`?: | |
|HHHHHH | | | | ?: | |
,?H|HHHHHH.`^^' `^^'.?: | |
.$H` "*HHHHHH$$$$$HHHHHH╯ |
I hereby claim:
- I am mostlylikeable on github.
- I am mostlylikeable (https://keybase.io/mostlylikeable) on keybase.
- I have a public key whose fingerprint is C217 F90F 1D51 FA20 97D8 5177 453A 7829 F617 92B8
To claim this, I am signing this object:
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
// Comment | |
`{{/* TODO: add more useful things */}}` | |
// Ternary var def with or | |
// $somevar := (.x ? .x : "") | |
`{{ $somevar := or .x "" }}` | |
// Ternary var def with and | |
// $somevar := (.x ? "" : .x) | |
`{{ $somevar := and .x "" }}` |
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 | |
# git-migrate-down.sh | |
function _gm_not_dry_run() { | |
return 1 # set to 0 to run | |
} | |
# pulls all stashes down, re-stashes, and deletes local branch. | |
# - can uncomment line to also delete remote tmp stash branch | |
function pull_stashes() { |
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
#!/bin/bash | |
# script for stashing and pushing all changes, stashes, local branches to remote/fork (origin) | |
# so they can be pulled down on another machine. | |
function _gm_not_dry_run() { | |
return 1 # set to 0 to run | |
} | |
# recursively stash any pending changes for all subdirs where this is run | |
function rstash() { |
NewerOlder