This file contains 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
;; This stuff is pretty useful in many contexts. | |
... | |
(:import (com.google.common.cache CacheBuilder CacheLoader)) | |
... | |
quantataraxia.core> (with (-> (CacheBuilder/newBuilder) | |
(.weakKeys) |
This file contains 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 [f (future | |
(try | |
(Thread/sleep 10000) | |
(catch Throwable e | |
(println e) | |
(println "isInterrupted:" (.isInterrupted (Thread/currentThread))) | |
(println "isAlive:" (.isAlive (Thread/currentThread))) | |
(println "interrupted:" (Thread/interrupted)))))] | |
(Thread/sleep 500) | |
(future-cancel f) |
This file contains 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
;; I keep forgetting how to do this stuff for some reason, so here goes: | |
(let [c (async/chan 1 (map #(* % 2)))] | |
(async/go | |
(loop [] | |
(when-let [e (async/<! c)] | |
(println "async/go, e:" e) | |
(recur)))) | |
(async/>!! c 1) | |
(async/>!! c 2)) |
This file contains 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
;; www.Quanto.ga | |
;; | |
;; cp/upmap is from https://github.com/TheClimateCorporation/claypoole | |
quantataraxia.core> (do | |
(println "MAP:") | |
(println (time (doall (map (fn [x] (Thread/sleep x) x) | |
(range 500 50 -9))))) | |
(println "PMAP:") |
This file contains 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
;; Performance of with-local-vars vs. atom vs. volatile vs. unsynchronized-mutable field. | |
(definterface IOObject | |
(setVal [new-val]) | |
(getVal []) | |
(oswap [f]) | |
(oswap [f x]) | |
(oswap [f x y]) | |
(oswap [f x y z])) |
This file contains 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
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
. ~/.bashrc | |
mkdir ~/local | |
mkdir ~/node-latest-install | |
cd ~/node-latest-install | |
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
./configure --prefix=~/local | |
make install # ok, fine, this step probably takes more than 30 seconds... | |
curl https://www.npmjs.org/install.sh | sh |
The whole install procedure is like the following.
You would have to do 7 steps.
- Download the latest tar file, and expand it.
- Move it to /usr/local/, and make a symbolic link to the folder.
- Add path to MongoDB binaries.
- Make an user that "mongod" runs on, and group that owns the user.
Requires:
-
Homebrew (http://mxcl.github.io/homebrew/)
-
Ruby
Verify Homebrew is not sick:
brew doctor
This file contains 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
// suggested shell cmd line to run this: | |
// | |
// mongo --shell example2.js | |
// | |
// Note: the { out : … } parameter is for mongodb 1.8+ | |
db.things.insert( { _id : 1, tags : ['dog', 'cat'] } ); | |
db.things.insert( { _id : 2, tags : ['cat'] } ); | |
db.things.insert( { _id : 3, tags : ['mouse', 'cat', 'dog'] } ); | |
db.things.insert( { _id : 4, tags : [] } ); |
NewerOlder