This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import cv2 | |
import numpy | |
# read png image and convert the image to HSV | |
image = cv2.imread("/path/to/target.png", cv2.IMREAD_COLOR) | |
hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV) | |
# detect green objects |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def test-data "'Updates' a value in a nested associative structure, where ks is a sequence of keys and f is a function that will take the old value ") | |
(->> (re-seq #"\w+" test-data) | |
(map #(.toLowerCase %)) | |
(group-by identity) | |
(map (fn [[k v]] [k (count v)]))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SEE: http://keens.github.io/slide/DSLtoTagless_Final/ | |
case class Result | |
case class JSON | |
trait ScenarioSYM[T] { | |
def get(url: String): ScenarioSYM[T] | |
def post(url: Sting, data: JSON): ScenarioSYM[T] | |
def and(first: ScenarioSYM[T], second: ScenarioSYM[T]): ScenarioSYM[T] | |
def run(scenario: ScenariosSYM[T]): ScenarioSYM[T] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Memoize1[-T, +R](f: T => R) extends (T => R) { | |
private[this] val memorized = scala.collection.mutable.Map.empty[T, R] | |
def apply(x: T):R = { | |
memorized.getOrElseUpdate(x, f(x)) | |
} | |
} | |
object Memoize1 { | |
def apply[T, R](f: T => R) = new Memoize1(f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.NoSuchElementException | |
/** | |
* | |
* | |
*/ | |
abstract class Term | |
case class TmVar(info:Object, x:Int, n:Int) extends Term |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* | |
*/ | |
abstract class Term | |
case class TmTrue(info: Object) extends Term | |
case class TmFalse(info: Object) extends Term | |
case class TmIf(info: Object, t1:Term, t2:Term, t3:Term) extends Term | |
case class TmZero(info: Object) extends Term | |
case class TmSucc(info: Object, t:Term) extends Term |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
list = [1, 2, 3] | |
def (c, d, e) = list | |
println c | |
println d | |
println e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns carmine-test.core | |
(:require [taoensso.carmine :as car]) | |
(:require [taoensso.carmine.locks :as carl])) | |
(def pool (car/make-conn-pool)) | |
(def spec-server1 (car/make-conn-spec)) | |
(defmacro wcar [& body] `(car/with-conn pool spec-server1 ~@body)) | |
(wcar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
#usage: perl td2json.pl < jvm-thread-dump.log | |
use strict; | |
use warnings; | |
use JSON; | |
my $buf = ''; | |
my $row = 0; | |
my $thread_info = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns adder.handler | |
(:use compojure.core) | |
(:require [compojure.handler :as handler] | |
[compojure.route :as route])) | |
(defn parse-input [s] | |
(Integer. (re-find #"[0-9]*" s))) | |
(def fibs | |
((fn rfib |