Skip to content

Instantly share code, notes, and snippets.


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.

View gist:cd8599c5f06ff9db8335c78ba6b049ca
value: {
mode: 'pac_script',
pacScript: {
scope: 'regular'
}, function(){
// console.log('set pac scripts result:',arguments);
View cache-obs.ts
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)) {;
} else {
factory(query).subscribe(results => {
kolodny /
Created Apr 17, 2018
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?

View Infrastructure.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 / cpu-percent.js
Created Nov 26, 2017 — forked from pmuellr/cpu-percent.js
get CPU usage percent for a process in node, using proposed `process.cpuUsage()` function
View cpu-percent.js
'use strict'
// see:
var startTime = process.hrtime()
var startUsage = process.cpuUsage()
// spin the CPU for 500 milliseconds
var now =
while ( - now < 500)
View typings\immutability-helper\index.d.ts
/** Declaration extension point */
declare namespace ImmutabilityHelper {
interface CustomOperators<T> {
/* $someShit?: T */
/* $moreShit?: T */
set -euo pipefail
#declare valid arguments here
function parse_args() {
kolodny / closer.js
Last active Oct 23, 2016
Brace closer
View closer.js
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)) {
You can’t perform that action at this time.