Fork me on GitHub
#clojure
<
2016-04-22
>
pre04:04:07

Is anyone interested in exploring the serialization possibilities of Clojure’s s-expression into Amazon’s recently announce Ion s-expression notation? http://amznlabs.github.io/ion-docs/spec.html

darnok06:04:15

Hi, I'm trying to compile yesql locally and I've got this exception java.lang.ClassNotFoundException: yesql.types.Query. Did anyone get such exception?

darnok06:04:34

The strangest thing is that it compiles on my MacBook without any problems, but I get errors on my PC on Debian Stable.

hiredman06:04:08

when you say "trying to compile" what does that mean you are doing?

darnok06:04:32

Oh, yes simple_smile. I'mean "lein test-all"

hiredman06:04:08

are you sure you have checked out the same sha on places where it works and where it doesn't?

hiredman06:04:47

rm -rf target and try again

darnok06:04:58

I've forked yesql. Here's the repo: https://github.com/mrroman/yesql.

darnok06:04:41

I get the same exception.

darnok06:04:53

Tests pass with travis-ci too.

hiredman06:04:07

if you made changes, and are getting an error, then remove those changes and try it

darnok06:04:00

But it got compiled on the Mac and on Travis with the changes.

darnok06:04:03

The only problem is with PC with Debian Stable.

darnok06:04:02

Yeah, I know, it's strange.

hiredman06:04:15

