#clojure log - Jun 28 2014

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:42 ivan: did any of the 54 people who retweeted https://twitter.com/mikeflynn_/status/482251458742472705/photo/1 check https://www.chrome.com/cubelab#tech

0:47 yedi: clojure is gone from there?

0:49 catern: was it shopped?

0:50 yes

0:50 it must have been

0:50 Clojure isn't in all caps and the rest are

5:00 sveri: hi, anyone here using jig? the documentation says there needs to be a config.edn file in config folder, however putting a config folder into jig with a config.edn it seems like jig does not recognize this, how would I do this correctly (I dont want to put it into $HOME folder, if possible)

5:15 clgv: sveri: it's likely that you have to specify that config file somewhere, isn't it?

5:17 sveri: clgv: yea, I just found it, it has to be in the resources folder of jig

5:17 I think the documentation is a bit misleading here, however, looking at the code, things clear up, as most of the times :D

5:18 clgv: sveri: oh so it's rellay config at build time and after that it is "hard" to change without a rebuild

5:19 sveri: clgv: I think so

5:20 clgv: sveri: every time I take a look at jig's docs it seems not that "simple" as advertised

5:24 sveri: clgv: I just took two hours to get it running, but now it occured to me that I do have a dependency on jig that I might not need

5:25 clgv: I am still thinking about using it, especially the part that you cannot have a user.clj file in your sources is kind of disturbing to me

5:25 clgv: sveri: what's that about the user.clj?

5:26 sveri: clgv: https://github.com/juxt/jig#userclj

5:27 clgv: ah ok.

5:27 strange. why could jig just use any *.jig.* namespace?

5:27 sveri: clgv: that was my first thought too, I immediately opened an issue for this as I read it

5:28 any kind of application with some sort of user management will have a user.clj file on the classpath

5:29 clgv: sveri: another strang thing. it is not a proper library right? otherwise why would I have to clone jig itself?

5:29 sveri: no I think they only mean a toplevel user.clj

5:29 sveri: that's special stuff from leiningen which seems to be supported by tools.namespace as well

5:29 sveri: clgv: I am not sure about it, could be

5:29 magopian: is "Christophe Grand" around here?

5:30 sveri: clgv: I think the documentation is not explicit enough about it and leaves some doubt for me

5:30 clgv: magopian: sometimes as "cgrand" (or cgrande?) but apparently not right now

5:30 magopian: I live not far away from him I believe (something like 1.5hours of driving), and would love to meet someone that uses clojure in person ;)

5:30 clgv: ok thanks);

5:30 thanks ;)

5:36 clgv: sveri: did you clone that jig repo to use it or did you just add it as dependency to your project?

6:14 sveri: clgv: I cloned it, like the docs said

6:16 clgv: sveri: from different project it seems it could be used a normal lib. so they'd just make a leiningen template replacing the clone advice

6:18 sveri: clgv: I am not sure about that, did you find docs for this usecase? this would benice too I guee

6:18 *guess

6:18 clgv: sveri: no docs, but other project from the "juxt" user on github

6:53 sveri: clgv: you mean that modular project?

6:54 clgv: sceri: I meant that one https://github.com/juxt/juxt-accounting

6:58 sveri: ^^

7:07 sveri: clgv: I see, I was always wondering if you could add jig as a dependency

7:07 clgv: sveri: the only sane way if you ask me ;)

7:08 sveri: clgv: yea, otherwise every member of your team has to setup jig himself

7:38 leyluj: hello?

7:38 clojurebot: BUENOS DING DONG DIDDLY DIOS, fRaUline leyluj

7:39 leyluj: i just saw closure, i was aking mr bot where can i use closure?

7:40 ddellacosta: leyluj: Where can you use the language Clojure?

7:40 leyluj: anywhere you got a JVM handy I guess. :-)

7:41 leyluj: so its a java kinda language ddellacosta?

7:41 :)

7:41 ddellacosta: leyluj: well, Clojure runs on top of the JVM. But I wouldn't say it's very Java-like, no. It does provide good Java interop however.

