#clojure logs

2015-12-04

01:01allen_hello
01:01allen_can someone help me load a java file into a clojure project
01:02allen_i keep getting class not found exception
02:03sarais anyone know how to connect mysql database with my clojure project using clojurescript and om?
02:39Loveywow . hello
02:42thatslif_having trouble understanding this, any suggestions? #(reduce + (map (constantly 1) %))
02:56opqdonutthatslif_: that's a convoluted way of computing the length of the input
02:56opqdonutthatslif_: (reduce + foo) is the sum of all elements in list foo
02:57opqdonutthatslif_: (constantly 1) is a function that always returns 1: ((constantly 1) x) ==> 1
02:57opqdonutthatslif_: so (map (constantly 1) bar) gives you a list with the same number of elements as bar, but all of the elements are 1
02:58thatslif_oh awesome, thanks for the explanation!
03:32bionji'm trying to un-interleave by an arbitrary number of steps. for 2 dimensions this works: ((juxt #(take-nth 2 %) #(take-nth 2 (rest %))) (range 10)). but i need n dimensions
03:32bionjany thoughts?
03:59kungiIs cider 0.10 connect to lein repl so much faster or does it just feel like it?
04:04bbazhi
04:16Trioxini think my IDEA might be messed up. I'm just now finally getting back to learning clojure. what's the procedure for loading a namespace into the repl again so I can call functions in lets say the core.clj file?
04:17Trioxini tried running the iml, project.clj, and then the core file all in the repl but wasn't able to run the functions I'm after
04:17Trioxini'm using cursive
04:18Trioxinnvm, switch namespace /facepalm
04:18Trioxinactually that didn't work
04:20Trioxin(myfunc somestring)
04:22Trioxinit's unable to resolve the function name
04:23Trioxinnvm I got it
05:41somnasperhttp://www.infoworld.com/article/2987529/java/insider-oracle-lost-interest-in-java.html
05:41somnasperSo, what does this mean for Clojure's future?
05:41mavbozojava platform is one of those platform that is too big to fail
05:42mavbozolots of multi-nationals, mega corporations depend on java platform
05:42somnasperSo, it's more likely they'll get bought out than successfully stop supporting it?
05:48mavbozosomnasper, more likely oracle gets more pressure from those big mega corps to continue support java
05:48mavbozomost probably by buying oracle shares
05:51poweredor we'll just all bail to clojurescript
05:51somnasperArgh, Figwheel keeps freezing on "notifying browser that file changed"
05:51somnasperIt didn't do this before, and it's doing it on two different projects
05:53somnasperServer's working, but shows "Page not found"
05:56TEttingerI think the JVM has been slowly dying for a while under Oracle. I would not be surprised if the JDK9 changes to modularity finally encourage a large-scale fork of the VM itself
05:56TEttinger(to remove any link to oracle)
05:56TEttinger(probably also to fix things they have neglected)
05:58poweredI don't think java will break backwards compatibility
05:59TEttingerI think they did in 8, in a few tiny ways
06:01TEttingeroooh this is good
06:01TEttingerhttp://docs.oracle.com/javase/7/docs/api/java/awt/image/renderable/RenderContext.html
06:01TEttingerstill in 8 http://docs.oracle.com/javase/8/docs/api/java/awt/image/renderable/RenderContext.html
06:02TEttingerconcetenate eh?
06:02TEttingerwere they hiring kids fresh out of middle school?
06:02TEttinger"spell check good bro"
06:03powered" It is here for backward compatibility with previous releases which misspelled the method name"
06:03poweredlol
09:07poweredmemoize doesn't actually guarantee that the function is only called once per argument
09:07poweredhow would I get such a setup?
09:08poweredactually nevermind that, I logged something double so there's no problem :)
09:21jonathanjhow would i perform some function f on every key-value pair in a map recursively and transform the map by the return value
09:22beakyiterate?
09:22jonathanjclojure.walk/walk seems like what i would want, calling walk again from the inner function if the value is a map
09:22beaky,(iterate (fn [[k v]] (+ k v)) {0 1 1 2 2 3})
09:23clojurebot#<UnsupportedOperationException java.lang.UnsupportedOperationException: nth not supported on this type: PersistentArrayMap>
09:23beakyoops
09:25muhuk,(map (fn [[k v]] (+ k v)) {0 1 1 2 2 3)
09:25clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>
09:25muhuk,(map (fn [[k v]] (+ k v)) {0 1 1 2 2 3})
09:25clojurebot(1 3 5)
09:29jonathanji want to retain the structure, just transform the values recursively
09:30MJB47_,(map (fn [[k v]] {k (+ k v)}) {0 1 1 2 2 3})
09:30clojurebot({0 1} {1 3} {2 5})
09:30MJB47_?
09:30MJB47_nvm
09:31muhuk(into {} (map (fn [[k v]] ... [new-k new-v]) coll)) actually
09:32muhukjonathanj: and the fn inside map may be the outer function (calling itself)
09:54sdegutisHi there.
09:56beakyhello sdegutis
09:56sdegutisHow are you.
09:58beakyim alright
11:29puredangerhello all, the 2015 Clojure community survey is now open - would be great to see your responses! http://blog.cognitect.com/blog/2015-clojure-community-survey
11:39ARM9not sure what the difference between 'slightly important' and 'somewhat important' is
11:40ARM9both sound equally indecisive to me
11:49xemdetiaARM9, to me somewhat important > slightly important
11:52ARM9maybe the meaning is lost in translation, both words translate to pretty much the exact same meanings
11:53ARM9would've been clearer to just use 'important' for the third option imo
11:53puredangerit's a fairly arbitrary scale :)
11:53xemdetiawell then you should let the user define their own in a variety of emojis
11:55ARM94 👍 out of 5
11:56jonathanjthe dictionary definition of "slightly" is "to a small degree", while the definition of "somewhat" is "to a moderate extent"
11:57jonathanjmaybe they could have been worded in a way that makes their differences more apparent to the majority of readers but they do have different meanings
12:06kwladyka(defn bar [page-size elems & opts] ...) (defn foo [page-size & opts] (rotator-cms page-size 1 opts)) <- how to pass foo opts into bar opts :)
12:10sdegutispuredanger: your css is so post-modern that I had a really hard time finding the link to the survey itself :(
12:11puredangersorry :)
12:11puredangersquarespace junk
12:12sdegutispuredanger: ok :)
12:13sdegutispuredanger: also 1/4 of these questions have words and phrases i dont understand, and 1/2 of the questions are worded such that i cant answer it correctly given the choices
12:13puredangersuch as?
12:13kwladykaok i know, with apply :)
12:13sdegutispuredanger: in #7 what is the difference between trad-infra and public-clud?
12:13puredangerpublic cloud would be stuff like AWS
12:13sdegutispuredanger: such as: in #5, our app has parts that are customer facing and parts that are internal
12:13sdegutispuredanger: then whats trad-infra?
12:13puredangertrad-infra would be stuff like a box in your own data center
12:14puredangerin #5, can't you select both?
12:14sdegutispuredanger: okay that makes a lot more sense; i didnt know those phrases before, some "e.g. [bla]" might help next to answers
12:14puredangerok
12:14sdegutispuredanger: for #5 yes but thats probably not what you mean by the question: the internal parts are for devops and scheduling and stuff, but they only serve the user facing parts
12:15puredangerI would just check both
12:15sdegutispuredanger: and in #3 its difficult to say my "primary" language, because i used several of them for work and several of them for hobby outside work, all being used heavily
12:15jonathanjhow would i associate a value with a key only when the key doesn't exist?
12:15sdegutispuredanger: ok
12:15puredangerthen check multiple
12:15puredangerthat's why it's multi select
12:15sdegutispuredanger: ok just wanted to let you know in case you intended teh answers to mean different things than im meaning when i check them
12:16puredangerjonathanj: you can check if it exists first
12:16sdegutispuredanger: from these questions and how they're worded, i have a strong feeling that you're not gonna get accurate data from me and from a lot of people is what i mean according to the definitions at their face value
12:16puredangersdegutis: I think it's impossible for questions to be worded in such a way that they are universally understood
12:16sdegutispuredanger: i.e. #5 is going to look like i use clojure for micro-services and stuff, when thats not really the case
12:17sdegutispuredanger: ok +1
12:17sdegutispuredanger: also im guessing #6 doesnt really apply to teams of 1 dev
12:17puredangerif something doesn't apply, skip it
12:17puredangeronly the first 2 questions are required
12:17sdegutisoh
12:17sdegutisok
12:23ecmikepuredanger: done, first two pages only though
12:23puredangerwell it doesn't count till you get to the end :)
12:24ecmikeI clicked next to the end, just didn't fill anything out after page 21
12:24ecmike*2
12:27puredangercool, thx!
13:35Guest19_hi! I was wondering if someone could help me write a function having trouble getting parity with
13:36Guest19_fuck changed name.
13:36Guest19_anywyas, does anyone have a good example of a 'dissoc-in' that handles vectors as well?
13:38Guest19_or i guess a dissoc that handles vectors.
13:38momerath you might check out Specter: https://github.com/nathanmarz/specter
13:38WorldsEndlessIs there a more elegant way to perform this kind of lazy-seq/defrecord-delving? https://www.refheap.com/112348
13:40WorldsEndlessI guess a related question: is "first" the best way to grab a scalar value out of a lazy seq?
13:42Guest19_@momerath what should i check out in Specter?
13:42justin_smithWorldsEndless: especially when experimenting in the repl, I find -> very helpful with things like that
13:43justin_smithso I'd start with (-> personal-info type) - see it's a lazy-seq, (-> personal-info first type) - see it's a hash, (-> personal-info first keys) - OK, we've got a :content key (-> personal-info first :content type) etc. etc. etc.
13:44justin_smithWorldsEndless: I find the linear chain of lookups with -> much easier to read and explore with, compared with mixed nesting like you have
13:46beakyhello
13:46WorldsEndlessjustin_smith: Yeah, usually I use the thread, too, but I'm havin gtrouble at the point I get to the (filter #()) portion, since macros can't be nested
13:46justin_smithWorldsEndless: check this out ---
13:46justin_smith,'#(foo)
13:46clojurebot(fn* [] (foo))
13:47justin_smithfn does nest, and #() is just a shorthand for fn
13:47WorldsEndlessgotcha
13:47justin_smithWorldsEndless: and if you want to switch away from ->, deep nesting only obfuscates, I'd use let bindings instead
13:48justin_smithhard to read code leads to hard to find bugs
13:48WorldsEndlessjustin_smith: I definitely want -> . It's just a matter of getting it right with the records and filters
13:48justin_smithWorldsEndless: sure, ->> nests inside ->
13:49WorldsEndlessjustin_smith: really? I'll have to think about that. It's making me dizzy.
13:49justin_smith(-> personal-info first :content (->> filter (fn [x] (= :PFNAME (:tag x)))) first :content first)
13:50justin_smithoh, wait
13:50justin_smithno, yeah, that should work
13:50justin_smithexcept filter needs parens around it, of course
13:51Guest19_can i get feedback on
13:51Guest19_https://gist.github.com/fzakaria/740c16e07fb3835d2285
13:51Guest19_seems to work in my case of using JSON pointers (to remove a certain element) in a nested container with maps + vectors
13:52justin_smithGuest19_: on line 7, I think you can get away with using into instead of vec and concat
13:52justin_smith,(into (subvec [:a :b :c :d] 2 3) [:g :h :i])
13:52clojurebot[:c :g :h :i]
13:52justin_smiththat saves a few operations
13:52Guest19_thanks
13:53Guest19_simplified
13:54Guest19_is there a lein plugin that will minimize my requires
13:54Guest19_to what im using
13:55justin_smithGuest19_: I think eastwood might help with unneeded required libs - if not that slamhound might help
13:56Guest19_thanks.
13:59WorldsEndlessWell, it's still some of the more difficult clojure code I've had to read, but it's much better: https://www.refheap.com/112348
14:00justin_smithWorldsEndless: also, an alternative to (fn [x] (= :PFNAME (:tag x))) is (comp #{:PFNAME} :tag)
14:01justin_smithwhether the latter is more straightforward might be controversial
14:01WorldsEndlessGuess it might be time for me to learn (comp)
14:02justin_smiththe function is simple - knowing how it can simplify code and make it more powerful is the tricky / subtle part
14:02justin_smithimho
14:02justin_smithit's sort of a functional programming nerd goto, replacing nested function calls with using comp to generate a function
14:03rhg135Very much so, it just obfuscates mine
14:04rhg135Knowing when to use it is difficult
14:27timmmm,q
14:27clojurebot#error {\n :cause "Unable to resolve symbol: q in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: q in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: q in this context"\n ...
14:28beakyhehe
14:40jakedusthi! say I want to validate that for a map, every value is also a key. is prismatic schema good for that?
14:40jakedustI'd just to attach a predicate like (clojure.set/subset? (set (vals my-map)) (set (keys my-map))) to a schema
14:42justin_smithjakedust: well, you can express the fact that the map is made of keyword keys with keyword values directly in a schema definition
14:42clojurebotIn Ordnung
14:43justin_smith{s/Keyword s/Keyword}
14:44justin_smithjakedust: nb. keywords are not only for map keys (of course) and are not the only type allowed as keys in maps
14:44MJB47i think he means more {:a :b :b :a} is valid but {:a :b :c :a} isnt
14:44jakedustyup, as MJB47 said
14:44justin_smithoh
14:45justin_smiththat's different, sorry
14:45jakedustactually, I'd happy just being able to say that (vals map) is a subset of (keys map)
14:46jakedustwhile using the nice machinery of prismatic schema
14:47justin_smithjakedust: yeah, clearly I misunderstood what you were trying to do, but it looks like that's a reasonable approach
15:11beakyhow do i do imperative programming in clojure
15:11beakywith good old mutable variables and for (int i = 0; i < n; i++) loops
15:11justin_smithbeaky: if you use mutable java data types, you can do everything to them in clojure that you can in java
15:12ARM9(dotimes [i n] foo)
15:12muhukbeaky: check out https://github.com/ztellman/proteus
15:36kenrestivowhat's the general philosophy on dealing with a java lib that has lots of mutable state? use its state, duplicate its functionality outside of the lib using clojure reference types?
15:36kenrestivosimilar question regarding callbacks: deal with its callback hell? or wrap it in core.async channels and go loops?
15:38muhukkenrestivo: depends on the functionality I guess
15:38kenrestivoyeah, maybe there's no right answer.
15:38muhukkenrestivo: but generally the host functionality is embraced
15:39muhukif you're interested, you can take a look at ring jetty adapter's source for example
15:39kenrestivothat's a great idea, thanks.
15:39muhukyw
15:40muhukanother interesting case could be clojure.java.jdbc
15:41kenrestivointeresting is an apt word
15:42kenrestivoi think in this case i'm going to go all out and write a core.async wrapper
15:42kenrestivothis is an mqtt library. there's already a clojure wrapper that works ok but is kind of thin
15:43kenrestivothere's a neat core.async wrapper for sockets that i found a while ago; i might use that for inspiration
15:43kenrestivocom.gearswithingears/async-sockets <-- something like this for mqtt is what i'd really like, so i'll try writing it
15:45kenrestivobetter link https://github.com/bguthrie/async-sockets the existing wrapper is here https://github.com/clojurewerkz/machine_head
17:35Frozenlo`yogthos: is there a function to create a table of contents in your markdown-clj? I gave it a quick look but found nothing of the sort.
17:47justin_smithFrozenlo`: markdown can do TOC?
17:51Frozenlo`Markdown lets you make titles/subtitles/subsub...titles. A TOC could just take them a link to their anchor.
17:53Frozenlo`/s/take/make
17:59alive876hi, newbie from a tutorial, when i run "lein ring server-headless " i get "'ring' is not a task. Did you mean this? lein run "the main program is here web.clj http://pastebin.com/yJ1Wfr9m and this is project.clj http://pastebin.com/zQn1up7i
18:00Frozenlo`alive876: I think you are missing the lein-ring plugin.
18:01Frozenlo`Wait, that's not the project.clj
18:01justin_smithyeah, that's a namespace, not a project.clj
18:02justin_smithalive876: did you use lein new to make your project, or just copy that one file?
18:03alive876i used this "lein new heroku crisco" from the tutorial
18:03justin_smithalive876: and then did you cd into the created dir before starting lein?
18:04alive876yes
18:04justin_smithcan you share your actual project.clj? because that file above is not a valid project.clj, it's a namespace defining an http server
18:05alive876ok
18:07alive876here is the project,clj, sorry about mixup http://pastebin.com/PZj7CywW
18:08alive876and this is tutorial http://ben.vandgrift.com/2014/04/24/a-clojure-datomic-web-app-tutorial.html
18:08justin_smithalive876: yeah, that project doesn't have the lein ring plugin, so the lein ring commands won't be available
18:09justin_smithI guess that's a bug in the template?
18:09alive876seems to be
18:09alive876there are those other ring deps in there
18:10justin_smitheasiest fix is to add the lein-ring plugin under the :plugins key https://github.com/weavejester/lein-ring [lein-ring "0.9.7"]
18:10justin_smithright, but you need a lein plugin to add lein commands
18:10justin_smithif you don't want to use lein ring you can start ring manually, but lein-ring is convenient (especially for the lein ring uberwar task)
18:11alive876ok, much thanks
18:11justin_smithalive876: one of my complaints about lein is that you can't explicitly ask for a template version (as far as I know), which makes tutorials break :(
18:12justin_smithso the users who are least able to fix the problem are stuck with broken intro materials
18:12alive876yea, as a newbie is kind of discourging
18:13alive876but its nice to have you guys out there!
18:13ecmikebut irc help is encouraging, no?
18:13justin_smithwe try
18:14alive876its the greatest, thats atleast half of why i'm going with clojure
18:14alive876i mean that too
18:24WorldsEndlessCan anyone see why the final line brings a "No matching field found" error? https://www.refheap.com/112349
18:24WorldsEndlessEven autocomplete agrees with all commands, but the REPL won't take it.
18:28WorldsEndlessThink I found the problem. Checking: clojure nil will be read as java "null", right?
18:37alive876at this point it tells me it wants :ring {:handler your.app/handler} , however i'm not sure what your.app is, the project name is "crisco" but i am aware that namespaces may come into play?
18:44gfredericksWorldsEndless: yes, nil and null are entirely the same
18:45gfredericksdifferent names for the same thing
18:45WorldsEndlessDo I need to do anything special to invoke a java final class in Clojure?
18:45WorldsEndlessUsing (Class.) isn't seeming to do it fo rme
18:45gfrederickswhat does invoking a class mean?
18:45gfredericks(Class.) will instantiate it with the no-arg constructor
18:46WorldsEndlessI'm trying to get one of these guys: https://pdfbox.apache.org/docs/2.0.0-SNAPSHOT/javadocs/org/apache/pdfbox/io/MemoryUsageSetting.html
18:47gfredericksdo you know how you would do it in java?
18:47WorldsEndlessBut I'm getting a "no matching ctor" error.
18:48gfredericksright, there is no public constructor it looks like
18:48gfredericks(so that shouldn't work in java either)
18:48WorldsEndlessYeah, thought I just wasn't finding it.
18:48gfredericksthere are various static methods that return instances of the class
18:48gfredericksmaybe one of those does what you want
18:49gfrederickse.g. (MemoryUsageSetting/setupTempFileOnly) would do something (dunno what)
18:49WorldsEndlessYeah, that's what I was wondering
18:49WorldsEndlessOk, I'll try that syntax
18:49gfredericks(works for any static method)
18:54alive876newbie here, in the ring plug-in , it mentions it needs this handler in project file :ring {handler hello-world.core/handler}, hello-world.core supposed to me the path to the core.clj file? tanks
19:00gfredericksalive876: under default leiningen settings, you would have src/hello_world/core.clj with a (defn handler ...) inside it
19:05alive876<gfredericks> thanks. i am not actually using that hello world, one i am instead trying to get this other example working refered to above, where i think the equivalent is this file, http://pastebin.com/zQn1up7i but i don't see any ring handlers defined
19:08gfredericksalive876: `app` is technically a ring handler, but there are features in wrap-app that aren't included there
19:08gfrederickswrap-app isn't a handler, it's a function that returns a handler
19:08gfredericksand I'm not sure how to make that work with lein-ring
19:09alive876so it seems another mistake in this template (?)
20:41troydmhow do I override default toString() implementation for a deftype?
20:41troydmah, nvm
21:14troydmhttps://www.refheap.com/112355
21:14troydmis there any way to improve this?
21:15troydmI mean instead of writing everytime a function for both t and f, to instead use something that would be more suitable?
21:16troydmI'm thinkin of omitting a# part and instead have it just and then write functions as (+ 3 a) etc
21:16troydmbut not sure if it's good idea
21:16michaelroseanyone use vim + clojure + fireplace + eastwood?
21:17troydmmichaelrose: I use but don't use eastwood
21:17troydmmichaelrose: I'm not sure what that even is
21:17michaelroseI seem to have the first 3 working but have some trouble with the last, I just basically want it to highlight stupid errors if any while I'm learning
21:17michaelroseits a linter for syntastic
21:17troydmoic, nope never tried it
21:20michaelroseany decent alternatives?
21:22troydmmichaelrose: not sure, never tried using linters, but you probably can use it from inside clojure code as a library probably
21:22michaelrosethat does not appear to be so
21:22troydmmichaelrose: or some plugin for lein
21:22michaelroseits both a plugin in lein and a vim plugin
21:23troydmmichaelrose: use it as lein plugin then
21:23troydmmichaelrose: not from vim but using command line
21:24michaelrosethat kind of negates the usefulness
21:25michaelrosewell its not so bad evaluating with fireplace gives an error and a line number
21:26WickedShell,(float-array [1 2 3])
21:26clojurebot#object["[F" 0x2336417 "[F@2336417"]
21:26WickedShellhttps://clojuredocs.org/clojure.core/float-array leads me to believe I should get float[] back? not obj?
21:27WickedShell,(type (float-array [1 2 3]))
21:27clojurebot[F
21:27michaelroseand I can still run it from the command line to check the whole project so thats good enough
21:54WickedShellHas anyone ever had a problem creating a java array? all the into-array or float-array etc don't seem to be given me an array back, at least in the REPL if I print I never see []'s and they don't seem quite right (ie type gives me F or LFloat)
22:33TEttingerWickedShell: that's one of those weirdnesses of the JVM
22:33TEttinger,(type (int-array [1 2 3]))
22:33clojurebot[I
22:33TEttinger,(type (long-array [1 2 3]))
22:33clojurebot[J
22:34TEttinger,(type (boolean-array [true true false]))
22:34clojurebot[Z
22:34WickedShellTEttinger, yeah I've determined it seems to be working just that its not a response on type like I expected at all...
22:34TEttingerthose are, with some caveats, essentially the types
22:34TEttingeryou can type hint something as taking a long array with ^longs or with ^"[L"
22:35TEttingererr
22:35TEttingeryou can type hint something as taking a long array with ^longs or with ^"[J"
22:35WickedShellI now wish I marked error's as higher on the state of clojure survey :P I've been tripping on that for a bit for now :P
22:35TEttinger2D long array? [[J
22:35WickedShellis there a list somewhere of the various I J Z stuff?
22:35TEttingeryeah, I found a blogpost a while back...
22:46TEttingerWickedShell: http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/types.html#wp276
22:46TEttingerdamn...
22:46TEttingerclojurebot: primitive arrays |are| http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/types.html#wp276
22:46clojurebotAlles klar
22:47TEttinger~primitive arrays
22:47clojurebotprimitive arrays are http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/types.html#wp276
22:47WickedShellhey thanks! now to bookmark that again as I spent waaay to long on that
22:48TEttingersame here! I can't believe it isn't in a more prominent place somewhere