Skip to content

Instantly share code, notes, and snippets.

@kolodny
kolodny / visual-regression-testing.md
Created December 27, 2019 16:58 — forked from dferber90/visual-regression-testing.md
Visual Regression Testing in Jest

Visual Regression Testing with Jest

This is a walkthrough of how to set up Visual Regression Testing with Jest for an application created with create-react-app.

The following walkthrough uses React as an example, but the approach should work for any modern frontend library! I assume it can be used with Angular, Vue, Cycle.js and more.

This gist walks you through a create-react-app application as an example of how to set up Visual Regression Testing in Jest using libraries I wrote recently which enable this: jsdom-screenshot, jest-transform-css and jest-transform-file.

chrome.proxy.settings.set({
value: {
mode: 'pac_script',
pacScript: {
data:data
}
},
scope: 'regular'
}, function(){
// console.log('set pac scripts result:',arguments);
function cache<Query, Result>(
factory: (query: Query) => Observable<Result>,
cache: Map<Query, Result> = new Map()): (query: Query) =>
Observable<Result> {
const subject = new Subject<Result>();
return query => {
if (cache.has(query)) {
subject.next(cache.get(query));
} else {
factory(query).subscribe(results => {
@kolodny
kolodny / post.md
Created April 17, 2018 13:40
Swift State Machine

Fully Exhaustive Swift State Machine

The following is a nice Swift pattern to make a vanilla Swift state machine:

class Machine {
  enum State {
    case foo
    case bar(String)
    case baz(Int)

In this tutorial we're going to build a set of parser combinators.

What is a parser combinator?

We'll answer the above question in 2 steps

  1. what is a parser?
  2. and.. what is a parser combinator?

So first question: What is parser?

@kolodny
kolodny / Infrastructure.js
Created December 15, 2017 04:27 — forked from sebmarkbage/Infrastructure.js
SynchronousAsync.js
let cache = new Map();
let pending = new Map();
function fetchTextSync(url) {
if (cache.has(url)) {
return cache.get(url);
}
if (pending.has(url)) {
throw pending.get(url);
}
@kolodny
kolodny / cpu-percent.js
Created November 26, 2017 17:33 — forked from pmuellr/cpu-percent.js
get CPU usage percent for a process in node, using proposed `process.cpuUsage()` function
'use strict'
// see: https://github.com/nodejs/node/pull/6157
var startTime = process.hrtime()
var startUsage = process.cpuUsage()
// spin the CPU for 500 milliseconds
var now = Date.now()
while (Date.now() - now < 500)
// https://github.com/kolodny/immutability-helper
/** Declaration extension point */
declare namespace ImmutabilityHelper {
interface CustomOperators<T> {
/* $someShit?: T */
/* $moreShit?: T */
}
}
@kolodny
kolodny / args.sh
Last active November 25, 2020 08:00
args.sh
#!/bin/sh
set -euo pipefail
#declare valid arguments here
bar=
baz=
function parse_args() {
args=()
@kolodny
kolodny / closer.js
Last active October 23, 2016 02:15
Brace closer
module.exports = closer;
function closer(codeString) {
var lines = codeString.split('\n');
var lastIndent = 0;
var currentScope = { indent: 0, children: [] };
for (lineIndex = 0; lineIndex < lines.length; lineIndex++) {
var line = lines[lineIndex];
var currentIndent = /^\s*/.exec(line)[0].length;
if (/^\s*√\s*$/.test(line)) {