Skip to content

Instantly share code, notes, and snippets.

package utils
import java.util.function.Predicate
import org.testcontainers.containers.GenericContainer.AbstractWaitStrategy
import org.testcontainers.containers.output.OutputFrame.OutputType.STDOUT
import org.testcontainers.containers.output.{OutputFrame, WaitingConsumer}
class WaitForLogLine(val msg: String) extends AbstractWaitStrategy {
# -*- coding: utf-8 -*-
#
# Copyright (C) 2015 Thomas Amland
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@tamland
tamland / Solarized-Dark.ksf
Created March 8, 2014 12:56
Solarized Dark for Komodo Edit. Modified the system scheme to look more like the original.
Version = 11
Booleans = {'caretLineVisible': True, 'preferFixed': 1, 'useSelFore': True}
CommonStyles = {'attribute name': {'fore': 7872391},
'attribute value': {'fore': 3100463},
'bracebad': {'fore': 3093212},
'bracehighlight': {'fore': 8533715},
'classes': {'fore': 13798182},
'comments': {'fore': 7695960, 'italic': True},
@tamland
tamland / obox.scala
Last active August 29, 2015 13:56
Find the minimum arbitrarily oriented bounding box from the convex hull
case class Point(x: Double, y: Double)
def orientedBoundingBox(hull: Seq[Point]) = {
val (area, rect) = (1 until hull.size).map { i =>
val (u, v) = (hull(i-1), hull(i))
val angle = math.atan((u.x - v.x) / (u.y - v.y))
val rotated = hull.map(rotate(_, angle))
val xs = rotated.map(_.x)
val ys = rotated.map(_.y)
@tamland
tamland / MultiWeiszfeld.scala
Last active August 29, 2015 13:56
Weiszfeld method for the multi-facility location problem
/**
* A straightforward implementation of the multi-facility Weiszfeld method described by
* Iyigun et al. for 2D euclidean. http://dx.doi.org/10.1016/j.orl.2009.11.005
* Have some failings, e.g. if all the initial locations are the same
*
* @param points The demand points
* @param initial Initial locations of facilities
*/
def multiWeiszfeld(points: Seq[Point], initial: Seq[Point]): Seq[Point] = {
val eps = 1e-6
import scala.collection.mutable.ListBuffer
case class Point(x: Double, y: Double)
/** Compute the convex hull of given points. Returns vertices ordered ccw */
def convexHull(_points: Seq[Point]): Seq[Point] = {
val points = _points.sortBy(_.x)
val upper = halfHull(points)
val lower = halfHull(points.reverse)
upper.remove(0)
@tamland
tamland / hls.py
Last active December 23, 2015 06:29
newer version here: https://github.com/tamland/pyhls