#clojure log - Jan 10 2016

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

4:43 arrdem: Is it just me or has nobody written a Clojure IRC server?

5:27 domgetter: So I don't have to rlwrap when I do lein repl, but I *do* have to rlwrap when I do lein figwheel

5:27 what should I look into to change figwheel so that I don't need rlwrap with it? Surely it's possible since lein repl doesn't need it?

5:33 ridcully_: the lein repl uses some faux readline library from the java universe

5:35 yet if you prefer the jline over the readline (i don't) iirc there should be bit about starting figwheel from the repl in the wiki over there

5:47 blt: ␐/exit

5:54 t0by: blt just invented IRC russian roulette, it seems.

7:59 m1dnight_: Can I uset jvm-opts in developer mode and deply mode? Ive been looking at some project.clj files but I can't find one.

7:59 Or even better, put it in an external file so I don't have to ignore my project.clj file when I push.

8:00 kwladyka: m1dnight_ https://github.com/kwladyka/chess-challenge/blob/master/project.clj

8:00 m1dnight_: The hting is, I have set the path for configuration files as a jvm option. When I run it on my server I had to change my project.clj file.

8:00 kwladyka: YEs that is what I have now. But it would be great if I could set it up differently for developing and for deploying.

8:01 kwladyka: m1dnight_ use :profiles

8:11 m1dnight_: ,(inc kwladyka)

8:11 that worked, thanks

8:11 clojurebot: #error {\n :cause "Unable to resolve symbol: kwladyka in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: kwladyka in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: kwladyk...

8:11 m1dnight_: (inc kwladyka)

8:11 kwladyka: m1dnight_ happy to hear that :)

9:22 m1dnight_: If somebody is looking for a project to help form time to time, I could use a second opinion on my irc/slack bot. I feel Im making a mess of things :p

9:38 jonathanj: why do you think that?

9:43 m1dnight_: Well, the thing is getting very big and I think I might be missing some proper design patterns here and there.

9:47 jonathanj: those are kind of broad reasons

9:55 m1dnight_: Well sure. But I think you learn more/faster if you work together. Different people have different views.

10:02 jonathanj: well, what's the current implementation look like?

10:05 m1dnight_: https://github.com/m1dnight/clojbot/tree/slack_connector

10:05 This is where Im currently at. I just added a slack connection so the bot can do irc and slack.

10:06 (disclaimer: the readme hasnt been updated to reflect this)