7:42 leyluj: there is also a JS-transpiled version, ClojureScript, which you may be aware of. I would check out the official site for a more thorough explanation though: http://clojure.org

7:43 leyluj: oh okay, im just starting out learning new stuff this 3 months and i saw clojure ... ddellacosta

7:43 where can i apply it ? web apps? desktop apps? mobile apps?

7:43 ddellacosta: leyluj: welcome! I think you'll find it a fun language and the community is full of nice, helpful folks. If I do say so myself.

7:43 kungi_: leyluj: There is http://cljsfiddle.net/ where you can play around with clojure

7:43 ddellacosta: leyluj: well, I can tell you there is a lot of folks using it for web dev, as I am. There is also a fair bit of machine learning in Clojure.

7:44 leyluj: You can write GUI apps with it as well, for example using SeeSaw: https://github.com/daveray/seesaw

7:45 leyluj: I guess I would say it's pretty useful for many things, but falls a bit short on stuff like scripting--the JVM startup time makes that kind of prohibitive. However, there are even some projects which aim to mitigate that: https://github.com/technomancy/grenchman

7:45 leyluj: thank you ddellacosta... im loving the community already ..

7:45 ddellacosta: leyluj: :-)

7:46 leyluj: lemme go play with it and check on you laters cheers ... thanks once again

7:46 ddellacosta: leyluj: cheers, enjoy, and come back if you have questions.

7:47 leyluj: this is a great place to start, btw: 4clojure.org

7:47 leyluj: aight then ddellacosta ... lemme hop on it

7:54 * nathan7 eyes ticking

8:05 clgv: ddellacosta: though it is more the Clojure statup time thats a problem compared to the JVM startup time ;)

8:06 ddellacosta: clgv: right, correction! leyluj ^

8:06 clgv: hello?

8:06 clojurebot: BUENOS DING DONG DIDDLY DIOS, fRaUline clgv

8:07 clgv: ok he says fräulein all the time ,)

8:07 ddellacosta: clgv: you're lucky, clojurebot and I aren't on speaking terms

8:07 ,(println "don't make me cry clojurebot")

8:08 clojurebot: eval service is offline

8:08 clgv: yeah, read it some days ago ;)

8:08 * ddellacosta would love to be called fraulein by clojurebot

8:08 * ddellacosta *sniffs* pitifully

8:09 clgv: ,(println "don't cry.")

8:09 clojurebot: don't cry.\n

8:09 clgv: oops forgot the name^^

8:09 ddellacosta: hahaha

8:09 clgv: I liked the time when you could initiate a bot conversation like that ;)

8:36 ocharles: Hi folks, having to do packaging stuff for work and I need to download a jar manually from Clojars - is that possible?

8:37 I'm not really a Clojure developer, I'm just helping out with some deployment stuff :)

8:37 e.g., how would one get the jar for https://clojars.org/lein-cljsbuild/versions/1.0.3 ?

8:42 clgv: ocharles: https://clojars.org/repo/

8:43 ocharles: ah, perfect! thanks clgv

8:43 clgv: ocharles: but why not use leiningen or at least maven?

8:44 ocharles: clgv: somewhat a long story, but we do at the moment

8:44 We use NixOS at work, which means that most of our builds are ran from clean environments - so every build requires downloading all dependencies

8:44 I'm hoping to optimize that out, by moving the dependency resolution into the package manager itself

8:45 It may end up being more pain than just waiting a little for lein to download dependencies, but I still want to explore it

8:56 nathan7: ocharles: Cool, never heard of anyone actually using NixOS in prod

8:56 ocharles: We're something of a rare breed :)

8:56 But I don't know why, it makes an awful lot of sense

8:58 nathan7: Yeah, I dislike the Nix package language a bunch, but I love the concept

8:58 nooga: hi, I have seq fs of functions, I'd like to get sum of results: (reduce + (map (fn [f] (f 5)) fs)) is there a more idiomatic way?

8:58 p_l: nathan7: there's scheme-based toolkit on top of Nix

8:58 ocharles: nathan7: yea, the language itself is so-so

