Skip to content

Instantly share code, notes, and snippets.

View kevinold's full-sized avatar

Kevin Old kevinold

View GitHub Profile
const dataMachine = Machine({
id: "dataMachine",
initial: "idle",
context: {
pageData: {},
results: []
},
states: {
idle: {
on: {
@kevinold
kevinold / machine.js
Last active March 10, 2020 21:00
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@kevinold
kevinold / jwtUtils-spec.js
Created August 8, 2019 22:32
Test that a JWT is expired or expires within a certain window using Sinon's Fake Timers
import expect from "expect";
import sinon from "sinon";
// Inline version of function to be tested
const expiredOrExpiresWithin = (decodedJwt, seconds) =>
Date.now() >= (decodedJwt.exp + (-Math.abs(seconds) || 0)) * 1000;
describe("jwtUtils", () => {
describe("expiredOrExpiresWithin", () => {
let clock;
@kevinold
kevinold / delay-promise.js
Created June 18, 2019 22:26 — forked from joepie91/delay-promise.js
ES6 Promise.delay
module.exports = function(duration) {
return function(){
return new Promise(function(resolve, reject){
setTimeout(function(){
resolve();
}, duration)
});
};
};
@kevinold
kevinold / README.md
Created June 17, 2019 13:42 — forked from NoriSte/README.md
Conio Business site monitoring

A Cypress test checking the most common issues faced by Conio with the AWS/S3 management (with a custom configuration for Brotli)

Parameters:
Env:
Description: An environment name that will be prefixed to resource names
Type: String
AllowedValues: ["development", "production"]
resources:
NetworkRole:
Type: "AWS::IAM::Role"
Properties:
@kevinold
kevinold / serverless-deploy-user.yaml
Created June 5, 2019 17:20 — forked from bsamuel-ui/serverless-deploy-user.yaml
Cloudformation template to deploy permissions for deploying a serverless project.
AWSTemplateFormatVersion: 2010-09-09
Description: >
Constructs a managed IAM policy to deploy a serverless project.
This template assumes the stack is being deployed in the current region and account.
You can then attach this policy to other IAM objects, such as users or roles.
Based on the work done in: https://github.com/serverless/serverless/issues/1439
@kevinold
kevinold / editPage.js
Created June 4, 2019 16:30 — forked from pmarquees/editPage.js
Edit page (bookmarlet)
javascript:document.body.contentEditable = 'true'; document.designMode='on'; void 0
@kevinold
kevinold / postgres_queries_and_commands.sql
Created May 15, 2019 20:30 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@kevinold
kevinold / restart_bluetooth.sh
Created May 1, 2019 17:01 — forked from nicolasembleton/restart_bluetooth.sh
Restart Bluetooth Daemon on Mac OS X without restarting
#!/bin/bash
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport