Skip to content

Instantly share code, notes, and snippets.

View potix2's full-sized avatar
:octocat:

Katsunori Kanda potix2

:octocat:
View GitHub Profile
@potix2
potix2 / view_mask.py
Created November 17, 2016 08:58
simple target dtection
#!/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
@potix2
potix2 / wordcount.clj
Created September 25, 2013 00:22
Lisp Meet Up #9
(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)])))
@potix2
potix2 / tagless.scala
Created December 18, 2015 14:50
[WIP]tagless final
//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]
}
@potix2
potix2 / fibonacci.scala
Created June 2, 2013 14:41
memoized fibonacci
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)
@potix2
potix2 / Chapter7.scala
Created May 26, 2013 23:19
TAPL Chapter7 - Lambda Calculus
import java.util.NoSuchElementException
/**
*
*
*/
abstract class Term
case class TmVar(info:Object, x:Int, n:Int) extends Term
@potix2
potix2 / Chapter4.scala
Created May 26, 2013 23:16
TAPL Chapter4 - Arithmetic Expression
/**
*
*
*/
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
@potix2
potix2 / gist:5211862
Last active December 15, 2015 05:49
Example: Multiple Assignment in groovy
list = [1, 2, 3]
def (c, d, e) = list
println c
println d
println e
@potix2
potix2 / core.clj
Created March 17, 2013 09:28
example of carmine
(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
@potix2
potix2 / td2json.pl
Last active December 14, 2015 16:18
スレッドダンプからRUNNABLEなものだけ抽出する
#!/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 = {};
@potix2
potix2 / gist:5024367
Created February 24, 2013 16:12
compojure example
(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