Skip to content

Instantly share code, notes, and snippets.

@ChrisDobby
ChrisDobby / lighthouse.js
Created Jan 23, 2019
Runs lighthouse against a web application - successful if everything scores 0.9 or above
View lighthouse.js
require('colors');
const lighthouse = require('lighthouse');
const chromeLauncher = require('chrome-launcher');
const launchAndRun = (url, opts, config = null) =>
chromeLauncher.launch({ chromeFlags: opts.chromeFlags })
.then(chrome => {
opts.port = chrome.port;
return lighthouse(url, opts, config).then(results => chrome.kill().then(() => results.lhr));
});
@ChrisDobby
ChrisDobby / classNameFunc.js
Last active Jun 6, 2018
Creates a css class on the fly from an object
View classNameFunc.js
const ClassName = () => {
const createdClasses = [];
const stringToCss = str => str.split('').map(c => c.charCodeAt(0) >= 97
? c
: `-${String.fromCharCode(c.charCodeAt(0) + 32)}`).join('');
const cssString = css => Object.keys(css).map(key => `${stringToCss(key)}:${css[key]}`).join(';');
const addStyle = (name, css) => {
View Visitor.fs
namespace Visitor
type IPrescription =
abstract member Accept : IPrescriptionVisitor -> unit
and IPrescriptionVisitor =
abstract member Visit : PointInTime -> unit
abstract member Visit : Infusion -> unit
and PointInTime() =
You can’t perform that action at this time.