Skip to content

Instantly share code, notes, and snippets.

View jaetask's full-sized avatar

Jae Task jaetask

View GitHub Profile
@jaetask
jaetask / data.csv
Created May 28, 2017 11:32 — forked from grncdr/data.csv
Demo of importing a CSV file into a Contentful space
first name last name age
Stephen Sugden 31
Tom Reznik 29
Justin Thomas 30
@jaetask
jaetask / example.js
Created February 1, 2019 10:06
[Cypress match text / tag name case insensitively] #cypress
cy.get('[data-testid=grid-children]')
.should('have.prop', 'tagName')
.should('match', /div/i);
@jaetask
jaetask / example.js
Created February 1, 2019 10:19
[Cypress before / beforeEach optimisation] Descrease time to test by only requesting the base page once #cypress
// If all the tests happen on a single page with no dynamic changes
// use before instead of before each
// This exponentially reduces the test time. from 7.5s to 1.2s for only 5 tests.
before(() => {
cy.visit('/style-guide');
});
@jaetask
jaetask / cognito.yaml
Last active February 17, 2019 19:25 — forked from singledigit/cognito.yaml
[Create a Cognito Authentication Backend via CloudFormation] #aws #serverless #cognito
AWSTemplateFormatVersion: '2010-09-09'
Description: Cognito Stack
Parameters:
AuthName:
Type: String
Description: Unique Auth Name for Cognito Resources
Resources:
# Creates a role that allows Cognito to send SNS messages
SNSRole:
@jaetask
jaetask / export-named-sheet-as-csv.gs
Created November 16, 2019 10:25 — forked from mrkrndvs/export-named-sheet-as-csv.gs
Google apps script to export an individual sheet as csv file
/*
* script to export data of the named sheet as an individual csv files
* sheet downloaded to Google Drive and then downloaded as a CSV file
* file named according to the name of the sheet
* original author: Michael Derazon (https://gist.github.com/mderazon/9655893)
*/
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var csvMenuEntries = [{name: "Download Primary Time File", functionName: "saveAsCSV"}];
@jaetask
jaetask / machine.js
Last active March 21, 2020 14:29
Generated by XState Viz: https://xstate.js.org/viz
const G99_REQUIRED_THRESHOLD = 3.68;
const assignByValue = (context, event) => event.value
const updateExistingPv = assign({existingPv: assignByValue});
const updateProposedPv = assign({proposedPv: assignByValue});
const updateBatteryOutput = assign({batteryOutput: assignByValue});
const updateBatteryEnabled = assign({isBatteryEnabled: assignByValue});
const updateG99DecisionOverridden = assign({hasG99DecisionBeenOverridden: assignByValue});
const calcTotalOnSiteGeneration = assign({
totalOnSiteGeneration: (context, event) => {
let result = context.existingPv + context.proposedPv;
@jaetask
jaetask / machine.js
Last active March 21, 2020 18:10
Generated by XState Viz: https://xstate.js.org/viz
const assignByValue = name => assign({ [name]: (context, event) => event.value });
const addProduct = (logic, product) =>
assign({
products: (c, e) => (logic(c, e) ? c.products.concat(product) : c.products),
});
const installCostsMachine = Machine(
{
id: 'install_costs',
@jaetask
jaetask / machine.js
Last active March 26, 2020 17:20
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - assign
// - send
// - raise
// - actions
const loginMachine = Machine({
id: 'login_machine',
initial: 'idle',
@jaetask
jaetask / machine.js
Last active March 26, 2020 19:45
Generated by XState Viz: https://xstate.js.org/viz
// import { assign, Machine } from 'xstate';
const MIN_NUM_SURVEYS = 1;
const MAX_NUM_SURVEYS = 4;
const surveyInitialState = { name: 'Default Name' };
const canAdd = context => context.surveys.length < MAX_NUM_SURVEYS;
const canClone = context => context.surveys.length < MAX_NUM_SURVEYS;
const canUndoDelete = context => context.surveys.length < MAX_NUM_SURVEYS;
@jaetask
jaetask / machine.js
Last active March 28, 2020 10:49
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)