This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-11-28
Channels
- # admin-announcements (1)
- # aleph (3)
- # bangalore-clj (4)
- # beginners (167)
- # boot (14)
- # cider (4)
- # cljs-dev (24)
- # cljsjs (21)
- # cljsrn (33)
- # clojure (214)
- # clojure-greece (2)
- # clojure-italy (2)
- # clojure-korea (16)
- # clojure-russia (29)
- # clojure-spec (31)
- # clojure-uk (86)
- # clojurescript (144)
- # core-matrix (2)
- # cursive (37)
- # datascript (5)
- # datomic (104)
- # devcards (2)
- # events (2)
- # jobs (2)
- # luminus (8)
- # midje (1)
- # nyc (4)
- # off-topic (1)
- # om (39)
- # om-next (1)
- # onyx (47)
- # perun (1)
- # planck (6)
- # proton (2)
- # re-frame (25)
- # reagent (40)
- # spacemacs (9)
- # vim (71)
- # yada (3)
What does (.. )
mean?
used like this:
(.. (getChannel (str "/topic/" channel-name))
+ (subscribe (proxy [ClientSessionChannel$MessageListener] []
+ (onMessage [channel message]
+ (do
+ (println "[[Receieved Message]]" message)
+ (on-message [channel message])))))))
no, ..
is a macro that applies a series of Java method calls to an object
so the getChannel
expression returns an object and then the subscribe
method is invoked on it
Hey gang, what are my options for passing environment variables to clojurescript? I’m currently using levand/immuconf which is fantastic but I’m pretty stumped on using this on the frontend. I use hiccup to generate my index page - can I somehow pass this info through that?
the environment variables would be things like hostname and port so this is not an option
@chooie: if they're set at compile-time you could always take whatever you're using to get them in clj and just send it to cljs in a macro. The general technique demonstrated here (w/ json data and hiccup generated from templates, but easily adapted to environment variables): https://github.com/paultopia/jsonmacrodemo
@gowder it’s a good suggestion but the use of calling immuconf/load doesn’t seem to play well with immuconf’s reader literals:
java.lang.RuntimeException: No reader function for tag immuconf/override
.
I’ll have to do some more research into how those literals work.
Additionally, a minor gripe is that the macro namespace would have to be recompiled every time a change was made to the config file (admittedly this wouldn’t happen often).
Any suggestions for Clojure projects that have issues that could be looked at by someone relatively new to that project ? I'm looking to do as much as I can for Clojure projects in December for http://24pullrequests.com/
That’s a great site and you can enable the ‘beginner friendly’ search flag to find easier projects to contribute to.
Someone who can help me with this challenge from4clojure :
(= [1 2 [3 4 5] [1 2 3 4 5]] (let [[a b & c :as d] __] [a b c d]))
IM thinking of : [a b [c] [d]]
but then I see this error message :
Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0)
if you are asking about what should go instead of __
then it should be [1 2 3 4 5]
. which after destructuring and binding will give
a=1, b=2, c=[1 2 3] and d=[1 2 3 4 5]
oke, then I make there my thinking error. I already figured out that a = 1 , b = 2 , c = [1.2.3] and d = [,2,3,4,5]
I have to solve this challenge : (= false (__ false false))
. So I made this : (fn [& x] (not-any? x ))
but now I see this error message on 4clojure : Wrong number of args (1) passed to: core$some
I think it needs a function so I change it to (fn [ & x] (not-any? true? x))
but now this error message : 'clojure.lang.Cons cannot be cast to clojure.lang.IFn `
i don’t know, because it works for me except logic is wrong. but i think you better use and
instead of your own function
i'm pretty sure you've moved beyond needing to do challenges and need to just make some software
@roelofw You can also find solutions all over github, in case you're interested in seeing some options
@dpsutton I like to write some financial app which can grow to a some sort of accounting app
I could begin with one account and try to make it work that you could deposit and withdraw money from it
my one piece of advice would be to build something you actually want and need to use
I want to use it because there is no free accounting system which I can use for my volunatry work as a financial person for a toy library
that is a very small "company" which has no money for a accounting system which is also suitable for persons which are not used and have no knowlegde about accounting
second step : add second account and try to withdraw on one account and deposit on the other
maybe another idea is to look if I can rewrite a rails app I have made which reads and displays data from painting from the "Rijksmuseum" in Amsterdam
so your time is spent actually doing productive things but focusing on how to to it clojure-y
Then I have to figure out how to read from a api and process some json data that I want to display
I can do it on two ways . read first all the paintings ( some 4700) or read it 10 at the time
@dpsutton is this a good tutorial for the reading part : http://nerd.kelseyinnis.com/blog/2014/04/22/how-to-make-an-http-call-in-clojure-when-you-dont-know-anything/
Can anyone make sense of this ArityException I’m getting? https://gist.github.com/sooheon/5cba1df56336d9b7e0b9c779a1f8cab9 I’m taking a 2D vector of maps, where the maps represent points on a graph like {:x 1 :y 2}
, and I’m trying to convert this to a single map where everything is keyed by a vector of coordinates, like [0 1]
. As you can see, when I call the same code without defining it as a function it works just fine.
Wow, now that I paste that in I see my mistake. I’m overwriting the definition of the map
function with my stupid function variable name… thanks for helping by merely existing, guys :p
How can I download en use cli-http in repl. I did (require cli-http as client) but then clj-http cannot be found ?
It needs to be in your project.clj
or build.boot
dependencies.
Or, if you’re using Boot, you can just specify it on the command line: boot -d clj-http repl
(I know, we’ve had this discussion 🙂 )
That is one of the nice things about Boot when you’re just experimenting with libraries, you can start a REPL anywhere with all the dependencies you need, without needing to create a project first 🙂
I did the same in rails earlier this year and there I had to wait till I saw the data
Next on my list. Take all the principalOrFirstMaker and the longTitle out for every painting.
Stupid beginners question. How can I store the contents of cli-http in a variable in repl?
create a debug atom, and in your code you can reset! the atom with the thing you want to mess with
why here a object as output :
(ns proefopdracht.core
(require [clj-http.client :as client])
(require [cheshire.core :refer :all]))
(defn read_numbers
"Reads the ids of the paintings"
[]
(-> (client/get "")
:body
parse-string
(get "artObjects")
(->> (map #(get % "id")))))
(println read_numbers )
just tried in the repl
repl
proefopdracht.core=> (read_numbers)
("nl-SK-A-1718" "nl-SK-A-2963" "nl-SK-C-2" "nl-SK-C-149" "nl-SK-A-3841" "nl-SK-C-1368" "nl-SK-A-1115" "nl-SK-C-216" "nl-SK-C-211" "nl-SK-A-799")
Tomorrow work on the second part. With the numbers I can ask for more data on the external api
@roelofw You can tell clj-http to parse the result from JSON to Clojure data structures automatically so you don’t need parse-string
(client/get “the URL” {:as :json})
I believe… would have to check the docs...
@seancorfield oke, I have to look that up on the readme
I think you mean : {:accept :json}) @seancorfield
nope, when I do :
defn read_numbers
"Reads the ids of the paintings"
[]
(-> (client/get "" {:accept :json})
:body
(get "artObjects")
(->> (map #(get % "id")))))
and when I do this :
(defn read_numbers
"Reads the ids of the paintings"
[]
(-> (client/get ""{:as :clojure})
:body
(get "artObjects")
(->> (map #(get % "id")))))
(println (read_numbers))
I see this error : xception in thread "main" java.lang.RuntimeException: Invalid token: :, compiling:(C:\Users\rwobb\Desktop\clojure\proefopdracht\src\proefopdracht\core.clj:15:1)
If I do a print after :body I see this as output :
{:elapsedMilliseconds 74, :count 4736, :artObjects [{:principalOrFirstMaker Piero di Cosimo, :webImage {:guid e68b810a-1d70-49e0-a210-5eb7b28a38aa,
on this code :
defn read_numbers
"Reads the ids of the paintings"
[]
(-> (client/get ""{:as :json})
:body
:artObjects)
(->> (map :id)))
(println (read_numbers))
Everyone thanks, tomorrow time to try to download more data with the help of the numbers I got now
I need then to use two different urls which used the numbers . I hope I can make it work async somehow
but if you're going to double thread, inverting the flow reads a slight bit better to me:
(defn read_numbers
[]
(->> (-> (client/get "" {:as :json})
:body
:artObjects)
(map :id)))
;; better
(defn read_numbers
[]
(let [art-objects (-> (client/get "" {:as :json})
:body
:artObjects)]
(map :id art-objects)))
Given that you can use either ->
or ->>
with the keywords to navigate the structure I’d do
(->> (client/get “…” {:as :json})
:body
:artObjects
(map :id))
-> threads the given argument through the "primary position" (the second argument) in each of the forms ->> threads the given argument through the last position in each of the forms
things like assoc
dissoc
take the primary argument in second position (assoc the-map ...)