Skip to content

Instantly share code, notes, and snippets.

View DopamineDriven's full-sized avatar
🎯
cloud hopping

Andrew Ross DopamineDriven

🎯
cloud hopping
View GitHub Profile
@ardiewen
ardiewen / client.js
Last active July 28, 2021 01:55
Example of modifying the existing "with-apollo" NextJS example with wp-graphql-woocommerce middleware.
import { useMemo } from 'react'
import { ApolloClient, InMemoryCache, from } from '@apollo/client'
import merge from 'deepmerge'
import isEqual from 'lodash/isEqual'
import {
httpLink,
onErrorLink,
wooSessionMiddleware,
wooSessionAfterware,
} from 'lib/apollo/middleware'
@justjake
justjake / server-preload.js
Last active June 30, 2024 12:37
Customizing NextJS for error reporting and Datadog APM (dd-trace) integration. See https://jake.tl/notes/2021-04-04-nextjs-preload-hack
// @ts-check
"use strict"
/**
* Set up datadog tracing. This should be called first, so Datadog can hook
* all the other dependencies like `http`.
*/
function setUpDatadogTracing() {
const { tracer: Tracer } = require('dd-trace')
const tracer = Tracer.init({
@nandorojo
nandorojo / use-swr-infinite-enhanced.ts
Last active July 10, 2023 11:01
useSWRInfinite with pagination & typescript safety
import { ConfigInterface, useSWRInfinite } from 'swr'
import { useMemo, useCallback, useRef } from 'react'
import last from 'lodash.last'
import get from 'lodash.get'
type PageKeyMaker<Page, Key extends any[]> = (
index: number,
previousPageData?: Page
/**
* Mutable ref object. Set this to `true` before the request and `false` afterwards if the request is fetching more.
@kpratik2015
kpratik2015 / apollo-client-updated.ts
Created October 10, 2020 20:39
Updated Apollo Client with v3 apollo and cross-fetch
import {
ApolloClient,
InMemoryCache,
HttpLink,
ApolloLink,
from,
} from "@apollo/client";
import fetch from "cross-fetch";
import { setContext } from "@apollo/client/link/context";
@azu
azu / amp.d.ts
Last active November 19, 2022 06:08
TypeScript definitions for AMP Attributes. Write AMP in JSX.
// roughish AMP attribute types for JSX/TypeScript
// Source: https://playground.amp.dev/amphtml-hint.json
// https://github.com/Microsoft/TypeScript/issues/15449
// https://stackoverflow.com/questions/50585952/typescript-and-google-amp-property-amp-img-does-not-exist-on-type-jsx-intrin
import * as React from 'react';
// why null ?
type _ANY = any;
type _ANYS = any;
declare module 'react' {
interface HTMLAttributes<T> {
@joduplessis
joduplessis / cookie-typescript-utils.ts
Created September 12, 2017 06:50
Setting, deleting and retrieving cookies in Typescript.
@vdelacou
vdelacou / UploadFileComponent.tsx
Last active May 9, 2022 14:09
React / Typescript / Material UI / Upload file / Custom Button / Async /
// import .....
const inputUploadFile: CSSProperties = {
display: 'none',
};
const buttonUploadFile: CSSProperties = {
margin: 8,
};
@zkiraly
zkiraly / procedure-to-archive-git-branches.md
Last active June 12, 2024 12:03
Procedure to archive git branches.
@raelgc
raelgc / Email Server (Windows Only).md
Last active September 6, 2024 08:22
Setup a Local Only Email Server (Windows Only)
@goldenapples
goldenapples / gravityforms-richeditors.php
Created May 26, 2012 20:19
Rich text editors for Gravity Forms
<?php
/*
Plugin Name: Rich Text editors for Gravity Forms
Description: Converts the textarea fields in Gravity Forms to WordPress rich text editors
Author: Nathaniel Taintor
Author URI: http://goldenapplesdesign.com
Version: 1.0
License: GPLv2
*/