This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-02-03
Channels
- # aatree (5)
- # admin-announcements (52)
- # announcements (1)
- # aws (2)
- # beginners (55)
- # boot (494)
- # braid-chat (17)
- # cider (2)
- # cljsjs (4)
- # cljsrn (8)
- # clojure (157)
- # clojure-austin (6)
- # clojure-czech (7)
- # clojure-denmark (1)
- # clojure-dev (102)
- # clojure-ireland (6)
- # clojure-japan (4)
- # clojure-miami (2)
- # clojure-poland (90)
- # clojure-russia (415)
- # clojurebridge (2)
- # clojurescript (143)
- # core-async (1)
- # datavis (4)
- # datomic (20)
- # devcards (5)
- # dirac (40)
- # emacs (9)
- # events (103)
- # gorilla (1)
- # immutant (122)
- # jobs (3)
- # ldnclj (20)
- # lein-figwheel (1)
- # mount (2)
- # off-topic (22)
- # om (170)
- # onyx (7)
- # overtone (6)
- # parinfer (100)
- # proton (2)
- # re-frame (5)
- # reagent (32)
- # ring-swagger (2)
- # spacemacs (6)
@jonahbenton: it does work. the letfn macro lets you reference any of its bindings from any of the functions you define within it
@gabehollombe: excellent! there it is, right in the docs, intended for exactly that use case. very cool!
Yeah! I learned it yesterday 😃
Hiya! I am running into a problem while reading configurations via an edn file. I have created an atomic map in which all the configurations are inserted at the start of the application. This works fine if I load the configurations manually via repl. However when I run the entire application then the configuration is loaded later on, and the vars
dependent on these configuration are initialized first. I seem to be missing out on something very basic.
Sounds like laziness is biting you?
@udit could you show some code of how you're reading this configuration, and you're setting up these vars that depend on it?
If I do lein run
then I get the runtime exception that :bot-name
key was not found; the one which I am throwing in the get-config
function.
The dump of the config map along with the exception gives an empty map. So obviously the global-appconfig
map hasnt been initialized. Shouldn’t it be initialized first since it is the first function to be called in main?
I don't immediately see anything that's wrong. what's possible is that you're indirectly calling one of these functions at the top level, e.g. to define a var
in that case that will get executed immediately when Clojure "reads" that form, so even before it starts executing -main
in a way all Clojure code is executed immediately, but most of it will just set up functions to be called later
So the way forward for me would be: 1) Initialize the config at the time of definition of the global-appconfig
or 2) Change the defs
dependent upon this config map to be functions. Which one is the preferred approach?
you could even explicitly pass that config (or parts of it) into any function that needs it. Now you're setting it up as globally accessible state, which makes it easy to run into problems like these, because one part of your program is setting up that state, and another part reads it, and there's no connection between the two, so you the programmer are responsible for figuring out the timing to make that work
if you read the config and then start passing it into the functions that rely on it, then the connection is explicit and clojure will make sure the reading happens before the code that depends on it
of course that might mean a lot more work to pass that config around, so it might be a valid trade-off to do it the way you're doing it, it's just interesting to contrast those two approaches
need help in luminusweb
hey @samlinncon do you have a specific issue or problem? there also is a #C077KDE3A channel
i’ve got a vector of strings, and a vector of maps. the strings are an order that the maps need to be ordered in. how would i sort the vector of maps, by key, based on the order of the vector?
don’t want the answer spoon fed, just looking for a nudge in the right direction
is there a general consensus on if using clojure in place of shell scripts is good practice? experimenting has been fun but making system calls with clojure.java.shell/sh seems a little “hacky"
I haven't heard anything but I've considered using it.
I think the biggest problem is startup time
yeah. there is this: https://github.com/hugoduncan/clj-ssh
@chadhs: yeah, the sh
aspect can be a little hacky, especially if dealing with piping and other things you'd get from, say, Bash. But if you have any logic or data processing, I'd much rather be in Clojure (or ClojureScript).
yeah that’s what i’m running into right now, im doing all this stuff with sed
and found myself saying “man i wish i was in clojure right now” but then i found myself not being able to do the easy stuff i do in bash (due to ignorance / inexperience im sure) like just doing something to every file in a dir.
(with-sh-dir “/path/to/somewhere"
(doseq [file (rest (file-seq “/maybe/some/other/dir"))]
(sh “somecmd” “anarg" (:path file)))
@mfikes: yes i’ve recently discovered file-seq
as well, thanks for that snippet. the example here is returning an “object” rather than file names for me https://clojuredocs.org/clojure.core/file-seq
@mfikes: got this to work and just in time before having to run to pick up the kiddos 😛 thnx again
(def working-dir (io/file "/Users/chadhs/tmp/blocks/a"))
(def the-files (vec (map str (rest (file-seq working-dir)))))
(map #(shell/sh "ls" %) the-files)
I'm not sure it's too actively maintained anymore, but https://github.com/Raynes/conch has a lot of useful utils for stuff like this