Skip to content

Instantly share code, notes, and snippets.

View tgriesser's full-sized avatar

Tim Griesser tgriesser

View GitHub Profile
@tgriesser
tgriesser / cacheResult.ts
Created December 6, 2019 19:34
cache result getter
/**
* A cache result decorator means the value is lazily evaluated once and
* the result is cached on the class instance.
*/
export const cacheResult = <T>(
target: T,
key: PropertyKey,
descriptor: PropertyDescriptor
): void => {
if (!descriptor) {
@tgriesser
tgriesser / codegen.yml
Created December 6, 2019 19:31
Codegen for GraphQL Tests
overwrite: true
hooks:
afterAllFileWrite:
- prettier --write
schema: 'packages/graphql-schema/api-schema.graphql'
generates:
packages/api-graphql/test/testgen/GeneratedGraphQLTestFns.gen.ts:
documents: 'packages/api-graphql/test/**/*.graphql'
plugins:
- add: "// This file is auto-generated, do not edit directly!\n/* eslint-disable */"
import { dynamicOutputMethod, core, objectType, inputObjectType } from 'nexus'
import { GraphQLFieldResolver, GraphQLResolveInfo } from 'graphql'
import _ from 'lodash'
import {
BatchResolveFunction,
createBatchResolver,
} from 'graphql-resolve-batch'
export function paginatedInputType<TypeName extends string>(
config: Omit<core.NexusInputObjectTypeConfig<TypeName>, 'definition'> & {
function commonPostFields(t) {
t.string('title')
t.string('body')
t.list.field('tags', { type: TagEnum })
t.field('meta', { type: "PostMetadata" })
}
export const Post = objectType({
name: "Post",
@tgriesser
tgriesser / formik.tsx
Last active March 12, 2021 10:58
Formik w/ Hooks
import React, {
useContext,
createContext,
createElement,
useEffect,
useRef,
useCallback,
useState,
} from 'react';
import isEqual from 'react-fast-compare';
<!DOCTYPE html>
<html>
<head>
<title>ScriptEd CSS Garden</title>
</head>
<body>
<h1 id="banner">ScriptEd CSS Site!</h1>
<h1 id="tagline">We love ScriptEd</h1>
<img src="http://i65.tinypic.com/qxvr46.jpg">
<!DOCTYPE html>
<html>
<head>
<title>ScriptEd CSS Garden</title>
</head>
<body>
<h1 id="banner">ScriptEd CSS Site!</h1>
<h1 id="tagline">We love ScriptEd</h1>
<img src="http://i65.tinypic.com/qxvr46.jpg">
<p id="mission">ScriptEd equips students with the fundamental coding skills and professional experiences that together create access to careers in technology.</p>
<!DOCTYPE html>
<html>
<head>
<title>No Name</title>
</head>
<body>
<h2>This line should have a green background</h2>
<p>This line should also have a green background</p>
<p>This line should have "Comic Sans MS" font-family</p>
<h3>These shold have some some colors:</h3>
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>Hello world</h1>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>