#clojure log - Oct 28 2015

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

0:11 WickedShell: With core.async channels is there a way to make a channel LIFO? (Goal here would be a LIFO slidding buffer on a channel)

0:12 I guess I could define my own buffer? I've never touched that aspect but thats the only way I've seen so far to accomplish that

1:43 xzilend: Is there a way to have tools.logging log calls be printed in a CIDER REPL?

6:36 jonathanj: are there any structured logging libraries for Clojure or Java that anyone would recommend?

6:37 (structured in the "produces something like JSON and retains hierarchical log structure" sense)

6:38 we use Eliot <https://eliot.readthedocs.org/&gt; for our Python code and would like to reap the benefits of producing the same kind of logs everywhere

6:42 yenda: Is anyone here using compojure-api ?

6:52 powered: I'm using compojure because sente requires it

6:56 Deraen: powered: Sente doesn't require Compojure, examples just use it but you should be able to use any routing library to define the endpoints.

6:57 yenda: Yes

6:59 yenda: Deraen: do you have a workaround when you are developping in local to get the validation of your swagger.json working ?

6:59 I get [{"level":"error","message":"Can't read from file http://127.0.0.1:3000/swagger.json"}], obviously because swagger.io validator can't access my local file

7:01 powered: well that's good news, another dependency that can be taken out

7:07 Deraen: yenda: I have never tried to validate my local swagger.json

7:15 kwladyka: What do you use to make configuration files for app? EDN and for example https://github.com/yogthos/edn-config?

7:29 i guess this one is the best https://github.com/sonian/carica

8:33 ikitommi_: Yenda: this might be related - https://github.com/metosin/ring-swagger/issues/67

8:36 -> "By default, Swagger-UI attempts to validate specs against swagger.io's online validator. ". That's an evil default IMO. But need a PR to allow overriding that in tje clj-side. And default to null.

8:38 I think we could shop own own swagger-validator and default to that. Validator already used in tests.

9:06 yenda: kwladyka_: I use environ

9:06 kwladyka_: is any shortcut in Intellij to make test files in Clojure projects?

9:07 yenda, thx

9:07 i see weavejester makes it so it is probably good :)

9:08 yenda: I think it is the best if you intend to do more than a pet project and have it running in production someday

9:08 There is also propertied whore clojurewerkz which also use a plain java proprerties file

9:09 kwladyka: yenda, anyway i need make standalone java file and load data from config file on user computer

9:09 so user can modify config file

9:09 i am not sure it is good library for that?

9:09 config file is about SMTP authorisation etc.

9:10 yenda: if you want a plain java properties file it is probably better to use propertied

9:10 kwladyka: and i want have different data during test, then after compile file

9:10 yenda: because environ is more oriented towards profiles.clj in dev/test and environment variables in production

9:10 kwladyka: i am not sure how it is working... edn file can be like what i want?

9:11 and if i understand environ wouldn't work in that way but carica will work like that?

9:11 i am not sure

9:11 for now i am doing scratch project which will just work... after that i will verify details :)

9:12 yenda: kwladyka: use environ rather than karika

9:12 you just need a profiles.clj file

9:12 you put your profiles and variables like that {:dev {:env {:database-url "jdbc:postgres://localhost/dev"}}

9:12 :test {:env {:database-url "jdbc:postgres://localhost/test"}}}

9:13 and then call (env :database-url)

9:13 in prod you will have DATABASE_URL environment variable defined

9:14 kwladyka: it will also work as standalone uberjava file?

9:14 i am not sure how work profiles then

9:22 program will be running on user machine, not on server. It is dedicated to no technical people. Upload on server is to hard :)

9:23 so program has to read all files from local drive as uberjar

9:50 noncom: did anybody get into situation when maven leaves the "main" folder inside the jar and some inner folders, all of which are empty?

11:07 bluezone: Do people use IntelliJ for clojure?

11:11 powered: I use eclipse + counterclockwise

11:13 bluezone: I prefer not to go back to eclipse :D

11:18 powered: It's going to be 3 java VM instances either way lol

11:23 bluezone: lol

11:23 snowell: bluezone: I can vouch that cursive clojure makes intellij very nice for clojure development

11:25 kwladyka: I have all the time AuthenticationFailedException when using postal and gmail. Did you have this problem?

