This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-09-26
Channels
- # arachne (4)
- # beginners (70)
- # bigdata (1)
- # boot (373)
- # braid-chat (3)
- # cider (4)
- # cljs-dev (10)
- # cljsjs (6)
- # cljsrn (27)
- # clojars (11)
- # clojure (114)
- # clojure-austria (1)
- # clojure-czech (2)
- # clojure-dusseldorf (2)
- # clojure-greece (7)
- # clojure-italy (2)
- # clojure-nl (6)
- # clojure-russia (15)
- # clojure-serbia (11)
- # clojure-spec (92)
- # clojure-uk (5)
- # clojurescript (183)
- # component (9)
- # cursive (28)
- # datomic (36)
- # editors (4)
- # emacs (1)
- # garden (11)
- # hoplon (155)
- # lein-figwheel (7)
- # mount (47)
- # om (97)
- # onyx (25)
- # proton (3)
- # rdf (3)
- # re-frame (80)
- # reagent (9)
- # ring-swagger (9)
- # spacemacs (1)
- # untangled (145)
- # vim (2)
:thinking_face: I'm using http.async.client
(mostly because I'm now using its websockets) and I'm facing an issue where it's not sending the authentication headers as expected...
(defn send-message [session msg channel]
(let [client (http/create-client)
resp (http/POST
; client (str " " channel "/message")
client "" ;I'd rather keep that private!
:headers {:Authorization (str "Bot " (get @session :token))}
:body {:content msg}
)]
[resp])
)
The body is fine (as you can see I'm using http://requestb.in to check the request, great troubleshooting tool), but the Authorization
header is not present. Anyone can tell me how I'm derping?just a guess, but try to use string keys for headers, i.e. :headers {"Authorization" (str "Bot " (get @session :token))}
And simple as that, @manenko saves the day! Thank you, that was exactly it.
Quick question regarding clj-time that's probably too dumb for stackoverflow. If I have an arbitrary date, how can I specifically set the hour? Something like (at-hour (t/now) 9)? I could write a function but I feel like there's some core functionality that I'm glossing over.
And if I wrote a function it would require something like (t/date-time (t/year dt) (t/month dt) (t/day dt) hour (t/minutes dt) (t/seconds dt))'
which feels verbose, especially if I'm writing a functions for each granularity of a datetime.
whats the latest on clojure dataflow? it looks like it was around in contrib in v1.2, and now it is deprecated? there is hoplon which is a cljs implementation, and some other libs (pulsar?) but is native support anywhere?
you might want to look at core.async for that kind of thing
@rodeorockstar Feel free to open a GitHub issue on clj-time suggesting that enhancement… You’re right there’s nothing like it right now. The closest would be with-time-at-start-of-day
and then add the hours as a period I think...
@seancorfield Do you know how to do a lein clean on heroku?
@josh_tackett Sorry, no clue. I don’t use Heroku (beyond experimenting to get an instance up and running a Clojure program years ago).
no worries
@seancorfield No matching method: sha1Hex, compiling:(taoensso/carmine.clj:156:20)
I’m having this issue
lein deps :tree looks good though
Sounds like a version conflict. Have you tried :pedantic
?
That sha1Hex
error rings a bell… I don’t remember the fix tho’, sorry.
:pedantic ?
lein deps :pedantic
returns nothing
@josh_tackett run heroku config:set LEIN_BUILD_TASK=“clean compile”
err, maybe uberjar
instead of compile
@josh_tackett You’d need to put :pedantic? :abort
in project.clj
and then run lein deps
I think. I don’t use Leiningen these days but I think that’s the approach. https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L74-L78
@seancorfield what does that do?
it looks like it won’t help with this issue
@dominicm I added that and it runs fine with lein run
the issue is happening when I run travis
travis-ci
Figured it out
it was another module of our project that was built in Java
it was throwing the error
and pushing up through since it is also a dep for me
@alexmiller thanks you are right - totally derped there/
I have a threading macro ->
I want to finish at some point based on a function parameter n
:
(defn step-until [n]
(-> foo
step1
step2
step3
step4
step5))
For (= n 2)
I’d like to execute until step3
I’m reading about cond->
but I don’t know how to apply it here. Is there a good soul with an idea how to do it? Thanks!Naively I’d write:
(defn step-until [n]
(cond-> foo
(< 1 n) step1
(< 2 n) step2
(< 3 n) step3
(< 4 n) step4
(< 5 n) step5))
no step-until
is not intended to be run in a loop
indeed you got me here it is loopish in behaviour, but I have a set of different steps
I would likely not have ended up with this particular structure though, because it feels very foreign to me.
no side effects here, i have a single map, that i pass to a number of functions...
yeah in that sense it’s a state
see the bottom of http://jcswart.github.io/2014/01/25/clojure-like-im-five-reduce-functions/
thanks, but I still don’t see how reduce
would end multi-step map transformation at certain point.
boot.user=> (doc reduced) ------------------------- clojure.core/reduced ([x]) Wraps x in a way such that a reduce will terminate with the value x
Odds are though there is a completely different way to write this code such that none of this is an issue.
sure, thanks anyways!
it goes down to the data I think 😉 I think I’ll include the step number in the map as it’s meaningful (it’s queried upon)
I’m practicing basics of the language
I’ll post it on github soon enough 😉
@jswart thanks mate! you helped alot, I went with reduce
, but here’s the twist I’m passing a collection of partial
s from the initial threading macro to the reduce
and take n
from that collection before passing to reduce to get the desired effect. Good ‘ol reduce
always does the job 🙂