#clojure logs

2014-06-28

00:42ivandid any of the 54 people who retweeted https://twitter.com/mikeflynn_/status/482251458742472705/photo/1 check https://www.chrome.com/cubelab#tech
00:47yediclojure is gone from there?
00:49caternwas it shopped?
00:50caternyes
00:50caternit must have been
00:50caternClojure isn't in all caps and the rest are
05:00sverihi, 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)
05:15clgvsveri: it's likely that you have to specify that config file somewhere, isn't it?
05:17svericlgv: yea, I just found it, it has to be in the resources folder of jig
05:17sveriI think the documentation is a bit misleading here, however, looking at the code, things clear up, as most of the times :D
05:18clgvsveri: oh so it's rellay config at build time and after that it is "hard" to change without a rebuild
05:19svericlgv: I think so
05:20clgvsveri: every time I take a look at jig's docs it seems not that "simple" as advertised
05:24svericlgv: 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
05:25svericlgv: 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
05:25clgvsveri: what's that about the user.clj?
05:26svericlgv: https://github.com/juxt/jig#userclj
05:27clgvah ok.
05:27clgvstrange. why could jig just use any *.jig.* namespace?
05:27svericlgv: that was my first thought too, I immediately opened an issue for this as I read it
05:28sveriany kind of application with some sort of user management will have a user.clj file on the classpath
05:29clgvsveri: another strang thing. it is not a proper library right? otherwise why would I have to clone jig itself?
05:29clgvsveri: no I think they only mean a toplevel user.clj
05:29clgvsveri: that's special stuff from leiningen which seems to be supported by tools.namespace as well
05:29svericlgv: I am not sure about it, could be
05:29magopianis "Christophe Grand" around here?
05:30svericlgv: I think the documentation is not explicit enough about it and leaves some doubt for me
05:30clgvmagopian: sometimes as "cgrand" (or cgrande?) but apparently not right now
05:30magopianI 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 ;)
05:30magopianclgv: ok thanks);
05:30magopianthanks ;)
05:36clgvsveri: did you clone that jig repo to use it or did you just add it as dependency to your project?
06:14svericlgv: I cloned it, like the docs said
06:16clgvsveri: from different project it seems it could be used a normal lib. so they'd just make a leiningen template replacing the clone advice
06:18svericlgv: I am not sure about that, did you find docs for this usecase? this would benice too I guee
06:18sveri*guess
06:18clgvsveri: no docs, but other project from the "juxt" user on github
06:53svericlgv: you mean that modular project?
06:54clgvsceri: I meant that one https://github.com/juxt/juxt-accounting
06:58clgvsveri: ^^
07:07svericlgv: I see, I was always wondering if you could add jig as a dependency
07:07clgvsveri: the only sane way if you ask me ;)
07:08svericlgv: yea, otherwise every member of your team has to setup jig himself
07:38leylujhello?
07:38clojurebotBUENOS DING DONG DIDDLY DIOS, fRaUline leyluj
07:39leyluji just saw closure, i was aking mr bot where can i use closure?
07:40ddellacostaleyluj: Where can you use the language Clojure?
07:40ddellacostaleyluj: anywhere you got a JVM handy I guess. :-)
07:41leylujso its a java kinda language ddellacosta?
07:41leyluj:)
07:41ddellacostaleyluj: 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.
07:42ddellacostaleyluj: 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
07:43leylujoh okay, im just starting out learning new stuff this 3 months and i saw clojure ... ddellacosta
07:43leylujwhere can i apply it ? web apps? desktop apps? mobile apps?
07:43ddellacostaleyluj: 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.
07:43kungi_leyluj: There is http://cljsfiddle.net/ where you can play around with clojure
07:43ddellacostaleyluj: 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.
07:44ddellacostaleyluj: You can write GUI apps with it as well, for example using SeeSaw: https://github.com/daveray/seesaw
07:45ddellacostaleyluj: 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
07:45leylujthank you ddellacosta... im loving the community already ..
07:45ddellacostaleyluj: :-)
07:46leylujlemme go play with it and check on you laters cheers ... thanks once again
07:46ddellacostaleyluj: cheers, enjoy, and come back if you have questions.
07:47ddellacostaleyluj: this is a great place to start, btw: 4clojure.org
07:47leylujaight then ddellacosta ... lemme hop on it
08:05clgvddellacosta: though it is more the Clojure statup time thats a problem compared to the JVM startup time ;)
08:06ddellacostaclgv: right, correction! leyluj ^
08:06clgvhello?
08:06clojurebotBUENOS DING DONG DIDDLY DIOS, fRaUline clgv
08:07clgvok he says fräulein all the time ,)
08:07ddellacostaclgv: you're lucky, clojurebot and I aren't on speaking terms
08:07ddellacosta,(println "don't make me cry clojurebot")
08:08clojureboteval service is offline
08:08clgvyeah, read it some days ago ;)
08:09clgv,(println "don't cry.")
08:09clojurebotdon't cry.\n
08:09clgvoops forgot the name^^
08:09ddellacostahahaha
08:09clgvI liked the time when you could initiate a bot conversation like that ;)
08:36ocharlesHi folks, having to do packaging stuff for work and I need to download a jar manually from Clojars - is that possible?
08:37ocharlesI'm not really a Clojure developer, I'm just helping out with some deployment stuff :)
08:37ocharlese.g., how would one get the jar for https://clojars.org/lein-cljsbuild/versions/1.0.3 ?
08:42clgvocharles: https://clojars.org/repo/
08:43ocharlesah, perfect! thanks clgv
08:43clgvocharles: but why not use leiningen or at least maven?
08:44ocharlesclgv: somewhat a long story, but we do at the moment
08:44ocharlesWe use NixOS at work, which means that most of our builds are ran from clean environments - so every build requires downloading all dependencies
08:44ocharlesI'm hoping to optimize that out, by moving the dependency resolution into the package manager itself
08:45ocharlesIt may end up being more pain than just waiting a little for lein to download dependencies, but I still want to explore it
08:56nathan7ocharles: Cool, never heard of anyone actually using NixOS in prod
08:56ocharlesWe're something of a rare breed :)
08:56ocharlesBut I don't know why, it makes an awful lot of sense
08:58nathan7Yeah, I dislike the Nix package language a bunch, but I love the concept
08:58noogahi, 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?
08:58p_lnathan7: there's scheme-based toolkit on top of Nix
08:58ocharlesnathan7: yea, the language itself is so-so
08:58ocharlesnathan7: you know of guix too?
08:58nathan7ocharles: no, haven't heard of that
08:59ocharlesThat may be more up your street :)
08:59nathan7interesting
09:05btcNeverSleeps,(+ 2 3) ; testing the bot's syntax before asking a question
09:06clojurebot5
09:06btcNeverSleeps,(disj (into #{} (range 1 12)) 7 9) ; ok, works fine
09:06clojurebot#{1 4 6 3 2 ...}
09:07btcNeverSleeps,(let [v [7 9]] (disj (into #{} (range 1 12)) v)) ; <- doesn't do what I want
09:07clojurebot#{7 1 4 6 3 ...}
09:08btcNeverSleepsbecause 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)
09:11nathan7apply
09:11nathan7(apply disj (set (range 1 12)) v)
09:11nathan7,(let [v [7 9]] (apply disj (set (range 1 12)) v))
09:11clojurebot#{1 4 6 3 2 ...}
09:12btcNeverSleepsnathan7: ah great, thanks
11:36sandbagsCan anyone tell me how to get a ring server to log incoming requests to the console?
11:36sandbagsi'm searching but can't seem to find any option for this
11:37ddellacostasandbags: you could try this: https://github.com/pjlegato/ring.middleware.logger
11:38sandbagsddellacosta: thanks... i guess having a middleware do it makes sense, kind of
11:38ddellacostasandbags: it's also pretty simple to just write a tiny little middleware layer to dump out requests using a logger
11:38ddellacostayeah
11:38ddellacostasandbags: what other way would you think may make sense?
11:38sandbagsddellacosta: well logging is kind of an essential function of a server and there's not a huge amount of magic to it
11:38sandbagsi'm just surprised its not baked in
11:39ddellacostasandbags: 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:40sandbagsit's not a big deal, i was just surprised is all
11:40ddellacostasandbags: I guess you could probably also set up logging defaults for Jetty too
11:52halogenandtoastIs 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:55Frozenlockhalogenandtoast: You could maybe use 'mapv' if you don't want 'into []'
11:57halogenandtoastFrozenlock: Sure enough that seems to work, now I need to understand why. Reading up.
11:58halogenandtoastmapv is also not lazy it seems.
11:58halogenandtoastWhich is good because I don’t want a lazy sequence.
11:59Frozenlockmapv is a shorthand for (into [] (map ...
11:59ticking_halogenandtoast: If you don't want lazyness use reducers.
11:59ticking_they will give you a significant performance boost
12:00halogenandtoastticking_: 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:00ticking_Frozenlock: only when applied to more than one collection. In the simple case it even uses transients so it should be rather fast.
12:01ticking_https://github.com/clojure/clojure/blob/028af0e0b271aa558ea44780e5d951f4932c7842/src/clj/clojure/core.clj#L6344
12:01ticking_halogenandtoast: mapv is your friend then
12:01Frozenlockticking true
12:01halogenandtoastdoes the v stand for vector in this case?
12:01ticking_yes
12:02halogenandtoastCool
12:03halogenandtoastOff to the smorgasburg, thanks ticking_ and Frozenlock
12:07nathan7ticking_: how's life?
14:34travisrdoes anyone have insight as to why re-match, without wildcards doesn't automatically substring the string under test?
14:35travisrala grep...
14:36ticking_travisr: because re-find has that behaviour?
14:36travisre.g., if I have a regex expression #"cat", this will not match: "somecathere"
14:36travisrthe question was why.
14:36travisr@ticking_ ^
14:37ticking_that is why
14:37ticking_travisr: clojure regexes are just thin wrappers around java regexes
14:38ticking_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:38travisrthanks... I will look into that...
14:38ticking_http://docs.oracle.com/javase/7/docs/api/java/util/regex/Matcher.html
14:39ticking_So if you want grep like behaviour use re-find, otherwise use re-matches
14:39travisrgot it... thanks
14:40travisrthanks... that is perfect.
14:40travisri just tried it and it works exactly as you've said.
14:40travisrthanks again
14:41ticking_youre welcome ^^
14:41metellus(inc ticking_)
14:41lazybot⇒ 1
15:02Frozenlock(dec so)
15:02lazybot⇒ -30
15:51Shayanjmif 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:51Shayanjmor should I be creating more general functions which take the atom as a parameter?
15:53jeremyheilerShayanjm: i'd create the general functions
15:54jeremyheileralso consider how you'll test the functions
15:55ShayanjmSure, that's fair
15:55Shayanjmthanks
15:56jeremyheilerif the requirements change and suddenly you'll need two atoms, then you'll probably be grateful for having the general functions.
15:57bbloomif you can help it, i'd avoid taking atoms at all
15:57benkayif 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:57bbloommake the functions totally pure
15:57bbloomand use them with swap!
16:01martinklepschcount will exhaust a lazy seq right?
16:01bbloom(doc count)
16:01clojurebot"([coll]); Returns the number of items in the collection. (count nil) returns 0. Also works on strings, arrays, and Java Collections and Maps"
16:01bbloomoh, i thought it documetned that
16:01bbloommartinklepsch: but yeah, it will
16:01bbloombut note that "lists" are counted in constant time
16:01bbloom(doc counted?)
16:01clojurebot"([coll]); Returns true if coll implements count in constant time"
16:01bbloom,(counted? (list 1 2 3))
16:01clojurebottrue
16:02bbloom,(counted? (lazy-seq (list 1 2 3)))
16:02clojurebotfalse
16:07benkaycaching? ring? anyone?
16:09Jaoodbenkay: why don't you use nginx for that?
16:10benkaynaively, 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:11benkaythat *ring*, using jetty...
16:12benkaymind you, i know next to nothing about how jetty works under the hood. i'm blessed with well-written wrappers.
16:13benkayam i completely off my rocker, Jaood ?
16:13seangrov`Anyone know if fressian can compress native clojure data structures with structural sharing?
16:13seangrov`(pr-str ..)-ing the data is madness, it balloons horribly
16:14bbloomseangrov`: fressian is primarily about streaming, it only caches some number of recently printed values
16:14bbloomi think it's like 90-something
16:14bbloombut i too have wanted full interning
16:15bbloomalso unfortuantely, internal data types (like red/black nodes) aren't exposed in any meaningful way with equality or hashing or anything like that
16:15Jaoodbenkay: 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:15bbloomso there's no good way w/ standard clojure structures to recover internal sharing
16:17benkayJaood: i may be engaging in premature maloptimization ;)
16:17seangrov`bbloom: Yeah, I was worried about that
16:18bbloomseangrov`: unfortunately, your options are pretty limited for general purpose solutions... you'll be best off just writing a custom serialization transform
16:19benkayanother 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:22seangrov`bbloom: So many cool features that could be realistically enabled if the structural sharing wasn't opaque
16:22seangrov`Maybe I'll give it a go in a few weeks
16:23bbloomseangrov`: yes. big time. i've really wanted that
16:23bbloomseangrov`: as is, you'd basically have no choice but to re-implement all the main data structures
16:23bbloomalso, there's a trade off between "hash-cons" style creation and deferred recovery of sharing
16:24bbloomin the former, you achieve perfect sharing, at the cost of reduced construction rate
16:24bbloomin the later, you pay a pause cost in a GC-style transform that recovers sharing
16:25seangrov`Aren't the cljs data structures using hash-cons style?
16:25bbloomseangrov`: no
16:25bbloomto do hash-cons-ing you need a lookup table
16:25bbloomwhich would prevent GC in js (no weak refs)
16:29seangrov`bbloom: How about jvm-clj then?
16:30bbloomseangrov`: nope. it's the wrong trade off for functional programs
16:30bbloomyou want high construction rates
16:30seangrov`Ah, makes sense
16:30bbloomit's the classic space/time tradeoff analogous to ref counting & tracing GC
16:40sveriocharles: you could take it from .m2 folder after having declared a dependency on it
16:43sveriocharles: you could also clone the commit of the specific release and build a jar yourself with lein jar
16:44arohneris 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:44arohnerand I've used lein credentials and :env/foo without trouble before
16:50arohnersigh, password vs. passphrase
17:01benkayarohner: i usually download datomic, and then bin/maven-install - is that what you're doing?
17:01arohnerno, I added "my.datomic.com/repo" to lein repos
17:01benkayi had no idea that was even a thing
17:01arohnerinstructions are at https://my.datomic.com/account
17:03benkay*sigh* another password reset...
17:06benkaymakes 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:16gastoveAnybody 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:26Shayanjmif 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:28gastovereflect
17:28gastoveWhoops, wrong window, sorry.
17:28Shayanjmhttps://gist.github.com/shayanjm/e5ebf21a4d57c84a4718
17:31arohnerclojurebot: ~anyone
17:31clojurebotCool story bro.
17:31arohner~anyone
17:31clojurebotJust 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:32arohnergastove: https://github.com/arohner/clj-wallhack/blob/master/src/wall/hack.clj has some examples of using reflection
17:33gastoveHa. Thanks for the pointer, arohner.
17:33Bronsasi`
17:34gastovearohner: and thanks for the github link!
17:34arohnernp
17:35gastoveTrying 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:36arohnergastove: look at wall.hack/method "obj - nil for static methods"
17:39gastovearohner: Cool, I'll poke at that.
17:45Shayanjmif I have a map {:thing "something" :content "realcontent" :secondthing {:thirdthing "another thing" :content "something again"}} (for example)
17:46Shayanjmhow do I identify and string together :content all the way into the nested map?
17:46Shayanjm(assuming the nested map is of unidentified structure and could have more than just 2 layers)
17:52kristofShayanjm: you could flatten it first
17:53kristofAnd then... bazam! Just pretend like it's a simple hash map.
18:20TravisDemacs
18:20TravisDoops.
18:28kristofNot-ur-term-m8
18:28kristof(decf TravisD)
18:28kristof(dec TravisD)
18:28lazybot⇒ 2
18:28kristof:)
18:28TravisDhehe, ouchies
18:41noncom|3please 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:46kristofWhy would that be bad?
18:52noncom|3because 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:52noncom|3does that make sense?
18:52TravisDkristof: I guess if there are multiple modules in the library, it can be difficult to figure out where things are defined
18:52noncom|3or am i missing something?
18:53kristofthat does make sense
18:53kristofbut that can't be too hard
18:53noncom|3personally i would consider (use) or (require :refel-all) an antipattern
18:54benkaygrep can help with those situations, noncom|3 ;)
18:54benkayjokes aside, i'm totally with you.
18:54TravisDI 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:54benkaywouldn't that be an unpattern?
18:54noncom|3that 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:54benkaynoise?
18:55benkaynoncom|3: yeah, you defo want to avoid use in your own code
18:56benkayalso i try to save my limited supply of punches-through-the-internet for the ecmascript implementors.
18:56noncom|3haha :D
18:56benkayand everyone who ever wrote a django app that survived to become legacy code (including myself)
18:57noncom|3oh yes, in that land, there is even more of that kind of badness ...
18:58benkaynoncom|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:58benkaybut your tastes may vary.
18:58benkayand mileage.
18:58noncom|3i agree with you..
18:59noncom|3but now we are long past deadline and studying these wonderful pieces of code inside does not make me any happier..
18:59benkayhahahaha
18:59noncom|3:)
18:59benkaycarry on, soldier
18:59benkayme, i'm going to have another bloody mary.
19:00noncom|3thanks :)
19:52nooniannoncom|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:55noncom|3noonian: thanks for the advice, gonna check it out!
21:27echo-areaI 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:28echo-areaUsing of dynamic var in this scenario seems natural and proper to me. What do you think?
21:31technomancycan't use metadata?
21:33echo-areaThat information also depends on the context
22:53gastoveHi 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:55gastove(The specific problem I need to solve is: I need to call a static method on a java class stored in a variable.)
23:08gwsgastove: are you able to paste a snippet of what you're doing?
23:09gastoveSure -- give me a second to put together something comprehensible.
23:09gastovePart 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:19gastovegws: Here we are. https://gist.github.com/Gastove/b083083f22d7f198d964
23:43gastoveOr, if you like: http://stackoverflow.com/questions/24472968/invoke-a-static-method-on-a-java-class-stored-in-a-var