11:25 bluezone, i use UtelliJ, in my personal opinion it is the best solution.

11:25 But... i din't try myself others to be honest.

11:27 gmail suggest me i am trying to login with unsafe devices when use postal...

12:23 bluezone: kwladyka: I hate authentication problems :( Been trying 3 weeks to solve OAuth 2 problems lol

12:35 justin_smith: regarding "using compojure because sente requires it" above, this is false, I use sente without compojure just fine, all you need to do is assign sente's handlers to paths, the router you use does not matter

12:42 kwladyka: bluezone, i found it. google added additional security for non secure apps... i am wonder how they define not secure apps.

12:42 justin_smith, hi old friend :)

12:43 justin_smith: hello

14:19 kaladin: is core async reasonable to use for parallel computation of large datasets or am i using the wrong tool for the job?

14:29 hlship: Just curious how much traffic is still here on IRC, now that Slack has gone live.

14:29 Also, just getting LimeChat set up on my new Mac.

14:29 justin_smith: hlship: it's been less active, but there's still some traffic

14:41 Frozenlock: hlship: IRC is master race anyway :-p

14:55 SpookySpookyBoo: hlship: slack barely runs on my computer

14:56 but im also connected to a few different teams

14:56 xemdetia: irc may also nicer depending on your corporate overlord regime

14:57 *also be

15:04 snowell: I have to be on a VPN fairly often that blocks IRC but NOT Slack

15:04 Figure that one out :|

15:05 Frozenlock: snowell: Could the VPN be killing any connection not on port 80 or 443?

15:05 snowell: It's the US Government, so anything's possible

15:05 amalloy: NSA operative confirmed

15:05 * snowell says nothing

15:06 hiredman: you just need an web based irc client

15:07 snowell: hiredman: But that would be a change. I don't like that

15:07 hiredman: e.g. https://webchat.freenode.net/

15:07 slack would also be a change

15:07 snowell: shhhhhh

15:12 hiredman: Thanks. Trying the web thing out to see how it goes

15:13 hiredman: forcing everything to be tunneled over http is just the worst, what a world we have built

15:13 mnemnion: hi everyone. I'm using Luminus, and having trouble getting it set up so that it hot-reloads changed .clj files. Any tips? "lein run" doesn't appear to do it.

15:20 justin_smith: mnemnion: lein run does not cause hot-reloads, no, this is not a feature of lein

15:21 mnemnion: you can use the wrap-reload middleware from ring, that should cause your handlers to reload if changed when new requests come in

15:24 mnemnion: Thanks justin_smith

15:27 bendavisnc: anyone here have any suggestions between "the joy of clojure" vs "clojure for the brave and true"?

15:27 i want to get into clojure i think after briefly looking at the little schemer book

15:31 didibus: In Clojure, can I refer to a Var in another namespace without importing the namespace?

15:31 justin_smith: didibus: without requiring it? yes you can, but usually it's a bad idea

15:31 bluezone: didibus: yes by doing namespace/varname (something like this)

15:32 justin_smith: didibus: circular namespace dependency? if so, bluezone 's suggestion will not help, resolve will work, and you are probably doing something all wrong

15:34 bluezone: I am a noob but this is what the author wrote in Living Clojure

15:35 justin_smith: bluezone: you can call it as namespace/varname but calling that way without requiring is sloppy - there's no advantage to it, and there are ways it can subtly break

15:36 bluezone: How does it break? So I don't fall into hole pls ^_^

15:36 hiredman: any var that exists can in be referenced by its full name, but vars only exist when the code that creates them has been run

15:36 justin_smith: bluezone: when you call foo/bar without requiring foo, you are relying on the fact that some other namespace required foo already before you made that call

15:37 hiredman: so if you have a file that creates a var, trying to reference that var doesn't cause the file to be loaded

15:37 justin_smith: so if that other namespace changes, it could break your code, with no visible connection between the two namespaces

15:37 bluezone: isn't it smart enough to implicitly require foo when you do foo/bar?

15:38 justin_smith: bluezone: no, clojure's compiler is very stupid

15:38 intentionally

15:38 bluezone: Ah okay :)

15:45 didibus: Sorry my IRC disconnected. So I am calling an atom using @namespace/atom and not importing the namespace

15:46 In my REPL that works fine, but when I build it gives me a build error

15:46 hiredman: you don't import a namespace

