Skip to content

Instantly share code, notes, and snippets.

@savagematt
savagematt / hack3dSecure.js
Last active September 5, 2019 12:31
Automate 3D secure when testing strong customer authentication flows with Stripe
const { Builder, By, until } = require("selenium-webdriver");
const tcpPortUsed = require("tcp-port-used");
const { exec } = require("child_process");
process.env.SELENIUM_BROWSER = "chrome:75:LINUX";
process.env.SELENIUM_REMOTE_URL = "http://localhost:4444/wd/hub";
let driver = () => {
const result = new Builder().forBrowser("chrome").build();
driver = () => result;
@savagematt
savagematt / withX.ts
Created August 7, 2019 14:02
scenario withX
export type ReturnValue<T> = T extends (...args: any[]) => infer RETURN
? RETURN
: T;
export type Args<T> = T extends (...args: infer ARGS) => any
? ARGS
: [];
export type CallAsStep<C, T> = (...args: Args<T>) => Step<C, Promise<Resolve<ReturnValue<T>>>>;
export type StepGenerator<C, T> = { [K in keyof T]: CallAsStep<C, T[K]> };
export type Resolve<T> = T extends Promise<infer U> ? U :T;
@savagematt
savagematt / vars.ts
Created August 7, 2019 13:59
scenario vars
export interface Vars<T> {
/**
* Returns a step that assigns the result of step to key k.
*
* Always returns void, so if the step returned a promise set() won't block.
*
* You can:
*
* // will NOT block on stepThatCompletesEventually return value
* set('value',stepThatCompletesEventually),
@savagematt
savagematt / partitions.ts
Created July 17, 2019 04:49
partitionMany
import {marbles} from "rxjs-marbles";
export function partitions<T>(
source: ObservableInput<T>,
p1: ((value: T, index: number) => boolean),
): [Observable<T>, Observable<T>] ;
export function partitions<T>(
source: ObservableInput<T>,
p1: ((value: T, index: number) => boolean),
// Quick and easy
// add correlation id to app logs
// set correlation id in test steps (but ignore user-specified correlation id in production)
log.anonymised({some:"log"});
log.sensitive(() => {some:"log"});
log.sensitive({some:"log"});
// Maybe inconvenient, and maybe we don't need it
@savagematt
savagematt / blah.md
Last active June 29, 2016 14:54
Toshtogo README WIP

Toshtogo

"Aha!"

What is Toshtogo? (the simple version)

A workflow engine, for monitoring and orchestrating a graph of processes that depend on each other.

Terms

(ns pierrepoint.di
(:require [clojure.string :as st]
[potemkin.collections :refer [def-map-type keys*]])
(:import [java.util NoSuchElementException UUID Map]
[java.lang.reflect Method]
[clojure.lang RestFn Fn ArityException IDeref]
[java.lang AutoCloseable]))
; Utils
; ==================================
(ns midje.contrib.midje-schema
(:require [schema.core :as sch]
[schema.coerce :as coer]
[schema.utils :as utils]
[schema.macros :as macros]
[midje.checking.core :refer [as-data-laden-falsehood]]
[clj-time.core :refer [now minutes seconds millis plus minus after? interval within?]]
[clojure.pprint :refer [pprint]]
[clojure.stacktrace :refer [print-cause-trace]]
))
@savagematt
savagematt / OMGWTFBBQ
Last active August 29, 2015 13:57
OMGWTFBBQ
(defprotocol Foo (one [this])
(two [this arg]))
(def echo-foo
(reify
Foo
(one [this] "test")
(two [this arg] arg)))
(defn delegating-s-expression [this-symbol sig arglist]
@savagematt
savagematt / gist:1192295
Created September 4, 2011 05:02
First time!!!
package au.com.sheep;
import org.hamcrest.Matcher;
import org.junit.Test;
import org.mockito.Matchers;
import java.util.List;
import static au.com.sheep.MockitoMatcherRecorder.record;
import static org.hamcrest.MatcherAssert.assertThat;