This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-05
Channels
- # announcements (2)
- # beginners (44)
- # calva (7)
- # cider (8)
- # cljs-dev (2)
- # clojure (131)
- # clojure-serbia (2)
- # clojure-spec (3)
- # clojure-uk (56)
- # clojurescript (27)
- # cursive (7)
- # datomic (6)
- # fulcro (25)
- # jobs (3)
- # klipse (3)
- # leiningen (2)
- # off-topic (8)
- # overtone (2)
- # pathom (2)
- # portkey (2)
- # re-frame (2)
- # reagent (10)
- # shadow-cljs (44)
- # spacemacs (1)
- # tools-deps (6)
- # uncomplicate (2)
It’s not ring-dependent. Different web servers handle this differently, but most web servers will indeed handle requests with different threads.
In most cases, you don’t need to worry about it - but also never assume the same thread is going to be used for another user, so don’t store things in thread locals.
Hi 👋 , I love that the Clojure ecosystem is into combining libraries on a per-app basis—that's a skill I want to build. Can anyone recommend resources on application architecture? They don't need to be written in Clojure, I'm just looking for something that will help me get better at combining a set of libraries together to meet the needs of a given project. (I want to learn to do this myself, so I'm not after library suggestions.) Thanks!
@alexchalk17 i recommend taking a look at the source code for strong template projects like sente. what are you interested in building? if it is web i have recommendations, other things different people may be more savvy.
Luminus and duct might be good examples as well to study architecture not necessarily use
I was wondering.... I want to conj a map onto a vector of maps. But! I only want to conj a fresh map on if there is no map with 2 keys matching. However, if these 2 keys do in fact match, I want to just update the entry. Should I reduce-kv / keep-indexed on the vector of maps, filter it (?) on those two keys, and then if it exists / is not empty update the extant entry, and if it's not just conj? I want to have tweezers that let me update in the vector or append, but it seems like having a seek is inexorable.
Do you care about the relative order of the maps in your vector of maps at all?
If you do not, you could instead have a map of maps, where the values are the maps, and the keys are some values that contain the 2 keys that you want to be unique.
maybe i'm not communicating my need correctly. map of maps? o.o
e.g. a vector containing those 2 key values only, or a map containing those 2 values as values.
It is possible to have maps where the keys and/or values are themselves maps, or other kinds of immutable values.
immutable values can nest in arbitrary ways.
If I build a jar with command lein with-profile +single-node ring uberjar ... and then run the jar with command: java -jar target/uberjar/simple-server-1.0-standalone.jar ... everything works just fine - application finds the environmental variables defined in file profiles.clj: :single-node { :env { :ss-env "single-node" :my-env "dev" ... *BUT* if I bake the same jar into a Docker image and then start the application exactly the same way in a Docker container the app does not find the environmental variables defined in that profile. Really weird. I first thought I have done some stupid configuration error but I have checked this many times.
I was wondering what differences there are. I suddenly realized that the profiles.clj is not in the Docker image. I somehow assumed that it is baked into the jar somehow.
Yep. That's it. I just copied the app into another directory in my host - not working there either.
The lesson: Never assume anything. 🙂
... but I'm still puzzled how the app reads the profile env variables in the project directory but not in some other directory.
Ok. I think I got it. There is this .lein-env file (by Environ) that apparently gets generated when building the jar.
You do not have to do this, but if I understand your desired behavior correctly, it would be a very natural way to take advantage of the characteristics of maps, for keeping the maps unique on the 2 keys you want to keep them unique on.
Hmm.. so the key for each map is a combo term of the keys I want to demand uniqueness on?
Right.
And there are choices in that. The key you want uniqueness on could be itself a map, with only the 2 key/value pairs from the original map that you care about uniqueness for.
That's a cool idea. How do you suggest I compose these keys? It's like usernames and article IDs to enforce the fact that a user may only rate an article once (or update their rating to something new, but all in all, one rating per article per user)
i.e. you could construct that using select-keys
on the original map you want to put in the collection.
o.o select-keys
tell me more about that?
user=> (select-keys {:username "a" :article-id 17 :other-stuff "foo"} [:username :article-id])
{:username "a", :article-id 17}
You give it a map, and a sequence of key values, and it returns a map containing only those key/value pairs from the original that have a key from the sequence.
hmm.. i'm not sure how i would incorporate this into my current toolkit,
almost all my maps in the vector have the same keys
just different values for them
So you have many maps in your vector, and they all have different values for the user name and article id, as you wish?
If you had such a vector, you can create a map of maps from it, indexed by the "2 element maps" described above, like this:
First define a little helper function that creates the 'unique key' you want from your maps: (defn make-key [m] (select-keys m [:username :article-id]))
Then some code like this can create a map of maps:
(def vector-of-maps [{:username "a" :article-id 7 :other-stuff "foo"} {:username "b" :article-id 7 :other-stuff "bar"}])
does anyone know any ML companies / open source projects using clojure, elixir or FP in general ?
There are certainly folks doing ML stuff in Clojure lately. @U04VAD6RL has been writing a lot of interesting blog posts on the topic; her blog is at http://gigasquidsoftware.com This list of companies (& see linked success stories / community stories pages) is one place to start looking: https://clojure.org/community/companies