#clojure logs

2015-10-28

00:11WickedShellWith core.async channels is there a way to make a channel LIFO? (Goal here would be a LIFO slidding buffer on a channel)
00:12WickedShellI 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
01:43xzilendIs there a way to have tools.logging log calls be printed in a CIDER REPL?
06:36jonathanjare there any structured logging libraries for Clojure or Java that anyone would recommend?
06:37jonathanj(structured in the "produces something like JSON and retains hierarchical log structure" sense)
06:38jonathanjwe 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
06:42yendaIs anyone here using compojure-api ?
06:52poweredI'm using compojure because sente requires it
06:56Deraenpowered: Sente doesn't require Compojure, examples just use it but you should be able to use any routing library to define the endpoints.
06:57Deraenyenda: Yes
06:59yendaDeraen: do you have a workaround when you are developping in local to get the validation of your swagger.json working ?
06:59yendaI get [{"level":"error","message":"Can't read from file http://127.0.0.1:3000/swagger.json&quot;}], obviously because swagger.io validator can't access my local file
07:01poweredwell that's good news, another dependency that can be taken out
07:07Deraenyenda: I have never tried to validate my local swagger.json
07:15kwladykaWhat do you use to make configuration files for app? EDN and for example https://github.com/yogthos/edn-config?
07:29kwladykai guess this one is the best https://github.com/sonian/carica
08:33ikitommi_Yenda: this might be related - https://github.com/metosin/ring-swagger/issues/67
08:36ikitommi_-> "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.
08:38ikitommi_I think we could shop own own swagger-validator and default to that. Validator already used in tests.
09:06yendakwladyka_: I use environ
09:06kwladyka_is any shortcut in Intellij to make test files in Clojure projects?
09:07kwladyka_yenda, thx
09:07kwladyka_i see weavejester makes it so it is probably good :)
09:08yendaI think it is the best if you intend to do more than a pet project and have it running in production someday
09:08yendaThere is also propertied whore clojurewerkz which also use a plain java proprerties file
09:09kwladykayenda, anyway i need make standalone java file and load data from config file on user computer
09:09kwladykaso user can modify config file
09:09kwladykai am not sure it is good library for that?
09:09kwladykaconfig file is about SMTP authorisation etc.
09:10yendaif you want a plain java properties file it is probably better to use propertied
09:10kwladykaand i want have different data during test, then after compile file
09:10yendabecause environ is more oriented towards profiles.clj in dev/test and environment variables in production
09:10kwladykai am not sure how it is working... edn file can be like what i want?
09:11kwladykaand if i understand environ wouldn't work in that way but carica will work like that?
09:11kwladykai am not sure
09:11kwladykafor now i am doing scratch project which will just work... after that i will verify details :)
09:12yendakwladyka: use environ rather than karika
09:12yendayou just need a profiles.clj file
09:12yendayou put your profiles and variables like that {:dev {:env {:database-url "jdbc:postgres://localhost/dev"}}
09:12yenda :test {:env {:database-url "jdbc:postgres://localhost/test"}}}
09:13yendaand then call (env :database-url)
09:13yendain prod you will have DATABASE_URL environment variable defined
09:14kwladykait will also work as standalone uberjava file?
09:14kwladykai am not sure how work profiles then
09:22kwladykaprogram will be running on user machine, not on server. It is dedicated to no technical people. Upload on server is to hard :)
09:23kwladykaso program has to read all files from local drive as uberjar
09:50noncomdid anybody get into situation when maven leaves the "main" folder inside the jar and some inner folders, all of which are empty?
11:07bluezoneDo people use IntelliJ for clojure?
11:11poweredI use eclipse + counterclockwise
11:13bluezoneI prefer not to go back to eclipse :D
11:18poweredIt's going to be 3 java VM instances either way lol
11:23bluezonelol
11:23snowellbluezone: I can vouch that cursive clojure makes intellij very nice for clojure development
11:25kwladykaI have all the time AuthenticationFailedException when using postal and gmail. Did you have this problem?
11:25kwladykabluezone, i use UtelliJ, in my personal opinion it is the best solution.
11:25kwladykaBut... i din't try myself others to be honest.
11:27kwladykagmail suggest me i am trying to login with unsafe devices when use postal...
12:23bluezonekwladyka: I hate authentication problems :( Been trying 3 weeks to solve OAuth 2 problems lol
12:35justin_smithregarding "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:42kwladykabluezone, i found it. google added additional security for non secure apps... i am wonder how they define not secure apps.
12:42kwladykajustin_smith, hi old friend :)
12:43justin_smithhello
14:19kaladinis core async reasonable to use for parallel computation of large datasets or am i using the wrong tool for the job?
14:29hlshipJust curious how much traffic is still here on IRC, now that Slack has gone live.
14:29hlshipAlso, just getting LimeChat set up on my new Mac.
14:29justin_smithhlship: it's been less active, but there's still some traffic
14:41Frozenlockhlship: IRC is master race anyway :-p
14:55SpookySpookyBoohlship: slack barely runs on my computer
14:56SpookySpookyBoobut im also connected to a few different teams
14:56xemdetiairc may also nicer depending on your corporate overlord regime
14:57xemdetia*also be
15:04snowellI have to be on a VPN fairly often that blocks IRC but NOT Slack
15:04snowellFigure that one out :|
15:05Frozenlocksnowell: Could the VPN be killing any connection not on port 80 or 443?
15:05snowellIt's the US Government, so anything's possible
15:05amalloyNSA operative confirmed
15:06hiredmanyou just need an web based irc client
15:07snowellhiredman: But that would be a change. I don't like that
15:07hiredmane.g. https://webchat.freenode.net/
15:07hiredmanslack would also be a change
15:07snowellshhhhhh
15:12snowellhiredman: Thanks. Trying the web thing out to see how it goes
15:13hiredmanforcing everything to be tunneled over http is just the worst, what a world we have built
15:13mnemnionhi 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:20justin_smithmnemnion: lein run does not cause hot-reloads, no, this is not a feature of lein
15:21justin_smithmnemnion: you can use the wrap-reload middleware from ring, that should cause your handlers to reload if changed when new requests come in
15:24mnemnionThanks justin_smith
15:27bendavisncanyone here have any suggestions between "the joy of clojure" vs "clojure for the brave and true"?
15:27bendavisnci want to get into clojure i think after briefly looking at the little schemer book
15:31didibusIn Clojure, can I refer to a Var in another namespace without importing the namespace?
15:31justin_smithdidibus: without requiring it? yes you can, but usually it's a bad idea
15:31bluezonedidibus: yes by doing namespace/varname (something like this)
15:32justin_smithdidibus: circular namespace dependency? if so, bluezone 's suggestion will not help, resolve will work, and you are probably doing something all wrong
15:34bluezoneI am a noob but this is what the author wrote in Living Clojure
15:35justin_smithbluezone: 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:36bluezoneHow does it break? So I don't fall into hole pls ^_^
15:36hiredmanany 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:36justin_smithbluezone: 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:37hiredmanso if you have a file that creates a var, trying to reference that var doesn't cause the file to be loaded
15:37justin_smithso if that other namespace changes, it could break your code, with no visible connection between the two namespaces
15:37bluezoneisn't it smart enough to implicitly require foo when you do foo/bar?
15:38justin_smithbluezone: no, clojure's compiler is very stupid
15:38justin_smithintentionally
15:38bluezoneAh okay :)
15:45didibusSorry my IRC disconnected. So I am calling an atom using @namespace/atom and not importing the namespace
15:46didibusIn my REPL that works fine, but when I build it gives me a build error
15:46hiredmanyou don't import a namespace
15:46didibus compilation failed: java.lang.ClassNotFoundException
15:46justin_smithdidibus: that only works accidentally, and only if some other code required the namespace
15:46justin_smithdidibus: why wouldn't you just require the namespace?
15:46hiredmangenerally you'll use 'require' or 'use' (or :require and :use)
15:47hiredmanboth of those actually do multiple things
15:47hiredmanthe first thing is to look for a file the corresponds to the namespace name you asked for and load it
15:47didibusIt'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:48didibusIs there a function or macro to just load a file?
15:48hiredmandidibus: why not use require?
15:48justin_smithdidibus: what's wrong with require? why do you hate it so?
15:49hiredmanyou will be effectively reimplmenting it
15:49didibusHum, 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:49justin_smithdidibus: the real fix is to take that shit out of the namespace
15:50justin_smithit's either required or not
15:50hiredmandidibus: sounds like those belong in a different namespace
15:50hiredmanif 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:51didibusHum, 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:52didibusIt'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:52didibusWould only use it in the REPL to quickly create the client
15:53didibusBut, I'll just move that stuff in it's own namespace
16:02kenrestivoif a future isn't completed before -main exits, will the process wait or will the threads die?
16:04kenrestivoi 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:07justin_smithkenrestivo: the process will wait, unless you call (shutdown-agents) or (System/exit N) (where n is an int)
16:09justin_smithkenrestivo: 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:09justin_smiths/)/"
16:12kenrestivogreat, thanks justin_smith
16:16kenrestivoc
17:25leikaDoes anyone know if clojure-mode (for Emacs) exposes a way to turn off font-locking for symbols defined in clojure.core?
18:05irctcHi everyone. :)
18:06irctcCan 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:07justin_smithirctc: sounds like something I would do in cljs / js
18:07justin_smithirctc: render "loading" into the page from the server, run a process in the browser that eventually replaces that text
18:07irctcSo you are recommending that I do this in Clojure Script?
18:08justin_smithirctc: 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:08irctcMy idea was to create two threads so that one is loaded before the other one is ready.
18:08irctcBut I was thinking in terms of just plain clojure.
18:09justin_smithirctc: threads?
18:09justin_smithirctc: there are no threads in the browser
18:09irctcYes, I want to create an asynchronous process.
18:09justin_smithright, you want js or cljs for that of course
18:11irctcSo 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:15justin_smithirctc: 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:18irctcI've heard about reagent before. It was recommended. I'll probably use that. Thank you for your advice. I appreciate it. :)
18:19justin_smithirctc: 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:20justin_smiththis would all be so much easier if everyone would drop the www and go back to gopher
18:21irctcI 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:21justin_smithirctc: gopher is old, and text only, and had no client side scripting, and no images, and no text formatting
18:22justin_smithyou would get directories, and in those directories you get files or links to other directories on other servers - and that's it
18:22justin_smithso much simpler!
18:23irctcMaybe 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:23irctcBesides, our industry has been enriched by all these new technologies.
18:23noncom|2yeah.. gopher +1... and fido1
18:24WickedShellIs 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:24noncom|2ah, if only this wonderful graphical uis were well standardized and straightforward to use
18:25noncom|2html is not bad, but javascript alone is a hell
18:25irctcI think that's just a dropping-buffer.
18:25irctcIt discards messages on a LIFO method.
18:26irctcI 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:27WickedShellI want the channel to behave in a LIFO method though thats not what dropping buffer does?
18:27justin_smithWickedShell: you should be able to make your own "channel" by implementing the protocol core.async uses right?
18:28WickedShelljustin_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:29WickedShellBut I should be able to do it. I actually think I can do it by implementing a new buffer strategy
18:29justin_smithWickedShell: what about a very small sliding buffer?
18:29WickedShelljustin_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:30irctcWickedShell, I would love to help you more but I am also very new at core.async.
18:30WickedShellAll the channel's/buffer's I've found are all FIFO when pulling from the buffers
18:31noncom|2yeah, afaik they're all fifo
18:31noncom|2coz they are made to pipe messages
18:31noncom|2it's pipes from CSP
18:32noncom|2so look no further, just try to implement a lifo buffer!
18:33WickedShellJust wanted to confirm that was the approach before reinventing the wheel :)
18:33noncom|2also, that will a bit contradict to core.async dogma i think
18:33WickedShellEr reimplementing...
18:33WickedShellOh? How come?
18:33noncom|2coz one of the core features of core.async is controlling backpressure
18:33noncom|2imagine you have 2 puts and 2 reads. the elements lying on the bottom will never be taken from there
18:34noncom|2now the put becomes 1 message and take is still 2 - the buffer gets emptied
18:34noncom|2whatever that means, is that you have very little predictable behavior
18:34noncom|2it's not like that for fifos
18:35noncom|2i 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:35WickedShellHm... 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:36noncom|2hmmmmmmm i just have no clue why would you use core async channels as events storage here...
18:37noncom|2you *could* use them to communicate to the storage, be it implemented somehow else, say, some rotating mechanism with java.concurrent things/queues...
18:38noncom|2with a dispatcher and stuff
18:38noncom|2just remember, core async is about realtime comms
18:38irctcOff to bed. Take care everyone. :)
18:38noncom|2have you read CSP? maybe you will find it interesting
18:39noncom|2irctc: good night!
18:39justin_smithWickedShell: sounds like a prio-queue based channel
18:39WickedShellI have not read CSP or prio-queue.
18:39noncom|2i read like 5 pages of CSP
18:40noncom|2really enjoyed it
18:41noncom|2justin_smith: are there any good implementations of priority queues for c.a?
18:41noncom|2i google only that people talk about it...
18:41noncom|2but not some actual solutions...
18:41justin_smithnoncom|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:42noncom|2yeah, maybe.. idk, it's new to me
18:42noncom|2here's a nice article http://dzimchuk.net/post/a-sample-implementation-of-a-priority-queue-based-on-azure-service-bus
18:42noncom|2not for c.a though
18:42noncom|2but has some theory and code
18:42WickedShellyeah priority, where increasing priority goes to newest things. Thus its monatomically increasing priority (which is essentially LIFO)
18:44WickedShellI have to read up on deftype/protocols though thats all new to me
18:44noncom|2WickedShell: hmmm what about the problem that the bottom of a lifo stack can be reached in a year?
18:44WickedShellwell I want to maintain the drop properties on the buffer size
18:44noncom|2ah
18:44WickedShellThe reality of my application anyways is that once the result is to stale its not worth doing
18:45noncom|2well, 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:45noncom|2that would be very c.a-ey
18:45WickedShellNot sure what you mean by a new channel for each switching...
18:46noncom|2have a stack of channels
18:46noncom|2just an idea
18:46noncom|2wiorkers switch to new location, as you said - and you give them a new channel for that location events
18:46noncom|2the old channel, however, is still available for reading
18:46noncom|2but idk, that's just an idea
18:47WickedShellStill sounds like a LIFO with limited capacity would work best/easier...
18:47noncom|2maybe
18:47noncom|2well, then just try to implement it!
18:47WickedShellI am :D (well except when I stop to type here.... which is maybe to often)
18:47justin_smithWickedShell: 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:48noncom|2WickedShell: 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:48WickedShelljustin_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:49justin_smithWickedShell: 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:49justin_smithWickedShell: ahh! so you don't need to define a channel, just a buffer, much easier
18:50WickedShellyeah once I saw the protocol of buffer it looked like a pretty easy job :)
18:50noncom|2justin_smith: hmm.. how do you think, could such a buffer simply be an agent?
18:50noncom|2w/o c.a
18:50justin_smithnoncom|2: you don't need an agent, your buffer can be immutable
18:50noncom|2ah
18:50noncom|2yes
18:50justin_smithI mean you could ditch c.a and use an agent with a stack, maybe, but c.a has other advantages
18:51noncom|2yeah
19:17notid1is there a library that would make it possible to process clojure code as a datastructure?
19:17notid1i'm trying to write something that will search a codebase for certain function calls
19:20notid1kibit does something similar, but not exactly what I want
19:21justin_smithnotid1: you could check out what eastwood does - it uses tools.analyzer
19:21justin_smith"search a codebase for certain function calls" is definitely a subset of what eastwood does today
19:22justin_smith(eg. it can figure out if a function is called with the wrong number of args)
19:22notid1justin_smith: okay, that might be helpful
19:22justin_smiththere is also slamhound, which is for refactoring
19:23notid1cool. 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:23notid1in the entire project
19:24justin_smithnotid1: but not at runtime, just in the literal source?
19:24notid1just the literal source, yes
19:24justin_smithbecause you could use robert.hooke at runtime to track args
19:24justin_smithcool
19:31notid1justin_smith: slam.hound.aspload is exactly what i'm looking for.
19:31notid1justin_smith: thank you!
19:32justin_smithawesome
19:37neoncontrailsHeh. I love Clojure repository readmes, they're so... literary and metaphorical
19:37neoncontrailshttps://github.com/technomancy/slamhound
22:26CharlesNwhy this (mod (Math/pow 174 55) 221) returns 0.0 ?. The correct answer should be 47.
22:40xeqi,(Math/pow 174 55)
22:40clojurebot1.699059764806151E123
22:40CharlesN, (mod (Math/pow 174 55) 221)
22:40clojurebot0.0
23:11ezehi, is there any gsoc 2016 posible mentor?