#clojure logs

2016-02-09

00:45wombawombaI'm trying to generate data that conforms to a prismatic schema. However, different fields of the data need to conform to certain constraints (on the form `(= field_x (f {:y field_y :z field_z ...}))`). I want my generator to take a schema and a collection of such constraints, and produce valid output when possible. Any ideas on how to get started on this?
00:45wombawombaI was thinking I might be able to leverage core.logic somehow, but I'm not sure
00:46wombawombaspecifically I'm thinking that each constraint would be on the form `{:f some-fn :vars {:y [:path :to :y :in :schema] ...}}`
04:41noncomwombawomba: yeah, well, while thinking about it, core.logic seems like it may be of help.. but i am not too much into it, so i cannot really say. you could try #minikanren to ask about core.logic
04:42noncomwombawomba: other than that, a simple solution comes to my mind - something like "combined generators" - akin to combined parsers
04:45noncomwombawomba: you can generate the datastructure level-by-level, using some grammar to describe it, like the L-ssytems
04:54jonathanjdoes clojure.java.io/copy disturb the input?
04:55jonathanji have to pass an InputStream to a function to render, but i would first like to parse it as XML (to extract some information)
04:55noncomjonathanj: disturb the input?
04:55jonathanjthere is a possibility the stream is not rewindable, how do i get two copies?
04:56noncomummm idk, why not just work with streams?
04:56noncomcopy is just a quick function for an easy task.. not sure it can do what you're asking..
04:56jonathanjsorry, i don't understand what you're asking
04:56jonathanji have one stream, i need to do two things with it
04:56noncom<jonathanj> does clojure.java.io/copy disturb the input?
04:56noncom^^ disturb
04:57jonathanjif at all possible i'd like to avoid trying to store all the content in memory as byte[]
04:58noncomjonathanj: see the source: https://github.com/clojure/clojure/blob/2c9ff46454ebf34b14ab4612f691b3c93031b362/src/clj/clojure/java/io.clj#L391 the function is very bare-bones
04:58noncomif i were you then dealing with any more or less complex task on working with streams, i'd simply write the logic i need manually
04:59noncomnot sure if you can coerce (copy) to do anything else than just copy
04:59jonathanjeven without copy, is it possibly to clone the original stream somehow?
05:00noncomjonathanj: depends on what you mean by "clone"
05:00noncomsure, you can read data and do two different tasks with it
05:01noncomthe stream is read in chunks, so you get these chunks on every "read"
05:01noncomyou always read a stream into a buffer of a fixed size
05:01noncomdoes it make any sense to you?
05:02jonathanjnot really, no
05:02noncomwhat is your task, exactly?
05:02jonathanjthe two tasks are: render an XML document (with flying saucer) and parse the XML document to extract information from it
05:03jonathanji'm not sure how reading chunks out of the stream actually help me achieve both of those tasks unless i read the entire contents of the stream
05:03noncomso, you 1) read the xml doc from a file, 2) send it to the renderer, 3) extract the info from it?
05:03noncomjonathanj: that's the point: "no how will it help you" :)
05:03noncomjonathanj: you simply need to read it all in order to really process it
05:04noncomand when you've read it all, there you have it - you can run several tasks on that data
05:05noncomi don't really see any problem here unless the xml is really big
05:05noncombut then, rendering it would also be pointless
05:06noncomxml is such a thing, it has the opening and closing tags.. you can't really make sense out of the document if you don't have 100% of it
05:06MasseRStreaming xml?
05:06MasseRIt's a thing
05:07MasseRBut you probably need to have a schema of the document first
05:21jonathanjif i'm using clojure.data.xml, how can i produce a org.w3c.dom.Document?
06:08Kah0onacd /#clojure-beginners
06:08Kah0onalol
06:09Kah0onaQuestion: I am developing a ring app, using compojure.api. But when I change my api definitions, the changes aren't picked up. I have wrap-reload as middle ware in place. Should that do it, or am I missing something
06:11jonathanjKah0ona: maybe https://github.com/weavejester/lein-ring might be helpful to you?
06:12Kah0onaok so `lein ring server` should already do the trick?
06:13Kah0onacan it be because of compojure.api requiring its routes to be declared in a macro? Are macro's re-expanded after route definitions have changed?
06:13jonathanjAssuming that auto-reload? is enabled and the code you're changing is in reload-paths
06:13Kah0onaokay
06:13Kah0onaand then it can be inside (defroutes ) and it will work?
06:13jonathanjI'm pretty sure that lein-ring just reloads on file changes, so as long as the file actually changes, it should work regardless of what the code does.
06:14Kah0onaanother thing I am confused about with lein ring server --> stuff like (println ) statements arent displayed anywhere. So should I opt for a development flow where i use some (start-server) function that starts up jetty?
06:14Kah0onaor will `lein ring server` provide a repl as well
06:15jonathanjthere is an :nrepl option you can use to have lein-ring start an nrepl, that you can connect to with cider or whatever tools you prefer
06:16jonathanji think lein-ring is the thing that watches for file changes, so if you're not running your code via that then, unless you have something else in place, nothing will be reloading
06:17Kah0onaokay so then it would be:
06:17Kah0onastart lein ring server with nrepl option,
06:17Kah0onaconnect to it from a different lein repl session with :connect ..... added?
06:17jonathanjyou can also use `lein repl :connect the_host:the_port` to just get a plain clojure REPL if you're not using cider or such
06:17Kah0onaalright, i just noticed i dont have auto-reload? is there
06:17jonathanjKah0ona: :auto-reload? (according to the docs) is true by default for a dev environment
06:18Kah0onahmmm
06:18Kah0onaokay
06:18jonathanjyou can try explicitly setting it to true but the docs indicate that shouldn't be necessary
06:20Kah0onayeah, okay thanks for your info. will try some stuff and try to make it work with lein-ring
06:21jonathanjperhaps try minimizing your code while you're debugging it
06:21jonathanjby removing middleware and such, or creating a new ring application with the simplest possible code
06:22jonathanjalso read the lein-ring README again to make sure you didn't forget to set something (like :ring) or you didn't put it in the wrong key, etc.
07:14Kah0onaok it works now, thanks!
08:09ashnur"Could not find tag parser for js/Object" why does it need a tag parser? can't it just use it as a symbol
08:09ashnur?
08:11ashnuri took some edn i generated and put it into some weird thing called "ankha"
09:17lxsameerwhat does ^{:a 2} means ? (^ part)
09:20opqdonutit means "attach metadata to the next expression"
09:20opqdonutmetadata is used for e.g. type hints, doc strings
09:21opqdonut,(meta #'map)
09:21clojurebot{:arglists ([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & ...]), :doc "Returns a lazy sequence consisting of the result of applying f to\n the set of first items of each coll, followed by applying f to the\n set of second items in each coll, until any one of the colls is\n exhausted. Any remaining items in other colls are ignored. Function\n f should accept number-of-colls arguments. Retu...
09:22opqdonut,(meta (read-string "^{:a 2} foo"))
09:22clojurebot{:a 2}
09:53fatsaucissonHi there
09:54noncomfatsaucisson: hi
09:55noncomashnur: depends on what you're actually doing
09:55noncomif you don't eval on read, you can treat it as a symbol..?
09:56ashnuri don't want to treat it :), i just wanted to look at it, i didn't know that that ankha thing will try to eval it or something
09:56fatsaucissonI've issues with a macro I'm writing, can I ask that here or this a totally another purpose chan ?
09:57pbxsounds perfect for this channel fatsaucisson
09:59noncomfatsaucisson: yes sure you can
10:01fatsaucissonCool, I'm writing a macro that expands and works well in the REPL, but when called in a callback function (that's an ircbot) the code fail and drop a ClassCastException where String cannot be cast to IFn
10:02noncomfatsaucisson: use refheap to post your code
10:02noncomexample
10:02noncomashnur: hmmmm
10:02fatsaucissonrefheap (defmacro command
10:02fatsaucisson [name input suite & forms]
10:02fatsaucisson `(when (.startsWith ~input ~name)
10:02fatsaucisson (let [~suite (string/replace-first ~input (re-pattern ~name) "")]
10:02fatsaucisson ~@forms)))
10:03noncomfatsaucisson: it's https://www.refheap.com/ XD
10:03noncombut ok
10:03fatsaucissonwoops, well here's the macro
10:03noncomthis is small enough to grasp here
10:03fatsaucissonnot that big
10:04noncomhmmmm
10:04noncomand what is the stack trace?
10:05fatsaucissonhttps://www.refheap.com/114608
10:06fatsaucissonthe lib used is irclj i link you the error callback
10:07noncomfatsaucisson: well, looks like somewhere you end up using a string as a function
10:07noncom,("heeeey" 1 2 3)
10:07clojurebot#error {\n :cause "java.lang.String cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.String cannot be cast to clojure.lang.IFn"\n :at [sandbox$eval25 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval25 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval25 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.java" 6...
10:07noncomsee, same error
10:08fatsaucissonwell i understand that
10:08fatsaucissonbut i don't point where
10:09noncomhmmm
10:10fatsaucissoni refhead some use case for you making an idea
10:12noncomwfatsaucisson: well, it is very hard to say.. many things can happen. especially that we don't know what 'forms you're passing in
10:13fatsaucissonhere : https://www.refheap.com/114609
10:15fatsaucissonwell i copy/past to quick there is error in the refhead
10:16fatsaucissonhere corrected one : https://www.refheap.com/114610
10:19noncomfatsaucisson: hmmm, well, doing (println ~@forms) before you call ~@forms prints nil...
10:21noncomfatsaucisson: because what's in () gets evaluated before it is passed to the macro
10:23lumathe problem is in the command macro
10:23noncomfatsaucisson: that's one thing i have found that you're probably expecting to work the other way
10:23noncomluma what do you think?
10:23noncomluma: i'm actually a bit puzzled by this one
10:23lumain the errorcallback, the command macro expands to (when (.startsWith 'text "!echo") ...)
10:24fatsaucissonyeah
10:24noncomahh, that
10:25fatsaucissonoh you mean 'text and not text ?
10:25noncomthat thing
10:25noncomit's call your macro with a macro thing :)
10:25lumayes, i mean 'text, the symbol text
10:26lumanot whatever that symbol would resolve to, because that isn't known at compile time (when the macro is expanded)
10:26noncomand you likely can't use (resolve) because it's a local variable
10:26noncomright?
10:26clojurebotright is not wrong
10:26lumayou can
10:27lumayou can't
10:27lumabecause the symbol is just a symbol, it doesn't resolve to anything at that point
10:27fatsaucissonyeah but it's in a context where that symbol is bind to something no?
10:28lumano
10:28lumait will be at runtime
10:28fatsaucissonYeah at runtime
10:29fatsaucissonthat's what i want
10:29lumabut not during macro expansion
10:29fatsaucissonI actually want the symbol text and the symbol suite
10:30lumahmm, maybe i misread your code
10:30lumalet me take another look at it
10:30fatsaucissonin fact after a macroexpansion errorcallback become goodcallback
10:31fatsaucissonor at least I think it does
10:31lumayeah, i see my mistake, i thought that the when was outside the syntax-quote
10:31lumasorry
10:33fatsaucissonI don't think it's inside the irclj lib, because the callback function is pass at Runtime so it should already be macroexpand
10:33lumayes, it was my mistake
10:34lumai plugged that into repl and it seems to work (although i don't understand why you bind suite to "" inside errorcallback and never use that binding)
10:35fatsaucissonif I don' bind it, it does not want to compile
10:35fatsaucissonis there an other way to declare it ?
10:37lumayou don't need to "declare" it
10:38lumayour macro is generating the let binding for it
10:39noncomyeah, just use like (let [suite# (something) ...] ...)
10:40lumano
10:40lumayou don't want to do that here
10:40lumayou want to give the symbol as a parameter for the macro so that you can use that symbol in the forms
10:40noncomoh
10:41lumaseems to work for me: https://www.refheap.com/114611
10:41fatsaucissonerrorcallback function works properly…
10:41fatsaucissonI don't get it
10:42fatsaucissonthat's irclj doing obscure stuff then
10:42lumawhat is the actual error that you get?
10:44fatsaucissonWhen I give errorcallback as a callback function for irclj (do that stuff each time you receive an irc message) it returns an error when receiving a message
10:44fatsaucissonthat's not the case with goodcallback
10:46fatsaucissonok
10:46fatsaucissonso now it works properly
10:46fatsaucissonand I have no idea why
10:46fatsaucissonhow bizarre
10:57fatsaucissonwell
10:59fatsaucissonit seems that simplifying the field accessed in the args worked (just picked text, nick, target, host)
10:59fatsaucissonwhereas when i bind all the fields that somehow breaks
10:59fatsaucissonthat's really strange
11:00fatsaucissonno
11:00fatsaucissonok
11:00fatsaucissongot it
11:00fatsaucissonthere was a field named command
11:00fatsaucisson
11:01fatsaucissonwow sorry for getting you involved in a mistake of that level
11:10fatsaucissonOk, just another macro question
11:13fatsaucissoni have my command macro, now i want to write a macro doing something like this https://www.refheap.com/114614
11:14fatsaucissonhow can I do in order to rewrite the list of command ?
11:18lumasomething like this: https://www.refheap.com/114615
11:20fatsaucissonok, that's exactly the pattern I was looking for !
11:20fatsaucissonThx
11:49python476hi there
11:49fatsaucissonI'm leaving, bye. Have a nice day.
11:50fatsaucissonpython476 : Hi
11:50python476I'm struggling hard between cljs and dom collections
11:50python476so far people managed to make a ISeq out of HTMLCollection, but mapping #(... .-name ...) yields 'ReferenceError: proxy is not defined'
11:54fatsaucissonare you in a browser, or just with node ?
11:54python476in browser sorry
11:55python476in a jsbin sandbox too
11:56fatsaucissonokay, seems like ecmascript6 support thing. Can't help you on that one. GL
11:57python476aight
13:03TristeFigurePossible bug : let is reported as a special form in the doc but (special-symbol? 'let) returns false. Under the hood, special-symbol? checks for the presence of the symbol as a key in (. clojure.lang.Compiler specials). 'let is not in this map but 'let* is. (special-symbol? 'let*) returns true. Should I report this ?
13:04justin_smithTristeFigure: let* is actually a special form, let is a macro that expands to a call to let*, I forget the rationale, but there is one for falsely reporting let is special
13:04justin_smithTristeFigure: see also fn vs. fn*, same scenario
13:05justin_smith,(special-symbol? 'fn)
13:05clojurebotfalse
13:05justin_smith,(special-symbol? 'fn*)
13:05clojurebottrue
13:06justin_smithTristeFigure: I think the doc is just oversimplifying for the sake of clarity, those are macros not special forms (the difference is that the macros support destructuring and the * version special forms they expand to do not)
13:12TristeFigurejustin_smith: okay then. Anyway, special-symbol? is mostly an obscure function ... unless you happen to be writing a debugger !
13:18ekryynhello all !
13:25ekryynI am new to clojure and I'm struggling with a need that comes very often
13:26ekryynsuppose we have (defn create-cell [color x y] {:color color :x x :y y})
13:27ekryynand a vector of coord under that form [ [1 2] [10 20] [5 9] ]
13:27ekryynwhat is a good way to create 3 cells with :color fixed to "blue" ?
13:27ekryynfrom this set of coords
13:29justin_smith,(map (fn [[x y]] {:color "blue" :x x :y y}) [[1 2] [10 20] [5 9]])
13:29clojurebot({:color "blue", :x 1, :y 2} {:color "blue", :x 10, :y 20} {:color "blue", :x 5, :y 9})
13:29justin_smith,(for [[x y] [[1 2] [10 20] [5 9]]] {:color "blue" :x x :y y}) ; alternately
13:29clojurebot({:color "blue", :x 1, :y 2} {:color "blue", :x 10, :y 20} {:color "blue", :x 5, :y 9})
13:30ekryynI really want to use "create-cell"
13:30justin_smithwhy?
13:30clojurebotwhy is the ram gone
13:30ekryynbecause it's supposed to hold the "implementation" of the cell, wich I simplified to a dict
13:30justin_smithekryyn: (map #(apply create-cell "blue" %) ...)
13:30ekryynthe cell might be represented differently
13:31justin_smithekryyn: hiding data representation is not idiomatic in clojure
13:32ekryynjustin : according to the doc, apply will prepend x and y, so i'll end up with calls like : (create-cell 1 2 "blue")
13:32justin_smithekryyn: though you could implement a protocol if you plan on making multiple implementations and swapping them out
13:32justin_smithekryyn: no
13:32justin_smiththat is false
13:32justin_smith,(apply list 1 [2 3])
13:32clojurebot(1 2 3)
13:32ekryynok, but if my cell representation is not suitable anymore ?
13:32justin_smiththen change your code
13:32ekryynthat means all the places that potentially create cells
13:33mmasticCan core.async do state? or do I need a ref type in addition?
13:34justin_smithekryyn: if you plan on swapping out implementations, the idiomatic way to do that is a protocol, but that's about abstracting behaviors typically rather than just data structure
13:34justin_smithmmastic: core.async is 100% imperative, it isn't even fp
13:34justin_smithit's all state
13:35mmasticOh yeah but I mean, can it do *my* state? :P like, can I have a channel that stores a number that I could manipulate over time, for instance?
13:35ekryynok justin, I re-read apply doc and I guess it's clear now
13:36ekryynThank you for the insight
13:37justin_smithmmastic: you could have (go-loop [state nil] (let [command (alts! change-state send-state)] ... (recur new-state)) (very rough sketch)
13:38justin_smithekryyn: np. my main point about abstracting data representations (as opposed to behaviors) is that we don't do much information hiding, and don't need it as much because things are for the most part default immutable. So this leads to a different kind of code hygeine, if that makes any sense.
13:38mmasticjustin_smith: Oh pretty cool, like seriously a tail-recursive loop, yeah?
13:38justin_smithekryyn: instead of hiding a data structure in a constructor function, we would be more likely to make a protocol, and implement that using various data structures / behaviors (though in practice all would be records, which act like maps for data access)
13:39justin_smithmmastic: right, where you either send or receive a value based on that alts! for each message, and persist any changed value with recur, and send any changed value back to the channel requested
13:39justin_smithmmastic: a get value request would look like [c] where c is the channel to send back on
13:40mmasticLove it, I'll try it out now. Thanks a lot already ^^
13:40justin_smithmmastic: that's how I do state with message passing at least. You can also just use an atom / ref / agent where that makes sense :P
13:41ekryynjustin_smith: I'm not sure I really understand. Often, development process is done by enriching structure as features come in
13:41mmasticYeah, I'm trying to avoid it. State makes me cry. Imagine what explicit ref state does to me.. :P
13:42justin_smithekryyn: in clojure "enriching structure" usually means attaching a new key to a hash map, and the functions that don't use that key can ignore it
13:42justin_smithmmastic: but core.async is just a big old state dance
13:44mmasticTrue, and Haskeller me still prefers FRP, but I'm getting that a lot of people like it a lot and prefer it over that, Rich saying it's simpler, plus GUI libraries plug to it out of the box, so it's fair to give it a try.
13:44ekryynjustin_smith: ok it's hard for me to see how things come together in the end. I have a lot to learn yet. Thank you anyway
13:44mmasticTransitioning over is really hard for me but I'm really drawn to Lisp.
13:45justin_smithekryyn: np, and of course you can implement these things however makes sense for your app, just trying to provide the rationale for our usual idioms.
13:45ekryynjustin_smith: yes it makes sense, how do you look for the usual idioms in specific situations ? What is the best resource ?
13:46justin_smithekryyn: there are some great books out there, like Joy of Clojure, Clojure Applied in particular
13:46ekryynok, cheers
13:47justin_smithekryyn: also there are often opinionated clojure devs here or on the clojurians slack channel who are willing to argue about design choices :)
13:47sdegutisUsing "Components" for an entire web app /seems/ really nice in theory.
13:47sdegutisBut in practice, then you have a chicken/egg problem.
13:47sdegutisThe router and other services all depend on each other.
13:47justin_smithsdegutis: I solve that by splitting components
13:48sdegutisjustin_smith: Even if you have a lot of components, the fact is that the router depends on them, and somehow they have to be usable within the router.
13:48justin_smithsdegutis: for example, I have a "conduit" - a channel of communication. I split this into the raw communication facility, and the abstractions on top of it like routing etc. That way each channel knows how to send something on the other
13:48justin_smithbecause all the routing / top level mechanisms have access to the sending mechanisms of all the others
13:49justin_smithbecause the sending facility is separated and doesn't need access to anything else
13:49justin_smithsdegutis: same with components and a router, you can separate any common thing that the router needs that are also needed by something using the router
13:49justin_smithsplit it and pull it together at the top
13:50justin_smithsdegutis: true loops can be fixed with top level bindings, but they should be rare
13:54sdegutisjustin_smith: ahh so your router is pretty "dumb" then, and just translates Ring messages (via something like weavejester/clout) into messages to go over your transport, i.e. a function to call and the parameters to give it, and then just send it over?
13:54justin_smithsdegutis: also, a component can put a promise in the system map that something further down delivers to, if you need to retain modularity
13:55justin_smithsdegutis: oh, the routing I was talking about just now was message routing, but for my http router what I do is write components that implement ring middleware to provide their functionality, and the http-router is at the top level, nobody else needs its data
13:55justin_smithI don't provide the endpoints themselves through component though (I guess I could...)
13:55sdegutisjustin_smith: huh, using middleware for core business functionality? never heard of that before
13:56justin_smithsdegutis: eg. my db component passes along a wrapper that provides a handle to the db connection in the request map
13:57justin_smithin the form of a ring middleware, of course
13:58sdegutisjustin_smith: oh yeah that makes more sense.. I have a middlware that passes the db, another one that checks if you're logged in and if so assoc's the logged in user, etc
13:58sdegutisactually no "etc" those are literally the only two
13:58sdegutisBut now I think I have to have one that passes in the top-level "system" component, so that routes can do stuff with it.
13:59justin_smithsdegutis: couldn't you just make the http-server/router component pull in all the other components?
14:03sdegutisjustin_smith: I think so... but then it has to put each of them into a middleware so that routes can actually have access to them...
14:03sdegutisjustin_smith: and then that gets into confusion about object lifetimes, regarding objects which have a strong hold on other, which confuses me...
14:03justin_smithsdegutis: see, I did the opposite, and created middlewares in each component then applied them in the http-server component, same result though
14:03sdegutisjustin_smith: something about object retain cycles
14:04sdegutisjustin_smith: hmm
14:04sdegutisI wonder, in Clojure 1.8 is it possible to use the built-in socket server instead of jetty/ring-adapter?
14:04justin_smithlifetimes of what objects? anything that ends up in a component map implicitly should have the same lifetime as the component system itself
14:04sdegutisI suppose.
14:04justin_smithsdegutis: feel like implementing http? the socket server is just tcp
14:04sdegutisMan, I haven't been this confused in years.
14:05sdegutisjustin_smith: ah
14:05justin_smithhaha
14:05justin_smithsdegutis: getting confused regularly is a good habit, and unlike eg. drinking lots of whisky this confusion will even likely lead to learning something valuable other than "that's what it feels like to be hung over"
14:06justin_smithfree life advice
14:13m1dnight_Would a library for giphy be something reasonable to publish on Clojars?
14:13m1dnight_I want to publish something :p
14:13justin_smithm1dnight_: what would a giphy lib do?
14:14m1dnight_Search for example
14:14m1dnight_It's something trivial but I figured why not
14:14m1dnight_Hence the question
14:18timvisherhas anyone used `clj-http 2.0.0` to make a `TLSv1.1` request on Java 7?
14:19timvishercome on justin_smith, save my bacon like you always do :P
14:34sdegutisI wouldn't mind a nice gif library, yeah.
14:34sdegutisI don't know how to use all those fancy Adobe softwares, so it's really hard to hit /r/gif's or imgur's front pages.
14:35amalloym1dnight_: if a thing is written in clojure, and does something that at least one person (you) would want to do, then it is a good candidate for putting on clojars
14:45noncom|2what do you typically have for clojure in emacs? CIDER, clojure-mode... anything else?
14:45justin_smithtimvisher: day job :P - sorry I have never explicitly used TLSv1.1 (though maybe I accidentally used it by making an https request?)
15:09timvisherjustin_smith: thanks as always for the response. the fix appears to be to upgrade to java 8
15:09timvisheramazingly
15:09justin_smithhmph
15:10timvisherthere must be a way to get java 7 to do this but it's beyond me :)
15:30xemdetiajava 7 can do sslv3 to tls v1.2, I just don't know how clj-http works
15:32xemdetiayou need to tune the jce though I think
15:32xemdetianot usually
15:33xemdetiaUsually some combination of SSLContext.getInstance() w/ https://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#SSLContext
15:36xemdetiaagain you can sometimes tune this externally through -D options
15:36timvisherhow do i tell `clojure.java.jdbc/insert!` to use `CURRENT_TIMESTAMP` or `NOW` for a value?
15:37timvisherxemdetia: i've seen mention of a `https.protocols` system property
15:37timvisherthat seems to have no effect on anything when i attempt to use it though
15:37xemdetiait depends on the JCE driver you are using
15:37xemdetiaI am aware of 10
15:38timvisherwhew
15:38xemdetiathe flags are implementation specific
15:38timvisherit's apache httpcomponents under the hood
15:38timvisheris that what you mean?
15:38xemdetiano, I am talking specifically about the cryptography engine
15:39timvisherhttps://gist.github.com/e94682655756035c945a
15:39timvisherdoes that give you any clues?
15:46xemdetiawhat is your default JCE driver? are you on a sunjsse2 stack with oracle jvm? are you on openjdk?
15:46xemdetialots of questions
15:47timvisherxemdetia: lots of questions indeed.
15:47timvisherjava version "1.7.0_95"
15:47timvisherOpenJDK Runtime Environment (IcedTea 2.6.4) (7u95-2.6.4-0ubuntu0.14.04.1)
15:47timvisherOpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode)
15:47timvisheri honestly don't know what the default JCE driver is
15:47xemdetiaand you are using clj-http right
15:52xemdetiaI mean I don't know how the org.apache.http.conn.ssl is different than other tls implementations
15:52xemdetianot usually my tool of choice
15:52xemdetiadid you check to see if the remote can even do tls 1.1 or tls 1.2?
15:52xemdetiahow did you scan the port?
15:53xemdetiaif you have openssl 1.0.1 or later you can just do openssl s_client -connect host:port -tls1, openssl s_client -connect host:port -tls1_1 and openssl s_client -connect host:port -tls1_2
15:53timvisherxemdetia: the story is that the service used to support 1.0, 1.1, and 1.2
15:53timvisherthey are turning of 1.0 soon
15:54timvisherand we're discovering that our client appears to be unable to speak anything else
15:54xemdetiathis is common
15:54xemdetiaespecially if it was something that was built around the time of openssl 0.9.8
15:54timvisherif we bump to java 8, which supposedly use tlsv1.2 by default (i'm not sure what tha means) then everything just starts working
15:54xemdetiahttps://github.com/dakrone/clj-http/blob/master/src/clj_http/conn_mgr.clj#L35
15:54xemdetiahere you go
15:54xemdetiait is probably this
15:55timvisherthat's extremely interesting
15:55xemdetiatimvisher, because of security changes and the fact java is trying to be a stable platform
15:55timvisheri would think though that with that in place upgrading java should have no effect?
15:55xemdetiathe string passed to SSLContext's gets interpreted differently depending what JCE driver is getting it
15:55xemdetiaso for instance post POODLE, "SSL" was auto-corrected to "TLS" in recent java's
15:56xemdetiajava 8 might be autopromoting everything to "TLSv1.2" by default
15:56timvisheroh very interesting
15:56xemdetiaanyway I would dork with that line I found
15:56xemdetiait looks like it accepts a set
15:57xemdetiaor use a different string like I mentioned earlier from https://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#SSLContext
15:57xemdetiaswitching it to just "TLS" may permit it to talk TLSv1, TLSv1.1, and TLSv1.2; most things work like that
15:57xemdetiadepends on the JCE driver though
15:57timvisherxemdetia: right. the problem with that is that we're not explicitly defining the SSLContext here
15:58xemdetiaright, so if you want it to work modify the source and see
15:58xemdetiain that .clj
15:58timvisherxemdetia: yep
15:58timvisherthanks this was extremely helpful
15:58timvisher(i'm a little out of my depth on this one :P)
15:58xemdetiamost are
16:03justin_smithxemdetia: I think security stuff makes me a little more cautious about my usual "OK I get most of this lets just plow forward optimistically" plan :)
16:04xemdetiajustin_smith, or you become the unfortunate curator of that domain for everyone around you
16:04xemdetiathis seems to be my case
16:04justin_smithxemdetia: oh, I am in that position too!
16:05justin_smithI'm just not as far along the path to competence
16:10xemdetiaI suppose
16:10xemdetiaI have been so deep in it lately I just want a nap!
16:11timvisherxemdetia: you have my permission :P
17:23macrolicioustrying to learn the syntax; I want foozy to contain 9; evaluating (def foozy []) (map #(if (> % 5) (conj foozy %) [1 3 2 9]) produces [] … help.
17:23macroliciousalso, if anyone wants to give me tips on how my question would have been better structured/presented, all ears.
17:27justin_smithmacrolicious: [] is not mutable
17:28macroliciousok...
17:28justin_smithmacrolicious: conj returns a new data structure that has your argument added
17:28justin_smithyou need to use the return value of conj if you want that new data structure
17:28macroliciousI tried and failed to use def in that way…
17:29macroliciouswasn't nailing it...
17:29justin_smith,(def a [])
17:29clojurebot#'sandbox/a
17:29justin_smith,(def a (reduce conj a [1 2 3]))
17:29clojurebot#'sandbox/a
17:29justin_smith,a
17:29clojurebot[1 2 3]
17:29justin_smiththe thing is we never do that
17:29macroliciousok
17:29justin_smithdef is for values that won't change
17:30macroliciousI'm guessing I'm thinking in the old way
17:30amalloy(def foozy (filter #(> % 5) [1 3 2 9])) would be the closest thing to what you were trying to do
17:30macroliciousah, filter, one I don't know
17:30macroliciousok
17:30macrolicioussweet
17:30justin_smithwhat you actually do is use let for local bindings, and do function calls using those bindings, without creating top level defs - def is for things known at compile time typically
17:31justin_smithbut one step at a time, of course :)
17:31macroliciousokey dokey
17:32macroliciousI'm following tutorials (slowly) then decided to play around in the repl, with predictable results… back to the tutorials ;-)
17:33macrolicioushttps://www.youtube.com/watch?v=MeRghYqi090
17:38amalloyis that link relevant somehow? off-topic chat in here is fine, but a video link with no context, where someone can't even evaluate whether they might want to watch it without clicking it first, is something i wouldn't encourage
17:39sdegutisYeah I'm with amalloy on this one.
17:39sdegutisNo rickrolling please.
17:40amalloyi'm never gonna give up rickrolling
17:42sdegutisamalloy: Oh you! http://i.imgur.com/uVs9TRS.jpg
17:44sdegutisDear everyone here, including justin_smith: when you're writing a web app and Hiccup is involved, what's your preferred way to handle the monstrosity of Hiccup code that's extracted as the common "template" (header & footer in Hiccup) for all your pages?
17:44justin_smithsdegutis: I use a templating library that does "wraps" (which are like includes but inside out - your content goes in the middle instead of it going in the middle of your content)
17:45justin_smithactually I have not done that kind of templating in a while, but that's what I did back then
17:46justin_smithsdegutis: with hiccup you can do (assoc-in page-skeleton [magic spot here] content)
17:46justin_smithsame concept
17:47justin_smithif skeleton is [:html [:head ...] [:body]] then (assoc-in page-skeleton [2 0] content)
17:48sdegutisHmm, that seems limited since it can't do evaluation on input when the page-skeleton contains logic.
17:48justin_smithor... [2 1] but you probably get the idea
17:48sdegutisLike, to show a different navbar whether you're signed in or not.
17:49justin_smithwell that's a different skeleton for each condition, but same concept (you'll just be associng deeper)
17:51amalloythat sounds awful
17:51justin_smithamalloy: alternate proposal?
17:51amalloya function that takes arguments for the variable stuff
17:51amalloy(defn page [body] [:html [:head whatever] [:body body]])
17:51justin_smithoh yeah that's cleaner
17:52amalloyhiccup data structures are basically write-only
17:52amalloyif you ever take one as input, lose 8 Sanity
17:52amalloyif you want to treat your html structure as input (a reasonable thing to want), you want to use something other than hiccup, like enlive
17:54amalloyi wrote this years and years ago, but see https://github.com/4clojure/4clojure/blob/develop/src/foreclojure/template.clj for a larger example of the style i'm suggesting
17:59sdegutisamalloy: that's waht I have now, but it's a really huge Hiccup template, like 100 lines or something...
17:59amalloyi mean, you can break that up into some smaller functions, and that helps a little
17:59sdegutisGood thinking. I may do that.
18:00amalloybut some of it is just like...i dunno, you play with fire, you get burned. webdev, not even once
18:00sdegutisI've been cleaning up my routing code a bit, and this just felt like kind of an anti-pattern for some reason.
18:01sdegutisSo I wanted to clean it up, because there's basically (ns myapp.web.template) which has (defn template [& body] ...) and that's all the file is, but it's like 102 lines long or something.
18:01sdegutisAnd it just felt like this thing floating out there by itself, being weird and not fitting in anywhere.
18:02sdegutisYet, like, 30 other namespaces all depend on it so that they can just call (template (view/whatever)) as the end-result of the route
18:02sdegutisI can't quite put my finger on why that feels weird, but it just does...
18:02sdegutisDoes that make sense?
18:02amalloyi find it hard to believe you can do much with just [& body] params
18:03amalloyadd some real named params, at least one "config" map, to let your callers specialize how the template is produced for them
18:12macroliciousamalloy: my apologies for the video link… the preceding chat gave context (and hence it was an analogy to my learning clojure) but my bad.
18:16sdegutisamalloy: Oh right it also takes the request, so it can find out if you're signed in and access the signed in user if so.
18:22ridcullyso sister mary can use hiccup for input
18:23sdegutisridcully: who? what? huh?
18:25amalloysister mary gets some kind of Sanity bonus
19:40sdegutishi
19:46sdegutishi justin_smith
19:49justin_smithsdegutis: how do I do undo-tree but only apply changes inside the region?
19:49justin_smithI am fearing it is impossible
19:49sdegutisjustin_smith: no this is patrick
19:49sdegutisjustin_smith: anyway yeah I never tried that
19:50sdegutisjustin_smith: usually I just undo until I find the change I want, copy it, then redo until I'm where I started, and paste it
19:50justin_smithyeah yeah OK
19:51sdegutisman we're gonna watch o brother tonight havent seen that in years so excited also unbreakable its a pretty good plot personally i think
20:13sdegutisamalloy: do you do what justin_smith does with components and router? or how do you tackel that?
20:13amalloyi lack the context to answer that question
20:15sdegutisok
20:19sdegutisamalloy: like heres what i mean.. ok look.. you have a router, and you have components, and a system component, and presumably the router is one of the components, but it also has asccess to all the other components or some not all, or all. and how do you get the routes to have hold of those other components? lets say you're using compojure for e.g. what do you usually do to solve this?
20:19sdegutisit's the same question i asked justin_smith earlier in here publicly btw fwiw fyi
20:19amalloyi haven't really built a webserver of any size since component became popular
20:20sdegutistouché
20:20amalloyand i don't know what you mean by a router either
20:20amalloyso i am probably the wrong person to answer
20:21sdegutishey thats ok amalloy dont feel bad
21:41TimMcI assume it's a question about dependency management within a web server.
21:42binjuredhow can i use a macro to generate a type-hinted function? i'm running into an issue during compilation where, e.g., [^java.lang.Integer foo] is being evaluated as [gf__^java.lang.Integer__46045] which, surprise, is not a class
21:43binjuredinterestingly (to me), the short form [^Integer foo] works fine, assuming Integer was imported in the ns already.
21:44binjuredmacroexpand doesn't show the gensym-style name in the output, either.
22:06TEttingerbinjured: interesting. I think it may be because that's in a syntax quote
22:07TEttinger,`(fn [^java.lang.Integer x] (+ x 1))
22:07clojurebot(clojure.core/fn [sandbox/x] (clojure.core/+ sandbox/x 1))
22:07TEttinger,``(fn [^java.lang.Integer x] (+ x 1))
22:07clojurebot(clojure.core/seq (clojure.core/concat (clojure.core/list (quote clojure.core/fn)) (clojure.core/list (clojure.core/apply clojure.core/vector (clojure.core/seq (clojure.core/concat (clojure.core/list (clojure.core/with-meta (quote sandbox/x) (clojure.core/apply clojure.core/hash-map (clojure.core/seq #)))))))) (clojure.core/list (clojure.core/seq (clojure.core/concat (clojure.core/list (quote cloj...
22:07binjuredscary! :D
22:08TEttingerdo you have the full macro to put ob refheap or gist?
22:08TEttingeron
22:09binjurednot at the moment, currently seeing if i can get it to cooperate by using with-meta instead of just literal symbols
22:15binjuredTEttinger: looks like using with-meta fixed it.
22:15TEttingerinteresting
22:16binjuredin unrelated news, the `meta` function seems to throw CIDER into an infinite loop, which is interesting!
22:16amalloybinjured, TEttinger: http://stackoverflow.com/q/11919602/625403
22:20binjuredamalloy: that doesn't really explain it, though. i wasn't evaluating [^java.lang.Integer foo] i was emiting it; that question is only really addressing the mistake of evaluating forms in a macro, hence all the namespace pollution.
22:21binjuredit also doesn't explain why emiting [^Integer foo] works fine, unless i'm missing something
22:23amalloyi don't think you are correct about what you're emitting. what code are you actually running?
22:24cflemingmarcfontaine: Sadly no structural search for Clojure code, although it would certainly be nice
22:28binjuredamalloy: i basically just replaced `[~(symbol (str "^" thing)) ...] with `[~(with-meta ... {:tag thing})] and it worked fine after that.
22:28amalloywell yeah, because symbol str is nonsense
22:28amalloylike it's fine, and it generates something that *prints like* attaching metadata, but is in fact jsut a symbol with an awful name
22:29binjuredwell then, i was tricked by macroexpand! ;)
23:22rhg135Ah, ya gotta love the symbol /keyword fns
23:23rhg135,(symbol "1")
23:23clojurebot1