Skip to content

Instantly share code, notes, and snippets.

View h-jennings's full-sized avatar

Hunter Jennings h-jennings

View GitHub Profile
@h-jennings
h-jennings / booksToScrape.js
Last active September 27, 2019 12:53
Scraping all product headlines from a site
const jsdom = require('jsdom');
const {
JSDOM
} = jsdom;
const Nightmare = require('nightmare');
const nightmare = Nightmare();
const url = 'http://books.toscrape.com/';
// Grabbing the homepage html
@h-jennings
h-jennings / machine.js
Created November 5, 2019 03:48
Generated by XState Viz: https://xstate.js.org/viz
const allData = new Array(25).fill(0).map((_val, i) => i + 1);
const perPage = 10;
const dataMachine = new Machine({
id: 'dataMachine',
initial: 'loading',
context: {
data: [],
},
@h-jennings
h-jennings / sliderMachine.js
Last active November 7, 2019 21:09
Generated by XState Viz: https://xstate.js.org/viz
const sliderMachine = new Machine({
id: 'sliderMachine',
initial: 'idle',
context: {},
states: {
idle:{
on: {
CLICK_RIGHT: {
target: 'nextSlide'
},
@h-jennings
h-jennings / machine.js
Created December 30, 2019 16:56
Generated by XState Viz: https://xstate.js.org/viz
const dataCollectionStates = {
id: 'dataCollectionStates',
initial: 'idle',
states: {
idle: {
on: {
CHANGE: {
target: 'idle',
actions: ['updateValue'],
},
Powered*
powerFail -> Unpowered
Green*
tick -> Yellow
Yellow
tick -> Red
Red
tick -> Green
Unpowered
@h-jennings
h-jennings / react-btn-w-icon.jsx
Last active June 17, 2020 12:23
Button in react, with icon component
import React, { ReactNode } from 'react';
type ButtonVariants = 'orange' | 'light';
interface ButtonProps {
children: ReactNode;
variant?: ButtonVariants;
icon?: ReactNode;
clickFn?: () => any;
}
MWR_PANEL*
IDLE*
click -> FETCHING_DATA
fetch -> FETCHING_DATA
FETCHING_DATA
success -> COMPONENT_HYDRATED
fail -> ERROR
ERROR
retry -> FETCHING_DATA
COMPONENT_HYDRATED
@h-jennings
h-jennings / coc-settings.json
Last active October 5, 2022 19:13
Coc config
{
"suggest.noselect": false,
"coc.preferences.formatOnSaveFiletypes": [
"javascript",
"typescript",
"typescriptreact",
"json",
"javascriptreact",
"typescript.tsx",
"scss",
@h-jennings
h-jennings / SketchSystems.spec
Last active October 1, 2020 14:59
Main Navigation
Main Navigation
nav_closed*
MOUSE_IN -> nav_open
nav_open
MOUSE_OUT -> nav_closed
Panel_One&
PANEL_CLICK -> panel_open
panel_closed*
panel_open
PANEL_CLICK -> panel_closed
@h-jennings
h-jennings / create-array-groups.ts
Last active October 24, 2020 14:14
function that creates a group of arrays with length limit given an array and a max array length (number)
function createArrayGroups(
data: any[],
maxArrayLength: number
): (any | any[])[] {
let array = [...data];
let groups: (any | any[])[] = [];
do {
groups.push(array.splice(0, maxArrayLength));
} while (array.length > 0);