This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ******************************************************************* | |
// ATTENTION | |
// This gist is now an npm module | |
// The API of some functions is altered slightly. | |
// All future work will happen in the repo. | |
// | |
// https://gitlab.com/rhythnic/vuex-intern | |
// ******************************************************************* | |
// ******************************************************************* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isFn = x => typeof x === 'function' | |
const plural = (words, count) => { | |
words = words.split('|').map(x => x.trim()) | |
return count > 1 ? words[2].replace('{n}', count) : words[count] | |
} | |
// Given a Vuelidate validations object, find the validator keys | |
export function extractValidatorKeys (validations, validators = []) { | |
const keys = Object.keys(validations) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// *************************************** | |
// AnimatedTextFactory | |
// Factory gives you a custom element that accepts a text property. | |
// Each character of the text is wrapped in an element and appended as a child. | |
// You can achieve cool effects by combining css animation with props | |
// set on the child nodes. | |
// | |
// Usage | |
// <template> | |
// <text-stagger-animation-delay text="The ants go marching one by one."> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Small wrapper to enhance the fetch API and handle errors | |
// Requires Promise, fetch, and Object.assign polyfills | |
function checkFetchResponse (response) { | |
if (response.ok) return response | |
return response.text().then(function (text) { | |
const error = new Error(text || response.statusText) | |
error.status = response.status | |
error.statusText = response.statusText | |
throw error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Builder, until } = require('selenium-webdriver') | |
async function setupSeleniumDriver (config) { | |
let driver = await new Builder().forBrowser(config.BROWSER) | |
if (config.HUB_HOST) { | |
driver = driver.usingServer(`http://${config.HUB_HOST}:${config.HUB_PORT}/wd/hub`) | |
} | |
driver = driver.build() | |
await driver.manage().window().setPosition(0, 0) | |
await driver.manage().window().setSize(1280, 1024) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { join } = require('path') | |
const fs = require('fs') | |
const pump = require('pump') | |
class Directory { | |
constructor ({ dir = '' }) { | |
this.dir = dir | |
this.init() | |
} | |
init () {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Directory } = require('./Directory') | |
const AWS = require('aws-sdk') | |
const { PassThrough } = require('stream') | |
const s3 = new AWS.S3({ apiVersion: '2006-03-01' }) | |
module.exports = class S3Directory extends Directory { | |
constructor (opts) { | |
super(opts) | |
this.Bucket = opts.Bucket |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usage with Jest | |
// | |
// const loginForm = [ | |
// { | |
// selector: '#login_username', | |
// property: 'username' | |
// }, | |
// { | |
// selector: '#login_password', | |
// property: 'password' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Serve a single page application (web-client) | |
const path = require('path') | |
const Express = require('express') | |
module.exports = function serveSpa ({ app, omit, public }) { | |
if (!omit) omit = () => false | |
app | |
.use(Express.static(public)) | |
.get('*', (req, res, next) => { | |
if (req.accepts('html') && !omit(req)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express') | |
const R = require('ramda') | |
const uuid = require('uuid') | |
const request = require('request') | |
// ******************************************************* | |
// Models | |
// ******************************************************* | |
// RequestSummary | |
// { |
OlderNewer