8:58 nathan7: you know of guix too?

8:58 nathan7: ocharles: no, haven't heard of that

8:59 ocharles: That may be more up your street :)

8:59 nathan7: interesting

9:05 btcNeverSleeps: ,(+ 2 3) ; testing the bot's syntax before asking a question

9:06 clojurebot: 5

9:06 btcNeverSleeps: ,(disj (into #{} (range 1 12)) 7 9) ; ok, works fine

9:06 clojurebot: #{1 4 6 3 2 ...}

9:07 btcNeverSleeps: ,(let [v [7 9]] (disj (into #{} (range 1 12)) v)) ; <- doesn't do what I want

9:07 clojurebot: #{7 1 4 6 3 ...}

9:08 btcNeverSleeps: because v is passed to disj a single element and the set doesn't contain [7 9]. How can I solve that? (I don't know what to google for)

9:11 nathan7: apply

9:11 (apply disj (set (range 1 12)) v)

9:11 ,(let [v [7 9]] (apply disj (set (range 1 12)) v))

9:11 clojurebot: #{1 4 6 3 2 ...}

9:12 btcNeverSleeps: nathan7: ah great, thanks

11:36 sandbags: Can anyone tell me how to get a ring server to log incoming requests to the console?

11:36 i'm searching but can't seem to find any option for this

11:37 ddellacosta: sandbags: you could try this: https://github.com/pjlegato/ring.middleware.logger

11:38 sandbags: ddellacosta: thanks... i guess having a middleware do it makes sense, kind of

11:38 ddellacosta: sandbags: it's also pretty simple to just write a tiny little middleware layer to dump out requests using a logger

11:38 yeah

11:38 sandbags: what other way would you think may make sense?

11:38 sandbags: ddellacosta: well logging is kind of an essential function of a server and there's not a huge amount of magic to it

11:38 i'm just surprised its not baked in

11:39 ddellacosta: sandbags: well, it's quite simple to do, which I suppose is part of the reason why it's not. I can't say I've ever found it lacking as I've done web dev in Clojure

11:40 sandbags: it's not a big deal, i was just surprised is all

11:40 ddellacosta: sandbags: I guess you could probably also set up logging defaults for Jetty too

11:52 halogenandtoast: Is the (into []) here https://gist.github.com/halogenandtoast/58cf169f271d49f69005#file-progress-clj-L31 necessary, without it line 54 breaks but it seems redundant to me.

11:55 Frozenlock: halogenandtoast: You could maybe use 'mapv' if you don't want 'into []'

11:57 halogenandtoast: Frozenlock: Sure enough that seems to work, now I need to understand why. Reading up.

11:58 mapv is also not lazy it seems.

11:58 Which is good because I don’t want a lazy sequence.

11:59 Frozenlock: mapv is a shorthand for (into [] (map ...

11:59 ticking_: halogenandtoast: If you don't want lazyness use reducers.

11:59 they will give you a significant performance boost

12:00 halogenandtoast: ticking_: I’ll give them a try, but the performance boost is negligable the map should run between 2-4 times and there is io between each call.

12:00 ticking_: Frozenlock: only when applied to more than one collection. In the simple case it even uses transients so it should be rather fast.

12:01 https://github.com/clojure/clojure/blob/028af0e0b271aa558ea44780e5d951f4932c7842/src/clj/clojure/core.clj#L6344

12:01 halogenandtoast: mapv is your friend then

12:01 Frozenlock: ticking true

12:01 halogenandtoast: does the v stand for vector in this case?

12:01 ticking_: yes

12:02 halogenandtoast: Cool

12:03 Off to the smorgasburg, thanks ticking_ and Frozenlock

12:07 nathan7: ticking_: how's life?

14:34 travisr: does anyone have insight as to why re-match, without wildcards doesn't automatically substring the string under test?

14:35 ala grep...

14:36 ticking_: travisr: because re-find has that behaviour?

14:36 travisr: e.g., if I have a regex expression #"cat", this will not match: "somecathere"

14:36 the question was why.

14:36 @ticking_ ^

14:37 ticking_: that is why

14:37 travisr: clojure regexes are just thin wrappers around java regexes

14:38 travisr: and java has match and find methods to apply a regex to a string, where match tries an exact match and find tries to find a substring

14:38 travisr: thanks... I will look into that...

14:38 ticking_: http://docs.oracle.com/javase/7/docs/api/java/util/regex/Matcher.html

14:39 So if you want grep like behaviour use re-find, otherwise use re-matches

14:39 travisr: got it... thanks

14:40 thanks... that is perfect.

14:40 i just tried it and it works exactly as you've said.

14:40 thanks again

14:41 ticking_: youre welcome ^^

14:41 metellus: (inc ticking_)

14:41 lazybot: ⇒ 1

15:02 Frozenlock: (dec so)

15:02 lazybot: ⇒ -30

15:51 Shayanjm: if I have an atom which I'm using to store various pieces of data, is it 'bad clojure' to create functions that take 0 parameters and update ONLY that atom with relevant data?

15:51 or should I be creating more general functions which take the atom as a parameter?

15:53 jeremyheiler: Shayanjm: i'd create the general functions

15:54 also consider how you'll test the functions

15:55 Shayanjm: Sure, that's fair

15:55 thanks

15:56 jeremyheiler: if the requirements change and suddenly you'll need two atoms, then you'll probably be grateful for having the general functions.

15:57 bbloom: if you can help it, i'd avoid taking atoms at all

15:57 benkay: if i'm going to be serving a buttload of images with a ring server, it'd be a bad idea to pull the images off the disk on each request, right? is there an idiomatic approach to storing binary data in memory and then serving that as though it were a static file?

15:57 bbloom: make the functions totally pure

15:57 and use them with swap!

16:01 martinklepsch: count will exhaust a lazy seq right?

16:01 bbloom: (doc count)

16:01 clojurebot: "([coll]); Returns the number of items in the collection. (count nil) returns 0. Also works on strings, arrays, and Java Collections and Maps"

16:01 bbloom: oh, i thought it documetned that

16:01 martinklepsch: but yeah, it will

16:01 but note that "lists" are counted in constant time

16:01 (doc counted?)

16:01 clojurebot: "([coll]); Returns true if coll implements count in constant time"

16:01 bbloom: ,(counted? (list 1 2 3))

16:01 clojurebot: true

16:02 bbloom: ,(counted? (lazy-seq (list 1 2 3)))

16:02 clojurebot: false

16:07 benkay: caching? ring? anyone?

16:09 Jaood: benkay: why don't you use nginx for that?

16:10 benkay: naively, perhaps, i'd prefer to keep as much of the logic in the app as possible. i'd hope that (using jetty) would be well enough written to serve static assets out of memory relatively performantly.

16:11 that *ring*, using jetty...

16:12 mind you, i know next to nothing about how jetty works under the hood. i'm blessed with well-written wrappers.

16:13 am i completely off my rocker, Jaood ?

16:13 seangrov`: Anyone know if fressian can compress native clojure data structures with structural sharing?

16:13 (pr-str ..)-ing the data is madness, it balloons horribly

16:14 bbloom: seangrov`: fressian is primarily about streaming, it only caches some number of recently printed values

16:14 i think it's like 90-something

16:14 but i too have wanted full interning

16:14 * seangrov` grumbles

16:15 bbloom: also unfortuantely, internal data types (like red/black nodes) aren't exposed in any meaningful way with equality or hashing or anything like that

16:15 Jaood: benkay: if is a "buttload" of you images as you say why do you want to keep them in memory? anyway, nginx is highly optimized for serving static assets

16:15 bbloom: so there's no good way w/ standard clojure structures to recover internal sharing

16:17 benkay: Jaood: i may be engaging in premature maloptimization ;)

16:17 seangrov`: bbloom: Yeah, I was worried about that

16:18 bbloom: seangrov`: unfortunately, your options are pretty limited for general purpose solutions... you'll be best off just writing a custom serialization transform

16:19 benkay: another constraint i'm dealing with is that the request is going to hit /images/thinger_x_y.png which will need to serve one of a set of images - i suppose that ring could return a redirect to the path from which nginx would serve the specific image in question.

16:22 seangrov`: bbloom: So many cool features that could be realistically enabled if the structural sharing wasn't opaque

16:22 Maybe I'll give it a go in a few weeks

16:23 bbloom: seangrov`: yes. big time. i've really wanted that

16:23 seangrov`: as is, you'd basically have no choice but to re-implement all the main data structures

16:23 also, there's a trade off between "hash-cons" style creation and deferred recovery of sharing

16:24 in the former, you achieve perfect sharing, at the cost of reduced construction rate

16:24 in the later, you pay a pause cost in a GC-style transform that recovers sharing

16:25 seangrov`: Aren't the cljs data structures using hash-cons style?

16:25 bbloom: seangrov`: no

16:25 to do hash-cons-ing you need a lookup table

16:25 which would prevent GC in js (no weak refs)

16:29 seangrov`: bbloom: How about jvm-clj then?

16:30 bbloom: seangrov`: nope. it's the wrong trade off for functional programs

16:30 you want high construction rates

16:30 seangrov`: Ah, makes sense

16:30 bbloom: it's the classic space/time tradeoff analogous to ref counting & tracing GC

16:40 sveri: ocharles: you could take it from .m2 folder after having declared a dependency on it

16:43 ocharles: you could also clone the commit of the specific release and build a jar yourself with lein jar

16:44 arohner: is there any trick to making the datomic maven repo work? I can download datomic releases over http just fine, but lein seems to be having trouble

16:44 and I've used lein credentials and :env/foo without trouble before

16:50 sigh, password vs. passphrase

17:01 benkay: arohner: i usually download datomic, and then bin/maven-install - is that what you're doing?

17:01 arohner: no, I added "my.datomic.com/repo" to lein repos

17:01 benkay: i had no idea that was even a thing

17:01 arohner: instructions are at https://my.datomic.com/account

17:03 benkay: *sigh* another password reset...

17:06 makes me wonder, if the datomic team expects one to have a gpg toolchain set up already why not just ask for a clearsigned token?

17:16 gastove: Anybody in here game for a Reflection question? I'm trying to figure out how to access static methods on a class stored in a var.

17:26 Shayanjm: if I only want to get the text content from an enlive select - how might I go about doing that? I'm having issues with stuff like links inside the content body

17:28 gastove: reflect

17:28 Whoops, wrong window, sorry.

17:28 Shayanjm: https://gist.github.com/shayanjm/e5ebf21a4d57c84a4718

17:31 arohner: clojurebot: ~anyone

17:31 clojurebot: Cool story bro.

17:31 arohner: ~anyone

17:31 clojurebot: Just a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."

17:32 arohner: gastove: https://github.com/arohner/clj-wallhack/blob/master/src/wall/hack.clj has some examples of using reflection

17:33 gastove: Ha. Thanks for the pointer, arohner.

17:33 Bronsa: si`

17:34 gastove: arohner: and thanks for the github link!

17:34 arohner: np

17:35 gastove: Trying again, here's my question: I have a static class stored in a var. I need to call a static method from that class. I cannot figure out how the hell to do it.

17:36 arohner: gastove: look at wall.hack/method "obj - nil for static methods"

17:39 gastove: arohner: Cool, I'll poke at that.

17:45 Shayanjm: if I have a map {:thing "something" :content "realcontent" :secondthing {:thirdthing "another thing" :content "something again"}} (for example)

17:46 how do I identify and string together :content all the way into the nested map?

17:46 (assuming the nested map is of unidentified structure and could have more than just 2 layers)

17:52 kristof: Shayanjm: you could flatten it first

17:53 And then... bazam! Just pretend like it's a simple hash map.

18:20 TravisD: emacs

18:20 oops.

18:28 kristof: Not-ur-term-m8

18:28 (decf TravisD)

18:28 (dec TravisD)

18:28 lazybot: ⇒ 2

18:28 kristof: :)

18:28 TravisD: hehe, ouchies

18:41 noncom|3: please excuse me, if i am rude, but have you ever wanted to punch in the face a person who gives examples of usage of his lib, loaded with (use) or (require :refer-all) ns declarations?

18:46 kristof: Why would that be bad?

18:52 noncom|3: because it has lots of functions from, say 5-10 different namespaces. and in a real app, i cannot use (use) or (require :refel-all). and then i have to manually pick each function from its namespace. but in order to know which one of the tiny functions comes from where, i have look it up in the source

18:52 does that make sense?

18:52 TravisD: kristof: I guess if there are multiple modules in the library, it can be difficult to figure out where things are defined

18:52 noncom|3: or am i missing something?

18:53 kristof: that does make sense

18:53 but that can't be too hard

18:53 noncom|3: personally i would consider (use) or (require :refel-all) an antipattern

18:54 benkay: grep can help with those situations, noncom|3 ;)

18:54 jokes aside, i'm totally with you.

18:54 TravisD: I don't understand the term antipattern. In my mind, that means the lack of a pattern, and not a pattern which shouldn't be

18:54 benkay: wouldn't that be an unpattern?

18:54 noncom|3: that is that too bad since if i cannot remember which comes from where, there are too many of them.. and a tiny error would cause repl to be unable to eval the stuff and exit. since i work with opengl that causes the context to be lost and i have to re-launch all the stuff anew

18:54 benkay: noise?

18:55 noncom|3: yeah, you defo want to avoid use in your own code

18:56 also i try to save my limited supply of punches-through-the-internet for the ecmascript implementors.

18:56 noncom|3: haha :D

18:56 benkay: and everyone who ever wrote a django app that survived to become legacy code (including myself)

18:57 noncom|3: oh yes, in that land, there is even more of that kind of badness ...

18:58 benkay: noncom|3: in my experience reading the source is the best way to get to know clojure libs. documentation is sparse, and reading source has done more for me as a developer than all of the curl2sudo(tm) "easy" things that lib documentors and authors have done in other languages.

18:58 but your tastes may vary.

18:58 and mileage.

18:58 noncom|3: i agree with you..

18:59 but now we are long past deadline and studying these wonderful pieces of code inside does not make me any happier..

18:59 benkay: hahahaha

18:59 noncom|3: :)

18:59 benkay: carry on, soldier

18:59 me, i'm going to have another bloody mary.

19:00 noncom|3: thanks :)

19:52 noonian: noncom|3: slamhound could help in those situations, just get a repl up, remove the use form, and run slamhound; it will fix up the ns form with proper requires

19:55 noncom|3: noonian: thanks for the advice, gonna check it out!

21:27 echo-area: I think I have found a good use of dynamic vars: I need extra information in a watch function, but don't want to modify the watched reference object. Hence I use a dynamic var for carrying this information.

21:28 Using of dynamic var in this scenario seems natural and proper to me. What do you think?

21:31 technomancy: can't use metadata?

21:33 echo-area: That information also depends on the context

22:53 gastove: Hi all. I'm trying to access a static method on a class using reflection, using a method from clojure.contrib (http://clojuredocs.org/clojure_contrib/clojure.contrib.reflect/call-method). I'm getting a pretty nonsensical error (array element type mismatch), and am generally pretty bewildered. Would anybody be able to offer some guidance?

22:55 (The specific problem I need to solve is: I need to call a static method on a java class stored in a variable.)

23:08 gws: gastove: are you able to paste a snippet of what you're doing?

23:09 gastove: Sure -- give me a second to put together something comprehensible.

23:09 Part of the problem I'm trying to figure out is: every way I've seen to use reflection to access a static member of a class assumes you'll pass the name of the method as a string. But, the static method I'm trying to access dispatches on both type and arity -- so how do I specify which one I want?

23:19 gws: Here we are. https://gist.github.com/Gastove/b083083f22d7f198d964

23:43 Or, if you like: http://stackoverflow.com/questions/24472968/invoke-a-static-method-on-a-java-class-stored-in-a-var

Logging service provided by n01se.net