it is much more likely to be some confusion in the test running process (you think it is passing on the mac, but it isn't) and your changes broke something

hiredman06:04:42

you should go back to the mac, rm -rf target and see if the tests still pass

darnok06:04:24

Ok, I'll try but it passes on the Travis too simple_smile.

hiredman06:04:55

what makes you say that?

gokul06:04:14

hi guys i'm facing issue of too large buffer size when i rquest an api here is the log "2016-04-18 12:35:47,390 (qtp1320509032-20) [INFO] : ([0m[34m[46mf15c[0m) [36mStarting [0m:post /api/v1/location/current/tempr/five for 192.168.0.8 {"origin" "<chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop>", "host" "192.168.0.15:7000", "user-agent" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36", "content-type" "application/json", "content-length" "51", "connection" "keep-alive", "accept" "/", "accept-language" "en-US,en;q=0.8,hi;q=0.6", "accept-encoding" "gzip, deflate", "postman-token" "5b16c467-e709-b616-a8a2-51bee3062e66", "cache-control" "no-cache"} 2016-04-18 12:35:47,403 (qtp1320509032-20) [INFO] : ([0m[34m[46mf15c[0m) 12.903034677.6177216 2016-04-18 12:35:47,832 (qtp1320509032-20) [INFO] : ([0m[34m[46mf15c[0m) {:latitude 12.9030346, :longitude 77.6177216} 2016-04-18 12:35:47,894 (qtp1320509032-20) [INFO] : ([0m[34m[46mf15c[0m) [36mFinished [0m:post /api/v1/location/current/tempr/five for 192.168.0.8 in ([33m506[0m ms) Status: [39m201[0m 2016-04-18 12:35:47,955 (qtp1320509032-20) [WARN] : (null) java.io.IOException: Response header too large at org.eclipse.jetty.http.HttpGenerator.generateResponse(HttpGenerator.java:400) at org.eclipse.jetty.server.HttpConnection$SendCallback.process(HttpConnection.java:637) at org.eclipse.jetty.util.IteratingCallback.processing(IteratingCallback.java:246) at org.eclipse.jetty.util.IteratingCallback.iterate(IteratingCallback.java:208) at org.eclipse.jetty.server.HttpConnection.send(HttpConnection.java:471) at org.eclipse.jetty.server.HttpChannel.sendResponse(HttpChannel.java:763) at org.eclipse.jetty.server.HttpChannel.write(HttpChannel.java:801) at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:142) at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:135) at org.eclipse.jetty.server.HttpOutput.close(HttpOutput.java:166) at org.eclipse.jetty.server.HttpWriter.close(HttpWriter.java:49) at java.io.PrintWriter.close(PrintWriter.java:339) at ring.util.servlet$set_body.invokeStatic(servlet.clj:89) at ring.util.servlet$set_body.invoke(servlet.clj:84) at ring.util.servlet$update_servlet_response.invokeStatic(servlet.clj:115) at ring.util.servlet$update_servlet_response.invoke(servlet.clj:107) at ring.adapter.jetty$proxy_handler$fn__7450.invoke(jetty.clj:26) at ring.adapter.jetty.proxy$org.eclipse.jetty.server.handler.AbstractHandler$ff19274a.handle(Unknown Source) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) at org.eclipse.jetty.server.Server.handle(Server.java:497) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) at java.lang.Thread.run(Thread.java:745) Caused by: java.nio.BufferOverflowException at java.nio.Buffer.nextPutIndex(Buffer.java:513) at java.nio.HeapByteBuffer.put(HeapByteBuffer.java:163) at org.eclipse.jetty.http.HttpGenerator.putSanitisedValue(HttpGenerator.java:1057) at org.eclipse.jetty.http.HttpGenerator.putTo(HttpGenerator.java:1079) at org.eclipse.jetty.http.HttpGenerator.generateHeaders(HttpGenerator.java:703) at org.eclipse.jetty.http.HttpGenerator.generateResponse(HttpGenerator.java:385) ... 25 more Commit failed " any anybody explain me the exact issue

darnok06:04:17

I said that I run build on my repo with the changes

hiredman06:04:07

do you have the full stacktrace of the error?

darnok06:04:53

should I paste it here?

hiredman06:04:15

a pastebin or a snippet would be best

darnok06:04:13

pastebin said that is on heavy load simple_smile.

hiredman06:04:27

I have decided I hate yesql, first using expectations, and now this

hiredman06:04:18

this file is importing the query type without loading the clojure file that creates the type

hiredman06:04:48

so of course you'll get an error about the type not existing, the real mystery is why it works anywhere else

hiredman06:04:42

what jvms are you using?

hiredman06:04:25

I suspect, that for some reason lein is loading namespaces for the tests in a different order, which could be the result of different jvms maybe or different lein versions

darnok06:04:36

I have 1.8.0_77. I've tested it on OpenJDK 64-Bit Server VM 1.7.0_95-b00 too.

darnok06:04:16

Ok, I've seen that Travis uses Oracle JDK build 1.7.0_76-b13

darnok06:04:28

I'll try to test it with that.

hiredman06:04:18

if you create a file called src/user.clj with the contents:

(alter-var-root #'clojure.core/*loading-verbosely* (constantly true))
that will print out the namespace loading information

darnok06:04:24

I have in the deb repo, Java HotSpot(TM) 64-Bit Server VM 1.7.0_80-b15. It still doesn't compile.

hiredman06:04:25

it will print out alot

hiredman06:04:15

but in theory you'll be able to compare that output to confirm that the namespaces are being loaded in a different order

darnok06:04:48

I put it in my fork and compare it with local.

darnok06:04:07

Thanks a lot. I'll let you know, what was the result.

hiredman06:04:49

I opened an issue on yesql

lucj0607:04:16

Hello, I’m using clj-http.client, and when issuing POST request it seems we need to give a stringified json body (www/post "" {:body "{\"username\":\"user\",\"password\":\"pass\"}" :accept :json :content-type "application/json" :throw-entire-message? true}). Any idea why passing the json directly does not work ?

hiredman07:04:04

you cannot pass json directly

hiredman07:04:14

json is a serialization format

hiredman07:04:53

are you asking why you cannot pass in the clojure data structures directly?

hiredman07:04:45

(I mean, I guess the string is the json, so by passing the string you are passing json directly)

plexus07:04:59

@hiredman @lucj06 according to the docs it does actually support that, from the README (client/post "" {:form-params {:foo "bar"} :content-type :json})

plexus07:04:37

but it also says

plexus07:04:41

;; optional dependencies
[cheshire] ;; for :as :json

plexus07:04:02

so maybe try including cheshire in your project.clj if you don't have it already

hiredman07:04:07

it is true, clj-http will do some encoding and decoding for you if you pass it the right options (:content-type :json)

hiredman07:04:55

but you aren't passing json directly, you are passing a clojure datastructure (or even jvm datastructure depending on your view point)

lucj0607:04:33

@hiredman: @plexus thanks guys, that makes the thing much more clear.

darnok08:04:34

@hiredman: I've fix this issue with yesql by adding yesql.types to (:require). I wonder how fast do they accept pull requests simple_smile.

darnok08:04:58

They have already 21 pull requests simple_smile. 22 would be that fix simple_smile.

meme310:04:30

I'm relatively new to Clojure (I'm half way through Clojure for the brave and true) and for a fun project I wanted to use a Java library in my Clojure program. In an example for the library there is this code:

server.addListener(new ServerAdapter() {
                @Override
                public void sessionAdded(SessionAddedEvent event) {
                    event.getSession().addListener(new SessionAdapter() {
                        @Override
                        public void packetReceived(PacketReceivedEvent event) {
                            // do more stuff with the event
                        }
                    });
                }

meme310:04:10

I am currently trying to execute that method including that build(Server server), I was recommended to use reify, but how exactly would I use it?

meme310:04:30

This code fails to work with Exception in thread "main" java.lang.IllegalArgumentException: only interfaces are supported

(. server addListener (reify ServerAdapter
                            (sessionAdded [SessionAddedEvent event])))

pastafari10:04:19

meme3: what is ServerAdapter?

meme310:04:47

The source? One second...

pastafari10:04:49

meme3: also `Note that the first parameter must be supplied to correspond to the target object ('this' in Java parlance). Thus methods for interfaces will take one more argument than do the interface declarations.`

meme310:04:46

@pastafari: Ah, ok, I'll see if that fixes it

meme310:04:05

Ok, what do you suggest?

pastafari10:04:19

@meme3: the error says you can only reify interfaces

pastafari10:04:29

@meme3 ServerAdapter is a class

darnok10:04:10

you have to use (proxy)

darnok10:04:41

(proxy [ServerAdapter] [] (sessionAdded [this event] )))

meme310:04:08

Hmmm, (. server addListener (proxy ServerAdapter [] (sessionAdded [this event])) seems to not work with: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol

darnok11:04:49

I made a mistake (writing from top of my head without checking :)). (proxy [ServerAdapter] [] (sessionAdded [event] )))

meme311:04:26

Awesome! Thanks 😉 should I do the same thing for the second event?

darnok11:04:44

Do you mean, how to implement another method in the ServerAdapter?

meme311:04:19

So I'm just trying to do the same thing

meme311:04:34

Also, how should I do a instanceof style thing?

meme311:04:56

instance?

darnok11:04:02

ok, so you want:

(proxy [ServerAdapter] [] 
  (sessionAdded [event] 
    (comment Here to put the method body))
  (sessionRemoved [event]
    (comment Here to put the method body)))

meme311:04:51

Awesome, I'm loving clojure so far 😄

darnok11:04:50

Here is an example (the second part of a snippet), how you can "switch" by class: http://clojuredocs.org/clojure.core/condp#example-542692cbc026201cdc326be2

darnok11:04:38

you're welcome simple_smile.

telent11:04:52

well, I'm impressed. just got my 15 month old abandonware project running again in only 30 minutes (haven't tried lein ancient yet thobut)

