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 July 8, 2025 16:50
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 March 3, 2026 06:20
Procedure to archive git branches.
@tadast
tadast / countries_codes_and_coordinates.csv
Last active May 11, 2026 22:57
Countries with their (ISO 3166-1) Alpha-2 code, Alpha-3 code, UN M49, average latitude and longitude coordinates
Country Alpha-2 code Alpha-3 code Numeric code Latitude (average) Longitude (average)
Afghanistan AF AFG 4 33 65
Åland Islands AX ALA 248 60.116667 19.9
Albania AL ALB 8 41 20
Algeria DZ DZA 12 28 3
American Samoa AS ASM 16 -14.3333 -170
Andorra AD AND 20 42.5 1.6
Angola AO AGO 24 -12.5 18.5
Anguilla AI AIA 660 18.25 -63.1667
Antarctica AQ ATA 10 -90 0
@raelgc
raelgc / Email Server (Windows Only).md
Last active October 8, 2025 22:41
Setup a Local Only Email Server (Windows Only)