15:46 didibus: compilation failed: java.lang.ClassNotFoundException

15:46 justin_smith: didibus: that only works accidentally, and only if some other code required the namespace

15:46 didibus: why wouldn't you just require the namespace?

15:46 hiredman: generally you'll use 'require' or 'use' (or :require and :use)

15:47 both of those actually do multiple things

15:47 the first thing is to look for a file the corresponds to the namespace name you asked for and load it

15:47 didibus: It's only at the end of my namespace, I've got some things def just for REPL conveniance to test the functions in my namespace, so I don't really need anything when running as an app

15:48 Is there a function or macro to just load a file?

15:48 hiredman: didibus: why not use require?

15:48 justin_smith: didibus: what's wrong with require? why do you hate it so?

15:49 hiredman: you will be effectively reimplmenting it

15:49 didibus: Hum, I'm fine with require, I just don't want to have it look like the namespace is required, it's only required for the things I've defined at the bottom that are only conveniances to setup things so you can call the functions from the REPL

15:49 justin_smith: didibus: the real fix is to take that shit out of the namespace

15:50 it's either required or not

15:50 hiredman: didibus: sounds like those belong in a different namespace

15:50 * justin_smith loves /ignore.

15:50 hiredman: if you have a grouping of functions that you want to distinguish from another group of functions, namespaces are a great way to do that

15:51 didibus: Hum, ya, I guess I could put that in a different namespace, load it in the repl when I need it and test my stuff through it. But have nothing require that namespace. Ok, thanks everyone, that will work

15:52 It's basically because my namespace has a lot of functions with takes a client object, and do remote calls with it. When I work on the namespace, creating that client is very verbose, have to setup a lot of stuff. So I had a function in the namesapce that setup a test client.

15:52 Would only use it in the REPL to quickly create the client

15:53 But, I'll just move that stuff in it's own namespace

16:02 kenrestivo: if a future isn't completed before -main exits, will the process wait or will the threads die?

16:04 i guess i could find a way to kick them all back up to some function that needs to return before -main does, and deref all the futures

16:07 justin_smith: kenrestivo: the process will wait, unless you call (shutdown-agents) or (System/exit N) (where n is an int)

16:09 kenrestivo: usually this comes up because someone is like "why does -main hang instead of exiting at the end" and the answer is "somebody used the thread pools, and you need to use shutdown-agents and/or System/exit to make it exit)

16:09 s/)/"

16:12 kenrestivo: great, thanks justin_smith

16:16 c

17:25 leika: Does anyone know if clojure-mode (for Emacs) exposes a way to turn off font-locking for symbols defined in clojure.core?

18:05 irctc: Hi everyone. :)

18:06 Can anyone tell me how to display text that just says Loading... while my backend async process fetches the results for the user? I'm using compojure.

18:07 justin_smith: irctc: sounds like something I would do in cljs / js

18:07 irctc: render "loading" into the page from the server, run a process in the browser that eventually replaces that text

18:07 irctc: So you are recommending that I do this in Clojure Script?

18:08 justin_smith: irctc: unless you have another idea of how "loading" on a web page would be replaced by page contents - this is usually done via frontend scripting

18:08 irctc: My idea was to create two threads so that one is loaded before the other one is ready.

18:08 But I was thinking in terms of just plain clojure.

18:09 justin_smith: irctc: threads?

18:09 irctc: there are no threads in the browser

18:09 irctc: Yes, I want to create an asynchronous process.

18:09 justin_smith: right, you want js or cljs for that of course

18:11 irctc: So would I just point my view to the cljs function which would then create the two processes and display the one that says Loading... until the other one is ready?

18:15 justin_smith: irctc: right, but how this is done in the details would vary based on what frontend DOM management you use (I recommend something react based, I use reagent at work, om-next looks great)

18:18 irctc: I've heard about reagent before. It was recommended. I'll probably use that. Thank you for your advice. I appreciate it. :)

18:19 justin_smith: irctc: I really wish this was just one simple thing, but it's amazing the amount of complexity under the hood for "simple" things that people expect from web pages these days :)

18:20 this would all be so much easier if everyone would drop the www and go back to gopher

18:21 irctc: I realize it's not going to be very easy to do, but I am open to a new experience. :) I don't know much about gopher so I can't comment on that. :)

