This file contains hidden or 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
(let [workers nil] | |
(defn monitor-and-pyramid [src dest steps] | |
(if (empty? @workers) | |
(let [monitor (monitor-and-pyramid src dest) | |
pyramid (make-image-pyramid dest steps)] | |
(set! workers (list monitor pyramid)) | |
(doseq [w workers] (.execute w))) | |
(do (doseq [w workers] (.cancel w true)) | |
(set! workers nil))))) |
This file contains hidden or 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
(let [workers (ref [])] | |
(defn monitor-and-pyramid [src dest steps] | |
(if (empty? @workers) | |
(let [monitor (monitor-directory src dest) | |
pyramid (make-image-pyramid dest steps)] | |
(dosync (doseq [w [monitor pyramid]] (.execute w)) | |
(ref-set workers [monitor pyramid]))) | |
(dosync (doseq [w @workers] (.cancel w true)) | |
(println "Cancelled") | |
(ref-set workers []))))) |
This file contains hidden or 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
(defn thumbnail-info [dir i] | |
(let [thumbs (.listFiles dir (with-suffix i))] | |
(when-not (empty? thumbs) | |
(let [image (IJ/openImage (.getAbsolutePath (first thumbs)))] | |
{:width (.getWidth image) | |
:height (.getHeight image)})))) |
This file contains hidden or 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
int count; | |
byte [] data = new byte [DATA_BLOCK_SIZE]; | |
while ((count = input.read (data, 0, DATA_BLOCK_SIZE)) != -1) { | |
output.write (data, 0, count); | |
} |
This file contains hidden or 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
(defn write [name data] | |
(let [buf (make-array Byte/TYPE 1024) | |
dest (FileOutputStream. name)] | |
(with-open [r (BufferedInputStream. data) | |
w (BufferedOutputStream. dest)] | |
(loop [bytes (.read r buf 0 1024)] | |
(when-not (= bytes -1) | |
(.write w buf) | |
(recur (.read r buf 0 1024))))) | |
(println "Wrote" name))) |
This file contains hidden or 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
(defn calculate-offset [value file s r c] | |
(println "Calculating offset for" (.getName file) "at" [s r c]) | |
(condp #(%1 %2) | |
(or (neg? s) (neg? r) (neg? c)) [-1 -1] | |
(tile-exists? s r c) :>> #(really-calculate-offset file (:file %)) | |
(do (Thread/sleep 60000) | |
(recur value file s r c)))) |
This file contains hidden or 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
(defn calculate-offset [value file s r c] | |
(println "Calculating offset for" (.getName file) "at" [s r c]) | |
(if-let [tile (get-tile s r c)] | |
(really-calculate-offset file (:file tile)) | |
(do (Thread/sleep 60000) | |
(recur value file s r c)))) | |
(defn make-offset [file sec row col] | |
(let [->offset #(calculate-offset %1 file sec %2 %3) | |
row-1 (dec row) row+1 (inc row) |
This file contains hidden or 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
(defn calculate-offset [value file section row column direction] | |
(let [tile (get-tile section row column)] | |
(cond | |
(out-of-bounds? row column) [-1 -1] | |
(not (false? tile)) (really-calculate-offset file (:file tile) direction) | |
:else | |
(do (Thread/sleep 60000) | |
(recur value file section row column direction))))) | |
(defn make-agent [section row column action direction] |
This file contains hidden or 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
(defn find-edge [image cx cy] | |
(let [width (.getWidth image) | |
height (.getHeight image) | |
ip (-> image .getProcessor .duplicate)] | |
(.findEdges ip) | |
(doall | |
(for [x (range width) | |
y (range height) | |
:let [value (.get ip x y)] | |
:when (not (zero? value))] |
This file contains hidden or 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
//find PK column | |
List<String> pkColList = new ArrayList<String>(); | |
DatabaseMetaData dbMetaData = con.getMetaData(); | |
ResultSet pkRs = dbMetaData.getPrimaryKeys(null, schema, table); | |
while(pkRs.next()) { | |
pkColList.add(pkRs.getString(4)); | |
} | |
pkRs.close(); | |
if (pkColList.size() != 1) { | |
throw new InvalidTableException("Table " + schema + "." + table + " has " + pkColList.size() + " PK columns - only allowed 1"); |
OlderNewer