This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-07-20
Channels
- # announcements (1)
- # asami (19)
- # beginners (6)
- # biff (1)
- # cljs-dev (3)
- # clojure (27)
- # clojure-europe (7)
- # clojure-gamedev (4)
- # clojure-hungary (47)
- # clojure-nl (5)
- # clojure-norway (29)
- # clojure-uk (5)
- # clojurescript (23)
- # data-science (1)
- # emacs (36)
- # events (3)
- # fulcro (22)
- # graphql (1)
- # gratitude (1)
- # introduce-yourself (3)
- # lsp (5)
- # nbb (7)
- # off-topic (68)
- # other-languages (2)
- # pathom (5)
- # reagent (4)
- # reitit (10)
- # remote-jobs (2)
- # reveal (2)
- # ring (1)
- # shadow-cljs (46)
- # spacemacs (15)
- # tools-deps (4)
Cloistered JVM dev here: On the non-JVM hosts of Clojure, are there concepts parallel to system properties? Is there a platform-agnostic alternative to
EDIT: Fell prey to the X Y problem. What I really want to know is: Is there a runtime-agnostic way to get the name of the logged in (OS) user?System/getProperty
?
Maybe I should specify further that I'm fetching "user.name"
.
On a UNIX system the USER env var will probably contain the name of the user the process is running as.
I think, given a dilemma between them, I'll prefer OS-agnostic over runtime-agnostic
Hi folks. I'm trying to include an external jar dependency via lein uberjar, so I can run with java -jar, and it does not seem to work despite it working fine with lein repl. Am including via:
:resource-paths ["resources/openrq-3.3.2.jar"]
Compilation proceeds fine.
❯ unzip -l standalone.jar|grep openrq
283205 2021-12-08 06:32 openrq-3.3.2.jar
However, when running with java -jar standalone.jar I receive a stacktrace, with:
Caused by: java.lang.ClassNotFoundException: net.fec.openrq.OpenRQ
Any ideas of what I'm doing wrong?you're putting a jar in a jar, shouldn't you be adding the content of the jar (the class files) ?
I don't know. I just type lein uberjar. Works fine with repl as I said, do I need special configuration beyond what I already have above?
With resource-paths it's plenty to work with at repl, just wondered what else I need. Googling starts talking about local maven repositories and other such magic but I suspect there must be a simpler path.
i can think of 2 ways to do it: using a local maven repo or copying the content of the jar in the uberjar (there may be some files to skip)
i don't think there is a simpler path, but maybe some lein plugins already exist for that
Adding the jar contents manually worked. Thanks! I'll see if I can find some way to automate it. Proper deps.edn knowledge still on my todo-list (my legacy projects are all still lein)
apparently I misunderstand refs and STM. I have two streams of key/value records that are being processed by separate threads, and each thread has a simple cache (ref {})
associated with it. if a thread reads a record that isn't in the other thread's cache, it stores the key/value pair in its cache and returns []
. if the key is found in the other thread's cache, that entry is removed and [v v2]
is returned, where v
is this thread's value and v2
is the value from the other cache. (the idea is to process two potentially unordered streams in parallel to determine where they match/don't match.) the test code I hacked up is, as usually happens when writing async code, inconsistent: sometimes one thread returns both values, other times a value ends up in one cache. here's the code:
(let [k :k
v "value"]
(defn check
[cache k v other-cache]
(dosync
(if (contains? @other-cache k)
(let [v2 (get @other-cache k)]
(alter other-cache dissoc k)
[v v2])
(do
(alter cache assoc k v)
[]))))
(let [cache1 (ref {})
ch1 (chan)
cache2 (ref {})
ch2 (chan)]
(go (>! ch1 (check cache1 k v cache2)))
(go (>! ch2 (check cache2 k v cache1)))
{:cache1 @cache1 :result1 (<!! ch1) :cache2 @cache2 :result2 (<!! ch2)}))
since both threads are processing the same key/value, this hack should consistently return cache1 and cache2 empty and either result1 or result2 should be ["value" "value"]
.... but that's not happening. any ideas on what I'm borking up?checking that ...
I don't use the stm much, but if I recall deref in a transaction is stable, in that multiple derefs of the same ref in a transaction will always return the in transaction value of the ref, but at the point the transaction commits, a deref that would have gotten a different value at that point in time will not cause the transaction to retry
https://github.com/fmi/clojure-examples/blob/master/2013/07-concurrency/04-write-skew.clj nope write skew
I suspected there might be something up with the STM machinery not correctly recognizing the @cache
read or something similar.
I thought about atoms, but stm/refs seemed like a better fit with two threads banging on two separate data structures. if ensure
works, then all is cool, otherwise atoms are an option -- this isn't long-term production code, just a hack to monitor streams during system migration to a new data center. thanks --