#clojure log - May 03 2015

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:10 wizzo: hi, i was looking if a function exists that would kind of act like a cross between map and ->. something that takes a function, a value and a list of arguments

0:10 and it would go through the argument list apply it to the function and the value

0:10 and thread the result of value through

0:10 is that a thing?

0:10 justin_smith: reduce? you could do something like that with reduce

0:11 wizzo: i tried reduce but it seems to be giving the entire argument list at once

0:11 but i want it to iterate each just one at a time

0:11 justin_smith: you need a little more than that

0:11 wizzo: i think i can do it fine with loop but just wondering if something already exists

0:11 justin_smith: ,(reduce (fn [v f] (f v)) 1 [inc #(* % %) inc])

0:12 clojurebot: 5

0:12 justin_smith: so you abstract that as a function, so the last two args are supplied by the user

0:13 ,(reduce #(%2 %) 1 (take 30 (cycle [inc /])))

0:13 clojurebot: 987/1597

0:13 wizzo: hmm ok i might need to play more than, i'm not getting the same behaviour

0:13 or at least i don't think so

0:14 thanks!

0:42 justin_smith that worked perfect, just a problem with a function i used to generate the arguments

0:42 thanks again for your help

0:42 justin_smith: np

0:51 TEttinger: ,(reductions #(%2 %) 1 (take 30 (cycle [inc /])))

0:51 clojurebot: (1 2 1/2 3/2 2/3 ...)

0:58 justin_smith: haha, if I look at it locally, so many of the numbers in the ratios are in the fibonacci sequence...

0:59 there is some deeper mathematical reason for this that would be easier for me to puzzle out if I had less wine in me

1:01 TEttinger: I am not sure how I would implement a sobol sequence one-liner in clojure. the impl is pretty small in apache commons math but uses a massive embedded resource that stores the "direction information" needed to generate points in dimensions from 2-1000

1:02 I did a halton sequence one-liner

1:22 tomjack: ,(numerator 1/1)

1:22 clojurebot: #error{:cause "java.lang.Long cannot be cast to clojure.lang.Ratio", :via [{:type java.lang.ClassCastException, :message "java.lang.Long cannot be cast to clojure.lang.Ratio", :at [clojure.core$numerator invoke "core.clj" 3460]}], :trace [[clojure.core$numerator invoke "core.clj" 3460] [sandbox$eval25 invoke "NO_SOURCE_FILE" 0] [clojure.lang.Compiler eval "Compiler.java" 6792] [clojure.lang.Compil...

1:24 TEttinger: hmmm

1:24 ,(type 1/1)

1:24 clojurebot: java.lang.Long

1:24 TEttinger: ,(type 3/3)

1:24 clojurebot: java.lang.Long

1:25 justin_smith: funny that it does that, but 1.0 remains a double

1:25 TEttinger: ,(type 6/3)

1:25 justin_smith: ,(type (+ 1/2 1/2))

1:25 clojurebot: java.lang.Long

1:25 clojure.lang.BigInt

1:25 justin_smith: sorry

1:25 ,(type (+ 1/2 1/2))

1:25 clojurebot: clojure.lang.BigInt

1:25 TEttinger: hmmmm

1:25 tomjack: ouch..

1:26 not that I've ever used numerator for anything other than dicking around

1:26 justin_smith: clearly you need a numerator multimethod

1:27 (returning N for every non-ratio input)

1:27 TEttinger: hm, how would #clojure approach this... I have a "random" number generator that produces double results in the range [0,1)

1:27 tomjack: I would think it should err on floating point

1:27 also bigdec?

1:27 dunno

1:27 justin_smith: bigdec is guaranteed to have a rational representation isn't it?

1:28 tomjack: https://www.refheap.com/df016418a88c9cd199a8d837d

1:28 TEttinger: I want to make any input flipped. so 0.5 stays 0.5 or very close, but 0.25 becomes 0.75 or very close, and 0 becomes just shy of 1

1:28 justin_smith: yes, what a weird way to derive a duplicated fibonacci :)

1:29 durka42: TEttinger: … subtract from 1?

1:29 justin_smith: (inc durka42)

1:29 lazybot: ⇒ 1

1:29 TEttinger: that's (0,1]

1:30 I need [0,1)

1:30 so really if there's a way to get the value one step below one representable by a double, that works

1:31 durka42: I would imagine it is (- 1 Double/EPSILON) or something

1:31 TEttinger: (- 1.0 Double/EPSILON)

1:31 ,(- 1.0 Double/EPSILON)

1:31 clojurebot: #error{:cause "Unable to find static field: EPSILON in class java.lang.Double", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.RuntimeException: Unable to find static field: EPSILON in class java.lang.Double, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyze "Compiler.java" 6543]} {:type java.lang.RuntimeException, :message "Unable to find static field:...

1:31 TEttinger: mmmm

1:31 justin_smith: TEttinger: this could call for one of my favorite functions - rangemap (defn rangemap [x a b a' b'] (+ a' (* (- x a) (/ (- b' a') (- b a)))))

1:31 of course you can optimize it by returning a function for that range

1:32 durka42: ,(= 1.0 (- 1.0 Double/MIN_VALUE))

1:32 TEttinger: justin_smith: uh that doesn't appear to be doing any mapping

1:32 clojurebot: true

1:33 justin_smith: (defn make-rangemapper [a b a' b'] (let [scale (/ (- b' a') (- b a))] (fn [x] (+ a' (* (- x a) scale)))))

1:33 durka42: aha

1:33 justin_smith: TEttinger: it's a mapping

1:33 durka42: ,(= 1.0 (- 1.0 (Math/ulp 1.0)))

1:33 clojurebot: false

1:33 durka42: ,(Math/ulp 1.0)

1:33 clojurebot: 2.220446049250313E-16

1:33 justin_smith: TEttinger: in the mathematical sense of map

1:34 TEttinger: ,(- 1.0 (Math/ulp 1.0))

1:34 clojurebot: 0.9999999999999998

1:35 tomjack: brilliant

1:35 TEttinger: ,(+ 1.0 (* -1.0 (Math/ulp 1.0)) (Math/ulp 1.0))

1:35 clojurebot: 1.0

1:35 TEttinger: nice

1:35 justin_smith: (defn make-rangemapper [a b a' b'] (let [scale (/ (- b' a') (-

1:35 b a))] (fn [x] (+ a' (* (- x a) scale)))))

1:35 durka42: ulp(0.0) is different from ulp(1.0), though

1:35 justin_smith: ergh

1:35 ,(defn make-rangemapper [a b a' b'] (let [scale (/ (- b' a') (- b a))] (fn [x] (+ a' (* (- x a) scale)))))

1:35 clojurebot: #'sandbox/make-rangemapper

1:36 justin_smith: (def flippy (make-rangemapper 0.0 0.5 1.0 0.5))

1:36 ,(def flippy (make-rangemapper 0.0 0.5 1.0 0.5))

1:36 clojurebot: #'sandbox/flippy

1:36 TEttinger: ,flippy

1:36 clojurebot: #object[sandbox$make_rangemapper$fn__145 0x48c95e2f "sandbox$make_rangemapper$fn__145@48c95e2f"]

1:36 justin_smith: ,(flippy 0.0)

1:36 clojurebot: 1.0

1:36 justin_smith: ,(flippy 0.5)

1:36 TEttinger: oh justin_smith

1:36 clojurebot: 0.5

1:36 justin_smith: you define an input line, and an output line

1:36 it maps points on one, to points on the other

1:36 TEttinger: ,(flippy (- 1.0 (Math/ulp 1.0)))

1:36 clojurebot: 2.220446049250313E-16

1:37 justin_smith: well, it returns a function that does said mapping

1:37 which you can then use in your random range thing

1:37 if you add an exponent, you can even make it map in a curved manner :)

1:37 TEttinger: well the ulp thing seems to be the solution

1:37 (inc durka42)

1:37 lazybot: ⇒ 2

1:37 justin_smith: oh, interesting

1:38 TEttinger: the 2d version of rangemapper is called a projection

1:40 TEttinger: ,(Math/nextDown 1.0)

1:40 clojurebot: #error{:cause "No matching method: nextDown", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.IllegalArgumentException: No matching method: nextDown, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6740]} {:type java.lang.IllegalArgumentException, :message "No matching method: nextDown", :at [clojure.lang.Compiler$StaticMethodExpr <i...

1:40 justin_smith: TEttinger: I think that's a java8 thing

1:40 ,*java-version*

1:40 clojurebot: #error{:cause "Unable to resolve symbol: *java-version* in this context", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.RuntimeException: Unable to resolve symbol: *java-version* in this context, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyze "Compiler.java" 6543]} {:type java.lang.RuntimeException, :message "Unable to resolve symbol: *java-version*...

1:40 justin_smith: er

1:40 ,(clojure-version)

1:40 clojurebot: "1.7.0-master-SNAPSHOT"

1:40 TEttinger: &(Math/nextDown 1.0)

1:40 lazybot: java.lang.IllegalArgumentException: No matching method: nextDown

1:41 justin_smith: ,(System/getProperty "java.version")

1:41 clojurebot: #error{:cause "denied", :via [{:type java.lang.SecurityException, :message "denied", :at [clojurebot.sandbox$enable_security_manager$fn__835 invoke "sandbox.clj" 69]}], :trace [[clojurebot.sandbox$enable_security_manager$fn__835 invoke "sandbox.clj" 69] [clojurebot.sandbox.proxy$java.lang.SecurityManager$Door$f500ea40 checkPropertyAccess nil -1] [java.lang.System getProperty "System.java" 708] [sa...

1:41 justin_smith: :P

1:43 TEttinger: ,(Math/nextAfter 1.0 0.0)

1:43 clojurebot: 0.9999999999999999

1:43 TEttinger: mmmm

1:43 that's not the same as the ulp one

1:43 ,(> (Math/nextAfter 1.0 0.0) (- 1.0 (Math/ulp 1.0)))

1:43 clojurebot: true

1:44 TEttinger: ,(= (Math/nextAfter 1.0 0.0) 0.9999999999999999)

1:44 clojurebot: true

2:03 justin_smith: ,0.9999999999999999

2:03 clojurebot: 0.9999999999999999

2:04 TEttinger: ,(= (Math/nextAfter 1.0 0.0) 0.99999999999999999)

2:04 clojurebot: false

2:04 TEttinger: hm

2:04 ,0.99999999999999999

2:04 clojurebot: 1.0

2:04 TEttinger: ah!

2:04 ,0.99999999999999991

2:04 clojurebot: 0.9999999999999999

2:04 TEttinger: ,0.99999999999999995

2:04 clojurebot: 1.0

2:04 justin_smith: ,(nth (iterate #(Math/nextAfter % 0.0) 1.0) 1000)

2:04 TEttinger: that's the line

2:04 clojurebot: 0.999999999999889

2:05 justin_smith: so funny to realize there are 1000 distinct floating point values between 1.0 and 0.999999999999889

2:05 TEttinger: heh

2:05 justin_smith: ,(nth (iterate #(Math/nextAfter % 0.0) 1.0) 10000)

2:05 clojurebot: 0.9999999999988898

2:05 justin_smith: ,(nth (iterate #(Math/nextAfter % 0.0) 1.0) 100000)

2:05 clojurebot: 0.9999999999888978

2:05 TEttinger: nice

2:05 justin_smith: how far do we need to go before we break 0.8...

2:06 ,(nth (iterate #(Math/nextAfter % 0.0) 1.0) 1000000)

2:06 clojurebot: Execution Timed Out

2:06 justin_smith: that returns 0.9999999998889777

2:13 (nth (iterate #(Math/nextAfter % 0.0) 1.0) 100000000) ... takes for ever ... => 0.9999999888977698

2:19 durka42: user=> (count (take-while (partial < 0.8) (iterate #(Math/nextAfter % 0.0) 1.0)))

2:19 justin_smith: … this oughta run for a bit…

2:19 justin_smith: haha

2:19 durka42: I hope #'count doesn't hold on to its head

2:19 justin_smith: no, it definitely does not

2:20 durka42: likely it would be faster for a human to just go look up the floating point spec and do the math for how many distinct values can exist between 1.0 and 0.8

2:22 durka42: probablyu

2:22 justin_smith: so for an ieee 754 double, you get 53 bits in a significand

2:23 everything from 0.8 to 1.0 would have the same exponent

2:24 actually, more precisely 0.1 through 0.9999... should all have the same exponent

2:25 ,(/ (- 1.0 0.1) (- 1.0 0.8))

2:25 clojurebot: 4.500000000000001

2:26 justin_smith: ,(/ (Double/pow 2 52) 4.500000000000001)

2:26 clojurebot: #error{:cause "No matching method: pow", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.IllegalArgumentException: No matching method: pow, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6740]} {:type java.lang.IllegalArgumentException, :message "No matching method: pow", :at [clojure.lang.Compiler$StaticMethodExpr <init> "Compiler....

2:26 justin_smith: ergh

2:26 ,(/ (Math/pow 2 52) 4.500000000000001)

2:26 clojurebot: 1.0007999171934434E15

2:27 justin_smith: so there you have it

2:27 durka42: ,(apply - (map #(Double/doubleToLongBits %) [1.0 0.8]))

2:27 clojurebot: 1801439850948198

2:28 justin_smith: ~ 1000799917193443.4 distinct values between 0.8 and 1.0 ?

2:28 clojurebot: No entiendo

2:28 durka42: ,(Math/log10 (apply - (map #(Double/doubleToLongBits %) [1.0 0.8])))

2:28 clojurebot: 15.255619765854984

2:28 durka42: ~1E15, I concur :)

2:28 clojurebot: Cool story bro.

2:28 justin_smith: haha, much more direct, nice

3:20 WickedShell: I'm finding lots of different methods for writing/reading from files with clojure, but I'm having trouble sifting through what is simply stale information/vs what is good practice. Ideally I'd like to avoid stepping back to simply interoping with bufferedwriters, although if thats the best method then that's fine. (Also of note: I need to work almost entirely with binary streams, rather then character streams)

3:21 IE slurp/split look like they don't address working with binary data well (or at all?) and past that I;m fininding mostly fallbacks to BufferedWriter

3:22 TEttinger: yeah, slurp and spit are for strings. it sounds like you want an equivalent for byte arrays?

3:23 or binary streams, right

3:23 this is the point when we check ztellman's github to see if he wrote something already :)

3:23 $google ztellman github

3:23 lazybot: [ztellman (Zach Tellman) · GitHub] https://github.com/ztellman

3:24 TEttinger: https://github.com/ztellman/gloss it seems

3:25 justin_smith: depending on what you want from that binary stream

3:25 if you just want bytes, it's still easiest to just use interop

3:28 TEttinger: ah! https://github.com/ztellman/byte-streams

3:28 WickedShell: well for now I'm simply throwing the bytes at the disk, and later will reload the fetched data as an image (which is fairly easy). At somepoint down this road I will need to figure out how I'm handling actually breaking apart some binary packed structs, but that part isn't related to the filesystem

3:31 TEttinger: that looks really helpful actually, solves one of the things that traditionally blows up in java...

3:31 and I had yet to find that via google

3:36 TEttinger: great!

3:59 WickedShell: protip: don't allow the output from a HTTP request to print in the windows command prompt, you may end up stuck listening to 30 seconds of terminal bells (also don't use windows, but hey)

4:04 edbond: &(/ 1M 3M)

4:04 lazybot: java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.

4:04 edbond: &(/ 1 3)

4:04 lazybot: ⇒ 1/3

4:04 edbond: &(type (/ 1 3))

4:04 lazybot: ⇒ clojure.lang.Ratio

5:11 WickedShell: say i want to spool up a series of identical worker threads, rather then copy pasting the code to create each thread, or call the create function several times with identical arguments is there a way to easily spawn all the threads? (best I've come up with is a for loop, which seems rather wrong in the clojure enviorment)

6:31 the-kenny: WickedShell: `dotimes'?

6:59 himangshuj: Need a bit of advice, I am running a few backend jobs in clojure, the jobs are being triggered using lein trampoline run which are being triggered via crontab, is there a framework container for running clojure code . I do not want a full fledged tomcat and quartz

7:09 WickedShell: the-kenny, yeah that does the trick quite nicely... thanks :P

7:47 bbloom: puredanger: hey, i'm super stoked about clojure.lang.TaggedLiteral, but, in a truly never satisfied way, i'd love to chat about a protocol for conversion to EDN: see http://dev.clojure.org/display/design/Representing+EDN

7:48 puredanger: if we had such a protocol, people could write very simple functions to transform their data types & get pretty printing for free

7:56 i'm also wondering. is the #< unreadable form now totally obsolete? ie unknown tags replace them?

8:14 the-kenny: himangshuj: why not just use a webserver embedded in your Clojure application? Immutant or so.

9:45 justin_smith: $mail himangshuj consider building uberjars and using jsvc

9:45 lazybot: Message saved.

9:47 justin_smith: running lein from crontab is as silly as running make/gcc from crontab, imho

10:29 dssedadddssd: /load -rs GlobalFind.mrc

10:31 /load -rs GlobalFind\GlobalFind.mrc

11:49 Confusionist: Is there a simple way to bring the functions from a namespace in scope in every other namespace of the code? I'm running a repl and would like to add some trace statements without having to go through the hassle to change my 'require' forms there and back again.

11:50 justin_smith: Confusionist: you can use tools.trace to add trace statements without altering the code or the target namespace

11:53 Confusionist: justin_smith, and that should work without having to explicitly call (clojure.tools.trace/trace ..._

11:53 TimMc: FSVO "altering"

11:53 Confusionist: ?

11:53 justin_smith: TimMc: well the file isn't altered

11:54 Confusionist: you would still need to call tools.trace, with your namespace or function as an argument

11:54 but this would be done from user

11:54 not from the namespace you are tracing

12:06 jacksonje: is there a way to "introspect" the keywords a function may take if its not documented?

12:21 underplank: Question about using the repl and Cider. Do most people swtich to the namespace of the file they are working in, and evaluate forms? or do people tend to just do things in the user namespace? Pro’s? cons?

12:24 wasamasa: I switch to the file namespace as soon as I've got something working together

12:28 underplank: is that because its easier to refer to the vars in that namespace when you are in the namespace?

12:28 wasamasa: uhuh

12:35 Cheery: trying to get myself a GLL parser.

12:35 managed to write a recognizer while ago.

12:40 tomjack: jacksonje: not really

12:41 consider (fn [m] (:foo m)) and many more complicated functions? also (fn [m] (k m)) for some non-literal k, etc

12:42 if it's a {:keys [...]} thing you can _try_ to grab that out of the (meta (:arglists #'your/fn)), but probably not very robustly

12:43 er, (:arglists (meta #'your/fn))

12:53 jacksonje: too bad, i was looking at for example, spit and :append, but its not in the doc, the meta or the source

12:58 jstew: I've got an app that I want a dead simple crud interface on. I'll be using compojure, and can write all of the routes myself, but is there anything that can do most of the work for me? basic get/post/put/delete on database backed resources.

13:05 bensu: jstew: have you looked at liberator?

13:11 jstew: I'm looking at liberator right now, as a matter of fact. :). I'm curious as to whether there are other options that I'm not considering.

13:21 TimMc: Huh, since when is .lein/repl-history a binary file?

13:21 justin_smith: wat

13:22 TimMc: ~/.lein/repl-history, not .lein-repl-history in each project

13:22 clojurebot: Excuse me?

13:22 TimMc: or maybe something is borked here...

13:22 justin_smith: TimMc: mine is repl forms

13:22 yeah, I think something on your end is borked

13:23 TimMc: Oh, and running `lein repl` outside of a project and hitting up-arrow gives me garbage. Just borked, then.

13:23 nkozo: I have modified some source from https://github.com/clojure/clojure , how I run the tests to see nothing is break?

13:24 puredanger: mvn clean test

13:24 nkozo: puredanger: thanks

13:25 puredanger: See http://dev.clojure.org/display/community/Developing+Patches for lots more info

13:27 nkozo: great

13:48 mcescher:

14:01 bitcycle: Hey all. How does one validate that a command-line argument is not-nil/not-null? here's what I've got so far: https://github.com/sochoa/compressit/blob/master/src/compress/core.clj

14:04 ztellman: bitcycle: in your particular case you can just do #(and % (< 0 % 0x10000))

14:04 that also will fail when the input is 'false', but that's not possible for your CLI use case

14:05 justin_smith: I also like using some-> for this generally (though it doesn't work with second position in <)

14:05 bitcycle: ztellman: sorry, I'm not sure I follow you. I copied the validation from somewhere else to give me a starting point. The -in argument is just a file path.

14:06 justin_smith: or you could just add identity to :validate

14:06 TimMc: :validate only takes one validator?

14:06 justin_smith: bitcycle: in that case, if you just want to test that it isn't nil, use :validate [some?]

14:07 ,(some? false)

14:07 clojurebot: true

14:07 justin_smith: ,(some? "")

14:07 clojurebot: true

14:07 justin_smith: ,(some? nil)

14:07 clojurebot: false

14:08 TimMc: bitcycle: How about this? :validate [some? "Must be provided", #(< 0 % 0x10000) "Must be a number between 0 and 65536"]

14:08 bitcycle: justin_smith: what is "some" in clojure? Is that reserved?

14:08 justin_smith: it's called some?

14:08 (doc some?)

14:08 clojurebot: "([x]); Returns true if x is not nil, false otherwise."

14:09 bitcycle: TimMc: That's awesome. I'll just need to check to see if the file exists instead of whether its a number between 0 and 65536.

14:09 irctc: I am new to clojure, but is not the point of having lazy seqs to be able to execute each element down the chain till you hit a non lazy operation. I am using using double map over a lazy seq(range 10). the second map executes after the first map has processed all the elements. Is there a way to be able to process elements in depth first manner?

14:09 bitcycle: justin_smith: interesting. I'm coming from Python/C++/Ruby/Bash/C# ... so forgive my silly questions.

14:10 justin_smith: no problem

14:10 bitcycle: check out http://conj.io

14:10 it has a nice overview of commonly used functions, most of core

14:11 bitcycle: sweet, ty.

14:11 tomjack: irctc: you are seeing an implementation detail

14:11 try it with (range 100)

14:11 justin_smith: irctc: sure, if you composed your maps as a transducer, that would be depth first, or if you applied the second map before the first was realized

14:11 tomjack: (not sure if I understood you)

14:12 justin_smith: ,(take 1 (map println (range 100)))

14:12 clojurebot: (0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\nnil)

14:12 justin_smith: that's what tomjack is referring to ^

14:17 tomjack: irctc: demo https://www.refheap.com/e3cc981908094464336680cdf

14:18 (of course, one should not typically do side-effects in a map function..)

14:19 justin_smith: but if you care about breadth vs. depth first, then you are doing side effects

14:20 irctc: <justin_smith> I will look into that. But if I try with (range 100) it is not sequential, it seems lazy(well first map processes about 10 elements the it goes to the second map. Some weird stuff:)). So do I really need transducers? I am trying to achieve LINQ behaviour if anyone is familiar with c#

14:21 justin_smith: transduers were a tangent

14:28 bitcycle: justin_smith: quick question. how would I coorce the argument here? ["-in" "what file to compress" :validate [some? "Must be provided", #(.exists (as-file))]]))

14:29 nm, I got it. :)

14:29 justin_smith: bitcycle: yeah, no coercion is needed for some? to work

14:37 bitcycle: also there is a more specific test you could use - string?

14:38 TimMc: bitcycle: You can also leave "file exists" stuff for later; it's not necessarily appropriate for first-pass validation.

14:38 e.g. checking that the file exists may not be relevant depending on some other options

14:39 validate only allows you to check each one in isolation

14:44 dfletcher: heh well justin_smith after our discussion yesterday and reading through https://github.com/edn-format/edn I actually ended up just wrapping java.util.Preferences. It's just much simpler and don't have to think about where they're stored on disk, and I don't really need to treat them as a collection. thanks for pushing me towards a globally mutable state though - when reading about clojure this seems like a big no-no, but a necessary evil

14:47 bitcycle: justin_smith: So, here's what I've got now. It looks right, but when I dont pass any argument to the jar, it doesn't report failure. https://github.com/sochoa/compressit/blob/master/src/compress/core.clj

14:55 elvis4526: I'm having with a production app deployed on a server with nginx

14:56 I'm sending some custom headers when calling the rest api on the frontend

14:56 when I run the app locally, the backend can catch the custom header

14:56 when the app is running with nginx (+ its over https), the backend doesn't seem to see the custom header

14:57 is there anything particular about ssl and HTTP in general that i'm not aware off ?

14:57 Is there an #http channel or something like that

15:10 justin_smith: elvis4526: my suspicion would be that nginx is ignoring and thus not forwarding the header

15:10 and #nginx would be a good place to ask regardless, I bet

16:03 danielcompton: cfleming: I was stoked to be able to run a Clojure REPL by right clicking on a pom.xml

16:42 kaiyin: Is there a clojure library for reading epub?

16:48 WickedShell: I think I'm being an idiot here, but I'm trying to import a java library, that I have in a jar file. No matter how I try and import from the commandline I can't seem to succeed in resolving the import. If I pass javap the jar file as the classpath it finds it succesfully, and I can see in clojure that the jar file is in the classpath, but I can't seem to import any of the classes or actually use them, any idea what might be happening? I suspect tha

16:48 t I am having a problem relating to java packages and paths but I'm pretty lost

16:52 Yoshee: hi

16:53 hi guys

16:54 justin_smith: WickedShell: how are you setting your classpath? are you using a tool like lein or boot?

16:55 Yoshee: Yes

16:55 WickedShell: justin_smith, I'm using lein the jar is specified through the :resource-paths at the moment (not sure that is actually correct)

16:55 Yoshee: WickedShell

16:55 How are you ?

16:56 justin_smith: in order of preference: ask for the jar as a maven dep, install it locally then require that, explicitly put the absolute path of the jar itself on your resource-paths

16:57 WickedShell: I've never touched maven, and had to build the jar myself, is it worth delving into maven for a jar that I will need to maintain?

16:57 justin_smith: WickedShell: no no, lein deps are just maven coords

16:57 so put it in your deps

16:58 if you had to build it, then you can also use mvn to install locally

16:58 but better if you can ask for it from a public repo of course

17:00 brainproxy: why does putting metadata on a function make invocations of that function slower?

17:00 WickedShell: yeah, I'm not sure if that's an option to do yet, the java files are actually generated content...

17:00 brainproxy: and is there anything I can do about it, i.e. if I really need to have metadata on the function

17:00 justin_smith: WickedShell: you can manually install any jar to your local maven cache, which is what lein uses to find deps

17:00 WickedShell: justin_smith, do you have a link handy related to adding a local jar to maven? (haven't found it via google yet)

17:01 justin_smith: brainproxy: usually metadata would go on vars, not functions

17:01 WickedShell: split developing between windows and *nix and maven is not an installed tool, or at least from the commandline

17:01 justin_smith: yes, it is an install tool

17:01 cfleming: danielcompton: Nice! yeah, I need to make some easier REPL start options.

17:02 justin_smith: $google mvn install arbitrary jar

17:02 lazybot: [How to include custom library into maven local repository?] http://www.mkyong.com/maven/how-to-include-library-manully-into-maven-local-repository/

17:02 danielcompton: cfleming: well that was about as easy as I could expect for a pom

17:02 justin_smith: WickedShell: ^ see link

17:02 oddcully: WickedShell: search for mvn install http://stackoverflow.com/questions/442230/how-to-manually-install-an-artifact-in-maven-2

17:03 justin_smith: WickedShell: anyway, it's a one liner with a few magic command line switches, and after that you can just require the jar like you would any other dep from lein

17:03 brainproxy: justin_smith: i need it on the funcs

17:04 justin_smith: brainproxy: interesting, I have never heard of that perf issue, but I wouldn't be surprised by it either

17:08 danielcompton: cfleming: but lein REPL invocation could be a touch easier

17:09 cfleming: danielcompton: Yeah - I plan to create the run config by default, and put a button in the empty toolwindow to start it.

17:09 danielcompton: cfleming: perfect

17:09 cfleming: danielcompton: I might actually also prompt the user if they try to send something to the REPL and there isn't one running.

17:10 danielcompton: cfleming: that would be good too

17:10 cfleming: danielcompton: BTW with lein you can also right-click on project.clj, as you did with pom.xml.

17:11 danielcompton: cfleming: question, is there a way to tell when a REPL is ready for use? After the startup, it doesn't have a visual indication that it's ready for input (that I could see)

17:11 cfleming: danielcompton: No, there's really no good way to tell that that I'm aware of. I'd love to fix that though, since several people have reported that loading things into the REPL while it's still starting can leave it in a funky state.

17:12 * danielcompton cfleming: I usually try (+ 1) before starting to load things

17:12 * danielcompton cfleming: in cider, your REPL is also your command window, so you can't start typing before you get a returned prompt

17:13 cfleming: danielcompton: Right, I don't focus the editor window until the REPL is supposedly ready, but it's not very reliable.

17:20 WickedShell: justin_smith, I think I got it in with maven, it shows up in deps tree, I still see the same problem on importing though http://pastebin.com/TVMCYSPb for reference Parser is a java class located in com.MAVLink, there is no clojure in the jar file

17:24 justin_smith: WickedShell: does Parser not have a package?

17:24 WickedShell: its within the com.Mavlink package

17:25 justin_smith: then the correct way to import it is (import com.MAVLink.Parser)

17:26 you don't need to quote it, because jvm class loading is used to resolve it before you import

17:26 WickedShell: so that's what I thought to, but that ends up throwing a ClassNotFoundException (and the jar is in the classpath)

17:27 justin_smith: is parser a normal class? is it an inner class? anything else that might be special about it?

17:27 if it is an inner class, use $ instead of .

17:27 com.MAVLink$Parser (but com is a terrible package to be using so I doubt it is that)

17:28 WickedShell: nope, parser is a very standard class

17:33 is there a method to dump *all* classes that the REPL can see? (outside of the simple presence of the classpath) I have to wonder if I built my JAR file wrong (although javap makes me feel better about it)

17:41 tomjack: "(wrong name: com/MAVLink/Parser)" interesting

17:41 is it `package com.mavlink` or `package com.MAVLink`?

17:42 WickedShell: package com.MAVLink;

17:42 which is the worstname in my opnion, I hate the selected casing on MAVLink.....

17:45 tomjack: and it's in com/MAVLink/Parser.class on the classpath? curious whether you're on a mac

17:46 I guess it hopefully shouldn't matter if it's inside a jar?

17:46 wait, what: (import 'Parser) ??

17:46 lazybot: tomjack: Uh, no. Why would you even ask?

17:46 WickedShell: it's a windows machine, if I dump the classpath within clojure I only see the jar of course

17:47 tomjack: you have it as just Parser.class on the classpath?

17:47 i.e. inside that jar

17:47 it needs to be at com/MAVLink/Parser.class inside the jar

17:49 WickedShell: *cough* um yeah that makes sense... not really sure why the entire thing doesn't just build that way... well imma go coerce it so that makes sense and see what happens

17:52 tomjack: then your import should be fixed to what justin_smith indicated

17:55 justin_smith: so the issue is that the file had a mismatched package / directory structire, sounds like

17:56 WickedShell: tomjack, justin_smith yeah that was it, thanks a lot! I admit the jar came out looking different then I was used to, but I expected that the creators new what they were doing with it... (clearly not)

19:01 danielcompton: What is the impact of having unused requires in a namespace? I presume it adds to compilation time, is there anything else?

19:20 the-kenny: danielcompton: The namespace might cause some side effects. Or some code walks through all project namespaces to do something.

19:21 danielcompton: the-kenny: ah yes, side effecting require's, my favourite

19:21 the-kenny: danielcompton: yeah :D

19:21 danielcompton: well. The other thing might be more valid.

19:47 afhammad: how can I add a local dependancy during development in leiningen?

19:48 irctc: \w

19:53 jlegler: Can anyone point me to any tutorials or example code of using http-kit with an async library that isn't websockets?

19:55 All I want to do is take get a request, asynchronously grab some data from postgres, and respond. Apparently it's the first time anyone has tried to do it.

19:55 Sorry, I'm really frustrated.

20:01 lvh: jlegler: I don't know to what extent http-kit does that, but aleph definitely does, and also uses the ring api

20:02 danielcompton: jlegler: you could have a look at https://crossclj.info/ns/http-kit/2.1.19/project.clj.html to see libraries which use http-kit

20:02 lvh: jlegler: more importantly, aleph uses manifold, which is a library specifically built around the idea of being able to do the plumbing between all of these async concepts :)

20:02 jlegler: also let-flow is basically the best thing ever <3

20:03 jlegler: I will take a look at it. I'm a Scala dev primarily, and it just kind of shocks me that the async is so bad. I have to be doing something wrong.

20:04 I like a lot about this language, but the async stuff is driving me kind of nuts.

20:07 Manifold looks good. This is more like how I expect an async library to work. Thank you.

20:19 maxpenguin: Hey I've got this in my project.clj: :profiles {:uberjar {:aot :all} :lib {:aot :none}}, but running lein with-profile lib uberjar it does aot

20:20 I want to have one clojure project that has a main with aot (so it can be used as a console app) but also can be built as a library (without aot, main .class etc.)

20:21 any suggestions or ideas?

20:23 TimMc: maxpenguin: Generally, a lib would not be an uberjar anyhow, not that that answers your question.

20:25 justin_smith: you could make an optional shim class or ns with main. or use the clojure.rt api or load inside a method at runtme so aot is not transitive to the lib code

20:26 maxpenguin: justin_smith: interesting, let me look into that - thanks :)

20:28 TimMc: maxpenguin: look at lein-otf for inspiration

20:29 maxpenguin: TimMc: thanks, will do

21:14 cmhobbs: just posted this in #clojure-beginners, anyone here have an idea?

21:14 hello, all! i'm new to clojure and i'm not sure what exactly this stack trace is pointing at. could this be an issue with my code or does it seem like i don't have the proper packages installed on my system? here's the error: https://gist.github.com/cmhobbs/151715947143a9f95aa6 and it appears to be complaining about this line: https://github.com/madetomeasure/madetomeasure/blob/readme_and_config/test/madetomeasure_api/test/routes/subscribers.cl

21:14 j#L10

21:15 migrations work just fine for me (with clj-sql-up). i'm on debian wheezy and i have postgres and the postgres jdbc drivers

21:19 TEttinger: cmhobbs, it seems like the lower error is the most relevant; the problem seems to be when it tries to load your db-spec

21:21 cmhobbs: TEttinger, i'll start looking that direction, thanks

21:22 TEttinger: cmhobbs, there seems like there might be a quirk here, though I have 0 experience with JDBC: https://github.com/madetomeasure/madetomeasure/blob/readme_and_config/src/madetomeasure_api/db/core.clj#L12

21:22 it says that the expected string has one ":" in it

21:22 but you're splitting into 3 parts and discarding the first

21:23 cmhobbs: TEttinger, i'll look there

21:23 thanks again

21:23 TEttinger: np

21:47 crimeminister: hey folks, are there any pedestal gurus about by any chance?

21:47 xeqi: ~anyone

21:47 clojurebot: anyone is anybody

21:49 crimeminister: in that case… I posted this on StackOverflow: http://stackoverflow.com/questions/29998012/how-does-one-configure-sibling-pedestal-routes-so-that-all-are-accessible-when-u

21:50 trying to decide if I've mucked up my terse routes or if I'm encountering something… odd

22:08 cmhobbs: TEttinger, just for reference, you were absolutely correct. i changed the database strings from "jdbc:postgresql://host/dbname?user=bob&password=123" to "jdbc:postgresql:bob:123@host/dbname" (the canonical jdbc format). i believe the split on ':' in db-spec was there to support the other connection string format

22:08 for whatever reason

22:08 thanks again for pointing me in the right direction

22:10 durka42: (inc TEttinger)

22:10 lazybot: ⇒ 52

22:19 TEttinger: cmhobbs, that's great! what's also great is you solved that, and i got ice cream!

22:19 (inc ice cream)

22:19 lazybot: ⇒ 1

22:32 david_____: hi there -- I recently built the dev clojure on my system and was interesting in beginning to contribute. Anyone have any pointers for tasks that are relatively simple that will help me get in the flow of contributing?

22:36 interested**

22:37 TimMc: david_____: For contributing to clojure core itself? That's relatively tough.

22:38 david_____: nope -- any libs

22:38 TimMc: Ah, OK. Well, leiningen has a set of issues labeled "newbie" that should be relatively low-hanging fruit.

22:42 david_____: awesome -- I will look into these thank you Tim

23:19 lvh: That also has the benefit that most folks are using lein, so your code will probably end up helping tons of folks

Logging service provided by n01se.net