#clojure log - Dec 05 2015

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

1:06 moredhel: hi all, trying to work on a patch for om, but don't know how to include local libraries in lein. could someone give me a hand? or should I be asking this in #clojurescript?

1:08 Seanliu: Hai

1:10 tolstoy: moredhel: I think the answer is to run a maven command to "deploy" them to a repository that's in your source code.

1:11 moredhel: ah, that sounds painful. tbh, my java-project management skills are zero.

1:11 is that easy to grok?

1:11 tolstoy: https://www.pgrs.net/2011/10/30/using-local-jars-with-leiningen/

1:11 moredhel: ah, perfect :)

1:11 thanks!

1:12 tolstoy: moredhel Maybe also this? https://github.com/kumarshantanu/lein-localrepo

1:14 moredhel: thanks, gonna have a run through now

1:14 tolstoy: The lein folks seem oppose to free floating jars, for good reasons, but sometimes you just need to do it to see if it's even worth the effort.

1:15 I think you can also add a ".lein-classpath

1:15 " file to augment the classpath as well.

1:15 I've used that for plugins I don't want to deploy separately.

1:16 moredhel: but then how do I develop against a local copy of om for instance?

1:16 tolstoy: What I've done is check out the Om repo, make your changes, then run "lein install" and it'll put it in your local ~/.m2.

1:16 moredhel: ah, didn't know about the lein install thing.

1:17 so I can write it, then run that, and it overwrites the 'upstream' version

1:17 tolstoy: If you're not sure it's working, add a change that prints something, or whatever.

1:17 Yes, I think so.

1:17 You could also just bump the number in project.clj to be super sure, if you wanted.

1:18 moredhel: ah yeah, that's a good though.

1:19 rerunning the REPL now, I'll be a sec

1:19 arg

1:19 hmm... gonna try bumping version no

1:20 tolstoy: You can try running watch "ls -l /path/to/.m2/dir/om" and see if date/times change. ;)

1:22 moredhel: hehe, trying to find om under 3m2

1:22 .m2*

1:23 tolstoy: find ~/.m2 -iname "om"

1:23 moredhel: you are a literal live-saver

1:23 life*

1:23 tolstoy: This might work better: find ~/.m2 -iname "om*"

1:24 Adding a wildcard. There's a lot of versions of stuff in my cache.

1:24 org/om, then org/omcljs, etc.

1:26 moredhel: alright! something seems to be happening

1:26 I assume I need to update my project dependency to point to the new version too

1:27 tolstoy: Yep.

1:27 moredhel: hmm:

