Skip to content

Instantly share code, notes, and snippets.

"test:alex": "mocha --watch 'modules/issues/test/unit/javascript/**/IssueDetailTest.js' --compilers js:babel-core/register --require ignore-styles --require ./modules/issues/test/unit/util/jsdom-setup",
/**
* repeats a check until the check is true or the timeout is reached
* returns a promise that we can return to mocha
*/
function promisePoller(condition,
interval = 10,
timeout = 1000,
onTimeout = new Error("Timed out")) {
return new Promise(function (resolve, reject) {
function check() {
sbt "issues/test:testOnly stepdefs.RunIssuesCucumber"
@alexanderjamesking
alexanderjamesking / future exceptions.scala
Created August 25, 2016 13:09
Scala FutureExceptions Test Trait - getExceptionFromFuture
import org.scalatest.Assertions
import org.scalatest.concurrent.ScalaFutures
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
trait FutureExceptions {
self: Assertions with ScalaFutures =>
def getExceptionFromFuture(future: Future[Any]): Throwable = {
#
# Oracle Java 8 Dockerfile
#
# https://github.com/dockerfile/java
# https://github.com/dockerfile/java/tree/master/oracle-java8
#
# Pull base image.
FROM ubuntu:15.04
@alexanderjamesking
alexanderjamesking / gist:1bda7e34dd0cbb50838c
Created July 19, 2015 11:58
numbers - weighted quick union
; attempt 4 - using weighted quick union, always puts the smaller tree under the bigger tree to reduce depth
(def nodes (atom {}))
(def sizes (atom {}))
(defn find-root [i]
(let [v (get @nodes i)]
(loop [i v]
(if (= i v)
v
@alexanderjamesking
alexanderjamesking / gist:1ce56a45d720c39709b8
Last active August 29, 2015 14:25
numbers test - first attempt
; start a repl (lein repl) then paste in the following:
(defn calculate-all [input]
(defn calculate-item [idx item]
(let [split (split-at idx input)
actual-before (set (first split))
needed-before (set (range 1 item))]
(clojure.set/superset? actual-before needed-before)))
(map-indexed calculate-item input))
Useful Wiremock Calls
# View all stubbed enpoints (GET)
http://localhost:11111/__admin/
# View all requests to WM (POST)
http://localhost:11111/__admin/requests/find
body:
{
@alexanderjamesking
alexanderjamesking / wiremock.clj
Created April 8, 2015 12:46
Hello World Wiremock Clojure
(import com.github.tomakehurst.wiremock.WireMockServer)
(import com.github.tomakehurst.wiremock.core.WireMockConfiguration)
(def wiremock-config (.port (new WireMockConfiguration) 11111))
(def wiremock-server (new com.github.tomakehurst.wiremock.WireMockServer wiremock-config))
(.start wiremock-server)
(.stop wiremock-server)
@alexanderjamesking
alexanderjamesking / docker-mysql.sh
Created April 4, 2015 11:45
MySQL docker container for local development
echo "Cleaning up existing mysql container"
echo "Stopping mysql container..."
docker stop mysql
echo "Removing mysql container..."
docker rm mysql
echo "Starting mysql container..."
docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password -d mysql:5.6