#clojure logs

2015-02-17

00:14justin_smithdoes this look like a cromulent way to do a timeout without core.async? https://www.refheap.com/97344
00:14justin_smithif definitely behaves properly, but it feels very low level
00:19justin_smithon my machine (timeout 1 #(apply *' (range 1 1000)))
00:19justin_smithreturns nil sometimes, and a huge number spanning about 50 lines others
00:26justin_smithupdated with frequencies for repeated usage https://www.refheap.com/97344
00:28l1xyeah this looks good to
00:28justin_smithl1x: your issue reminded me of this thing I brainstormed
00:28justin_smithI think it's decent, but wanted to get second opinions
00:35l1xyep, i might even use your code if you dont mind
00:35justin_smithoh, please do
00:36l1xthanks!
00:36justin_smithit might be handy as a macro, which would allow an arbitrary body instead of a function
00:36justin_smithbut I don't think having to pass a lambda is too ugly
00:39l1xnah its fine
00:53justin_smithl1x: one caveat is that cancelling futures / threads is tricky in the jvm, some actions aren't guaranteed interruptable
00:53justin_smithbut in general polling for some result should be
00:54justin_smithbut eg. a long running system call may keep going even if it had ben cancelled
00:55justin_smithhttp://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#interrupt() details on that
00:56justin_smithl1x: I think for your usage it hinges on whether the input you are reading on is interruptable or blocked on a Selector
00:57justin_smithworst case though is I guess that some thread hangs around waiting for a result that your main flow of logic gave up on
00:59l1xyeah i am going to test these
00:59l1xsee what happens
01:00justin_smitheasiest is to add a print after the data is fully received
01:00justin_smithbut if you (or the lib that does your async http request) is using nio, the cancel should do it's thing
01:01justin_smithl1x: for example if you use this lib, cancelling will make the request process stop https://github.com/neotyk/http.async.client
01:01justin_smithsome other libs, it may not
01:03justin_smithl1x: actually, http.async.client has a :timeout option built in, even better :)
01:04justin_smithdocumented here https://github.com/neotyk/http.async.client/blob/development/docs.org#timeout
02:21vashow do I make sure a symbol is bound ? is (resolve ) the preferred approach?
03:06amalloyvas: it is a fairly weird thing to want to do (in addition to being not specific enough to give a real answer). what makes you think you need to do that?
03:08vasamalloy: middleware that checks the :session values to make sure someone is logged in. if :session is not set yet, i get a null pointer exception. how can I check if it's set? i'm looking at if-let currently
04:03dm3hey
04:03zactshi
04:04vashola
04:04dm3does anyone know if it's possible to compile a small clojurescript fragment to javascript
04:04dm3like "(fn [x] x)" -> "function(x) { return x;}"
04:04dm3without any google closure machinery
04:05ro_stpretty sure it's not possible
04:20dysfunvery exciting
04:23jballancdysfun: congrats!
04:24dysfunit doesn't do much (it's a one page site with some template interpolation and serving static files), but it's clojure
04:24dysfunand that seems worth a drink or two
04:24dysfun<3 clients who don't impose a tech stack
04:25dysfunbesides, it's all going to get cached behind nginx anyway, so it's only the admin panel that it'll be serving
04:26jballancEh, my first paid Clojure project was little more than a REST API in front of a HornetQ queue, but getting that first wedge in the tech stack is important
04:30dysfunwell, the client doesn't care and i'm going to end up open-sourcing the cms
04:30dysfunit needs making a bit more flexible, but it'll be great
04:33dysfunis there a way to express this as a destructuring bind in the defn (currently bound to r)? (let [{:keys [username password]} (:params r)]
04:34dysfuni feel like it's doable but i'm having a thinko
04:36Glenjamin[{{:keys [username password]} :params} r]
04:36dysfunperfect, thanks
04:36Glenjamin,(let [r {:params {:username "u" :password "p"}} {{:keys [username password]} :params} r] [username password])
04:37clojurebot["u" "p"]
04:37Glenjaminyeah, that's the one
04:38dysfun,(defn foo [{{:keys [username password]} :params :as r}] [username password r])
04:38clojurebot#'sandbox/foo
04:39dysfun, (foo {:params {:username :u :password :p}})
04:39clojurebot[:u :p {:params {:password :p, :username :u}}]
04:39dysfunthanks Glenjamin
04:39dysfun(inc Glenjamin)
04:39lazybot⇒ 14
04:49zotany suggestions for debugging a dependency (lein-repack) that isn't in my project.clj, and doesn't appear with lein deps :tree? it appears to be responsible for breaking my deps (exclusion suggestion when running midje), but i can't see its origin.
04:50Glenjaminzot: try lein deps :plugin-tree
04:51Glenjaminor possibly some variation of with-profile
04:51Glenjaminsome plugins add deps for you, which is magical and confusing
04:51zotGlenjamin: tnx, that's what i was just trying to figure out
04:51zotplugin-tree didn't do it, so it must be a magical profile-based dep
04:52Glenjaminwell, even in that case plugin-tree should show it i think
04:52zotsadly, not.
04:52Glenjaminwhat command are you running that shows the error?
04:53zotlein midje :autotest :filter foo
04:53zothttps://gist.github.com/anonymous/f39978d608f64ba6bbe5
04:54zoti found the "now fixed" bits about cider-nrepl and cljfmt / rewrite-clj, but even with latest snaps, i'm still tracking down origin
04:54zot(go away for 12 day vacation, come back to non-building code. not fun.)
04:55Glenjamindependencies are hard
04:56Glenjamini was once told it wasn't a problem in clojure because "everyone keeps stuff up-to-date". I think that's less true now
04:56zotlol
04:56Glenjaminthat was well over a year ago, to be fair
04:56Glenjaminmaybe over 2 years
04:57zoti think people try. but the system appears (from a relative novice) to have its share of flaws. and i get that packaging is hard. as in H-a-r-d. but that doesn't make it suck less, especially when learning.
04:57Glenjaminafaik the flaws are inherited from java packaging
04:57noncom|2does anyone have experience with raynes conch?
04:58Glenjaminthere's nothing particularly different that clojure does, or tries to do
04:58noncom|2how do i enter the password for sudo with it?
04:58zotthe worst part here is that it's ultimately emacs+repl; but since emacs packaging won't let me revert to cider-repl 0.8.2 without going to stable, i'm screwed either way.
04:58noncom|2i can do (let-programs [sudo "sudo"] (sudo "lalala")) but first it wants password then
04:58Glenjaminnoncom|2: you probably need a user with passwordless sudo enabled
04:59Glenjamini'm not aware of any good systems for entering a sudo password automatically
05:00noncom|2Glenjamin: will this advice work? http://osxdaily.com/2014/02/06/add-user-sudoers-file-mac/
05:00hyPiRionyou probably shouldn't do this for security reasons
05:00Glenjaminentering the password, or setting nopasswd ?
05:00noncom|2Glenjamin: setting nopassword
05:00Glenjaminprobably both tbh, why do you need to sudo?
05:01noncom|2hyPiRion: in this situation i think security is not an issue, the computer is hardly accessible from network anyway
05:02hyPiRionnoncom|2: heh, hence my "probably" – what you can do in that case, is to run the clojure program as root
05:02noncom|2Glenjamin: i need to change the current user of java clojure process. in other words, i have to exec a command as another user
05:03noncom|2hyPiRion: yes, running as a more enabled user is the best option.. but the script starts under TeamCity CI agent and it is configured to run as a lesser user.. I will have to wait for people that configure TeamCity to come back from vacation to do that...
05:03dysfuninherently if you're using sudo, you will have to nopasswd at least that
05:03dysfunyou might also try setuid
05:04dysfuni think setuid only works for binaries, so you might have to knock together a quick c program to exec
05:04IntegralistHi, I'm running the following basic example clojure app (http://goo.gl/hRn0Gq) and I'm getting the following error "Unable to resolve symbol: app-source in this context". I'm not sure why this would be, because when I look at my lib where that's defined (http://goo.gl/f3QcwT) it works when running via lein repl. It's only when I load it within the example application that this error occurs?
05:05slipsetnoncom|2: isn't it great working in a place where you can't get work done because people are not there and you yourself are not authorized?
05:05dysfunsetuid is the mechanism sudo uses, it's just that sudo is setuid root and then does the checks itself. which is why people read the source of it trying to discover new exploits a lot
05:06noncom|2dysfun: strange, but it says that setuid is not found
05:06dysfunthere used to be a good bug where trampolining sudo as sudo sudo sudo would let you in as root :)
05:06dysfunsetuid is a file flag
05:06noncom|2ah
05:07dysfunthere's also setgid
05:07dysfunyou are now in the realms of unix, not the jvm
05:08noncom|2slipset: well, actually that sucks. but in the big picture, if i am helpless and have to wait, i just go doing my own pet projects and feel fine with that :)
05:08dysfunheh. i spent several months going crazy with a client who would hold up all attempts to get things done
05:09dysfunbeing paid well for my time did not make it worth it
05:09dysfunnor did personal projects
05:09Glenjaminanyone know how to google for stack overflow errors?
05:09dysfun:)
05:10dysfuncan you -site:stackoverflow.com ?
05:10Glenjamini dunno, i do want answers from there as well >.<
05:11dysfunthe similar problem i have a lot is products that have ungooglable names
05:11slipsetgo?
05:11slipsetas in go-lang
05:12dysfunkudos to the symfony project for telling all their devs to call it 'symfony2' rather than 'symfony' when they made huge breaking api changes
05:12dysfungo i always google as 'go lang'. but at least they tried
05:13dysfungoogling for scheme things is tedious sometimes, because a lot of things in the real world have schemes
05:15Raynesnoncom|2: You can work with processes interactively.
05:16noncom|2Raynes: you mean i can get the stdin for the process from the returned map and write there?
05:16RaynesAll ya gots to do is wait for the password prompt to pop up in stdout and then throw a password at stdin.
05:17RaynesYou don't even have to wait
05:18Raynesnoncom|2: https://github.com/raynes/conch#piping
05:18RaynesSee the first example
05:18RaynesYou can pass a string to :in and it goes to stdin.
05:18RaynesThe first thing it asks for is a password prompt, right? If so, all you gotta do is push it :in there.
05:19noncom|2well, i tried this: (let-programs [sudo "sudo"] (sudo "lalal" {:in "my-password"})) but it looks like it did not work
05:19noncom|2or it hanged up there
05:19noncom|2for some other reason
05:19noncom|2script execution never continued after that..
05:20hyPiRionnoncom|2: use `sudo -S`, sudo by default reads from the terminal, not stdin
05:20hyPiRion(Also, the password has to be followed by a newline)
05:21noncom|2ah, that is a valuable piece of info
05:23RaynesYup, what hyPiRion said.
05:25swiHello. What lib can i use for tcp/udp socket operations ? Can't see something like this on toolbox
05:26noncom|2swi: i used aleph https://github.com/ztellman/aleph and http://paulosuzart.github.io/blog/2012/07/09/tcp-server-with-clojure-aleph-and-gloss/
05:26noncom|2swi: but surely you can use any java loib
05:26noncom|2*lib
05:27swinoncom|2: oh, thanks. )
05:28Raynesnoncom|2: (sh/with-programs [sudo] (sudo "-S" "ls" {:in "pass\n"}))
05:29RaynesTested this
05:29RaynesIt works
05:29RaynesThough I'm not sure how I feel about helping you sudo from a Clojure program :P
05:29noncom|2Raynes: wow, cool! :) already getting to the same edge
05:30noncom|2hahaha, that is for the Greater Good :)
05:32RaynesI fixed some Python code recently that, rather than just import another piece of code, it instead invoked a Python interpreter and ran the file as a script. Better yet, it invoked it with sudo because that script was writing to a root owned location... rather than just changing the permissions...
05:34noncom|2i totally understand that. besides, everybody knows that machines invented the restricted access to control humans...
05:35noncom|2they're being passively-aggressive with that: "if you do not protect me with a password, all your important and personal data is compromised..".. while truly it rises barriers among people, but not among machines.
05:36hyPiRionI thought the lizard people was behind those things
05:39noncom|2well lizard people are the ones who nurish certain kind of ambitions and techology here (all that security stuff). so yes, that particular thing is a part of their plan, afaik.
06:03noncom|2Raynes: is it possible to pipe more that 1 command with conch?
06:03Raynes?
06:04RaynesOh
06:04noncom|2using (proc) i guess..
06:04noncom|2is a possible solution
06:04Rayneslol noooooo
06:04Raynesu silly
06:04swihm.. how can i ask lein to update/install all deps in project ?
06:05noncom|2swi: afaik there is no auto-update feature..
06:05Raynesnoncom|2: So, by pipe more than one command, do you mean `foo | bar | baz` vs `foo | bar`?
06:06swinoncom|2: well, i mean afair lein must download those deps i'v added to project.clj, no ?
06:06noncom|2Raynes: yes
06:06noncom|2swi: try "lein deps"
06:06Raynesnoncom|2: Once again, see first example here: https://github.com/raynes/conch#piping :P
06:07RaynesYou should be able to :in chain forever, presumably.
06:07noncom|2Raynes: oh :) rrrright, just add one more :in to the inner command..
06:07RaynesThat could be improved.
06:07RaynesI'd like to make it work with ->.
06:07Raynes=D
06:09swinoncom|2: it shows nothing, with :tree it shows aleph and i see it in .m2/repository
06:10noncom|2swi: "lein deps" often shows no ouput, afair.. did not use it from a command line for long time (i am using an IDE)
06:10noncom|2swi: i would suppose that the library is already available from within your project
06:11noncom|2swi: try "lein repl" and then "(require '[aleph.http :as http])"
06:11noncom|2if there is no error, all is intact
06:12swinoncom|2: damn.. require was a mistake. i writen (require '[aleph])
06:12noncom|2swi: also, libraries do not get copied to your project or something. they just reside in the .m2/repository folder.
06:13noncom|2swi: i suggest you getting an ide of sorts.. :) developing in bare cli repl is something rough i think
06:13swinoncom|2: yes, i know about m2, but seems dont' get about require correctly
06:14noncom|2ok, so what does "(require '[aleph.http :as http])" say ?
06:14swinoncom|2: nothing :) i mean no errors :)
06:14noncom|2swi: you must require particular namespaces of a library. not a library itself
06:15noncom|2swi: nothing is fine. it means you have required the lib ok
06:15noncom|2now all what is inside the namespace is available to you..
06:15noncom|2is it your first experience with clojure?
06:15swiso i can't require whole lib anduse it like lib.foo.func ?
06:16noncom|2swi: correct. you can't. only exact namespaces can be required.
06:16swiwell, i'v read a basic intro to clojure about 4-5 month ago.
06:17swiseems like need to reread some book again :)
06:17noncom|2swi: well, don't worry, the concepts are rather simple and once you get some experience, you'll have a firm grasp.
06:18swinoncom|2: practice - mother of mastership :)
06:18noncom|2swi: also, (require) is a function that is to be executed from a repl
06:18swiall can be executed from repl the almighty :)
06:19swinoncom|2: i can't use require in src ?
06:19noncom|2swi: i just want to mention that when you create your own namespace with (ns..) and have (ns mynamepsace (:require [aaa.bbb :as b])) then it is different
06:19noncom|2in src you mainly use the (ns) form
06:19Integral1stHi, I'm running the following basic example clojure app (http://goo.gl/hRn0Gq) and I'm getting the following error "Unable to resolve symbol: app-source in this context". I'm not sure why this would be, because when I look at my lib where that's defined (http://goo.gl/f3QcwT) it works when running via lein repl. It's only when I load it within the example application that this error occurs?
06:19noncom|2that (ns) form declares and creates a ns, and all your requires and imports should be declared there
06:19noncom|2just look at some existing sources..
06:20noncom|2(require) can be used in src, but it is not a usual practice
06:24noncom|2Integral1st: ummm.. where is it referenced in your first source at all?
06:24noncom|2whats the stack trace?
06:24swinoncom|2: hm. thanks for explanation :)
06:25noncom|2swi: yeah, (ns) calls (require) implicitly for all things listed in your (:require ...) list inside the (ns) call :)
06:26swinoncom|2: funny, (require) and (:require) in (ns) are both works :)
06:26BronsaIntegral1st: eval is definitely not the way to go there
06:27noncom|2swi: that is because (require) gets evaluated anyway, effectively returnin "nil" in its place, and (:require) undergoes the usual procedure
06:27noncom|2a bit strange that (ns) tolerates nils but what we could do about that..
06:27noncom|2maybe there is even a reason for that
06:32dysfunthe (ns) just expands to a simple binding form ultimately
06:32dysfunwell, that bit of it does
06:34dysfuniirc it macroexpands to (in-ns 'namespace-symbol)
06:34dysfununder the hood that sets *ns*
07:23aaaaaaaaarrrrHow do I figure out if a certain (aribtrarily deep) list/vector structure is a sub-structure of another?
07:24aaaaaaaaarrrrI tried doing something like (->> (postwalk (partial = a) b) flatten (every? false?) not)
07:24aaaaaaaaarrrrbut that won't work, since postwalk will iteratively replace the innermost values of the structure it's walking
07:25AeroNotixaaaaaaaaarrrr: what's the larger problem you're trying to solve?
07:25hyPiRionwhat do you mean by sub-structure in the first place?
07:25aaaaaaaaarrrrAeroNotix: does a hiccup template contain a certain piece of data anywhere?
07:26AeroNotixWhy don't you know where it is?
07:26aaaaaaaaarrrrhyPiRion: [a [b]] is a sub-structure of [a [b]], [[a [b]] c], etc, but not of [a b]
07:27aaaaaaaaarrrrAeroNotix: I don't care where it is. I'm writig tests
07:30AeroNotixaaaaaaaaarrrr: could use walk with someting that sets an atom if it's just for tests
07:30swi`(+ 2 2)
07:31AeroNotixaaaaaaaaarrrr: https://gist.github.com/AeroNotix/83e1e4d88f8d96e46ad2
07:32aaaaaaaaarrrrAeroNotix: cool, thanks
07:38hyPiRionwhy not just something like
07:38hyPiRion(defn deep-contains? [coll x] (or (if (sequential? coll) (some #(deep-contains? % x) coll)) (= coll x)))
07:39AeroNotixsame difference really
07:39AeroNotixyou still traverse the entire thing, no?
07:39hyPiRionwell, it short-circuits if you find the thing you're looking for
07:40hyPiRionbut yeah, gives you the same result
07:42scottjopps, sorry if I just sent something to channel, I was fiddling with my irc client.
07:55TimMcscottj: You did! The message was: "opps, sorry if I just sent something to channel, I was fiddling with my irc client."
07:56scottjTimMc: ahh. I thought /notice would display me a notice, but I guess it sends one to the channel, but I probably don't have permissions to do that.
07:57Integral1stnoncom|2: Bronsa apologies, I was pulled into a meeting.
07:57TEttingerdid you want /msg ?
07:58noncom|2Integral1st: don't worry, this is irc.. people may appear and disappear and then reappear or not randomly :D
07:59Integral1stnoncom|2: when I execute `lein ring server` from my `spurious-clojure-example` app I get the following stack trace error https://gist.github.com/Integralist/e3a92c4d93d83a385a7a
07:59Glenjaminscottj: i saw the notice
08:01noncom|2Integral1st: so, the eval does not eval in that namespace that you expect
08:01BronsaIntegral1st: using eval that way is also a terrible idea
08:02noncom|2Integral1st: a simple workaround would be (binding [*ns* (find-ns 'spurious-aws-sdk-helper.utils)] (eval ...))
08:02noncom|2Integral1st: but as Bronsa says, this be descouraged
08:03noncom|2better store all your data in a map, so it can be accessed by a key which can be coined
08:09Integral1stnoncom|2: ok so eval is happening in some top level ns. What's an alternative way of achieving this without eval?
08:56maiowhen I define anon function as (fn xyz [] ...) can I somehow get is't name later on? (xyz)
09:03dnolenmaio: xyz in that case is a local name only available to the body of that fn
09:16noncom|2Integral1st: try (ns-resolve ...)
09:17noncom|2Integral1st: although I would *strongly* recommend against a similar approach
09:17noncom|2guessing symbols defined in a namespace is a very bad practice usually, this case included
09:17noncom|2better create a {} of your settings and pick keys from it
09:28Integral1stnoncom|2: ok, so effectively have a map defined in the initial namespace that can be globally available is what's being suggested. I'll have to google that as I didn't think Clojure had a global scope access (I thought everything was scoped to namespaces)
09:28noncomIntegral1st: clojure does not have a global scope, all is indeed scoped to namespaces
09:28noncomIntegral1st: what i meant by saying what i said is
09:29noncomIntegral1st: prefer this: (def my-data {:data-key-a whatever-data-a :data-key-b whatever-data-b ...}) to (def data-key-a whatever-data-a) ...
09:29noncomor, if you want dynamism, (def my-data (atom {...}))
09:30noncomjust avoid guessing variables names
09:30noncomthat is sometimes needed, but only in hardcore metaprogramming, which your case is apparently not
09:32noncomwhen you do (def my-data {:data-key-a whatever-data-a ...}) and you get a string "data-key-a" from somewhere, you can ((keyword key-string) my-data)
09:32noncomIntegral1st: and it'll get you whatever-data-a
09:33noncomyou could even do string keys instead of keyword keys and just (get my-data "some-string-key")
09:34noncomIntegral1st: also, in your case the data and the function that uses it are defined in one namespace, so why complicate things? :)
09:41Integral1stnoncom: ok thanks, I'll have a think about how best to refactor this :-)
09:44gfredericksbtest
09:44gfrederickswhoops
10:33zotis there a portable way to instantiate a record with 0 args? (defrecord Foo [bar baz]) … (map->Foo {}) works, but using map + {} seems inelegant.
10:34zotalthough i suppose it is explicit, in that the keys are (presumably) instantiated w/ nil, instead of not present
10:49justin_smithzot: yeah, (Foo. nil nil)
10:50justin_smithzot: the above is equivalent to (map->Foo {})
10:50justin_smith,(defrecord Foo [bar baz])
10:50clojurebotsandbox.Foo
10:50justin_smith,(= (map->Foo {}) (Foo. nil nil))
10:50clojurebottrue
10:51dmbennettinteresting
10:51justin_smith,(= (->Foo nil nil) (map->Foo {}) (Foo. nil nil))
10:51clojurebottrue
10:51zotjustin_smith: tnx; i figured as much, but wanted something that works for instantiating an empty 'root' object for later merges :)
10:52zotand in several places, with differing underlying records
10:52justin_smithzot: right, all of those produce equivalent records
10:52justin_smithunderlying records?
10:52zotdifferent record types
10:52justin_smithahh, OK, then you likely want the map->Foo form then
10:52zotexactly :)
11:03rodnaphi'm trying to do some java interop and when calling a constructor (PdfReader. "file.pdf") I'm getting InvocationTargetException - can anyone tell me if there is a general cause for this error? (like not being able to find a constrctor with matching types or something...)
11:05justin_smithrodnaph: I don't know what lib that is, but I would expect PdfReader to take a file or InputStream, and not a file name
11:05justin_smithrodnaph: just based on other classes / APIs in the java world
11:06rodnaphjustin_smith: yeah i don't expect you to know the library, i just thought this error was coming from clojure doing the interop, and not the library
11:07justin_smithrodnaph: I have never seen that exception from clojure, but it's an exception that constructors should throw if there is something wrong with an argument
11:07justin_smith(or methods... but since we are talking about a constructor here...)
11:08rodnaphjustin_smith: you are correct sir! my assumption was mistaken (just grepped the clojure codebase to be sure as well)
11:08rodnaphjustin_smith: thanks!
11:09justin_smithrodnaph: which pdfreader class is it anyway?
11:10rodnaphjustin_smith: com.itextpdf.text.pdf.PdfReader from iText - i was given it an invalid path to the file :E
11:10justin_smithaha!
11:10justin_smiththat would do it then
11:10rodnaphwhen you're looking at the stars, make sure you don't trip on the pavement ;)
11:13djamesl1x: I saw some of your messages from yesterday. Looks like you are open to various kind of timeout options and aren't necessarily using core.async.
11:14djamesWhich, of course, broadens the discussion quite a bit. :)
11:14l1x;)
11:14djamesYou found something you are happy with now?
11:14justin_smithl1x: yeah, I hope you saw that async client that has a timeout arg in the request function
11:15justin_smithhaha
11:15justin_smithsudden?
11:15djamesever-present is more like it!
11:15l1xjustin_smith: i haven't
11:16djamesl1x: what are your constraints?
11:16djamesYou want to make an HTTP call with a timeout perhaps?
11:16djamesTrying to figure out what pieces you have.
11:16justin_smithl1x: "documented here https://github.com/neotyk/http.async.client/blob/development/docs.org#timeout "
11:17djamesBecause I have this terrible tendency to point out that NIO.2 is actually pretty cool.
11:17djamesThough it is low-level and not necessarily useful if you are just doing HTTP.
11:17justin_smithl1x: what led me to that was realizing that timeout doesn't do as much to help you if the http request isn't cancellation friendly - which led me to "which http lib is friendly to having request cancelled" which led me to the fact that http.async.client has a :timeout arg built in
11:17l1xjustin_smith: i am working on a http server not a client
11:18justin_smithl1x: so you are a server, timing out the client?
11:18l1xa server timing out on writing to a message q
11:18djamesl1x: how is your http server different? why not use something off the shelf?
11:18justin_smithaha, I misunderstood that bit
11:19justin_smithl1x: yeah, the timeout function I shared before should work if you are blocked on writing to a queue
11:26sdegutisCan anyone give recommendations on how to quickly become proficient at Clojure? Thanks in advance, best regards.
11:27vassdegutis: i am just a novice myself, but there are 2 books I have found very useful: The Joy of Clojure , and Clojure Programming
11:27sdegutisvas: is the second one by cemerick?
11:28vassdegutis: yeah, cemerick, cgrand, and brian carper
11:28sdegutisthanks
11:29sdegutisI know there's two books with nearly the same name.
11:29justin_smith,(shuffle '[clojure programming])
11:29clojurebot[clojure programming]
11:29justin_smith,(shuffle '[clojure programming])
11:29clojurebot[clojure programming]
11:29justin_smith,(shuffle '[clojure programming])
11:29clojurebot[programming clojure]
11:29vasFrom a newbie's perspective I think Joy of Clojure is superb. I'm mostly using Clojure Programming for reference
11:30vaslol justin
11:30justin_smith,(repeatedly 8 #(shuffle '[clojure programming]))
11:30clojurebot([clojure programming] [programming clojure] [programming clojure] [clojure programming] [programming clojure] ...)
11:32sdegutis,(distinct (repeatedly 3 #(shuffle [:clojure :programming])))
11:32clojurebot([:programming :clojure] [:clojure :programming])
11:32sdegutis,(distinct (repeatedly 2 #(shuffle [:clojure :programming])))
11:32clojurebot([:clojure :programming] [:programming :clojure])
11:32sdegutis"random" lol
11:33michaelr`cfleming: kudos for let binding alignment, I might get used to such luxury :)
11:35mmitchellI have a leiningen project and have added cider-nrepl to my :user :plugins profile. Whenever I cider-connect in emacs, I get a warning "Please, install (or update) cider-nrepl 0.9.0-SNAPSHOT and restart CIDER" -- but that's the version of cider-nrepl I have in my :user :plugins.
11:35mmitchellIf I start the repl (lein repl) in a different directory and re-connect, I don't get the warning.
11:35TEttingersdegutis: yeah IIRC the RNG java uses by default is not great
11:35mmitchellany ideas on what's going on there?
11:35justin_smithmmitchell: not plugins
11:35justin_smithmmitchell: it's runtime, it needs to be in dependencies
11:35TEttingeror dev-dependencies
11:35justin_smithplugins is for tooling that isn't available in the runtime
11:35mmitchelloh! man, thanks for that. Makes sense
11:35justin_smithTEttinger: good point
11:36justin_smithmmitchell: I usually put it in profiles.clj
11:36justin_smithsince you want the same dep for all your local clojure dev
11:36justin_smithbut not in anything you deploy
11:37TimMc,(let [things ["cooking" "painting" "sex" "clojure"]] (str "the joy of " (rand-nth things)))
11:37clojurebot"the joy of clojure"
11:37justin_smithother good things to put in your profiles.clj :user :dependencies are criterium and pallet/alembic
11:37justin_smith(inc TimMc)
11:37lazybot⇒ 92
11:37TimMc,(repeatedly 5 #(rand-nth (range 10)))
11:37clojurebot(9 9 9 9 9)
11:38justin_smithwoah...
11:38justin_smithdid you rebind rand-nth?
11:38TimMcmaaaybe
11:38TimMcbut for a good cause
11:38justin_smith,(rand-nth (range 100000))
11:38clojurebot99999
11:38mmitchellthanks justin_smith / TEttinger - going to try now
11:38sdegutis,(random)
11:38clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: random in this context, compiling:(NO_SOURCE_PATH:0:0)>
11:38sdegutis,(rand)
11:38clojurebot0.7762006921209322
11:39TimMc,(let [things ["cooking" "painting" "sex" "clojure"]] (str "the joy of " (rand-nth things)))
11:39clojurebot"the joy of cats"
11:39justin_smithlol
11:39TimMc,(repeatedly 5 #(rand-nth (range 10)))
11:39sdegutis,(with-redefs [rand (constantly 4)] (repeatedly 5 rand))
11:39clojurebot("cats" "cats" "cats" "cats" "cats")
11:39clojurebot(4 4 4 4 4)
11:39TimMcCats are statistically likely.
11:41sdegutis,(alter-var-root #'clojure.core/rand (constantly (constantly 4)))
11:41clojurebot#<core$constantly$fn__4346 clojure.core$constantly$fn__4346@17e9b369>
11:41sdegutis,(rand)
11:41clojurebot4
11:41sdegutis,(repeatedly 10 rand)
11:41clojurebot(4 4 4 4 4 ...)
11:42sdegutiswelp, my work here is done
11:42justin_smith,(repeatedly (rand) rand)
11:42clojurebot(4 4 4 4)
11:42TimMc,(rand-int 10)
11:42clojurebot4
11:42TimMchmm
11:42TimMc,(shuffle (range 10))
11:42clojurebot[2 3 4 5 8 ...]
11:42TEttinger,(rand-nth "abcdefg")
11:42clojurebot\e
11:43TEttinger,(rand-nth "abcdefghijklmnop")
11:43clojurebot\e
11:43TimMcWhy not cats?
11:43mmitchelljustin_smith: sorry, i didn't describe my problem accurately. I'm using tools.nrepl to spawn a repl in dev. It's when I connect that _that_ repl server the cider warning is displayed in emacs.
11:44justin_smithmmitchell: if you add the cider-nrepl dep to profiles.clj, or to the appropriate project's dependencies, it should clear that up
11:44justin_smithmmitchell: unless cider has a bug where it reports the wrong string for the required cider-nrepl version (which wouldn't be a huge surprise)
11:45mmitchelljustin_smith: i tried it yeah, and same message is displayed
11:45justin_smithmmitchell: does lein deps :tree show the cider-nrepl dep?
11:46mmitchelljustin_smith: yeah it's there
11:50justin_smithmmitchell: what's the cider-version it goes with?
11:51mmitchelldeps :tree shows this - cider/cider-nrepl "0.9.0-20150216.224738-8"
11:51mmitchelloh you mean cider?
11:51justin_smithmmitchell: I mean in elisp / emacs the cider version
11:51mmitchelljustin_smith: .emacs.d/elpa/cider-20150215.730/
11:52justin_smithugh, melpa really messes up the version strings doesn't it...
11:53sdegutis,(rand)
11:53clojurebot0.7207220370066598
11:53sdegutisWait, how did it get fixed?
11:53justin_smithit resets automatically
11:54sdegutisaw
11:54TimMcEvry 15 minutes or so.
11:58mmitchelljustin_smith: installing from marmalade yields this: .emacs.d/elpa/cider-0.8.2/
11:59justin_smithOK - yeah, but that's a different version than you had before - but anyway, if that's properly installed, you would want the cider-nrepl with the matching version
12:00justin_smithbut beware that changing cider versions usually requires deleting all your elc files and doing a full emacs restart
12:00mmitchelljustin_smith: how do i specify a set version for a package?
12:01justin_smithemacs doesn't really support that sadly, as it doesn't have declarative dep resolution
12:01justin_smithmmitchell: or if you mean setting a version of cider-nrepl on the clojure side, that's a matter of changing your version string, of course
12:02mmitchelloh i see. Yeah, I'll try that
12:07justin_smith~map
12:07clojurebotmap is hard
12:07justin_smith~lazy
12:07clojurebotlazy is what will save us all
12:07justin_smith~for
12:07clojurebotfor is Lua
12:08justin_smithclojurebot: clojurebot is weird
12:08clojurebotIn Ordnung
12:08cddr`Speaking of cider-nrepl, I'm wondering about the edit/test cycle of people who work on that. Do you have any tricks to avoid lein install after each change?
12:09justin_smithcddr`: hypothetically you can test it out within it's own repo, right?
12:09justin_smith*its
12:10cddr`but when a user uses it, they use it as a plugin
12:10justin_smithcddr`: no, it won't work as a plugin
12:10justin_smithit needs to be present at runtime
12:10justin_smithwhich means a dependency
12:11justin_smitherr... wait
12:11justin_smithI'm wrong
12:11justin_smithhow the hell does it work then?
12:12justin_smithahh, the plugin inserts itself in deps... https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider_nrepl/plugin.clj#L20
12:12justin_smithmmitchell: hey, I was wrong, you can actually use cider-nrepl as a plugin, it then magically inserts itself into your deps vector
12:13mmitchellah ok, i guess my unchanged result makes sense then
12:16mmitchelljustin_smith: so cider-nrepl is at 0.9.0-SNAPSHOT - does that mean there is no compatible cider package for that (cider is at 0.8.2)
12:16justin_smithmmitchell: if cider is 0.8.2, that should be your cider-nrepl version too
12:16{blake}cfleming: No problem, I get babies.
12:17justin_smith{blake}: I think there's a pill for that
12:17anildigitallol java.io.FileNotFoundException: Could not locate recursion__init.class or recursion.clj on classpath:
12:17anildigitaljava.io.FileNotFoundException: Could not locate count__init.class or count.clj on classpath:
12:17justin_smith /rimshot
12:17anildigital Exception in thread "main" java.io.FileNotFoundException: Could not locate time__init.class or time.clj on classpath:
12:17anildigital3 different errors while deploying to heroku
12:17{blake}justin_smith: Go on, recommend the veal.
12:17anildigitalerror changes when tried to deploy each itme
12:18justin_smithanildigital: sounds like something that would happen with corrupted require clauses
12:18anildigitalAnd now lists java.io.FileNotFoundException: Could not locate lists__init.class or lists.clj on classpath:
12:18anildigitaljustin_smith: okay
12:19mmitchelljustin_smith: ugh ok, so the problem is that cider is installed from melpa at version cider-20150216.2223 - if I can't control what version is getting installed, and cider-nrepl needs to be the same version, it would seem that there's no way to sync the two :(
12:19justin_smithanildigital: are these similar to anything you are trying to require in your namespaces?
12:19anildigitaljustin_smith: https://gist.github.com/anildigital/3b911e40b2fa99c66b27
12:19justin_smithanildigital: weird...
12:20llasrammmitchell: melpa-stable
12:20anildigitaljustin_smith: hmm
12:21Glenjaminwould nrepl clients be capable of installing their own middleware after connecting?
12:21Glenjaminit seems like it should work in theory, it's just evalling some code
12:21justin_smithGlenjamin: using pomegranate, it would be possible
12:21Glenjamineven without, just send the forms over
12:21justin_smithGlenjamin: and that would be a lot cleaner than requiring that the user have two projects installed in compatible versions
12:22Glenjamini think so, yeah
12:22anildigitaljustin_smith: ah.. noticed why is it happening.. there are clojure files in
12:22anildigitalhttps://github.com/anildigital/clojurebyexample/tree/master/src/clojurebyexample/code
12:22anildigitaland those are trying to get compiled
12:22justin_smithGlenjamin: but would cider accept a change that so radically alters their api? /s
12:22cddr`I just cloned the cider repo and put it on my elisp path.
12:22anildigitalI don't want those to get compiled.
12:23justin_smithanildigital: OK, yeah, because they have invalid namespaces relative to your classpath
12:23justin_smithso yeah, that would cause that error
12:23justin_smithso I think you need some exclusion, or to make sure they are not in the src-paths
12:23anildigitaljustin_smith: hmm yes
12:23justin_smithanildigital: maybe move them from source to resources?
12:23justin_smithsince they aren't normal namespaces
12:23anildigitaljustin_smith: do you know any such rule
12:24justin_smithanildigital: the rule is that a namespace must reflect the file path relative to the classpath
12:24anildigitaljustin_smith: can I add something in project.clj to tell that don't compile code folder
12:24justin_smithanildigital: but if you put it under resources rather than src you'll have no such problem
12:25justin_smithanildigital: you could alter source-paths to not include src, or put those files under a dir other than src
12:26justin_smithanildigital: if it was my project, I would move src/clojurebyexample/cope/ to resources/code/
12:26anildigitaljustin_smith: hmm
12:26justin_smithsince it's not code used by your project (the namespaces aren't even valid for such), it's a resource that has demonstration code
12:26justin_smithand you can still use eg. load to load the files since resources/ is on the classpath
12:27justin_smithbut putting it under resources/code makes sure the packaging process does not try to compile those files
12:27justin_smithwhich would fail, because they have invalid namespaces relative to their classpath
12:28anildigitaljustin_smith: okay
12:28justin_smithalso, I think it just makes sense to segregate the code you use as examples of clojure code from the code that runs your app
12:29anildigitalokay done.. fingers crossed for heroku
12:30anildigitaljustin_smith: to see different error each time was something for me
12:30anildigitaland simple classes like lists, count etc
12:30justin_smithright
12:30anildigitaluntil I realized the issue
12:30anildigitalsweet http://clojurebyexample.com/
12:31justin_smithnice
12:31justin_smithso moving the code/ folder did it
12:32anildigitaljustin_smith: yep
12:32anildigitalI wish I could remove the docs for dependencies in the page
12:33justin_smithahh - will marginalia still work with the moved code dir?
12:33justin_smithmaybe you should have a "sub project" rooted under resources where you can run marginalia
12:33anildigitaljustin_smith: I generate that myself
12:33justin_smithOK
12:33anildigitaljustin_smith: these are actually simple code snippets
12:34justin_smithright
12:34justin_smithbut from what I remember "lein marg" doesn't have many options
12:40anildigitaljustin_smith: yeah
12:40anildigitalI am hoping lein marg becomes good
12:51mmitchellllasram: thanks for the melpa-stable tip :)
12:52mmitchellI now have cider 0.8.2 installed and cider-nrepk too. And now after doing a cider-connect I get: "Please, install (or update) cider-nrepl 0.8.2 and restart CIDER" lol
12:52mmitchellmust be related to it being an embedded nrepl via tools.nrepl
12:55gfredericksmmitchell: if you're starting up the nrepl server yourself you have to specify the middleware explicitly
12:56mmitchellgfredericks: is that cider-nrepl middleware?
12:56gfredericksyeah
13:01anildigitalWhat's your-handler here https://github.com/ring-clojure/ring/wiki/Static-Resources
13:01anildigitalI just dont' have that..
13:01anildigitaland want to serve static resources only
13:01nooniana ring handler is just a function from request to response maps
13:01anildigitalnoonian: but what if I don't want to write that..
13:02anildigitalI just want to serve static resources
13:03mmitchellis cider and cider-nrepl compatible with lein ring and its repl options?
13:03nooniani think compojure has some helpers for returning handlers that serve static resources
13:03anildigitalnoonian: I just want to skip handler.. may be return true or something so that it will always fall back to resources
13:04noonianyeah should be able to do something like: (cc/defroutes my-app (compojure.route/resources "/"))
13:04anildigitalnoonian: I am not using compojust
13:04anildigitalcompojure
13:05nooniansince you are serving from a webserver you need to create a handler that does the job of serving the static assets, the other option would be to use something like nginx to serve the resources
13:05anildigitalI am restricted to ring
13:05anildigitalnoonian: hmm can't use nginx
13:05anildigitalwhat's simple empty handler.. which doesn't do anything
13:05anildigitalsomething harmful
13:06noonian(ring.util.response/not-found "we just serve resources here")
13:07adgtllike no-op handler
13:07noonian(constantly (ring.util.response/not-found "not-found message")) you can probably use that as your handler
13:07noonianshould return static resources and not found if a resource wasn't requested
13:08noonianwhen wrapped with the wrap-resource middleware
13:08adgtlnoonian: actually when / is hit. I want to return index.html
13:08adgtlindex.html is static resource..
13:09mmitchellOK the only way i can get cider / nrepl happy is through lein repl -- lein ring server (with repl options) doesn't work. both cider and cider-nrepl are at 0.8.2
13:09adgtlI could add 302 and Location "/index.html"
13:09adgtlbut instead want to return 200 and index.html
13:12nooniani'd definitely recommend using something like compojure or clout at least then so you dont have to do routing yourself
13:14noonianadgtl: then you should get everything you want with something like this: https://www.refheap.com/97372
13:14noonianmissing a couple refers in the require statement
13:14adgtlnoonian: yep.. but can't use compojure
13:14nooniancan you use any library?
13:17noonianotherwise you will need to write a handler that inspects the request map and does its own dispatching based on the request url; i don't have time to help you with that though especially when there are tons of libs that do it (might checkout compojure's src to see how it does it)
13:19adgtl :body (java.io.FileInputStream. "resources/output/toc.html")})
13:19adgtl:)
13:23justin_smithadgtl: that will fail if you deploy a jar
13:23adgtlhmm
13:23justin_smithadgtl: consider instead (clojure.java.io/resource "output/toc.html")
13:23justin_smithsame contents, works from a jar
13:23adgtljustin_smith: how about (file-response "resources/output/toc.html")
13:23justin_smithno
13:23justin_smithbecause it isn't a file
13:23justin_smith(in a jar that is)
13:24justin_smiththere might be a resource-response I guess
13:24justin_smithyeah, resource-response exists
13:24justin_smithhttps://github.com/ring-clojure/ring/blob/1.3.1/ring-core/src/ring/util/response.clj#L204
13:25adgtljustin_smith: thanks :)
13:26mikerodIs it reliable behavior that this works?
13:26mikerod,(keys (filter identity {:a 1 :b 2}))
13:26clojurebot(:b :a)
13:26mikerodThe point being that `keys` accepts a seq-view of a map rather than needing to be an actual map
13:26mikerodI understand that it works due to the impl of `keys` calling seq on the input coll anyways
13:27mikerodHowever, that seems to just be an impl detail- not something I should rely on in the contract
13:27mikerodso perhaps I should be doing:
13:27mikerod,(keys (into {} (filter identity {:a 1 :b 2})))
13:27clojurebot(:b :a)
13:28justin_smithmikerod: wait, what does filter identity even do for you here? or is that a placeholder for a real filter you would actually do?
13:28mikerodjustin_smith: placeholder
13:28mikerodoh sorry
13:28mikerod(keys (seq {:a 1 :b 2}))
13:28mikerodI should have kept it at a minimal, that was carry over
13:30justin_smithOK
13:32noonianseems like an implementation detail, can't even see that its calling seq since it delegates to RT but it implies it saying that they will be in the same order as (seq map)
13:33mikerodnoonian: yeah...
13:33mikerodI guess the doc string says the word "map"
13:33mikerodso its probably best to only pass it a map..
13:34mikerodthere are plenty of places where a seq of MapEntry fails when map is expected
13:34justin_smithit's been mention by Hickey that seq, keys, and vals will use the same underlying ordering from a map
13:34mikerodjustin_smith: yes, I've read those posts
13:34justin_smithOK
13:34mikerodI mean, I interpreted that that's just concerning the order. I didn't take away that that implied that keys and vals will accept seq's of maps instead of maps
13:35mikerodI was just worried that the behavior (keys (seq {:a 1})) is not reliable and that I should do (keys (into {} (seq {:a 1})))
13:35mikerodHowever, I'm guessing it is just a gray area. Wanted to know if anyone knew specifically that this was a good or bad idea.
13:36noonianyeah, just pass it a map to preserve warm and fuzzy feelings about your code
13:36mikerodI appreciate the feedback on the topic though.
13:36justin_smithI can't think of many ways "keys" could be implemented that wouldn't call seq on the map as its first step
13:36justin_smiths/many/any
13:37mikerodnoonian: I try to shoot for writing something that will not be busted in a newer version of clj. So I worry when it comes down to just the RT impl of a function
13:37mikerodjustin_smith: yeah, that is true
13:37mikerodit is "natural"
13:57gfredericks,(def foo '''foo)
13:57clojurebot#'sandbox/foo
13:57gfredericks,(nth (iterate eval foo) 42)
13:57clojurebot(quote (quote foo))
13:58tbaldrid_mikerod: I've heard it mentioned that (zipmap (keys mp) (vals mp)) is common enough that changing the seq order of keys vs vals would break a ton of code
13:58tbaldrid_I can't think of a reason that will change soon. It doesn't make sense from a language development standpoint, or from a technical standpoint.
13:59tbaldrid_So I'd say you're just fine doing (keys mp) and assuming that as long as mp doesn't change, the order of keys will stay the same
13:59justin_smithtbaldrid_: his issue was more specifically if keys would always work in the case of (keys (seq {:a 0})) which is a bit more esoteric a thing
13:59gfrederickshmm
13:59tbaldrid_that works at all?
13:59trisshi all. If I do a clojure.data/diff on something is there an easy way to get the paths to the locations in that something that have changed?
13:59tbaldrid_,(keys (seq {1 2 3 4}))
13:59clojurebot(1 3)
13:59gfrederickswhat about a map with some internal mutability for performance (e.g., a lazy map)
13:59tbaldrid_eh...interesting
13:59justin_smithtbaldrid_: of course, because how would keys work without calling seq, or the equivalent, internally?
14:00gfrederickscould conceivably change its ordering incidentally
14:00gfredericksnow I'm curious if that lazy-map impl does this
14:00tbaldrid_gfredericks: sure, I'm only talking about the standard clojure impls. Other impls will have different characteristics
14:01gfredericksI just hadn't thought of this possibility before
14:01tbaldrid_justin_smith: yeah, I know it calls seq internall, I just didn't know it accepted a seq as well. That's interesting
14:01justin_smithtbaldrid_: well (seq (seq x)) will always work :)
14:01justin_smithif you know it calls seq, then passing a seq should work
14:02justin_smithbut it is a bit uglier a thing to assume, of course
14:02hiredmantbaldrid_: the first time I heard rich say the keys order will always match the vals was sometime around '08 or '09, and he has repeatedly said that whenever someone (often stuart) jumps on someone for assuming that (zipmap (keys m) (vals m)) is safe
14:02tbaldrid_(inc hiredman)
14:02lazybot⇒ 70
14:02tbaldrid_agreed
14:03hiredmanso, like, I don't work with the man, but it seems pretty clear what his intentions are there at this point
14:04tbaldrid_mikerod: hiredman: here's what I'd consider the authoritative word, see 2nd to last comment by Rich http://dev.clojure.org/jira/browse/CLJ-1302
14:05tbaldrid_and as mentioned by hiredman the thread contains a bit of hand slapping by Stuart, followed by a bit of hand slapping by Rich ;-)
14:06tbaldrid_and I assume this is now in the docs?
14:06tbaldrid_,(doc keys)
14:06clojurebot"([map]); Returns a sequence of the map's keys, in the same order as (seq map)."
14:14mikerodtbaldrid_: yes, the surprise to me was that (keys (seq {:a 1})) works
14:14mikerodspecifically because I passed it a seq, not a map
14:15mikerodI understand the impl and why it works. I just wanted to know if it was intentionally accepting seq's or just an internal detail where we get lucky
14:15mikerodI also have followed that seq == keys == vals
14:15mikerodand I think that is an important property that I hope doesn't change since it is nice to use in zipmap etc
14:15mikerodMy concerns were just that most functions that are meant for maps do not interchangeably accept maps-as-seqs
14:16mikerodbut due to keys and vals impl, they do accept this
14:16mikerodit was mostly a curiosity thing. I thought I should have gotten some sort of cast exception when I did a (keys (filter ... {:a 1})) earlier and I was surprised to see that it Just Works.
14:20gfredericksthat stuff is all over clojure
14:20gfredericks,(deliver +)
14:20clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core/deliver>
14:20gfredericks,(deliver + 42)
14:20clojurebot42
14:21gfredericksI wish I knew how rich felt about that sort of thing
14:21gfredericksdifficilt to tell what's intentional and what's accidental
14:21justin_smith,(deliver (get get get get) get)
14:21clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core/get>
14:22justin_smithoops!
14:22hiredmanrich likes to call behavior undefined, but it is hard to tell where that line is
14:22hiredmangfredericks: but that certainly seems like "undefined" behaviour
14:24gfredericksseems like a weird thing to value
14:25gfrederickslike I'm not sure if the goal is simplest-possible-impl (where checks are clutterful) or fastest-possible (where checks are expensive) or preserving current behavior or ...
14:27amalloygfredericks: i actually mentioned the fact that (deliver f x) is just (f x) at clojure/west, talking to reiddraper and rich at dinner, and he said if you rely on that working you deserve what you get, or something to that effect
14:27hiredman"undefined"
14:27gfredericksthat doesn't make it not worth changing though
14:27gfredericksit's not just a question of relying on it working it's a question of how mistakes manifest
14:28gfredericksand when stuff is implemented in this style, failure behavior is a lot messier
14:29justin_smithyeah, I am sure I have code that "works by accident"
14:29amalloygfredericks: like what?
14:30gfredericksamalloy: like if I pass a function to deliver instead of the promise I meant to, the function gets called and something weirder happens rather than the straightforward "can't deliver a not-a-promise" exception
14:30gfrederickswhere "something weirder" could be virtually anything
14:30gfredericksclojure.lang.CannotDeliverANotAPromiseException
14:31justin_smithamalloy: gfredericks: or a practical example, someone not long ago had (:or x y) - which is kind of like or, but it always picks why
14:31justin_smitherr, always pick y, that is
14:31gfredericksclojure.lang.problems.concurrency.promises.impl.NotOneException
14:31justin_smithwhich is a simple typo, but it can pass unit tests
14:31amalloygfredericks: you just made me think of something. java.lang.IllegalStateException is cool, but clojure needs a clojure.lang.StateIllegalException because state is illegal
14:32justin_smithhaha
14:32andyfgfredericks: Dynalint ?
14:32gfredericksthrown when you do (atom (agent nil))
14:32hiredmanwhat are you, some kind of crypto ml loving type fetishist?
14:32gfredericksandyf: yeah that's a reasonable approach
14:33gfredericks,(nth (iterate agent nil) 10)
14:33andyfNot sure how big dynalint's performance overhead is
14:33clojurebot#<Agent@31443ae7: #<Agent@76772cf5: #<Agent@a28c596: #<Agent@7ac4000f: #<Agent@59e017c0: #<Agent@7376c59: #<Agent@47aa4ac2: #<Agent@7d122b4f: #<Agent@33d98faf: #<Agent@106844c1: nil>>>>>>>>>>
14:33amalloygfredericks: or (filter #(zero? (swap! some-atom + %)) xs)
14:34mikerodI definitely agree I'd like to hear thoughts from Rich on these weird behaviors due to impl issues
14:34mikerodI often wonder why a little sanity checking isn't done by functions - if it doesn't cost a lot in terms of performance
14:35amalloymikerod: i imagine it's because it does cost a lot
14:35gfrederickswould be cool if it were standard to add metadata to vars about things that could be dynalinted
14:35amalloythe core language functions get called all the time, including in implementing other core functions
14:35gfredericksand then just turn those on in tests or whatevs
14:35mikerodA related question, does anyone know why it'd be a Good Thing to have keywords look themselves up in anything - returning nil if it doesn't make sense?
14:35mikerodamalloy: I suppose that's fair
14:35gfredericks,(:mikerod-like-this? 42)
14:35clojurebotnil
14:36mikerodgfredericks: yes
14:36mikerodthat is a great way to hide a bug
14:36justin_smithmikerod: it's just invoking get
14:36andyfgfredericks: Create a technique that becomes de facto standard?
14:36justin_smithand get is just super easy going about args
14:36mikerodjustin_smith: oh good point I forgot it is get to blame
14:36justin_smith,((get get get get) {get get} get)
14:36clojurebot#<core$get clojure.core$get@4f478df8>
14:37mikerod:P
14:37amalloyjustin_smith: it actually doesn't call get unless it has to
14:37justin_smithamalloy: oh?
14:37amalloyit prefers to call (.valAt obj this) when possible
14:37amalloyif obj is an instance of ILookup
14:38justin_smithok - but we can still blame get for the fallback
14:38gfredericksandyf: just a :dynalint key in the metadata could be interesting
14:38mikerodyeah
14:38amalloyi guess that's true
14:38gfredericks:dynalint/pre, :dynalint/post
14:39andyfAlter-var-root is calling ...
14:39mikerodwhat about this
14:39mikerod,(let [x nil] (x))
14:39clojurebot#<NullPointerException java.lang.NullPointerException>
14:39mikerodWhat is not being checked there
14:39amalloyi mean, i hear you guys talking about all these checks for various different kinds of errors that could happen at runtime and clojure makes weird choices about what happens in situations that shouldn't happen, and it's like...wouldn't it be great if we had static types?
14:39amalloymikerod: huh? what else could happen besides a NPE? a wrapper around NPE that says "you tried to call a function, dummy"?
14:39andyf~guards
14:39clojurebotSEIZE HIM!
14:39amalloyer, tried to call nil as a function
14:40gfredericksamalloy: ##(nil)
14:40lazybotjava.lang.IllegalArgumentException: Can't call nil
14:40amalloyandyf: i *am* the guards
14:40hiredmanclojurebot: static types is <reply>what are you, some kind of crypto ml loving type fetishist?
14:40clojurebotGabh mo leithscéal?
14:40hiredmanclojurebot: static types is <reply>what are you, some kind of crypto ml loving type fetishist
14:40clojurebotc'est bon!
14:40andyfI know :)
14:40mikerodamalloy: yeah, I know. I'm not really necessarily "complaining", I just am always curious when stumbling across these weird behaviors that tend to be trouble.
14:40mikerodgfredericks: yes
14:40amalloyi know you know, et cetera
14:40mikerodgfredericks: I like how it catches a direct call to nil, but not an indirect call. Nil checks are highly performant I believe?
14:40amalloygfredericks: (nil) is just the weirdest special case in the world. i don't know why you'd bother
14:40amalloymikerod: not as performant as omitting them
14:41andyf~amalloy
14:41clojurebotamalloy only uses locally sourced, free range electrons
14:41mikerodamalloy: haha fair enough..
14:41amalloyand if you checked for nil on *every* function call the language would slow down by like, jeez i dunno, 100%
14:42mikerodJava code tends to nil check about 50% of the codebase
14:42amalloymore realistically it's probably like 20%, but that is still a lot
14:42mikerodI mean spend 50% nil checking
14:42mikerod*of lines of code* - so lots of them is the point
14:43mikerodI do like how clj code rarely has to be worried about nil, so I shouldn't complain
14:43gfredericksamalloy: I bet it bothers with (nil) because it might have to be a special case in the compiler regardless
14:43mikerodjust don't try to call it as a function :)
14:43TMAand -- by my experience -- testing for nils is faster than catching the NPE
14:44amalloyTMA: the idea is that if you're calling nil as a function you are pretty much screwed anyway, whether you check it or not, so performance in that case isn't terribly important
14:44TMA,((:foo 42))
14:44amalloymight as well optimize for the non-mistake
14:44clojurebot#<NullPointerException java.lang.NullPointerException>
14:44hiredmangfredericks: I bet someone was writing a macro that emitted (nil) and they complained very loudly when they couldn't figure out why their macro was being dumb
14:45amalloygfredericks: nope
14:45Bronsa,(.invoke nil)
14:45clojurebot#<NullPointerException java.lang.NullPointerException>
14:46amalloyhttps://github.com/clojure/clojure/commit/a4f923670d89fd7f4d72f39ec85ec8f46ea43bdc#diff-f17f860d14163523f1e1308ece478ddbL4063
14:46amalloyis the only time in the entire codebase that "can't call nil" was touched, and it really does not look to me like a special case that needed to be handled anyway
14:47justin_smitheveryone's all like "damn clojure doesn't static check any of this" and amalloy's like "hey that one thing it does check - it really shouldn't need to"
14:47amalloyjustin_smith: man i wish it would check a ton of things
14:47amalloybut this is the dumbest thing to check
14:49mikerodI've had it thrown on me a few times before, and I was like "wow, that was surprisingly descriptive of an error message"
14:49mikerodWhere is my NPE at
14:54TMA,(defmacro foo-macro [] `(~(:foo 42) 1 2)))
14:54clojurebot#'sandbox/foo-macro
14:54TMA,(macroexpand '(foo-macro))
14:54clojurebot(foo-macro)
14:54TMA,(macroexpand '(sandbox/foo-macro))
14:54clojurebot(sandbox/foo-macro)
14:55TMA(fn [] (foo-macro))
14:55TMA,(fn [] (foo-macro))
14:55clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: foo-macro in this context, compiling:(NO_SOURCE_PATH:0:0)>
14:59TEttinger,(defmacro foo-macro [] `(~(:foo 42) 1 2)))
14:59clojurebot#'sandbox/foo-macro
14:59TEttinger,(fn [] (foo-macro))
14:59clojurebot#<CompilerException java.lang.IllegalArgumentException: Can't call nil, compiling:(NO_SOURCE_PATH:0:0)>
15:00TEttinger,(macroexpand-1 foo-macro)
15:00clojurebot#<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'sandbox/foo-macro, compiling:(NO_SOURCE_PATH:0:0)>
15:00TEttinger,(macroexpand-1 'foo-macro)
15:00clojurebotfoo-macro
15:00TEttingergah
15:00TEttinger,(macroexpand-1 #'foo-macro)
15:00clojurebot#'sandbox/foo-macro
15:01BronsaTEttinger what'd you expect that to do?
15:01TEttinger,(macroexpand-1 (foo-macro))
15:01clojurebot#<CompilerException java.lang.IllegalArgumentException: Can't call nil, compiling:(NO_SOURCE_PATH:0:0)>
15:01TEttingerI have no idea how macros work Bronsa
15:01TMA,(macroexpand-1 '(foo-macro))
15:01clojurebot(nil 1 2)
15:01TEttingerah!
15:02kaplanI still don't understand macros
15:04TMAbased on the conversation with clojurebot, the check could be for the benefit of macros -- a buggy macro might easily place nil into function position
15:05TimMckaplan: Macros are just functions that the compiler calls.
15:06TimMcWhen the compiler sees the name of a macro in call position, it calls the macro and hands it the pile of lists and symbols and whatnot that are in the arg positions.
15:06TimMcThe function returns replacement code and things go on from there.
15:17gfredericksandyf: you made me try dynalint and I discovered that lein-dynalint has been broken for probably a year at least
15:17gfredericksthese are exciting times we live in
15:21gfredericksrunning dynalint on my work project yielded 7 warnings, 2 of them caused by leiningen code and the other five by pomegranate (which is called by leiningen)
15:21gfredericksactually that makes me suspect it's only linting leiningen and not my project
15:22justin_smithgfredericks: is it meant to be called as a plugin or from within your project as a dep?
15:23gfrederickslein-dynalint claims you should put lein-dynalint and dynalint as plugins in your project and then call `lein dynalint test`
15:23gfrederickslooking at the source code it does indeed look like it just lints the leiningen jvm and then runs your tests
15:24gfredericksI swear it must be nobody has ever used this before
15:24justin_smithhaha
15:24andyfgfredericks: I haven't used dynalint's for about that long, and it was only an experiment on my part then. Haven't followed it closely.
15:26gfredericksno wonder it claimed you should add dynalint as a plugin dep instead of a normal dep
15:41vasso I have a (GET "/session" [ req ] (str "request map is " req))
15:42vasin a defroutes.. it was working earlier, but suddenly it no longer spits out the request map
15:42vasany ideas?
15:42justin_smithvas: what does it give you instead?
15:42vasjust the leading text, in that example "request map is "
15:43vasas if req was a blank
15:43justin_smithperhaps some middleware is messing with the request? but clearly enough was there to lead to your handler function
15:43justin_smithtry replacing req above with (pr-str req)
15:43justin_smiththat may print nil, or ""
15:44bdruthGood afternoon
15:45bdruthI'm having a strange issue with destructuring a map
15:45bdruthit's a data structure returned from another component
15:45bdruthand the first key looks like this: :us-east-1/i-824af2e4
15:46justin_smithand how do you destructure that?
15:46JimKetanybody here know anything about octopushub?
15:46amalloy~anyone
15:46clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
15:46bdruthwell, it seems like it's not wanting to use this in get-in or (<map> key) forms
15:46bdruthhold on though, I just noticed something with the level of the key
15:46bdruthsec
15:46justin_smithbdruth: can you use refheap to show us the results of (keys m) (where m is the data you get)
15:47bdruthoh, damn - yeah - I'm good
15:47vasjustin_smith: thanks for the suggestion for pr-str. it now returns the lead up string followed by ... nil
15:47bdruthit was doubly nested, sorry for the noise
15:47bdruthI latched on to the '/' in the key and thought there would be a problem with that
15:47justin_smithvas: maybe a broken middleware is swallowing the actual request? perhaps an if with only one branch in a custom middleware?
15:48JimKethrmmm, well in that case, octopushub seems to be logging one of my channels, and looks as though it's logging yours as well
15:48JimKetcuriosity is getting the better of me and I was wondering if anybody had details regarding the site
15:49justin_smithJimKet: I have noticed that before - I don't know what their deal is
15:50justin_smiththey are scraping irc channels and putting it in hidden pages
15:50TimMcamalloy: This is that weird-ass site you pointed out the other day, it's not a clojure lib. :-P
15:50justin_smithJimKet: my guess is SEO for their frequent updates
15:50JimKetyeah, our nicks are showing up all over google searches
15:50justin_smithoh, yeah, amalloy pointed that site out
15:51justin_smithoctopushub.org, not to be confused with octopushub.com (a tennis shop)
15:53justin_smithJimKet: their whois shows a valid email address you could contact
15:53TimMcJimKet: Is it actively adding to any entries?
15:54TimMcIf you can predict who it will log, you could poison its log with an entry that would kill its SEO.
15:54justin_smithit was first created the 23rd of january
15:54vasjustin_smith: hey i got it working again checking my git diffs (thank gitness)... although I don't know why it works
15:54justin_smithTimMc: oh, excellent point
15:54justin_smithvas: can you describe the difference?
15:54TimMcI haven't looked into it, but there should be documentation on what Google really hates to find on sites.
15:55vas(GET "/session" [ ph-auth-token :as req ] (str "the request map looks like " req))
15:55justin_smithTimMc: links to known crappy sites
15:55TimMcI think it's robust enough not to render HTML, though.
15:55vasi was under the impression that using :as just made the whole argument vector into whatever you name it... i guess pulling one value out of it does some sort of magic?
15:56justin_smithvas: compojure destructuring sometimes confuses me
15:56TimMchmm
15:56TimMc,(let [[:as n] 6] n)
15:56clojurebot6
15:56vasoh right. it's compojure stuff.
15:57justin_smithvas: (GET "/session" [req] ...) looks for a key called req in the request
15:57vaswell, i'll have to remember that trick in case someone else needs it in the future
15:57vasAhaaaa. makes sense
15:57justin_smithvas: well, not to me, but OK :)
15:57vashaha SE
15:57vas:D*
15:57vasprogrammer dvorak lol
15:57Bronsa,(let [[:as [:as [:as [:as n]]]] 6] n)
15:57clojurebot6
15:57justin_smithif you instead specify {{token :ph-auth-token} :as request} that should bind token to your token, and also allow access to the whole thing as "request"
15:58justin_smithBronsa: what got me here was that [foo] would mean {:keys [foo]}
15:59justin_smith(in compojure-land)
15:59TimMcBronsa: :-D
15:59justin_smithwell - actually [foo] means {{foo :foo} :params} I guess?
16:00justin_smithvas: https://github.com/weavejester/compojure/wiki/Destructuring-Syntax
16:01justin_smithBronsa: also, that is wacky
16:01justin_smith(inc Bronsa)
16:01lazybot⇒ 93
16:02TimMc,(let [{:keys [a] :as {:keys [b] :as {:keys [c]}}} {:a 1 :b 2 :c 3}] [a b c])
16:02clojurebot#<CompilerException java.lang.IllegalArgumentException: Bad binding form, expected symbol, got: {:keys [b], :as {:keys [c]}}, compiling:(NO_SOURCE_PATH:0:0)>
16:29arrdemhyPiRion: ping
17:25atratustheres no way to run clojure on squawk right? gotta have reflection?
17:26atratusI just left a debug session with a FIRST robotics team....felt so bad for those kids geez
17:27TimMcOh hey, FIRST.
17:28TimMcI did that in... 2000-ish?
17:28atratuswell the code hasnt changed lol
17:30TimMcI somehow ended up with our second-place medal. I should find out if there's still a Charlottesville/Albemarle Robotics Team to return it to.
17:32TimMcOh yeah, there they are! http://www.carobotics.org/
17:32TimMcteam 619
17:38TimMcor maybe each team member got a medal, and there was a lexan award thingum for the whole team?
17:40turbofailha. i was in team 192
17:41turbofaili wasn't a programmer back then though, i used a hacksaw and various machine tools
17:41noonianhacksaw programming
17:41TimMcI didn't do any of the programming, just design and strategy.
17:41TimMcIt worked out pretty well.
17:42atratuswasn't on team, but wish I was. didnt get programming bug until college. volunteering now though
17:43atratushttp://first.wpi.edu/Images/CMS/First/Getting_Started_with_Java_for_FRC.pdf
17:44atratusbased on java 1.3 so probably screwed
17:47TimMcOurs was a forklift design that could cantilever its battery and control board out the back as a counterweight.
17:50TimMc"2001 - Diabolical Dynamics"
18:05hyPiRionarrdem: pong
18:10hiredmantbaldrid_: pixie doesn't have chunked seqs, does it?
18:11tbaldrid_hiredman: no, mostly because I think I can optimize seqs away via the JIT. If I fail in that area, I may add chunked seqs in
18:11tbaldrid_I really don't like chunked seqs, so I hope to keep them out
18:12hiredmangood on you
18:15TimMc&(map (comp count #(`[{~@%~@%}](+))) (map range (range 20)))
18:15lazybot⇒ (0 1 1 3 2 5 3 7 4 9 5 11 6 13 7 15 8 17 9 19)
18:20TimMc&(apply map vector (partition 2 (map (comp count #(`[{~@%~@%}](+))) (map range (range 20)))))
18:20lazybot⇒ ([0 1 2 3 4 5 6 7 8 9] [1 3 5 7 9 11 13 15 17 19])
18:21amalloyTimMc: that first one was a real fibonacci disappointment
18:22amalloy0 1 1 3 2 5 too cruel
18:22__number5__what '#(`[{~@%~@%}](+))' supposed to do?
18:23amalloy__number5__: supposed to look confusing
18:23__number5__@_@
18:23__number5__&(doc apply)
18:24lazybot⇒ "([f args] [f x args] [f x y args] [f x y z args] [f a b c d & args]); Applies fn f to the argument list formed by prepending intervening arguments to args."
18:24TimMc__number5__: In normal Clojure, that would be (fn [& args] (apply hash-map (concat args args))) which is already pretty useless.
18:24amalloyyeah i was trying to figure out why you were making that map
18:24amalloyit looks like a way to get to second
18:25justin_smith,'#(`[{~@%~@%}](+))
18:25clojurebot(fn* [p1__25#] ((clojure.core/apply clojure.core/vector (clojure.core/seq (clojure.core/concat (clojure.core/list (clojure.core/apply clojure.core/hash-map (clojure.core/seq (clojure.core/concat p1__25# p1__25#))))))) (+)))
18:25TimMc__number5__: Basically I'm just playing around with obfuscated code. http://hypirion.com/swearjure
18:26__number5__TimMc: cool. nice name btw
18:27AeroNotixwhat are people using for a clojurescript repl?
18:27justin_smith__number5__: also, there's a #clojure-beginners channel, which can be useful when everyone here is distracted with compiler stuff or weird parts of the language that are hardly ever used
18:28srrubyI've got a small web service I'm writing in Clojure/compojure. It has to run on port 80. Can anyone recommend how to configure nginx ?
18:28justin_smithsrruby: should be the same as any other reverse-proxy scenario - you have nginx run on port 80, and forward the port that the clojure process serves on
18:29AeroNotixDo you need nginx?
18:29justin_smithAeroNotix: better than running the jvm as root
18:29__number5__justin_smith: thanks, guess the beginner channel suits me better :P
18:30justin_smithAeroNotix: normal user processes can't serve on port 80
18:30AeroNotixjustin_smith: I know
18:30justin_smith__number5__: not saying you aren't welcome here though
18:30AeroNotixjustin_smith: depends what you're doing. I typically just run stuff behind an ELB on EC2.
18:30justin_smithAeroNotix: also, nginx has security stuff that most of the jvm web servers lack
18:30AeroNotixbut that's cause I'm not paying :)
18:30justin_smith:)
18:30srrubyjustin_smith: Thanks
18:33{blake}Crap...there's a #clojure-beginners channel? heh
18:35justin_smith{blake}: it's a fairly recent invention
18:35brainproxyjustin_smith: you could run it non-root in a docker container and map 80 to the non-priv'd port
18:35brainproxyi.e. as an alternative to putting nginx in front of it
18:35justin_smithbrainproxy: but you'd want nginx for security reasons anyway
18:36brainproxysure, it's generally a good idea to put a hardened http proxy in front of jvm, node, etc.
18:37brainproxynginx, varnish, haproxy, traffic server -- lots of options
18:37{blake}justin_smith: Oh. Wait, like last week recent? =P
18:38justin_smith{blake}: yeah, seancorfield set it up iirc
18:39{blake}justin_smith: OK. *phew*
18:47ambrosebssanity check: it's impossible to construct a value with `new` that is false?
18:48TimMc,(remove #(re-find #"[a-zA-Z0-9]" (name %)) (keys (ns-publics 'clojure.core)))
18:48clojurebot(+' = < .. <= ...)
18:49noonianI hope so. Rich Hickey made a comment in one of his talks about new Boolean being wrong but still having to check for it because some java classes do it.
18:49TimMcambrosebs: No. :-(
18:49TimMcWell... let's see.
18:50TimMc,(boolean (Boolean. false))
18:50clojurebotfalse
18:50amalloywell. (new Boolean "false") evaluates as truthy
18:50amalloydoesn' it? i thought it did
18:50Bronsaambrosebs: if you mean that (if (new ..) 1 2) will _never_ return 2, that's correct
18:50ambrosebsthe invariant I'm claiming is (if (new ...) 1 2) always returns 1
18:50noonian(or (Boolean. false) true)
18:50noonian,(or (Boolean. false) true)
18:50clojurebotfalse
18:50ambrosebs:)
18:50ambrosebsBronsa: yes that's it.
18:50AeroNotix,(Boolean false)
18:50clojurebot#<RuntimeException java.lang.RuntimeException: Expecting var, but Boolean is mapped to class java.lang.Boolean>
18:51amalloyambrosebs: yes, i believe that invariant holds
18:51TimMc,(if (new Boolean false) 1 2)
18:51clojurebot1
18:51noonian,(Boolean. false)
18:51clojurebotfalse
18:51noonian,(identical? (Boolean. false) false)
18:51clojurebotfalse
18:51ambrosebsamalloy: thanks
18:51noonian,(= (Boolean. false) false)
18:51clojurebottrue
18:51TimMcAh, so if does not use the same coercion.
18:52amalloyTimMc: right, (if x y z) doesn't call boolean
18:52TimMc,(identical? (boolean (Boolean. false)) false)
18:52clojurebottrue
18:52AeroNotix,(Boolean. false)
18:52clojurebotfalse
18:52amalloyit compares to nil and to Boolean/FALSE
18:52AeroNotixI feel like this comes up every week or so
18:52TimMcInteresting choice.
18:52AeroNotixshould be in the tpic
18:53AeroNotixtopic
18:53amalloywell actually i guess that's not the relevant point
18:53amalloythe point is that the return value of RT/booleanCast is autoboxed for you, when you call boolean, and that uses the canonical boxing method
18:56TimMc&(filter #(re-find #"'$" (name %)) (keys (ns-publics 'clojure.core)))
18:56lazybotjava.lang.SecurityException: You tripped the alarm! ns-publics is bad!
18:56TimMc,(filter #(re-find #"'$" (name %)) (keys (ns-publics 'clojure.core)))
18:56clojurebot(+' dec' inc' -' *')
18:57TimMcIs it unreasonable that I am annoyed at /' not existing?
19:05justin_smith,(/ 1 (/ 1 1000000000))
19:05clojurebot1000000000N
19:06justin_smithit already auto-promotes
19:06justin_smithin some contexts at least
19:15TimMcFunky.
19:16TimMcDid someone make a mistake and forget to make it not autopromote?
19:16justin_smithI think it's down to the fact that rational would auto-promote
19:16justin_smithhehe
19:16TimMcOh, I see.
19:16justin_smithit's already anti-optimized due to rationals, so yeah
19:17justin_smithoh, I didn't even need to try a "large" number ##(/ 1 (/ 1 2))
19:17amalloyjustin_smith: pessimized
19:17lazybot⇒ 2N
19:17justin_smithamalloy: of course
19:18justin_smith(inc amalloy)
19:18lazybot⇒ 227
19:24TimMc(I'm still trying to figure out if we can get floats in swearjure.)
19:48hlprmnkyis it a known/expected thing that running 'lein uberjar' in a project that's using tools.namespace to have a reloaded-ized REPL experience, breaks said REPL experience until you run 'lein clean'?
19:49amalloy~aot
19:49clojurebothttp://i.qkme.me/3vb225.jpg
19:49amalloywell, not what i was expecting, but pretty on-topic i guess
19:49amalloy~aot
19:49clojurebotaot was so ahead of its time
19:50hlprmnkyso the fact that some things are being aot-compiled by the uberjar profile leaves stuff in a state that (reset) doesn't like
19:50hlprmnky?
19:50amalloyprobably
19:50hlprmnkyI can live with that as long as it's not Something Bad I Did™
19:51amalloyi am not a big fan of either clojure.tools.namespace's reload mechanism or of AOT, but i am pretty sure that using them both together would cause issues
19:51hlprmnkyand I thought I'd ask, after Googling to little effect and before trying to build a pastebin-able test case
20:03zactsxb
20:08amalloyzacts: TooMuchEmacsException
20:10zactslol
20:14SegFaultAXIs it possible to exclude a single dependency from your uberjar?
20:15SegFaultAX(That dependency will already be on the cp of the target system)
20:15justin_smithSegFaultAX: https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L388
20:15justin_smithSegFaultAX: that document is the Holy Scripture that answers all lein questions that can be answered
20:16amalloyhm, is that really the way to do it? i'd try to find an equivalent to mvn's scope=provided
20:16justin_smithhmm
20:16SegFaultAXjustin_smith: Sure, but I'm not clear how to do that for a dependency. #"foodependency.*.jar"
20:17amalloyit looks like lein knows something about :provided
20:17justin_smithSegFaultAX: maybe put the dep under your :dev profile but not your main profile?
20:17SegFaultAXThe actual problem is: Storm ensures that the storm libraries will be on the CP for each worker, and expects you to use that rather than bundling it yourself.
20:17amalloyjustin_smith: that's another plausible solution
20:17justin_smithamalloy: woah, if it does, that is missing from the sample project.clj and should be added
20:17SegFaultAXOh, that's a good one.
20:18SegFaultAX:dev would be sufficient probably.
20:18amalloylooking through lein source, it looks like you want a profile named :provided
20:18justin_smithamalloy: SegFaultAX: yeah, having it under :dev only would match how we handle eg. the embedded jetty server when deploying a war file
20:19justin_smithamalloy: interesting, if that really works we should add it to the sample project.clj
20:19SegFaultAXamalloy: Mind sharing where you found that?
20:19amalloySegFaultAX: cd leiningen && find . -name '*.clj' -type f -exec grep -nH -Pie 'provided' {} +
20:21amalloythat puts it into the pom as provided, but i'm not sure yet whether that's actually what you want
20:22SegFaultAXamalloy: Thanks.
20:22amalloyit seems to put it on the classpath when in dev and not when in uberjar context
20:22amalloyso probably yes
20:24SegFaultAXTIL: pom-scope
20:27SegFaultAX(Which is the only interesting configuration that profile has)
20:33gfredericksI think I might be in macro hell.
20:35justin_smithgfredericks: sure way to check - are there demons throwing ` / ~ / ~@ at the sexprs of the damned?
20:35gfredericksoh yeah lots of that
20:36{blake}The & is the universal sign of the demon. At least in the Nethack universe.
20:36justin_smith"sexprs of the damned" is my next band name, btw
20:36justin_smith{blake}: it's true
20:36justin_smith&env is a major demon, hanging out with an eye, a nymph, and a vortex
20:36lazybotjava.lang.RuntimeException: Unable to resolve symbol: env in this context
20:36amalloygfredericks: do nothing with the vals of &env srsly
20:36justin_smithhaha
20:37justin_smithe / v are usually easy to deal with, but an &n gangup can be bad bad news
20:37amalloyjustin_smith: pandemonium lord, elf, uh...necrophage i guess, and an insubstantial wisp
20:38gfredericksamalloy: man all I wanna know is what kind of locals get introduced by a thing :/
20:38amalloy<3 DCSS
20:38justin_smithamalloy: stone soup?
20:38amalloygfredericks: isn't that just keys of &env? do you need their types?
20:38gfredericksamalloy: ideally would detect shadowing
20:39amalloyjustin_smith: yeah, i've been playing since august-ish
20:40gfredericksI could make a macro that stores some thread local state and expands to another macro that reads it. That would only be completely awful, right?
20:40SegFaultAXjustin_smith: I've been playing for 2 weeks!
20:40amalloygfredericks: what on earth are you doing
20:41TimMcTrying to write fizzbuzz, no doubt.
20:41justin_smithgfredericks: wait, &env is locals? I thought it was a map you had to explicitly access
20:41amalloyjustin_smith: &env is the lexical environment into which the macro is being expanded
20:42justin_smithamalloy: oh, OK then, I thought it was more limited than that
20:42amalloy,(defmacro m [] `(list ~@(keys &env)))
20:42clojurebot#'sandbox/m
20:42amalloy,(let [x 1 y 2] (m))
20:42clojurebot(2 1)
20:42TimMc(defmacro n [] `(list ~@(m)))
20:43TimMc,(defmacro n [] `(list ~@(m)))
20:43clojurebot#'sandbox/n
20:43TimMc,(n)
20:43clojurebot#<CompilerException java.lang.StackOverflowError, compiling:(NO_SOURCE_PATH:0:0)>
20:43TimMcuh... OK.
20:44amalloy,(defmacro m' [] (into {} (for [k (keys &env)] `['~k ~k])))
20:44clojurebot#'sandbox/m'
20:44amalloy,(let [x 1 y 2] (m'))
20:44clojurebot{y 2, x 1}
20:49gfredericksamalloy: https://github.com/gfredericks/test.chuck/pull/7
20:49gfrederickstrying to find an alternative to filtering symbols based on whether or not they look like gensyms
20:52gfredericksthe only other idea is basically reimplementing all the destructuring logic
20:52amalloygfredericks: are you sure you want to be calling destructure by hand? like, can't you just bind once per non-keyword and then use let?
20:52gfredericksdo what per who?
20:53amalloygfredericks: this is for something like (for-all [x xs, [a b c] x] ...)?
20:53gfredericksI don't *want* to be calling destructure by hand that's for sure
20:53gfredericksyeah
20:53amalloyand at some point do you have need to access a, other than for making it available to the body of the for-all?
20:53amalloythe answer to that seems like it ought to be no
20:53gfredericksexcept that it's yes
20:54gfredericksthis is for reporting what things were generated
20:54gfredericksand maybe your example is bad
20:54gfredericks(for-all [x (gen-an-x), [a b c] (gen-something-with x)] ...)
20:55gfredericksso both x and a b c are relevant to reporting a test failure
20:55gfredericksyou might argue that I should just report [a b c] as an atomic value
20:55amalloyyes
20:55amalloyi was just typing that
20:55gfredericksbut the allowable syntax gets more complicated
20:55gfredericksthis strategy works for test.check's builtin for-all
20:56gfredericksthe failure gets reported as [x [a b c]], and it's easy to figure out what's what
20:56gfredericksbut test.chuck's for-all can e.g., have clauses like (for-all [:parallel [x1 (gen-an-x), x2 (gen-an-x)], [a b c] (gen-some-abcs-with x1 x2)])
20:57gfredericksand then the positionality starts to be more confusing
20:57gfredericksthat's the most complicated element at the moment but I've been noodling another feature that would have similar issues
20:58amalloywhat is this parallel baloney?
20:58gfrederickssugar for gen/tuple
20:58amalloythat looks like vinegar, not sugar
20:58amalloybut i guess it's a matter of taste, har har
20:59gfredericks(for-all [[x1 x2] (gen/tuple (gen-an-x) (gen-an-x)), ...] ...)
20:59cflemingI'm having a problem with thread-local bindings after upgrading from 1.5.1 to 1.7.0-alpha5
20:59gfredericks^ you don't have the bindings next to the generators that way
20:59gfredericksso in all but the simplest cases it can be a lot harder to read
20:59cflemingThis is for the Cursive Leiningen integration
20:59amalloygfredericks: mmm, okay, i can see how that might be nice. i would address it by writing [x1 x2] [(gen-x1) RET (gen-x2)] but okay
21:00cflemingWhen lein loads wagon plugins, it calls eval on a file that it fishes out of the wagon jar
21:00gfredericksamalloy: that looks like syntactic hot dogs
21:01cflemingI bind the thread local classloader and Compiler/LOCAL to a new DynamicClassLoader before calling into lein, and that's always worked until now.
21:01cflemingNow it can't find one of the classes that should be present in that classloader, and indeed the classloader bound to LOADER is switched at some point.
21:02cflemingDoes anyone know of any changes in recent clojure versions that might affect this?
21:03cflemingI think eval creates a new classloader for each evaluation, but I assume it did that in 1.5.1 too.
21:10TimMc,(defmacro env [] (vec (map name (keys &env))))
21:10clojurebot#'sandbox/env
21:10TimMc,(defmacro subject [] (env))
21:10clojurebot#'sandbox/subject
21:10TimMc,(subject)
21:10clojurebot["&env" "&form"]
21:10gfrederickswelp it works https://www.refheap.com/97457 TimMc amalloy justin_smith
21:11gfredericksI made it anaphoric because while you're writing a side-effecting macro you might as well also do that
21:11gfredericksI guess this will fail if you use let' in the binding expressions, but I just thought of a way to fix that
21:12gfredericksI probably won't bother because I can't imagine I will actually use this
21:12julianlevistonfor cursive do I need to have the .idea/workspace.xml file checked in to my CVS?
21:12cflemingjulianleviston: No, it's better not to - that changes all the time and contains things like window placement and so on.
21:13amalloygfredericks: ThreadLocal has a constructor where you can pass it a thunk to use to generate a fresh copy
21:13amalloyor something like that
21:13gfredericksamalloy: is that useful here?
21:13julianlevistoncfleming: Cool. I looked at its contents before and it seemed that that was what it was for. I’ll gitignore it. Ta!
21:13amalloygfredericks: well you'd never have to worry about the-env being nil and then setting it to {}
21:13gfredericksthat's not why {} is there
21:14gfredericksI *want* it to be nil normally that's how I can tell the macro is being called the first time versus the second time
21:14julianlevistoncfleming: might be a good idea to add this to the website. I had a look there first, but didn’t find it.
21:14gfredericks{} is there because &env is nil apparently instead of {}
21:14gfrederickswhich ruins my flag
21:14cflemingjulianleviston: Good idea, I'll do that
21:14gfredericksI mean I could set the-env to default to something else like ::nope, either way
21:15julianlevistoncfleming: one more thing for your extremely light workload ;-)
21:15cflemingjulianleviston: I'll add it to a list somewhere :)
21:16amalloygfredericks: so wait, you still get the vec__x thing here. how is this better than using destructure, then?
21:16gfredericksamalloy: in fact if I were to solve the called-in-the-bindings-expr-as-well problem I'd probably just quit using a ThreadLocal and make a global atom
21:16gfredericksamalloy: with destructure I get a totally different gensym and compile fails
21:16gfredericksthis time it's the right gensym
21:17amalloyhuh? what do you mean, a different gensym?
21:17gfredericksI'm calling it and the compiler is calling it
21:17amalloyno, don't let the compiler call it
21:18amalloyjust let the destructured stuff yourself
21:18gfredericksthat sounds best if I can make it fit in this macro, gotta think it through
21:19gfredericksit's definitely possible but it's not as trivial is you'd suspect
21:19gfredericksto the point where I'm still wanting something cleaner
21:20amalloygfredericks: https://www.refheap.com/2e4a14d4331ea0918bfb57e4a
21:20amalloy(let' [[a b] (range)] &lettings) ;=> (vec__2198 a b)
21:21gfredericksamalloy: yeah it works fine for just let I'm saying for for-all it's harder
21:21gfredericksdue to things like :parallel
21:22gfredericksI'm starting to think just encoding a sufficient amount of destructuring logic actually isn't bad
21:25gfredericksyeah I can do this in like 20 lines
21:25gfredericksand this avoids the gensyms too, which is a secondary goal
21:28gfrederickshere it is and there are absolutely no bugs: https://www.refheap.com/97466
21:30amalloygfredericks: :(
21:30amalloywant me to tell you some bugs?
21:30gfredericksyes
21:30amalloyoh well actually i didn't really read it. maybe it's fine
21:30justin_smithhaha
21:31gfredericks;; amalloy says maybe this is fine
21:31gfredericksactually there is one bug
21:32gfredericks,(let [{:keys [a/b]} {:a/b 12}] b)
21:32clojurebot12
21:32gfredericks^ that nonsense
21:32gfredericks,(let [{:syms [a/b]} {'a/b 12}] b)
21:32clojurebot12
21:32gfredericks,(let [{:strs [a/b]} {"a/b" 12}] b)
21:32clojurebot12
21:32gfredericksomg
21:32amalloybahahaha
21:32amalloyfeature unlocked
21:32justin_smiththat reminds me - this code seems good so far, but I am suspicous, any obvious issues? https://www.refheap.com/97344
21:32justin_smithgfredericks: that is hilarious
21:33gfrederickswoulda bet $10 against that
21:33gfrederickshey it makes my code easier cause it's consistent
21:34numbertendoes clojure have a way to compare strings (or better yet keywords) lexicographically?
21:34justin_smith,(comp "hello" "world")
21:34clojurebot#<core$comp$fn__4458 clojure.core$comp$fn__4458@66df3220>
21:34amalloyjustin_smith: why are you using this at all instead of like (deref (future (f) time alternate))?
21:34justin_smitherr
21:34justin_smith,(compare "hello" "world")
21:34amalloyer
21:34clojurebot-15
21:34amalloy(deref (future (f)) time alternate)
21:35justin_smithamalloy: hmm... does that cancel the future after the timeout?
21:35numbertenjustin_smith: thanks :)
21:35gfredericksnumberten: github.com/gfredericks/compare if you want better syntax
21:35julianlevistonnumberten: what’s your expected output?
21:36justin_smithamalloy: that doesn't cancel the future
21:36amalloyjustin_smith: no, but future-cancel is a best-effort thing anyway
21:36justin_smithamalloy: right, but I intended for this to be used with things that are cancellable
21:37justin_smithamalloy: excellent point about the extra args on deref though, I totally forgot about that
21:37amalloyjustin_smith: well, you can write the function much more easily with deref than your version, even if you want to ensure it gets cancelled
21:37justin_smithamalloy: yeah, that is a good point
21:37justin_smith(inc amalloy)
21:37lazybot⇒ 228
21:37numbertenjustin_smith: just wanting to compare things
21:38amalloy(let [ret (deref (future (f)) time ::time)] (if (= ret ::time) alternate ret))
21:38justin_smithnumberten: julianleviston was the one who asked
21:38numbertens/justin_smith/julianleviston
21:38numbertenyeah
21:38amalloybut cancelling where appropriate
21:38justin_smithnumberten: yeah, compare uses the underlying comparable interface, which strings (among many many other things) implement
21:38justin_smithnumberten: so it should do everything you like
21:38numbertenideally i'd like to be able to use a comparable key for maps
21:39numbertenand write a function that can return the next lowest key
21:39gfrederickssorted-map-by
21:39amalloyand then subseq/rsubseq
21:39gfredericksI used those in my test.chuck code and it was way overkill O_O
21:40gfrederickslike it a context where collections would almost never have more than ten elements but *you never know*
21:42numbertendo subseq/rsubseq returns sorted collections?
21:43numbertencan you be sure that the first one is the least/most less/more than the key?
21:43numbertenthe documentation is unclear
21:43justin_smithnumberten: they do if they are derived from a sorted collection
21:43numbertenthat makes sense, just from an implementation pov I guess
21:43numbertenthank you :)
21:43clojurebotHuh?
21:48julianleviston,(sorted-map :x 1 :a 3 :d 5)
21:48clojurebot{:a 3, :d 5, :x 1}
21:48julianlevistonnumberten: I’m guessing your answer is… sorted map just does what you want, so pick that collection?
21:51justin_smith(subseq (sorted-map :a 0 :b 1 :c 2 :d 3 :e 4) < :d)
21:51justin_smith,(subseq (sorted-map :a 0 :b 1 :c 2 :d 3 :e 4) < :d)
21:51clojurebot([:a 0] [:b 1] [:c 2])
21:52justin_smithsadly it doesn't hand you back another sorted-map
21:53julianlevistoncan’t you just into sorted-map filter or something?
21:54gfredericksyeah but that's linear time now
21:54justin_smithwell, you don't need the filter part if you have subseq, but sure
21:54justin_smith(inc gfredericks)
21:54lazybot⇒ 118
21:54numbertenis subseq/rsubseq lazy?
21:54justin_smith,(type (subseq (sorted-map :a 0 :b 1 :c 2 :d 3 :e 4) < :d))
21:54clojurebotclojure.lang.LazySeq
21:55justin_smithI'm surprised, but yes
21:55numbertenvery cool
21:55numbertenso then
21:55julianlevistonI’m not really sure what he’s trying to do anymore… I thought he was just trying to have a sorted map?
21:55justin_smithjulianleviston: he wants a subsequence by some key
21:55justin_smithjulianleviston: subseq can give you that directly without walking every item preceding it
21:55justin_smithsince vectors / sorted maps are associative
21:56julianlevistonjustin_smith: sorry, I thought he just wanted to sort a map. All good.
21:56numberten#(first (rsubseq %1) < %2) should give you the first element less than some key
21:56numbertenin a sorted map
21:56justin_smithnumberten: subseq also has an extra arity for for an end-test / end-key
21:56numberteninteresting
21:57justin_smithif you want a "slice"
21:57numbertenyeah
21:57numbertenthat's pretty nifty
21:57numbertenmany thanks
21:58amalloyjustin_smith: checking whether its type is LazySeq doesn't really tell you anything about whether it's lazy
21:59amalloyi can compute a result eagerly and then just by coincidencey wrap it in a lazyseq
21:59justin_smithamalloy: that's a good point
21:59amalloyas it happens subseq *is* lazy
21:59amalloybecause like, why wouldn't it be
22:00justin_smithamalloy: I guess I trusted the clojure devs to pick lazy-seq if and when laziness would actually be exploited, and pick something else otherwise. It payed off this time I guess.
22:00numberteni hadn't thought of that
22:00numbertengood to note though
22:01amalloyPS if you are looking for a way to get confused, try to call subseq on (sorted-map-by > 1 :a 2 :b)
22:01amalloy(or well a larger version of this map, because for 2 elements it's not so bad)
22:01justin_smithamalloy: shouldn't the comparator provided to subseq agree with the one provided to sorted-map-by?
22:02justin_smithor are you talking about something trickier than that
22:03amalloyjustin_smith: i mean, that sorted-map-by is just a map sorted backwards, right, you can easily imagine saying "i want to find the first number greater than 6 in this map"
22:04amalloywhich if you made a (sorted-map 1 :a 2 :b) is just (key (first (subseq m > 6)))
22:04amalloythe other way it's < instead of >
22:05justin_smithmirror-reality
22:06justin_smithwe could rename it to bizarro-map-by
22:08gfredericksI released it :/ https://github.com/gfredericks/test.chuck/blob/master/src/com/gfredericks/test/chuck/properties.clj#L8-48
22:09gfredericksAt Least It's Not A Macro That Shoves &env Into A ThreadLocal™
22:10amalloygfredericks: you decided not to fix the a/b issue?
22:11gfredericksit's fixed
22:11gfredericksI mean I didn't test it but
22:11gfredericksthat's why it calls symbol-name
22:12amalloyoh, i figured you would just do that in the symbol? case. i didn't look at the map case
22:12gfredericks,(let [a/b 12] b)
22:12clojurebot#<CompilerException java.lang.RuntimeException: Can't let qualified name: a/b, compiling:(NO_SOURCE_PATH:0:0)>
22:12gfredericksphew
22:15gfredericks,(let [{:keys [a/b b]} {:a/b 12 b 13}] b)
22:15clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: b in this context, compiling:(NO_SOURCE_PATH:0:0)>
22:15gfredericks,(let [{:keys [a/b b]} {:a/b 12 :b 13}] b)
22:15clojurebot12
22:15gfrederickssurewhynot
22:25justin_smithamalloy_: yeah, this is kind of weird ##(subseq (sorted-map-by (comp #(* -1 %) compare) :a 0 :b 1 :c 2 :d 3 :e 4 :f 5) < :e < :b)
22:25lazybot⇒ ([:d 3] [:c 2])
22:26justin_smithusually the conditions would want to be opposites
22:26justin_smithbut with the reverse map, they actually want to agree
22:26justin_smithreverse-sorted
22:29justin_smithequavalent sorted map, with opposing tests ##(subseq (sorted-map :a 0 :b 1 :c 2 :d 3 :e 4 :f 5) > :b < :e)
22:29lazybot⇒ ([:c 2] [:d 3])
22:29tvanhensanyone ever have trouble with wrap-cors library? All my other middleware are functioning properly but when I add it to my chain and allow #".*" I don't see any allow headers on my response headers
23:01amalloyjustin_smith: now remember to ask whether you mean subseq or rsubseq in that reversed map...
23:01justin_smithheh
23:54emaczenwhich emacs clojure mode should I use with Cider?
23:54emaczenClojure-mode or clj-mode?
23:55emaczenOr does Cider use one of those by default?
23:55justin_smithemaczen: clojure-mode