18:21 justin_smith: irctc: gopher is old, and text only, and had no client side scripting, and no images, and no text formatting

18:22 you would get directories, and in those directories you get files or links to other directories on other servers - and that's it

18:22 so much simpler!

18:23 irctc: Maybe from our perspective (people who are used to a text based user interface), but for the majority of people it is much more intuitive to use a graphic based UI.

18:23 Besides, our industry has been enriched by all these new technologies.

18:23 noncom|2: yeah.. gopher +1... and fido1

18:24 WickedShell: Is there is a LIFO channel mechansim for core.async? Or is that something that would need to be done via a new Buffer impl?

18:24 noncom|2: ah, if only this wonderful graphical uis were well standardized and straightforward to use

18:25 html is not bad, but javascript alone is a hell

18:25 irctc: I think that's just a dropping-buffer.

18:25 It discards messages on a LIFO method.

18:26 I agree about the standards part. So many things in the world would be simpler if only they were standardized. For example the measuring systems.

18:27 WickedShell: I want the channel to behave in a LIFO method though thats not what dropping buffer does?

18:27 justin_smith: WickedShell: you should be able to make your own "channel" by implementing the protocol core.async uses right?

18:28 WickedShell: justin_smith, yeah i suspect thats what I need to do. Never done it before, and I kinda was surprised I couldn't find one that behaved that way

18:29 But I should be able to do it. I actually think I can do it by implementing a new buffer strategy

18:29 justin_smith: WickedShell: what about a very small sliding buffer?

18:29 WickedShell: justin_smith, right so sliding buffer drops messages the way I want, but taking from it doesn't behave in a LIFO manner, the takes are still FIFO

18:30 irctc: WickedShell, I would love to help you more but I am also very new at core.async.

18:30 WickedShell: All the channel's/buffer's I've found are all FIFO when pulling from the buffers

18:31 noncom|2: yeah, afaik they're all fifo

18:31 coz they are made to pipe messages

18:31 it's pipes from CSP

18:32 so look no further, just try to implement a lifo buffer!

18:33 WickedShell: Just wanted to confirm that was the approach before reinventing the wheel :)

18:33 noncom|2: also, that will a bit contradict to core.async dogma i think

18:33 WickedShell: Er reimplementing...

18:33 Oh? How come?

18:33 noncom|2: coz one of the core features of core.async is controlling backpressure

18:33 imagine you have 2 puts and 2 reads. the elements lying on the bottom will never be taken from there

18:34 now the put becomes 1 message and take is still 2 - the buffer gets emptied

18:34 whatever that means, is that you have very little predictable behavior

18:34 it's not like that for fifos

18:35 i am no pro of course with core async, but you should have a *really* specific case if you need core async lifo somewhere in your design

18:35 WickedShell: Hm... The reason I'm looking for it is I have a single source that generates a list of needed results that multiple workers are working on, but if the user has moved to a new region I need to prioritize the work for the region that they are looking at. But the prior work is still valid and should be done if possible. But theres a really bad noticable latency problem if I simply work through the fifo buffer

18:36 noncom|2: hmmmmmmm i just have no clue why would you use core async channels as events storage here...

18:37 you *could* use them to communicate to the storage, be it implemented somehow else, say, some rotating mechanism with java.concurrent things/queues...

18:38 with a dispatcher and stuff

18:38 just remember, core async is about realtime comms

18:38 irctc: Off to bed. Take care everyone. :)

18:38 noncom|2: have you read CSP? maybe you will find it interesting

18:39 irctc: good night!

18:39 justin_smith: WickedShell: sounds like a prio-queue based channel

18:39 WickedShell: I have not read CSP or prio-queue.

18:39 * WickedShell goes and googles

18:39 noncom|2: i read like 5 pages of CSP

18:40 really enjoyed it

18:41 justin_smith: are there any good implementations of priority queues for c.a?

18:41 i google only that people talk about it...

18:41 but not some actual solutions...

18:41 justin_smith: noncom|2: I really have no clue, but it just sounded like what he wanted was a channel backed by a prio-queue instead of a normal queue

18:42 noncom|2: yeah, maybe.. idk, it's new to me

18:42 here's a nice article http://dzimchuk.net/post/a-sample-implementation-of-a-priority-queue-based-on-azure-service-bus

18:42 not for c.a though

18:42 but has some theory and code