1:27 Could not find artifact org.omcljs:om:jar:1.0.2-alpha22-SNAPSHOT in clojars (https://clojars.org/repo/)

1:28 seems not to be picking it up

1:28 tolstoy: It's been a while, but you might also just "rm -rf .m2/repositor/org/omcljs" before running "lein install" just to make sure.

1:31 moredhel: yep, just nuked it, and I am getting it to build now! which is always a good thing

1:31 darn, doesn't seem to be doing printy things

1:32 is there a way to inspect a function definition in clojure? I know it can be done for macros

1:33 tolstoy: For clojurescript, if nothing else, you can look in your "out" directory to see what got compiled.

2:47 favetelinguis: is there a way to change how defrecord prints its type in the repl, it is cinda unreadable for me atm

2:54 kenrestivo: snapshots are weird

3:50 Trioxin: "When you see code snippets like this, lines that begin with ; => indicate the output of the code being run." ... are these basically comments?

3:50 comments with a specific purpose rather than just ;; ?

3:51 opqdonut: yes

3:51 Trioxin: k

3:51 opqdonut: it's just a convention

3:56 j-pb: hey, I'm a bit confused, in clojure you can call protocol methods on deftyped objects with and without a interop dot. But in cljs you can't.

3:57 (.foo x) (foo x) are both valid in clj but (.foo x) will fail in cljs

3:59 what is the correct behaviour here? I'm asking because data.avl has this piece of code https://github.com/clojure/data.avl/blob/master/src/main/cljs/clojure/data/avl.cljs#L1170

3:59 in it's cljs implementation, which was ported from the clj version, and I don't understand why it works

4:01 Trioxin: so in clojure, an if statement has preset logic flow of "evaluate -> execute if true -> execute else" but what about elseif?

4:03 ARM9: see cond

4:03 Trioxin: k

4:12 in this (when true (println "Success!") "abra cadabra") is "abra cadabra" the same as doing ; => "abra cadabra" ?

4:14 or is that what gets returned for some reason?

4:15 it was printed in the repl as => "abra cadabra"

4:17 I see that the jar doesn't output that line.

4:42 why does this evaluate nil? I was just trying to get 2 println for if true: (if true (do (println "true1") (println "true2")) (do (println "false")))

4:43 or just put them all in the same do I guess

4:43 sqlman: anyone using yesql ?

4:44 is there a way to do simple string substitution in query

4:44 e.g. select * from (:subquery)

4:47 Trioxin: oh nvm, the return value isn't specified

8:37 beaky: so...

8:37 how well does clojure adhere to rich hickey's philosophy on simplicity

8:38 (in how its features 'complect')

8:38 or rathre decomplect :D

9:12 OscarZ: i was thinking of testing core.async a bit and make a ring web app that would create a channel when the server starts.. the incoming web requests would then put some stuff in the channel, and it would process the stuff asynchronously

9:13 is this a bad idea? i remember reading something that channels are supposed to be light weight etc. and shouldnt live long

9:15 i would like to have 3 threads that will process the requests from channel concurrently

9:15 is this a use-case for core.async or would something else work better?

9:35 gfredericks: OscarZ: I think ring might be incompatible with that actually

9:35 at least if you want to avoid having ring's thread pool blocking on the whole thing

9:35 pedestal had a non-ring approach to solving that, I don't know which other libraries do

9:36 OscarZ: gfredericks, ok.. i thought if i have a go- block, then it wouldnt block it ?

9:38 gfredericks: OscarZ: but any ring adapter is going to block, because the core idea of ring is a function that takes a request and returns a response; no matter what you do inside that function, there'll be a thread sitting there waiting for the function to return

9:39 OscarZ: ive done a bit of testing with http-kit.. its ring- compliant though.. but do you mean that the ring programming model, having those "handler" functions is not going to work with this idea?

9:40 ok.. yes.. i just realized that

9:41 the whole idea of "thread parking" is a bit vague for me as im used to Java programming etc..

9:46 ucb: I'm having a bit of trouble with gen-class, namespaces, and symbols. Imagine I have a thread that will eval whatever you send to it (via messages, IPC, whatever) and that it uses (eval form-sent-by-other-thread)

9:46 I'm running into namespaces not bein available (same for symbols that were in the closure that spawned the thread)

9:46 being*

9:46 so I'm obviously not understanding in which context (eval ...) evals forms

9:48 any thoughts or pointers to rtfm?

9:49 I mentioned gen-class because I kick everything off via gen-class and -main

9:50 mostly because if I test the main fn in a repl, everything works

9:50 OscarZ: gfredericks, do you think it would be possible to have a macro that would take a list of handlers forming the ring application and based on that inject all code that is required for core.async to work (sacrifice goats, etc..)

9:50 ucb: I assume because the fn is being evaluated in the ns where all things are required, and vars declared, and so on

9:50 OscarZ: gfredericks, which would return a single handler with all the magic

10:02 gfredericks: OscarZ: nope, still wouldn't be able to use it with any vanilla ring adapter

10:02 OscarZ: ok.. good to know..

10:03 kungi: When someone in your company is sick and someone second does his job until the first one returns. How do you call the second one? I found proxy or deputy in the dictionary but this does not sound right to me.

10:04 OscarZ: what if i dont care about the result for the ring app.. i just want to "submit" some work to be processed.. and i want 3 threads to process them, would core.async then be ok to use?

10:10 kungi: maybe "substitute" or "replacement".. if its soccer, then its definitely substitute

10:10 kungi: OscarZ: Substitute sounds good

10:17 OscarZ: Thank you

11:36 favetelinguis: is there a way to change how the repel outputs my records, right now it prints very long names, i was hoping i could override som toString thing but cant find any examples on internet

11:37 j-pb: oveeride Object (toString [this])

11:52 schmee: anyone in here using react-select with Reagent?

11:53 I'm trying to make it work but I'm running into some errors I can't figure out

12:57 jonathanj: how does one use the :client-auth option for the jetty ring adapter?

12:58 so you specify :client-auth :need, but then how does one actually control client cert auth?

13:35 jjttjj: is there any sort of paid pair programming or code review service out there that can be used with clojure?

13:35 ARM9: http://vpaste.net/up6Ss do you really have to typehint types/records to avoid reflection or whatever is causing the slowdown?

13:36 (also curious that keyword accessors are allowed for deftype'd types)

13:38 nvm it's not allowed, it actually just returns nil

13:46 justin_smith: ,(:anything 2)

13:46 clojurebot: nil

14:16 swhalen: Hello #clojure

14:16 does anyone have any recommendations for clojure plotting libraries?

14:17 I am aware that incanter has some plotting facilities, but it looks like a stalled project so I am wondering if there is a newer plotting library that people are using

14:24 scottj: swhalen: https://github.com/JonyEpsilon/gg4clj

14:27 swhalen: scottj: thanks, I'll take a look. ggplot2 is nice

14:28 jjttjj: swhalen: probably not ideal but i ran into this problem too and ended up settling on just using a javascript library like highcharts that just takes a big json map and renders a visualization from it, generating this map in clojure then converting it to json and, then shoving that json in a html file that's ready to go with highcharts using format, then useing clojure.java.browse-url to open a browser with said html file

14:31 sounds convoluted but i've been really pleased with the results

14:35 swhalen: jjttjj: cheers, it does sound convoluted but of course you only need to set it up once

15:55 WickedShell: Is there a limit to the number of messages I can stick in a chan if I don't provide a buffer or a fixed size? I'm under the impression there isn't (well outside of memory etc)

15:55 justin_smith: WickedShell: yes, there's a default buffer size

15:57 WickedShell: justin_smith, darn! was really hoping there wasn't :P

15:58 Would I pay a large memory penalty if I just set the buffer size to be fairly large? (I'm assuming no, as it should be just the refs?)

16:14 rhg135: How large are references on the jvm?

16:22 jonathanj: wasn't there a flow chart about selecting which form of reify, defrecord, deftype, genclass you need?

16:22 rhg135: ~types

16:22 clojurebot: Titim gan éirí ort.

16:23 rhg135: It's somewhere

16:23 jonathanj: http://cemerick.com/2011/07/05/flowchart-for-choosing-the-right-clojure-type-definition-form/

16:23 rhg135: Ah yes that

16:23 jonathanj: cool, looks like I just need reify

17:54 WickedShell: if I pass a map to a function I can explicitly bind members of the map in the argument specifier (I forget the name for this, sorry). Is there an equivelent I can use in a let statement? IE I have a function that returns a map, can I bind the results directly without having to first bind the overall map?

17:56 ohh looks like I can use the same keys structure.. duh

17:56 ,(let [{:keys [a b]} {:a 1 :b 2}] (+ a b))

17:56 clojurebot: 3

17:58 crazydiamond: Hi. What tool is better to use to deploy Clojure Web projects?

17:58 ianhedoesit: crazydiamond: what do you mean better?

17:59 do you have your own server? are you using a vps service?

17:59 crazydiamond: I mean one that doesn't require much work to do it

17:59 Yes I do

18:01 thing that I wonder about the most is what tool to control server process with

18:01 Should I use Python's supervisor for that?

18:01 also, "better" means "what many ppl use"

18:02 ianhedoesit: can't you just java -cp clojure.jar clojure.main -m project.web?

18:02 or something

18:02 crazydiamond: and leave terminal open?

18:04 ianhedoesit: I mean I suppose it depends on what you're using in your project

18:04 crazydiamond: how's that?

18:05 I think it would be Ring, in the end

18:05 tolstoy: crazydiamond: I've been playing with "monit". Seems to work well.

18:05 crazydiamond: Though I use /usr/bin/daemon to start/stop it so I get a clean PID, which monit requires.

18:06 crazydiamond: thanks, but absence of common answer make me think that people unlikely use Clojure in production at all (I'm actively using Clojure 1 year or so, but for data processing mostly), which is very frustrating

18:07 tolstoy: crazydiamond: Because clojure runs on the JVM, people use whatever JVM requirements or techniques they're used to at their respective companies.

18:08 crazydiamond: You can turn your app into a War file and deploy to any App Server, for instance.

18:08 crazydiamond: Or you can run it as a jar file and use any of the numerous techniques for running those in production.

18:08 crazydiamond: Make sense?

18:09 crazydiamond: yes, thanks ianhedoesit and tolstoy !

18:10 tolstoy: crazydiamond: That supervisord thing works just fine. Tell it to "java -jar <your-uberjar>.jar" and it Should Work (™).

18:14 crazydiamond: okay :-)

19:14 MONODA: I'm having trouble writing a protocol for my matrix implementation

19:14 It requires recursion but when the program enters the first recursive call, it calls the default matrix implementation's protocol

19:24 alive876: newbie: running some of the ring tutorials, curious why i can't seem to connect externally, although i can see the rendering on local host using curl. the simple code is here :http://pastebin.com/LS5kVUvN thanks!

19:24 jonathanj: how do i spell byte[] as a type hint again?

19:26 hyPiRion: I would guess ^bytes

23:47 Trioxin: So I'm finally getting the hang of Clojure (My first Lispy language) where I can do most basic things. The more I code the more I find myself saying "This is some weird shit" (In a good way).

23:48 strangely intuitive comes to mind

23:50 pontiki: your mind warps around lisp and then nothing ever seems right again

23:52 Trioxin: I'm mainly doing this to apply machine learning. I've seen many examples where implementing algorithms displayed far less code than I'm used to and that seems to be true of just about anything.

23:53 in Clojure that is

23:54 coming from D, C#, JS, PHP. Can't wait to start using clojurescript as well.

23:57 clojurescript with HTML5 in node-webkit's DOM for frontend + clojure jars and clojurescript in node for backend of apps sounds beautiful.

23:57 well, node-webkit and cordova/phonegap

23:58 will iOS be a pain still? We'll see when it comes time for heavy lifting.

Logging service provided by n01se.net