#clojure logs

2015-05-22

00:18kennyjwilli_Hey, can anyone help me with a problem that I am having with Datomic? I'm newer to Datomic and Clojure. Thanks! :)
00:36Rayneskennyjwilli_: I know nothing about datomic and thus am useless, but a general tip for IRC channels is to just ask the question you have (even if it's long) and see if anyone bites. If you just ask for help, you're asking folks to commit to helping solve a problem that could potentially be quite time consuming.
00:47kennyjwilli_Got it. Thanks Raynes :)
01:29justin_smithkennyjwilli_: you still haven't asked your question
01:39kennyjwilli_I actually got it answered in #datomic. Thanks though :)
02:25[mad]hi
02:26escherizehi.
02:26[mad]sup escherize :)
02:27escherizehi [mad]
02:27escherizeyour name is hard to type because i have smartparens on. :()
02:27[mad]:D
02:32[mad]is anyone using coreos with clojure? need a guide or something to start from 0
02:46wasamasawait, wasn't that the deployment platform?
02:46wasamasahow is that related to programming clojure generally
02:51heurist`[mad]: if you can get a coreos java container (and there must be plenty of those) then clojure should be simple to add to it. clojure is just a jar file.
02:53[mad]wasamasa yep
02:53[mad]heurist i'm looking some info from digitalocean about it
02:54[mad]searching for examples on github, but nothing for now
02:56heurist[mad]: google has links to deploying java on digital ocean, and also coreos specific ones. get java working then worry about clojure. you can make an uberjar out of your clojure project and java -jar my-uber.jar it on the container once it works. I can not give more specifics since I have not done java on coreos, but it should not be complicated. good luck.
02:57[mad]thanks dude :)
03:28stanford_droneDoes anyone know C/C++, Computer Vision/Image Processing, Machine Learning, AI, linux systems programming, or electronics? I'm looking for a programmer to join my Startup. We're going to China (manufacturing is there) from July to November. We're a team of 4. We're building a flying computer. A drone that you can play games with and install apps on.
03:31kaiyinstanford_drone: do you use clojure?
03:32kaiyinalright. anyone care to have a look at this? http://stackoverflow.com/questions/30390817/core-typed-not-reporting-type-error-in-repl
03:34[mad]stanford_drone cool, what stack r u using on that project? :D
03:35stanford_drone[mad], linux computer with CUDA gpus, flying on a drone. C++/OpenCV
03:35engblom[mad]: Unless you really type this from a phone, please use as good English as you are able to use. Especially in programming channels, stuff like "r u" feels really disturbing.
03:35stanford_droneare you interested in joining?
03:37[mad]stanford_drone sounds interesting, no sorry, noob here :D
03:37[mad]engblom okay
03:38dstocktonr u for real engblom ?
04:30kaiyincould anyone help with this? http://stackoverflow.com/questions/30391847/is-order-guaranteed-when-multiple-processes-are-waiting-to-put-data-in-the-same
04:32WickedShellare there any seesaw/font whizes around? I'm finding registering a TTF font to be a problem
04:33[mad]re
04:34[mad]heurist i find that http://palletops.com/blog/lein-uberimage/ :D
05:11entityis def and defn slower than let? I'm currently using those two to define local functions and variables and I'm wondering, if it's slowing things down
05:11entityI didn't know that def and defn is for global bindings, so I'll rewrite it anyway
05:11entityI'm just wondering what's the impact on performance, because I'm getting some really slow function evaluations
05:18amalloydef creates a Var, registers it in your namespace, sets its value, gives it metadata...and let is free, costing you maybe one bytecode instruction depending on JIT
05:18entityokay, so calling def 10k times per second = bad
05:19amalloyentity: don't call def at runtime, at all. there are exceptions, but they are not common
05:19entityand I was wondering why the REPL was seeing all my local variables, heh
05:19amalloynot just for performance reasons, but because that's not what defs are "for"
05:19entitythanks a lot :)
06:23ionthas_Hei! I have a vector [1 1 0 0] and I want to have the inverse [0 0 1 1]. 0 and 1 are not treated as true,false so I cannot apply the function (map not [1 1 0 0]). Is there any way to do that? Thanks!
06:26katratxoionthas_: reverse ? http://conj.io/store/v1/org.clojure/clojure/1.6.0/clj/clojure.core/reverse/
06:26AimHereionthas_, what do you mean by inverse, specifically?
06:26oddcully,(map (partial bit-xor 1) [1 1 0 0])
06:27clojurebot(0 0 1 1)
06:27AimHere,(mapv #(- 1 %) [1 1 0 0])
06:27clojurebot[0 0 1 1]
06:27ionthas_That was exactly what I needed. Tanks.
09:00entityis there no parallel sort-by in the standard library?
09:35fourqDoes anyone have the vim rainbow parens plugin working on load? I'd like to see what you set in your vimrc to avoid having to toggle it on each src file.
09:35fourqA bit off topic, but then again...parens
09:37entitythe readme says to put let g:rainbow_active = 1
09:38entityI'm going to try it out now :P
09:38entity(https://github.com/luochen1990/rainbow)
09:38fourqwhere do you....oh
09:38fourqdif repo
09:38fourqI was looking at https://github.com/kien/rainbow_parentheses.vim
09:39fourqbut i'll try the one you found
09:40entitydo you use pathigen by chance? Any idea how to install the plugin properly?
09:40fourqyeah
09:40fourqI go to my .vim root first
09:40fourqthen
09:40fourqgit submodule add <git url> bundles/<name of bundle>
09:40fourqbut that's with submod
09:41fourqyou can also just drop it in bundles
09:42entitythanks
09:43entityseems to work nicely
09:43fourqI can't wait to change the colors on it =)
09:44entityyay for fruit salad code :)
09:44fourqhehe
09:53escheriz`nice
09:55entityI'm wondering if someone would be willing to look at a function I wrote and tell me if there are some obvious performance issues? It's running slower than I'd like
09:55entityhere it is: https://github.com/osense/clojure-robby/blob/master/src/clojure_robby/core.clj#L79
09:56entitybasically, make-step is iterated a hundred times and each iteration computes the newly modified map, position and score
10:00entitymaybe it's because current-map is copied between each step, but I'd have thought that this would get optimized away
10:01dnolenentity: is `dna` always a vector? otherwise you have a linear cost to calling `nth` on it
10:01entityyes, dna is always a vector
10:02entitysame for the map
10:02dnolenentity: so it sounds like simulate is an inner loop for you. It doesn't not appear this code was written for perf but for clarity. It too much code for me to give you a better suggestion than - use a profile.
10:02dnolens/profile/profiler
10:03entityyeah, I did write it for clarity, especially as it's the first thing in CLojure for me :)
10:03entitythanks for the suggestion, I'll also try to integrate pmap somewhere I guess
10:04dnolenentity: then I honestly wouldn't worry about perf, unless it's a blocker for your learning process.
10:05dnolenentity: it's possible to write very, very fast Clojure code but that's a fairly big topic on it's own.
10:07jtmarmondoes anyone know of an example web app using stuartsierra's component? trying to figure out how to structure a compojure API using it
10:11gfredericksjtmarmon: not sure what your exact problem is, but I've taken two approaches to compojure + component
10:11gfredericksone is you make a function for the routes
10:11gfredericks(defn make-the-routes [server-component] (routes ...))
10:11gfredericks^ which lets you use the server lexically
10:11gfredericksthe other is to have middleware that attaches relevant components to the request
10:12gfredericks(defn wrap-components [some-component handler] (fn [req] (-> req (assoc ::component some-component) (handler))))
10:12jtmarmonah makes sense. the former definitely looks cleaner but seems like it would be a pain in the ass for project structure
10:12gfredericksbecause all the routes have to go in one place?
10:13jtmarmonya
10:14gfredericksyeah, that's why the second is more flexible; but you could also compose several such route functions
10:14gfredericks(defn make-the-routes [server-component] (routes (make-these-routes server-component) (make-those-routes server-component)))
10:15jtmarmonright, yeah. I'll consider which one makes more sense for us. thanks for the advice!
10:18gfredericksnp
10:22wmealingis this the wrong place to ask about clojurescript questions ?
10:23bensuwmealing, #clojurescript
10:23wmealingthanks bensu.
10:52TimMcjustin_smith: From a quick look, lein-diff seems more complicated than I thought. Dependencies get resolved in the context of a project; a project is loaded from file; the file *might* need to be in the context of the entire repo in case of lurking middleware.
10:54TimMcso it might have to be orchestrated by a shell script, I'm not sure
10:59TimMcMaybe you have a shell script that clones the project to two locations, checks out the appropriate commit in each, then calls lein diff with paths to the project.clj in each project. That lein diff then invokes lein diff from the working directory of each project to extract data, receives the results, and outputs the diff results.
11:05justin_smithTimMc: well, can't you compare the data structures returned from lein/load-project ?
11:06justin_smithload, bind, checkout branch, load, compare
11:07TimMcmaaaaaybe
11:07TimMcMucking around with the working directory while I have code running in it sounds pretty fragile.
11:08justin_smithin fact, instead of checkout out branches, it should suffice to checkout the project.clj from each branch into temp files, then load each of those temp files
11:08TimMcI'm still unclear whether it's enough to just have project.clj.
11:08TimMcI didn't have time to go into depth on that.
11:08justin_smithyou would want project.clj plus all instances you can find of profiles.clj
11:08TimMcI might just say "to heck with local middleware" but I'd like to have a more comprehensive solution.
11:09justin_smithiirc
11:09TimMcWait, how many profiles.clj can there be?
11:09justin_smithTimMc: it's one of those classpath based things
11:09justin_smithso you can have ~/.lein/profiles.clj and project/profiles.clj
11:09TimMcyikes, didn't know that
11:09justin_smithbut that's enough to generalize to "find all of them" for the corner cases
11:10TimMcI think I'd use the :production profile by default, for that matter.
11:10justin_smithTimMc: but iirc leiningen.core/load-project (or whatever the function / namespace combo) should be doing all that for you, and returning your final effective lein config data structure
11:11justin_smiththough the comparing branches thing could be a mess...
11:12justin_smithTimMc: git-cat-file might help you here (it can copy a file from a given git state I think)
11:14justin_smithoh, no, git show
11:14justin_smithgit show TREEISH:project.clj > tmp1; git show TREISH2:project.clj > temp2
11:14justin_smithetc.
11:15justin_smiththe lein function foading a project can take an explicit file arg
11:15justin_smithfoading ~= for loading
11:16TimMcThe shell script idea would allow me to support other VCSs, which would be nice.
11:19TimMcbut I'd settle for an option pointing to a script that can be called with args "setup", "switch-first", "switch-second", "cleanup" so arbitrary commands could be used.
11:19TimMcThat way lein-diff could drive the show.
11:43ToBeReplacedany success/failure with an ssh lib from clojure? needs to support kerberos auth from rsa key
11:52winkToBeReplaced: only ssh thingy I can think of is stuff from pallet
11:52winkbut no clue about your specifics
11:57ToBeReplacedit uses clj-ssh which is an opinionated wrapper on jsch... jsch seems to be the known evil and most likely to work for complex cases, so it looks like i'll go with that
14:47clojerIs there a better way to test if something is map than (if (= (type x) clojure.lang.PersistentArrayMap) .... ?
14:48justin_smith,(map? {})
14:48clojurebottrue
14:48clojerjustin_smith: I searched for that in clojuredocs but couldn't find it. Great.
14:49justin_smithclojer: because arraymaps are only for small maps, when they get more keys they become persistenthashmaps
14:49justin_smithand also it's more clear too :)
14:54puredangeryou really should never refer to concrete types inside Clojure as a general rule
14:54puredangerif you must, use IPersistentMap etc
14:55justin_smiththe big exception to that would be type hints maybe? at least primitive type hints
14:55justin_smithotherwise 100% agreed, excellent point
14:55puredangereven then
14:55puredangerthere's no reason to typehint the concrete class over the interface
14:56justin_smithwait, for primitives?
14:56chouserprimitive types look like hints but are really more than that
14:56puredangernot talking about primitives, that's different
14:56justin_smithOK, got it
14:56justin_smithchouser: because of the difference of implementation, or an explicitly different thing?
14:57chouserHm, not sure how to differentiate between those options. :-)
14:58justin_smithwelcome to the blurry world of clojure I guess
14:58justin_smithhaha
14:58chouserboth the meaning of the interface and the meaning at the bytecode level are different
14:59chousera type hint is a "hint," it allows the compiler to generate bytecode that does less work at runtime
14:59justin_smithand with a primitive...
14:59bensupuredanger, 1.7.0-RC1 passed all the tests without issues
14:59puredangeryay
15:00chousera primitive typed fn parameter can only support that exact kind of argument. It declares a key part of the interface to that fn.
15:00justin_smithoh yeah, I vaguely recall some very weird stack traces this can lead to
15:01chouser(fn f [^Foo x]) means the body of f will be treating x as a Foo in some cases, but it isn't explicitly checked at the fn call boundary. It's a hint to the compiler inside the body of f.
15:02andyfThis may be a question best for the clojure-dev group, but is there an at-most-2-sentence description of what in Clojure's Java code guaranteed that the older transient implementation safely published changes it made to other threads? (I'm also curious about the answer for the newer one, but realized I probably didn't understand why this worked before, either)
15:02chouser(fn g [^long x]) means g only takes a primitive long, and passing anything incompatible *will* break at the call boundary.
15:03justin_smithchouser: aha, that's really helpful. One of these days I will do some more work on hint-hint (a repo with unit tests that demonstrate what works / breaks / does nothing in the world of hinting)
15:04justin_smithand I'll make a note to demonstrate how primitive hinting can break
15:05chouserjustin_smith: That sounds very interesting. Visibility into the compiler's understanding of type hints and primitives has always been a bit poor.
15:05chouserThere is that nice disassembler that I always forget to try.
15:06justin_smithchouser: the trick so far is eval inside with-out-str with warn-on-reflection turned on, and unit tests about the messages given. a more advanced iteration might make assertions about the disassembled output?
15:08puredangerno.disassemble ?
15:08puredangeryou can use ASM to make assertions about the bytecode, but prob no picnic
15:08chouserpuredanger: that's the one
15:09justin_smithpuredanger: yeah, that's another options - but a regex test on the output of no.disassemble/disassemble seems straightforward enough
15:11justin_smithor even a tree walk on the right part of the disassemble-data output actually... gee this is a cool lib!
15:11justin_smith(inc gtrak)
15:11lazybot⇒ 14
15:19gfredericks(inc gtrak)
15:19lazybot⇒ 15
16:01arohnerif I have an uberjar created by lein, is there a way to figure out which version of a dependency got used?
16:10puredangeryeah, the version info is in the pom.properties under META-INF
16:10puredangerthere will be a file in uberjar like META-INF/maven/org.clojure/core.async/pom.properties
16:17arohnerpuredanger: thanks
16:18arohnerhrm, I have tools.nrepl specified as 0.2.10, but lein is resolving to 0.2.6. I also have tools.nrepl in :exclusions, to try to prevent any dep from specifying it. Not sure where to look now
16:23arohnerlooks like leiningen injects it?
16:24gfredericksarohner: um
16:24gfredericksarohner: is this uh
16:24gfredericksarohner: so
16:24gfredericksare you running `lein repl` outside a project?
16:24arohnergfredericks: nope
16:25gfredericksokay then I don't know; lein is supposed to respect an [org.clojure/tools.nrepl "..."] in your deps list
16:25gfredericksit only works for me when running with an existing project though
16:25puredangerlein deps :tree ?
16:26arohnerpuredanger: it's hard to read, because I have so many exclusions. but tree says it's using 0.2.6
16:28puredanger<that shrug emoticon thing>
16:28puredangerset table on fire, then flip?
16:28arohnerI'm not sure this is a smoking gun yet, but it is suspicious: https://github.com/technomancy/leiningen/blob/2.5.1/leiningen-core/src/leiningen/core/project.clj#L483
16:29puredangerthere is some way to get rid of hte default profile, cna't remember how
16:30Bronsa(╯°□°)╯︵ ┻━┻
16:32bensuarohner, you can usually get what you want out of lein deps :tree with grep!
16:32TEttinger,(def ╯°□° (print "(╯°□°)╯︵ ┻┻")
16:32clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
16:32TEttinger,(def ╯°□° (print "(╯°□°)╯︵ ┻┻"))
16:32clojurebot(╯°□°)╯︵ ┻┻#'sandbox/╯°□°
16:33TEttinger,(def ╯°□° #(print "(╯°□°)╯︵ ┻┻"))
16:33clojurebot#'sandbox/╯°□°
16:33TEttinger,(╯°□°)╯︵ ┻┻
16:33clojurebot(╯°□°)╯︵ ┻┻
16:34arohner:profiles {:base {:dependencies ^:replace []}
16:35arohnerjust strips out the deps that leiningen injects
16:35justin_smithTEttinger: did you intend that to be a defn?
16:35amalloyjustin_smith: the most recent definition is one
16:35TEttingerI didn't want to have square brackets
16:35justin_smithahh
16:37TEttinger,(first (sort-by #(- (count (filter (partial = \) %))) (clojure.string/split "loser, loser, winner, loser, loser, loser" #", ")))
16:37clojurebot"winner"
16:37TEttingerthis is a fun tool for loaded decisions
16:38TEttinger,(first (sort-by #(- (count (filter (partial = \) %))) (clojure.string/split "a, b, c, d, e, f, g, h" #", "))) ; d will win
16:38clojurebot"d"
16:39amalloyTEttinger: there's an nbsp in there somewhere, i guess?
16:39TEttingerBOM
16:39TEttingerplease, amalloy, what am I a filthy peasant?
16:39TEttingerthere's two BOMs
16:40amalloyTEttinger: i think the (partial = \) is not subtle enough. the \ is obviously dangling
16:40TEttingeryes
16:40amalloytry replacing it with #{\ \n \r \t}
16:41amalloyor i guess #{\ \n \r \t} so it looks like \space
16:41TEttingerthere's a definite way to do this... I think by determining what will hash to feff it might work
16:41justin_smith,(int \)
16:41clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
16:41justin_smithoh this tty doesn't do it right
16:41amalloywell i didn't put an actual BOM in, if you were just copying from me
16:42justin_smith,(int \)
16:42clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
16:42TEttinger,(.toHexString (hash :a))
16:42clojurebot#error {\n :cause "No matching field found: toHexString for class java.lang.Integer"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "No matching field found: toHexString for class java.lang.Integer"\n :at [clojure.lang.Reflector getInstanceField "Reflector.java" 271]}]\n :trace\n [[clojure.lang.Reflector getInstanceField "Reflector.java" 271]\n [clojure.lang.Reflector invokeNo...
16:42TEttinger,(Integer/toHexString (hash :a))
16:42clojurebot"816f5f1e"
16:42TEttingerhmmm
16:44TEttinger,(reduce #(if (= (hash %2) 0xfeff) (reduced %2)) (range))
16:45clojureboteval service is offline
16:45TEttingeryep
16:45TEttinger,(reduce #(if (== (short (hash %2)) 0xfeff) (reduced %2)) (range))
16:45clojurebot#error {\n :cause "Value out of range for short: 1392991556"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Value out of range for short: 1392991556"\n :at [clojure.lang.RT shortCast "RT.java" 1116]}]\n :trace\n [[clojure.lang.RT shortCast "RT.java" 1116]\n [sandbox$eval103$fn__104 invoke "NO_SOURCE_FILE" 0]\n [clojure.lang.Iterate reduce "Iterate.java" 64]\n [clojure.core$...
16:50entityhm, when I launch the uberjar (java -jar ...), after finishing it's thing, it hangs for a minute before exiting
16:50entitywhat's going on?
16:51puredanger(shutdown-agents)
16:52puredangerthe agent pool has non-daemon threads in a background pool with a 60s timeout
16:52puredangerso add the shutdown call to kill them
16:52entityyup, that fixed it
16:52entitythanks
16:59andyfentity: And if you have (or are willing to create) an account on JIRA, vote on this ticket: http://dev.clojure.org/jira/browse/CLJ-124
17:00puredangerI think that was the first ticket I ever commented on in Clojure :)
17:04entityandyf: hehe, good to know this is getting some attention
17:04w01fe,(->> (range 10000) (mapcat (fn [_] (java.util.ArrayList. (range 10)))) (reduce (constantly nil)))
17:04clojurebot#error {\n :cause nil\n :via\n [{:type java.lang.StackOverflowError\n :message nil\n :at [clojure.lang.AFunction <init> "AFunction.java" 18]}]\n :trace\n [[clojure.lang.AFunction <init> "AFunction.java" 18]\n [clojure.core$concat$cat__4214$fn__4215 <init> "core.clj" 697]\n [clojure.core$concat$cat__4214 invoke "core.clj" 696]\n [clojure.core$concat$cat__4214$fn__4215 invoke "core.clj" 702]\...
17:06w01fe(seems like a bug in 1.7-RC1?)
17:07puredangerisn't this the classic concat stack problem?
17:07amalloypuredanger: no, it's a different classic problem
17:07amalloylesser known
17:08w01fewell, it ran fine under 1.6 ... i think this is specific to the new internal reducing stuff
17:08amalloyyou get the same thing if you (reduce (constantly nil) (apply concat (take 10000 (cycle [[1] '(1)]))))
17:09amalloyif it ran fine in 1.6 maybe it is a different issue
17:10puredangercould be range changes
17:11puredangerwell I am about to shut down my computer and disconnect from Clojure for a week
17:11puredangerso file a jira :)
17:11amalloypuredanger is so horrified by this issue he's gone into shock
17:11amalloycan't look at a computer for a week
17:11puredangervacation :)
17:11w01fehaha will do :) thanks, have a good break
17:26tvanhensI'm running into a weird issue that i can't solve for the life of me. I am trying to develop a webserver and I have some middleware that converts responses into a buffered input stream (wrap-middleware-format). If I slurp the body of the response and call edn/read-stream on the body I can read it no problem. If I do the same and assoc the resulting body back into the original map I get a FileNotFound exception which makes now
17:26tvanhens sense to me
17:27tvanhensbasically whenever I try to put the result in a map I get a file not found exception
17:27tvanhensif I return the result plain I get what I expect
17:28tvanhens(defn request
17:28tvanhens "Makes a request to a catalyst system."
17:28tvanhens [system method uri & {:keys [params token]}]
17:28tvanhens (let [handler (handler system)
17:28tvanhens {:keys [body
17:28tvanhens status] :as response}
17:28tvanhens (handler
17:28tvanhens {:request-method method
17:28tvanhens :uri uri
17:28tvanhens :params params
17:28tvanhens :headers (-> {"content-type" "application/edn"
17:28tvanhens "accept" "application/edn"}
17:28tvanhensthats fine but if I do:
17:28amalloytvanhens: stop pasting
17:28amalloyif you want to paste a large code snippet, use refheap or gist or something
17:28tvanhenssorry didn't know it would do that
17:28tvanhensgotcha
17:28tvanhensthanks
17:30tvanhenshttps://www.refheap.com/101489 that summarizes the problem. I'm flabbergasted as to what the difference is
17:31tvanhensany help would be greatly appreciated because this is driving me mad feel like I've tried every workaround I can
17:33amalloytvanhens: why are you mucking with the response body at all? typically responses should be a string, not a clojure data structure
17:34tvanhensThis is for a repl util I'm trying to mock requests and get a response back in edn
17:35justin_smithtvanhens: using ring-mock?
17:35tvanhensno I'm just passing in {:uri "" :params {} :headers {}} manually
17:35tvanhensthe input seems to go fine
17:36tvanhensits the reading of the response thats causing trouble
17:38TEttinger,(first (sort-by (fn [_] (rand-int 0xffff)) (clojure.string/split "a, b, c, d, e, f, g, h" #", "))) ; g will win
17:38clojurebot"g"
17:38tvanhensI suppose the crux of it is I'm not using a webserver in local tests because I don't want any port bind errors if the tests fail and the state can't be cleared
17:39tvanhensso I am manually crafting "mock" requests similar to ring mock but having trouble converting the body of the response to edn for testing
17:40amalloytvanhens: convert the body to edn in your test, not in the handler
17:41amalloythe stuff returned by a ring handler should conform to the ring spec
17:42tvanhensgotcha I thought I was though. That funciton linked in the refheap is a util funciton in the test ns
17:42tvanhensI'm not trying to convert anything in the handler
17:43tvanhensI'm trying to convert the response of the request to the handler
17:43amalloytvanhens: okay, so what are you doing with the result of this request function? there is no way for just calling (request whatever) to throw an exception for one of these definitions of request but not the other
17:43amalloyso it has to be a problem in what you are doing with the result
17:45tvanhensjust running it in the repl right now. I've disabled the tests I def one version of the funciton, eval it in the repl and then def the second version eval it in the repl and get an error
17:45tvanhensI've been using clojure for 2 years now and I've never seen anything quite like it. Moving it into the map changes the behavior
17:46tvanhensI've tried wrapping the the (-> body slurp edn/read-string) in a do all and letting the result and then returning it in a map just in case there was some tricky lazyness or some thing but no success
17:48tvanhensactually it gets even stranger
17:48tvanhenshttps://www.refheap.com/101492
17:48tvanhensthose two when evaled with the same args: one returns an error the other is fine
17:49tvanhensit seems like as long as I don't name the key body it works
17:50amalloythe two things you just posted appear identical
17:50justin_smithtvanhens: is there a typo in "works"?
17:50tvanhensoops sory yes there is
17:50tvanhensthe first one should have :body as a key in the return map
17:51tvanhensif :body is a key in the return map it doesnt work
17:51tvanhenshttps://www.refheap.com/101493
17:51tvanhensthats what I'm experiencing
17:52justin_smithI see body in both of those
17:52justin_smithI think they are identical
17:52amalloynot this time, justin_smith
17:52amalloythe last line of each is different
17:52tvanhenshttp://imgur.com/5wR7HCP
17:52justin_smithoh, you mean :body in what comes out
17:52justin_smithOK
17:53tvanhensthats my repl session evaling one and and then the other
17:53tvanhensthe imgur
17:53tvanhensrequest* just wraps request passing in a token
17:53tvanhensdoes no other transformations
17:54justin_smithtvanhens: is the content of the body a string that slurp might think is the uri of a file?
17:55justin_smiththat would be the parsimonous cause of an error like that
17:55justin_smithusually a handler would return a string in the body
17:55justin_smithand slurping it should throw that exception
17:55amalloytvanhens: imgur screenshots are a crime against debugging. please get a full stacktrace via (.printStackTrace *e *out), and then make a textual paste with its contents. ideally the repl session would also include the redefinition of request, so that we don't have to take your word for it that you redefined it in between
17:56tvanhensok I can get you that one sec amalloy. I appreciate your patience I know this might seem like a beginner issue. I've been working with clojure for 2 years and never seen anything like this
17:57tvanhensjustin_smith when I return just (-> body slurp edn/read-string) I get the expected response which isn't a uri
17:57amalloywell, it doesn't seem like a beginner issue. it seems like an issue being caused by some tiny mistake somewhere that is hidden in code you don't think is important to show (eg, request* or something)
17:57tvanhensok I'll get it all out there with repl results on sec
17:58amalloytvanhens: also, try just taking the working value (the one with :notcool), replacing the key with :body, and pasting that into the repl. maybe your repl is broken and somehow misinterpreting maps with a :body keyword
18:02tvanhenshttps://www.refheap.com/101494
18:03amalloytvanhens: ! well of course it behaves differently, request* is calling request twice, and expecting a map with :body in it
18:03tvanhensI missed a line in the copy paste process... after the second deffing of request I run the same (user/request* ...) command as the previous dev
18:05tvanhensI'm still confused... the first time it gets called... its expecting the body to be converted to edn
18:05tvanhensto pull out the token
18:05tvanhensand that works
18:05tvanhensnow it gets called again using that token
18:06tvanhenswhy would the first call affect the second call?
18:06amalloyno it doesn't. try printing body in request* both times, and you'll see it's different. probably nil in one case
18:06tvanhenstrying one sec
18:08tvanhensso the first time it grabs the token fine then it calls request again and I get that file not found exception before it returns and prints
18:10amalloyright, i'm taking issue with "it grabs the token fine". if you change the contract of request, so that sometimes it returns {:body x} and other times it returns just x, without making a corresponding change to request*, then request* will not find the information it was looking for
18:11amalloyat some point this miscommunication causes body to be a string instead of an inputstream, and as justin_smith said if you slurp a string it tries to open a file or whatever
18:11amalloy,(slurp "abcde")
18:11clojurebot#error {\n :cause "denied"\n :via\n [{:type java.lang.SecurityException\n :message "denied"\n :at [clojurebot.sandbox$enable_security_manager$fn__887 invoke "sandbox.clj" 69]}]\n :trace\n [[clojurebot.sandbox$enable_security_manager$fn__887 invoke "sandbox.clj" 69]\n [clojurebot.sandbox.proxy$java.lang.SecurityManager$Door$f500ea40 checkRead nil -1]\n [java.io.FileInputStream <init> "FileInp...
18:16tvanhensgotcha thanks I think I've figred it out based on that... looks like I have a middleware in front of format params that was getting triggered and that was returning pure edn and not getting converted into the stream
18:17tvanhensthank you thank you thank you that was driving me mad. I appologize for pasting in the channel. I don't frequent IRC much
18:18amalloyit's fine. everybody is new once
18:30oddcully(inc justin_smith)
18:30lazybot⇒ 255
18:30oddcully(inc amalloy)
18:30lazybot⇒ 274
19:14kaiyincould anyone help me with this macro? https://gist.github.com/kindlychung/2a1f5bc141ae9fb4a8e4
19:19amalloy(pprint expr#)
20:07icedp(identity icedp)
20:07lazyboticedp has karma 0.
20:10icedp(inc 0)
20:10lazybot⇒ 4
20:10icedp(inc 1)
20:10lazybot⇒ 10
20:10icedpem what?
20:11adereth(inc 0)
20:11lazybot⇒ 5
20:11icedp(inc 0)
20:11lazybot⇒ 6
20:11icedpah..
20:11icedp(source inc)
20:17WickedShellI'm having some problems with lein and rescources (particularly loadign things from sub directories). Anyone have a link to a good tutorial on resource management within lein?
20:20andyfWickedShell: I don't have a link to a tutorial, but I have successfully loaded resources in Clojure programs before, and may be able to help.
20:21WickedShellandyf, basically I can load anything from the root resources folder succesfully, but if I try to load an asset from a subfolder within my resources directrory, the file isn't found
20:21WickedShellThat and apparently I'm supposed to be loading it differently to handle being built into a jar, although my uberjar appears to be working at the moment
20:21andyfI am looking through the part of Eastwood that successfully does this, to remind myself what I did, since it has been a few months.
20:22andyfDid you try (clojure.java.io/resource "path/within/resource/dir/filename") to get .. whatever that returns?
20:23andyfI'll check what it returns, but it is probably a Java File or URL
20:24andyfIt returns something that you can call clojure.java.io/reader on to return a Java Reader
20:29WickedShellis (clojure.java.io/resource ) the appropriate way to load content for the jar as well?
20:29WickedShellI wonder if.... I bet seesaw has been protecting me from myself till now... (you pass it the name of say the image to load, and I've been simply passing it the name of the file in the resource directory)
20:31WickedShellwell thats somewhat working (clojure.java.io/resource) does find it, but I explicitly need a file object
20:31amalloyWickedShell: you can't get a file object for something in an uberjar, because they aren't files that exist on the filesystem
20:33WickedShellhm theres a version that takes an input stream, but it didn't match the resource
20:33WickedShellconverting the resource to io/file works, although it remains to be seen if it works in the jar
20:34amalloyWickedShell: you can get an input stream from a resource easily enough
20:34amalloyi think it's just c.j.io/input-stream
20:34WickedShellprobably :P
20:35WickedShellyeah looks like it is
20:35WickedShellalso possibly a stupid question, when building a uberjar I get a warning about reflection in clojure/core/memoize.clj is that expected or did I cause it?
20:37amalloydon't worry about it
20:39WickedShellkk, thanks for the assistance!
20:43WickedShellactually still having a problem with that, I dropped in (io/input-stream (io/resource "foo.bar")) which workc currectly in the repl/lein run but creates a java exception in the uberjar
20:44WickedShellwell actually its (io/input-stream (io/resource "foo/bar.txt"))
20:44amalloyi don't know why foo.bar ever would have worked there, but i'm glad you got it sorted out
20:45WickedShellthats not what I should have done? uh oh... :P
20:53WickedShellAhh I see the problem was I had windows \\ in the path (which was from before when I was providing an absolute path, the nice stanard *nix method of / in the path works beautifully
20:56andyfWickedShell: Yeah, I am pretty sure that Java resources should use / as the path separator regardless of the platform. That isn't universally true for all Java APIs, but I think it is for resource names.
20:56andyfSorry I went away there. Glad you found other help.
21:18justin_smithyeah, windows can handler /, but other platforms can't handler \\
21:18justin_smith*handle
21:18justin_smithcan't tell I've been writing backend web code all day
21:20WickedShellI hate the \ that windows uses... makes for the messiest set of \\ everywhere (also when using compiled regex's that can get a little crazy)
21:20WickedShellanyone here familiar with clj-serial (or java realcomm)
21:21WickedSheller not realcomm, purejavacomm
23:32WickedShelldoes clojure gurantee lazy evaluation? ie (if (and false (.bar nil)) (println "shouldneverrun") (println "lazyEval")) is that guranteed to always print lazyEval?
23:33justin_smithWickedShell: that's not laziness
23:33justin_smithbut yes, (.bar nil) won't run, and (println "shouldneverrun") won't either
23:33WickedShelljustin_smith, that's what I'd call it from C I guess (although usually thats applied to (true || expensiveFoo())
23:34justin_smithWickedShell: in clojure laziness is a specific behavior of the datatype LazySeq
23:34justin_smithwe would call the and / if / or behaviors short-circuiting
23:34WickedShelljustin_smith, thats it! thanks my bad
23:34WickedShellim tired
23:35WickedShellbut you are correct
23:35justin_smithnp, just making sure we're on the same page with the terminology
23:49WickedShellIf I require/use a file in one file and then require/use it in the other file does it get executed twice or simply share the namespace?
23:50justin_smithunless you specify :reload the top level does not get executed again
23:51justin_smithbut you should always write your code so that the result wouldn't be different whether the top level ran again or not
23:51justin_smithby having no top level side effects (nothing stateful in a def, no top level code that isn't in a def or defn)
23:52WickedShellhm.... only way I can see how to do that in this case is to forward declare the gui elements I need to access, which seems... bad as well?
23:53justin_smithWickedShell: there are various ways this can be handled. Including local bindings inside a defn instead of top level def
23:53WickedShellI'm having trouble adjusting to this aspect I think, I keep thinking interms of header files/pragma's
23:53WickedShelljustin_smith, do you have an example of that?
23:53justin_smiththe most reliable way to handle this stuff is stuartsierra's component library
23:54justin_smithwhich has many good examples, including in the lib's readme
23:59WickedShelljustin_smith, will read through that, thanks