18:42 WickedShell: yeah priority, where increasing priority goes to newest things. Thus its monatomically increasing priority (which is essentially LIFO)

18:44 I have to read up on deftype/protocols though thats all new to me

18:44 noncom|2: WickedShell: hmmm what about the problem that the bottom of a lifo stack can be reached in a year?

18:44 WickedShell: well I want to maintain the drop properties on the buffer size

18:44 noncom|2: ah

18:44 WickedShell: The reality of my application anyways is that once the result is to stale its not worth doing

18:45 noncom|2: well, you also could issue a new channel for each new switching, so that your workers will gain new channel, but still remember the old one, and work on it when they have time

18:45 that would be very c.a-ey

18:45 WickedShell: Not sure what you mean by a new channel for each switching...

18:46 noncom|2: have a stack of channels

18:46 just an idea

18:46 wiorkers switch to new location, as you said - and you give them a new channel for that location events

18:46 the old channel, however, is still available for reading

18:46 but idk, that's just an idea

18:47 WickedShell: Still sounds like a LIFO with limited capacity would work best/easier...

18:47 noncom|2: maybe

18:47 well, then just try to implement it!

18:47 WickedShell: I am :D (well except when I stop to type here.... which is maybe to often)

18:47 justin_smith: WickedShell: protocols and deftypes are not super hard, but maybe try it with a defrecord first, those are easier than deftype and have good defaults

18:48 noncom|2: WickedShell: also, regarding all the defrecord and deftype thing, here's a lifesaver clue: http://cemerick.com/2011/07/05/flowchart-for-choosing-the-right-clojure-type-definition-form/

18:48 WickedShell: justin_smith, I was looking at this: https://tgk.github.io/2013/10/inspect-core-async-channels.html and it looked reasonable. But I was going to find some doc on whats actually happening there with the def's first

18:49 justin_smith: WickedShell: make a custom function that creates an instance, that puts the underlying stack in a field of the record, then send just pushes onto the stack (which could just be conj on a list) and read polls or gets the first item (pops) etc...

18:49 WickedShell: ahh! so you don't need to define a channel, just a buffer, much easier

18:50 WickedShell: yeah once I saw the protocol of buffer it looked like a pretty easy job :)

18:50 noncom|2: justin_smith: hmm.. how do you think, could such a buffer simply be an agent?

18:50 w/o c.a

18:50 justin_smith: noncom|2: you don't need an agent, your buffer can be immutable

18:50 noncom|2: ah

18:50 yes

18:50 justin_smith: I mean you could ditch c.a and use an agent with a stack, maybe, but c.a has other advantages

18:51 noncom|2: yeah

19:17 notid1: is there a library that would make it possible to process clojure code as a datastructure?

19:17 i'm trying to write something that will search a codebase for certain function calls

19:20 kibit does something similar, but not exactly what I want

19:21 justin_smith: notid1: you could check out what eastwood does - it uses tools.analyzer

19:21 "search a codebase for certain function calls" is definitely a subset of what eastwood does today

19:22 (eg. it can figure out if a function is called with the wrong number of args)

19:22 notid1: justin_smith: okay, that might be helpful

19:22 justin_smith: there is also slamhound, which is for refactoring

19:23 notid1: cool. i'll check them both out. for reference, what i'm trying to do is build up a list of every value used as an argument for a few functions

19:23 in the entire project

19:24 justin_smith: notid1: but not at runtime, just in the literal source?

19:24 notid1: just the literal source, yes

19:24 justin_smith: because you could use robert.hooke at runtime to track args

19:24 cool

19:31 notid1: justin_smith: slam.hound.aspload is exactly what i'm looking for.

19:31 justin_smith: thank you!

19:32 justin_smith: awesome

19:37 neoncontrails: Heh. I love Clojure repository readmes, they're so... literary and metaphorical

19:37 https://github.com/technomancy/slamhound

22:26 CharlesN: why this (mod (Math/pow 174 55) 221) returns 0.0 ?. The correct answer should be 47.

22:40 xeqi: ,(Math/pow 174 55)

22:40 clojurebot: 1.699059764806151E123

22:40 CharlesN: , (mod (Math/pow 174 55) 221)

22:40 clojurebot: 0.0

23:11 eze: hi, is there any gsoc 2016 posible mentor?

Logging service provided by n01se.net