#clojure logs

2015-07-24

01:50J_ArcaneI didn't even know about ##.
02:47crocketIt seems inline implementations can refer to the type being defined in clojure 1.7
04:07sagaxhi all
04:08sagaxhowto run mycode.clj file in command line?
04:08sagaxrun in linux
04:08TEttingersagax: you should really really use leiningen.
04:09TEttingerif you want to run a single file, uh I think you can do it using clojure.jar
04:09sagaxuse leiningen it's true way?
04:10sagaxi wish command line because i need output in stdout
04:10TEttingerah!
04:10TEttingerjava -cp /path/to/the/clojure.jar clojure.main /path/to/your/code.clj
04:10TEttingerreplacing paths to fit
04:11sagaxthanks, i will try this
04:11TEttingerleiningen is command line unless something is wrapping it
04:11TEttingermost people will not know how to run your project if it's a bare clj file, though
04:11crocketTEttinger, Don't we have similar tools to leiningeN?
04:11TEttingeryeah, boot
04:11crocketI heard cake and so on.
04:12crocketCake doesn't exist anymore.
04:12crocketBy the way....
04:12sagaxhm, but now i have only single file .clj and nothing more
04:13crocketWhat is the best way to reduce leiningen repl startup time?
04:14TEttingercrocket: probably technomancy's odd-seeming but successful attempt to rewrite the slow parts of lein in OCaml
04:14TEttingerhttp://leiningen.org/grench.html for linux and osx only I think? maybe windows
04:15TEttingerfailing that, use drip to have a JVM already ready to go when you need one
04:15TEttingerhttps://github.com/josteink/lein-drip
04:16crocketHell
04:16crocketOCaml starts really fast.
04:17crocketOSome!!
04:17TEttingerhttps://github.com/technomancy/leiningen/wiki/Faster
04:17TEttingerglad to help!
04:18sagaxjava -cp /path/to/the/clojure.jar clojure.main /path/to/your/code.clj
04:18sagaxwhat mean "clojure.main"
04:18sagax?
04:19ordnungswidrigsafax: thats the classname in which the jvm looks for a main method to run
04:19TEttingerthat's telling clojure.jar what class to load, the class "clojure.main" in clojure.jar
04:20sagaxthank, i got it
04:20TEttingerand your/code.clj is an argument to clojure.main, so it runs it
04:20sagaxthat's what i need, thanks
04:21TEttingerif you don't pass the last argument (don't pass your code), then clojure.main defaults to running an interactive interpreter
04:39sagaxi must use ide for clojure programming or i can use vim?
04:40sagaxsome ide for java or clojure
04:48ordnungswidrigsagax: there's vim-fireplace https://github.com/tpope/vim-fireplace
04:48noidihttp://www.neo.com/2014/02/25/getting-started-with-clojure-in-vim
04:52xificurCwhat would be the correct way to generate a filename from a URL? e.g. input is http://www.example.com/my%20file.txt and output could be "my file.txt"
05:04ordnungswidrigxificurC: ,(.getPath (java.net.URI. "http://example.com/foo"))
05:05ordnungswidrigxificurC: but beware the URIs can contain characters which are not allowed on your local filesystem
05:06xificurCordnungswidrig: thanks. I'm trying to use itsy for crawling and fighting my way through. Not sure how to save an http request that resolves to a binary file
05:06xificurCe.g. zip, jpg etc
05:07xificurCordnungswidrig: is there a cross-platform normalizer for that? To convert a string to something allowed as a file name on the local filesystem
05:09xificurCI could save the URIs and wget them but there's surely a clojure way
05:10ordnungswidrigxificurC: java.nio.file.Path will test whether a file name is valid
05:49xificurCdoes anyone here know itsy? I'm riddled as it seems the spider (web crawler) spawns a bunch of threads and never checks if it finished its job (i.e. it doesn't stop the threads in the end). How does one then know when to terminate the spider?
06:12themeHi! I am still trying to understand how lisps are "good" languages
06:13themeSo I have a few questions
06:14themeIf you are not allowed to write any macros of your own, but you are allowed to use macros someone else wrote, would you still like lisp?
06:15algernonyes.
06:15themealgernon, why?
06:16xificurCtheme: if you can only use macros someone else wrote (like the language maintainer) it doesn't really matter whether he uses macros or other facilities, from your POV. So the question could very well be "would you use lisps if there were no macros?"
06:17themeok... lemme rephrase the question
06:17wasamasatheme: maybe you should take a look at how much of clojure.core is macros
06:17themewasamasa, that is why I didn't ask it the way xificurC suggested
06:18algernontheme: because my choice of lisps (clojure & hy) provide a great deal of benefits even without macros.
06:19wasamasatheme: it's ~70
06:19themealgernon, such as?
06:19themewasamasa, I allowed using macros *someone else* wrote
06:19xificurCI think of macros as a way to extend the expresiveness of the language (is that a good view?). theme - how much do you feel the need to extend insert-already-mature-language-here?
06:20wasamasatheme: yes, there's at least 70 of these in clojure
06:20themexificurC, for some languages, not much
06:20algernontheme: higher order functions, the concurrency stuff (core.async), the REPL, homoiconicity, to name a few.
06:20themeor maybe nothing
06:21algernonrepl-driven development is incredibly useful for what I do. being able to shape data *and* code the same way, too.
06:21xificurCtheme: the same way there's not much need of it here. It's a nice benefit though
06:22wasamasaseqs as abstraction allow describing very common problems in little code
06:22themeQuote from the book "On Lisp": "Language and program evolve together...In the end your program will look as if the language had been designed for it. And when language and program fit one another well, you end up with code which is clear, small, and efficient."
06:22themeHow true is that quote? ^
06:22themewasamasa, I have iterators in some languages
06:23wasamasatheme: which are totally not the same thing
06:23algernontheme: that quote is very true.
06:23themewasamasa, they aren't?
06:23themealgernon, can you give an example?
06:23wasamasatheme: what good are iterators if your language support for higher order functions sucks (as in python)
06:24algernontheme: any of the lisp DSLs. I think core.logic is an incredible example, and so is overtone.
06:24themealgernon, let me check that out
06:24sagaxhowto i print list with - for and range?
06:24sagaxlike this
06:24sagax1
06:24sagax2
06:24sagax3
06:25themewasamasa, iterators are probably just as good as seqs if the languages supports higher order functions well
06:26Bronsatheme: iterators are mutable though, seqs aren't
06:26wasamasatheme: have fun writing java 8 then
06:27wasamasait has iterators and lambdas, so if you believe that's all for it to not feel like an abomination, be my guest
06:28wasamasafor the record, ruby is probably the closest language if you want something that feels like lisp
06:29sagaxJava and clojure I still very unclear for me
06:29themewasamasa, java isn't a horrible language, but not my favorite language either
06:29themewasamasa, heh... so I wasn't the only person who feels ruby is similar to lisp
06:30themesagax, I believe that a "for loop" is the wrong tool for that
06:31wasamasa,(for [x (range 3)] (println x))
06:31clojurebot(0\n1\n2\nnil nil nil)
06:31themelol
06:32themeoh wait, I confused for with do
06:32themesagax, ignore me
06:34themewasamasa, so core.logic is prolog in clojure?
06:35wasamasatheme: sure sounds so
06:35wasamasacore.match is also neat
06:35themeok.... so macros can emulate a lot of features from other languages
06:37themeWhy people get confused in a dynamic-typed system?
06:37theme*don't get*
06:38wasamasawhy do some people climb mountains without ropes?
06:39themeWhen I write a function, one of the very first things I think is "What are the arguments' types? What can I do with them?"
06:39themeAs a result, I often write out the types even in languages where type signatures are optional
06:41wasamasawell, typed clojure is a thing if you want to reap these benefits
06:42themewasamasa, is your thought process different or something?
06:42wasamasatheme: yup
06:42wasamasatheme: I rather think about how functions transform their inputs
06:42Aang4chiwasamasa: isn't it the same thing?
06:42wasamasaAang4chi: well, no, in java I'd be rather thinking about the types
06:43themeI sometimes attempt to use an array index in place of the data in the array
06:44themeeven C's rudimentary type system can catch that
06:44Aang4chiwasamasa: oh, by saying "how function transmorms arguments" you mean actual implementation, not the mapping from inputs to outputs?
06:44wasamasaAang4chi: well, yes
06:44Aang4chiInteresting.
06:44wasamasaI also use the built-in datatypes way more than custom ones
06:46Aang4chitheme: the problem with modern type systems is that they are usually not expressible enough. I see types as a design tool, not as a development tool which helps you spot a typo or something like that. I think minor mistakes like the one you've described are rather rare and are non that important.
06:46themeWhen I try to write a recursive function in python, I sometimes get into confusing bugs, (such as appending a list of lists to a list of numbers)
06:46themeI find that very annoying
06:47themeAang4chi, what do you mean by "modern type systems"?
06:49Aang4chitheme: the ones we have in Haskell\Ocaml\Scala\etc
06:49themeAang4chi, and that's not expressive enough?
06:49themeO_o
06:50Aang4chiWell, yes.
06:51themebtw quite a large portion of my bugs involves doing the right thing with the wrong variable
06:52themeAang4chi, what do you want to express that you find those type systems not expressive enough?
06:56algernontheme: recursive functions are much more clear when you don't mutate random stuff.
06:57themealgernon, I don't mutate random stuff -_-
06:58thememost of my functions mutate only local variables
06:59Aang4chitheme: well, it's not about me in particular. For example, in ocaml it's not very convenient to work with polymorphic definitions due to lack of type classes. In Scala... Do we even have dependent types in scala? Haskell... Try defining plus = (+). The list goes on and on.
07:01themeAang4chi, what's wrong with "plus = (+)"?
07:02Aang4chitheme: https://www.refheap.com/106911
07:03themeAang4chi, eh??
07:03lazybottheme: Uh, no. Why would you even ask?
07:04themeAang4chi, works on ghc.io
07:05themeweird
07:06themeAang4chi, oh great... "The restriction is turned on by default in compiled modules, and turned off by default at the GHCi prompt (since GHC 7.8.1)."
07:06Aang4chitheme: well, I'm not really following Haskell so I can't tell you whether they did something to the inference algorithm in later versions of ghc or it depends on compilation options.
07:06themehttps://wiki.haskell.org/Monomorphism_restriction
07:06Aang4chiYeah, that's the link I wanted to paste too, lol.
07:07themeAang4chi, you can turn it off, so it doesn't sound like a fundamental problem with types
07:08Aang4chiWell, obviously it's just one minor special case. The point is that type systems are still not sophisticated enough.
07:11Aang4chiI should point out that I think types are awesome and really cool and all that stuff. I imagine someday we will have formal description of every API and protocol on the web, and implementations will be checked statically to conform to it. But we're not there yet.
07:16TMAand we won't ever be there, APIs and protocols are made faster than formal descriptions thereof
07:19Aang4chiTMA: well, they are writing documentation after all, aren't they?
07:21TMAthat too is unfortunately lagging behind the implementation
07:25TMAa given chunk of functionality takes M pages of code -- i can cram more features in if I forgo documentation or testing or formal specification or ...
07:27TMAmost people are not motivated enough to improve on their work once the product is labeled "WORKSFORME" in their heads; I think that the problem is with human psychology
07:27TMAif it can be shipped without X it eventually will be
07:28noncom|2Aang4chi: probably we have to make an AI to do that since as I see it, human factors will never avail to it, unless someone employs specifically OCD-enabled people for that, but that's not very likely too
07:28TMAAang4chi: unless there is a way to make the formal specification mandatory for using the product, the specs won't exist in general
07:30noncom|2yeah, coding takes too much thought and dedication. no one cares much for the mere narrative letters when they can code... something else has to come and fill the space for this to work.
07:32TMAand to add insult to injury: the people responsible for shipping might just strip the formal specification from the documentation, because they do not understand it ad therefore it is some unnecessary fluff
07:33TMAafter several years of a system being in production we have received formal specification of the interface. On a special request. As an _exceptional_ courtesy. Even though it was available (and acurate, unlike the provided documentation) since the very start.
07:34noncom|2TMA: are you talking about some system you use?
07:34noncom|2some 3rd party one?
07:34TMAnoncom|2: yes
07:35noncom|2heh
07:37TMAthe programmer of the 3rd party system has told me, that he has this formal description for every version he made, because it makes HIS life easier; We have spent a week with each version by recreating it (to make our lives easier) via reverse engineering
07:43Aang4chiTMA: so bitter
07:43Aang4chiIf Shakespeare was a programmer, I'm sure he'd written something along these lines
07:44Aang4chiIn the end both your and 3rd party teams would kill themselves out of desperation.
07:46Aang4chiSeriously though, if SPAs will be dominating and servers will just serve raw data, I imagine search engines could do something to politely force people to maintain specs to their data.
07:46Aang4chiIt's very, very speculative, but you get what I mean.
07:53wiruzxHi everyone
07:55wiruzxDo you know, why leiningen says to me that Don't know how to create ISeq from: clojure.lang.Keyword when I'm adding :source-paths ["src/clj"] into a project file?
07:55wiruzxSorry for the stupid question though
07:56Aang4chiwiruzx: paste the whole project.clj
07:56oddcullywiruzx: could you put your projects.clj on refheap, pastebin, ... please?
07:56winkwiruzx: maybe it should be [["src/clj"]]
07:56wiruzxI tried, but it didn't work
07:57winkok, then see what the others said ;)
07:57wiruzxBasically it's just an empty compojure template
07:57wiruzxWith only added :source-paths
07:57wiruzxjust a sec, i'll create gist
07:57oddcullythe problem could be, where you have added it
07:57wiruzxhttps://gist.github.com/wiruzx/b329e9081e3a8b01548f
07:58wiruzxoh crap
07:58wiruzxsorry
07:58wiruzxi'm very stupid
07:58oddcullyrubberducking worked?
07:58wiruzxYou were absolutely right
07:58oddcully(inc rubberduck)
07:58lazybot⇒ 3
07:58clojurebotCool story bro.
07:58wiruzxThanks
07:58Aang4chiLol.
07:59wiruzxI need more cofee
07:59snowellNever heard that term before…now I will use it more than I should :D
08:01Aang4chisnowell: same here, lol.
08:06winkhttps://en.wikipedia.org/wiki/Rubber_duck_debugging yea
08:06winkbut my experience is more like typing it out into irc helps best.
08:06winkthe more people in the channel the better
08:07irctcHi, I want to use an atom in a multithreaded application to save some state
08:07irctcBut I have the following problem: http://pastebin.com/pqD6WPGy
08:08irctcI want to check if a value is in the collection , and if not, add it there and do some calculations.
08:08irctcProblem is that between the contains? check and the swap!, another swap! may have happened
08:08irctcSo do I need to use a ref to coordinate updates to a single state?
08:10Aang4chiEither use ref, or perfom check and modification in one function.
08:13irctcIf I do the check and modification in one function, using swap, then the new value of the collection is returned. But I would have to do another deref to check if the calculations need to be done
08:14irctcI dont see how to do this with swap
08:17irctcI got it to work like this: calculations only happen once. But it seems there is a simpler way: http://pastebin.com/HjsgGBt2
08:34ordnungswidrigiref: why not (swap! collector (fn [c] (if (contains c n) c (conj c n))))
08:37ordnungswidrigirctc: whoops, that was meant for you, not iref
09:20crockethi
09:21crocketDo we benefit a lot from dependency injection in clojure?
10:03yoyohi
10:18jefelanteIs there a more idiomatic way to write this function? it feels like I have some redundant blocks but it took me a lot of tries to get it to work since I don't quite understand go-loop and alt! https://gist.github.com/anonymous/a7c47cd7b38c2e71a9bd
10:47timjefelante: yes, when you close a channel it starts delivering nil after all pending puts are delivered
10:48timso drop the alt!, and the off-chan. Just close the in-chan when you're done
10:48jefelanteoh
10:49jefelantewell i guess i over thought that one
10:49jefelantethanks! :)
10:52ericbmerrittI have a, hopefully, straightforward ring question that is stumping me.
10:52ericbmerrittfor various reasons I am stuck deploying as a war. I am using sierra's component library.
10:52ericbmerrittI want to initialize the components once and then use them in the handlers.
10:53ericbmerrittbut the ring init function doesn't take advantage of a return value, there there isn't any way to set state (which is a good thing generally, but I am trapped by the war).
10:53ericbmerrittis there a way around this, or do I just have to move away from the component model?
10:56gfredericksericbmerritt: you should be able to use a var as a piece of global state
10:56gfredericksso the ring handler can be a var, and the init function can set it with alter-var-root
10:57ericbmerrittgfredericks: aren't vars all thread-local though (I am getting up to speed on clojure).
10:57gfredericksericbmerritt: nope, that's just ^:dynamic vars
10:57gfredericksnormally named *with-earmuffs*
10:58stuartsierraPrior to Clojure 1.3, all Vars were optionally bindable as thread-local.
10:58gfredericksclojure 1.3 is the oldest clojure ever
10:58ericbmerrittgfredericks: thanks. that should solve my problem. I wish I had asked two days ago :P
10:59gfredericks,(def my-handler nil)
10:59clojurebot#'sandbox/my-handler
10:59ericbmerrittstuartsierra: thanks for components, I was missing 'apps' from my erlang projects and that replaces it well
10:59gfredericks,(alter-var-root #'my-handler (constantly (fn [req] {:body "Got it."})))
10:59clojurebot#object[sandbox$eval47$fn__48 0x2a195a95 "sandbox$eval47$fn__48@2a195a95"]
10:59gfredericks,(my-handler {})
10:59clojurebot{:body "Got it."}
10:59stuartsierraericbmerritt: You're welcome!
11:02thein5OhWhy we're at it... I was always wondering: shouldn't the functions in component be called start! and stop!, that is, with exclamation marks? Is this convention still relevant?
11:02stuartsierrathein5Oh: the `!` convention isn't very well-defined. Some people use it to mean "has side effects" while others use it to mean "modifies state," e.g. swap!
11:03stuartsierraEven Clojure is inconsistent in this regard, e.g. swap! vs alter-var-root.
11:04stuartsierra`start` and `stop` in Component don't necessarily have side effects, although they usually do. It's up to the user.
11:05thein5Ohstuartsierra: I always thought it was safe to use in stm transactions vs not safe to do so (thus send but swap!). On the other hand, it may not be that practical to make such a general convention to depend on one particular language construct...
11:06thein5OhSo yeah, I see - there is no single convention actually.
11:09stuartsierraMy personal convention is to name side-effecting functions as verbs, pure functions as nouns.
11:18dstocktonwhat if a word is both a noun and a verb
11:19dstocktonaddress, credit, charge, answer
11:19dstocktontotal chaos
11:20TimMcI use Cyrillic homoglyphs for side-effecting functions.
11:21TimMcfor example, copy vs сору
11:22rpaulodo you program alone?
11:22TimMcFunny you should ask!
11:22TimMcBut in the end, does not everyone program alone?
11:32justin_smithstuartsierra: let's not forget the "! means not safe in a transaction" convention
12:17kwladykawhat do you think about parameters in functions? (defn foo [[cols rows] queen rook bishop king knight] ...) or (defn foo [[cols rows] [queen rook bishop king knight]] ...) or map with :queen 2 :king 3... from one side (defn foo [queen rook bishop king knight] ...) tell programer exactly what he need to write, but from other hand it is less readable, because in many cases i have to pass this as it is to other function
12:17kwladykaoh and (defn foo [board-size pieces] ...) <- which is the most readable
12:17kwladykabut dont tell coder how exactly parameters look
12:18kwladykabecause Clojure doesn't have strong types
12:22gfredericksdoes anybody know why my cljs program logs an error in the browser console trying to load "../goog/base.js" but then otherwise works fine?
12:23kwladykagfredericks, what error?
12:28gfredericksoh man I didn't look closely enough
12:28gfredericksmy html file explicitly tries to load it; I'll just delete that line since apparently I don't need it
12:28oddcullyswitched builds? stale stuff?
13:13gfredericksis anybody nontrivially using test.check in cljs?
13:50noncom|2is derefing an atom considered an expensive operation to be avoided when possible ?
13:51noncom|2(apart from other implications of derefing an atom)
13:52gfredericksnoncom|2: I don't think so
13:52noncom|2besides from the time taken for the actual pointer works, afaik it can block for a little while if the atom is currently being changed... no?
13:52justin_smithderef of an atom is cheap
13:52justin_smithnoncom|2: no, there is no blocking of deref
13:52noncom|2ah
13:53timvisher,(let [x (throw (Exception.))] ["ohai" x])
13:53clojurebot#error {\n :cause nil\n :via\n [{:type java.lang.Exception\n :message nil\n :at [sandbox$eval25 invoke "NO_SOURCE_FILE" -1]}]\n :trace\n [[sandbox$eval25 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.java" 6792]\n [clojure.lang.Compiler eval "Compiler.java" 6755]\n [clojure.core$eval invoke "core.clj" 3079]\n [clojure.core$eval3$fn__4$fn__14 invoke "NO_SOURCE_FILE" 0]...
13:53noncom|2timvisher: what did you expect with that?
13:53tbaldridgeright, deref will never bock. Although swap! will "spin lock" as every swap competes for access to the atom
13:54noncom|2okay, very good, so if I only have 1 thread working on atoms, reading and writing them, then there will be no real cost for that
13:55tbaldridgecorrect. not a significant one. There's some low-level CPU communication that has to happen, but you probably won't notice it
13:55timvishernoncom|2: we're having a very weird issue with cheshire 5.5.0 where we can't catch a parse exception
13:55justin_smithtbaldridge: right, but you don't need to wait for the swap!s to stop spinning before getting a value (for better or worse), if you want that kind of linearity an agent with await might help
13:55timvisherbut it behaves exactly as i'd expect to it in every other context
13:55timvisherwe thought because of some repl weirdness that the let was eating the exception and somehow binding it to the symbol
13:56timvisherbut that's obviously not the case
13:56noncom|2timvisher: maybe you could post a sample on refheap?
13:56timvisherand i just verified it
13:56timvishernoncom|2: let me see if we can
13:59noncom|2hmmmm, stumbled upon a fun thing:
13:59noncom|2,{[] [] (int-array 1) [] (int-array 1) []}
13:59clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Duplicate key: (int-array 1)>
14:00noncom|2the macro checks for the appearence...
14:00gfredericksit's not the macro, it's the reader
14:00gfredericks,'{[] [] (int-array 1) [] (int-array 1) []}
14:00clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Duplicate key: (int-array 1)>
14:00gfredericks^ you can't even quote it
14:00Bronsanoncom|2: the '(int-array 1) list appears twice as key at read-time
14:00justin_smithnoncom|2: ##(hash-map Double/NaN 0 Double/NaN 1 Double/NaN 2 Double/NaN 3)
14:00lazybot⇒ {NaN 0, NaN 1, NaN 2, NaN 3}
14:00noncom|2i thought thats the reader macro
14:01justin_smith,{Double/NaN 0 Double/NaN 1}
14:01clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Duplicate key: Double/NaN>
14:01noncom|2hehe
14:01gfredericksjustin_smith: cute
14:01noncom|2gotta keep an eye on all that
14:01noncom|2special cases
14:01justin_smith##(get (hash-map Double/NaN 0 Double/NaN 1 Double/NaN 2 Double/NaN 3) Double/NaN)
14:01noncom|2happen :)
14:01lazybot⇒ nil
14:02Bronsajustin_smith: wait what
14:02justin_smithit's hilarious, isn't it?
14:02Bronsaah yeah NaN is not a special symbol
14:02Bronsa(╯°□°)╯︵ ┻━┻
14:03Bronsa(http://dev.clojure.org/jira/browse/CLJ-1074)
14:05gfredericks#clojure is place where Bronsa listens to WTFs about clojure and points people to existing jira tickets
14:17vas_If i specify :ring {:handler ph.core/app, :port 4004} in project.clj everything works fine, but changing the port to 80 does not let the app run... possible to run my app on port 80?
14:18stuartsierravas_: Most operating systems require special privileges (e.g. root) to allow binding to port 80.
14:25vas_stuartsierra: awesome, that helps a lot... reading about it, it seems that people bind to something like 8080 and reroute via iptables... some people prefer to use nginx
14:33timvishernoncom|2: i think we've got it solved. it turned out to be a strange noir middleware issue.
14:34timvisheressentially we weren't the ones throwing the exception we were seeing
14:34timvisherthe strangest bit of it though is that we have stack traces that show our code as being the thrower
14:34timvisherbut we can't reproduce it anymore, and don't have time for a bisect :(
14:41noncom|2timvisher: yeah, such thing happen :)
16:37justin_smithERROR - increase :queue-size if this happens often
16:37justin_smithjava.util.concurrent.RejectedExecutionException: Task java.util.concurrent.FutureTask@46883bf4 rejected from java.util.concurrent.ThreadPoolExecutor@232dcbe[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 14768]
16:38justin_smitha coworker got this (it's intermittent) - where is the :queue-size this message mentions? The stack trace shows we are inside a ThreadPoolExecutor
16:39justin_smithwhich in turn was invoked by http-kit (but I don't know if this is an http-kit :queue-size option or what
16:41justin_smithOK, I found the error message in http-kit, so clearly she was overloading http-kit's ring-handler somehow https://github.com/http-kit/http-kit/blob/0e53d3d883901a229c189c263b2a4f6c07e66a0e/src/java/org/httpkit/server/RingHandler.java#L165
16:44justin_smithoh wait, it was here... https://github.com/http-kit/http-kit/blob/0e53d3d883901a229c189c263b2a4f6c07e66a0e/src/java/org/httpkit/server/RingHandler.java#L244 - now I see it was an error on close... never mind.
16:52gfredericksdnolen: do you know what this line does? https://github.com/clojure/test.check/blob/f3dc5aed2141205dc320255bbc9e839653019279/resources/run_tests_dev.html#L5
16:52gfredericksin my browser the file isn't found but everything runs fine anyhow
16:53gfredericksso the error in the console is a little annoying and I'm wondering if I can delete the line
17:08{blake}OK, I feel foolish I don't know this, but I want to create a lazy-sequence that reference a function, and terminates when the function returns nil. Like, if reading a text file, it'd be read(1) and reads the first line, read(2) returns the second, etc., and then read(n) returns nil if there is no line n.
17:08tom``how does compojure behave when being sent a request with the host containing a subdomain? It seems I can work with example.com/hello just fine but subdomain.example.com/hello never responds. (GET "/hello" request (println "hi")) works without the subdomain, but with a subdomain, I just get nothing back. Am I supposed to match (GET "/subdomain/hello" ...)?
17:08tom``Or is there something else going on?
17:10tbaldridge{blake}: https://github.com/clojure/clojure/blob/clojure-1.7.0/src/clj/clojure/core.clj#L2751
17:10hiredmantom``: what webserver do you have sitting in front of this?
17:10tbaldridgethat's a rather simple example ^^
17:10hiredmanmy guess is you don't have it setup to respond correctly on the subdomain
17:10tom``none
17:11hiredmantom``: I would double check all the configuration before you get to compojure, because while compojure can do routing stuff based on domains, you have to explicitly make it, without that all the routing is just based on the path part of the request
17:11tom``ok
17:12hiredmancheck the dns, check the webserver, etc
17:12tom``is it typical practice to put like nginx and port forward to the compojure application?
17:13{blake}tbaldridge: That looks good. Thanks!
17:13{blake}(inc tbaldridge)
17:13lazybot⇒ 22
17:14hiredmanI suspect it is, but I dunno, I think in general that is an easy solution to a few issues
17:15hiredmane.g. ops can have an easier time terminating ssl at nginx
18:23TimMcThere's no good way to ask compojure for a listing of its routes, yeah?
18:26justin_smith,(defn stupid-power-of-two [n] (/ (apply / (take (+ 2 n) (repeat 2)))))
18:26clojurebot#'sandbox/stupid-power-of-two
18:26justin_smith,(map stupid-power-of-two (range))
18:26clojurebot(1 2N 4N 8N 16N ...)
18:32justin_smith,(defn uncanny-power-of-two [n] (reduce (rand-nth [/ *]) (repeat n 2)))
18:32clojurebot#'sandbox/uncanny-power-of-two
18:32justin_smith,(map uncanny-power-of-two (range))
18:32clojurebot(1 2 4 8 16 ...)
18:33justin_smithwait that's totally wrong
18:34justin_smithit works only for even numbers
18:34justin_smithnope, not even then
18:35perplexajustin_smith: i dont'get it
18:35justin_smithperplexa: the uncanny one is totally broken and a sign I should go home for the weekend
18:35justin_smiththe stupid one works
18:35perplexaor.. did it just pick the 2nd item of the vector 5 times in a row? :|
18:36perplexa(rand-nth [/ *]) shouldn't that be / or *
18:36perplexaor is it only evaluated once and then passed into reduce, instead of every time?
18:36justin_smithit's random on every call
18:36justin_smithand it doesn't do what I wanted
18:38justin_smiththe "stupid" one uses the behavior of / when used with a single arg to invert a series of halvings to do doubling
18:38justin_smiththe other one doesn't do that so it doesn't work
18:57justin_smithperplexa: fixed it
18:57justin_smith,(defn uncanny-power-of-two [n] (let [o (rand-nth [* /])] (o (reduce o (repeat (+ n (Math/floor (o (o (o 1/2))))) 2)))))
18:57clojurebot#'sandbox/uncanny-power-of-two
18:57justin_smith,(map uncanny-power-of-two (range))
18:57clojurebot(1 2N 4 8N 16 ...)
18:57justin_smithyou can tell when / got picked from the N
18:58justin_smith,(map uncanny-power-of-two (range))
18:58clojurebot(1 2N 4 8N 16 ...)
18:58justin_smith,(map uncanny-power-of-two (range))
18:58clojurebot(1 2N 4 8 16 ...)
19:19perplexajustin_smith: gz :>
20:17weebzIs there a way to call ~@ outside of a quoted expression?
20:18weebzSo I can do (somefunc [1 2 3]) and have it transformed to (somefunc 1 2 3), without doing (eval `(somefunc ~@[1 2 3]))
20:53lodin_,(doc apply)
20:53clojurebot"([f args] [f x args] [f x y args] [f x y z args] [f a b c d ...]); Applies fn f to the argument list formed by prepending intervening arguments to args."
20:54lodin_weebz: ^^^
20:55tmtwdcan anyone help me ? CompilerException java.lang.Exception: Found lib name 'honeysql.core' containing period with prefix 'quote'. lib names inside prefix lists must not contain periods, compiling:(yesql_examples/honey.clj:1:1)
20:55tmtwdhttp://pastebin.com/mp9x0vSb
21:13justin_smithtmtwd: you have a ' in your ns declaration, and it should not be there
21:14tmtwdjustin_smith, you mean when I am using it in the repl?
21:15justin_smithtmtwd: no, that error happens when you have (ns foo.bar (:require 'honeysql.core))
21:15justin_smithit happens because of the '
21:15tmtwdbut I'm not doing that
21:15tmtwdin the ns
21:15justin_smithOK, somewhere require call has an extra '
21:16justin_smiththe usual case is in ns
21:16tmtwdthere are no ' at all in the file
21:16justin_smithcan you share a paste of the ns form?
21:17tmtwdhttp://pastebin.com/mp9x0vSb
21:17tmtwdsorry the error is now CompilerException java.io.FileNotFoundException: Could not locate honeysql/core__init.class or honeysql/core.clj on classpath: , compiling:(yesql_examples/honey.clj:1:1)
21:18justin_smithOK, so you fixed the first error already?
21:20justin_smithbecause if you simply have a different error when calling use a second time, that's because clojure will no-op when asked to load an ns a second time via use or require
21:21justin_smitheven if there was an error the first time, it simply doesn't try the second time
21:22tmtwdoh
21:22tmtwdok
21:23tmtwdI'll just switch to yesql and get help with someone irl
21:26smandyhi all - how do I get leiningen to use my local ~/.m2 repo as a source of artifacts. :local-repo "local-m2" doesn't seem to work? ( Referenced here https://github.com/technomancy/leiningen/blob/stable/sample.project.clj)
21:34justin_smithsmandy: leiningen should always look at ~/.m2/ before looking for an artifact remotely. Are you sure you haven't customized your repo location, and you are looking for the right version id?
21:35justin_smithif you specify "local-m2" it will literally look for a folder called local-m2 which would have your local cache
21:48celwellIs there a better pattern than "(doall (map " for performing side-effects on each item in a sequence?
21:48justin_smithcelwell: do you want the result?
21:49celwellno
21:49justin_smithif you are using 1.7, run!
21:49celwellJust something like sending an sms to every number in seq
21:49justin_smith(doc run!)
21:49clojurebot"([proc coll]); Runs the supplied procedure (via reduce), for purposes of side effects, on successive items in the collection. Returns nil"
21:49justin_smithit's just like map but for side effects
21:50justin_smithif not using 1.7, there's doseq
21:50celwellThat looks good. Is there any breaking changes in 1.7 from 1.6 (should I just upgrade now?)?
21:51justin_smithvery few if any
21:51justin_smithit's a great upgrade
21:51celwellOk, thanks.
21:52smandyjustin_smith: thanks for reply. Sorry was away :-)
22:04lodin_celwell: I have projects that define a function "update" which now clashes with clojure.core, so to avoid warnings I needed to exclude clojure.core/update when upgrading. Not breaking, but annoying.
22:07lodin_It would be good if you should specify clojure.core version in the ns form. If present it would import based on the the :added key in the metadata.
22:08lodin_If specified version is larger than the currently used clojure version, then you could get a sane error message.
23:14tolstoyIs there a clojure.core function kinda like repeatedly, but each "repeat" of the function call takes the value of the previous function call?
23:15tolstoymap-indexed (is what I was sorta wanting)
23:19justin_smithtolstoy: iterate
23:19justin_smith,(iterate inc 0)
23:19clojurebot(0 1 2 3 4 ...)
23:19tolstoyAh! ;)
23:20tolstoyI knew there was something like that. ;)
23:20justin_smithtolstoy: also, if you want to learn lazy-seqs, iterate is an easy one to do from scratch using the lazy-seq function
23:20tolstoyMust be time for my annual read clojure.core docs top to bottom.
23:20justin_smithtolstoy: be sure to also check out http://conj.io
23:23tolstoyLately I've been revisiting things after years away. Vague memory issues. ;)
23:23tolstoyFor instance, binary twiddling. Zach Tellman's gloss, binary-streams, etc, etc, are a great help.
23:25TEttingerZach Tellman's existence is a great help
23:26tolstoyAleph is quite nice.
23:26TEttingerI'm very glad primitive-math made it into clojure itself, in a way
23:28TEttingerIIRC in a game I was writing in clojure, rewriting boxed arithmetic to prefer primitive arithmetic wherever possible (which was made easy to spot when it was needed by primitive-math) allowed a rather significant speedup
23:29blkcati've been working with a lot of his stuff lately. gloss is a lifesaver
23:29TEttinger(I fixed a lot of stuff at the same time due to revisiting a lot of stuff, so I can't be sure that was all of it, but there were 400+ boxing math ops in a rather modestly sized program)
23:30TEttingerwas someone here working on a native clojure? clojure to C or something like it? I seem to recall justin_smith being involved maybe?
23:30justin_smitherr
23:31justin_smiththere's pixie, if that's what you were thinking of
23:31TEttingerno, I'm aware of that, there was an attempt at least of a C Clojure
23:31TEttinger... hm
23:34tolstoyI think tbaldridge had something going along those lines before pixie.
23:34TEttingerI'm just kinda wondering about language stuff. I really like LuaJIT's approach to a lot of things, not sure if I personally could do half as well as Pixie even using an existing state-of-the-art JIT
23:41TEttingerso I'm just sorta pondering. I really like clojure, the seq abstraction is great, the API is really, truly well-designed, but certain things I'm not as happy about.
23:42TEttingerit's too difficult to reason about performance. There are limitations of the JVM, like the heaviness of objects and the unusual behavior differences between primitives and objects
23:42TEttinger2d, 3d and higher-dimensionality arrays remain extremely hard to deal with
23:46justin_smithTEttinger: what do you think of core.matrix?
23:49justin_smith,(defn whatami [n] (let [o (rand-nth [* /])] (o (reduce o (repeat (+ n (Math/floor (o (o (o 1/2))))) 2)))))
23:49clojurebot#'sandbox/whatami
23:49justin_smith,(map whatami (range))
23:49clojurebot(1 2 4N 8N 16N ...)
23:50justin_smithTEttinger: how do you like that headscratcher?
23:55TEttingerhm?
23:55justin_smithTEttinger: the whatami function I defined above
23:55TEttingerhmmmmm
23:55justin_smithfun bit of obfuscation, I thought
23:55TEttinger,(re-find #"\ufeff" ",(defn whatami [n] (let [o (rand-nth [* /])] (o (reduce o (repeat (+ n (Math/floor (o (o (o 1/2))))) 2)))))")
23:55clojurebotnil
23:56TEttinger,(re-find #"\uffef" ",(defn whatami [n] (let [o (rand-nth [* /])] (o (reduce o (repeat (+ n (Math/floor (o (o (o 1/2))))) 2)))))")
23:56clojurebotnil
23:56TEttingerhm
23:56TEttingerjust checkin'
23:56justin_smithhahaha
23:56justin_smithno no, each part really does what it looks like
23:56justin_smiththe weird part is that it works
23:56justin_smith,(map whatami [8 16 32 64])
23:56clojurebot#<ArithmeticException java.lang.ArithmeticException: integer overflow>
23:56justin_smithargh
23:57justin_smithmostly works!
23:57justin_smith,(map whatami [8 16 32 63])
23:57clojurebot#<ArithmeticException java.lang.ArithmeticException: integer overflow>
23:57justin_smith:P
23:57justin_smith,(defn whatami [n] (let [o (rand-nth [*' /'])] (o (reduce o (repeat (+ n (Math/floor (o (o (o 1/2))))) 2)))))
23:57clojurebot#<RuntimeException java.lang.RuntimeException: Invalid token: /'>
23:57TEttinger,(* 1/2)
23:57clojurebot1/2
23:57TEttinger,(/ 1/2)
23:57clojurebot2N
23:57justin_smith,(defn whatami [n] (let [o (rand-nth [*' /])] (o (reduce o (repeat (+ n (Math/floor (o (o (o 1/2))))) 2)))))
23:57clojurebot#'sandbox/whatami
23:57justin_smith,(map whatami [8 16 32 63])
23:57clojurebot(256N 65536N 4294967296 9223372036854775808N)
23:58TEttinger,(* (* 1/2))
23:58clojurebot1/2
23:58justin_smith,(map whatami (range 8 32))
23:58TEttinger,(/ (/ 1/2))
23:58clojurebot(256N 512N 1024N 2048 4096N ...)
23:58clojurebot1/2
23:58TEttingerahhhh