#clojure logs

2015-07-16

00:02TEttinger,(boolean 0)
00:02clojurebottrue
00:02TEttinger,(boolean (/ 0.0 0.0))
00:02clojurebottrue
00:02TEttinger,(if Double/NaN true "wat")
00:02clojurebottrue
00:07whompis traversal of a set as a sequence deterministic?
00:25tomjackwhomp: I _think_ (= (seq xs) (seq xs)), but definitely not necessarily (if (= xs ys) (= (seq xs) (seq ys)))
00:36vasSo I want to make a "remember which page the user requested and forward them after they log in" feature
00:39H4nsvas: popular solutions include including the original url in the login form as hidden parameter, in a query parameter of the login page, using an extra cookie or storing the url in the user's session if you already have session tracking set up at that point.
00:40vasH4ns: thank you so very much. My login system is a bit different in that a user just gives me their email and I send them a login link which they must click to login. I'm going to try setting a session variable and see if that does the trick (assuming the user uses the same browser for both accesses)... perhaps it makes sense to encode it into the login link.
00:42H4nsvas: a session variable is unlikely to work unless you have persistent sessions and can refer to them through the url that you send out. i'd just use a parameter in the url.
00:44H4nsvas: ah, i did not read carefully. anyway, an extra parameter will be more robust. you could also store the "initial url" in the user's record in the database if you want to avoid the extra parameter.
00:49vasH4ns: Thanks, that makes sense. I think I'll just tag it onto the link. I'm avoiding database reads/writes by just checking a hash in the provided link/URL instead of reading to see if the user has the credentials so avoiding a db read would be in keeping with that.
00:50vasH4ns: there is an initial read to make sure the user has the right privs and all when they request a link, but the handler just checks a hash (which can only be received with proper creds). ... dunno if i explained that well enough but you might get the picture
00:52crocketHello clojour guys
00:52crocketmultimethod rocks.
00:52crocketIt lets me code polymorphic behaviors without types.
00:57vasH4ns: anyway, thanks for your help :D
00:57H4nsvas: yw
01:12bchamCan someone help me?
01:12bchamI can't seem to find why these two functions aren't equivalent
01:13bcham(defn clean-code [class-name]
01:13bcham #((html/wrap :pre) (html/wrap :code '{class (str "src" class-name)}) (html/text %)))
01:13bcham(defn clean-code [class-name]
01:13bcham (fn [x] ((html/wrap :pre) ((html/wrap :code '{:class (str "src " class-name)}) (html/text x)))))
01:13bchamwhy aren't those equivalent?
01:21crocketbcham, Do you want (= f1 f2) to return true?
01:22bchamI get an arity issue when I use the first one in another function, but not if i use the second function
01:22crocketPlus, your functions are awfully difficult to read.
01:22bchamand I can't seem to figure out why.
01:22bchambaby steps crocket :)
01:23bchamI don't want to functions themselves to be equal, rather i want what they do to be equal.
01:24crocketThey are not equal
01:25bchamempirically I know that, I'm wondering why.
01:25crocketbcham, I formatted those functions in emacs clojure-mode, and I got http://dpaste.com/1KTZV06
01:25crocketThey are not equal.
01:25crocketYou got parens wrong.
01:26crocketAlso, there are other differences.
01:26crocketYou should look for differences.
01:26bchamwhat's the hot key to format in clojure-mode?
01:26bchamI will thank you.
01:26crocketbcham, tab
01:27crocketbcham, You should seriously learn emacs.
01:27bchamI use emacs
01:27crocketI don't think you use emacs effectively.
01:28crocketBy the fact that you don't know how to use TAB in emacs, I think you're a newbie.
01:28bchamI am.
01:28amalloycrocket: this is not very welcoming behavior
01:28crocketAnd, you should use a pastebin to paste codes.
01:29bchamThank you for the feedback, as I sated above. I'm just learning. "Baby steps" means I don't know what I'm doing, and am trying to figure it out.
01:30amalloybcham: you're doing just fine. do keep in mind refheap.com for pasting larger snippets in future
02:11crocketHow do I call a function whose symbol obtained by (symbol "log" "info")?
02:12H4nsif you're thinking clojure.tools.logging/log, then that is a macro and cannot be called.
02:12crocketno
02:13crocketIt's taoensso.timber/info
02:13crocket(require '[taoensso.timber :as log])
02:14rpaulo_is there any lisp language that you can compile and deploy?
02:14TEttingerrpaulo_: sorta an odd question, what do you mean by deploy?
02:14rpaulo_I'm looking for something small that can be run standalone on a server
02:15H4nscrocket: ((resolve (symbol "log" "info")) [arg])
02:15rpaulo_i.e., without installing the actual VM (it would be bundled in the file)
02:15TEttingersmall as in language or small as in installation requirements?
02:16rpaulo_installation requirements
02:16TEttingerthere are almost certainly Common Lisp implementations that produce somewhat small binaries. there's more work done at the embedded-ish hardware field with Scheme variants than Common Lisp ones.
02:17rpaulo_scheme would work too
02:17TEttingerI'd look into Chicken Scheme and maybe Gambit Scheme
02:17TEttingerI'm no expert there though
02:17rpaulo_nice, thanks
02:27crocketH4ns, good
02:55crockethttp://dpaste.com/2G6Y88A is a config file for DDNS client I'm writing.
02:56crocketI want a function named update! to behave differently according to provider name.
02:56crocketHow should I implement it?
02:56H4nsso you're doing the resolve/symbol thing to log at the correct level? sounds gross.
02:56crocketProtocol + record, multimethod, or ???
02:56lazybotcrocket: How could that be wrong?
03:00crockethmm....
03:00crocketCurrently, it separates provider name from config.
03:00crocketThis justifies passing two arguments to a multimethod.
03:07crockethttps://github.com/crocket/clj-ddns-client/blob/master/src/clj_ddns_client/providers/dnsever.clj#L28
03:07crocketI feel that this is wrong.
03:08crocketWhy should I have to pass the name of provider to a log function?
03:08crocketI shouldn't have to
03:19crocketOk, this is ok.
04:09crocketWow
04:10crocketIs there an eager version of map?
04:12crocket(doall (map...
04:40crocketDo you usually avoid dynamic vars?
04:49magnarscrocket: if you want an eager map, you could use mapv - but maybe you are doing side-effects and should look at doseq?
05:37PupenoIs it possible to somehow resolve a symbol to the namespace it is located in lexically, and not dynamically? Inside the namespace korma.db I'm doing this (ns-resolve 'korma.db (symbol protocol)) and I would like not to have to repeat myself with korma.db there.
05:42oddcullyPupeno: just `resolve`?
05:43Pupenooddcully: that resolves to the current dynamically scoped namespace, not the lexically one.
05:44Phoh4angSo I've tried clojurescript with figwheel+cider and it's totally awesome, everything works, super cool! But now I want to have not only cljs repl, but the clojure one too. I'm not sure how can I get one more repl buffer in cider without starting another jvm process. Can anybody give a direction?
05:45Phoh4angPupeno: there is no such thing as "lexical namespace". I guess you are writing macro; google about &env and &syms hidden arguments.
05:46PupenoPhoh4ang: no, I'm not writing a macro, I'm calling a function by having the name on a string. Since there's no lexical namespace, I'll have to hard-code it.
05:47Phoh4angPupeno: I'm not sure what do you mean... So you have to call a function by its name given as a string, and the function is defined in a let block?
05:47Phoh4angSo (let [foo (fn ...)] (magic "foo")) something like this?
05:47PupenoPhoh4ang: no, the function is a top level function in the namespace 'korma.db.
05:48Phoh4angPupeno: well then you don't need anything "lexical" at all, just use ns-resolve or whatever.
05:49PupenoPhoh4ang: well, with ns-resolve I have to specify the namespace 'korma.db when this function I'm writing is already in the 'korma.db namespace and I was hopping to be able to infer it (so that for example, if the name of the namespace changes, it doesn't break).
05:50Phoh4angPupeno: eh, what's wrong with just `resolve` then?
05:51PupenoIf I'm in namespace foo.bar and I call korma.db/db-uri and db-uri evaluates (resolve :func), it evaluates to foo.bar/funk, not korma.db/func. I want korma.db/func.
05:51Pupeno(db-uri is the function I'm writing)
05:52Phoh4angAh, you have a function, not a macro, right. Well just save the *ns* somewhere when you defining your function.
05:52Phoh4angLike (let [my-ns *ns*] (defn my-fn ...)) or something similar. It should work, if I undestand thing correctly.
05:57Phoh4angPupeno: yep, just quickly checked it: https://www.refheap.com/106617 that's what you want, right?
05:57PupenoPhoh4ang: yes.
05:58PupenoPhoh4ang: I don think the loss in readability of having a defn inside a let is not worth the gains in the case the namespace name changes or something like that.
05:59PupenoPhoh4ang: but it does answer my question.
05:59Phoh4angPupeno: well, having defn inside a let doesn't reduce readibility at all in my opinion.
06:00PupenoI can see that. I'm contributing to someone else's code, so I'm trying to stay as readable and clean as possible
06:02Phoh4angOh, I see. Actually it's kinda interesting. I can't imagine why such weird thing with all that resolving stuff is required.
06:04PupenoPhoh4ang: in korma.db there's a set of functions named after database protocol, postgres, mysql, oracle, etc. They enhance a database connection specification with some sane defaults. I'm making a function that takes a jdbc uri (instead of a hashmap with user, pass, host, db, port, etc) and calls the appropriate function, mysql, postgresql, etc. So I'm extracting the name of the function I'm calling from the jdbc uri: ht
06:04Pupenotps://gist.github.com/pupeno/bc0363f61e0da2d73da4
06:09Phoh4angPupeno: hm, I see. That makes sense, though imho it would be somewhat clearer to explicitly define these functions with a special macro which would maintain a map of strings->functions.
06:09Phoh4angOn the other hand, less code is better.
06:21Akshaywhy clojure not lisp
06:21Akshay??
06:21lazybotAkshay: What are you, crazy? Of course not!
06:21clojurebotBOT FIGHT!!!!!111
06:25lokeNote that Akshay just asked the opposite thing on #lisp
06:25oddcullywhat was the bot response there?
06:28lokeoddcully: No bot response.
06:28ronh<loke> There are no benefits to clojure compared to Lisp
06:28lokeYep
06:28oddcullythen clojure wins clearly in terms of bot hilarity
06:28lokeoddcully: Indeed
06:28lokeI somewhat intentionally fed the troll
06:29tdammersbot hilarity is strictly the most important factor in a programming language's success
06:29loketdammers: the #lisp bot used to do meme quotes
06:29lokeLike doge
06:29H4nsback in the day, when it still worked
06:29lokeSince it doesn't do that anymore, I guess that's the death of lisp :-(
06:31tdammersdeath of lisp... not again...
06:34loketdammers: None of us want that, I think. Therefore the #lisp bot must immediately be fixed.
06:34H4nsloke: you can discuss #lisp's problems in #lisp, i guess :)
06:34lokeH4ns: Yes
06:35lokeH4ns: But you'd kick me if I did :-)
06:35H4nsloke: i got no ops and with my temper, it is good that way
06:48crocketless is better
07:14crocketDoes anyone know a good clojure logging library than timbre?
07:14crocketDoes anyone know any other good clojure logging library than timbre?
07:14crockettimbre doesn't have a decent rolling appender.
07:17oddcullyunilog?
07:21crocketunilog?
07:22crocketunilog uses logback.
07:22crocketan uberjar would have to include logback as well.
07:33crocketSo, I'd have to choose between small and big.
07:40xificurCyesterday I got a recommendation for fighweel and react from justin_smith. Can anyone point me to some nice guide to cljs in general and possibly these libs? I did clojure for a couple of months when it was 1.3 so I'm not completely clueless, but not up to speed either
07:41kwladykaif i want to do random test x times should i use "dorun" or is there something better?
07:43oddcullyxificurC: have you seen the figwheel quickstart? https://github.com/bhauman/lein-figwheel/wiki/Quick-Start
07:45oddcullyxificurC: there are lots of libs around react (om, reagent, rum, ...)
07:45oddcullyxificurC: also clojurescript has it's own irc channel - just fyi
07:49xificurCoddcully: no I haven't, and that actually links to a quick start for cljs as well, thanks
07:58kwladykahttps://www.refheap.com/3fc8e81c4cf03e0631232fb53 - how to run this test x times? The problem is when i do (dorun x (deftest)) or (deftest foo (dorun x (testing))) etc. it wouldn't work because deftest has to be first and is has to be first in testing etc.
08:14noncomkwladyka: what?
08:15noncomkwladyka: can you describe more? i don't get your question
08:15kwladykanoncom, i want run this test x times, how to do that?
08:15kwladykait is random test so i want run it more then once
08:16kwladykaand it is not so simple as it looks :)
08:17noncomkwladyka: are you using this? https://clojuredocs.org/clojure.test/deftest
08:18kwladykanoncom, as i shown https://www.refheap.com/3fc8e81c4cf03e0631232fb53
08:18noncomso, yeah
08:18kwladykathe problem is about "is" in tests
08:18kwladykabecause of java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Boolean
08:19kwladykathis exception occur when somebody is between is and testing or between testing and deftest
08:19noncomcan you post full stack trace?
08:19kwladyka"is" has to be always just behind "testing" or "deftest"
08:20kwladykanoncom, https://www.refheap.com/e18f0703e8291bc76681dcc15
08:20kwladyka*somebody - something
08:21kwladykayou can do this in repl, just change my code to anything else, even (= 1 1)
08:21kwladykaand try do it 5 times
08:25kwladykamaybe what i am trying to do is impossible with clojure.test and i have to use additional library like test.check
08:25kwladykabut honestly i dont want in this case
08:30m-ergeris closure a good first language?
08:30kwladykammm but maybe i will do (for) or something like that in condition and i will return list of true/false.... i don't see better solution
08:31kwladykam-erger, i don't know. I am not sure somebody try. It is still new technology :)
08:32kwladykam-erger, i think it is like question about is it better to start play on violin or guitar or something like that
08:32wasamasam-erger: closure is a concept, not a language
08:32noncomm-erger: from me, i'd say "yes"
08:33noncomkwladyka: hmmm, honestly i never used the testing framework...
08:33noncomkwladyka: so, you need to run this very test like 100 times and get the 100 results, right?
08:34kwladykawasamasa, i guess it is misspell and he wanted write clojure?
08:34kwladykanoncom, yes
08:35kwladykafirst i wanted to run test x times, but now i see only one solution using clojure.test is return '(true true true true true ....) to check condition
08:35kwladykait is still good but no so elegant :)
08:36kwladykajust it makes code more unreadable
08:37m-ergerclosure is a concept?
08:38oddcullym-erger: cloJure vs cloSure
08:38noncomm-erger: https://en.wikipedia.org/wiki/Closure_(computer_programming)
08:40kwladykawhich function works like (for [x (1 2 3 4 5)] body) but like (f 5 body)? I mean i want this function to return results like for, but i don't need input as x
08:41kwladykai can't find function like this, maybe is it just doesn't exist? :)
08:43lumafi_how about repeatedly
08:43noncomrepeatedly, yes
08:45kwladyka(repeat x body) :)
08:50kwladykaso if somebody is interested in it is my solution https://www.refheap.com/106622
08:50kwladykai am not repeating tests, but i am repeating the condition
08:51kwladykai don't see any other way
08:59tgoossensis it possible (not just plain JavaCompiler) in clojure to take clojure code and compile it
08:59tgoossensand how?
09:01tgoossensas far as I understand clojure
09:01tgoossensthis should be extremely easy
09:01puredangercall the http://clojure.github.io/clojure/clojure.core-api.html#clojure.core/compile function
09:02tgoossens-.-
09:02tgoossensthanks puredanger
09:02puredangermost build tools have a way to ahead-of-time (AOT) compile many source files
09:05tgoossenspuredanger, What I actually am going to do is (using instaparse) to convert a DSL into clojure code wich then needs to be compiled to a java class
09:05tgoossens*which
09:06puredangerI presume you have requirements that rule out the option of gen-class ?
09:07tgoossensnot that I'm aware of
09:07tgoossens(yet)
09:07tgoossensthat might be a good idea actually
09:08puredangerwell depends on your process a bit but it's effectively a Clojure DSL to generate Java classes
09:08kwladykais function like repeatedly but without lazy-seq?
09:08puredangerbut it can't do everything
09:08kwladykai don't wont unnecessary (take x)
09:08tgoossenspuredanger, thanks for the hint :)
09:08kwladykai just want something like (repeatedly 5 f)
09:09tgoossenspuredanger, now i'm going to try and figure out how to take a string of generated clojure code and use core.compile on it
09:09kwladykaor in another words something like (for [x (range 5)] body) but (for 5 body)
09:10kwladykawhat i did last time when i asked doesn't work
09:10kwladykaso problem coming back :)
09:11snowellkwladyka: repeatedly takes an optional length arg
09:11snowellSo (repeatedly 5 f) should work
09:11puredangerloop?
09:11clojurebotloop is https://www.refheap.com/90332
09:11kwladykasnowell, thx!
09:12kwladykapuredanger, loop is not the same, because it return values in another way
09:14puredangerif you're collecting results in addition to running side-effecty functions, you should look at run! (new in 1.7)
09:14puredangeractually I guess you can't return results with run!
09:15puredangerbut you could get similar eager return with reduce
09:17fourqAnyone here know the answer to Anna's clojure question posted on Twitter? I'm curious too. https://twitter.com/AnnaPawlicka/status/621667387847348224 "#clojure folks, why isn't x cleared when it’s a number in a ^:once-decorated function, but is for strings & keywords? "
09:18Bronsafourq: Herwig responded
09:18fourqIs that the answer?
09:18kwladykahuh so who can explain this magic ? https://www.refheap.com/b41e5a2b51028306dbefb883d for [x (range 3)] works but repeatedly 3 throw exception
09:18Bronsafourq: only Objects can be set to null, x is a primitive long in that binding
09:18fourqhe said "i bet"
09:18kwladykaClassCastException java.lang.Boolean cannot be cast to clojure.lang.IFn clojure.core/repeatedly/fn--4750 (core.clj:4716)
09:19Bronsafourq: well that's the right answer anyway :)
09:19kwladykaso magic :)
09:19fourq=)
09:19fourqthanks Bronsa
09:20snowellkwladyka: Try putting a # before the call to make it an anonymous function.
09:21snowellRight now it's using the return value, where repeatedly needs a Fn
09:21kwladykasnowell, oh....
09:22kwladykasnowell, thx
09:23kwladykai need a brake
09:31kaiyinhow can i `lein deploy clojars` without entering password every time?
09:32tcrawleykaiyin: take a look at https://github.com/technomancy/leiningen/blob/master/doc/DEPLOY.md#gpg
09:54kaiyintcrawley: thanks!
10:18kwladykawhat is the best way to not pass all the time the same parameters to all functions? i have parameter cols and rows which mean number of columns and number of rows. I need this information in almost every function in namespace. Should i use ref or atom or something like that or another solution?
10:19snowellYou could always (defonce cols 8) at the top of the ns
10:19snowellWho doesn't like a good global variable? :D
10:20kwladykasnowell, but rows and cols are not constant
10:20snowellHa, oh...
10:21kwladykai have to operate on board
10:21kwladykabut board can have different dimension each time
10:21kwladykabut i have many operations on each board and each operation need to know about size of this board
10:21snowellYou can probably make a Board object with things like deftype and just pass that around
10:22snowellHaving no experience with that sort of thing in clojure, however, I will defer to others :)
10:22kwladykabut still in all function i need to add additional parameter, i am not sure it is good way
10:22kwladykaor maybe it is
10:23kwladykai have this code to remember terminal size:
10:23kwladyka(def terminal-size (ref [0 0]))
10:23kwladyka(defn handle-resize [cols rows]
10:23kwladyka (dosync (ref-set terminal-size [cols rows])))
10:23kwladykaand maybe it is good idea to remember board size
10:23kwladykaor maybe i shouldn't do that and i should pass this as parameter
10:24kwladykai am not sure how looks the best practice
10:24snowellI might consider using deftype to define a Board, with cols and rows fields
10:24snowellThen you can pass the Board into your function and read the cols and rows from it
10:25snowellDifferently-sized boards would then just be separate Board objects
10:25kwladykaand also i have to pass iteration, because i draw many boards on screen and i have to know which one it is
10:25kwladykaand again i have to pass to all functions additional parameter
10:26kwladykabut maybe it is like it should be
11:04justin_smithkwladyka: the error you got with the test was not related to testing or is or deftest, it is some issue with your code https://www.refheap.com/106627
11:05kwladykajustin_smith, the problem wasn't about that
11:05justin_smithkwladyka: also, you can run is inside a doseq or loop
11:05kwladykabut it is solved anyway
11:05justin_smithOK
11:06kwladykajustin_smith, hmm i tried with (dorun 5 (is)) and it didn't work
11:06kwladykabut maybe i did some mistake
11:10justin_smithkwladyka: that's not how dorun works...
11:10kwladyka5
11:11justin_smithkwladyka: test updated to use totimes to run is 100 times https://www.refheap.com/106627
11:11justin_smith*dotimes
11:12kwladykaoh yes dotimes not dorun, sorry i have mess in my head after all day
11:12kwladykabut for me it wasn't work... mmm so good to know it works
11:17kwladykajustin_smith, hmm and why it doesn't work with dorun? Is any function works like dotimes but without x? (dotimes [x 5]) - i know i can use _
11:18kwladykait didn't work because i was trying use dorun...
11:18justin_smithkwladyka: dorun is a function that forces a lazy value without holding onto the results
11:18justin_smiththat is all it does
11:18justin_smith,(dorun (map inc (range 100)))
11:18clojurebotnil
11:18justin_smith,(dorun (map inc (range 1000000000)))
11:19clojureboteval service is offline
11:19kwladykaoh...
11:19justin_smiththat timed out
11:19justin_smithbecause it was evaluating every inc
11:22kwladykado you have maybe any idea can i find font with size NxN (square)? I need that for console to draw board
11:23justin_smithkwladyka: quick google finds this http://www.dafont.com/theme.php?cat=301
11:23kwladykayeah but i didin't mention as default system font :)
11:24justin_smithkwladyka: what system?
11:24kwladykaevery :)
11:24justin_smiththat's a really tall order
11:24kwladykai need only numbers, Q, K, B, N, B letter
11:24kwladykaand space
11:25kwladykai know :)
11:25justin_smithwouldn't it just be easier to make some tiles and use those instead of a font?
11:25kwladykabut my purpose is to have board to be square on screen
11:26kwladykajustin_smith, i use clojure-lanterna
11:26kwladykai don't know any better solution
11:30kwladykai don't know any better solution to draw in console board
11:31kwladykachess board exactly
11:33justin_smithand you control the font of the console?
11:34kwladykajustin_smith, yes it has option to set font http://sjl.bitbucket.org/clojure-lanterna/reference/#font-names
11:35justin_smithoh, it launches a new terminal window, you could do it that way, of course :)
11:35kwladykathis is just to be good if i achieve square but it is not the main problem
11:36justin_smithat first I thought that meant it was somehow changing the font from inside the terminal (which afaik is not possible)
11:37kwladykabut still i don't know how to draw square board :)
11:37kwladykabecause font is not square
11:39kwladykabut... maybe it is just mission impossible :)
11:39TimMcmission improbable
11:40justin_smithTimMc: cue theme music. Zoom in on man in black, climbing down a rope, to buy a lottery ticket.
11:42TimMc"The Terms and Conditions, should you choose to accept them..."
11:42justin_smithrofl
11:43kwladykai need definitely break, going train Wing Tsun. See you later! :)
11:46sdegutisHello. This is my question. Is Instaparse suitable for parsing an INI file. Thank you for your time. Good bye.
11:46blkcatum
11:48wasamasathis is even weirder than that guy's requests over at #emacs
11:48hellofunkclj ninja: two maps, same keys. want new map containing only keys where value is different, always using the second map's values where applicable. what's a good one-liner to do this?
11:53oddcullythe ninja disqualifies me, but i'll give it a shot ,(into {} (let [old {:a 1 :b 2} new {:a 1 :b 3}] (filter (fn [[k v]] (not (= (k old) v))) new)))
11:55justin_smithoddcully: that's better than mine was going to be
11:57hellofunkoddcully: was hoping for something even more elgant. i asked because i too come up with these little monsters
11:58hellofunkwhere is amalloy when you need him
11:58justin_smith,(first (reduce (fn [[m' m] [k :as e]] (if (= (find m k) e) m' (conj m' e))) [{} {:a 0 :b 1 :c 2}] {:a 0 :b 1 :c 3})
11:58clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
11:58justin_smitherr
11:58hellofunkglad to know this simple task requires much verbosity from others than just me :)
11:59sdegutisDoes anyone know whether this is the case or not. Thank you.
12:00ambrosebshellofunk: tried clojure.data/diff ?
12:00amalloy(into {} (remove (set m1) (select-keys m2 (keys m1))))?
12:01amalloy,((fn [m1 m2] (into {} (remove (set m1) (select-keys m2 (keys m1))))) {:a 1 :b 2} {:a 1 :b 3})
12:01clojurebot{:b 3}
12:01justin_smith,(let [m {:a 0 :b 1 :c 2}] (reduce (fn [m' [k :as e]] (if (= (find m k) e) m' (conj m' e))) {} {:a 0 :b 1 :c 3}))
12:01hellofunkamalloy: since both maps will always have same keys, select-keys is probably unnecessary?
12:01clojurebot{:c 3}
12:01amalloyoh, same keys
12:02amalloythen sure
12:02sdegutisI am finding it difficult to get started with a sample of Instagram.
12:02sdegutisThanks in advance.
12:02hellofunkamalloy wins
12:02sdegutisI mean Instaparse.
12:02crocketWhy does clojure say "clojure.lang.Symbol cannot be cast to clojure.lang.IPersistentVector" when it compiles https://www.refheap.com/106630 ?
12:02amalloy(into {} (remove (set m1) m2))
12:02hellofunkamalloy: totally awesome. i knew it was out there
12:02hellofunk(inc amalloy)
12:02amalloy,(disj {1 2} [3 4])
12:02lazybot⇒ 287
12:02clojurebot#error {\n :cause "clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.IPersistentSet"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.IPersistentSet"\n :at [clojure.core$disj invoke "core.clj" 1452]}]\n :trace\n [[clojure.core$disj invoke "core.clj" 1452]\n [sandbox$eval101 invoke "NO_SOURCE_FILE" 0]\n [cloj...
12:03hellofunkamalloy: funny how three of us had these paragraph-long ideas. if there's one thing 4clojure has taught me, there is almost always a simple expression for stuff like this
12:04wasamasasdegutis: well, it requires you to already know the theory behind parsing
12:04sdegutisThank you.
12:04wasamasasdegutis: perhaps you find it easier to get into https://github.com/youngnh/parsatron
12:04crocketHelp
12:05sdegutisI have a simple INI file.
12:05sdegutisPlease if you know how these two libraries compare in terms of community mentality.
12:05crocketAh...
12:05sdegutiswasamasa: Thank you in advance, best regards.
12:06wasamasasdegutis: the former does a lot more than the latter
12:06wasamasasdegutis: basically it supports every approach to parsing you'd encounter in the wild
12:06sdegutiswasamasa: I only need to parse a simple INI format. So it sounds like the latter might be suitable. However if it is completely terrible, and everybody hates it, that might be a problem.
12:06wasamasasdegutis: while the latter does recursive-descent parser combinators only
12:06crocketI should surround an anonymous function in parentheses in ->
12:07sdegutisI admire that it uses ClojureScript however this is not a feature I have absolutely any need for. So if this is the primary target of this library then we have differing philosophies and thus should part ways.
12:07sdegutisThank you.
12:08wasamasawat
12:08wasamasacould you please drop this superfluous speak, this isn't email
12:09wasamasaasides from that, I find it very hard to believe there's no existing library for parsing ini files: https://clojars.org/search?q=ini
12:09sdegutisI do not really have an INI file, it is very similar though. It is a custom text based format that we employ and which is very similar to INI format and simply has a defined text-based format.
12:10sdegutisIt has a simple specification, mostly using newlines for delimiters, but at one well-defined point also using brackets.
12:10sdegutisOur CEO asked me originally to just use an Excel file as the format but I had to explain why this was not an appropriate idea.
12:12sdegutisIt might even be simple enough to use simple Clojure sequence processing to transform it. However this is not strictly a good idea and thus I want to use some technique and/or methodology that is quite a bit more appropriate.
12:12sdegutisHowever that is why I have considered Instaparse and now Parsatron.
12:12sdegutisThank you for your advice and continued help.
12:13wasamasahave fun learning parsing theory then
12:13sdegutisThis person suggests that Parsatron is dead: https://twitter.com/kurisuwhyte/status/382699042938974208
12:13wasamasasuuure
12:14wasamasathat must be why I had to extend its grammar for a work project
12:14sdegutisThat does make sense.
12:15sdegutiswasamasa: I may be able to come up with an EBNF grammar, will that suffice for this?
12:15sdegutisThanks in advance.
12:17wasamasasdegutis: if you get it perfectly right the first time, yes
12:19sdegutisThank you.
12:24sdegutisHow do you specify "any alphanumeric, punctuation, or whitespace character except newline"?
12:24sdegutisIn other words "any printable character except newline" in Instaparse?
12:25blkcathave you considered using a regex?
12:28wasamasalol, you write parsers *because* you're doing something better than merely using regex
12:28wasamasaanyhow, I'm out as this is as far as my knowledge on the topic goes
12:28blkcathaha, that's fair :P
12:37sdegutisblkcat: that might be appropriate
12:37ShayanjmDoes anyone here have implementation experience in quantum computing?
12:39sdegutisI don't think that's a real thing yet.
12:39sdegutisI think it's mostly theoretical.
12:39justin_smithShayanjm: gfredericks has done some qc related projects
12:39Shayanjmsdegutis: nah there are tons of quantum simulators
12:39sdegutisOh.
12:40justin_smithShayanjm: simulator related, of course
12:40sdegutisBrb writing Clojure instead of Haskell or JavaScript.
12:40Shayanjmjustin_smith: great, thanks. I'm trying to build my own simulator on clj
12:40tolstoyIs there a way to make lein use the latest clojure when running outside a project context?
12:40Shayanjm@ gfredericks - would love to pick your brain a little bit when you have a moment
12:40justin_smithShayanjm: yeah, you could probably start with one of his
12:40tolstoyCorollary: Is leiningen ever going to be updated?
12:41Shayanjmjustin_smith: creeping his site, checking out his quantum circuit visualization. Looks really cool
12:43sdegutisI am attempting the following: Str = #'\\w|\\W'+
12:43sdegutisPlease advice.
12:45sdegutisAnyone here prefer Boot over Lein?
12:48puredangerthey serve different users imo - for a basic Clojure project, lein is going to satisfy most of your needs for a long while
12:48justin_smithpuredanger: who do you see as the target demographic for boot?
12:48puredangerboot is better the more customization you have to do, particularly intermediate file generation type tasks
12:48puredangermost cljs builds can probably benefit from it (I think) and more advanced large-project builds
12:49rhg135puredanger is correct. I do my plain clj in lein
12:50gfredericksShayanjm: what's up?
12:50hiredmanI disagree
12:50puredangerI'd love to hear your opinion
12:52rhg135Simpler cljs builds are fine with figwheel imo
12:52hiredmangenerally, builds are terrible, and javascript builds (for whatever reason) are the worst
12:52puredangerI think the other thing is that lein comes at the problem from the "declarative project model / lifecycle" perspective (like Maven) and boot comes more from an imperative "task" perspective - assembling pipelines of things that are useful for your particular build.
12:53puredangerthose might fit different projects and people differently
12:53cflemingI agree that the more complicated the build, the more flexible something like boot will end up being.
12:53hiredmanpeople generally react to that by calling for more tooling, I've already seen people calling for tooling above and beyond boot for wiring together all the cljs build parts
12:53hiredmanbut the tooling is more strata to dig through when it breaks
12:54hiredmanit is terrible
12:54sdegutisI am successfully using Instagram to parse my text file format.
12:54rhg135I'm hoping for a lein update soon
12:55rhg135I like my 1.7
12:56sdegutisIs Clojure 1.7 released then?
12:56rhg135Yeah
12:57hiredmanboot may or may not be good, but I think it's adoption is driven by an need to escape the terribleness of ui builds and a willingness to try anything to do that, without much reflection about if a solution actually solved anything
12:59rhg135It's better than writing dozens of shell scripts
12:59puredangerI'm looking at it for stuff that has nothing to do with ui and there many things I like about it
12:59hiredmanthe same impluse behind all the javascript build tools that make it impossible to get a node project up and running from source
13:00sdegutisI had to add this rule: Str = #'.+'
13:01rhg135It'd be useful for post/pre processing
13:01rhg135Like js gen or dexing
13:04sdegutispuredanger: Thanks for the comprehensive analysis and comparison of Boot vs Lein. I appreciate it. And it seems very accurate and compatible with my own experience using both and reading their documentations.
13:05puredangermy opinions are still forming on it, so for sure, do your own analysis
13:06sdegutisMy understanding is that Lein + a few mainstream plugins are what most Clojure people will use, since they share the common mentality of wanting to as much as possible in Clojure, and letting other libraries and plugins help them with the common cases, such as building dependencies, uploading to EC2, etc.
13:06sdegutisAnd that Boot is a reaction to this, to try simplifying it when you want more flexibility in any of these steps, which currently is a headache involving creating custom Lein plugins etc.
13:07sdegutisI am a fan of neither and would prefer to just use GNU Make.
13:07sdegutisBut alas we're in the Java world here.
13:07puredangersdegutis: you might want to look at cmma
13:07puredangerhttps://github.com/ohpauleez/cmma/
13:07puredangerPaul uses it pretty extensively to manage Clojure apps with make
13:08sdegutisIts README's rhetoric is too vague: cannot tell what it does, and how it's different than anything else.
13:08puredangerit uses make to manage Clojure projects
13:08sdegutisOh!
13:08puredangerit wraps other build systems (lein, boot, etc) to steal the dep-mgmt parts
13:09sdegutisAhh crap.
13:09sdegutisImplies: So many JVMs starting and stopping constantly.
13:10puredangermmm, don't think so? once you grab jars, you have them. no need to do that on every build.
13:10sdegutisEvery `lein run` rebuilds my Clj source and runs it.
13:10sdegutisThat's where this would come in.
13:14slesterHello hello; I'm sure this channel gets this question frequently, but since I can't use Clojure at work, I'm looking for a project (pref. GPL) to work on. Any suggestions? Sometimes it's a bit opaque how to get started in a community
13:15justin_smithslester: is epl good enough? there isn't much gpl clojure
13:15justin_smithbut there is a lot of epl clojure
13:16justin_smithslester: the leiningen project has a tag for issues that would be easy for a newcomer to work on in their github issue tracker
13:17justin_smithIt's EPL
13:17sdegutisIs there a better way to write (fn [s & _] s) ?
13:17justin_smithfirst
13:17justin_smithwell, no, not first
13:17justin_smith(comp first list)
13:18justin_smith,((comp first list) :a :b :c :d :e)
13:18sdegutisI tried `first` at first.
13:18clojurebot:a
13:18sdegutisjustin_smith: Thanks. Which way do you think is clearer?
13:19justin_smithsdegutis: probably your version
13:19justin_smithsdegutis: also (apply (comp first list) (range)) goes into a loop, (apply (fn [s & _] s) (range)) returns 0 immediately
13:20TMAsdegutis: if you need a name, in common lisp this function is called prog1
13:20sdegutisTMA: Thank you. That fully solidifies my distaste for CL.
13:21justin_smithclearly program-one is the right name for it
13:22TMAsdegutis: maybe you shall restructure the solution to avoid the need for such a distasteful function :)
13:22slesterjustin_smith: whoa, thanks, for some reason my IRC client/internet connection just sent me 20 messages at once
13:23justin_smithslester: yeah, the IRC protocol is kind of weird, things like this are not uncommon
13:23slesterjustin_smith: and yep, EPL is fine.
13:23slesterjustin_smith: leiningen seems kind of massive, I'll have a look through its issues though. I do like it a lot and would like to help.
13:24justin_smithanother bonus to working on leiningen is that nearly all of us use it
13:24justin_smithwhich amplifies the warm-fuzzies of contribution
13:24slestera very important part of contribution, if often not spoken of :)
13:24sdegutisTMA: I am interfacing with Instaparse. It is impossible to rework anything.
13:25sdegutisOops. It's actually (fn [s _] s) that I wanted to investigate replacing.
13:25sdegutisIt's a two-argument thingy.
13:26sdegutisActually, wait. Is it possible to just tell Instaparse to omit a certain thing from the output tree?
13:26sdegutisI have a literal '\n' in my rule (to indicate end of line as the terminator for that rule). But it keeps emitting this stupid character in my output tree.
13:27TimMcslester: lein has some issues marked "newbie" which don't require as much background
13:27justin_smithTimMc: yeah, that's why I brought it up
13:27sdegutisAnyone know if this is possible somehow?
13:27sdegutisTo tell it "hey don't omit this character in my rule"?
13:28xemdetiasdegutis, did you look at 'transform'
13:28sdegutisI am currently using it.
13:29sdegutisThat's where I'm putting (fn [s _] s)
13:30sdegutisOne way would be to give a name to my Newline character and then transform it into nil in the transform, if that even works. But that might not work. And even if it does, I don't want to name Newline.
13:30xemdetiacan't you just do :newline-token nil
13:30xemdetiawell it is a token in your input stream?
13:30sdegutisxemdetia: It's a literal '\n'
13:30xemdetiasince you are using it as a meaningful delimiter instead of whitespace?
13:31sdegutisEntry = Thing+ '\\n'
13:31xemdetiaso for the grammar to accept the input it must have a literal newline token
13:31xemdetiaso it makes sense it would be in your output
13:32sdegutisNot with how well-structured Instaparse's output tree already is.
13:32sdegutisI don't need the newline in my output, it's just there for the sake of the parser. Now that it's parsed, I don't need this token anymore.
13:33xemdetiaso tag it as a token and do a tree transform to get rid of it, that's really the answer if you are not able to override how the newline token is added to the tree
13:33xemdetiathis is more general parser theory than exactly instaparse
13:36sdegutisOh.
13:36sdegutisThanks xemdetia for your expert help.
13:36xemdetiaaccepting a grammar in a parser is one job, the data structure it emits as a representation is a separate part, if the path between lexer and tree is a black box to you
13:36xemdetiayou just have to deal with it on the output side
13:37sdegutisMost excellent.
13:38sdegutisTransforming it into `nil` does not help.
13:38sdegutisIt is still present, only now as nil.
13:38sdegutis(hehehehehheh)
13:39justin_smithsounds like a job for mapcat
13:40xemdetiaonly when you need mapcat to be
13:40xemdetiaduring the day mapcat is just cat, a noble blue collar worker
13:40xemdetiataking files from over there and dumping them to screens for the luxurious
13:40xemdetiabut at night
13:40xemdetiamapcat gets lispy
13:40justin_smithhaha
13:40justin_smith(doc cat)
13:40clojurebot"([rf]); A transducer which concatenates the contents of each input, which must be a collection, into the reduction."
13:42xemdetiasdegutis, will nil be happily handled by the reader of that tree
13:42xemdetiaif not maybe you just have to do some dissoc/remove-keys magic
13:42sdegutisxemdetia: no, it still requires me to use (fn [s _] s)
13:43xemdetiawell I didn't mean through instaparse transfor
13:43xemdetiajust use it like a tree
13:43sdegutisIt ends up inside a ["mystring" "\n"], where I ultimately just want to get "mystring" out.
13:44xemdetiaI mean you have a ref to a map that is your output, just use it like a map? filter maybe?
13:44xemdetiaI am not remembering how instaparse emits
13:44xemdetiabeen playing with antlr more lately
13:45sdegutisHow do you match the very end of a file?
13:45sdegutisShould I just append \0 to the file and match for that?
13:47xemdetiawe're talking about a few different things? when/how do you want to match the eof?
13:48xemdetiaI mean from lexer/parser land usually you just invent an eof token so you don't have to worry about it
13:48sdegutisPretend that, in the file my professor will give us, there may not be a trailing newline at the end of the file, whereas it belongs to a repeating rule.
13:49sdegutisFor example if Line was a rule to match a line and ends in '\n', and you might have many lines, but the last one doesn't end in a newline.
13:49sdegutisDoes this make sense?
13:49snowellsdegutis: You can use brackets to exclude it from the output: Entry = Thing <'\n'>?
13:49sdegutissnowell: Awesome!!!
13:50sdegutisLet me try.
13:50sdegutisAhhh: "Angle brackets on the right-hand side of a rule correspond to the hide combinator."
13:50sdegutisI did not look for "hide" anywhere ever. Only "ignore" and "omit".
13:56sdegutisYes, <> works perfect. To ignore the token itself but leave the rule name, I put it on the right side. To ignore both, I put it on both sides.
13:56sdegutisI never even saw the "Controlling the tree structure" section! This is useful.
13:56xemdetiasorry, haven't used instaparse enough
13:57xemdetiabut yeah there is a separation between 'accept grammar' and 'data structure'
13:57xemdetiayou either have hooks or you don't
14:06sdegutisSo if you have a file with multiple Lines, each Line ending in '\n', but the last line omits the newline -- how do you express this?
14:06sdegutisOr do you just add an \n at the end of the file just in case, ignoring a second \n that might be at the end?
14:08xemdetiasdegutis, one way could just accept '\n'+
14:08sdegutisxemdetia: But it might have 0 newlines on the last line
14:09xemdetiaor I might have misread it
14:09sdegutisAnd * doesn't work since every line before it requires at least one
14:09snowell? translates to 0 or 1
14:09sdegutisIt's a text file where each line is an entry, but the whole file might not end with a newline
14:09xemdetiaright, are you slurping the input file directly into instaparse or are you buffering it first
14:09sdegutis(slurp)
14:10sdegutis(->> file (slurp) (parse))
14:10xemdetiacan you just stick an extra newline on the end? *_*
14:10sdegutisYep. That's my current plan.
14:10snowellI would use ?
14:10xemdetiahe can't
14:10sdegutisBut it makes me feel dirty.
14:10xemdetianewline is a meaningful character
14:10hellofunkcljs repl experiments by mfikes are trending high on HN right now
14:11sdegutis(inc mfikes)
14:11lazybot⇒ 1
14:11xemdetiasdegutis, its not really dirty. massaging input before lexing is just something you have to do
14:11sdegutisIt's a thing?
14:11sdegutisPhew.
14:11sdegutisxemdetia++
14:11xemdetiawell I mean in most of my grammars I have an end of input thing
14:12xemdetiaand usually that is something I glue in lexer - EOF APPEND - parser
14:12xemdetiaif it is not convenient to do another way
14:13snowellYou could parse with a regex
14:13justizinanyone using clojure to test existing java code with no coverage?
14:13snowellsdegutis: Entry = Thing + <#
14:13snowellbah
14:14hiredmanjustizin: yes
14:14snowellEntry = Thing + <#"[\n|\Z]">
14:14sdegutisxemdetia: I've done that too in the past -- my lexer would append a special :EOF token to the end of the token stream.
14:14sdegutisxemdetia: But Instaparse is fun.'
14:14snowellThat will match on \n or end of string
14:14hiredmanwell, maybe "that depends"
14:14xemdetiathat's true
14:15xemdetiabut yeah just throwing an eof on the token string is easiest
14:15xemdetiabecause then you aren't relying on some condition of the input to be exactly right
14:15xemdetiawhich makes debugging easier
14:15snowellEasiest, sure. But like sdegutis I feel dirty doing something like that :D
14:16xemdetiawell
14:17xemdetiathis is why using whitespace as a delimiter is awkward
14:17xemdetiaif you used semis for every line you wouldn't have this problem at all
14:17xemdetiaand you would have a clean token string to feed the parser
14:17sdegutis+1
14:17snowellOf course then a user comes along and puts a semi in the input
14:18sdegutisxemdetia: the real problem is having to parse something that humans edited
14:18xemdetiayes
14:18justizinhiredman: any tips on where to start? examples?
14:18sdegutis*and assembled
14:18xemdetiathe real problem is the people
14:18xemdetiaremove the people
14:18sdegutisOF COURSE
14:18sdegutisROBOTICIZE THIS JOB
14:18sdegutishow could i not think of this
14:18sdegutisWelp, at least I'm not parsing Excel files.
14:19slesterthis is how the robot wars begin
14:19hiredmanjustizin: the first thing you'll need to figure out is how to tie the clojure tests in to your java project, the easiest way to do that is to build the java project using lein, then you can run with tests with `lein test` and write them using clojure.test
14:20hiredmanif you can't do that you can look at clojure, it is a java and clojure project, built using maven, tested in clojure
14:21sdegutisThanks in advance, regards.
14:21justizinhiredman: tks
14:22sdegutisMy awful hacky solution: https://gist.github.com/sdegutis/7ca83a4a4a61b7ced970
14:22sdegutisPasses all tests!
14:22sdegutisAnd now I'm done 3 hours early.
14:22sdegutisTime to convert Sass to Stylus.
14:23sdegutisI really want to convert it to Clj to be honest. But let's face it JVM startup time won't be acceptable for 15 more years.
14:24justizinhiredman: somehow this idea came out of the thought of using lein instead of maven
14:24justizini have a little experience with lein from working with jepsen and LightTable
14:25hiredmansure, lein does well building java, and then you can point test.check at your java, it is great
14:25justizinsweet
14:25justizinit feels like it might be less typing to write lots of new tests of a java module with clojure
14:26bauhausanyone seen a deps error in the latest version of datomic: I/O exception caught when processing request to {}->http://jline.sourceforge.net:80: Connection reset >.<
14:28sdegutisWe are very far behind in Datomic versions. Years old.
14:29sdegutisAlso in Clojure version.
14:29sdegutisWe can't update. Too expensive.
14:30bauhausthought the sourceforge ship had sunk
14:31bauhausguess not
14:31sdegutisbauhaus: yes it has
14:31bjajust submitted a PR to a project that introduces eval, preparing to get roasted...
14:34wasamasafor what reason?
14:34wasamasainb4 it's in a macro
14:38bjaI'm generating destructure arguments and have a macro that does let passing those bindings in (manual-let), I need to eval the result of that along with the symbols I want out
14:38bjaat least as far as I can tell
14:39bjaso the macro builds a let*, then I want to eval it so I can grab the result of the destructuring
14:39justizinhiredman: any examples of java projects built with lein? the documentation is all like 'clojure clojure clojure'
14:39bjahttps://github.com/stuartsierra/component/pull/37/files#diff-998bb67cf5bc59512267d4e162873450R137
14:40hiredmanhttps://github.com/sonian/Greenmail/blob/master/project.clj
14:40bjajustizin: storm used to be built with lein, but it's moved to straight maven during the 0.9 cycle
14:43wasamasabja: can I get a cookie for guessing right?
14:43bjawell, the eval isnt' in a macro
14:44bjabut I guess you can have a cookie anyway, since it's pretty close
14:44wasamasayay
14:45bja(inc wasamasa)
14:45lazybot⇒ 1
14:56sdegutisIs there a nice way to prettily diff two not-too-deep maps. Thanks?
14:56H4nssdegutis: https://clojuredocs.org/clojure.data/diff
14:58H4nsminus the "nice" and "pretty", i fear
14:58sdegutisSorry I mean to print.
14:59snowell,(doc prn)
14:59clojurebot"([& more]); Same as pr followed by (newline). Observes *flush-on-newline*"
14:59snowellsdegutis: ^
15:00sdegutissnowell: Thanks. I fear prn does not work well for many vectors.
15:01snowellWell you said they weren't too deep. pr-str / pr / prn are about as pretty as you can print
15:02snowellYou could try clojure.pprint/pprint I suppose
15:03xemdetiayou could print to legal and get out some highlighters
15:03xemdetiaI think I still have some stickers in a drawer somewhere
15:21atyzDoes anyone know where I can find information on how to efficiently query nested entities (of the same type, they all have the same ref - like a tree) in datomic?
15:41iwilligatyz: you might want to try the datomic channel
15:41iwilligbut would the pull api be enough for you ?
15:41fredfeIs net.mikera/core.matrix a prefered/stable matrix match lib?
15:59gfrederickssdegutis: the puget library might be useful
16:09hcumberdaleHi! :)
16:09hcumberdaleHow to register a log4j.properties file during a lein plugin execution ?
16:10hcumberdaleFiles under ./resources does not seem to be seen during plugin execution
16:21nicolai'm having a similar issue - my (clojure) code uses cassandra which logs A LOT of stuff on the console; is there a simple way to turn it off?
16:24hcumberdalenicola: generally you can set things via resources/log4j.properties
16:24hcumberdalebut this isn't recogniced during a plugin run
16:24nicolai'll try that, thanks
16:27justin_smithnicola: another option is to use lein repl in the console, which will start a repl and also start listening on a port, then you can use 'lein repl connect' in another terminal. The logging goes to the first one, and will not interrupt your work in the second.
16:27justin_smithin place of lein repl :connect, you can also use a client like cider of course
16:28nicolahcumberdale: didn't seem to work :( still logs a lot of stuff
16:29hcumberdalenicola: depends on what logging framework loggs this stuff.
16:29nicolajustin_smith: by console i meant stdout, not repl/cider
16:29nicolahcumberdale: i'm pretty sure it's log4j (at least from looking at cassandra's source code) but i'm still trying to sort this out so i might be wrong
16:29justin_smithnicola: then explicitly open a file handle and output to that instead of using stdout?
16:29hcumberdalenicola: what is writing to stdout? A framework? Yur application
16:30hcumberdalenicola: it might be java commons logging
16:30nicolai'm calling some function from cassandra; these functions in turn log a bunch of stuff to stdout, which i don't want
16:30justin_smithnicola: that would be the hack version at least. if you figure out what logger it is using, you can configure that logger of course.
16:30hcumberdaleyou can bundle all logs into a slf4j adapter
16:30hcumberdalesee: https://github.com/kremers/clojurewebtemplate/blob/master/project.clj << logging
16:31hcumberdaleit is using logback as backend
16:31justin_smithnicola: what is consuming your stdout?
16:31hcumberdaleconfigured here: https://github.com/kremers/clojurewebtemplate/blob/master/src/logback.xml
16:32hcumberdalenicola: the java driver for cassandra is using slf4j
16:33nicolajustin_smith: i'm just printing to console; i mean lein uberjar, then java -jar target/...-standalone.jar; i'm not piping this to anything
16:33nicolahcumberdale: oh interesting
16:35justin_smithnicola: the reason I ask, is if nothing is programatically consuming it in real time, you can even just use something like grep
16:35nicolajustin_smith: oh i see; i'd want to take it out anyway though
16:36justin_smithclearly a misunderstood a few things, heh
16:40nicolaYES! here's the solution (set to only warnings) (.setLevel (org.slf4j.LoggerFactory/getLogger ch.qos.logback.classic.Logger/ROOT_LOGGER_NAME ) ch.qos.logback.classic.Level/WARN)
16:40nicolathanks for the tip about slf4j hcumberdale
16:41hcumberdalenicola: better you use a file. So you are able to adjust it later without redeployment etc.
16:42nicolatrue
16:49hcumberdalehmmm technomancy not here
16:51slesterJust read this on HN: "Slow launch means you tend to write monolithic applications. You can't write cli tools with Clojure. You can't compose Clojure applications. You have to write a big bulky JVM app. Which definitely has its place, but ClojureScript is expanding Clojure's reach." -- Is that true? I mean the repl does take forever to start, but does that inhibit CLI?
16:54hiredmanit is ridiculous
16:54hiredmanmy ~/src has 18 shebang scripts written in clojure in it
16:55blkcatthe jvm startup time is not what i would call ideal
16:55hiredman(counted via find $PWD -name \*.clj -exec head -1 {} \;|grep '#!'|grep jar|wc -l)
16:55blkcatjust getting usage from lein takes a little under 4 seconds on my system
16:56hiredmanthe shebang lines for those 18 files are some variation of #!/usr/bin/java -jar /Users/hiredman/src/clojure/target/clojure-1.7.0-master-SNAPSHOT.jar
16:56justin_smithblkcat: the lein repl startup time is not caused by the jvm, the culprits are mainly nrepl, lein, and clojure.core, in that order last I checked
16:57justin_smithif you can avoid the lein and nrepl parts of the equation, you'll like your startup time much more
16:57slesterhiredman: and I guess the responsiveness is fast?
16:57slesterI searched and found https://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips#Shebang_Scripting_in_Clojure
16:59hiredmanI have no idea, they are not interactive, there is one to delete old clojurebot postgres backups from s3, one to launch the daily show on my roku, one to generate a youtube playlist from the gist of songs played in the strange loop main hall
17:00hiredmanI've never cared, or used time on them, and they work great
17:00puredangerI can run this in 0.893 sec: time java -cp clojure.jar clojure.main -e "(+ 1 1)"
17:00puredangerwhich starts a repl, evaluates an expr and shuts down
17:00slesterhiredman: launch the daily show on your roku? :O
17:00puredangerwell I guess starts a runtime, not a repl
17:01hiredmanslester: sure, that script is retired, replaced by a little web app that I used from phone, and then I moved and never set it up again
17:03hiredmanthe webapp was sweet, I ran it on a beaglebone and could use it to drive my tv, roku, even the fireplace
17:04hiredmanI touching a single button it would turn on the tv, set it to right input, then launch the hulu roku app, search of the daily show, then launch the most recent episode
17:05hiredmanI do a lot of stuff, and I do with clojure, and it works great
17:07hiredmanhttps://gist.github.com/hiredman/7682917
17:08vashiredman; that's impressive.
17:11csd_does there exist some macro that makes it easy to thread a async channel through a stateful series of functions for testing purposes? is this even a good practice to consider?
17:26adriansAnyone around who is using Emacs/cider and who could answer a few questions?
17:27mkadrians: best way to find out is to just ask :)
17:29Seyleriusadrians: I'm not massively experienced, but I'm using CIDER atm and could experiment. Speak your queries.''
17:37adriansfor some reason I don't seem to be getting the doc popup in my editor buffer when using cider/company-mode, but I do have it in my *cider-repl* buffer - same minor modes seem to be in effect for both buffers
17:42adriansWould anyone know what I should look for to determine why I'm not getting the help popup in the editor?
17:45adriansSeylerius, mk: still around?
17:45Seyleriusadrians: Yep.
17:46adriansAny suggestion?
17:46mkyes, but I don't use either of those
17:46Seyleriusadrians: Which help popup?
17:46adriansone that comes up after the auto completion popup appears
17:54Seyleriusadrians: The one that's supposed to provide the argument possibilities?
17:56adriansSeylerius: the package is called company-quickhelp
17:56SeyleriusAh, that one.
17:56adriansit shows the function signature plus the doc string
17:56adriansis this meant to work only in the repl buffer?
17:56arrdemthere's also eldoc-mode
17:57adriansarrdem: yes, I'm using that too, but I like the multi-line popup in addition to that
17:57arrdemand no both will work fine in both code and the repl
17:58arrdemassuming you're in cider-mode with a live connection among other things
17:58adriansaardem: so what could be a reason not to see it in a regular editor?
17:58adriansaardem: I am connected - I get the popup in the repl buffer
17:59adriansand on the github page, I see no configuration other than for turning it on and setting the delay
17:59arrdemso you have to hook company-quickhelp-mode to cider-mode
17:59arrdemor turn it on yourself
17:59arrdemI don't think cider does that automagically
18:00arrdemthat's something I think got added to the README recently along with adding company-mode to cider-mode. if not then it needs to be in the README
18:02arrdemadrians: did/does that help?
18:02adriansyes, thanks aardem
18:16broma0a good data structure for O(1) push/pop at both the front and back?
18:20arrdembroma0: doubly linked list
18:20arrdemnot immutable tho.
18:21arrdemfinger trees may be able to do that as well, but they're gonna be O(log32(n)) push/pop
18:21amalloyi think the main persistent options are finger trees and RRB trees
18:21amalloyarrdem: really? i know that's true of RRB trees, but i don't think finger trees have and kind of 32-wide branching
18:21arrdemamalloy: I don't remember the specifics of finger trees, maybe I have them confused with vectors
18:21arrdems/maybe/probably/g
18:22amalloyi think so. RRB trees are the thing bagwell gave a talk about, as a way to improve clojure's vectors
18:22arrdemheh
18:24hcumberdaleHow to enable the log4j debug logger on root level when executing leiningen plugins
18:38broma0arrdem: amalloy: Thank you
18:39TEttingergfredericks: I have some RNG puzzling to do that perhaps you are already an expert on
18:39TEttingergfredericks: I'm interested in implementing the PCG family of RNGs in Java (making them usable to Clojure as well, of course)
18:40TEttingerhttp://www.pcg-random.org/
18:43TEttingerthey're a very conceptually simple modification on a linear congruential generator (or multiplicative congruential generator, which is what I'm interested in) where they use the values in the low-period low bits as shift or rotation operands, and/or use them to perform a xorshift on the high bits of the LCG output
18:45TEttingerdownside is I need a better LCG than Java's, since java will only produce 32 bits with a period of 2^48, and there aren't nearly enough bits to work with there
19:03crocketCan anyone recommend a good command line parser?
19:04Surgotools.cli
19:04Surgohttps://github.com/clojure/tools.cli
19:04Surgoyour definition of good may vary
19:05crocketIs tools.cli simple and small?
19:05Surgosimple, you can decide on that yourself by checking the readme
19:06Surgosmall, it has no dependencies aside from clojure
20:57jhnif I have a set of maps, how can I test if there is some key in any of the maps that has a particular value?
20:59scriptor,(map #(contains? % :key) [[:key 1] [:bar 2]])
20:59clojurebot(false false)
20:59scriptorsorry
20:59scriptor,(map #(contains? % :key) [{:key 1} {:bar 2}])
20:59clojurebot(true false)
21:03jhnty
21:16julianlevistonum
21:17julianlevistonthat’s not going to test if there’s a key that has some particular value… unless you mean “how can I test that the map has a particular key”? which wasn’t what you asked.
21:18julianlevistonjhn Precision of language: This is a set of maps: #{{:a 1} {:b 2}} is this what you meant when you said “if I have a set of maps”?
21:19jhnjulianleviston Yes, I noticed, but that gave me the hint as to what I could do.
21:19jhnAnd yes, I meant an actual set.
21:21julianlevistongood o
21:23gfredericksTEttinger: was there a question associated with that?
21:24TEttingergfredericks: ah I assumed you weren't around and it was going to get passed out of history
21:25TEttingergfredericks: are you familiar with L'Ecuyer's LCG constants?
21:26TEttingerI was having a hard time understanding why he claims certain numbers for MCGs produce reversed-order generators compared to certain other numbers, and I think I don't understand his meaning
21:26gfredericksit doesn't sound familiar
21:26TEttingerhttp://www.ams.org/journals/mcom/1999-68-225/S0025-5718-99-00996-5/S0025-5718-99-00996-5.pdf
21:26gfredericksthe most I looked into LCGs was to read the knuth volume without doing any of the exercises
21:27TEttingerI gotta say I still haven't finished watching your splittable RNG talk :(
21:27TEttingerit was starting to go over my head when I stopped
21:27TEttingerI did look into Java 8' SplittableRandom source
21:28TEttingerhttp://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/util/SplittableRandom.java
21:28gfrederickswhat part was head-over? the algorithm descriptions?
21:28gfredericksyeah I looked at that file quite a lot :)
21:28TEttingerI can't remember, I don't understand the threading stuff that well
21:28TEttingerwhy you would want splittability, I mean
21:28gfredericksoh there are different reasons
21:28gfredericksdoesn't have to be threading
21:29gfrederickse.g. test.check more or less needs it and is single-threaded
21:29TEttingerah
21:29gfrederickslaziness is the key factor in the test.check case
21:29gfredericksbut the biggest reason is just that the state monad is a giant pain
21:29gfredericksespecially if the haskell compiler is not holding your hand
21:29TEttingerhm.
21:30gfredericksso if you want to write complex deterministic programs that depend on pseudorandomness, you can't give them an arbitrary structure, you have to manually linearize the program
21:30gfredericksI will admit this probably doesn't matter for most people
21:31TEttingerI think I can implement PCG-Random's bit-fiddling over any 64-bit-state, 64-bit-output generator and get a 32-bit generator out of it
21:31gfredericksif you're using a haskellesque language though, the language forces this to be important
21:32TEttingergfredericks, are you using SplittableRandom now or your own RNG?
21:32TEttinger(in test.check)
21:32gfredericksI ported it to clojure
21:32TEttingerah!
21:32gfredericksSplittableRandom is OOP style
21:32gfredericksthe port is clojure/functional style
21:32TEttingercool
21:32gfredericksbut it gives you identical results
21:33TEttingercan you skip ahead?
21:33TEttinger(efficiently?)
21:33gfredericksI don't think there's a need to?
21:33gfredericksI'd be curious to hear a use for that
21:33gfredericksthat can't be met by general splittability
21:33gfredericks(you might still be able to, I just haven't thought about it)
21:34TEttingereh, it's sometimes a handy feature. you can do it regardless of having been split, so it could be added onto a SplitMix style RNG
21:35TEttingeryou could have a decent-sized collection of SplitMix RNGs, right? each has tiny state so having lots isn't a problem
21:36julianlevistonis there a flip combinator in clojure?
21:36gfredericksI'm not sure what splitmix means exactly
21:36TEttingergfredericks: it's the type of generator SplittableRandom uses
21:36gfredericksoh that sounds familiar
21:36gfredericksthe "skipping ahead" question doesn't actually fit well with the API I aimed at because it's not linear at all
21:36gfredericksthere is no inherent "sequence of numbers" to skip ahead in
21:37gfredericksthough the SplittableRandom algorithm is more sequence-like
21:37gfredericksI just decided to more or less ignore that sequence
21:37TEttingerthey could all be seeded with the same state. the update step for SplittableRandom adds the gamma to state, then takes that value (not modifying state anymore) and xorshifts/multiplies it some
21:38TEttingerit's fairly straightforward to add gamma many times and only get the overflow out of it
21:38gfredericksoh yes, that's right
21:38TEttingerthat would be equivalent to skipping ahead
21:38gfredericksyep
21:39gfredericksf(state + gamma * n)
21:39TEttingeryes, but not quite
21:40gfrederickseh?
21:40TEttingerif you wanted to skip ahead 1000 iterations, will that be OK with regards to overflow?
21:40TEttingerhm, to the clojurebot
21:40gfredericksI believe the unchecked jvm arithmetic ops Just Work
21:40gfredericksyou just want to do modular arithmetic
21:41TEttingeroh, also: do you know how to get either of the bots to do *unchecked-math* ?
21:41gfredericks,(set! *unchecked-math* true)
21:41clojurebot#error {\n :cause "Can't change/establish root binding of: *unchecked-math* with set"\n :via\n [{:type java.lang.IllegalStateException\n :message "Can't change/establish root binding of: *unchecked-math* with set"\n :at [clojure.lang.Var set "Var.java" 221]}]\n :trace\n [[clojure.lang.Var set "Var.java" 221]\n [sandbox$eval25 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compile...
21:41gfredericksyou can always just call unchecked-foo directly
21:41gfredericks,(unchecked-multiply 382947923 723782542342)
21:41clojurebot469860187885181426
21:42TEttinger,(unchecked-multiply (quot Long/MAX_LONG 2) (quot Long/MAX_LONG 2))
21:42clojurebot#error {\n :cause "Unable to find static field: MAX_LONG in class java.lang.Long"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to find static field: MAX_LONG in class java.lang.Long, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to f...
21:43TEttinger,(unchecked-multiply (quot Long/MAXVALUE 2) (quot Long/MAX_VALUE 2))
21:43clojurebot#error {\n :cause "Unable to find static field: MAXVALUE in class java.lang.Long"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to find static field: MAXVALUE in class java.lang.Long, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to f...
21:43TEttinger,(unchecked-multiply (quot Long/MAX_VALUE 2) (quot Long/MAX_VALUE 2))
21:43clojurebot-9223372036854775807
21:43TEttingerNICE
21:43gfredericksyou gotta be careful with them though
21:43TEttingeryeah I got some weird thrown errors
21:43gfredericksthere's this goofy half-bug where they do checked arithmetic if you're not using primitives
21:43gfredericks,((fn [a b] (unchecked-multiply a b)) 2984289278487 472737237232)
21:43clojurebot#error {\n :cause "integer overflow"\n :via\n [{:type java.lang.ArithmeticException\n :message "integer overflow"\n :at [clojure.lang.Numbers throwIntOverflow "Numbers.java" 1501]}]\n :trace\n [[clojure.lang.Numbers throwIntOverflow "Numbers.java" 1501]\n [clojure.lang.Numbers multiply "Numbers.java" 1867]\n [clojure.lang.Numbers$LongOps multiply "Numbers.java" 467]\n [clojure.lang.Numbers ...
21:44TEttingerthat helps a lot thanks
22:33bchamQuick question: In this test, the code isn't being executed and I'm not sure why. The result of the expression ((clean-code "python") ...) is the correct answer, but when I run the test it just shows the unexecuted code. http://pastebin.com/bpv1K7bF
22:36bchamActually I think I figured it out
23:55lvhIn Compojure, how do I spell "anything with this route match *prefix*, go to this handler fn"
23:57lvhbasically /xyzzy, /xyzzy/ and /xyzzy/* (where the asterisk means "anything") should be handed off to this ring handler fn