This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-12-11
Channels
- # admin-announcements (26)
- # aws (1)
- # beginners (356)
- # boot (28)
- # cider (20)
- # clara (12)
- # cljs-dev (78)
- # cljsrn (22)
- # clojure (333)
- # clojure-brasil (1)
- # clojure-dev (15)
- # clojure-miami (1)
- # clojure-nl (3)
- # clojure-russia (61)
- # clojurecup (3)
- # clojurescript (137)
- # clojurex (4)
- # core-async (4)
- # data-science (3)
- # datavis (2)
- # datomic (31)
- # editors (1)
- # emacs (9)
- # hoplon (3)
- # juxt (8)
- # ldnclj (47)
- # leiningen (4)
- # luminus (4)
- # off-topic (20)
- # om (332)
- # onyx (1)
- # parinfer (23)
- # portland-or (4)
- # proton (161)
- # reagent (46)
- # ring-swagger (11)
- # specter (7)
- # yada (2)
another problem, is prn-str always guaranteed to return valid EDN to be parsed by read-string? for some reason it is dropping double-quotes sometimes when printing maps, I’m not sure it this is not related to some repl stuff or printer configuration
Sounds like a print-dup
issue?
@seancorfield: thanks, will try to tweak that setting, btw, I have switched that to transit and now it works without problems
Someone know what the difference between using defschema versus a plain def?. I couldn’t find an answer on the prismatic schema github page.
I read some tutorials in which the author used defschema, but in the prismatic website I only see schemas defined by def.
docstring from the code itself "Convenience macro to make it clear to reader that body is meant to be used as a schema. The name of the schema is recorded in the metadata."
Does anyone have an example use of this lein template? https://github.com/stuartsierra/reloaded
a web app perhaps, built using @stuartsierra’s workflow?
Hello! I only start studying Clojure. Prompt please about the conditional operators if. Where to find detailed information?
@billypiston: what do you think about this page : https://jafingerhut.github.io/cheatsheet/grimoire/cheatsheet-tiptip-cdocs-summary.html
Prompt please in the solution of a task. I have a clojure-project. I use a hiccup and Bootstrap styles. Everything works, but here only I don't understand as conditional operators work. Here my code: Project.clj file: (defproject yupppie "0.1.0-SNAPSHOT" :description "FIXME: write description" :url "http://example.com/FIXME" :license {: name "Eclipse Public License" :url "http://www .http://eclipse.org/legal/epl-v10.html" } :dependencies [[org.clojure/clojure "1.7.0"] [ring "1.4.0"] [compojure "1.4.0"] [hiccup "1.0.5"]] :plugins [[lein-ring "0.9.7"]] :ring {: handler yupppie.core/app }) Yupppie.core file: (ns yupppie.core require [compojure.core: refer: all] [compojure.route: as route] [ring.middleware.params: refer [wrap-params]] [clojure.pprint: refer: all] [hiccup.core: refer: all] [hiccup.page: refer [include-css include-js]])) (defn home [] (html [: head (include-css "/bootstrap-3.3.6-dist/css/bootstrap.min.css") (include-css "/styles.css") (include-css "https://fonts.googleapis.com/icon? family=Material+Icons") (include-js "/bootstrap-3.3.6-dist/js/bootstrap.min.js")] [: body [: div {: class "col-lg-6" } [: div {: class "input-group" } [: input {: type "text": class "form-control": placeholder "How old are you?" } [: span {: class "input-group-btn" } [: button {: class "btn btn-default": type = "button" } "Go, baby!"]]]]]])) ; (defroutes app (route/resources "/") (GET "/" [] (home)) (POST "/saveform" req (with-out-str (clojure.pprint/pprint params req))))) (def apps (wrap-params app)) I began to study it recently so so far not really I understand. I have a simple form. And at input in the field of figure less than 18 and pressing the button, it is necessary to make so that the picture was shown, and at input of figure 18 or more other picture. Here is how to me to use the conditional operator if that it earned?
Did you read a book about clojure or did exercises of 4clojure or did the clojure koans , @billypiston
But you couldn't prompt to me as to solve this problem?
I think you have to look at the parameters or req to see how the contents of the form is stored
then you could do something like this (if (= (parameter which holds the number) 18) (print picture))
but if you do not know the basics then you have a very hard time to finisch your programm
Thank you!
@billypiston: did you already figured out where and how to entered number is stored ?
what does (with-out-str (clojure.pprint/pprint :simple_smile: params req)))))
gives then
I did it according to the instruction and still not really well I understand a code. I simply юы wanted that you prompted that I need to read to solve my task.
I attached all the code above and I don't know as where to enter that after input the picture was shown 18, and after input of number less than 18 another was shown.
sorry but when I ran your code in cursive it will not run. There is a missing :main in your project.clj
I think you need something like firebug for Firefox to see what the form is sending exactly
Thanks. Everything works for me. Probably you didn't connect some files. And with my task I hope to me somebody will prompt.
I use IntelliJ.
Ok. Thank you
What is it?)
@roelof: @billpiston - I am going to move my answer to this thread the #C053AK3F9 channel to keep down chatter in this channel.
Who has a good example of a clojure macro that shows how you can get rid of boilerplate that you would have in java?
We chose the example from Programming Clojure: https://gist.github.com/borkdude/533beb1b833828092c35 But this is not entirely fair anymore since Java 1.8
@borkdude: How about any DTO / Factory and all the other x00 layers that are between one end and the others? I am serious here, the example might be a bit abstract, but it shows the strenghts of the data first approach IMO
In Java 8 the example would be:
boolean allBlank(String str) {
return str.chars().allMatch( c -> Character.isWhitespace(c));
}
Wonder if @stuartsierra will use a different example in the next edition of the book
@borkdude: You still need to define an interface for the lambda, which kind of strips a lot of the benefits of using an anonymous function.
having trouble with bidi and cors requests
options method returns 404, although it's added to the route def
cors POST requests always send an options pre-flight, it's browser enforced
nvm, i had a typo in the cors middleware
I'm checking differnt languages to know which should be my next move, I'm a Ruby developer
I thought in Clojure but don't know if from an job market point of view will be good option; I did some Racket in the past so I like it
but Go doesn't feel that appealing I'm learning it because of my job not exactly because I like it that much
but one of the advantages that I see of Go is the fact that is static linked after compiling a program, Clojure for intsance needs an investment in the JVM
also, one of the issues that I have with Ruby and teams is the lack of types not everybody knows how to write proper tests to take care of that but Clojure is a dynamic typed language
It's hard to gauge what is going to be successful in the long term anyway, unless you're willing to invest in all the major ones at once.
sgerguri: well, base on that argument I could pick Haskell which I'm checking for academy purpose I don't think I'll find a job in it at least not in the mainstream
I used to be probably one of the ~10 paid Erlang engineers in the country I come from, and I had to move to the UK to get a Clojure position.
@cored: I don't think issues in large teams are caused by the choice of programming language.
jannis: well, what I'm saying is that we as developers need to have a very good communication skill to share stuffs but if the language has some quirks then it will be even harder
There's a limit to how far you can take a lang - and the typing is just one part of it. The other is practices, how the code is structured etc.
if you have intermidate developers working on those type of platforms it will be harder to manage a big code base
Erlang is dynamically typed and our platform backbone had 30k+ lines of it. It was also massively concurrent and distributed, but you could still wrap your head around it.
What I'm writing in Clojure now is just a bunch of (micro)services so each one tends to be relatively small, in the hundreds to low thousands of lines of code.
I wouldn't learn a tech just because there's demand for it. Learn it because it teaches you something new.
@cored: Judging from the large number of C projects and the awfulness I've seen there, I'm not sure I agree. I would agree however that the language can make aspects such as maintainability harder. One example would be the ten different ways to write a simple loop in Ruby - everyone does it differently, so unless you enforce a specific style, your code can end up a mess. I'd argue that typing is only a small factor in this.
I'm not a big fan of learning hosted langs first. Learn the underlying tech before you go for what's built on top of it.
sgerguri: the downside for me is that for the fact that Go programs are easy to deploy at my current job are starting to use it to rebuild/build part of the application as micro services
@cored: Yes, communication, code review, discipline... it takes a good developer to write good, maintainable software, in any language.
I have interest in Clojure because of what can teach me as a Lisp and as mention I did some racket which was fun
and as with Ruby at the time I started with it I just did for fun, ended up finding a lot of jobs and quitting Java
Here's a question to the wider Clojure community - do you do top-down (i.e., from the api interfaces/main logic loop towards the data structure manipulation functions that you'll need) or bottom up (data structures first, then main logic flow/API level)?
I have a colleague who's very much into the bottom-up style, which I find usually leads to weird design unless you have very clear idea in your head as to where you are going. Interestingly, he seems to be the only one around who is so rigid about it, everyone else usually switches between the two as needed (myself included).
I do a mix usually
@sgerguri I really like to start with the data structures and then go back to top-down and revise them based on what the overall API tells me about what’s happening.
Thinking about the api I want usually leads me directly to consider the data structures I want the fns to operate on
The bottom up stuff is useful if I don’t know what the algorithm is going to be. Makes small tests and incremental experimentation easy
I’d call it top-down more often than not: write the code I want, then write the code I need in order to make it work
@donaldball True, looking at the function level helps for both. If you keep functions small it is easy to revise the structure.
And sometimes you end up realizing that the “big picture” needs to change once you’ve worked on the low-level view for a bit
the big problem with bottom-up is that it’s very easy to lose sight of the actual intended final product. so you can end up chasing down a rabbit hole that leads to the wrong solution
at least if you have a brain like mine ;D
@sgerguri: There is a video of a talk about bottom up and top down from last clojure conj
@abp: I've seen it. The trouble with cases like these is that you naturally have a reasonably big program state which you need to transition.
I'd go with it depends - more often than not building up function from simple manipulations towards more complex routines is the most sensible route, but sometimes you know what sort of toplevel structure you want. For example right now I'm writing a scaffolding for event sourcing and I do a bit of both - I understand what general shape would components in the system have and do a bit of bottom-up shaping exact methods that work on the events that I attach on those components.
is anyone aware of any reason not to set jetty's response header size limit to essentially unlimited in dev?
So it naturally leads to a data-manipulation-approach-first, since the majority of logic is going to be pure. Living in the AWS as a microservice talking to Kafka and Dynamo means large chunks are impure, however.
I'm not sure which direction I work. I tend to be the user of the api for the libraries I create so I usually have some capability in mind that I want to have and I rework things as much as necessary until it gets to the point that I can do what I want with a minimum of fuss.
@sgerguri: take datomic as an example, is big state transition really bad? Sorry in mobile, so terse
Said colleague of mine has taken this data approach to the extreme, we have reifications of atom interfaces so that Dynamo items can be treated as any other atom, with atomic CAS swaps.
Just have to say - floats are the work of the devil himself - what a royal pain in the ...
I don't know - like @joost-diepenmaat said, I find it fairly easy to lose sight of your destination when doing bottom up. It's fine if you can treat everything like pure data, but I find it easier to just flesh out the main logic and fill in the pure stuff once I have a skeleton ready than the other way around.
From my experience clear data based approaches slim the design, so yea there is potential for mistakes but also great oppurtunities
@abp I suppose they are, but they are related - this (along with a few other things) basically allows you to treat external storage almost like the local one, and in such scenario you can really write the entire program logic using simple data manipulation functions. And in those situations doing pure bottom-up kind of makes sense.
do you use breakpoints in your code and code execution stops there when calling that code from the REPL inside Cursive? I tried that and it's not working.
@sgerguri For the dynamo atoms, what’s the behavior when a dynamo request errors or times out?
which is the clojure way to extract "clojure" out of this string? "highlight highlight-source-clojure"
@donaldball: Off the top of my head, not exactly sure - I think there's an error thrown. Check out https://github.com/mixradio/multi-atom for the implementation.
@jjconti: what do you mean by extract? return a string without clojure, just the rest?
I feel like I'm missing something fundamental here, can someone explain to me why this assertion is being checked?
user> (binding [*assert* false] (assert (= 1 2)))
AssertionError Assert failed: (= 1 2) user/eval76726 (form-init2864370576484743983.clj:1)
Any ideas why my project is not deleting resources/public/js when I run lein clean? This is my configuration: https://github.com/carouselapps/ninjatools/blob/master/project.clj#L60
(clojure.string/replace "highlight highlight-source-clojure" "highlight highlight-source-" "")
What do you want to happen if clojure is not present?
Hi - I’m using timbre
for logging and am curious about how it handles lazy sequences. I’m basically just doing (timbre/info “some keys” (keys a-map)
. My question is; is this a bad idea and should I be calling (doall (keys a-map))
danmidwood: there you go: http://stackoverflow.com/questions/4874517/how-to-make-clojure-respect-assert-variable
jjconti: maybe
(re-seq #"highlight highlight-source-(.*)” "highlight highlight-source-clojure")
or something like that.@mpenet: Ah, of course. That makes a lot of sense, thanks
danmidwood: would be nice to have a property to toggle it ex: -Dclojure.compiler.assert=false
sgerguri: docker containers is the way to try new languages/environment at any job :-) talking about our last conversation
like I can build a clojure service put it inside a container and test things out in there
Like not saying you're going to write it in "x" if you can get all the support tooling ready to deploy and monitor it.
Or build a prototype and showcase it afterwards, with a focus on the advantages this gives you.
Trying to write a test that will stub out the lambda/get-function ... trying this ...
(deftest test-exception-throw-invalid-function
(with-redefs-fn {#'lambda/get-function (fn [c f n] "yikes")}
(let [result (handler/get-policy-link "foobar")]
(is (= result "blah")))))
and get this
ERROR in (test-exception-throw-invalid-function) (core.clj:7209)
Uncaught exception, not in assertion.
expected: nil
actual: java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.IFn
i expect a failing test. like blah is not yikes or something 😉
@clojuregeek: with-redefs-fn
takes an anonymous function as its body
it's a function, not a macro. if you want to avoid the (fn [] ..)
and the vars that you're redeffing are known at compile time, you can use with-redefs
instead
the -fn
suffix is about with-redefs-fn
being the function variant of with-redefs
, not about the kind of vars that it can redef
ok let me try some more.. thanks ... but in theory, its possible to redefine the function in the lambda namespace when its used in the function i want to test?
try this:
(deftest test-exception-throw-invalid-function
(with-redefs [lambda/get-function (fn [c f n] "yikes")]
(let [result (handler/get-policy-link "foobar")]
(is (= result "blah")))))
@clojuregeek: you can also try conjure
cool, i'll take a look .. but I think i want to just have one simple test right now.. trying example from @bronsa
There's supposed to be a new edition of https://pragprog.com/book/dswdcloj/web-development-with-clojure but it's not out yet.
@tesseract: I don't actually have any control over that, the publisher figures out everything related to distribution
@yogsototh: that is good news
@yogthos: in the new book light table is also used or can I follow it when I want to use cursive ?
and I use cursive myself, so the workflow in the projects is definitely cursive friendly
@bronsa sorry got sidetracked, yes that works great thanks!
@borkdude: That's Stuart Halloway's book, not mine
@stuartsierra: oops sorry
oke, and that docs are up-to-date. I tried the web Essentials book about luminus but I got the idea that some things were changed already
@yogthos: perhaps someone has a working basic web app with authorization built in so we could examine the source code?
@tesseract: hmm not sure of any off top of my head, the ClojureCup entries for this year might be a place to look actually
@tesseract: if you find one. Could you send me a link
@roelof: this one uses oauth https://github.com/split-brain/poetree
@tesseract: the buddy tutorial looks very good at first sight
Then I have to make a decesion. Make first a sample app with hiccup or wait on Om next
If I were you I wouldn't wait on Om.next. It solves problems you won't appreciate it solving until you encounter them. It will just feel needlessly complex. I'd rather try writing with reagent and re-frame first and after you get your bearings in that, only then try Om.next.
oke, I like to make a sort of ecommerce site and I like the idea that the shopping card is updated without a browser needs to load everything again
Including documents explaining various reagent topics - https://github.com/Day8/re-frame/wiki#reagent-tutorials
@roelof: You should also take a look at http://hoplon.io and http://boot-clj.com/. Hoplon is an alternative to the react-based front-ends and is VERY approachable for those new to clojure. The #C08BDAPRA channel is active and the folks there very helpful.
https://github.com/exicon/homepage uses hoplon - and they published their front-end - as well as https://github.com/exicon/webapp-skeleton (which may be dated).
@donmullen: thanks
The more I read about the reactive frameworks the more I think I like the style of quiescent
Its small, it does one thing, and it isn't reinventing the atom wheel (insert usual caveat: I'm a noob and probably don't know what I'm talking back)
@rantingbob: I’ve found https://github.com/hoplon/javelin fairly compelling - easy for people to understand the spreadsheet model of cells / formula cells.
@tesseract: @roelof closp has authorization and authentication built in using buddy: https://github.com/sveri/closp
@tesseract: np, if you have questions, just go ahead
@roelof @tesseract is delegating authZ authN an option?
@oli: for someone getting started is it worth looking at boot or should I just use lein ?
@roelof: you mean the one at http://sveri.de? could be someone changed it, there is no reset job. Apart from thatlein repl
Yes, I mean at http://sveri.de
Regarding the auth question. look here: https://github.com/sveri/closp/blob/master/resources/leiningen/new/closp/clj/service/auth.clj roles are "hand baked" and currently there is only a difference between a not loggedin user a logged in user and an admin
Take it step by step, my template is pretty exhaustive and picking single parts from it is difficult if you are new to clojure / the webstack
@sveri: I am watching the component talk from Sierra to see how your stuff differs Also I need to figure out ring and the like first, but your template looks great.
I am using system: https://github.com/danielsz/system/ which sits on top of component, offering some readymade ones. It is component just with a thin wrapper around it
@tesseract: i've never had an itch that i needed boot to scratch but i'm just a hobbyist YMMV