To select specific Java (JDK) to use for leiningen, set environment variable JAVA_CMD
For example,
JAVA_CMD=/path/to/bin/java lein repl
Credit: https://gist.github.com/camsaul/c982019fd915510677236cd4b720a583#gistcomment-3439527
To select specific Java (JDK) to use for leiningen, set environment variable JAVA_CMD
For example,
JAVA_CMD=/path/to/bin/java lein repl
Credit: https://gist.github.com/camsaul/c982019fd915510677236cd4b720a583#gistcomment-3439527
#error {:cause clojure.core$seq_QMARK___5848:via[{:type clojure.lang.Compiler$CompilerException:message java.lang.NoClassDefFoundError: clojure/core$seq_QMARK___5848, compiling:(clj_gatling/report.clj:1:1):at [clojure.lang.Compiler load Compiler.java 7415]}{:type java.lang.NoClassDefFoundError:message clojure/core$seq_QMARK___5848:at [clojure.core.cache$lru_cache_factory invokeStatic cache.clj 581]}{:type java.lang.ClassNotFoundException:message clojure.core$seq_QMARK___5848:at [java.net.URLClassLoader findClass URLClassLoader.java 381]}]:trace[[java.net.URLClassLoader findClass URLClassLoader.java 381][java.lang.ClassLoader loadClass ClassLoader.java 424][sun.misc.Launcher$AppClassLoader loadClass Launcher.java 331][java.lang.ClassLoader loadClass ClassLoader.java 357][clojure.core.cache$lru_cache_factory invokeStatic cache.clj 581][clojure.core.memoize$lru$fn__2765 invoke memoize.clj 334][clojure.lang.AFn applyToHelper AFn.java 160][clojure.lang.AFn applyTo AFn.java 144][clojure.core$apply invokeStatic core.clj 659][clojure.core.memoize$build_memoizer invokeStatic memoize.clj 152][clojure.core.memoize$lru invokeStatic memoize.clj 332][clojure.core.memoize$lru invoke memoize.clj 292][clojure.core.memoize$lru invokeStatic memoize.clj 328][clojure.core.memoize$lru invoke memoize.clj 292][clojure.tools.analyzer.jvm.utils__init load nil 79][clojure.tools.analyzer.jvm.utils__initnil -1] [java.lang.Class forName0 Class.java -2][java.lang.Class forName Class.java 348][clojure.lang.RT classForName RT.java 2183][clojure.lang.RT classForName RT.java 2192][clojure.lang.RT loadClassForName RT.java 2211][clojure.lang.RT load RT.java 445][clojure.lang.RT load RT.java 421][clojure.core$load$fn__7645 invoke core.clj 6008][clojure.core$load invokeStatic core.clj 6007][clojure.core$load doInvoke core.clj 5991][clojure.lang.RestFn invoke RestFn.java 408][clojure.core$load_one invokeStatic core.clj 5812][clojure.core$load_one invoke core.clj 5807][clojure.core$load_lib$fn__7590 invoke core.clj 5852][clojure.core$load_lib invokeStatic core.clj 5851][clojure.core$load_lib doInvoke core.clj 5832][clojure.lang.RestFn applyTo RestFn.java 142][clojure.core$apply invokeStatic core.clj 659][clojure.core$load_libs invokeStatic core.clj 5889][clojure.core$load_libs doInvoke core.clj 5873][clojure.lang.RestFn applyTo RestFn.java 137][clojure.core$apply invokeStatic core.clj 659][clojure.core$require invokeStatic core.clj 5911][clojure.tools.analyzer.jvm$loading__7118__auto____2196 invoke jvm.clj 9][clojure.tools.analyzer.jvm__init load nil 9][clojure.tools.analyzer.jvm__initnil -1] [java.lang.Class forName0 Class.java -2][java.lang.Class forName Class.java 348][clojure.lang.RT classForName RT.java 2183][clojure.lang.RT classForName RT.java 2192][clojure.lang.RT loadClassForName RT.java 2211][clojure.lang.RT load RT.java 445][clojure.lang.RT load RT.java 421][clojure.core$load$fn__7645 invoke core.clj 6008][clojure.core$load invokeStatic core.clj 6007][clojure.core$load doInvoke core.clj 5991][clojure.lang.RestFn invoke RestFn.java 408][clojure.core$load_one invokeStatic core.clj 5812][clojure.core$load_one invoke core.clj 5807][clojure.core$load_lib$fn__7590 invoke core.clj 5852][clojure.core$load_lib invokeStatic core.clj 5851][clojure.core$load_lib doInvoke core.clj 5832][clojure.lang.RestFn applyTo RestFn.java 142][clojure.core$apply invokeStatic core.clj 659][clojure.core$load_libs invokeStatic core.clj 5889][clojure.core$load_libs doInvoke core.clj 5873][clojure.lang.RestFn applyTo RestFn.java 137][clojure.core$apply invokeStatic core.clj 659][clojure.core$require invokeStatic core.clj 5911][clojure.core.async.impl.ioc_macros$loading__7118__auto____1596 invoke ioc_macros.clj 12][clojure.core.async.impl.ioc_macros__init load nil 12][clojure.core.async.impl.ioc_macros__initnil -1] [java.lang.Class forName0 Class.java -2][java.lang.Class forName Class.java 348][clojure.lang.RT classForName RT.java 2183][clojure.lang.RT classForName RT.java 2192][clojure.lang.RT loadClassForName RT.java 2211][clojure.lang.RT load RT.java 445][clojure.lang.RT load RT.java 421][clojure.core$load$fn__7645 invoke core.clj 6008][clojure.core$load invokeStatic core.clj 6007][clojure.core$load doInvoke core.clj 5991][clojure.lang.RestFn invoke RestFn.java 408][clojure.core$load_one invokeStatic core.clj 5812][clojure.core$load_one invoke core.clj 5807][clojure.core$load_lib$fn__7590 invoke core.clj 5852][clojure.core$load_lib invokeStatic core.clj 5851][clojure.core$load_lib doInvoke core.clj 5832][clojure.lang.RestFn applyTo RestFn.java 142][clojure.core$apply invokeStatic core.clj 659][clojure.core$load_libs invokeStatic core.clj 5889][clojure.core$load_libs doInvoke core.clj 5873][clojure.lang.RestFn applyTo RestFn.java 137][clojure.core$apply invokeStatic core.clj 659][clojure.core$require invokeStatic core.clj 5911][clojure.core.async$loading__7118__auto____1152 invoke async.clj 9][clojure.core.async__init load nil 9][clojure.core.async__initnil -1] [java.lang.Class forName0 Class.java -2][java.lang.Class forName Class.java 348][clojure.lang.RT classForName RT.java 2183][clojure.lang.RT classForName RT.java 2192][clojure.lang.RT loadClassForName RT.java 2211][clojure.lang.RT load RT.java 445][clojure.lang.RT load RT.java 421][clojure.core$load$fn__7645 invoke core.clj 6008][clojure.core$load invokeStatic core.clj 6007][clojure.core$load doInvoke core.clj 5991][clojure.lang.RestFn invoke RestFn.java 408][clojure.core$load_one invokeStatic core.clj 5812][clojure.core$load_one invoke core.clj 5807][clojure.core$load_lib$fn__7590 invoke core.clj 5852][clojure.core$load_lib invokeStatic core.clj 5851][clojure.core$load_lib doInvoke core.clj 5832][clojure.lang.RestFn applyTo RestFn.java 142][clojure.core$apply invokeStatic core.clj 659][clojure.core$load_libs invokeStatic core.clj 5889][clojure.core$load_libs doInvoke core.clj 5873][clojure.lang.RestFn applyTo RestFn.java 137][clojure.core$apply invokeStatic core.clj 659][clojure.core$require invokeStatic core.clj 5911][clojure.core$require doInvoke core.clj 5911][clojure.lang.RestFn invoke RestFn.java 436][clj_gatling.report$eval47$loading__7531__auto____48 invoke report.clj 1][clj_gatling.report$eval47 invokeStatic report.clj 1][clj_gatling.report$eval47 invoke report.clj 1][clojure.lang.Compiler eval Compiler.java 6951][clojure.lang.Compiler eval Compiler.java 6940][clojure.lang.Compiler load Compiler.java 7403][clojure.lang.RT loadResourceScript RT.java 374][clojure.lang.RT loadResourceScript RT.java 365][clojure.lang.RT load RT.java 455][clojure.lang.RT load RT.java 421][clojure.core$load$fn__7645 invoke core.clj 6008][clojure.core$load invokeStatic core.clj 6007][clojure.core$load doInvoke core.clj 5991][clojure.lang.RestFn invoke RestFn.java 408][clojure.core$load_one invokeStatic core.clj 5812][clojure.core$load_one invoke core.clj 5807][clojure.core$load_lib$fn__7590 invoke core.clj 5852][clojure.core$load_lib invokeStatic core.clj 5851][clojure.core$load_lib doInvoke core.clj 5832][clojure.lang.RestFn applyTo RestFn.java 142][clojure.core$apply invokeStatic core.clj 659][clojure.core$load_libs invokeStatic core.clj 5889][clojure.core$load_libs doInvoke core.clj 5873][clojure.lang.RestFn applyTo RestFn.java 137][clojure.core$apply invokeStatic core.clj 659][clojure.core$require invokeStatic core.clj 5911][clojure.core$require doInvoke core.clj 5911][clojure.lang.RestFn invoke RestFn.java 457][clj_gatling.core$eval30$loading__7531__auto____31 invoke core.clj 1][clj_gatling.core$eval30 invokeStatic core.clj 1][clj_gatling.core$eval30 invoke core.clj 1][clojure.lang.Compiler eval Compiler.java 6951][clojure.lang.Compiler eval Compiler.java 6940][clojure.lang.Compiler load Compiler.java 7403][clojure.lang.RT loadResourceScript RT.java 374][clojure.lang.RT loadResourceScript RT.java 365][clojure.lang.RT load RT.java 455][clojure.lang.RT load RT.java 421][clojure.core$load$fn__7645 invoke core.clj 6008][clojure.core$load invokeStatic core.clj 6007][clojure.core$load doInvoke core.clj 5991][clojure.lang.RestFn invoke RestFn.java 408][clojure.core$load_one invokeStatic core.clj 5812][clojure.core$load_one invoke core.clj 5807][clojure.core$load_lib$fn__7590 invoke core.clj 5852][clojure.core$load_lib invokeStatic core.clj 5851][clojure.core$load_lib doInvoke core.clj 5832][clojure.lang.RestFn applyTo RestFn.java 142][clojure.core$apply invokeStatic core.clj 659][clojure.core$load_libs invokeStatic core.clj 5889][clojure.core$load_libs doInvoke core.clj 5873][clojure.lang.RestFn applyTo RestFn.java 137][clojure.core$apply invokeStatic core.clj 659][clojure.core$require invokeStatic core.clj 5911][clojure.core$require doInvoke core.clj 5911][clojure.lang.RestFn invoke RestFn.java 551][army.core$eval24$loading__7531__auto____25 invoke core.clj 1][army.core$eval24 invokeStatic core.clj 1][army.core$eval24 invoke core.clj 1][clojure.lang.Compiler eval Compiler.java 6951][clojure.lang.Compiler eval Compiler.java 6940][clojure.lang.Compiler load Compiler.java 7403][clojure.lang.RT loadResourceScript RT.java 374][clojure.lang.RT loadResourceScript RT.java 365][clojure.lang.RT load RT.java 455][clojure.lang.RT load RT.java 421][clojure.core$load$fn__7645 invoke core.clj 6008][clojure.core$load invokeStatic core.clj 6007][clojure.core$load doInvoke core.clj 5991][clojure.lang.RestFn invoke RestFn.java 408][clojure.core$load_one invokeStatic core.clj 5812][clojure.core$load_one invoke core.clj 5807][clojure.core$load_lib$fn__7590 invoke core.clj 5852][clojure.core$load_lib invokeStatic core.clj 5851][clojure.core$load_lib doInvoke core.clj 5832][clojure.lang.RestFn applyTo RestFn.java 142][clojure.core$apply invokeStatic core.clj 659][clojure.core$load_libs invokeStatic core.clj 5889][clojure.core$load_libs doInvoke core.clj 5873][clojure.lang.RestFn applyTo RestFn.java 137][clojure.core$apply invokeStatic core.clj 659][clojure.core$require invokeStatic core.clj 5911][clojure.core$require doInvoke core.clj 5911][clojure.lang.RestFn invoke RestFn.java 408][user$eval15 invokeStatic form-init7134710474813340838.clj 1][user$eval15 invoke form-init7134710474813340838.clj 1][clojure.lang.Compiler eval Compiler.java 6951][clojure.lang.Compiler eval Compiler.java 6940][clojure.lang.Compiler eval Compiler.java 6940][clojure.lang.Compiler load Compiler.java 7403][clojure.lang.Compiler loadFile Compiler.java 7341][clojure.main$load_script invokeStatic main.clj 276][clojure.main$init_opt invokeStatic main.clj 278][clojure.main$init_opt invoke main.clj 278][clojure.main$initialize invokeStatic main.clj 309][clojure.main$null_opt invokeStatic main.clj 343][clojure.main$null_opt invoke main.clj 340][clojure.main$main invokeStatic main.clj 422][clojure.main$main doInvoke main.clj 385][clojure.lang.RestFn applyTo RestFn.java 137][clojure.lang.Var applyTo Var.java 700][clojure.main main main.java 37]]}
I came from Smalltalk, and I segued to Java a little bit, hated every minute of it, and then fell saved by Ruby. And so I have spent the last 20 some years writing code in languages that had enormous faith in my ability to do the right thing. And along with that enormous faith in my ability to do the right thing, they gave me the freedom of everything....
You just trust people. And he said they are not trustworthy. And I said well, they shouldn't write Ruby, they should write Java. I really prefer languages that allow me to shoot myself in the foot if I do but give me the power to do that.-----
If you have many test namespaces it's idiomatic to create a test runner namespace which imports all of your test namespaces and then invokes run-testsI personally couldn't get it to work. Though I have managed to make run-all-tests works. This is an example
(ns myns.test.runner (:require [cljs.test :refer-macros [run-all-tests]] [myns.test.ns1] [myns.test.ns2])) (run-all-tests #"myns.test.*")
Error: Expected number or lookup ref for entity id, got ....This happens because you didn't specify schema for that data attribute. Schema is optional on DataScript but it is required in this case. Add this line to your database, the issue should be fixed
{:your-attribute1 {:db/valueType :db.type/ref} :your-attribute2 {:db/valueType :db.type/ref}}
What's clojure equivalent of ruby's `caller` method? http://ruby-doc.org/core-2.2.3/Kernel.html#method-i-caller
To put it another way, if a function is call from multiple places, at runtime, is there a way to print out caller for debugging purpose?Thanks to Alex Miller. He answered
the Thread class has methods to inspect the stack
(Thread/dumpStack) will just dump that thread's stack to stderr
or (Thread/getStackTrace) gives you an array of StackTraceElement's that you can traverse and do whateverBasically, we can just use Java's Thread class. To be more precise, getStackTrace is an instance method so we have to call it this way.
(.getStackTrace (Thread/currentThread))We'll get back Java's array of StackTraceElement class.
(print (str (char 27) "[2J")) ; clear screenCredit: http://codereview.stackexchange.com/questions/17603/critique-my-clojure-game-of-life-code
(print (str (char 27) "[;H")) ; move cursor to the top left corner of the screen
$ lein with-profile test repl
Warning: no nREPL dependency detected.
Be sure to include org.clojure/tools.nrepl in :dependencies of your profile.
...
Error loading clojure.tools.nrepl.server: Could not locate clojure/tools/nrepl/server__init.class or clojure/tools/nrepl/server.clj on classpath:
Error loading complete.core: Could not locate complete/core__init.class or complete/core.clj on classpath:
Exception in thread "main" java.lang.ClassNotFoundException: clojure.tools.nrepl.server, compiling:(/private/var/folders/7d/98yf91rn0yz6wbh56h5q7rkh0000gn/T/form-init2792809345387087761.clj:1:1340)The reason is because unlike default profile, tools.nrepl isn't added as dependency for test profile. You can verify this by comparing the output between lein pprint (or lein with-profile default pprint) and lein with-profile test pprint.
$ lein with-profile default,test replWith the command above, lein should start the repl without any errors.
(def f (future (while true (your-function ... ))))
(future-cancel f)All you have to do as describe in this SO comment is to replace true with (not (Thread/interrupted)). Example:
(future (while (not (Thread/interrupted)) (your-function ... )))Because future-cancel will send interrupt signal to the future, Thread/interrupted will be changed to true. Now your future-cancel should work as expected.
(run-tests)and evaluate source code normally (cmd+shift+enter). See the output in the console.
=> (interleave [:a :b :c] [1 2 3])
(:a 1 :b 2 :c 3)After I solve this quiz with a long solution, I looked at the other people solution. One of the solution that impressed me somewhat similar to this
=> (apply concat (map vector [:a :b :c] [1 2 3]))
(:a 1 :b 2 :c 3)If we run only evaluate Map part, the result looks like this
=> (map vector [:a :b :c] [1 2 3])
([:a 1] [:b 2] [:c 3])I had hard time to understand that. I got a question in my head. "Of what reason, why Map function take element of 2 vector (3th, 4th parameters) one by one?" It turns out that this is a Clojure Map function behavior.
=> [1, 2, 3].map { |i| i + 1 }
[2, 3, 4]But for Clojure's Map function, it takes variable arguments and behave like what I explained earlier.
=> (map inc [1 2 3])
(2 3 4)
=> (map + [1 2 3] [4 5 6])
(5 7 9)Another question I had was "Can we archive the same variable arguments behavior with Object-Oriented style?"
map(->x,y{ x+y }, [1,2,3], [4,5,6])This examples might look trivial but if we look at it carefully it represents fundamental differences between OO languages and functional languages. For OO language, our method call is a mechanism of passing message to an object. But for functional language, it's just a function call.
I couldn't find this link when searching with google https://www.collectd.org/documentation/manpages/collectd.conf.html#plugin-postgresq...