Skip to content

Instantly share code, notes, and snippets.

@AshCoolman
AshCoolman / integration.test.js
Created January 19, 2018 12:11
Differencify live vs test
import Differencify from '../index';
const differencify = new Differencify({ debug: true });
describe('Differencify', async () => {
let target;
let page;
beforeAll(async () => {
await differencify.launchBrowser({ args: ['--no-sandbox', '--disable-setuid-sandbox'], headless: false });
target = differencify.init({ chain: false });
@AshCoolman
AshCoolman / jest.md
Created January 25, 2018 11:05
Jest cheat sheet

Jest cheat shiiiit

Expect

expect.any(constructor) // expect(callback).toBe(expect.any(Function))
expect.assertions(number) // total count of expected assertions, useful for async tests
.not
.resolves
.rejects
.toBe(value)

.toHaveBeenCalled()

@AshCoolman
AshCoolman / Jenkins cheat sheet.md
Last active January 31, 2018 10:34
Jenkins cheatsheet.md

Sections

Contains Directives or Steps

  • agent - where env will execute
  • post - run once Pipeline or stage has run. Supports blocks always (regardless), changed (different completion status), failure, success, unstable (Pipeline or stage run status == "unstable" e.g. test failures), aborted
@AshCoolman
AshCoolman / findAllTests.sh
Created February 1, 2018 10:57
Lerna repo test finder
# Easy to use mocha globs to find test files in this structure:
#
# └─src
# │ └─index.spec.js
# └─.dist
# │ └─index.spec.js
# └─node_modules
# └─(...various...)
#
# With this structure, it got very difficult with include+exclude globs (perhaps impossible)
@AshCoolman
AshCoolman / Snippets.md
Last active March 28, 2018 10:57
Snippets

Glob

python << EOF
import glob
for name in glob.glob('/*'):
  print(name)
EOF
@AshCoolman
AshCoolman / createNumberFormatFromNumberToLocalString.js
Created February 12, 2018 18:06
Create number format from Number.prototype.toLocaleString
// The following must be executed in browser, and can be pasted into
//
// WHY?
// 1. Browser support is a bit spotty
// 2. Testing with node framework made harder as node doesn't come with internationalistion (full-icu) data by default
// 3. Int shim is ~56Kb https://github.com/andyearnshaw/Intl.js/blob/master/dist/Intl.min.js. This is ~7kb
var getNumberFormatFromIso2 = (iso) => {
let thousandsSeparatorSymbol;
@AshCoolman
AshCoolman / label.js
Created February 15, 2018 11:57
Label to help with jest snapshots
// Jests dont write to file in chron order, prefix with number helps
let count = 0;
const label = (tmpl, ...val) => {
val.reverse();
return `${
count++ // eslint-disable-line
}. ${
tmpl.reduce((p, c) => p + c + (val.length ? val.pop() : ''), '')
}`;
@AshCoolman
AshCoolman / kk
Last active February 20, 2018 11:47
OSX notifications for 'kk.'
#!/usr/bin/env bash
notify "kk."
While such costs might be negligable for cold code, in the sort code comparator was invocated millions of times which made overheads of arguments adaptation quite pronounced.