#clojure logs

2014-04-19

00:01bodie_this is probably a silly question, but let's say I want to work on a library project (say a DigitalOcean API client), which I'm testing using a project with a -main. how do I include the lib project?
00:01bodie_(using Lein.)
00:01bodie_or uh, where do I need to start looking to understand this, that is?
00:02bodie_I get how to include external deps using lein... would I want to uberjar the subproject and include the jar as a resource?
00:09owl-v-how do i chanve :else part so that it runs without error? https://www.refheap.com/77460
00:10owl-v-putting elements of v into vv one by one in a recursive-function
00:15owl-v-solved my problem. but output is not correct
00:16owl-v-how do i get output '(1 2 3) from this code? https://www.refheap.com/77461
00:20owl-v-solved!
00:21owl-v-https://www.refheap.com/77462
00:21owl-v-solved :)
01:26teltubsanybody got lighttables to work on linux ?
01:29teltubsexit
02:06mr-foobarhi all, need some help I'm followinghttps://github.com/clojure/clojurescript/wiki/Quick-Start but I can't execute `:target: nodejs` code because it is outputting goog... code in the output
03:06yediyesssssssssssss
03:18owl-v-why is it hard to debug in clojure?
03:20oskarkvowl-v- is it hard? :P
03:22owl-v-it's much harder to debug in clojure than in python.
03:22owl-v-error prompt is not useful.
03:23owl-v-it's not telling what's wrong about my code
03:24owl-v-it just points to some line
03:24oskarkvowl-v- you mean stacktraces?
03:25owl-v-m.. maybe.. yes.
03:25oskarkvshow me one :p
03:25oskarkvexample
03:27owl-v-https://www.refheap.com/77486
03:28oskarkvowl-v- it does tell you what's wrong! "wrong number of args (0)..."
03:29owl-v-I can't tell where the # of args don't match
03:29oskarkvpaste the code too and i'll help you :p
03:30owl-v-thanks T.T https://www.refheap.com/77487
03:30amalloyi predict that bfs.invoke(add.clj:45) contains a call to (apply max xs), where xs is empty
03:31owl-v-it happened when i added (digit3) condition in bfsfun
03:32oskarkvowl-v- it's probably what amalloy said
03:33owl-v-hm... then (apply max) can't use on empty list/vector...
03:33amalloywell, what is the max of an empty list?
03:33owl-v-,(apply max '())
03:33clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: core/max>
03:33owl-v-!
03:33amalloyowl-v-: should it invent a number? how can you get the max?
03:34owl-v-hehe empty list
03:35oskarkvowl-v- Once you get more used to Clojure debugging is not that hard. Don't be discouraged! :p
03:36owl-v-thanks for your encouragement!
03:37amalloyit's true. i only needed to look at that stacktrace for about five seconds before i predicted the mistake. you can get there too
03:39owl-v-funny, the stack points to (for) where the actual problem happens on (max)
03:39owl-v-or does it points to the argument of (max)?
03:41amalloymaybe you have the line numbers wrong. it should be pointing to apply
04:40owl-v-i have no idea where (recur) goes to in this case. https://www.refheap.com/77488
04:41owl-v-i thought it (recur) to bfsfun with (pup u) but it shows the same value after iteration
04:41owl-v-something fishy about (let)...
04:50owl-v-the value is not equals to expected value: https://www.refheap.com/77494
04:52owl-v-is the problem from (let) or (recur)?: https://www.refheap.com/77494
05:04owl-v-in a recursive-function, (let) value don't change after (recur) ?
05:10owl-v-omg! i simply replaced (pop) to (rest) and it worked!: https://www.refheap.com/77494
05:11owl-v-what was i thinking ...
05:41owl-v-where would u recommend clojure over python? data-base? ai? embedded-system?
05:52penthiefIs there a way to stop a blocking socket read without taking down the whole process when in a cider repl?
05:53coventry` owl-v-: I've used python since the 90s. I would say python still has the edge in scientific programming and visualization, and may be superior in other areas where it has very mature libraries. However as general programming languages, clojure's thoughtful state management policies give it a clear edge.
06:28owl-v-coventry`: thanks.
06:52owl-v-still.. lips way is un-natural to me, but it's interesting as hell :-)
06:57owl-v-(question "can clojure have an infinite loop?")
06:58owl-v-(question "will clojure eat up all memory if (recur) used for infinite loop?")
07:03AimHereowl-v-, yes. no.
07:03AimHereAt least, as far as I'm aware
07:04owl-v-cool!
07:05AimHereUse this knowledge for good, not evil
07:07owl-v-um... (def good ..) (def evil ..)
07:11owl-v-how do I define good and evil?
07:12owl-v-is it global (def) or local (def)?
07:13owl-v-it would be interesting to see implementation of good/evil in artificial-intelligence .
09:28owl-v-is there way to add map? {:a 1} + {:a 2} = {:a 3}
09:29owl-v-is there way to add map? {:a 1, :b 2} + {:a 2, :b 1} = {:a 3, :b 3}
09:29jkj_interesting... is there map vals or so
09:29Bronsa,(merge-with + {:a 1 :b 2} {:a 2 :b 1})
09:29clojurebot{:b 3, :a 3}
09:30owl-v-lol. i don't see (merge-with) in this website: http://clojuredocs.org/clojure_core/1.2.0/clojure.core/map
09:32AimHereThat's because that's an (outdated) page on the 'map' function, not the map data structure
09:32owl-v-and this too: http://clojuredocs.org/clojure_core/clojure.core/map
09:32jkj_clj-kitchensink might do it: https://github.com/puppetlabs/clj-kitchensink/blob/master/src/puppetlabs/kitchensink/core.clj#LC315
09:33jkj_deeply... merge-with is nice if no deep required
09:33Bronsaowl-v-: map is a function that operates on seqs, it has nothing to do with merge-with
09:33AimHereI like the clojure cheatsheet meself. Try looking up the section 'Maps' in in here: http://clojure.org/cheatsheet
09:34owl-v-hm... actually... it does not work on "tryclj.com"
09:34owl-v-(merge-with {:a 1} {:a 1} ) -> {:a 1}
09:35owl-v-ops! forgot to put "+"
09:38owl-v-so.. clojuredocs.org is way out dated.
09:38owl-v-it's updated up to 1.3.0
09:54cddrWhat's the easiest way in clojure to override part of an interface (e.g. override the `write` method of an output stream)
09:59cddrAh, maybe proxy
10:00malyncddr: I use this for such questions -- https://github.com/cemerick/clojure-type-selection-flowchart
10:01owl-v-what's 2^3=8 in clojure?
10:03cddrHm, I think the flowchart leads me to reify. What I want is a writer that instead of writing to the console, collects messages into an array so they can be verified in a test
10:05malyncddr: Isn't that just with-out-str?
10:05malyn&(doc with-out-str)
10:05lazybot⇒ "Macro ([& body]); Evaluates exprs in a context in which *out* is bound to a fresh StringWriter. Returns the string created by any nested printing calls."
10:06cddrMaybe that would work
10:11owl-v-clojure needs MATH!
10:12owl-v-don't tell me to loop
10:12owl-v-because that's like looping (+) to do (*)
10:21cddrmalyn: Thanks for being my duck. I was totally overthinking it
10:21owl-v-still can't find math
10:25owl-v-:-(
10:27owl-v-where is scientific mind in clojure?
10:29owl-v-T.T
10:39owl-v-oh, clojure. give me MATH
10:40owl-v-clojure, let me do (= 8 (^ 2 3))
10:41weavejesterowl-v-: (Math/pow 2 3)
10:41invasmaniowl-v-: https://github.com/clojure/math.numeric-tower
10:43owl-v-weavejester: OMG!!!! big.THANK.u
10:44owl-v-i was going to give up and use python to solve math problem.
10:44owl-v-I had to use (int (Math/pow 2 3) to get integer.
12:13bbloomi really want an auto-splicing sequence data type
12:13bbloom(conj [1 2 3] (splice 4 5)) => [1 2 3 4 5]
12:17bbloomconj is already polymorphic for maps additions:
12:17bbloom,(conj {} nil [:x 1] {:y 2 :z 3})
12:17clojurebot{:z 3, :y 2, :x 1}
12:17bbloomneed a non-polymorphic conj for vectors, something like "append"
12:18bbloomthen conj can auto splice :-)
12:18jkjconcat too slow?
12:21owl-v-bbloom: what's (splice 4 5) ?
12:23bbloomowl-v-: some thing i just made up
12:24bbloomjkj: slow is not the issue, i want to be able to move the decision to concatenate from the receiver of the value to the generator of the value
13:08owl-v-bbloom: how does (splice) works?
13:08owl-v-bbloom: how does (splice) work?
13:16TravisDI am implementing some experiments where the goal is to compare different algorithms for solving the same problem. Right now, I am planning to make a protocol that defines the interface each algorithm should have, so that I can write the rest of the experiment code against these protocols. Is this abuse?
13:21apricotsIf I type “lein cljsbuild auto &” to background the command in my shell, instead of backgrounding, it replies with “[1]+ Stopped lein cljsbuild auto”. It’s a minor annoyance, but is there a way to around that?
13:28Jaood_apricots: no idea, maybe you should try screen/tmux
13:30ismaelvcHello everyone! I'm reading the clojure introduction at clojure-doc, I'm currently on "namespaces", and after reading about (require '[clojure.string :as str]), I tried to do (require '[javax.swing.JOptionPane :as Pane]), but I get: user=> (require '[javax.swing.JOptionPane/showMessageDialog :as Diag]) FileNotFoundException Could not locate showMessageDialog__init.class or showMessageDialog.clj on classpath: clojure.lang.RT.
13:30ismaelvcI only know Python, I'm trying to do something analogous to this in Jython: >>> from javax.swing.JOptionPane import showMessageDialog as Diag >>> Diag(None, "Hello Jython!")
13:31JohnJnoob here, I have this result from a function => ({: 1}) , what is this? A map with a empty string as key?
13:32JohnJismaelvc: I would say you need a require in the project.clj, do you have it?
13:32dbaschapricots: lein cljsbuild auto < /dev/null &
13:32mpenet,(import 'javax.swing.JOptionPane)
13:32clojurebot#<ExceptionInInitializerError java.lang.ExceptionInInitializerError>
13:33dbaschapricots: and you probably want to redirect the output to a file
13:33mpenetismaelvc: meh should work, in short java stuff gets imported with "import" not require
13:34mpenet,(import '(javax.swing JOptionPane))
13:34clojurebot#<NoClassDefFoundError java.lang.NoClassDefFoundError: Could not initialize class javax.swing.JOptionPane>
13:37mpenetismaelvc: then (JOptionPane/showMessageDialog nil "meh")
13:39r00kHi all, I'm trying to insert a record in a postgres db using korma. I'm calling (insert clients (values {:date_of_birth "1980-01-01"})). This gives me "ERROR: column "date_of_birth" is of type date but expression is of type character varying" from QueryExecutorImpl.java. This seems an odd error since pg happily accepts strings for that column in the psql console. Any thoughts?
13:40r00k(I realize that I'm touching pg and java here, and this might not be a clojure thing at all.)
13:44ismaelvc<JohnJ> No I don't have a require in project.clj, I just started using the REPL
13:45zamaterianr00k, try converting your string to a java.sql.Date
13:46ismaelvc<mpnet> Thanks that is closer to what I wnated, but still how can I make an alias for showMessageDialog?
13:49r00kzamaterian: Thanks! Giving that a shot.
13:49ismaelvcI want to write just (Diag nil "meh") instead of (JOptionPane/showMessageDialog nil "meh")
13:52JohnJguys which data structure is this: {: 1} ?
13:52bhaumanismaelvc: (defn diag [a b] (JOptionPane/showMessageDialog a b))
13:54r00kzamaterian: So when I convert my string to a java.sql.Date, it includes a time portion, so it's certain day at midnight at UTC. When I insert that in pg, it's storing it an one day prior, presumably because I'm in -5 UTC. Think I should specify a time zone on the java.sql.Date? I'd really rather avoid timezones entirely.
13:54r00ks/an one/as one
14:03ismaelvcbhauman: Thanks that works as I intended! So there's no alias when importing, only while requiring, right?
14:04owl-v-oh.. man. how do i sum prime numbers in between 1 and 2000000 ?
14:04owl-v-i'm using brute force
14:04bhaumanismaelvc: you can only alias the namespace not the definitions (functions) within the space
14:05owl-v-it's taking a lot of time...
14:05honzais there a list of built-in clojure functions that return chunked seqs?
14:05owl-v-and it's still calculating...
14:06zamaterianr00k, I would look into using clj-time
14:07zamaterianr00k, https://github.com/clj-time/clj-time
14:09r00kzamaterian: Thanks, but I actually have been using that. Still having issues. I'll keep struggilng.
14:17ismaelvcbhauman: Then what would be the advantege of first importing and then defining a function, I think it is better and less code just in one go like this: user=> (defn dialog [message] (javax.swing.JOptionPane/showMessageDialog nil message)) #'user/dialog user=> (dialog "Hello Clojure!") nil. Is there any drawback from doing it this way? Thanks so much! :)
14:19bhaumanismaelvc: there are no drawbacks that I see to either, case by case
14:21creeseI'm wondering what is best practice for app-level configs in a leiningen project. I want to store info like database-url, redis, etc. but somewhere I can keep out of version control. Is the ability built-in?
14:21mpenetcreese: https://github.com/weavejester/environ is nice for this kind of things
14:22mpenetor just read an edn file that you pass as argument to your app -main
14:22mpenetmany ways to do this (yaml comes to mind too)
14:24bhaumancreese: look at the functions: slurp and read-string , it’s pretty tirvial to read a clojure data structure from a file
14:25mpenethttp://clojure.github.io/clojure/clojure.edn-api.html this read-string, not the one from core preferably...
14:25mpenet,(doc read-string)
14:25clojurebot"([s]); Reads one object from the string s. Note that read-string can execute code (controlled by *read-eval*), and as such should be used only with trusted sources. For data structure interop use clojure.edn/read-string"
14:27creesempenet: I've used yaml before, seems like edn is a better choice here
14:28bhaumanmpenet: ok got it
14:29bhaumandon’t know why I ignore clojurebot so much, he seems to know what he’s talking about
14:29mpenetI like edn better too, but if you need to expose it to ppl who are not familiar yaml (or something else) can be a better choice
14:39sm0kei can see a cljs/core.js in the :output-dir, but still my browser complains "goog.require could not find: cljs.core "
14:40sm0kei was just trying to get the brepl working
14:40sm0kehttps://github.com/cemerick/piggieback#browser-repl
14:44amalloyhonza: well, the main ones are like...range, and seq on a vector. then there are the functions that preserve chunkiness, and the ones of those that i remember are for, map, filter/remove
14:44bhaumansm0ke: in that tutorial index.html is in the root of your project and so is the out/ directory
14:44honzaamalloy: cool
14:45honza,(chunked-seq? (seq [1 2 3]))
14:45clojurebottrue
15:14mpenetanyone knows if its possible to hide a protocol from codox generated doc?
15:17mpenetnm
15:26yediso i have a git repo that has my webapp in it, i gitignore resources/public/out.
15:27yedito deploy my app, I pull the git repo and run lein uberjar from the remote server
15:28yedihowever when i run lein uberjar, it seems that my resources/public/out isn't getting generated. so i get errors like GET http://reasonedrhymer.com/out/goog/base.js 404 (Not Found)
15:28dbaschyedi: it’s usually not a good idea to build things in a production server anyway
15:29yedihm, so I guess I should just somehow get the uberjar to the server during the deploy process? would it make sense to put the uberjar in source control?
15:29dbaschyedi: what I do is I have deploy scripts that scp the uberjar to the server
15:30dbaschyedi: btw, have you checked the uberjar to make sure the resources are in it?
15:30yediwell it ran fine on my vm when I scped the uberjar over for testing
15:31yediis there a way to inspect uberjars for specific resources?
15:31dbaschyedi: jar tvf file.jar |grep resources
15:31yediand yea, looks like i'll just do the scp strat, i was tryna avoid that since i'm generally on shitty internet so it might be slow, but if that's the best way i'll do it
15:31yedicool thanks dbasch
15:53mpenetif you use emacs you can just open/browse/modify it with dired
17:33coventryAnyone here used double-check? I'm getting "WARNING: No such namespace: math.seedrandom at line 1 file:.../pprng-0.0.2.jar!/cemerick/pprng.cljs" from cljsbuild, then "Undefined nameToPath for math.seedrandom" from javascript. Where should I be pulling in math.seedrandom from? Is it this? https://github.com/davidbau/seedrandom
17:33cemerickcoventry: follow the directions in the readme re: :libs
18:07coventrycemerick: Thanks.
18:11eraserhd_So, I've just written some more threading macros. This is usually a bad idea, I imagine.
18:12eraserhd_First, I wrote (in-> v a-fn & forms)
18:14eraserhd_where, if a-fn is a keyword, is equivalent to (update-in v [a-fn] (fn [s] (-> & forms))).
18:14eraserhd_and if a-fn is a function, is equivalent to (a-fn v (fn [s] (-> & forms)))
18:14eraserhd_for "lifting" sub-state.
18:16eraserhd_Then I wrote ->' , which is like -> except that it treats if and if-not specially, threading the value through the then and else clauses.
18:41atlasbladehttps://www.youtube.com/watch?v=bcuqxj5YTA8
18:41atlasbladehttps://www.youtube.com/watch?v=bcuqxj5YTA8
18:53ToBeReplacedis there a function to do (zero 1.0) => 0.0, (zero 1) => 0, etc.?
18:54BronsaToBeReplaced: (defn zero [n] (- n n))
18:57coventryWith cemerick.austin, what am I likely doing wrong if the browser repl connection string gives the error 'Cannot write "http://localhost:8001/out/goog/useragent/useragent.js&quot; after document load'?
19:00dbaschcoventry: what’s your version of clojurescript?
19:00coventryeraserhd_: You may want to take a look at synthread. It is a library of threading macros which the authors motivated in terms of monads.
19:00coventryNever used it myself.
19:08tempehHi
19:08tempehI'm looking for a good book or resource on functionally oriented algorithms/patterns
19:08tempehAny ideas?
19:32waynrhowdy folks
19:33waynranyone have advice for figuring out why this clojure program i am working with takes so long to load?
19:33nightflyIs it much longer than any other Java/Clojure program?
19:33waynrit's generally around 5 seconds
19:34nightflythat sounds pretty normal
19:34waynrah wait i just measured it's more like 15 seconds
19:37waynri added an aleph tcp port to the program which added 10 seconds to the load time compared to what it was previously
19:39waynri mean, an aleph tcp server
19:49amalloywaynr: aleph is pretty big. it takes a while to compile all that stuff
19:52mr-foobarhi all, I am trying to integrate grunt and cljs https://github.com/harsha-mudi/grunt-contrib-cljs I am getting a "goog not defined" when I run a compiled main.js script.
19:53mr-foobarThis what I am executing in the grunt `cljsc app/cljs '{:target :nodejs :optimization :none :output-to "generated/js/deps.js" :output-dir "generated/js/"}'`
19:58dbaschmr-foobar: how do you run your script?
19:59mr-foobardbasch: `node generated/js/main,js` https://github.com/clojure/clojurescript/wiki/Quick-Start (hello world code)
20:01dbaschsee “Notes on optimization settings"
20:04coventryWith test.check, I can I make a generator like gen/any, which goes at least n levels deep before it starts including simple types? I need some way for sized-container to know how deep in the structure it's being called.
20:05mr-foobardbasch: require("./generated/js/goog/bootstrap/nodejs") fails because there is not bootstrap folder
20:06satshabadHi, I've run into a frusterating problem with lein ring server, when I have a dir under /resources/public with a few web fonts ( .eot .svg, .tff and .woff files) lein ring server will auto refresh my browser forever
20:08satshabadhmm looks like there is a stylesheet.css in there and when I rm it, the problem stops...
20:10mr-foobardbasch: oops typo, :optimizations :none gives me the bootstrap folder
20:20owl-v-assume that the function call is very expensive, how one can remove (recur) tail-recursion?
20:21tempehthat seems entirely context dependent
20:22owl-v-breath-first-search and depth-first-search?
20:23owl-v-and iterating through list and update values?
20:29owl-v-ok ok, if i increment a value through loop and append it to a list/vector, this is going to eat up my memory faster than mutable-list/vector.
20:32owl-v-if there is a way to remove old values(throw them into garbage collector) then I can happily use immutable list/vector
20:39crocketIs clojure going to win on the server side?
20:41beamsowhy not?
20:42mr-foobardbasch: thanks ! the grunt task is working now with :simple need to polish it further.
20:43tempeh@owl-v- not sure what you mean by your latter comments, but why do you want to get rid of recur?
20:43tempehCan anyone recommend a good book/resource on functional algorithms/design patterns?
20:44amalloytempeh: well, SICP is free and is amazing. Purely Functional Data Structures has some seriously good stuff but is pretty challenging
20:45tempeh@amalloy I've looked into SICP and was turned off by it's use of Sceme. Is it not a problem?
20:45tempeh*scheme
20:45amalloylanguage doesn't matter so much. you asked about algorithms and design
20:46amalloyand like, it's hard to find a language closer to clojure than scheme anyway
20:46tempehRight, I meant is it a problem if I've never used Scheme
20:46amalloyno
20:46tempehdid you read it without knowing scheme?
20:46amalloynot for long!
20:46amalloypretty soon i knew scheme
20:46tempehha, okay
20:47tempehthanks, i'll look into getting it then
20:47amalloyyou can learn scheme in like...an hour, if you're familiar with programming and with lisp especially. the language is so small
20:47tempehin what way is purely functional data structures challenging?
20:47tempehokay
20:48amalloyit's a very dense book covering difficult concepts in a way that feels like a mathematics textbook
20:48tempehthat might be more what I'm looking for actually
20:48amalloytempeh: you can find some free papers by okasaki and read those, if you want to evaluate whether you want to buy PFDS
20:49amalloyactually maybe PFDS is free too? not sure
20:49amalloyhttp://www.cs.cmu.edu/~rwh/theses/okasaki.pdf looks like his thesis - i don't know if the book is identical or just closely related
20:50agarmanthe thesis is more about his framework for analysis of persistent datastructures
20:50tempehah, okay
20:50agarmanthe book is more about implementations and practical usage
20:51agarmanboth are aws=esmom
20:51tempehI found a directory of his papers, i'll check out one of those
20:51tempehthanks for you help guys, i know what i'm doing tonight
20:51amalloyhttp://www.westpoint.edu/eecs/SiteAssets/SitePages/Faculty%20Publication%20Documents/Okasaki/jfp98sixth.pdf is probably the first thing by him i read
20:51amalloynice and short
20:52tempehoh christ
20:52tempehi hope the answer to "why would anyone ever want to use a 6th order function" is "no one, ever"
20:52agarmanhis thesis is the first thing of his I read
20:53agarmanflattening combinators is good
20:54agarmanhttp://www.westpoint.edu/eecs/SiteAssets/SitePages/Faculty%20Publication%20Documents/Okasaki/jfp03flat.pdf
20:55amalloyi should add his disclaimer as my email signature: The views expressed in this [email] are those of the author and do not reflect the official policy or position of the United States Military Academy, the Department of the Army, the Department of Defense, or the U.S. Government.
20:56TimMcooo, ligature
20:56TimMcamalloy: Heck, use that as your IRC signature.
20:57amalloyTimMc: maybe my AIM buddy profile
20:57TimMcYou never know when some statement of yours might be misunderstood as an official position of the US gov't.
21:05owl-v-tempeh: i want to have some optimization
21:20owl-v-it's interesting to see creating a function in a loop in a function have different reference for each iteration: https://www.refheap.com/77755
21:24xcthulhuHow do I lazily read lines from a gzipped file?
21:29dbaschxcthulhu: use line-seq on a java gzipinputstream
21:30xcthulhuTrying that, running out of heap :(
21:30xcthulhu(defn populate-from-json-gz
21:30xcthulhu "Populate the database using a GZIPPED JSON file of chemical reactions"
21:30xcthulhu [json-gz]
21:30xcthulhu (with-open [data (io/reader
21:30xcthulhu (java.util.zip.GZIPInputStream.
21:30xcthulhu (io/input-stream json-gz)))]
21:30xcthulhu (first (line-seq data))))
21:30xcthulhu(populate-from-json-gz “really_big.json.gz")
21:30xcthulhuhehe, should have killed the docstring
21:31dbaschxcthulhu: use refheap
21:32xcthulhuhttps://www.refheap.com/77756
21:32xcthulhuChecking now to make sure that I’m actually writing seperate lines...
21:33xcthulhuSince if I don’t have newlines in that huge JSON it would make sense that this is falling over
21:43xcthulhuOkay, that was it. Sorry for bothering everyone :(
22:23FrozenlockSVG showing as a broken image with compojure. Any ideas why? (All the other types are fine... jpg, png...)
22:24jdkealyhow am i supposed to get payload params in a post request with compojure ?
22:25Frozenlockjdkealy: are you using the params middleware?
22:25Frozenlockhttps://weavejester.github.io/compojure/compojure.handler.html
22:26jdkealyi am requiring compojure.handler
22:27agarmanyou need to wrap your routes in wrap-params
22:27agarmanor api or site
22:27FrozenlockBut are you using it? (-> my-awesome-app-routes <and now the middleware --->> handler/site)
22:29jdkealyno i don't think i am
22:30jdkealyi will try to add the middleware to my awesome app routes :)
22:34dbaschFrozenlock: how are you serving the file?
22:35Frozenlock[:img {:src "/img/some-image.svg"}]
22:35dbaschFrozenlock: ok, how are you serving /img
22:36jdkealywhen you use wrap-params, can you still start server with "lein ring server" or do you need to write a custom start/stop method ?
22:36Frozenlockdbasch: You mean like text/html? I let compojure deal with it :p
22:36dbaschFrozenlock: I mean, are you using route/resources ?
22:37FrozenlockAh! I'm using the wrap-resource middleware
22:37FrozenlockLike I said, everything else seems to work.
22:38FrozenlockJS, CSS, images (jpg png)... but not svg
22:38owl-v-how do i call java function in myjavacode.java?
22:39dbaschFrozenlock: svg is being served as “"image/svg+xml"
22:39beamso(package.Class/staticMethod args)
22:39dbaschhttps://github.com/mmcgrana/ring/blob/master/ring-core/src/ring/util/mime_type.clj
22:39beamso(instanceMethod instance args)
22:39Frozenlockdbasch: Isn't it what it's supposed to be?
22:40dbaschFrozenlock: should be, you may want to check
22:41Frozenlockuh, my browser says it's being sent with text/xml
22:42dbaschFrozenlock: there’s your problem
22:42dbaschFrozenlock: try using route/resources instead of wrap-resource
22:47Frozenlockdbasch: I would expect them to be quite similar... But will try anyway. Thanks :-)
22:47dbaschFrozenlock: I was just looking at the source, route/resources tries to guess the mime type
22:48dbaschFrozenlock: I coudn’t find the same thing in wrap-resource
22:48dbaschFrozenlock: if you request other file types, what mime-type do you get?
22:48dbaschFrozenlock: I’m curious if you get text but the browser recognizes the extension and renders it anyway
22:49dbasch“be liberal in what you accept"
22:51FrozenlockHmm... unless my browser is lying, there's image/png and image/jpeg. Local JS is text/plain however...
22:51FrozenlockWeird
23:02FrozenlockYay, now my javascript is send with text/javascript.
23:02FrozenlockBut my svg is still with text/xml
23:06dbaschFrozenlock: btw, what browser are you using?
23:06Frozenlockchromium
23:08dbaschFrozenlock: are you sure the file is proper svg? Chromium renders svg just fine for me even without a mime-type in the response
23:09dbaschFrozenlock: what does your main handler look like?
23:09FrozenlockYes, taken directly from wikipedia.
23:10Frozenlockhttps://www.refheap.com/77766
23:10FrozenlockI think wrap-content-type middleware isn't added anywhere... O_o
23:10dbaschthe wikipedia file doesn’t render for me either
23:11Frozenlockdbasch: You get improper SVGs from wikipedia?
23:11FrozenlockBut anyhow, I can see it normaly, but not when I use it on my app.
23:11dbaschno, it’s fine
23:11dbaschbut the wikipedia server serves it with Content-Type:image/svg+xml
23:13FrozenlockI'm an idiot
23:13Frozenlockresources fixed it alright
23:13dbaschIf I add (route/resources "/") to my routes, it works
23:13FrozenlockIt was cached...
23:13dbaschand it’s for that reason: wrap-resource does’t guess the mime type, and route-resources does
23:13dbaschdoesn't
23:14FrozenlockF5 instead of shift-F5
23:14Frozenlockdbasch: You successfully found and solved my problem, thank you very much! :-)
23:15dbaschFrozenlock: np, I wonder if that’s a bug in wrap-resource or the intended behavior
23:15FrozenlockAny point in keeping 'wrap-resource' if just 'resources' works?
23:17dbaschFrozenlock: resources only works for a specific path, wrap-resource falls back on a handler if no resource is found
23:20Frozenlock If it can't find the file, how would falling back on the handler help?
23:21amalloyFrozenlock: the point is you use it like (wrap-resource (handle-non-resources))
23:22Frozenlockamalloy: Like generating a file on the fly?
23:22amalloyso first it tries finding a resource corresponding to the request, and if no such resource exists then it assumes the request must be for something else (eg, one of your dynamically generated pages) and calls your "main" handler
23:22FrozenlockI see. Thanks
23:23amalloy(wrap-resources foo handler) is a lot like (routes (resources foo) handler)
23:23dbaschamalloy: do you think not attempting to guess the mime-type is just an omission?
23:24amalloy*shrug*
23:24dbaschamalloy: probably, I see no reason to do it in resources and not in wrap-resource
23:25amalloydbasch: i'm pretty sure weavejester has thought about it a lot more than you or i have, and hundreds of people before you have used this function. if it behaves a particular way, there's probably a reason that's deeper than "i see no reason not to"
23:25amalloybut i don't have any special knowledge there, so who knows
23:30dbaschamalloy: resources is in compojure, wrap-resource is from ring
23:30dbaschthere was this issue: https://github.com/ring-clojure/ring/issues/21
23:31dbaschbut no mention of mime-type
23:31amalloythen it's not an omission at all! it's just a feature that's outside of ring's scope, probably
23:31dbaschamalloy: makes sense
23:32FrozenlockSo 'resources' is like wrap-resources, but with a little more sugar
23:36dbaschand content-type is too specific for ring, there’s no reason to assume a resource is going to be rendered by a browser at that level