#clojure logs

2015-07-08

00:27kschraderttt_fff: https://github.com/omcljs/om/blob/master/src/om/next.cljs
00:27kschrader:)
06:04lokeIs there a library that helps parsing/generating CL-compatible sexps from Clojure? My server-side is written in CL, and the client is written in Clojurescript. I'd like to be able to simply output my CL sexps straight to the client instead of having o go via JSON, which isn't native to either platform.
06:11r4vimaybe there is a CL library to parse EDN?
06:12loker4vi: That would be good too, but I haven't found one.
06:13loker4vi: I just feel that I jump through one too many hoops when using JSON to interchange data between CL and cljs
06:13lokeIt irks my sense of perfection :-)
06:14r4viyeah I can understand why it'd be annoying
06:15lokeI've considered limiting myself to a compatible subset of sexps that work in both, but it's quite limiting. I can basically only use plain lists, integers and keywords (the last one if I mess with the readtable case on the CL side betcause of casing issues)
06:17lokeClojure doesn't support read-time eval, does it?
06:18expezloke: it does
06:19expez,(read-string "#= (+ 1 1)")
06:19clojurebot#error {\n :cause "EvalReader not allowed when *read-eval* is false."\n :via\n [{:type java.lang.RuntimeException\n :message "EvalReader not allowed when *read-eval* is false."\n :at [clojure.lang.Util runtimeException "Util.java" 221]}]\n :trace\n [[clojure.lang.Util runtimeException "Util.java" 221]\n [clojure.lang.LispReader$EvalReader invoke "LispReader.java" 1100]\n [clojure.lang.LispRe...
06:19lokeAh nice
06:21Frozenlockloke: time to write transit for CL? :-p
06:21lokeFrozenlock: what is transit?
06:21Frozenlockhttps://github.com/cognitect/transit-clj
06:22lokeOooh
06:22FrozenlockYou should read the rationale if it's your first contact.
06:23lokeI am. I like it already
06:23FrozenlockThere's a transit implementation for many languages already https://github.com/cognitect
06:23lokeThe limitations of JSON has bugged me for so long that I'm already (after just 30 seconds of browsing the summary) liking it
06:24lokeLooks easy enough. I'll write a parser for this in CL
06:24lokeIf I read this correctly, it supports circular data structures and shared references?
06:25FrozenlockI don't know... I naively use it just to send my EDN everywhere :-p
06:28lokeOK, I'll consider building cl-transit-format.
06:29hyPiRionloke: Clojure itself doesn't really support circular data structures (only through mutable data structures on the underlying platform), so I'd be surprised if that was the case.
06:30hyPiRionDisclaimer: I've not used transit, so I might be wrong.
06:30lokehyPiRion: well, it seems to be able to encode references to other elements.
06:31lokeOh well, I don't need that stuff anyway :-) At least I found a new toy
07:55kwladykahow to do test with not thrown?
07:56kwladyka(is (not (thrown? Exception (board-validation 10 10)))) <- something like that, but it doesn't work
07:56kwladyka(is (board-validation 10 10)) <- and i can't do thing like that because function return nil
07:57kwladykaeventually i can check if it is nil, but it is not exactly what i want to test, test should say not exception thrown
07:58snowellWrap it in a try, then (catch (fail "thrown"))?
07:58kwladykasnowell, is it only one solution? nothing more beauty? :)
07:58snowellHaha that's my quick and dirty "get it to work" solution :)
07:59kwladykai have to write hight quality code for recruitment challenge
08:02kwladykasnowell, but i am afraid this solution is the only one
08:07snowellkwladyka: You could also macroexpand is, negate it, and create your own is-not macro
08:07noidiI don't see why you should check for _not_ throwing an exception
08:08noidiit's implicitly tested by your tests that check the return value
08:08snowell^ Also a fine point
08:08kwladykanoidi, because i am testing exceptions for some functions, and i want some parameter to pass without exception
08:09kwladykanoidi, but testing return value it is not really what i want to test, i want test exception
08:09kwladykawhat if retrun value will change? It will affect test
08:10noidiyes, it will affect the test that would have checked the return value anyway
08:10noidiif you have a function which does not return a sensible return value, but instew
08:10noidibut instead just throws or does not throw an exception
08:11noidiyou can rewrite it to return a boolean value for whether the input was valid or not
08:13kwladykai am creating board for chess and function can get only positive integer
08:13kwladykathere is no real use of this, it is just theoretical problem to solve
08:14kwladykaso i choose exception in situation when inputs are not logic
08:17kwladykaas i know it is in conception of Exceptions
08:19J_ArcaneIs there a core function for producing a function that spits out a static value? Something like identity but for closures?
08:20J_ArcaneI wound up just using (fn [_] true) in a few places today, and it seemed like this might be a thing there was already something for.
08:23snowellJ_Arcane: http://clojuredocs.org/clojure.core/constantly
08:23J_Arcanesnowell: Ahh, thanks. I'll remember that.
08:24gfredericks,(doc constantly)
08:24clojurebot"([x]); Returns a function that takes any number of arguments and returns x."
08:24snowellThat would have been more helpful, yes :)
08:33kwladyka(defn figures-validation [king queen bishop rook knight]) <- how can i check in most elegant way if all input values are integer and > 0 ?
08:34kwladykaI know i can use :as in map input, but is it possible to catch all this input and simple run > 0 for vector with all input or something like that?
08:34kwladykabut still i want check if all was given
08:36gfredericks,(defn pos-int? [x] (and (integer? x) (pos? x)))
08:36clojurebot#'sandbox/pos-int?
08:37gfredericks,(defn figures-validation [& args] (and (= 5 (count args)) (every? pos-int? args)))
08:37clojurebot#'sandbox/figures-validation
08:40kwladykagfredericks, mmm but is it possible to do something like (defn f [a b c d e :as all])?
08:40kwladykabecause i want it to be readable which position is which figure
08:41gfredericks,(defn figures-validation [& [king queen bishop rook knight :as args]] (and (= 5 (count args)) (every? pos-int? args)))
08:41clojurebot#'sandbox/figures-validation
08:41kwladykahmmm.... i thought it doesn't work in that way... ouh...
08:41kwladykathank you
08:41namracool
08:41gfredericksmaybe you forgot the &
08:42kwladykayes i didn't know i can do this like that
08:42gfredericksthe downside to that kind of destructuring is your function can take any number of args
08:43kwladykayes, but still is nice to know about that solution
08:48kwladykahow to use every? with > ?
08:48kwladykais it possible?
08:49kwladykai mean (> 5 3)
08:49kwladykasomething like (every? (> % 0) [1 2 3 4])
08:50snowell(> % 0) => pos?
08:50snowell,(doc pos?)
08:50clojurebot"([x]); Returns true if num is greater than zero, else false"
08:50kwladykaoh...
08:50kwladykaand another solution is anonymous function
08:50namra(every? pos? [1 2 3 4])
08:51namra,(every? pos? [1 2 3 4])
08:51clojurebottrue
08:51namra,(every? #(> % 3) [1 2 3 4])
08:51clojurebotfalse
08:55kwladyka((every-pred pos? integer?) king queen bishop rook knight) <- i end with this line
09:07piranhahey all! That is not strictly on-topic, but maybe somebody can share thoughts on load testing? I'm trying to get Grinder up and running and that process is a bit painful, so I'm wondering what do people use for load testing...
09:09kwladykais any shortcut to make test file in intellij?
10:17justin_smithkwladyka: if the options were integer or nil, you could use #(some-> % pos?)
10:25justin_smith,(map #(some-> % pos?) [1 nil -1 2 nil false 3])
10:25clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.Number>
10:25justin_smithergh
10:26justin_smith,(map #(some-> % pos?) [1 nil -1 2 nil 3])
10:26clojurebot(true nil false true nil ...)
10:26justin_smithsome-> doesn't deal with false, I forgot
11:18zactsmust I use the seq abstraction over the list?
11:18zactss/over/instead/
11:18zactsI guess I'm so newbie that I don't understand the advantage of the seq over plain lisp lists
11:19puredangera list is a seq (seq is a logical list abstraction)
11:21zactswell, ok
11:21zactsbut the seq just adds contextual convenience factors right?
11:22zactshm... I wonder if anyone has tried to modify CL or scheme to have a seq abstraction, as proof of concept in those languages
11:22zactsif you can, help me to grok what the power of the seq means
11:22hellofunkzacts: seq is the traditional lisp api, actually
11:22hellofunkfirst, rest, etc
11:22zactshellofunk: oh yes? hm... that seems interesting
11:23hellofunkthe term "seq" is not traditional necessarily
11:23zactsracket has first, rest, etc.... too... perhaps racket is already using a seq...
11:23zactsoh
11:23zactsok
11:23hellofunkzacts: first, rest and list processing are traditional lisp features... hence "lisp" acronym
11:24zactshow does first, rest, and list differ from cons car and cdr?
11:25hellofunkzacts: clojure conveniently allows you to use the seq api on things that are not sequential, like maps and sets
11:25hellofunkzacts: clojure has cons. car is first and cdr are rest, basically.
11:25zactsoh, I see
11:25zactsso you can access unordered data types, with the same api?
11:25hellofunkzacts: yes
11:26zactsso the seq is mainly a huge convenience...
11:26hellofunkzacts: maps turn key/val pairs into individual seq elements
11:26zactswhich can simplify code
11:26hellofunk,(seq {:a 1 :b2})
11:26clojurebot#<RuntimeException java.lang.RuntimeException: Map literal must contain an even number of forms>
11:26hellofunk,(seq {:a 1 :b 2})
11:26clojurebot([:a 1] [:b 2])
11:27zactsok
11:28clgvI have a pom.xml and a jar file from a 3rd party java library which didnt make it in any maven repository. how do I upload that one to clojars.org now that the scp method is disabled?
11:28tcrayford____@clgv see "uploading to maven" in the clojars wiki: https://github.com/ato/clojars-web/wiki/Pushing
11:30clgvtcrayford____: with that description maven tries to build the jar again...
11:32tcrayford____clgv: not sure how to fix that, sorry. Not a maven expert :(
11:32clgvand luckily that build fails although it is the release archive... O_o
11:50kwladykais similar function like pos? but doing >= instead of > 0?
11:50Bronsano but you can use (some-fn pos? zero?)
11:54gfredericks(complement neg?)
11:55tmtwdis it bad form to use a java library (because you're familiar with it), rather than a native clojure library?
11:55gfredericksnot if you're the only one who ever has to deal with the code :)
11:56clgvtmtwd: if the java library does its job well, use it. there is no need to have a clojure wrapper for everything - sometimes it is even a waste of time
12:15tmtwdso whats the best way of splitting a string by a space into an array of words?
12:16tmtwdnvm
12:16tmtwdi got it
12:20tmtwdwhy does require require a : when defined in a namespace? (:require [clojure.string :as str])
12:22justin_smithtmtwd: false premise https://www.refheap.com/105434
12:23kwladykatmtwd, because first argument of list by default is treated like function call and... yes there is also require function
12:23justin_smiththe ns form allows and encourages :require, but doesn't need it
12:23tmtwdcool
12:23tmtwdthanks
12:24justin_smithI always found it a bit odd that ns encourages the :require form, when require also works and is more consistent with non-ns usage of require...
12:24justin_smithI'm sure there's a good reason I haven't noticed
12:25Bronsajustin_smith: I think require works by accident
12:25justin_smithBronsa: oh, that's as good a reason not to do it that way as any :)
12:25justin_smithBronsa: I guess in a macro (name :require) and (name 'require) give the same result, yeah
12:25clojurebotTitim gan éirí ort.
12:26Bronsajustin_smith: also I think require would be more confusing than :require imho. keep in mind inside the ns you don't need quoting, outside you do
12:26justin_smithtrue
12:26Bronsaat least :require makes it explicit that it's a different thing
12:26justin_smithyeah, but then you get ##(:require 'does-not.exist)
12:26lazybot⇒ nil
12:26Bronsaalso understanding why and how :require is different from require is what made me really understand macros
12:26Bronsa:P
12:27justin_smithheh, I learned those lessons with common lisp, so it's good to be reminded of that
12:29BronsaI understood and used macros in CL for a while before starting clojure, but I never really *got* them until I understood the :require thing
12:41dnolenFinally Chrome will get Clojure syntax highlighting http://src.chromium.org/viewvc/blink?view=revision&amp;revision=198504
12:49johannbestowroushuzzah :)
12:57kwladykaOperation on matrix are optimal?
12:57kwladykai mean about performance
12:58kwladykai need to do algorithm with good performance
12:58justin_smithkwladyka: have you looked at core.matrix?
12:58kwladykaand i am not sure matrix are good way or not
12:59kwladykajustin_smith, not yet. I am thinking how should i count this.
12:59kwladykaThe problem is to find all unique configurations of a set of normal chess pieces on
12:59kwladykaa chess board with dimensions M×N where none of the pieces is in a position to take any of the
12:59kwladykaothers. Assume the colour of the piece does not matter, and that there are no pawns among the
12:59kwladykapieces.
12:59kwladykawow sorry for multilines
13:01kwladykaso i have to create list of chess board MxN and figures combination and counting if one figure can beat down another figure
13:01kwladykai am trying to figure out which mathematical operation will be the fastest for this problem and how should my data look for the best performance
13:02justin_smithkwladyka: yeah, I think there are matrix algorithms for n-queens etc.
13:02justin_smithprobably you want your data in a NxN square matrix
13:02kwladykajustin_smith, it is my first idea
13:04justin_smithkwladyka: you should be able to turn the positions in board x into a projection of moves on board y, and thus turn the concept of a "safe" piece into a zero result after a matrix multiply...
13:04justin_smithof the projected moves against the positions
13:05justin_smithsomething like that...
13:07hellofunkkwladyka: i think Byrd has some minikanren solutions to n-queens problem on his github, which are translateable easily to core.logic
13:07hellofunkwould be worth studying at least
13:11justin_smithof course I'm going with adapter because that's the one ring uses, but still
13:13kwladykajustin_smith, yeah i want do something in that way
13:14kwladykait is good to hear you agree with me :)
13:15kwladykajust i feel i am on good way :)
13:15kwladykahellofunk, but i don't know his nick on github :)
13:16kwladykahellofunk, and it is not Bryd as i see
13:18hellofunkkwladyka: https://github.com/miniKanren/miniKanren_org-website/blob/master/index.html and also http://martintrojer.github.io/clojure/2012/07/11/n-queens-with-corelogic-take-2/
13:20kwladykahellofunk, thx maybe i will get some inspirations after read
13:23hellofunkkwladyka: one of those pastes was supposed to be http://minikanren.org/ which you can then scroll down to see the n queens listings
13:31justin_smithhellofunk: he wanted fastest though, not most convenient for programming
13:32justin_smith(I read it as fastest at runtime, not quickest way to code a solution)
13:33hellofunki read it as "studying techniques to solve the problem"
13:36kwladykai have to find the best readable fastest solution in short time
13:36kwladykajust do this as good as possible in Clojure
13:37kwladyka*short - 7 days
13:38kwladykain free time :)
13:39andyfarrdem: Is it expected that conj.io Clojure 1.7.0 links go to 1.7.0-beta3 ?
13:41justin_smithkwladyka: well, I'll let your level of confidence guide your decision - if you think you can handle it, core.matrix will be much faster, logic programming techniques are notoriously slow
13:42snowellkwladyka: Good code, fast code, easy-to-write code. Pick 2 :D
13:42kwladykagood fast code of course ;)
13:43kwladykaok, i am going train kung fu, see you later and thank you for your ideas
14:18arrdemaw andyf left.
14:24justin_smith$mail andyf is there any plan / roadmap for eastwood doing cljc?
14:24lazybotMessage saved.
14:25justin_smithI made a new all-cljc lib, and was surprised that on my first linting everything passed. In reality, on first linting nothing was being checked...
14:25arrdemheh
14:36justin_smitharrdem: today I learned a bit about how to use :inline function metadata https://www.refheap.com/105437
14:36justin_smithuseless toy example, of course
14:36justin_smithmaybe that would have a place in grimoire
14:36Bronsajustin_smith: you shouldn't use :inline
14:37justin_smithBronsa: oh, OK. I was so pleased to discover it.
14:37justin_smithany particular reason?
14:37Bronsajustin_smith: it's gonna get deprecated
14:38justin_smithdoes the method overload use case have a replacement? Improved static inference maybe?
14:38Bronsajustin_smith: at least that's what I was told when I created a ticket adding :inline for a bunch of predicates in core.clj. not sure if clojure/core changed idea on that though, puredanger will know better
14:38justin_smith(local inference that is, of course)
14:38justin_smithoh, OK, thanks for the info
14:38justin_smith(inc Bronsa)
14:38lazybot⇒ 114
14:39Bronsajustin_smith: http://dev.clojure.org/display/design/Inlined+code
14:39justin_smithoh, nice, thanks for looking it up
14:39justin_smith(inc Bronsa)
14:39lazybot⇒ 115
14:40Bronsanot much there but I'm assuming that's where design work will happen
15:08lodin_Anyone here with experience of https://github.com/zcaudate/ribol?
16:24csd_is it bad practice not to specify a buffer size for a (chan) ?
16:31justin_smithcsd_: I'd say it's normal not to specify a buffer size
16:32hellofunkcsd_: i only specify a size when i expect occasional but temporary bursts that exceed the channel's read speed
16:35csd_ok one more stupid question
16:35csd_is anyone aware of anecdotes of switching from mongo to datomic
16:37hellofunkwell, i knew a guy who knew a guy... this one time, he... let me see if i can remember
16:37csd_:)
16:38justin_smithhellofunk: sounds like you went back to datomic and it dropped your data
16:38hellofunki think the other shoe dropped
16:46TimMccsd_: Like... writing migration scripts? Or adapating the data model?
16:47csd_the latter
19:00chomwitthow can i use a backslash in a string ?
19:01justin_smith\\
19:02justin_smith,(first "\\")
19:02clojurebot\\
19:03chomwitt(str ["\\a"]) => RuntimeException Unsupported escape character: \a
19:03justin_smith,"\\a"
19:03clojurebot"\\a"
19:03justin_smith,(str ["\\a"])
19:03clojurebot"[\"\\\\a\"]"
19:04chomwitt,hi
19:04clojurebot#error {\n :cause "Unable to resolve symbol: hi in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: hi in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: hi in this context"...
19:05chomwittsorry for that..
19:26andyf_justin_smith: I definitely want to enhance Eastwood to read and lint .cljc files, too, but as you discovered, today it ignores the contents of any files without a '.clj' suffix.
19:26andyf_No target date for that. Work has been pretty busy lately, so Eastwood work has been on the back burner for a while.
19:27andyf_I will at least add something to the README mentioning the lack of linting in .cljc files.
19:28R0B_RODHi anyone running Gentoo and have install Leiningen?
19:28elvis4526what are your favorites sql libraries ?
19:29elvis4526R0B_ROD: Just download it from the official website
19:30elvis4526put this in your $PATH https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein
19:31elvis4526and thats about it.
19:33R0B_RODhttps://bpaste.net/show/0a4b36df510d
19:33R0B_RODsorry
19:34elvis4526wrong c/p ?
19:34R0B_RODwrong chan
19:34elvis4526ah
19:35elvis4526idk about this particular overlay, but the only linux distro i've seen with lein packaged was arch.
19:37R0B_RODelvis4526: Thanks... I got it to work now missed a step in my config
19:42elvis4526ahh
19:43andyf_Possibly off-topic, except that there are now Clojure 'rooms' on Slack -- is Slack basically IRC plus built-in logs and easy searching?
19:43elvis4526basically yeah.
19:43hiredmandon't forget the hype
19:44hiredmanirc has none
19:45troydmhehe
19:46troydmu can connect to slack via IRC gateway
19:48andyf_I mean, built-in logs and easy searching are valuable things, granted. Not trying to diss it. Just wanted to know if there was more to it than that.
20:23arrdemandyf_: hey
20:23arrdemandyf_: so that's a known issue with the version sorting code. the /LATEST/ URL segment is missbehaving because it things that -beta3 is > the release.
20:24arrdemandyf_: as a workaround if you hard code /1.7.0/ in instead that'll work just fine
20:24arrdemhyPiRion: so what's required to put a dent in leiningen#1816?
20:25arrdemit doesn't seem like lein has a way to tell that classfiles are "clean" besides the proposed "don't rebuild" flag.
20:43andyf_arrdem: Understood. I had a similar bug in some code for creating graphs for the Clojure expression benchmark results. I probably have a custom version comparator function in there somewhere. Either that or I punted on the issue by using something like 1.7.0-final as a hack.
20:44arrdemandyf_: yeah I hear ya. gonna try and work on that tonight or tomorrow depending on the status of other yaks
20:44arrdemWill try and get that fixed for the new cheatsheet tho
20:48andyf_Ooooh. Project idea: web site showing hair length of various yaks in your pasture, to help you decide which one to shave next ...
20:48arrdemhehe
20:49arrdempoll github's issue and stars count
20:49justin_smithandyf_: combine it with cow clicker and make bank https://www.facebook.com/dialog/oauth?client_id=111596662223307&amp;redirect_uri=https://apps.facebook.com/cowclicker/default.aspx
20:49arrdemhair length is number of stars or maven downloads times issue count
20:49arrdemmaybe with some time factor since last release and commit
20:50justin_smitharrdem: hair length is number of PRs on the project, exponentiated by age
20:50arrdemjustin_smith: haha
20:51justin_smithcow clicker was designed to be a critique of facebook games, became successful facebook game http://www.wired.com/2011/12/ff_cowclicker/all/1
20:55andyf_cow clicker is no Progress Quest. You actually have to click on stuff.
21:19SeyleriusAre there clojure libs for managing virtual machines?
21:31justin_smithSeylerius: I know puppet uses clojure, and I think it has some clojure bindings, if that counts
21:32SeyleriusHmm...
21:32justin_smithSeylerius: also I know some puppet labs folks that hang out here time to time
21:32Seyleriusjustin_smith: I'll keep an eye out. One of my projects involves spooling up virtual machines on demand that download arbitrary files from the web and run tests on them.
21:33justin_smithSeylerius: maybe this https://github.com/puppetlabs/puppet-server
21:35SeyleriusInteresting.
21:35SeyleriusThanks for the tips.
21:35Seylerius(inc justin_smith)
21:35lazybot⇒ 272
22:01lucienjoin #racket
22:01lucienI think I spend more time reading about programming than programming
22:35elvis4526what's the official way to write docstring in clojure ?
22:35elvis4526I'm trying to use codox and it doesn't seem to parse my docstring.
22:36elvis4526ah the vector containing the arguments must be AFTER the docstring
22:37justin_smithelvis4526: yeah, this is because of multiple arities
22:37justin_smithyou still need to have just one doc string
23:00TEttingerlucien: it's uh more fun the other way
23:01TEttingerre: spending more time reading about programming than programming
23:02lokeDepends on what one reads
23:02TEttingerI don't think either is as fun as code golf
23:02lokeTEttinger: Yeah, that's fun. Especially to look at people trying to get their solutions down below, say, 100 characters and then come in and post a 15 character APL solution. :-)
23:04TEttingerI'm curious about making an APL style library for Clojure, actually. I tried once a long time ago
23:04TEttingernot the one-char names so much as the behavior around rank
23:08TEttingerI think being able to use clojure's existing collection-affecting fns for flat or irregularly nested sequences, and an array programming approach (likely using core.matrix) for stuff that fits that would be nice
23:14lokeTEttinger: I've had the same though, but using Common Lisp
23:14lokeBut I would write an APL language parser on top of it
23:55elvis4526Is there a way to use slashes in function names ?
23:56elvis4526yeah okay that's a dumb question - sorry