Skip to content

Instantly share code, notes, and snippets.

View simonholgate's full-sized avatar

Simon Holgate simonholgate

View GitHub Profile
@simonholgate
simonholgate / hbase.clj
Created June 21, 2012 13:50
Cascalog test with HBase
(ns test.hbase
(:require (cascalog [workflow :as w]
[ops :as c]
[vars :as v]))
(:import (org.apache.hadoop.hbase.util Bytes)
(com.twitter.maple.hbase HBaseTap HBaseScheme)
(cascading.hbase ByteHolder)))
(use '[cascalog api playground])
(bootstrap-emacs)
(ns testincanter.core
(:import (cern.colt.matrix.tdouble DoubleFactory2D DoubleMatrix2D)
(cern.jet.random.tdouble.engine DRand)
(cern.jet.math.tdouble DoubleFunctions)
(java.util Date)))
(defn test-multi [n]
(let [xs (.assign (.make DoubleFactory2D/dense n 23) (DRand. (Date.)))]
(time (let [result (.zMult xs xs nil 1 0 true false)]
[(.columns result) (.rows result)]))))
@simonholgate
simonholgate / gist:1632764
Created January 18, 2012 12:22
clojure.java.jdbc Oracle clob
(defn clob-to-string [clob]
"Turn an Oracle Clob into a String"
(with-open [rdr (java.io.BufferedReader. (.getCharacterStream clob))]
(apply str (line-seq rdr))))
(with-connection mydb
(transaction
(with-query-results rs ["select documentation from station"]
; rs will be a sequence of maps,
; one for each record in the result set.
@simonholgate
simonholgate / matrix.py
Created January 18, 2012 09:44 — forked from sritchie/matrix.py
timing matrix multiplication
(defn feature-vec [n]
(map (partial cons 1)
(for [x (range n)]
(take 22 (repeatedly rand)))))
(defn dot-product [x y]
(reduce + (map * x y)))
(defn transpose
"returns the transposition of a `coll` of vectors"