This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-25
Channels
- # aws (2)
- # bangalore-clj (2)
- # beginners (90)
- # boot (89)
- # bristol-clojurians (1)
- # cider (23)
- # cljs-dev (48)
- # cljsjs (2)
- # cljsrn (3)
- # clojure (118)
- # clojure-argentina (3)
- # clojure-austin (8)
- # clojure-czech (1)
- # clojure-dev (18)
- # clojure-ireland (1)
- # clojure-italy (4)
- # clojure-russia (6)
- # clojure-spec (75)
- # clojure-uk (224)
- # clojurescript (103)
- # core-async (28)
- # cursive (3)
- # datascript (7)
- # datomic (15)
- # dirac (30)
- # emacs (14)
- # events (3)
- # figwheel (1)
- # hispano (1)
- # hoplon (176)
- # lambdaisland (1)
- # lein-figwheel (6)
- # off-topic (21)
- # om (7)
- # onyx (2)
- # pedestal (6)
- # re-frame (4)
- # reagent (15)
- # spacemacs (67)
- # specter (13)
- # testing (9)
- # untangled (65)
- # vim (6)
- # yada (1)
With a large set of examples for are
, how do I know which one failed? I get output like:
FAIL in (required-args-tests) (refl_test.clj:66)
expected: #{}
actual: :payne.refl/missing-args
diff: - #{}
+ :payne.refl/missing-args
FAIL in (required-args-tests) (refl_test.clj:66)
expected: #{}
actual: :payne.refl/missing-args
diff: - #{}
+ :payne.refl/missing-args
FAIL in (required-args-tests) (refl_test.clj:66)
expected: #{}
actual: :payne.refl/missing-args
diff: - #{}
+ :payne.refl/missing-args
FAIL in (required-args-tests) (refl_test.clj:66)
expected: #{}
actual: :payne.refl/missing-args
diff: - #{}
+ :payne.refl/missing-args
which of course tells me zilch about what’s actually failing.the test is written like:
(t/deftest required-args-tests
(t/are [fn-var expected] (= expected (#'r/required-args fn-var))
#'amazonica.aws.ec2/describe-vpcs
#{}
#'amazonica.aws.ec2/describe-egress-only-internet-gateways
#{}
...
this is a long-standing problem with are
(but really with macros in general) - I think the infamous http://dev.clojure.org/jira/browse/CLJ-865 is related
@mobileink btw, Cognitect does on-site Clojure intro training. let me know if you need any more info.
why am i now seeing the antiforgery token error when i run my luminus project locally?
@thug.nasty are you passing in the anti forgery token?
Luminus enables CSRF protection by default, so you have to provide the token in form submissions
@yogthos yes, the token is being passed around
passed in*
well, nothing now. I also just restarted the server
oh wait. does the system clock have anything to do with the generation of the token?
ahh that’s much more like it, thanks!
Hi, coding clojure since quite a while again. Was there a trick to make changes in code automatically be loaded when the app has been started with lein run?
Using compojure-api and couldn't figure out how to mangle headers with it without creating a separate namespace that gets the response and hacking the headers there
ikitommi: Thanks, found this: https://clojurians.slack.com/files/ikitommi/F3VQWLCKZ/Untitled.clj Trying that. 🙂
Does not work. If I put it before {:swagger ...} the application is not fired up, and if I put it after {:swagger ...} it does not add the extra headers.
`(defn wrap-add-always-headers [handler headers] (fn [request] (some-> request handler (update :headers merge headers)))) (def app (api {:swagger {:ui "/" :spec "/swagger.json" :data {:info {:title "Rest-invoice" :description "Compojure Api example"} :tags [{:name "api", :description "some apis"}]}}} {:middleware [[wrap-add-always-headers {"kikka" "kukka"}]]} (context "/api" []`
the :middleware
option in api is introduced 1.2.0-alpha1
. You can use the latest alpha (not recommended for prod) or wrap the mw “normally”:
Messing around and I have a map of name-spaced keywords generated by core.spec
generator, and I want to return that from an api. Return JSON is all the namespaced keywords. Is there a way to easily turn all the namespaced keywords into just their regular keyword format?
Can I run another task whenever lein deps is run?
Compojure related question. I have defined a route GET “/xxx/:id”
. When sending a request to /xxx/123 I would like to have a middleware that prints “/xxx/:id”. Is there any easy way to do so? (:uri request) is not enough.
@psalaberria002 why is it not enough?
I want to get it with ":id”, the same way it’s defined in the route
For the hot realoading, I found this and it works: http://www.http-kit.org/migration.html So made a main namespace that gets routes from the handler namespace (using compojure-api)
what do you want to print?
“/xxx/:id"
I want a unique identifier for each different route
you want to print the string :id
? why?
so /xxx/1 and /xxx/2 will both return xxx/:id
for that kind of thing I recommend bidi instead of compojure
with bidi you associate routes with handlers, which could be keywords
it's more "decomplected" than compojure
thanks for the tip. I was thinking there may be a function in compojure that does exaclty what I want. will have a look into bidi, but I am afraid it will take some time to change the api from compojure to bidi.
hehe yeah I understand
Hello folks, I am working on a Clojure project for my study. My school always forced students to design the system with UML before implementing the functionality. That was easy to do with Java as a language, but I am not sure how this is done with a functional language as Clojure. I have read the articles on the net about this and I am wondering if you folks can give me an insight on how you are tackling designing a Clojure application.
I don’t think that’s entirely true
it depends on how detailed you want your UML to be
there are still probably entities in your system that are ~same as the noun-like objects you’d have in OO (but they’re maps or records)
to can model the sub-systems without the need to reference “classes"
beyond that, I think it’s more useful to think in terms of data flow
I would represent the data as components and functions as how they interact with each other
Does anyone know if Buddy or any other lib can do the same thing as verify_id_token
as in python's oauth2client? https://github.com/google/oauth2client/blob/master/oauth2client/client.py#L1530
I have used the java lib [com.nimbusds/nimbus-jose-jwt “4.18”]
to do that
I've seen a lot of things for benchmarking CPU & time taken. But I don't seem to be able to find anything about memory consumption, have I missed it, or is there a JVM limitation in this regard and JMX is what I must delegate to?
UML has more than class and package diagrams, what about communication diagrams, sequence diagrams, state models, etc.
Communication diagrams fit really well with component/service design regardless of programming paradigm
and sequence diagrams are not bad for function invocation (although higher order is challenging in some cases)
I flip flop between communication and sequence diagrams. Sequence for message order and communication to explore components/services
I think among Rich’s many skills are his adeptness at capturing a complex architecture in a single diagram that includes the essentials and omits the rest
these diagrams are typically a mixture of data and process
and not UML :)
I think that's possible but I don't have the intuitive insight to get there in one step...I need the intermediate diagrams to derive the final one
some good examples are in http://cdn.cognitect.com/presentations/2014/insidechannels.pdf
that’s Rich’s talk from EuroClojure 2014
I have been reminiscing about old fashioned Data Flow Diagrams (DFDs) recently....takes me back 25 years!
DFDs are great for functional (but again, challenging for higher-order stuff)
Is there a quick/easy way to have the java build spit out the last piece of source it was on when it died? I’m looking for a needle in a haystack of markdown being parsed as a macro, and it’s painstaking
java.lang.ClassFormatError: Unknown constant tag 112 in class file
is a little opaque.
What do people use for generating documentation? I’m thinking of using swagger for apis but not so sure about for regular docs.
I use codox and spit them to /docs
. Then, if you’re on GitHub, setup the repo’s GitHub Pages to point to /docs
then your docs are published to https://<user|org>.
@lvh that's why I never use 'are'... haven't used it in years for this reason.
Marginalia let's you embed Markdown everywhere and build html with side notes about whole source code
@talexxx check out https://www.overops.com, I use it for keeping an eye on jars that I'm running - it's very handy for seeing what failed and why, especially as it displays the values of the parameters that were being used at the time. Must have saved me hours of scrolling through log files, it's free to use on a single jvm, then you pay if you want multiple ones
preferred way of sorting contents of an atom... ?
How about an atom with a nested vector... such as
(def nf-atom (atom {
:nf [{:not-used stuff}]
:things-i-wanna-sort [{:id 1 :message "I could be first..."}
{:id 2 :message "... or I could be first"}]}))
pardon the horrendous formatting
why is "atom" relevant here, is this question relaly "how do I sort this complicated sturcture" ?
Pretty much. I have an atom that holds a lot of application state, but I wasn't sure how to sort just a subset of it...
(def nf-atom (atom {
:nf [{:not-used stuff}]
:things-i-wanna-sort
[{:id 1 :message "I could be first..."}
{:id 2 :message "... or I could be first"}]}))
(might be easier to read)sort will let you specify the sort function, update-in will let you choose which subset of data to sort (leaving the rest unchanged), and swap! will let you update the atom
(swap! nf-atom update :things-i-wanna-sort #(sort-by :id %))
{:nf [{:not-used stuff}], :things-i-wanna-sort ({:id 1, :message "I could be first..."} {:id 2, :message "... or I could be first"})}
clojure.lang.RT.intCast
checks the result of the cast and if it's different than passed throws exception. That's ok. But id doesn't in second case.
I have a src/foo/bar.cljc -- there's someway to have the cljs version of foo/bar use a macro from the clj version of foo/bar
@tsulej I get an error in both cases -- the number is too large to be cast to an int type
user=> (set! *unchecked-math* true)
true
user=> ((comp int #(long 1234567890123)))
IllegalArgumentException Value out of range for int: 1234567890123 clojure.lang.RT.intCast (RT.java:1205)
user=> (int (long 1234567890123))
1912276171
anything the behavior of int is different there because the higher order usage isn't inlined by the compiler
you may also want to check out https://github.com/ztellman/primitive-math