telent11:04:04

http://ww.telent.net/2014/12/8/ann_sledge_we_re_lost_in_music I've actually just been using youtube instead for the last year, but of course it's tricky finding Prince songs on youtube

lwhorton12:04:43

can someone point me to good reading on the rpoper way to write a macro that contains a macro?

lwhorton12:04:59

I feel like one macro is not “fully expanding” into another, which makes me believe I dont really understand fully what is going on.

lwhorton12:04:26

for example, I want to wrap some nicer looking behaviors into my clj.tests …

(deftest truth-test
  (when- "something is truthy"
    (is (= true false))))

curlyfry12:04:50

Hi, which book(s) would you guys recommend after finishing Clojure for the Brave and True? Perhaps something more intermediate rather than introductory.

borkdude12:04:28

@curlyfry: Maybe Applied Clojure (or Clojure Applied, can't remember the word order)

borkdude12:04:37

@curlyfry: Or The Joy of Clojure

curlyfry12:04:29

@borkdude: Cool, thanks! Any major difference between the two?

borkdude12:04:25

@curlyfry: TJoC: philosophical, Applied: best practices, build stuff

curlyfry12:04:07

@borkdude: Great, thanks again.

jstew12:04:39

Joy of Clojure is a great intermediate book. I second that recommendation

bojan.matic12:04:02

i have read clojure for brave and true and ordered “joy of clojure"

bojan.matic12:04:13

yes! validated! tnx @borkdude 😄

lucj0613:04:59

Hi, I’m working on my first CLojure project, kinda a consumer of RabbitMQ messages. At first I used a single file with all the function I needed. I’m cleaning this up and creating several files that I load in the main core.clj. Some functions (that are not in the same files) need the same clojars (like clj-http, log, …) what is the recommended way to load the commun lib ?

hans13:04:41

lucj06: you should use either leiningen (http://leiningen.org/) or boot (https://github.com/boot-clj/boot)

lucj0613:04:47

I’ve created the project with leiningen but I use the single core.clj file to put everything ...

lucj0613:04:26

so I’m spliting this file into several (smtp.clj, …) and load them in core.clj

bostonaholic13:04:04

@lucj06: check out #C053AK3F9

lucj0613:04:29

@bostonaholic: thanks, will do this

bojan.matic14:04:29

i realize i might be opening a can of worms here, but what is everyone’s thought on dynamic vs static typing? more and more I’m coming under the impression that the industry as a whole is leaning towards static typing being a better choice

bojan.matic14:04:46

how does core.typed compare? what are the benefits/drawbacks?

mpenet14:04:48

it's not all black/white

mpenet14:04:19

core.typed is not really usable in my experience, you're better of using something like Schema

bojan.matic14:04:55

has anyone seen “Types are like the Weather, Type Systems are like Weathermen - Matthias Felleisen”?

mpenet14:04:59

you can always disable most of the checks once you're confident you're code is "safe" with the latter

lwhorton14:04:45

if I have a clj file in test/clj/testing_util/core.clj and I try to run run-all-tests #”.*-test” .. it’s not picking up on my namespaces.. does that file have to be in a top level somewhere? do I need to set my ‘starting namespace’ higher?

tel14:04:32

bojan.matic mpenet: core.types isn’t usable… and that’s sad because it sort of feels like a failure of the gradually typed approach more than core.types as a technology.

tel14:04:56

I kind of want to believe it’ll work, but there’s a momentum barrier

Lambda/Sierra14:04:38

@lwhorton: clojure.test/run-all-tests does not search for files. It only searches namespaces that have already been loaded.

mpenet14:04:39

bojan.matic: it's hard to retrofit something that complex to a dyn language imho. It works as advertised, but it makes the dev workflow painful imho

lwhorton14:04:49

i’m using mike’s awesome https://github.com/mike-thompson-day8/cljsbuild-none-test-seed/issues/4 for using goog and require to load up all the files… so they’re all there (i can put a breakpoint in the index.html and inspect them all)

mpenet14:04:56

@bojan.matic: in haskell it's at the root of the language, it's more than just for checking

lwhorton15:04:01

@stuartsierra: it’s just for some reason unless I structure my items like /test/cljs/runner.cljs the runner doesn’t pick up on any other namespaces 😕

Lambda/Sierra15:04:20

If you're talking about Clojure*Script* test then I don't know.

Lambda/Sierra15:04:25

clojure.test in Clojure (JVM) and whatever ClojureScript has now — they don't know anything about each other.

lwhorton15:04:28

hmm i’ll keep digging

Lambda/Sierra15:04:04

You said you had a file named testing_util/core.clj, which I took to mean you were talking about clojure.test on Clojure(JVM)

mpenet15:04:59

@bojan.matic: I don't see the industry shifting one way or the other really

bojan.matic15:04:32

@mpenet: really? All I seem to be finding is people gravitating away from dynamic typing, I can't find counter examples

mpenet15:04:41

plenty of dyn languages do fine with other ways of checking code correctness, without hindering productivity

bojan.matic15:04:45

Maybe I hang out in the wrong clubs

mpenet15:04:55

depends on the context/domain

mpenet15:04:55

plenty of ppl move back to beam langs for instance

mpenet15:04:03

erlang/elixir

mpenet15:04:37

tools like dyalizer are just good enough

sveri17:04:58

@bojan.matic Regarding the fact that there surely are millions of developers world wide I think it is hard to say that there is a certain movement. Especially in niches like clojure / erlang / haskell. I mean, it was pretty obvious for node.js, as well as C and Java. Also C# has a big movement, being backed by Microsoft and then there is all the Apple stuff (Objective C / Swift I guess). But apart from that? For instance, not long ago Perl 6 was released. How would you tell if there is a movement to it or away from it? As long as you are not part of that community I guess it is almost impossible to do so.

spieden18:04:45

matthias felleisen gave a great keynote at clojurewest speaking to some of these typing matters and core.typed tangentially https://www.youtube.com/watch?v=XTl7Jn_kmio

dg18:04:27

Pretty cool to have the keynote be so... challenging.

spieden18:04:22

my take-away is that i’ll use a static type checker when someone makes a good one 😃

spieden18:04:53

meanwhile contracts and generative testing seem to work well

spieden18:04:44

.. and idempotency everywhere to make bugs recoverable

ghadi19:04:38

IMHO Transit or Fressian suffice

bojan.matic19:04:12

@spieden: i actually shared that same talk little further up 😄

spieden19:04:06

bojan.matic: ah whoops, didn’t see that. i was there

pre19:04:19

@ghadi: ion provides blob, clob, and structs and type annotations, in addition to the s-expression “container type.” Would it be possible to explore a transit -> ion and vice versa as a lossless transformation?

ghadi19:04:34

fressian handles all of that

ghadi19:04:43

transit doesn't (i think)

pre19:04:58

I’m familiar with transit, but not fressian.

ghadi19:04:14

fressian is datomic's internal format -- basically binary EDN

ghadi19:04:42

but it is public as clojure.data.fressian

pre19:04:00

My question is not whether ion is better than edn/transit, but to understand the transformation process between them, whether it will be lossy etc.,

hiredman19:04:39

I thought I saw something in the docs about ion's own json encoding being lossy

pre19:04:05

I would like to try a sample out this weekend, and would be curious to see if anyone has pointers.

hiredman19:04:15

I am wrong I guess

hiredman19:04:03

I would love to read a history of ion, they include a symbol type, and their extension mechanism is called sexps in the spec

pre19:04:16

From what I read, it provides a "pure sequence-of-values data model”, which is compelling.

hiredman19:04:29

well, it isn't that compelling from clojure because of all the other options people have mentioned that provide that, but it is an interesting case of convergent evolution

pre19:04:44

interesting things happen at convergence