#clojure logs

2015-07-19

00:23crocketIt's fucking weird.
00:24crocketThe maintainer of https://github.com/ptaoussanis/timbre blocked me from creating new issues because he thinks ANSI colors should be enabled by default in log files.
00:24crocketI knew he was rude, but I didn't know he was very rude.
00:28crocketIt seems timbre is basically a one-man show.
00:40crocketDoes anyone know a good logging library other than timbre?
00:40crocketTimbre is a brainfuck.
00:42anti-freezecrocket: Why so?
00:43anti-freezecrocket: I think there's a logger called tools.logging, but I prefer timbre. (https://github.com/clojure/tools.logging)
00:44crocketanti-freeze, Have you ever tried logging exceptions in a log file with timbre?
00:44anti-freezecrocket: Yes, it was pretty straight forward
00:44crocketNow, there are ANSI colors in exceptions in log files.
00:45anti-freezecrocket: Give me a second to find an example
00:45crocketanti-freeze, The maintainer of timbre blocked me from his timbre github repository because I wanted timbre to disable ANSI colors in log files.
00:45crocketDo not use timbre.
00:46crocketIf you use timbre, replace it with something else as soon as possible.
00:46crocketDo not rely on anything written by the maintainer of timbre.
00:47anti-freezecrocket: Hold on, I'm using a straight up (set-log-file (get-in config/env [:log :file])) and I have no issues
00:47anti-freezeUnless you're doing ASCII colours manually
00:47anti-freezeIn which case its not his responsibility to account for that
00:47crocketanti-freeze, Use the latest version of timbre, and log an exception to a file.
00:48crocket(log/info (Exception. "hi"))
00:48crocketYou can make a test project to test it.
00:48anti-freezecrocket: I see. Alright, how about you define a custom appender that uses filter to remove the colours?
00:49anti-freezecrocket: And then maybe submit a pull request to timbre
00:49crocketanti-freeze, As I said above, the maintainer of timbre blocked me from his repository.
00:49crocketThis means I can't submit a pull request or an issue.
00:49crocketI submitted a pull request that disables ANSI colors in rotor appender, which is a file appender.
00:49crocketHe turned it down.
00:49anti-freezecrocket: Well as a temporary solution, it works. We can't help when maintainers are assholes
00:50anti-freezecrocket: Did he give you a reason?
00:50crocketanti-freeze, Replace it with something else as soon as possible.
00:50crocketanti-freeze, He said some people wanted ANSI colors by default.
00:50crocketI think some people include only 'him'.
00:51anti-freezecrocket: Well, atleast he gave his reasoning. I don't see the issue with just using your custom version if you really want that functionality. Otherwise, there's tools.logging, which I didn't particularly enjoy
00:51iceCupaOLA
00:51iceCupaHello fellas
00:52crocketanti-freeze, Why did you not enjoy tools.logging?
00:52crocketIt seems tools.logging is another project maintained by a rude hermit.
00:53anti-freezecrocket: I don't remember. Last time I used it, it was lacking quite a bit. You know, you could write another logging library, they're not difficult to make. Call it YAL (Yet another logger) and state that you're not an asshole
00:54anti-freezelacking as in it didn't quite match up with my requirements
00:54anti-freezeNot to say that it doens't get the job done for others
00:54crocketanti-freeze, I wouldn't write another library if possible.
00:56anti-freezecrocket: Well you seem unsatisfied with the current state of logger libraries and if you're saying to yourself a "Someone outta do that", its probably a good idea to get started
00:56crocketAs long as tools.logging doesn't require me to write any configuration file without sacrificing configurability, I'm good.
00:57oahnercrocket: why not simply disable ANSI colors in timbre?
00:57crocketoahner, I wasted a few hours on figuring out how to disable ANSI colors in timbre.
00:58crocketEventually, the maintainer of timbre told me how to do it and blocked me from his repo.
00:58crocketThe maintainer didn't document how to disable ANSI colors in timbre.
00:58crocketObviously, the maintainer of timbre wants to push ANSI colors to everyone.
01:00oahnercrocket: so you have your solution?
01:00crocketoahner, I'm going to try tools.logging and decide what to do later.
01:02crocketOh, I could fork timbre and rename it.
01:06crocketOh god, tools.logging brings back the nightmare of logback.
01:07anti-freezecrocket: Yep. Just make your own fork man.
01:16crocketanti-freeze, Were you burnt by the maintainer before?
01:17anti-freezecrocket: Not really. When maintainers piss me off I either fork and maintain my own version or if I can justify it I begin a rewrite
01:23anti-freezecrocket: Ain't nobody got time to deal with arsy maintainers
01:25crocketha
01:26anti-freezecrocket: Life is too short, fork it.
01:26anti-freezecrocket: That should be a T-Shirt
01:28crocketI'll fork it when I find time.
01:30crocketHowever, I can't still believe that clojure only has two logging libraries.
01:30crockettimbre and tools.logging
01:31crocketI thought clojure had more momentum than that.
01:32crocketHmm....
01:32crocketNo
01:32crocketI'm going to write a very simple one.
01:32crocketThis is a mess.
01:34diyfupecocrocket, I used log4j, which worked fine. Maybe the problem is, that there are already good libraries out there which are written in Java?
01:36crocketdiyfupeco, log4j doesn't easily permit programmatic configuration.
01:36diyfupecocrocket, I know. Just wanted to say that are already tools (which a user may even know from earlier work).
01:37diyfupecocrocket, I'd like to see what you come up with though. Sign me up to your mailing list. :)
01:41crocketShould I have a global log configuration in a log library?
01:41crocketThis means impurity.
01:45anti-freezecrocket: Generally, people prefer using the lein config. I set up my own custom config loading, but that's application specific. I don't think you should enforce a specific configuration format
01:46crocket???
01:46lazybotcrocket: How could that be wrong?
01:47crockettimbre has *config*
01:51crocketlogback also doesn't easily permit programmatic configuration
02:03anti-freezecrocket: Its up to you really. I personally prefer a minimal config that can easily be integrated in to my application config
02:34crocketDoes anyone know an alternative to tools.logging and timbre?
03:14wasamasalol, it's possible to *block* people on github from creating issues and pull requests?
03:17wasamasaapparently it is: https://help.github.com/articles/blocking-a-user/
03:20oahnerwasamasa: I would assume because there's already email, irc, slack and everything on the internet for that
03:20oahnernot to mention, handling spam sucks
03:20wasamasaoahner: well, you'd first need to figure out their contact details
03:21wasamasaoahner: and that's a bit tricky if they haven't got anything useful listed in their profile, so I had to resort to looking up the DNS details of their website a bunch of times to mail them
03:22oahnerthat's true, but if you're on someone's github page, odds are you wish you want to discuss something related to a project, so the project's issue tracker probably should be tried first :P
03:23wasamasamost of the time, yes
04:53PupenoWhat should I do if I want to push a modified version of a library to clojars to use it in one of my projects before my changes are accepted upstream and released?
04:55TEttingerPupeno: use a different... what's the word... the part of the name that isn't the artifact ID. like if there's some org.clojure/dance-music , you would make com.pupeno/dance-music
04:55PupenoI see.
04:55TEttingerit automatically gets marked as unofficial pretty much
04:55TEttingerthere's a curated thing on clojars, kinda?
04:56TEttingerbut there's also a free-for-all thing
04:56TEttingerdifferent repos
04:56PupenoWhat should I do the with the version? the current version is 0.4.2... should I set it to 0.4.2.1 or something like that?
04:59dysfunTEttinger: 'group identifier'
05:01dysfunPupeno: it's a different package. you need not change it at all, but depending on what you're going to change, you may want to consider restarting the version numbering
07:37crocketDid anyone use unilog?
08:07grgrHi! This is a question about using Clojure with JVM. I installed Java 8 on my Mac, with the .dmg from java.com. If I were to run graphical Java programs, they would (I guess) start with Java 8. But when I run `java -version`, it tells me I'm on 1.7. When I run Cider (in Emacs), it also is using 1.7. How can I make lein & cider and all other clojure tools use Java 1.8 instead?
08:20grgrThe solution to my problem, if anyone in the same situation, is to install Java via homebrew instead of shitty Oracle installer. You want to install Homebrew Cask (https://github.com/caskroom/homebrew-cask), and then `brew cask install java`.
08:21oddcullygrgr: your problem was most likely around wrong set environment vars
09:05crocketWhy is org.clojure/tools.logging 0.3.1 missing in clojars.org?
09:06blkcatgood morning
09:07liuchanggood night
09:20andyfcrocket: Clojure, tools.logging, and all Clojure contrib libraries are released on maven.org, not Clojars. Search at search.maven.org
09:33crocketok
09:35arkhcrocket: is the something you don't like about timbre?
09:36arkhrhg135: did you find a solution?
09:44crocketarkh, timbre maintainer blocked me from creating pull requests and issues on his github repo because I wanted ANSI colors to be disabled by default in file appenders.
09:44arkhoh ok
09:44crocketarkh, I'm in the process of replacing timbre with clojure.tools.logging and unilog.
09:44crocketarkh, Do you know what I mean by ANSI colors in log files?
09:45crocketIt is a brainfuck.
09:45arkhescape sequences embedded with what you're trying to output, right?
09:45crocketyes
09:46crocketIt makes it impossible to read stack traces in log files.
09:46arkhhmm
09:46crocketSomehow, he was very rude from the beginning.
09:47crocketarkh, unilog configures logback with a map.
09:47crockettools.logging uses logback in the background.
09:48wasamasajust read the logs with `less` :P
09:54crocketLogging anything other than plain text in a log file is a brain damage.
09:54wasamasathat aside, I don't believe you were blocked for that issue specifically
09:55crocketI'm pretty sure I was blocked for wanting to push a change that disables ANSI colors in log files.
09:55crocketEven now, I can't believe I was blocked.
09:56crocketThe vast majority of people at least consider my github issues for days.
09:56crocketA small subset of people have 'no' empathy at all, and they don't hesitate blocking others.
09:57crocketThat's why it's so hard to believe that psychopathic behaviors happened.
09:57arkhyou could fork it
09:58crocketarkh, No, I'm replacing it with tools.loggin and unilog.
09:58crocketIt is saner.
09:58arkhunilog looks good, too
09:58crockettools.logging + unilog is actually simpler than timbre.
09:58crocketas long as you use what is provided.
09:59wasamasaFWIW, I don't see anything unusual in any of your issues/PRs
09:59wasamasathe questions you've posed were answered in all closed ones
09:59crocketHe blocked me right after he closed my last issue.
09:59wasamasaand as for the reason why the author didn't implement any of your suggestions, it's third-party code
09:59crocketAnd, he was very quick to close my issues.
10:00wasamasathe kind of code you get from someone else and don't know at all to make any changes to it
10:00crocketHe didn't even say sorry for closing my issues without a word.
10:00wasamasayou wrote there that you solved it yourself...
10:00crocketIt was a workaround, but not a solution.
10:01crocketTo really close the issue, there needs to be more documentation or a permanent solution.
10:01crockettimbre author didn't really document a way to turn off ANSI colors.
10:01crocketAnyway, he is an ass.
10:02crocketDon't rely on his libraries if your career or sanity is at stake.
10:03crocketHe clearly lacked any civil etiquette from the beginning.
10:04wasamasayou know, the usual reaction to a ban is reconsidering your own behaviour and reflecting what might have been possibly wrong about it
10:05crocketSince his actions were so absent of etiquette, I didn't have to contemplate about my behaviors.
10:05arkhcrocket: this is the wrong channel for attacking someone's character. We're all free to use whatever libraries we wish - unilog looks. Be well.
10:05wasamasaright, there's a #clojure-offtopic channel IIRC
10:07crocketok
10:08crocketSorry for being angry here.
10:44crocketDoes anyone know how to launch a stepping clojure debugger in emacs?
10:44crocketC-u C-M-x doesn't launch a debugging session.
11:39bensumfikes, cljs-1349 filed for the lein test failures we discussed yesterday
11:41mfikesbensu: Cool. I won't dup that one ;)
11:43bensumfikes, haha :) I only new about IKVReduce because I was about to take it when somebody commented "I'll do it!"
11:44bensus/new/knew -> s/knew/remember
12:07crocketDoes anyone debug clojure in emacs?
12:56dnolenmfikes: ping
12:56mfikesdnolen: pong
13:28crocketDoes *out* pull from System/out now?
13:28crocketnREPL fails to capture System/out in *out*.
13:44justin_smithcrocket: *out* doesn't pull from anything. It's a binding for an output channel. cider intentionally does not use System/out for output to its repl
13:44justin_smithcrocket: if you use cider-jack-in it uses a separate buffer for things printed to *out*
13:44justin_smitherr, for things printed to System/out that is
13:44crocketThe problem is logback.
13:45crocketlogback prints to System/out
13:45crocketcider repl fails to capture logback output.
13:45justin_smithyeah, logback stuff will not show up in your repl with cider, I have conversed with bbatsov, this is considered a feature
13:45crocketWhat
13:45justin_smithcrocket: it does output it, it goes to a separate buffer
13:45crocketHow do I capture it?
13:45justin_smithcrocket: he doesn't want the log output in the repl, because he does not consider it part of the repl interaction
13:46crocketI checked github issues, and it is not a feature.
13:46justin_smithyou open the other buffer, something like *nrepl output* iir
13:46justin_smith*iirc
13:46crocketThey closed the issue because it is an nREPL issue.
13:47justin_smithcrocket: I told him how to fix it. If they used the process buffer as the repl interaction buffer (like pretty much all other language repl modes do) the output would go to the expected place
13:47justin_smithbut he does not want that behavior
13:48crocketMeh
13:48crocketIgnoring market signals(including yours) is hardly good.
13:49justin_smithit could be, that technically the nrepl interaction model makes it so he can't do that...
13:50justin_smithcrocket: open source maintainers don't owe me shit. They aren't getting paid to do what I want. I make suggestions, and maybe they like the idea, maybe they don't. I decided not to use cider, but I am sure bbatsov doesn't care, it doesn't hurt him at all that I made that choice.
13:50crocketjustin_smith, I was referring to C4.1 process adopted by ZeroMQ community.
13:51crocketZeroMQ community tends to accept whatever doesn't break existing users.
13:51justin_smithcider isn't a community, it's one dude's project that some other people use
13:52justin_smithit would be cool if it were a community, but it really isn't
13:52crocketIf he was a free-market capitalist guy, he would have made a community with cider.
13:52justin_smithsimilar with clojure, there's a community of people using it, but it's run top down by rhickey, that's just how it is
13:55crocketReally?
13:56crocketEven, linus eventually hired sergeants.
13:56justin_smithcrocket: clojure isn't run by consensus or user input. Rich Hickey listens to community feedback, but there is no community driven process, it's totally run top-down.
13:57justin_smithcrocket: sure he has people like puredanger, but it's still a top-down project.
13:57crocketjustin_smith, Was cider's maintainer rude when he rejected?
13:57justin_smithcrocket: not at all
13:57crocketThen, it should be ok
13:57justin_smithhe explained why he didn't want it to be that way, and that was that
13:57justin_smithhe probably would have been rude if I had started arguing I guess
13:59wasamasafun fact: zmq got into trouble later on with their mindless api expansions :P
13:59justin_smithwasamasa: I can see how arbitrarily accepting new features would do that...
14:00wasamasajustin_smith: according to the developers it just got very hard to guarantee nothing to ever break
14:00wasamasajustin_smith: later one of them did a rewrite in C
14:16nenorbotAnyone know how to change the Clojure version when launching lein repl outside a project? Changing my ~/.lein/profiles.clj didn't help
14:16justin_smithnenorbot: you could fork leiningen
14:18justin_smithor wait for a new leiningen that uses 1.7 I guess
14:19nenorbotjustin_smith: i'll just run a repl inside a project :)
14:39tmtwdHow can I iterate through a map like this and get all the keys and values in just rows? {:content "lolcode", :author "TIMOTHY", :title "Good morning", :id 0}{:content "CONTENT", :author "jeff", :title "titletsr", :id 1}{:content "lolcode", :author "TIMOTHY", :title "Good morning", :id 2}{:content "hehne", :author "no prob", :title "yeah", :id 3}
14:40tmtwdand without the ids
14:43ro_st(let [maps [{:content "lolcode", :author "TIMOTHY", :title "Good morning", :id 0}
14:43ro_st {:content "CONTENT", :author "jeff", :title "titletsr", :id 1}
14:43ro_st {:content "lolcode", :author "TIMOTHY", :title "Good morning", :id 2}
14:43ro_st {:content "hehne", :author "no prob", :title "yeah", :id 3}]
14:43ro_st ks (keys (dissoc (first maps) :id))]
14:43ro_st (map (apply juxt ks) maps))
14:46justin_smithro_st: don't do that
14:46dpathakjthat assumes the first thing in your list has all the keys you want
14:47ro_stapologies, justin_smith - do you mean the paste? or did i write bad code?
14:47justin_smithmulti-line paste
14:47ro_stdpathakj: yes. tmtwd is welcome to write code to gather all the keys and handle missing keys on his own :-)
14:47ro_sti do apologise
14:48justin_smithro_st: your answer won't get the keys, only the values
14:48tmtwdwait that just returns a list of vectors?
14:48justin_smithtmtwd: what does "in just rows" mean?
14:48ro_stalso true. tmtwd perhaps if you show what you mean by a 'row'
14:48dpathakjits output is ([“lolcode" "Good morning" "TIMOTHY"]
14:48dpathakj ["CONTENT" "titletsr" "jeff"]
14:48dpathakj ["lolcode" "Good morning" "TIMOTHY"]
14:49dpathakj ["hehne" "yeah" "no prob"])
14:49dpathakjugh, sorry, that was a multiline paste
14:49tmtwdi meant like pargraphs or divs in html
14:50tmtwdin hiccup - kind of irrelevant I suppose
14:50justin_smithtmtwd: can you give an example of one row?
14:50dpathakjwhat’s the problem you are trying to solve? are you actually trying to generate html, or is it something else?
14:51tmtwdTitle: Good Morning , Author: Timothy, lolcode
14:51tmtwdyes Im generating html
14:51tmtwdusing hiccup
15:00tmtwdI tried that function http://pastebin.com/jKpsSWkt but I get a class cast exception
15:02justin_smithwas the exception because get-messages is not a hash-map? by the name I would guess it is a function that gets a hash-map
15:05justin_smithtmtwd: also "a class cast exception" is really generic, it's more helpful if you can add the full message and stack trace to the paste
15:05tmtwdyes you are right
15:06tmtwdget-messages returns a hash-map
15:06justin_smithso I would think you'd want [(get-messages)]
15:06justin_smithnot a sequential of hash-maps? if it was that, (get-messages) would suffice
15:08tmtwdit is a sequential of hash-maps I belive
15:08tmtwd clojure.lang.LazySeq cannot be cast to clojure.lang.IPersistentMap
15:09tmtwdso I need to establish that it is a list of hash-maps?
15:14justin_smithright, so use (get-messages) rather than [(get-messages)]
15:15tmtwdoh, right I think I know what to do :)
15:39monstaHello, can anyone tel me how to remove and get a specific char from a string
15:40joegallomonsta: what are you really trying to do? java strings are too amenable to that sort of thing. i mean, it can be done (after a fashion), but that's not really how folks typically attack the problem.
15:40justin_smithmonsta: remove and get?
15:40joegallos/are too/aren't too/
15:41justin_smithmonsta: since strings are immutable, the best you can do is return a new string with that character taken out.
15:41monstalike: remove "b" from "abcd" = "acd"
15:41justin_smithoh, so you don't need to "get" anytyhing at all
15:41joegallois this just an academic exercise, though, or is it a part of some bigger thing?
15:42monstathe get part that I was refering to is like: get "b" from "abcd" = "b"
15:42justin_smithmonsta: you'd have to return a collection for that
15:43monstaso filter?
15:43LollypopDo you have the char you want or the do have the index of the char?
15:43monstaI have the index
15:43Lollypopyou can get the char with .charAt
15:44Lollypop,(.charAt "abcd" 1)
15:44clojurebot\b
15:44monstauhh, I forgot all about Java
15:45monstathen how do I return "abcd" without \b
15:46Lollypopyou concat two substrings, one before and one after
15:46justin_smith,(#(str (subs % 0 (dec %2)) (subs % %2)) "abcd" 1)
15:46clojurebot"bcd"
15:46justin_smitherr
15:47justin_smith,(#(str (subs % 0 %2) (subs % (inc %2))) "abcd" 1)
15:47clojurebot"acd"
15:47monstaOk, I will try. Thanks
15:55tmtwd how do you do a foreach for a list?
15:55justin_smith,(defn stringectomy [st idx] [(.charAt st idx) (str (subs st 0 idx) (subs st (inc idx)))])
15:55clojurebot#'sandbox/stringectomy
15:56justin_smith,(stringectomy "abcd" 1)
15:56clojurebot[\b "acd"]
15:56justin_smithtmtwd: tmtwd doseq if you don't need a return value, for if you do
15:57tmtwdjustin_smith, is for just for vectors?
15:58justin_smith,(for [c "hello"] (char (inc (int c))))
15:58clojurebot(\i \f \m \m \p)
15:58justin_smith,(apply str (for [c "hello"] (char (inc (int c)))))
15:58clojurebot"ifmmp"
15:59tmtwdthanks
15:59justin_smithtmtwd: for works on anything seqable. Lots of things are seqable.
16:32noncom|2what would be the best analogy for core.async, but *synchronous* ?
16:33noncom|2in other words, is there any synchronous message delivery library for clojure ?
16:44monstajustin_smith: (defn stringectonomy [s i]
16:44monsta ((juxt #(.charAt % i) #(str (subs % 0 i) (subs % (inc i)))) s))
16:44tmtwd [ :h3 (first message) " (by: " (nth (message) 2)]]))) I get the error Wrong number of args (0) passed to: PersistentArrayMap for this line of hiccup
16:44justin_smithmonsta: I started with that, but it's needlessly verbose
16:45justin_smithtmtwd: (message) is weird
16:45justin_smithunless message is a function of no args...
16:45monstayup, but still :1
16:45tmtwdit says nth not supported on this type?
16:46justin_smithtmtwd: what is the type of "message" - if it isn't a function of 0 args, if it isn't a sequential you shouldn't be doing (nth message x)
16:47justin_smithtmtwd: based on prior context, I assume message is a hash map, neither of those operations make sense if it is a hash map
16:47tmtwdthanks, my bad
16:47justin_smithI mean even "first" is iffy in that case, though clojure lets you do it
16:48justin_smith,(first {:a 0 :b 1 :c 2 :d 3 :e 4 :f 5 :g 6 :h 7 :i 8 :j 9 :k 10})
16:48clojurebot[:e 4]
16:49tmtwdah yes
16:49rhg135arkh: yes, (-> path io/resource io/file .gePath load-file)
16:49tmtwdmy problem is that clojure let me use first
16:49rhg135getPath*
16:59clojurenoobI'm dealing with this situation in Korma: when I have (where (= :key val)) I get a valid query, whereas using (where temp) with temp being (= :key val), temp is not being translated.. I guess this has to do with macros being processed before run-time? is there anything I can do about this?
17:01tmtwdwhat do I use to access elements of a vector by index?
17:01tmtwdnvm
17:02justin_smithtmtwd: nth, get, or just calling it
17:02tmtwdIm okay, I was trying to call get on a map......
17:02tmtwdhehe
17:02justin_smithget on a map works too, just make sure to use the keys
17:08ed-gclojurenoob, For what its worth I found Korma confusing, and ended up moving to YESQL.
17:08clojurenoobhm, maybe I should look into that one then. I must say it's also confusing me
17:09ed-gI moved the fancy joins into the database as views to keep the sql code more concise in the application.
17:10ed-gAlso I found my life got easier when I realized I can mix and match clojure database libraries so if one library is more convenient for a purpose I can use it for that, and still use direct jdbc calls when that's more straightforward.
17:12clojurenoobunfortunately YESQL seems to be better suited for static queries
17:12clojurenoobI'm dealing with something that has to be quite dynamic :(
17:12ed-gclojurenoob, can you share the code?
17:15noncom|2,(keyword "how are we supposed to deal with this?")
17:15clojurebot:how are we supposed to deal with this?
17:15noncom|2,(symbol "'or even with this?")
17:15clojurebot'or even with this?
17:16noncom|2,(symbol "'this symbol has 'quote and spaces\space:)':)")
17:16clojurebot#<RuntimeException java.lang.RuntimeException: Unsupported escape character: \s>
17:16noncom|2,(symbol "'this symbol has 'quote and spaces:)':)")
17:16clojurebot'this symbol has 'quote and spaces:)':)
17:16noncom|2,(symbol "'this symbol has 'quote and spaces \space :)':)")
17:16clojurebot#<RuntimeException java.lang.RuntimeException: Unsupported escape character: \s>
17:16noncom|2huh..
17:17ed-gnoncom|2, run the string through a regular expression first, to convert non keyword-able characters?
17:17noncom|2yeah, that'd probably work... but it is funny to be able to do this thing
17:17ed-gs/ /-/g; s/[^_-A-Za-z]//g
17:18bchamStupid question inbound. I just cannot figure out how to deal with PersistentArrayMaps. my functions/db calls consistently return a map in the form ({:k v}) and I want to do things like merge it with another map {} but then I get errors. Can someone point me to an explanation about how to deal with these?
17:19ed-gbcham, I use http://jafingerhut.github.io/cheatsheet/grimoire/cheatsheet-tiptip-cdocs-summary.html all the time for short usage examples.
17:20ed-g,(merge-with assoc {:a 1} {:b 2})
17:20clojurebot{:a 1, :b 2}
17:20bcham,(merge {:k v} ({:k1 v1})
17:20clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
17:20bcham,(merge {:k v} ({:k1 v1}))
17:20clojurebot#error {\n :cause "Unable to resolve symbol: v in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: v 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: v in this context"\n ...
17:21bcham,(merge {:k "v"} ({:k1 "v1"}))
17:21clojurebot#error {\n :cause "Wrong number of args (0) passed to: PersistentArrayMap"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (0) passed to: PersistentArrayMap"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.AFn invoke "AFn.java" 28]\n [sandbox$eval210 invoke "NO_SOURCE_FILE" 0]\n [cloj...
17:21ed-gyou're trying to call (:{k1 "v1"}) as a function.
17:21ed-g,(merge {:k "v"} {:k1 "v1"})
17:21clojurebot{:k "v", :k1 "v1"}
17:22ed-g,(merge {:k "v"} (first '({:k1 "v1"}))
17:22clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
17:22bchamYeah that's the issue, I know what my problem is. It's calling it like a function, but that is what is being returned from my db-calls in the library I am using. and I don't know how to work around that. I get how to do it, as you just wrote, but I don't know how to work with the paren wrapped version.
17:22clojurenoobed-g: give me a second
17:22bchamI figured out the whole "first" work around but that just feels like the wrong solution
17:23bchamDoes that make sense ed-g? I understand my problem, that it's wrapped like a function call, but the thing is, it shouldn't be. I can call (first ()) but that just feels ugly... So I figured there'd be a more clojured way of doing that.
17:23ed-gbcham, also you can use destructuring bind. (let [[m] [{:k1 "v1"}]] {merge {:k 'v} m))
17:23justin_smithbcham: what do you want to do with the return value? if it returned multiple results, what would you want to do with each of them?
17:24ed-gjustin_smith, yeah that's the better question ;-)
17:24clojurenoobed-g: http://pastebin.com/gBXz7RwA
17:24bchamjustin_smith, the logic being that if a db-query returned multiple results, I should be able to handle that? Well it shouldn't return multiple results as I'm calling a specific `id` key.
17:25justin_smithbcham: if it's guaranteed to return only one result, use first, or if you'd like to feel clever use destructuring instead
17:25clojurenoobed-g: my goal is to get the query at the bottom to work with cl instead of (= :CBORD "KM1")
17:25bchamnot clever enough to want to feel clever :). Thanks justin_smith and ed-g
17:25justin_smithbcham: it always returns a sequence, because the database calls themselves are always allowed to return multiple results (regardless of what you know about the query / schema)
17:26bchamGotcha, that makes sense now.
17:26bchamthanks so much
17:26bchamsuper helpful
17:27justin_smithbcham: imagine how much harder it would be to write code to deal with a function that sometimes returns a sequence, and sometimes a hash-map
17:27bchamyeah, when I think about it that way it makes a ton more sense. So much more logical that way.
17:27justin_smithbcham: if you weren't careful the conditionals to handle each of these cases could leak all through the codebase...
17:28bchamThat's why I come to the IRC channel, so much learning to be had here.
17:29ed-gclojurenoob, I'm looking at the database code, my question is what task does this code accomplish?
17:30ed-git looks like there is some kind of program stored in the database and you're interpreting it using clojure?
17:32ed-gfor one thing you'll want cl to be a function instead of a value. It's being evaluated at compile time.
17:34ed-gAlso its better form to use a let form that to redefine toplevel var's at run time.
17:35ed-g*than* to redefine var's
17:37ed-gI don't know whether you have the authority to change the database schema, but it could make things simpler to move each "OP" to its own table which you can join to webqryr rather than as a tag within webqryr.wsopr
17:37ed-gMy $0.02 anyhow.
17:38ed-gIf your application really requires building dynamic SQL, I would also consider going full monty and writing a database function to build and then EXECUTE the SQL within DB.
17:39squeedeeHey folks. Im using Midje to test some code, and I want to make sure that my function, in a specific case, returns '+' (as in the function).
17:39ed-gBut hard to say without knowing more about what the application is.
17:39ed-gsqueedee, can you compare (= '+ (yourfn ...))
17:40ed-grather, lose the '+ and use +
17:40clojurenoobunfortunately I can't change the schema, this is what I have to work with :)
17:40ed-gclojurenoob, what does the application do?
17:40squeedeeyeah withor without the quote its failing for me
17:40clojurenoobed-g, I'm basically trying to rebuild an SQL query which components are stored in my database
17:40squeedeeI think it's an artifact of Midje's macros. I might try it with .test first
17:41tmtwdhttp://pastebin.com/BED5yKim when I do this in compojure the routes don't work
17:41justin_smithed-g: '+ is not the function +
17:41ed-gclojurenoob, I understand. I think that's an inherently messy process regardless of which library you use.
17:42justin_smithed-g: squeedee: compare + itself, or @(resolve '+)
17:42tmtwdfor example (GET "/" [] "hey") works, but (GET "/messages/new" [] "hi there") doesn't work
17:42justin_smith,(= @(resolve '+) +)
17:42clojurebottrue
17:42justin_smith,(= '+ +)
17:42clojurebotfalse
17:42ed-gjustin_smith, yeah I was stuck halfway to common lisp ;-)
17:42justin_smithheh
17:43justin_smith~lisp-2
17:43clojurebotExcuse me?
17:43justin_smithoh, I was hoping we had a witty factoid
17:43scriptor~lisp2
17:43clojurebotI don't understand.
17:44squeedeeYeah it's definitely something in mije
17:44tmtwdnvm my code works
17:44ed-gtmtwd, glad we could help! ;-)
17:45ed-gsqueedee, can you post the function you're testing, and the failing test?
17:46squeedee(test (= + +)) is fine.. (fact "plus is plus" + => +) fails with:
17:46squeedeehttps://www.irccloud.com/pastebin/SJOIuwwJ/
17:46squeedeeed-g yeah was just making a reduction for you :D
17:47justin_smithsqueedee: I don't know midge, but "checking function" makes me think that there is something else going on there
17:47squeedeei think midge see's the function as a 'matcher'
17:47squeedeeI'll look into it some more.
17:47squeedeeWas hoping someone just knew :D
17:47ed-gwhat happens if you test (= (fact "plus is plus" + => +) core/+) ?
17:47justin_smith~midge
17:47clojurebotGabh mo leithscéal?
17:47justin_smitherr
17:47justin_smith~midje
17:47clojurebotmidje is :(
17:48ed-gnamespacing the symbol?
17:48justin_smithalso, who the hell aliases clojure.core as core? that's weird
17:49squeedeeThere are things i like about Marick's thinking around tests
17:49squeedeeso I want to explore Midje.
17:50squeedeeHe's inspired me on a number of occasions on a bunch of different topics, i'll suspend disbelief
17:51squeedeethis i think is what is hapenning https://github.com/marick/Midje/wiki/Checkers
17:52justin_smithsqueedee: maybe you want (fact (identity +) => +) - just cargo culting those docs
17:52justin_smithoh wait!
17:52squeedeeother side maybe
17:52justin_smith(fact + => #(= + %))
17:52squeedeegah
17:52squeedeelooking through the issues :D
17:53squeedeeif it starts looking like that I'll just leave :D
17:53justin_smithI don't know how the macros are working there, it could just be (fact + => (= +))
17:54justin_smith(dec macros)
17:54lazybot⇒ -1
17:54ed-gsqueedee, is the issue that Midje will try to execute a function argument? perhaps if you compared the name of the function rather than function itself?
17:54squeedeeed-g: that might solve it too. I just don't like it.
17:56ed-gsqueedee, good luck. See y'all later.
17:56squeedeeciao
17:57squeedeejustin, inserting the 'equal' checker works
17:57squeedeeIt's just ugly
18:02squeedeejustin_smith: I found the answer in the docs, in case anyone else asks the same esoteric thing.. It's `(+ => (exactly +))`
18:05justin_smithcool
18:17tmtwdHow do we generate forms in hiccup? http://pastebin.com/t389s1U2 I tried this
18:31justin_smithtmtwd: I think you want :label and not label, and options (foo=bar style) after that should be in a hash-map
18:38reutermjHey, does anyone know how to get gradle working with clojure?
18:56tmtwdanyone know any resources to make forms in hiccup?
20:41mistaBIZ_hello, what is supposed to be in .lein/profiles.clj?
20:45mistaBIZ_upon trying to create a new project or run repl im getting an error pointing to that, and it is somehow blank
20:55justin_smithmistaBIZ_: ~/.lein/profiles.clj should contain a map of keywords indicating run profiles
20:56justin_smithmistaBIZ_: perhaps try setting aside your whole ~/.lein/ first?
20:56justin_smith(eg. moving it somewhere other than your home directory, temporarily)
21:02bchamHey in emacs, I'll commonly give myself some extra spaces between closing parens, like when adding parts to a function or something like that. is there anyway to mass delete all the space between two closing parens? ie ) ) to ))?
21:09amalloybcham: are you using paredit? if so, you can just press ]. if not, you should try it
21:10bchamI am, and that's what I was looking for amalloy.
21:10bchamThat works perfectly man I knew someone had solved this problem :)
21:21mistaBIZ_what is the default in .lein/profiles.clj?
21:23justin_smithmistaBIZ_: it can just be an empty file.
21:24justin_smithmistaBIZ_: and remember it is ~/.lein/profiles.clj - the one in your home directory is the important one
21:31mistaBIZ_a
21:33mistaBIZ_trying to open repl or project / app any.. is saying "Error reading from profiles.clj
21:51mistaBIZyeah, i can run 0 lein commands
21:51justin_smiththen delete the file
21:51justin_smithor fix it
21:52scriptoris there more to the error? Pastebin it if you need to
21:54mistaBIZhttp://pastebin.com/V5KisFuj
21:54justin_smithmistaBIZ: just delete the file, you don't need it
21:54justin_smithand the error will go away
21:54justin_smithor, you could paste the contents, and someone could tell you how to fix it
21:54mistaBIZk will give it a go justin
21:57mistaBIZjstin removing file worked, that makes no sense, whats pointing to it?
21:57justin_smithmistaBIZ: lein reads the file when it starts up
21:57justin_smithmistaBIZ: so if the file is broken, lein just fails
21:59Wild_Cat...and since it's your user-wide profiles.clj, it's read for *every* project you attempt to open
21:59Wild_Cat(which means that if it's broken they all fail)
21:59mistaBIZyeah but does that inhibit me from making global deps in future?
22:00mistaBIZor is it ther lack of specificity to current deps (empty profiles.clj)
22:00mistaBIZi would have hoped it would be smarter =n
22:00justin_smithmistaBIZ: the error you were getting was caused by invalid contents of the file. If you fixed the file it would work.
22:01justin_smithmistaBIZ: it's plenty smart, but it thinks it is more helpful to fail and let you know it was misconfigured, rather than continue without your customization
22:02mistaBIZok, thanks all
23:43crocketStepping into java libraries in a clojure debug session seems impossible.
23:54crocketI can't figure out why logback fails to roll log files.