Skip to content

Instantly share code, notes, and snippets.

View elliottsj's full-sized avatar

Spencer Elliott elliottsj

View GitHub Profile
@elliottsj
elliottsj / machine.js
Last active April 3, 2023 15:12
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@elliottsj
elliottsj / ActionList.stories.tsx
Last active November 17, 2021 21:51
Basic stories in Next.js 11 (put `[...slug].tsx` and `index.tsx` in `pages/`, stories in `stories/`)
import React from 'react';
import { ActionList, ActionItemButton } from '../components';
import { css } from '@emotion/core';
import { Example, Title } from './Utilities';
export default {
title: 'ActionList',
};
10:50:21.963 Installing build runtime...
10:50:22.444 Build runtime installed: 481.399ms
10:50:22.907 Looking up build cache...
10:50:23.039 Build cache found. Downloading...
10:50:25.843 Build cache downloaded [90.50 MB]: 2803.485ms
10:50:26.320 Running "install" command: `npx pnpm install --store=node_modules/.pnpm-store`...
10:50:27.647 npx: installed 1 in 1.265s
10:50:28.182 Lockfile is up-to-date, resolution step is skipped
10:50:28.318 Already up-to-date
10:50:28.819 dependencies:
@elliottsj
elliottsj / machine.js
Created November 16, 2020 22:33
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@elliottsj
elliottsj / cucumber.impl.js
Created January 17, 2020 17:14
Cucumber Nx builder example
const {
createBuilder,
targetFromTargetString,
scheduleTargetAndForget,
} = require('@angular-devkit/architect');
const { readWorkspaceJson } = require('@yolkai/nx-workspace');
const execa = require('execa');
const path = require('path');
const { Observable, from, of } = require('rxjs');
const { catchError, map, mergeMap } = require('rxjs/operators');
@elliottsj
elliottsj / App.tsx
Created March 27, 2019 16:46
Composable Next.js App HoCs with TypeScript: appWithCookies + appWithApolloClient
import ApolloClient from 'apollo-client';
import { NormalizedCacheObject } from 'apollo-cache-inmemory';
import { NextContext } from 'next';
import App, { Container, NextAppContext, AppProps } from 'next/app';
import { DefaultQuery } from 'next/router';
import * as React from 'react';
import { ApolloProvider } from 'react-apollo';
import { Cookies, CookiesProvider } from 'react-cookie';
import appWithApolloClient from './appWithApolloClient';
@elliottsj
elliottsj / mergeSchemas.ts
Last active January 28, 2021 04:29
An example of using Apollo graphql-tools `mergeSchemas` to delegate to a non-root sub-field
import { GraphQLSchema, Kind } from 'graphql';
import {
makeExecutableSchema,
mergeSchemas,
transformSchema,
RenameRootFields,
RenameTypes,
WrapQuery,
} from 'graphql-tools';
home*
askIssue
AirWatch -> airWatch
Lync -> lync
View or Update Ticket -> viewUpdateTicket
airWatch
determineDevice
iPhone -> iphone
iPad -> ipad
/**
* Scan the given array to find the index of the element which satisfies the predicate,
* which receives the previous, current, and next elements every iteration.
*
* The `current` element is the element at the "current" index, so returning true in the predicate
* will cause `findIndex3` to return the index of the `current` element.
*
* `previous` will be undefined on the first iteration, and `current` and `next` will be undefined
* on the previous iteration.
*
import {
IObjectWithKey,
ISelection,
SELECTION_CHANGE,
SelectionMode,
Selection
} from 'office-ui-fabric-react/lib/utilities/selection/index';
import { EventGroup } from 'office-ui-fabric-react/lib/Utilities';
export interface ITopAnchoredRangeSelectionOptions {