Skip to content

Instantly share code, notes, and snippets.

View jasonkuhrt's full-sized avatar
🏔️
Building Prisma Cloud

Jason Kuhrt jasonkuhrt

🏔️
Building Prisma Cloud
View GitHub Profile
@jasonkuhrt
jasonkuhrt / @ Explore New Alge APIs.md
Last active August 2, 2022 03:32
Explore New Alge APIs

Explore new Alge APIs

@jasonkuhrt
jasonkuhrt / exampleUsage.ts
Created March 17, 2021 12:30
Abstraction for defining result fields in Nexus
/**
* This does not show surrounding code like referenced types.
*/
resultMutationField('inviteUserToProject', {
input(t) {
t.nonNull.id('userHandle')
t.nonNull.id('projectId')
t.nonNull.field('role', {
type: 'ProjectRole',
@jasonkuhrt
jasonkuhrt / next-auth-prisma.ts
Last active March 2, 2021 21:19
prisma adaptor for next-auth with cuid
/**
* Adapted from https://github.com/nextauthjs/adapters/tree/canary/packages/prisma
*/
import * as Prisma from '@prisma/client'
import { User } from '@prisma/client'
import { AppOptions } from 'next-auth'
// @ts-expect-error TODO expose errors in next-auth
import { CreateUserError } from 'next-auth/dist/lib/errors'
// @ts-expect-error TODO expose logger in next-auth
@jasonkuhrt
jasonkuhrt / nexus-prisma reboot sketching.md
Last active February 26, 2021 03:15
Stream of consciousness design of the new Nexus Prisma

This sketch is outdated. Please refer to https://github.com/prisma/nexus-prisma for current spec & status.



Here is a GraphQL object manually projecting fields from the model layer. Assume the parent returned data of a project model.

objectType({
@jasonkuhrt
jasonkuhrt / transition.tsx
Created January 12, 2019 15:39
Transition component with typed invariant modelling
import * as React from "react"
/**
* There are four cases of children state that Transition has to deal with.
*/
type ChildCase =
| {
type: "no_child"
}
| {
@jasonkuhrt
jasonkuhrt / node-dependency-shenanigans.md
Created May 31, 2018 02:59
Node Dependency Shenanigans

Node Dependency Shenanigans

This is a TL;DR from a day in the life of node dependency shenanigans. Throughout this article I will use git status and git diff to make state explicit. You should be able to reproduce exactly what you see here. Lines prefixed with > are what I entered into the terminal. Anything else is output I chose to show herein but often I will not copy the terminal output to this article because it would not be interesting.

Setup

Lets start with an empty node project.

First our node and npm versions:

@jasonkuhrt
jasonkuhrt / bufferUntil.js
Last active November 12, 2017 03:50
Most.js Buffer Until
function bufferUntil(stream, promise) {
return {
run: (sink, scheduler) => {
let didResolve = false
const buffer = []
stream.source.run(
{
event: (t, x) => {
if (didResolve) {
@jasonkuhrt
jasonkuhrt / bufferedApply.js
Last active November 12, 2017 03:02
Most.js Buffered Apply
function bufferedApply(streamOfFunctions, streamOfValues) {
const source = {
run: (sink, scheduler) => {
let f = null
const buffer = []
streamOfFunctions.source.run(
{
event: (t, newF) => {
f = newF
@jasonkuhrt
jasonkuhrt / main.js
Created October 6, 2017 03:14
falling-water.js
// Falling water
// Calculate the area of sum of areas of water that would be captured in
// valleys of water along a series of constant-width variable-height columns.
// The geometry is grid based meaning there are no curves in this world.
const log = console.log
const sumPools = (cs) => {