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
| var doTree = function (tree, func) { | |
| func (tree.value); | |
| for (var child in tree.children) { doTree (child); } | |
| }; | |
| var makeNode = function (i) { return { value: i, children: [] };}; | |
| var numTree = { value: 42, children: [makeNode (1), makeNode (2)]}; | |
| var sumTree = function (i) { if (this.sum == undefined) this.sum = 0; else this.sum += i; }; |
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
| (ns edu.harvard.connectome.convert-tiff-to-png | |
| (:gen-class) | |
| (:import [ij IJ ImagePlus]) | |
| (:use [clojure.contrib io seq string :as s])) | |
| (defn only-tiff (proxy [java.io.FilenameFilter] [] | |
| (accept [file name] (.endsWith name "tif")))) | |
| (defn replace-extension [file old-ext new-ext] | |
| (.replace (str file) old-ext new-ext)) |
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
| (ns edu.harvard.connectome.convert-tiff-to-png | |
| (:gen-class) | |
| (:import [edu.harvard.connectome Dataset IterationCallback] | |
| [ij IJ])) | |
| (defn only-tiff (proxy [java.io.FilenameFilter] [] | |
| (accept [file name] (.endsWith name "tif")))) | |
| (defn replace-extension [file old-ext new-ext] | |
| (.replace (str file) old-ext new-ext)) |
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
| ij> describe app.markup; | |
| COLUMN_NAME |TYPE_NAME|DEC&|NUM&|COLUM&|COLUMN_DEF|CHAR_OCTE&|IS_NULL& | |
| ------------------------------------------------------------------------------ | |
| ID |INTEGER |0 |10 |10 |GENERATED&|NULL |NO | |
| PROCESS_ID |INTEGER |0 |10 |10 |NULL |NULL |NO | |
| SECTION_ID |INTEGER |0 |10 |10 |NULL |NULL |NO | |
| RED |SMALLINT |0 |10 |5 |NULL |NULL |NO | |
| GREEN |SMALLINT |0 |10 |5 |NULL |NULL |NO | |
| BLUE |SMALLINT |0 |10 |5 |NULL |NULL |NO | |
| ALPHA |SMALLINT |0 |10 |5 |NULL |NULL |YES |
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
| Test successful | |
| Profiler: top 3 stack trace(s) of 595217 ms [build-139]: | |
| 11750/11786 | |
| at java.io.RandomAccessFile.writeBytes(Native Method) | |
| at java.io.RandomAccessFile.write(Unknown Source) | |
| at org.h2.store.FileStore.write(FileStore.java:332) | |
| at org.h2.store.PageStore.checkpoint(PageStore.java:389) | |
| at org.h2.store.PageStore.openExisting(PageStore.java:317) | |
| at org.h2.store.PageStore.open(PageStore.java:264) | |
| at org.h2.engine.Database.getPageStore(Database.java:2059) |
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
| class Test { | |
| public static abstract class Base { | |
| public Base (int x) { initialize (x); } | |
| protected String value; | |
| private void initialize (int x) { | |
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
| mac:foo duncan$ cat src/foo/core.clj | |
| (ns foo.core (:require clojure.java.io)) | |
| (defn foo [] (println (file (System/getProperty "user.home")))) | |
| mac:foo duncan$ java -cp "lib/*" clojure.main src/foo/core.clj | |
| Exception in thread "main" java.lang.Exception: Unable to resolve symbol: file in this context (core.clj:3) | |
| at clojure.lang.Compiler.analyze(Compiler.java:5205) | |
| at clojure.lang.Compiler.analyze(Compiler.java:5151) | |
| at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3036) |
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
| (ns ScriptIJ.distance-matrix | |
| (:import [java.awt.geom Point2D$Double])) | |
| (defn ->point [m] | |
| (Point2D$Double. (Double/parseDouble (get m "XM")) | |
| (Double/parseDouble (get m "YM")))) | |
| (defn compute-matrix [table] | |
| (partition (count table) | |
| (for [a table, b table] |
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
| (defmulti distance #(vector (class %1) (class %2))) | |
| (defmethod distance [IPersistentVector IPersistentVector] | |
| [p q] | |
| (let [[x1 y1] p, [x2 y2] q] | |
| (.distance (Point. x1 y1) (Point. x2 y2)))) | |
| (defmethod distance [Point Point] | |
| [p q] (.distance p q)) |
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 rotations [s] | |
| (map #(take (count s) (drop % (cycle s))) | |
| (range (count s))) |