#clojure logs

2015-03-19

00:00devni didn't find it, just wanted to share the knowledge
00:15amalloydevn: what is the bug?
01:04justin_smithamalloy: ##(= (partition-all 9/4 (range 10)) (partition-all (long 9/4) (range 10)))
01:04lazybot⇒ false
01:04amalloywell yeah. (not= 9/4 (long 9/4))
01:04amalloyif you pass different arguments to a function, and get different results back, that is not evidence of a bug
01:05justin_smithmy interpretation of that is that partition treats a rational different than long would
01:05amalloyIMO the bug is that it doesn't crash when you pass 9/4
01:05amalloyif there's any bug at all
01:05justin_smithheh, fair enough
04:27Glenjamin,(long 9/4)
04:27clojurebot2
04:31code-shoilyHello guys
04:35code-shoilyhaving an autoload issue with Luminus with +http-kit
04:36code-shoilyWhenever I add a new route, it doesn't work unless I reload the server
04:39gyimthe problem is probably that you do something like this: (compojure.handler/site myroutes)
04:39gyiminstead you should write (compojure.handler/site #'myroutes)
04:42gyimbecause if you write (some-fn some-var), the actual value of the var is read and passed to the function. So if the function stores it, it will use the same value even if you redefine the var later
04:42gyimone way to resolve this is to pass the var instead of the actual value
04:45code-shoilyisn't the wrap-reload supposed to recompile the folders it is warching?
04:45code-shoilyIt is not even triggering a reload when I add new handlers, since it is a change in the folder, it should have. Whereas if I change the content of the function, it reloads them fine.
04:51gyimare you sure it does not reload the namespace? My guess is that it does reload it, but the http handler / route object is cached
04:52code-shoilyYes I think what you are saying is right. My bad.
04:57code-shoilyThanks gyim ... it worked now that I have user (-> (routes #'admin-route #'forum-route)) etc.. it was autogenerated from luminus template so didn't care to look into that. I understand it now :)
04:57gyimgreat! i'm glad it works
05:39acron^How do I pass in keyword arguments to a function?
06:12egliacron^: a quick google search gives some pretty good hints
06:12acron^i figured it out in the end =]
06:13egliacron^: http://stackoverflow.com/a/3969693 seems pretty reasonable
06:22kungiHow would one start to analyze this exception?
06:22kungiCaused by: java.lang.RuntimeException: No such var: s/defn, compiling:(schema/coerce.clj:25:1)
06:23schmirkungi: ask on irc?
06:24schmirsorry couldn't resist :)
06:24kungischmir: :-P
06:24schmircan't you take a look at the source?
06:25kungischmir: I did have a look and s/defn is defined. The problem is in this case that it works in one project but does not in another.
06:26TEttingermaybe s hasn't been required in yet?
06:26schmirdifferent dependencies?
06:26TEttingeror it's requiring an old version?
06:26TEttingerlein clean
06:26kungiI will start with lein clean first thanks.
06:28kungi\o/
06:28kungi(inc TEttinger)
06:28lazybot⇒ 44
06:28TEttingerwoah thanks!
06:28TEttingersurprised that was all it needed!
06:29TEttingerglad too
06:29kungiRemember: If something strange happens you can't explain => lein clean
06:29kungiStrange as in some error in library code that works elsewhere
06:29schmirkungi: or use boot (we met on clojured btw)
06:31kungischmir: then you should join #clojure.de the german clojure channel!
06:31schmirok
06:46noncomwhat's the best clojure way to work with zip files?
06:46schmirnoncom: I've used java.util.zip
06:46kunginoncom: I use java.util.zip for this
06:47schmirnot sure if that's the best way
06:47kungi:-)
06:47noncom:)
09:00Retsamtipapologies for cross-posting. am having trouble setting cookies in a Ring app (Luminus)
09:25noncom|2,(def k 1)
09:25clojurebot#'sandbox/k
09:25noncom|2,(meta k)
09:25clojurebotnil
09:25noncom|2,(reset-meta! k {:z 1})
09:25clojurebot#error{:cause "java.lang.Long cannot be cast to clojure.lang.IReference", :via [{:type java.lang.ClassCastException, :message "java.lang.Long cannot be cast to clojure.lang.IReference", :at [clojure.core$reset_meta_BANG_ invoke "core.clj" 2287]}], :trace [[clojure.core$reset_meta_BANG_ invoke "core.clj" 2287] [sandbox$eval71 invoke "NO_SOURCE_FILE" -1] [clojure.lang.Compiler eval "Compiler.java" 6...
09:25noncom|2,(reset-meta! #'k {:z 1})
09:25clojurebot{:z 1}
09:25noncom|2,(meta k)
09:25clojurebotnil
09:25noncom|2^^^^^ how is that? why nil ?
09:25agarman,(meta #'k)
09:25clojurebot{:z 1}
09:26noncom|2wow
09:26noncom|2should i always #' with meta?
09:26agarmanmeta is on Var
09:26agarman,(def z {})
09:26clojurebot#'sandbox/z
09:26noncom|2aah, right..
09:26noncom|2got it
09:26agarman,(reset-meta #'z {:foo 1})
09:26clojurebot#error{:cause "Unable to resolve symbol: reset-meta in this context", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.RuntimeException: Unable to resolve symbol: reset-meta in this context, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyze "Compiler.java" 6535]} {:type java.lang.RuntimeException, :message "Unable to resolve symbol: reset-meta in this con...
09:27agarman,(reset-meta! #'z {:foo 1})
09:27clojurebot{:foo 1}
09:27agarman,(meta z)
09:27clojurebotnil
09:28agarmannoncom|2: meta is on a Var, in (meta k), k gets resolved and isn't a Var
09:28agarmanevaled
09:28noncom|2so it takes meta on 1? (the k's value)..
09:28noncom|2,(meta 1)
09:28clojurebotnil
09:28noncom|2right
09:28agarmanyes
09:29noncom|2umm.. is it possible to somehow make (meta) return not nil on (meta 1) ?
09:29agarmanmeta is just a function so it gets evaled like any other function
09:30agarman1 isn't a IReference so it can't have meta attached to it
09:30noncom|2why no exception then?
09:30noncom|2i think this worth a class cast one
09:30agarman,(source meta)
09:30clojurebotSource not found\n
09:31agarmanbecause meta returns nil if what you're passing it isn't instance? clojure.lang.IMeta
09:31noncom|2ah, ok..
09:32agarman,(defn mmeta [x] (if (instance? clojure.lang.IMeta x) (.meta x)))
09:32clojurebot#'sandbox/mmeta
09:32agarman,(mmeta 1)
09:32clojurebotnil
09:32agarman,(mmeta #'k)
09:32clojurebot{:z 1}
09:32noncom|2so they wanted no exception here
09:33noncom|2is there a way to imitate #' with a passed symbol?
09:33noncom|2like 'sym can be imitated with (quote sym)
09:33agarman,(var k)
09:33clojurebot#'sandbox/k
09:34noncom|2so, this is very good
09:35agarmanhttp://java.ociweb.com/mark/clojure/images/ClassDiagram.png
09:35agarmanthat's a useful diagram for understanding relationships of Clojure's various cell types.
09:37noncom|2thank you, it is a very useful one
10:40borkdudewhen I serve a file from clojure ( liberator), how so I set the name properly?
10:41mpenetvia the Content-Disposition header if I recall
10:41schmirright. or redirect to url with the right name as last component
10:42borkdudempenet schmir thanks :)
10:42ordnungswidrigborkdude: Add a content-disposition header, you need to use ring-response for that.
10:43ordnungswidrigschmir: that only works if the the content cannot be displayed by the browser.
10:43borkdudeordnungswidrig how do I add a header with liberator? with :as-response?
10:43borkdudeordnungswidrig like at the bottom here? https://clojure-liberator.github.io/liberator/doc/representations.html
10:44ordnungswidrigborkdude: no, that would add a header for every response of that resource, i.e. for 404s, too.
10:44borkdudeordnungswidrig hmm right
10:45borkdudeordnungswidrig I have been puzzled by how to manipulate the ring response in liberator. how do I do that in general
10:46ordnungswidrigborkdude: in :handle-ok (fn [ctx] (ring-response (assoc-in (as-response ctx {:foo :my-data}) [:headers "Content-Disposition"] "attached; filename=foo.txt")))
10:47michaelr`I have this ":hooks [leiningen.cljsbuild]
10:47borkdudeordnungswidrig so if I return a map in the function, liberator interprets it as a ring response?
10:47ordnungswidrigborkdude: only if you wrap the map with `ring-response`
10:47michaelr`I have this ":hooks [leiningen.cljsbuild]" in my prod profile but uberjar doesn't run cljsbuild - why?
10:48ordnungswidrigIn 0.12.3 ring-response will support that directly: (ring-response my-data-for-as-response {:headers {"Foo" "bar"}})
10:49ordnungswidrigYou can then specify a second parameter to ring-respose which is a ring-response map which is combined with the response generated by as-response for the first parameter
10:49borkdudeordnungswidrig ah I get it now. ring-response is a function from liberator. doh, sorry :)
10:49borkdudeordnungswidrig thanks
10:50borkdudeordnungswidrig thank you for liberator btw <3 <3 <3
10:50ordnungswidrigborkdude: it's a please to see people use it.
10:51ordnungswidrigpleasure...
11:00borkdudeordnungswidrig thanks it worked. the order of args in as-response had to be {:foo :my-data} ctx btw.
11:01ordnungswidrigborkdude: ah, sure.
11:01ordnungswidrigsorry.
11:01borkdudeordnungswidrig no problem
11:07borkdudednolen are functions that are referred in the ns form, but not actually used, also pruned by closure, or not?
11:10yogsotothHi, I experience a strange behaviour with threads. I do a (future (while true...)) but my thread get killed or maybe is blocked
11:10yogsotothGenerally the thread stop working when I use a lot of other threads intensively
11:10borkdudednolen sorry I should have asked this in #clojurescript
11:11dnolenborkdude: dead code elimination doesn't have anything to do with ns forms, :refers are really complete fiction for var resolution
11:11borkdudednolen ok, so no worries there then
11:32sm0kein reagent are there functions to work with `ref` attributes?
11:50danlentzi noticed the const macro in im.chit/hara library: https://github.com/zcaudate/hara/blob/master/src/hara/expression/compile.clj#L3
11:51danlentzwould it be considered bad form in clojure to effect compile-time evaluation with something like: `~(+ 1 1)
11:52danlentzie, rather than (defmacro const [body] (eval body))
11:52danlentz(const (+ 1 1))
12:07gfredericksdanlentz: I'm not sure why `~(+ 1 1) would do what you want
12:08danlentzyes, i think i had a brain fart. thanks
12:13danlentzso, could this be accompished with a data-readers.clj — to implment an #eval reader tag that would be equivalet to common lisp #.
12:13danlentz?
12:18gfredericksyep; you have to be careful with that stuff since the local scope is irrelevant when using eval
12:18gfredericksI think (def ^:const ...) is usually just as good
12:20mfikes_danlentz: Dang... I tried what you were doing in ClojureScript with Closure optimizations and (+ 1 1) gets reduced down to 2.
12:21danlentzjust looking for the most ideomatic way to manually cause partial evaluation of a piece of a computation at compile time
12:21danlentzright
12:22danlentzi could just replace the code with the evaluated constant, but I was looking to keep some of the trivial computations for the sake of documentation value (as opposed to weird constants showing up all over the place)
12:23gfredericksdanlentz: why not just a def?
12:23gfredericks(def TAU (* 2 Math/PI))
12:24danlentzthere are a lot of them
12:24danlentzabout 20 i guess
12:24gfredericksand you don't like lots of defs?
12:25danlentzsituation such as this:
12:25danlentzhttps://github.com/danlentz/clj-uuid/blob/master/src/clj_uuid.clj#L591
12:25justin_smithdanlentz: if you really need compile time evaluation, use a macro and suck up the parens, I'd say
12:26danlentz:)
12:26justin_smithwell, that is for compile time eval plus no runtime deref
12:27justin_smithanother hack is to put your top level code inside a let block (but that's ugly and wrong)
12:27gfredericksjustin_smith: why not just ^:const?
12:27danlentzits not a huge big deal calliing (mask 2 62) is just a few bit-level operations
12:27justin_smithgfredericks: I'm confused by :const, maybe it does the right thing?
12:27danlentzAlready generating UUID’s 10x faster than java.util.UUID :)
12:28AeroNotixI've always wondered what use-case you need to be generating UUIDs really quickly.
12:28gfredericksjustin_smith: yeah I think it's exactly what he's asking for
12:28danlentzThe intent of the UUID is to enable distributed systems to uniquely identify information without significant central coordination
12:29AeroNotixand?
12:29danlentzhttp://danlentz.github.io/clj-uuid/
12:29gfredericksjustin_smith: it gets the value embedded in the bytecode, bypassing the var
12:30danlentztalks a bit about UUID’s
12:30justin_smithgfredericks: that's the right answer then, yeah
12:30AeroNotixdanlentz: I've read it -- you just say "It's better because it's faster"
12:30danlentzi’m not explaining all the ways to use UUID’s there
12:30danlentzi think that is like explaing all the ways to use memory addresses
12:31AeroNotixI'm just curious why you need to have incredibly faster generation of UUIDs.
12:31justin_smithdanlentz: I think he's asking for a use case where UUID generation would be the bottleneck
12:31AeroNotixyeah this
12:31danlentzit is better because it is compliant with the IETF standard and because it allows you to use UUID’s in a variety of ways that they are intended to be used that were not previously an option
12:32danlentzand it is much much faster if you use v1 ID’s as intended when performance is an issue
12:32AeroNotixso why is the key-feature whenever you mention it, the speed?
12:32danlentzwell, because I worked hard to optimize the v1's
12:32AeroNotixdanlentz: do you have/did you have a place where uuid generation was a bottleneck?
12:32danlentzthats what they are for: to be fast
12:33AeroNotixUUIDs are used in a lot of places nowadays but I've never heard someone say "dang I wish our UUID generator was faster"
12:33AeroNotixjust curious if you had this problem
12:33danlentzgiven that v3,v5 wasnt available at all (apparently) as a clojure library I didnt think i had to talk a lot about why you might want to use it instead of another namespaced identifier. For V!’s I felt it was important to distinguish their use case.
12:34danlentzyes absolutely
12:34AeroNotixwhat was your use-case for the speed?
12:34danlentzi wrote it because UUID generation was a bottleneck for implementing various things on a graph database
12:35AeroNotixgotcha, cool. Just the first time I've heard of generating uuids as being the bottleneck
12:35tyson2Dan, which graph db are you using?
12:35danlentzas an efficent index type for my weight balanced tree collection, which in turn is used for graph indees
12:35tyson2ah it looks like you're building your own
12:35danlentzwell, professionally i use datomic
12:35danlentzbut https://github.com/danlentz/clj-fgl
12:35danlentzmy own experimental sandbox
12:36AeroNotixhttps://github.com/danlentz/clj-fgl#tuple-store formatting screwed
12:36tyson2ok. I'm about to test out a demo of neo4j-clojure
12:36danlentzyeah, its not done
12:36justin_smithtyson2: neo4j has weird ass licensing
12:36danlentzits just a plaything, but ive been working the ideas for a while…
12:37justin_smithtyson2: technically it's the same as eg. mongodb but they enforce it differently...
12:37tyson2justin, tell me about it. The community version also has some limitations. The commercial version is quite expensive
12:38justin_smithcool, just wanted to make sure you were aware before building anything significant with it and finding yourself potentially stuck
12:38tyson2but we are semi-committed to neo4j, so I am going to see how it works in a clojure environment
12:42danlentzAeronotix: Also, I found I got mostly yawns and crickets when I told people I implemented RFC4122 compliant unique identifiers. It seems like it gets poeple to at least look at the site when I say they’re faster, and hopefully from there it also shows some of the other ways UUID’s can be useful.
12:43AeroNotixdanlentz: I understand what you mean, but it really perplexed me that someone would take the time to generate UUIDs faster
12:43AeroNotixjust was interested
12:43AeroNotix:)
12:44danlentzit actually nauseates me a bit to “promote” my own library, but since I started it’s gotten an order of magnitude more attention and a lot of people have come back with really good suggestions. So, getting it more exposure is helping me to make it better.
12:46danlentzAnd there have been some really nice reports that have come back that people have seen significant improvement in their productiion code by simply swapping in clj-uuid for UUID generation.
12:47danlentzSo, a lot of people think of UUID’s as trivial, but there is a lot to be said for doing them well.
12:47AeroNotixwhat kind of improvements?
12:47danlentzI don’t have any specific details to share, I’m just going from some of the conversations from the “issues” log
12:48danlentzbut for my case, my entire bottleneck was UUID’s so my improvement was 1000%
12:49danlentzfor functional, immutable data structures, UUID’s make a very useful addressing token.
12:49AeroNotixcool
12:50danlentzThefore, if you need to frequently update a functional data structure, the cost of computing new identifiers can mount considerably
12:50danlentzto build a binary tree of 100000 nodes requires one to generate 1.2 million “keys” in the process
12:51danlentzso you tell me if it is useful to do that fast.
12:53danlentzn log n i guess
12:53danlentz2 million
12:53danlentzsomething like that
12:55danlentzi felt like the reason they arent used more broadly in clojure is just because they didn’t seem very easy or fast to generate correctly]
12:56danlentzbut I think the use of UUID
12:57danlentzthat made me interested in them in the first place was the way they are used to implement a distributed transaction system in he CL graph-object database system http://github.com/lisp/de.setf.resource
12:58danlentzDr. Anderson writes some pretty amazing code. I spent about two years pouring over it…. :)
12:59danlentzalso, their use in peer-to-peer networks, although I’m not sure generating ID
13:00danlentzquickly is a big concern in that case
13:08michaelr`how to write this: (.. (js/jQuery "body") (addClass "app")) so it survives advanced compilation?
13:09michaelr`Currently compiles to this: jQuery("body").zj("app")
13:09nullptrshort answer is use https://github.com/ibdknox/jayq
13:09nullptrlonger answer is to either call addClass by name or create an externs file
13:10michaelr`nullptr: i'm using jquery's externs file..
13:10michaelr`it has this: jQuery.prototype.addClass = function(arg1) {};
13:12michaelr`nullptr: what do you mean to call it by name?
13:16danlentzi invoke thee by name of house Lannister
13:16nullptrmichaelr`: ((aget jQuery "addClass") ...)
13:17nullptrbut if you have an externs file w/addClass that shouldn't be necessary, not sure what's happening there
13:19michaelr`nullptr: i'm using the externs file for 1.9.0 with version 1.9.1, could this somehow be the reason?
13:21nullptrmichaelr`: i wouldn't think so
13:24gfrederickssomehow clj-http 1.0.1 is putting test.check in my uberjar
13:24michaelr`nullptr: i'm using the externs file for 1.9.0 with version 1.9.1,
13:24michaelr` could this somehow be the reason?
13:25gfrederickswell more precisely [com.cognitect/transit-clj "0.8.259"] is
13:25nullptrmichaelr`: doubtful, typically the externs processing avoids renaming for anything named there -- it's not terribly "smart"
13:26dnolenmichaelr`: only if addClass is missing, or the externs.js not actually getting included, I suspect the later
13:26dnolenmichaelr`: the externs file needs to be on the classpath, random location will not work
13:26dnolennot even a regular file path
13:26gfredericksoh I see it's https://github.com/cognitect/transit-clj/commit/640c35166740642f5c197c78883784acb993d7a1
13:27michaelr`dnolen: thanks. I have it here resources/public/vendor/js/jquery-1.9.0.ext.js - it's supposed to be on the classpath, no?
13:27dakronegfredericks: transit-clj is an optional dep, you should be able to exclude it
13:28dnolenmichaelr`: no idea, I don't know anything your project.clj nor what you specified for :externs since you haven't shown us
13:28nullptrmichaelr`: how are you referencing it?
13:29michaelr`ok wait, I think I put my :externs in the wrong place ;)
13:30gfredericksdakrone: yeah, that's what I'll be doing; created an issue in the meantime
13:30gfredericksdakrone: spurious deps probably don't normally bother anybody much but when it's a test lib it can cause a lot of confusion
13:30dakroneyeah, makes sense
13:31Guest39789trying to build a tree from maps like [{:id 1} {:id 2 :parent 1}]: https://gist.github.com/martinklepsch/4902c514c235dfa85f84
13:32Guest39789I have a basic solution but I'd like to see if it can be improved etc
13:34jjttjjanyone have any experience getting global hotkeys to work with clojure in windows?
13:34jjttjjlike hit F10 to do something without the program in focus
13:35Guest39789jjttjj: I'd research how you can achieve it with Java and then go from there
13:47aaelony~mapply
13:47clojurebotYou could (defn mapply [f & args] (apply f (apply concat (butlast args) (last args))))
13:47aaelonyis there a way to use mapply with juxt to pass named args ?
13:48justin_smithaaelony: what do you want the calling form to look like?
13:49aaelonyjustin_smith: I have a vector of maps with keys, keys that I have in another vector. I ultimately need to collect the values for each key into a vector.
13:50aaelonysomething like (map (juxt ks) coll) I guess
13:51justin_smith,(map (apply juxt [:a :b :c]) [{:a 0 :b 1 :c 2} {:a 1 :c 3 :d 4}]) ; like this?
13:51creeseAnyone know a good lib for Twilio?
13:51clojurebot([0 1 2] [1 nil 3])
13:51aaelonywhereas (map (juxt :a :b :c) coll) works but I'd like ks to be [:a :b :c]
13:51justin_smithaaelony: yeah (apply juxt coll)
13:51justin_smithlike I did above
13:51aaelonyjustin_smith: cool. let me try it out...
13:52justin_smithmapply is about apply with function that use [ & {:keys [a b c]}]
13:53aaelonyI see. I'm playing around with gg4clj and taking records from a database where the result set is a vector of maps. I believe gg4clj needs {:key [vector of values] :key2 [vector ...] ...}
13:54aaelonybut if I have a lot of fields, I only want a couple, hence juxt
13:58justin_smithaaelony: merge-with conj ... one moment I'll have an example
13:58aaelonyyeah, I'm actually thinking about a bunch of other options. maybe even transducers...
14:00justin_smith,(let [raw [{:a 0 :b 1} {:a 1 :c "OK"} {:b 2 :c "hello"}] base-keys (into #{} (mapcat keys raw))] (apply merge-with conj (zipmap base-keys (repeat [])) raw))
14:00clojurebot{:c ["OK" "hello"], :b [1 2], :a [0 1]}
14:00justin_smithwhere likely "raw" would actually be your function input
14:00aaelonyvery cool
14:01justin_smithit even preserves order
14:02aaelonyawesome stuff
14:03justin_smithI wonder if that (into #{} ...) needs to wrap the mapcat or not
14:03justin_smithwell I know for a fact it doesn't need to, I just wonder if making a set before zipmapping is a net win or not
14:06aaelonythank you justin, still playing with it myself
14:06aaelonymany thanks
14:18justin_smithaaelony: OK, both with and without jit turned on, the version without (into #{} ) wrapping the mapcat was faster
14:18justin_smithonly a little, but hey, its simpler too
14:34lasergoathi, i have a very strange AOT compilation issue i was hoping someone would help me with. Somehow, adding a dependency to storm-core causes my usage of clj-time.coerce to break
14:34modulusHi. A few versions ago the use of the clojure repl, at least from lein, became problematic with a spanish keyboard layout. Does anyone know if any improvements are coming on this, and if so, when?
14:34lasergoati have a minimal reproduction of the issue: https://github.com/icambron/storm-time
14:34justin_smithlasergoat: this rings a bell, something about storm-core having aot'd deps
14:35lasergoatjustin_smith: i see
14:35justin_smithmodulus: what OS do you use?
14:35moduluswin8
14:36lasergoatjustin_smith: was there a workaround? (it is true that storm-core also depends on clj-time and thus I guess AOTs it into the jar)
14:36justin_smithOK. I would have suggested rlwrap otherwise (I assume it would be better localized than the java lib that lein uses with nrepl for input handling)
14:36justin_smithlasergoat: that's the part I don't know. maybe there is something about it on SO or the mailing list if nobody recalls here?
14:37lasergoatmy brief search didn't find anything, but i can do some more digging
14:37modulusProbably what is most annoying is that it's a reversion. This used to work. Oh well.
14:38justin_smithmodulus: one thing you can try is running a vanilla clojure repl - it will lack the nrepl features, but it may be more usable
14:38justin_smithmodulus: java -cp (output of lein cp goes here) clojure.main
14:38justin_smithI don't know how to do stdout substitution in the windows shell, sorry
14:38modulusHow would I do this? I guess I'm too used to lein to be aware how to run this by itself.
14:39justin_smithmodulus: lein cp will output a classpath
14:39modulusah i will try that
14:39justin_smithjava -cp <that classpath> clojure.main
14:39justin_smithyou may need quoting around the classpath part
14:39modulusyes, likely
14:43modulushmm doesn't look like this will fit the command line length limit
14:45lasergoatwhat's the best way to search this channels logs?
14:46lasergoatsince either my google-fu isn't good enough to find this issue or the previous discussion of it may have actually been here
14:47godd2lasergoat have you tried googling "freenode log clojure"
14:48lasergoatah, that pointed me in the right direction, thanks
14:48lasergoatsite:http://www.raynes.me/logs/irc.freenode.net/clojure/
14:48lasergoatwas how i wanted to prefix my search
14:52lasergoatjustin_smith: thanks for the help. That should get me started at least
14:52aaelonyjustin_smith: makes sense to remove without the into#{} , since there shouldn't be duped keys anyways.
14:52justin_smithoh, cool
14:52aaelonyjustin_smith: gosh my english is terrible
15:17drbobbeatyHas anyone used the :javac-options in Leiningen? I ask because I'm compiling a lot of Java code (SOAP) and it's barfing on OutOfMemory, but the -J-Xms32m or -Xms32m options are coming back as "illegal args" to javac. (running 1.7.0_71 on OS X, if that matters)
15:24michaelr`drbobbeaty: The compiler oom's?
15:24drbobbeatyYup
15:24michaelr`because -Xmx I think is only for the jvm
15:24drbobbeatyAnd I'm a little afraid that Leiningen is placing the options to javac *after* the files, and in 1.7, I think that might be considered illegal.
15:25justin_smithdrbobbeaty: maybe you need ^:replace - I know that is sometimes needed with :jvm-opts
15:25drbobbeatyYeah, but putting the -J in from is supposed to pass it to the VM of the compiler. I have tested it independently, and the -J-Xms32m is the right argument to javac.
15:25drbobbeatyjustin_smith: I'm not familiar with that metadata tag, can you possibly please elaborate?
15:26justin_smith:some-config ^:replace [opts...]
15:26justin_smithit tells lein to replace the defaults, instead of the default (merging in)
15:27justin_smithdrbobbeaty: eg. this is needed if lein provides a default arg that contradicts the option you want (this comes up with hotspot options)
15:27justin_smithso in your case you could try :javac-options ^:replace [...]
15:27drbobbeatyjustin_smith: I'll give it a go. Thanks.
15:28drbobbeatyjustin_smith: Tried it... didn't work out. I'm going to see if I can get Leiningen to log what it's doing - I see the log messages in the code, I just want to see them output... more digging.
15:29drbobbeatyjustin_smith: Thanks for the help, though
15:29justin_smithdrbobbeaty: have you tried :eval-in pprint to get the effective project.clj?
15:30drbobbeatyjustin_smith: No... I didn't know that trick, I'm just looking at my project.clj in the editor.
15:37michaelr`drbobbeaty: never met :eval-in but there is an easy to use plugin lein-pprint
15:37aneis it possible to do structural typing with defrecord and protocols? as in, is it possible to avoid specifying the protocols i am implementing?
15:37drbobbeatymichaelr`: Thanks, I'll try it.
15:38lasergoatok, so more specifically the problem is that storm-core contains older versions of the dependency i'm trying to use and it's winning the war for the classpath. thus anything i'm using from clj-time that didn't exist in the prehistoric version causes a compiler error
15:39bloawlerHi! I'm trying to get the Leiningen repl working, I'm following a tutorial, and when I execute " (require '[clojure.zip :as zip]) " a FileNotFound exception is raised. Is there some specific setup needed to load these libraries into the lein repl?
15:39lasergoatin other words: https://issues.apache.org/jira/browse/STORM-169
15:39dan_blasergoat: have you tried something like
15:39dan_b [ring "1.3.2" :exclusions [org.clojure/java.classpath]]
15:39dan_bon yout project.clj
15:40dan_bobviously varying the package names to the ones you're having trouble with ;-0)
15:40lasergoatlike trying to exclude clj-time from my storm dependency? i did try that, had no effect
15:40justin_smithdan_b: the issue is that storm compiles deps into itself
15:40dan_bdunno then, sorry
15:41lasergoatyeah, something about how it actually AOTs them -- lein doesn't seem to be able to override that? (it's becoming increasingly painful that i don't understand how this stuff works under the hood)
15:45lasergoatbloawler: that should work out of the box
15:46justin_smithbloawler: if (require '[clojure.zip :as zip]) doesn't work, the first thing I would check for is a typo
15:46justin_smiththe second thing would be an insanely old clojure version I guess?
15:46justin_smithbloawler: what lein version are you using?
15:54bloawlerjustin_smith: 2.5.1, just upgraded through brew
15:56gfredericksis there a ring middleware for printing exceptions that prints the ex-data too?
15:56bloawlerfull exception: https://gist.github.com/anonymous/d3eee5c3c3d7e2e0ad00
15:56justin_smithbloawler: like I said, typo
15:56justin_smiths/closure/clojure
15:56bloawlerahmigad
15:56bloawleri make this same spelling error in my google searches
15:56bloawlershoulda caught it
15:57kungiikitommi_: Did you ever use compojure-api together with friend, and if ... can you give me some pointers on how to use it?
15:57bloawlerthanks /embarrassed
15:57justin_smithit's a fair mistake for a newcomer, you were spelling the word correctly as far as the real world is concerned :)
16:28gfrederickshypirion: ping
16:31hyPiRiongfredericks: pong
16:31gfrederickshyPiRion: leiningen issue 1757
16:31gfrederickswould this cause `lein with-profile +foo uberjar` to be ineffective?
16:31gfredericksw.r.t. resource-paths in particular
16:33hyPiRiongfredericks: no, I think that should be fine
16:34hyPiRionI could imagine it being broken though, it has been painful in the past
16:34ikitommi_kungi: for no good reason, have rolled own auth libs. Restructurings like :roles #{:admin}
16:35gfrederickshyPiRion: cool I'll dig deeper
16:35gfrederickshyPiRion: specifically I'm seeing the correct set of resource-paths if I `lein with-profile +foo pprint` yet still the file does not make it into the uberjar
16:35gfredericksgoing to make a user.clj and monkeypatch myself some logging or something
16:36hyPiRiongfredericks: Have you attached the ^:leaky metadata on foo?
16:36hyPiRionthat was a breaking change that somehow got through
16:36gfredericksthe what??
16:36lazybotgfredericks: What are you, crazy? Of course not!
16:37ikitommi_kungi: same for injecting components into routes via :components. These binding are mostly only few lines of code, but could add some common ones back to c-api.
16:38hyPiRiongfredericks: PR #1681 in lein
16:38hyPiRionhttps://github.com/technomancy/leiningen/pull/1681
16:38ikitommi_kungi: would love to see samples of friend or buddy integrated in. We could add those to examples.
16:39gfrederickshyPiRion: HUH. so ^:leaky is exactly what I want for this purpose and I shouldn't expect it to work without it?
16:41hyPiRiongfredericks: Yeah, but it's a breaking change 2.5.0
16:41hyPiRionthat landed in 2.5.0*
16:43danlentzjustin_smith: and the others with whom I was discussing compile-time evaluation. I have been pointed to the (undocumented) #= reader macro which is equivalent to common lisp
16:44danlentzcommon-lisp #. which is what i wanted
16:44gfrederickshyPiRion: cool thanks!
16:44hyPiRionnp
16:44gfredericks(inc hyPiRion)
16:44lazybot⇒ 71
16:45justin_smithdanlentz: best known as a weird security issue ##(read-string "1 + 1 is ##(+ 1 1)")
16:45lazybot⇒ 2
16:45justin_smitherr
16:45justin_smith&(read-string "1 + 1 is #=(+ 1 1)")
16:45lazybot⇒ 1
16:46justin_smith&(read-string "#=(+ 1 1)")
16:46lazybotjava.lang.RuntimeException: EvalReader not allowed when *read-eval* is false.
16:46justin_smith:P
16:47gfrederickshyPiRion: based on me just trying it I suspect #1718 (uberjar-name) is the same issue
16:47gfredericksshould I comment and close it?
16:48gfredericksor is it a bug because :uberjar-name shouldn't require ^:leaky?
16:49hyPiRionI think it shouldn't require ^:leaky, but I'll have to look into the details again. There's a PR (#1849) for solving #1718 which I'll have a look at during the weekend
16:49gfrederickshyPiRion: okay cool, thanks again
16:49hyPiRionanytime
17:02campetersonHey all, forgive me if this is is a weird question. I have a keyword :large? which correspond to a function name in the (ns image.core). I require image.core as image. I want to do this: (image/large? some_image) but I'm not sure how put the ns & function name together to evaluate it.
17:03justin_smithcampeterson: why not just call image/large?
17:04justin_smithand where does this keyword come in again?
17:05campetersonjustin_smith: I actually have a list of keywords which function names
17:05campeterson‘(:large? :medium? :small?)
17:06justin_smithwhy do you need these keywords in a list?
17:07campetersonIt’s how the data is stored. They are rules.
17:07campetersonMy task is to check and make sure all the rules match (returning true or false)
17:08campeterson“Here are a list of functions. Let me know if they’re all true or not”
17:08campetersonIt’s stored as data
17:08campeterson“Rules”
17:08justin_smithif that's what you want, then why are you using keywords instead of the functions themselves?
17:09justin_smith,((every-pred [number? even? pos?]) 2)
17:09clojurebottrue
17:09justin_smithif you just had a list of the functions, you could use every-pred
17:10campetersongood point
17:10amalloyjustin_smith: ITYM ((every-pred number? even? pos?) 2), amusnigly
17:10justin_smithwait, oh that worked by accident
17:10justin_smithlol
17:10justin_smith(inc amalloy)
17:10lazybot⇒ 239
17:11amalloyyour version happens to work because ([x y z] 2) returns z
17:11justin_smithright
17:11justin_smithcampeterson: so it would be ##((apply every-pred [number? even? pos?]) 2)
17:11lazybot⇒ true
17:11justin_smithusing your list of functions of course
17:12justin_smithand yeah, you could write a function that takes a list of keywords and makes a list of functions from it, but if you can use functions, that's simpler
17:12campetersonWhat I’m doing (arguably very hacky) is akin to calling some_image.send(image/large?)
17:13campetersonthe problem is I need to store the list of functions to call in the map
17:13justin_smithcampeterson: if it has to be plain data and not functions, you can use symbols instead of keywords, then use resolve
17:13justin_smithbut functions are simplest, if you can swing them
17:14campetersonThe data is just json (written by a non-clojure system), so I’m afraid it has to be plain data
17:14justin_smith,((apply every-pred (map resolve '[number? even? pos?])) 2)
17:14clojurebottrue
17:15justin_smithor, since it is coming in as json, better to do explicit lookup to prevent a security hole
17:15campetersonsure
17:15justin_smith(get {:large? image/large ...} option)
17:16justin_smithor even (map {:large? image/larg ...} kw-options)
17:16amalloy(inc justin_smith)
17:16lazybot⇒ 216
17:16campetersoncool. Thanks for sticking through it. Kind of a weird issue
17:51campetersonjustin_smith: thanks again. I got it. (though the code isn’t super pretty) ((ns-resolve (the-ns ‘image.core) (symbol (name :large?))) some-image)
17:57justin_smithcampeterson: why use resolve at all instead of just using the functions in a lookup map?
17:57justin_smithyou already know which functions will be valid, right?
17:58justin_smithcampeterson: ##((apply every-pred (map {:even? even? :number? number? :pos? pos?} [:even? :number? :pos?])) 2)
17:58lazybot⇒ true
18:00justin_smithcampeterson: but of course in your case the hash map of keyword / function pairs would likely be a def, and the list of keywords to look up would be extracted from the json
18:15kungiikitommi_: Ok I will try to generate a nice example. If I have some problems I will write to you tomorrow :-)
18:21ikitommi_kungi: sounds great
18:22nena30ola
18:28arrdemIs there an "aggressive" URL encoding tool? By default Java won't urlencode stuff like \. that's not really filesystem or URL safe.
18:29amalloyarrdem: uh, fairly sure java's url encoder correctly encodes urls
18:30amalloyif you want something that's "safe" in any arbitrary weird encoding context, you can base64 everything
18:32kungiikitommi_: \o/ It works. Let's talk about the example tomorrow.
18:32arrdemamalloy: yeah that's the worst case approach for sure.
18:33arrdemeh forcibly encoding . as %2E is a superset of URL encoding and works for now.
18:55hyPiRionHas someone made a `with-out-str`, but for System/out? It seems pretty straightforward to implement, but I just want to know if there are any pitfalls I should attempt to avoid
19:34aaelonyl
19:34aaelonysorry, wrong window. arrrrrrgh.
20:03gfrederickshyPiRion: well it'd be global is the big difference, right?
20:03gfredericksotherwise I don't know of any issues
20:17gfredericksany macro-lovers have thoughts about this? https://github.com/gfredericks/catch-data/pull/5
20:25omgfredericks: wrapping the unquote seems a good idea to me...
20:26gfredericksom: oh, not about that part, I mean about my top level PR comments
20:26ombut may be I missed the real point of your question
20:26omoh, sorry
20:27om(just that I did some wrapping of unquotings recently with the same concern as yours here)
20:27gfredericksyeah that's a totally normal macro thing
20:31gfredericksadded another comment to it
20:35vermahey guys how do you like my sticker collage: http://udayv.com/mcti-clojure-workshop/stickers.html ? trying to get this up for a local workshop I am going to run this april, collecting stickers to give away from local and well-known clojure companies
20:40ibashverma: what is ithis?
20:40vermaibash: just a collection of stickers I'd be giving out to attendees at a clojure workshop I'd be running :)
20:41vermaibash: I am trying to get local companies and clojure companies to donate stickers :)
20:41ibashwe have stickers
20:41vermaSEND ME ZE STICKRZZ!
20:41ibashnot a clojure company :(
20:42vermayou're hanging out in #clojure, that's serious
20:42verma:)
20:42ibashI’m learning still
20:42vermaibash you can pm me your company name, email and I will send you a mail
20:43ibash.done
22:44grantglooking for the right way to remove from an atom containing a vector. i know for maps to (swap! the-atom dissoc key), but i cannot think of a nice way to do it with vectors by the value.
22:45justin_smithgrantg: vectors don't support removal except of the last item
22:46justin_smithif you want to remove items in the middle, use a list / seq of some sort, and use the remove function
22:47justin_smithotherwise, the best bet with a vector is to use remove (which will give you a lazy seq back) and put the result into a vector
22:48grantghmm...
22:48justin_smithor a set, those support removal by value
22:48justin_smith,(disj #{:a :b :c :d :e} :b)
22:48clojurebot#{:e :c :d :a}
22:48justin_smithdepends if you need something ordered or not I gues
22:48justin_smiths
22:49grantgthe set may work.
22:56TEttingergrantg, also reset! if you don't mind changing the whole value
22:56mfikesIs there a cleaner way to map a list of fns across a sequence than this? (map #(%1 %2) [inc inc dec] [3 5 11])
22:56justin_smithmfikes: juxt
22:57Retsamtipanyone know how to set session values in ring middleware?
22:57justin_smith,(map (juxt inc inc dec) [3 5 11])
22:57grantgjustin_smith: the set works, thanks.
22:57clojurebot([4 4 2] [6 6 4] [12 12 10])
22:57justin_smithgrantg: cool
22:57grantgTEttinger: didn't want to go to reset!, but thanks. :)
22:58TEttinger(inc juxt)
22:58lazybot⇒ 20
22:58mfikes,(map #(%1 %2) [inc inc dec] [3 5 11])
22:58clojurebot(4 6 10)
22:58justin_smithRetsamtip: (update-in my-response [:session :some-key] some-fn) or (assoc-in my-response [:session :some-key] value)
22:58justin_smithmfikes: oh, you don't want every function on every item, OK
22:59Retsamtipjustin_smith: thanks, let me try that
22:59justin_smithRetsamtip: that's in order to generate the result of your handler of course, these are pure functions
23:00Retsamtipright, i guess that’s where i’m getting canfused
23:00justin_smithRetsamtip: so the update-in or assoc-in would wrap whatever you currently are returning
23:00Retsamtipto chain I have to return (handler request)
23:00mfikesjustin_smith: Yeah. Honestly, I only ran into needing this once recently. It bothered me that I couldn't think of a clean solution, and thought I'd ask here. Maybe it doesn't occur frequently.
23:01justin_smithRetsamtip: right, so either you do the update inside handler, or you do (update-in (handler request) ...)
23:01TEttinger((apply juxt [inc inc dec]) [3 5 11])
23:01TEttinger,((apply juxt [inc inc dec]) [3 5 11])
23:01clojurebot#error{:cause "clojure.lang.PersistentVector cannot be cast to java.lang.Number", :via [{:type java.lang.ClassCastException, :message "clojure.lang.PersistentVector cannot be cast to java.lang.Number", :at [clojure.lang.Numbers inc "Numbers.java" 112]}], :trace [[clojure.lang.Numbers inc "Numbers.java" 112] [clojure.core$inc invoke "core.clj" 890] [clojure.core$juxt$fn__4463 invoke "core.clj" 2468...
23:01TEttingeragh
23:02justin_smithTEttinger: yeah, that juxt wants one arg
23:02mfikesjustin_smith: TEttinger: Yeah. `juxt` feels like it must be part of the answer :)
23:03justin_smithit really only makes sense if all the functions are applied to an input
23:03Retsamtipjustin_smith: does this look right, then? (update-in (handler req) [:session :some-key] "value")
23:04justin_smith,(map apply [inc inc dec] (map list [3 5 11]))
23:04clojurebot(4 6 10)
23:04justin_smithRetsamtip: yes
23:04justin_smiththe apply / list version is silly
23:04mfikesjustin_smith: Wow. Cool.
23:05justin_smithmfikes: #(%1 %2) is better though
23:05justin_smitheven if less aesthetically pleasing
23:06mfikesjustin_smith: Yeah. I'm finding your other solution hard to tease apart.
23:07TEttingerit might make sense to (defn call [f & args] (apply f args))
23:07justin_smithmfikes: apply takes any number of args, the first is called with the others as arguments, with the last ones all needing to be in a list
23:07justin_smith,(apply + 1 [2])
23:07clojurebot3
23:07justin_smithonce you know that, my weird thing should make sense
23:07justin_smiththough it's still silly
23:07TEttinger,(defn call [f & args] (apply f args))
23:07clojurebot#'sandbox/call
23:08TEttinger,(map call [inc inc dec] [3 5 11])
23:08clojurebot(4 6 10)
23:08Retsamtipjustin_smith: thanks, not working for me. here’s the middleware http://pastebin.com/Vnsgmrba
23:08TEttinger,(map call [+ - *] [3 5 11] [10 20 30])
23:08clojurebot(13 -15 330)
23:08Retsamtipthat last assoc-in does not seem to update the session
23:09mfikesTEttinger: Hmm. `call` seems useful :)
23:09justin_smithRetsamtip: why is (handler req) on line 17?
23:09Retsamtipthought that’s what i need to return to chain
23:09justin_smithno
23:10TEttingermfikes, if it comes up more than once it might be handy to define it
23:10justin_smithRetsamtip: remember I said, you need to wrap (handler req) with the session update
23:10TEttingerotherwise, #(%1 %2) should suffice
23:10justin_smithRetsamtip: because assoc-in is a pure function, if you don't return it, it may as well not be there - you create the session and throw it away
23:11TEttingerit's equivalent to #(apply %1 %&) anyway
23:11TEttinger(my call)
23:11mfikesTEttinger: right
23:11Retsamtipjustin_smith: got it. so removing that return value should work. let me try it
23:12justin_smithRetsamtip: what you have there should work if you take out (handler req) on line 17
23:12justin_smithRetsamtip: also, either take (handler req) out of your let block, or change the assoc in to (assoc-in response ...)
23:12justin_smithbecause there's no need to do the handler twice
23:12Retsamtipyes, works! thank you very much, now I understand my n00b mistake
23:13justin_smithRetsamtip: also, your code will be much easier to understand if you don't put multiple let bindings on one line
23:13justin_smithRetsamtip: best is one value / binding on each line of the binding vector
23:13Retsamtipgood call, i’ll do that