This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-12-07
Channels
- # admin-announcements (54)
- # announcements (1)
- # beginners (145)
- # boot (122)
- # cider (10)
- # cljs-dev (25)
- # cljsrn (20)
- # clojure (173)
- # clojure-art (4)
- # clojure-austria (1)
- # clojure-berlin (3)
- # clojure-germany (1)
- # clojure-nl (2)
- # clojure-russia (117)
- # clojure-switzerland (1)
- # clojure-uk (3)
- # clojurebridge (6)
- # clojurecup (36)
- # clojurescript (218)
- # clojurex (1)
- # core-typed (17)
- # cursive (23)
- # data-science (1)
- # datavis (2)
- # datomic (28)
- # emacs (3)
- # flambo (1)
- # hoplon (28)
- # ldnclj (19)
- # lein-figwheel (2)
- # leiningen (1)
- # luminus (1)
- # off-topic (1)
- # om (158)
- # portland-or (1)
- # re-frame (72)
- # reagent (48)
- # remote-jobs (1)
- # slack-help (7)
nice, reminds me of the Python csv
lib, which rather spoiled me for others
hi all - i was looking for a simple example of a udp server - i found a gist (that appears outdated) using aleph, but not much else - am i missing any obvious libraries? (coming from a python background). Thanks for any notes/help/etc!
and uh - this is my first time in a slack channel, so if there's an accepted way to ask questions, please feel free to correct my style....
@dm3: thanks, yes semantic-csv looks nice, but it still needs a lib for parsing if I understood correctly
For my Prerenderer library I want to have some programs that exercise it, to help test/develop it. These would be almost full Leineingen projects. Is there any conventions where to put them? I thinking /example. And is there a way to have leineingen pick the Prerenderer source code instead of the installed one? the checkout trick won’t work as github can’t keep track of symlinks.
Anyone is using duct?. I am trying to figure out how to pass the database record to the handler component. Actually, I am just passing the database URI, but I would like to pass the DB record in order to facilitate unit testing. The instantiation of the database records happens inside the same map (system-map) that I use to instantiate the handler component. Should I move the DB record instantiation outside (maybe inside the let bindings)?
I got the idea from here https://www.booleanknot.com/blog/2015/05/22/structuring-clojure-web-apps.html.
rcanepa: If you just want to add a mock database record, can't you create the system, then just assoc the mock db record into it before calling start on the system (when testing)?
That way you don't have to muck around with the system while you're building it just to account for a mock.
A parsing question: I have a sequence 1ab2cde3f4ghij
which I would like to turn into a map {1 (ab) 2 (cde) 3 (f) 4 (ghij)}
. I written one version with recur, which got ugly, and another version with partition-by
which I'm not entierly happy with either
(let [partitioned (partition-by (set "1234") "1ab2cde3f4ghij")
ks (map first (take-nth 2 partitioned))
vs (take-nth 2 (rest partitioned))]
(zipmap ks vs))
Other suggestions?@maxt Are you only dealing with strings? Maybe (re-seq #"(\d)([a-z]+)" "1ab2cde3f4ghij")
would produce more convenient partitions, to create a map from?
@andreaslundahl: Right, intresting. No I want to use it on any sequences. But your idea does suggest that it's a finite state machine im looking for
(group-by #(nth % 1) (re-seq #"(\d)([a-z]+)" "1ab2cde3f4ghij"))
got me close-ish. Not really a better solution than what you posted though.
I need to save various media (images, video) to a file system. Should I use Java interop, or is there a library that handles this for me?
Anyone who knows a good tutorial about making a website with login , authorisation and so on with clojure
I suggest buddy instead - https://github.com/funcool/buddy/ - it's considerably simpler
Here are some nice blogposts on how to use it - http://rundis.github.io/blog/tags/buddy.html
I also like/recommend buddy, @roelof here are some examples from https://github.com/funcool/buddy-auth/tree/master/examples
Oh, that's probably somewhat better for starters, since it has cookie based authentication example.
For routes and templating you don't really need more than the documentation of libraries, that's pretty simple.
oke, so I do not have to buy a book like web Essentials or web development with clojure ?
If you want something more classic then something like mustache - https://github.com/davidsantiago/stencil - or selmer - https://github.com/yogthos/Selmer - could work
@roelof: I didn't need something like this, but then again I've been doing Rails for four years already.
Also, why not Luminus? To me it seems like a good introduction to Clojure way of building webapps.
I just think it's fairly representative of how most simple Clojure webdev projects would look.
There's also duct, but it uses components, that might be somewhat confusing for a newcomer.
@roelof: Luminus also has a book, but it's a bit outdated and a new edition is supposed to come soon-ish.
oke, then I will concentrate on 4clojure at this moment and try to do all the "easy" challenges
@jaen: I think duct may have a slightly steeper learning curve but it's definitely worth the effort especially when deciding the best place to hold state. I went to Clojure X and saw a great overview/rationale by the author: https://skillsmatter.com/skillscasts/7229-duct-covered and here's another tutorial which covers all the basics very well by the author of Luminus : http://yogthos.net/posts/2015-10-01-Compojure-API.html
@bigkahuna: yeah, hence my caveat "for a newcomer". I'm using components myself (though not duct).
@roelof: Working through 4clojure is a very useful exercise as you'll internalize how Clojure works. I've been attended a few hackadays as part of the LJC and found the following pages useful: http://www.practical.li/ The author John Stevenson also has a github page with a project that can be loaded into a repl or Lightable that outlines Clojure's features. You can experiment with them to further your understanding: https://github.com/practicalli/clojure-through-code/tree/master/src/clojure_through_code I've also found Living Clojure by Carin Meier an excellent book for newbies. It guides you through the language at just the right pace: http://shop.oreilly.com/product/0636920034292.do
@bigkahuna: thanks for the tips
You mean this book - https://www.packtpub.com/application-development/clojure-web-development-essentials ?
There's also an older one by the author of the framework - https://pragprog.com/book/dswdcloj/web-development-with-clojure
https://pragprog.com/book/dswdcloj2/web-development-with-clojure-second-edition is out next year. First book is still worth reading, just that the libraries used are a tad out of date.
(defn my-gcd
[number1 number2]
(loop
[n1 number1
n2 number2]
(if (zero? (rem n1 n2))
n2
(recur n1 (rem n1 n2)))))
Probably. I think there's a way to short-circuit reduce
so that at some point you can skip processing the rest of the items. But I'd consider that an anti-pattern and a sign that you should be using loop
/ recur
, so I'd say stick with what you have.
reduce
makes the most sense when you want to process every item in a sequence.
Yeah, it's better to use those when they make sense. But to me, this looks like a good use case for loop
. Neither map
nor reduce
are well-shaped tools for this problem.
in all cases that work 1 or 2 of the numbers are even. 2 4 in the first, 10 in the second and 858 in the last one
it works for me, make sure what whatever algo you are looking at on wikipedia, is using recursion.
I tried to use the euclids solution on this page : https://en.wikipedia.org/wiki/Greatest_common_divisor
@roelof your solution works you are just forgetting something that is in the definition
\gcd(a,b) = \gcd(a - b,b)\quad, if a > b
\gcd(a,b) = \gcd(a, b-a)\quad, if b > a
(defn my-gcd
[number1 number2]
(loop
[n1 number1
n2 number2]
(if (zero? n2)
n1
(recur n2 (mod n1 n2) ))))
Hacker Dict Our ClojureCup hackathon entry is a dictionary for programmers by programmers. <Http://hacker-dict.com> We believe the programming community needs such a tool for discussing and gathering chronological data about programming. Basic functionality is there, we will improve upon it once the judging period is over. We used Clojure, ClojureScript and Datomic for the project Please sign up and share: http://hacker-dict.com
Nice work. One thing you probably already noticed: the browser back button doesn't work.
@jeff.terrell: thank you :) yes aim was to use a client side library but didn't have time to learn so it just updates the Url manually via push state
We will implement properly once they allow us to commit more
This is interesting for Clojure community because most stuff on the net is mutable
Wikipedia is mutable
Twitter is not but ephemeral
We aim to create a medium where people ca. Share facts and opinions about various aspects of programming
Yeah, that's a pretty interesting concept. What data should be mutable vs. immutable?
And others can learn chronologically
So that one can learn historical data and trends
And what is what and who is who
We also want to be able to share subjective facts not objective facts :)
You can also link with []
If it contains spaces
[rich hickey]
in some sense, a wikipedia article is a mutable pointer to its most recent revision, and the revisions are immutable
Much like, in git, the objects (e.g. commits) are immutable but the references (e.g. branches) are pointers that point to different immutable objects at different times. Datomic has a similar model. The stored data is immutable, but an entity's attribute can take on different values at different times.
True!
wonder anyone used https://github.com/Factual/drake in production? is this still under active development?
When I do lein ring server on a blank luminus project then I see this error message : 'ring' is not a task. See 'lein help'.
@roelof: yes, try it lein run
when you pull stuff with lein new luminus project
it's actually not reflective of the book instead it pulls the latest. In all likelihood this stuff is evolving very rapidly so what was good then is probably dated now.
@johnjtran: thanks, it worked. When I open my browser I see the startup page
@roelof: when in doubt, you can check http://www.luminusweb.net/docs also
I have a love/hate relationship with luminus. By all accounts, it appears to be very good -- but multiple layers and lots of wrappers etc. I don't advocate that you pick one over another, but take a look at pedestal
as an option. Less bells and whistles but appears to be slightly less aggressive with their updates -- thus stable.
hi, i’m trying to go from byte array to map with some spec - googling brought me to buffy and octet, but i just found gloss . is gloss my best bet for byte array to map of data?
(if this isn’t the right question for beginner questions, please let me know - thanks!)
http://construct.readthedocs.org/en/latest/ is the python version of what i'm trying to find
@hoopes: is this similar? https://github.com/smee/binary