10:24 jonathanj: (doall (map #(f x) xs)) seems like longhand for something

10:24 maybe (doseq [x xs] (f x))

10:24 MJB47: x isnt from xs there

10:24 otherwise it would be %

10:25 but i think the doall is unecessary

10:25 if you dont want the lazyness (which there you dont)

10:25 then mapv might be the function

10:25 jonathanj: sorry, i meant % not x

10:25 MJB47: thgouh i think map is the wrong thing

10:25 jonathanj: i find using map for side-effects gives me a weird feeling

10:25 MJB47: yer

10:25 i think maybe dotimes might be better?

10:26 novak`: if I have (defn onetwo [& {:keys [one two]}] (print "one: " one ", two: " two)) is it possible to call it with something like (onetwo {:one 1 :two 2})?

10:26 MJB47: remove the &

10:27 i actually have no idea how [& {:keys [one two]}] works (or if its meant to)

10:27 but yer, anything after & is put into a list

10:27 so you input to that function would look like ({:one 1 :two 2})

10:28 which is not what you want by the looks of things

10:28 jonathanj: that's not actually true

10:28 MJB47: oh?

10:28 jonathanj: & {...} lets you write stuff like (f :a 1 :b 2)

10:28 but apparently that style is frowned upon because it's difficult to compose and it's a little bit funky

10:28 MJB47: ohrly? thats pretty sick

10:29 it does seem rather implicit

10:29 i would have just assumed it was undefined behaviour

10:29 jonathanj: ,((fn [& {:keys [a b]}] (vector a b)) :a 1 :b 2 :c 'nope)

10:29 clojurebot: [1 2]

10:30 MJB47: interesting

10:30 the more you know :)

10:30 jonathanj: ,(let [{a :a} '(:a 2)] a)

10:30 clojurebot: 2

10:31 novak`: jonathanj: Yup, but ,((fn [& {:keys [a b]}] (vector a b)) {:a 1 :b 2 :c 'nope})

10:31 jonathanj: so for whatever reason you can destructure a seq of pairs as a map

10:32 novak`: then just lose the & like MJB47 said

10:32 ,((fn [{:keys [a b]] (vector a b)) {:a 1 :b 2 :c 'nope})

10:32 clojurebot: #<RuntimeException java.lang.RuntimeException: Unmatched delimiter: ]>

10:32 jonathanj: ,((fn [{:keys [a b]}] (vector a b)) {:a 1 :b 2 :c 'nope})

10:32 clojurebot: [1 2]

10:32 novak`: So, answer to my question is: No?

10:32 jonathanj: you can't use & to do both

10:33 it doesn't really make sense, if you think about it

10:33 novak`: jonathanj: OK, thanks!

10:44 m1dnight_: Am I correct in assuming that I can create an uberjar locally and run it om y server?

10:44 Compiling on my server really takes 5 minutes or so. Locally only a few seconds.

10:46 kwladyka: m1dnight_ yes, uberjar is standalone ver. with everything compiled in

10:47 novak`: jonathanj: wait, it might have sense, I saw it in cemerick's nrepl server https://github.com/clojure/tools.nrepl/blob/master/src/main/clojure/clojure/tools/nrepl/server.clj#L121

12:56 elika1: (+ 1 2 3 4)

12:56 clojurebot: *suffusion of yellow*

12:56 elika1: (+ 1 2)

12:56 clojurebot: 3

12:56 elika1: (+ 1 2 4)

12:56 clojurebot: *suffusion of yellow*

12:56 elika1: (+ 1 2 1)

12:56 clojurebot: 4

12:56 elika1: (+ 1 2 0 0 0 )

12:56 clojurebot: 3

12:56 elika1: (+ 1 1 1 1 0 0 0 )

12:56 clojurebot: 4

12:56 elika1: (+ 1 1 1 1 0 0 0 1)

12:56 clojurebot: *suffusion of yellow*

12:56 elika1: (+ 1 1 1 1 0 0 0 190)

12:56 clojurebot: *suffusion of yellow*

13:02 ridcully_: everyday with this bot... everyday something new, that makes me crack up

13:52 favetelinguis: ,(* 60 60 60 3)

13:52 clojurebot: 648000

14:00 jonathanj: is there a public web repl?

14:00 `lein repl` takes forever, especially when i just want to play with a function or check something

14:00 MJB47: i use http://clojurescript.net/ for clojurescript

14:00 gfredericks: I have a long-running emacs with a long-running repl that I can switch to easily

14:01 devsda: jonathanj: you could try http://www.tryclj.com/

14:03 ridcully_: also `java -cp ~/.m2/repository/org/clojure/clojure/1.7.0/clojure-1.7.0.jar clojure.main` starts quite fast

14:04 jonathanj: gfredericks: that *usually* works for me, but sometimes i'm not actually at my own computer when i want to do this

14:04 (also ridcully_)

14:04 clojurebot: Gabh mo leithscéal?

14:04 jonathanj: devsda: thanks, that seems sufficient

14:05 it would be nice if had modern editor features (like just paren matching) but i guess i'll be happy with what i can get :)

14:08 ridcully_: ssh home? no?

14:08 Arker: Hi everyone. I am new to the clojure community and wish to contribute to the project. I was wondering where to start and will be grateful for your opinions.

14:16 justin_smith: Arker: clojure is very conservative about the code it accepts, and submissions are accepted on the clojure jira

14:17 http://dev.clojure.org/jira/browse/CLJ

14:22 Arker: justin_smith: Hi. I wish to start by contributing to the project by choosing a bug or enhancement request from the issue tracker list.

14:24 Later on I also wish to work on some projects bigger projects like the ones listed under GSoC

15:12 justin_smith: it's very nice that Arker wants to contribute, but I warned them.

15:18 favetelinguis: im not sure what the difference is between put! >! and >!! in core.async, i do understand where >! >!! is different but put! was new to me

15:19 the only usecase i have seens is using put! instaed of (go (>! ch c))

15:21 justin_smith: favetelinguis: put! takes an optional callback, and is async without being inside a go block. >!! is blocking. >! is async, but only inside a go block.

15:23 favetelinguis: so put! is sort of an implicit go block wrapper?

15:24 justin_smith: kind of, except for the whole callback thing, and it optionally runs the callback on the caller's thread instead of its own

15:31 visof: hi guys

15:31 MJB47: sup

15:33 visof: i have csv files, file1 has 3 fields and file2 has 4 fields, from file1 i want to get first and second fields and from file2 want to get second and third fields, how can write a generic method which do this transparentely?

15:33 ,(clojure.string/split "a,b,c" #",")

15:34 clojurebot: ["a" "b" "c"]

15:34 gfredericks: ,(subvec ["a" "b" "c"] 0 2)

15:34 clojurebot: ["a" "b"]

15:34 MJB47: i would use https://github.com/davidsantiago/clojure-csv

15:34 justin_smith: visof: there are csv libraries that handle the quoting and such

15:34 yeah

15:34 MJB47: and then use normal vector functions

15:35 visof: ,(let [[a b c] (clojure.string/split "a,b,c" #",")] [a b])

15:35 clojurebot: ["a" "b"]

15:35 visof: ,(let [[a b c] (clojure.string/split "d,a,b,c" #",")] [a b])

15:35 clojurebot: ["d" "a"]

15:35 visof: i want to get ["a" "b"]

15:35 for both cases

15:35 ErhardtMundt: hey there

15:35 visof: ,(let [[_ a b c] (clojure.string/split "d,a,b,c" #",")] [a b])

15:35 clojurebot: ["a" "b"]

15:36 visof: i want the code which take "d,a,b,c" or "a,b,c" and get only ["a" "b"]

15:36 for both cases

15:36 MJB47: are ab the same value in both cases?

15:37 ErhardtMundt: I'm new to clojure, I was playing around with compojure and stuff and I wondered if there's any best practice about stylesheet other than having DSL sources (the hiccup way)

15:37 I'd like to go the enlive way

15:37 visof: MJB47: not necessary, i mean i need a method which take csv line with 3 or 4 fields and return ]

15:37 return

15:37 ErhardtMundt: (having html and css stuff being independent from the code)

15:37 justin_smith: ,(map (comp (partial take 2) (partial take-last 3)) '[[a b c] [wrong a b c]])

15:37 clojurebot: ((a b) (a b))

15:38 MJB47: then i dont think you can do it with a single arity function (without doing something like (if (= 4 (count ...)

15:38 or justin smith just proves me wrong

15:38 justin_smith: MJB47: the above does it ^

15:38 MJB47: again

15:38 either way

15:40 visof: justin_smith: thanks

17:57 hi guys

17:58 if i have list of hashes [{:x 10 :y "a"} {:x 1 :y "b"} {:x 8 :y "a"}], how can i take one of hashes of unique y with higher :x

17:59 so i take {:x 10 :y "a"} {:x 1 :y "b"}

18:01 gfredericks: (defn unique-y-with-higher-x [hashes] (->> hashes (group-by :y) (vals) (map (fn [more-hashes] (apply max-key :x more-hashes)))))

18:01 ,(defn unique-y-with-higher-x [hashes] (->> hashes (group-by :y) (vals) (map (fn [more-hashes] (apply max-key :x more-hashes)))))

18:01 clojurebot: #'sandbox/unique-y-with-higher-x

18:01 gfredericks: ,(unique-y-with-higher-x [{:x 10 :y "a"} {:x 1 :y "b"} {:x 8 :y "a"}])

18:01 clojurebot: ({:x 10, :y "a"} {:x 1, :y "b"})

18:01 MJB47: that was fast o.0

18:01 visof: thanks gfredericks

18:02 * gfredericks is pretty tall so he can reach the obscure functions more easily

18:03 domgetter: mmmm, those top-shelf functions

18:03 MJB47: it literally took you longer to write that /me than the function

19:07 neoncontrails: What sort of network issues could be symptomatic of lein not finding a "luminus-nrepl" artifact when trying to boot a fresh cljs template?

19:08 I know it's not a typo in dependencies. I just ran lein new luminus with +cljs +http-kit and +site flags

19:12 Eh. I'll see if rebooting helps

21:05 elvis4526: Hi - is there a way to see all channels subscribed to a pub ?

21:57 muraiki: is anyone using bouncer for validation? if so, do you have a recommendation for handling the use case of an html form with numeric inputs failing to validate as number because they are java strings?

22:15 neoncontrails: Is it safe to delete "luminus-nrepl" from maven's local cache? I suspect it might have saved some bindings to project that doesn't exist anymore

22:16 justin_smith: neoncontrails: it should be safe to delete anything from the cache that you did not install by hand

22:25 neoncontrails: Hmm. That wasn't it. Is it possible a luminus project I deleted earlier had some of its settings cached to maven?

22:25 Particularly nrepl-related settings?

22:25 justin_smith: maven doesn't hold settings

22:25 it holds jars

22:25 I mean I guess you can use a jar to hold some settings files but I don't know of anyone that does that.

22:26 also, the jars are immutable - every time you get a specific version, you will get the same jar

22:26 neoncontrails: Gotcha. I was able to run luminus projects earlier, but now lein is having dependency issues

22:26 justin_smith: neoncontrails: what's the specific error you are getting?

22:27 neoncontrails: have you changed your .lein/profiles.clj since then?

22:27 neoncontrails: "Could not find artifact luminus-nrepl:luminus-nrepl:jar:0.1.2 in central (https://repo1.maven.org/maven2/) ... This could be due to a typo in :dependencies or network issues."

22:27 justin_smith: did you make a new "lein new" that might have looked at a new template version?

22:28 neoncontrails: justin_smith: uh I'm not sure I understand your question, did I create two instances of the same luminus template you mean?

22:29 justin_smith: neoncontrails: was it a previously working project that stopped working, or a new luminus project that doesn't work?

22:29 neoncontrails: new luminus project that doesn't work.

22:30 justin_smith: the most recent version of luminus-nrepl is 0.1.1, so yeah it won't find 0.1.2 anywhere

22:30 that's not because of lein - the jar isn't up there

22:30 https://clojars.org/luminus-nrepl

22:30 neoncontrails: justin_smith: good catch. Let me fix the template

22:31 justin_smith: neoncontrails: if you clone this and run lein install, that will make the not-yet-available 0.1.2 available on your local system https://github.com/luminus-framework/luminus-nrepl

22:31 and maybe someone should tell them they broke their template by relying on an artifact they did not deploy

22:32 which is funny, because 0.1.1 was just deployed today for the first time

22:33 neoncontrails: justin_smith: you are a savior. Thank you, I was stuck on this for hours

22:34 justin_smith: neoncontrails: do you see how the nature of the problem was right there in the error?

22:34 neoncontrails: and np, any time

22:35 neoncontrails: It makes sense, yeah. What threw me is, I didn't get this error last night

22:36 So I was working under the assumption I must have augmented my local environment in some way. Bad assumption, of course

22:37 justin_smith: and the fact that "lein new" templates are not immutable or versioned, so every time you use lein new you get random crap!

22:37 (this breaks a lot of tutorials too)

22:38 and this sucks because it's people who are newest to the language that are likely to be following a tutorial, and they are likely to judge the whole language by the fact that the tutorial no longer works because the template has mutated

22:39 versioned templates is my feature vote for lein 3

22:39 neoncontrails: Hear, hear. I'll create a new issue right now

22:42 BRODUS: is @ only used for derefing?

22:43 i'm looking for a char that clojure doesn't have any special meaning

22:43 for

22:47 gfredericks: ! $ & *

22:47 ?

22:47 - _

22:48 <>

22:48 |

22:48 most of those mostly don't have a special meaning

22:48 even % is usually usable

22:48 justin_smith: ☃ is the best char, and it has no meaning in clojure

22:48 BRODUS: hahaha

22:49 gfredericks: I didn't even mention + or =

22:49 justin_smith: ,(defn ☃ [f & args] (apply f (shuffle args)))

22:49 BRODUS: id like to use dollar but thats used to access nested classes

22:49 clojurebot: #'sandbox/☃

22:49 justin_smith: BRODUS: no, it's just part of the name

22:49 gfredericks: BRODUS: use it for what?

22:49 justin_smith: it's not an operator

22:50 ,(☃ / 1 2 3 4)

22:50 clojurebot: 1/24

22:50 justin_smith: ,(☃ / 1 2 3 4)

22:50 clojurebot: 3/8

22:50 justin_smith: ,(☃ / 1 2 3 4)

22:50 clojurebot: 1/24

22:50 gfredericks: ,(☃ / 0 1 2 3 4)

22:50 clojurebot: #error {\n :cause "Divide by zero"\n :via\n [{:type java.lang.ArithmeticException\n :message "Divide by zero"\n :at [clojure.lang.Numbers divide "Numbers.java" 158]}]\n :trace\n [[clojure.lang.Numbers divide "Numbers.java" 158]\n [clojure.core$_SLASH_ invokeStatic "core.clj" 1007]\n [clojure.core$_SLASH_ invoke "core.clj" 1000]\n [clojure.lang.ArrayChunk reduce "ArrayChunk.java" 63]\n [clo...

22:50 BRODUS: im building a helm extension thats lets you apply transformations to data

22:51 for a clojure evaluation context i want to find a symbol that users can use to acess arguments of the data

22:51 $ for the whole argument, $0 $1 .. $N for elements within if applicable

22:53 justin_smith: BRODUS: that's very much like *1 *2 *3 etc. in the repl

22:54 BRODUS: i haven't seen that before

22:54 gfredericks: justin_smith: that "etc" was pretty misleading

22:54 justin_smith: BRODUS: in the repl, *1 is the last result, *2 is the one before that

22:54 gfredericks: :)

22:56 TimMc: (def *4 *3)

22:56 gfredericks: ha

22:56 TimMc: (that might be the shortest joke I've told)

22:57 gfredericks: would be fun if clojure added a new *N with every release

22:57 TimMc: :-D

22:57 BRODUS: ah cool. I would want the symbol to be used against the current item being transformed, so if you're transforming [1 2 3] then (list %0 %1 %2 %) would return (1 2 3 [1 2 3])

22:58 justin_smith: so this is for a dsl that has to be compatible with clojure, and used inside helm?

23:00 BRODUS: a very small dsl but yeah, i think I just need a symbols for element access

23:01 TEttinger: well you can't redefine '@', '#', or any other reader macro

23:01 justin_smith: ,(apply #(list %1 %2 %3 %&] [1 2 3]) ; BRODUS - not far from what you are doing...

23:01 clojurebot: #<RuntimeException java.lang.RuntimeException: Unmatched delimiter: ]>

23:01 justin_smith: ,(apply #(list %1 %2 %3 %&) [1 2 3])

23:01 clojurebot: (1 2 3 nil)

23:02 justin_smith: oh, right

23:02 %& won't work there

23:03 BRODUS: using snowman or something is a good idea since that can be bound to a shortcut in emacs

Logging service provided by n01se.net