This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-11
Channels
- # beginners (132)
- # boot (2)
- # cider (17)
- # cljs-dev (6)
- # cljsrn (24)
- # clojure (134)
- # clojure-austin (2)
- # clojure-dusseldorf (11)
- # clojure-france (1)
- # clojure-greece (27)
- # clojure-italy (17)
- # clojure-madison (1)
- # clojure-russia (31)
- # clojure-serbia (1)
- # clojure-sg (2)
- # clojure-spec (30)
- # clojure-uk (66)
- # clojurescript (73)
- # core-async (2)
- # cursive (8)
- # data-science (2)
- # datomic (23)
- # dirac (8)
- # emacs (18)
- # gsoc (1)
- # hoplon (36)
- # immutant (26)
- # leiningen (6)
- # off-topic (21)
- # om (19)
- # onyx (6)
- # other-languages (1)
- # pedestal (3)
- # proton (2)
- # random (1)
- # re-frame (1)
- # reagent (2)
- # remote-jobs (2)
- # ring-swagger (8)
- # rum (21)
- # slack-help (1)
- # spacemacs (4)
- # specter (16)
- # untangled (6)
@steveb8n fwiw this does exist (but definitely inconvenient) https://www.google.com/search?q=site%3Aclojurians-log.clojureverse.org+data+macros&oq=site%3Aclojurians-log.clojureverse.org+data+macros&aqs=chrome..69i57j69i58.1046j0j9&sourceid=chrome&ie=UTF-8 (fixed link)
@noisesmith thanks. it seems like groups is still best for long term threads. not ideal either but I’m more concerned with the content c.f. the host 🙂
if it were up to me we'd all have stayed on IRC, I'm here because other people went here
someone should write a slack alternative in clj/cljs, then write a book called "intro web programming full stack" on the design/impl;
Is there a more elegant way to do the following?
(defn apply-sequentially
"For fns = [f g h ...], return [x (f x) (g (f x)) (h (g (f x))) ...]"
[fns x]
(loop [fns fns
vs [x]]
(if (empty? fns)
vs
(recur (rest fns)
(conj vs ((first fns) (last vs)))))))
Maybe something like:
(defn sequential-applications [x fns]
(reductions #(%2 %1) x fns))
hi guys, in clojure how do we pprint
without ,
and everything must be in newline ?
(clojure.pprint/pprint {:a :b :c :d})
{:a :b, :c :d} ;; results
{:a :b
:c :d} ;; I want this
@U0CT59540 maybe check the dynamic vars in https://clojure.github.io/clojure/clojure.pprint-api.html
@U0WL6FA77 that doesn't work, it prints the map in vectors @U06GS6P1N I haven't messed with this one yet. But it seems to be the right way.
doesn't seem to solve the comma problem though
if every collection has exactly one line per item, it may be viable to remove the commas using a regexp
e.g #",\n"
assuming pprint doen't issue multiline-strings (I don't think it does)
I think i will stick with vim replace for now. Will dig in this one later. thanks for collab everyone 🙂
hmm i think function like pr-str
but print in more human readable format will be really cool, please share if you find something
for example i use map to throw errors with data to debugging, reading it is uncomfortable
when using clojure.core.reducers/fold
, how would one usually go about choosing the chunk size n
?
Hi All, I am looking for some project ideas in Clojure/Clojurescript (intermediate-level). Any suggestions?
Perhaps build a webscraper using https://github.com/cgrand/enlive and then use cljs to present the scraped data in an aggregated and nicer way? Or a simple turn-based browser game using something like re-frame?
@jjl Thanks for replying. I will do that on the side. Actually, I am looking for a full fledged end-to-end clojure project. @curlyfry Thanks for the suggestions.Not really a big fan of web scraping and I have just finished making a turn-based game called 'Chain-Reaction' using figwheel and reagent. ----- Are there any small but useful missing modules/libraries in clojure that i can write?
Hello everyone. sorry for asking kind of silly question but I honestly couldn’t find actual example anywhere. How do I type-hint java arrays of objects?
@jetzajac try #^java.lang.String
I do see that this is missing from the interop page on http://clojure.org
@cpmcdaniel wow. It couldn’t be simpler 😃 thanx
I had to look it up myself, but it took some digging
@cpmcdaniel @jetzajac that's the older hinting syntax, and that is not an array hint. try:
^"[Ljava.lang.String;" collection
Does anyone here use Lighttable?
How can I assign the same keymap to two different commands under different conditions? (for example making f12
open the console if it is closed or close it if it is already open)
[
signifies array and Lclassname;
represents a class in the bytecode.
Regarding clojure typehints, the #^
syntax has been deprecated for a while. Just need ^
I am javac to compile a lein project manually. I am using clojure 1.9.16-alpha. Do you know why I would get this error during compilation of clojure.core.specs.alpha Unable to resolve symbol: qualified-keyword? in this context, compiling:(clojure/spec/gen/alpha.clj:131:4)
By manually, I mean, I am using lein-droid which calls javac.
hi guys, I have a question that's been bugging me... what would be the difference between a function composition and a transducer?
@vitruvia it sounds like you would need to write a behavior or command in your user plugin and then assign it to the user keymap for f12
@sbauer Thanks, looks a little advanced for me since I've never made any plugins... any suggestion for a place to start?
There is some documentation of varying levels of quality on making plugins in the [LT wiki](https://github.com/LightTable/LightTable/wiki) that should be a good place to start
If you do not have User plugin yet, you should be able to run the command Settings: Add User plugin to workspace
to get one set up
I'll read some of the tutorials and see what I can do with my current level of skill ^^
Depending on your specific needs, like toggling the console open or closed, it might be possible the command already exists in LT, in which case you could just modify your user keybinding file and not deal with the User plugin...
In this case the command does exist, but for example if I assign opening the console to f12 and then assign closing the console to f12, it will only do one of those
hmm, something like [:editor "f12" :toggle-console]
doesn't work? (assuming the editor has focus)
i created #lighttable so we can leave #clojure focused on clojure, if you have additional questons
I have a helper fn with signature: (defn helper [resource f] ...)
that handles resource management while running f
If f
throws an exception, I want to still handle closing the resource in a try
's finally
, but bubble up the original exception to the caller of helper
...
Is it good practice for the catch
in a try
block to just re throw the error? And will finally
still be called?
josh.freckleton: You don’t even need the catch form if you’re not doing something besides rethrowing the original exception without alteration
oh, like just a try
+ finally
, no catch
?
huh, that works
thanks
well there I have it 🙂
What’s a good way to make available a named value inside the body which you pass to a macro? Use a kind of binding syntax?
Probably the bad way:
(defmacro foo [& body] `(let [~'url ""] ~@body))
(foo (println url))
is not really clean I guessIt's fairly common for a macro to accept a binding form. Using an implicit binding form can be confusing.
user=> (defmacro foo [sym & body] `(let [~sym "foo"] ~@body))
#'user/foo
user=> (foo name-of-var (println name-of-var))
foo
I’m doing this for a macro I use in testing endpoints, didn’t want to pass the name url all the time, but for exposed macros I guess this is better
I saw something somewhere for that... but i'd have to recommend using clojure.core functions rather than some gross (though convenient) DSL like jq
Don't get me wrong, I use jq
regularly... but it can never beat using the language you already know.
No, I agree, but maybe it could be implemented as just a wrapper around the core
fns and a pretty printer
right, just like clojure can
I mean, even clojure.core can do this if you are willing to wait about 1 second startup time
it’s things like leiningen and nrepl that make it take longer, you don’t need those for edn
justin@S: ~$ time echo '(+ 1 1)' | java -jar ~/bin/clojure-1.9.0-alpha15.jar
Clojure 1.9.0-alpha15
user=> 2
user=>
real 0m1.425s
user 0m2.022s
sys 0m0.181s
@grav if it's useful: https://github.com/mfikes/planck/issues/371
So I guess it’s something like curl
@grav Command line tools are not really Clojure’s strength because of the JVM, but Lumo or Planck makes it great.
@mfikes What do you mean by “exposed via some stable public API meant for consumption”? How would the code example in the ticket look if it was like that?
(sorry, I started typing, then left and then finished what I was typing before reading all the responses)
@grav planck.pprint.data/pprint
wasn't really meant for external use when I wrote it, that's all
@grav One other option, that is really fast, but maybe not so mature yet: https://github.com/candid82/joker
justin@S: ~$ time cat ...secrets.../development.clj | java -jar ~/bin/clojure-1.9.0-alpha15.jar -e '(require '"'"'clojure.pprint '"'"'clojure.edn) (clojure.pprint/pprint (clojure.edn/read-string (slurp *in*)))'
{:logging {:loggers [{:type :stdout, :level :debug}]},
:app {:use-database true},
:database
{...secrets...}}
real 0m1.185s
user 0m2.149s
sys 0m0.139s
@grav Yes, I use the linter in Emacs. For that it’s really great, because of the responsiveness
so I demonstrate you can do it in under 3 seconds with clojure - but it’s obviously not being done optimally (you would probably want an actual clj file etc.)
is it a bad practice to use boot and lein together ? I want boot to act like rake
or make
for my tasks and not the actual build system
I wouldn't say it's super bad, but requiring less from your users is always preferable. (If you're migrating from one to the other, you'll almost certainly have an intermediate state where both are in play.) They both have their strengths and weaknesses
Alright, I see that's http://dev.clojure.org/jira/browse/CLJ-1459 , voted on it.
Say, is there any reason the predicate clojure.test/function?
is socked away in clojure.test instead of the main namespace? Is there a more idiomatic way for me to test whether a value is a function?
There’s also fn?
which returns false for maps and keywords
I find I want fn?
approx 0% of the time :)
Aha, I see there is already an fn?
predicate in clojure.core, I'll use that
Clojure 1.9.0-master-SNAPSHOT
user=> (defmulti foo identity)
#'user/foo
user=> (fn? foo)
false
user=>
sounds like you'd be surprised at the things that are "functional" that aren't created with fn
What is the best way to transfer files through clojure between two different processes running on different hosts?
I’d transfer data rather than files, if the difference matters at all
Maybe using some clojure libraries as well. But should happen as part of clojure code, so I can process that file once available.
sure, what I’m saying is that “file” is a specific place to put a sequence of bytes
and code that uses bytes generalizes better than code that uses files, the file part is trivial
So far I have got it working by creating a websocket to one of the process and receiving the file over that socket as data
OK - http://clojure.java.io has two functions, copy, and file
that will take care of the rest for you
just be sure not to use any of the text oriented io functions
Hello all, how can I convert this to clojure?
TrustManager[] trustAllCerts = { new X509TrustManager()
{
public X509Certificate[] getAcceptedIssuers()
{
return null;
}
public void checkClientTrusted(X509Certificate[] certs, String authType) {}
public void checkServerTrusted(X509Certificate[] certs, String authType) {}
} };
This didn´t work:
((X509TrustManager.)
(reify
(into-array X509Certificate) (getAcceptedIssuers [] nil)
(checkClientTrusted [certs authType])
(checkServerTrusted [certs authType])
))
If you want an anonymous instance implementing it, you can use:
(reify X509TrustManager
(getAcceptedIssuers [this]
nil)
(checkClientTrusted [this chain authType]
;; impl...
)
(checkServerTrusted [this chain authType]
;; do whatever...
))
@jjl Thanks for replying. I will do that on the side. Actually, I am looking for a full fledged end-to-end clojure project. @curlyfry Thanks for the suggestions.Not really a big fan of web scraping and I have just finished making a turn-based game called 'Chain-Reaction' using figwheel and reagent. ----- Are there any small but useful missing modules/libraries in clojure that i can write?