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
| Transient used by non-owner thread | |
| ;; [Thrown class java.lang.IllegalAccessError] |
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
| (def & comp) | |
| (def p partial) | |
| (def $ apply) | |
| (def kws (map (& keyword str) (seq "abcdefghijklmnopqrstuvwxyz"))) | |
| (defn items [] | |
| (for [i (range 10000)] | |
| ($ merge (for [kw kws] {kw i})))) | |
| (def head ($ merge (for [kw kws] {kw []}))) |
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
| (defun lein-swank (root &optional args) | |
| "starts lein-swank and connects slime with it" | |
| (interactive (find-file-read-args "Project root: " nil)) | |
| (start-process "lein-swank" "*lein-swank*" | |
| "/bin/bash" "-c" (concat "cd " root "; lein swank")) | |
| (slime-connect "127.0.0.1" "4005")) |
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
| /** A subclass of RandomAccessFile to enable basic buffering to a byte array | |
| * Copyright (C) 2009 minddumped.blogspot.com | |
| * This program is free software: you can redistribute it and/or modify | |
| * it under the terms of the GNU General Public License as published by | |
| * the Free Software Foundation, either version 3 of the License, or | |
| * (at your option) any later version. | |
| * This program is distributed in the hope that it will be useful, | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of |
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
| (use 'clojure.contrib.duck-streams) | |
| (in-ns 'clojure.contrib.duck-streams) | |
| (import '(java.io File RandomAccessFile)) | |
| (import 'BufferedRandomAccessFile) | |
| ;; copied and adapted from c.c.ds | |
| (defmulti #^{:arglist '([x])} random-access-reader class) | |
| (defmethod random-access-reader File [#^File x] | |
| (BufferedRandomAccessFile. x "r")) |
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
| user> (statistics 25 (with-open [rar (random-access-reader (model-file "upps.data.model"))] (doseq [line (lazy-rest rar)] nil))) | |
| Runs: 25 | |
| Min: 1740.527 | |
| Max: 2911.521 | |
| Mean: 2516.340 | |
| Median: 2326.024 | |
| sd: 424.961 |
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
| /** A subclass of RandomAccessFile to enable basic buffering to a byte array | |
| * Copyright (C) 2009 minddumped.blogspot.com | |
| * This program is free software: you can redistribute it and/or modify | |
| * it under the terms of the GNU General Public License as published by | |
| * the Free Software Foundation, either version 3 of the License, or | |
| * (at your option) any later version. | |
| * This program is distributed in the hope that it will be useful, | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of |
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
| (use 'clojure.contrib.duck-streams) | |
| (in-ns 'clojure.contrib.duck-streams) | |
| (import '(java.io File RandomAccessFile)) | |
| (import 'BufferedRandomAccessFile) | |
| ;; copied and adapted from c.c.ds | |
| (defmulti #^{:arglist '([x])} random-access-reader class) | |
| (defmethod random-access-reader File [#^File x] | |
| (BufferedRandomAccessFile. x "r")) |
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
| (defmacro timer | |
| [expr] | |
| `(let [start# (. System (nanoTime)) | |
| ret# ~expr] | |
| (/ (double (- (. System (nanoTime)) start#)) 1000000.0))) | |
| (defmacro statistics [n expr] | |
| `(let [timings# (take ~n (repeatedly (fn [] (timer ~expr)))) | |
| min# (apply min timings#) | |
| max# (apply max timings#) |
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
| (with-random-access-reader "/Users/angerman/upps.data.model" | |
| (println (next-line)) ;; first line | |
| (println (next-line)) ;; second line | |
| (save-excursion | |
| (println (subs (last (lazy-rest)) 0 20))) ;; last line's first 20 char | |
| (println (next-line)) ;; third line | |
| (println (subs (last (lazy-rest)) 0 20))) ;; last lines first 20 char |