#clojure logs

2016-05-16

00:24dysfunilevd: ?
00:25dysfuntwo timed bigger than what?
00:25ilevdThan it was in database
00:25dysfunhow do you work that out?
00:26ilevdI do select it returns [B
00:27ilevdIt seems it needs to return bytea as string
00:27dysfunthat sounds about right
00:27dysfunhex encoded, probably
00:29dysfunthere's a bug against mpg to give you back a bytebuffer for bytea
00:30dysfunmeanwhile the project lead on that has gone awol and my release manager has also gone awol, so it's fun times trying to get clojure out recently :)
00:30TEttingeroh, and the byte array could possibly be 2 times bigger, but it depends on encoding I think
00:30TEttingerUCS-4 would be 4 tims bigger :D
00:30TEttingeror at least twice
00:31dysfunTEttinger: however, i happen to know there are only two internal encodings used by postgres: hex and the old one that uses prefix escapes
00:32dysfunboth take ascii
00:32ilevdyeah http://www.postgresql.org/docs/9.5/static/datatype-binary.html
00:33ilevdOk, but how can I get it, I need something like SELECT to_hex(bytea_field) FROM ..
00:34dysfunwell what do you actually get back?
00:34ilevd[B
00:34dysfunthat's byte[], right?
00:35ilevdYes
00:35dysfunbut what is in it?
00:35dysfunit's mysteriously twice as big, are you sure it's not hex?
00:35ilevdI tried to do String.
00:36ilevd(4b030 vs 504b030
00:36ilevdSome symbols are different
00:36dysfunthose are the hex representations?
00:36ilevdYes
00:37dysfunthat looks like it's length prefixed (??)
00:37dysfunbut 50 is a lot more than 4 characters
00:37dysfunsorry, i have no idea. try asking #postgresql
00:38dysfunthey've been quite good at helping me figure things out for mpg
00:49idevI have sequence of maps
00:50idevhow do I convert this to json
00:50idevI have [Elem], wehre each Elem is a map from :keyword => string/double
00:50idevhow do I convert this to json ?
00:50dysfundo you want it to be a json array?
00:50idevsure
00:50dysfunin mpg we use cheshire
00:50dysfunit's just a single function in cheshire.core
00:51idevI like that
00:51idevgenerate-string ?
00:51dysfunyeah
00:51dysfunseqs should get turned into lists
00:51dysfuner arrays
00:55idevdysfun: it works; this was precisely what I was looking for; thanks!
00:55idev(inc dysfun)
00:55dysfunthere hasn't been a karmabot for a while :)
00:56idevdysfun: it's not the karma, it's the thought that counts :-)
00:56dysfun:)
00:56dysfuni just like helping
00:56idevactually, can I tell you a secret?
00:56dysfunit's about all i can do while i wake up enough to do my own stuff
00:56dysfunsure, but the channel is publically logged :)
00:56idevI like types and I'm a haskell user. I'm just using clojure to use apache pdfbox to do pdf processing.
00:57dysfunfair enough. i'm also a haskell user :)
00:57dysfunbut i write more clojure than haskell
00:57ilevddysfyn, it needs to return it as SELECT encode(bytea_filed, 'hex') ..
00:57idevI like "lein repl" more than I like "cabal repl", but at around 2000 lines ,I really start liking types
00:57dysfunthanks. could you drop a note on the relevant issue please?
00:58ilevdOk
00:58dysfunidev: once you're more familiar with clojure you learn how to make it scale better
00:58dysfunthe trick to good clojure is to create fewer, not more types
00:59dysfunfor the most part i only use the type system for performance reasons
00:59idevI use clojure for about 4 years.
00:59idevthen I swithced to haskell.
00:59idevthis isn't my first run with clojure :-)
00:59dysfunfair enough
00:59dysfunwell i like haskell types too, but they're also very annoying at times
01:00dysfuni've got a totally insane template haskell project
01:00idevTH is insane
01:00idevI don't like TH
01:00dysfunnobody who has used TH likes TH
01:01dysfuni feel like haskell is 'getting there' these days. it's got most of what you need to deploy it to production. but it's still going to leave you in hot water wanting to do certain things
01:01dysfunand believe it or not TH was the easy option
01:02idevalmost entirley my project is in haskell
01:02idevit's just that I don't trust ghostscript to process pdfs; and refer apachebox/jvm
01:02idevbreak ghostscript ==> exploit
01:03dysfunuhuh
01:03idevbreak apchepdfbox ==> good luck trying to breka the jvm
01:03engblomI think Haskell is a great language, and still to this day, I have not found a language easier to read than Haskell. If I look at my own old Haskell code, or if I look at code someone else wrote, I learn a lot faster what it does
01:03idevengblom: agreed
01:03idevokay, 'spit' is easiest way to do "String :: Content, String :: FilePath -> IO ()" right? :-)
01:03engblomThe biggest drawback of Haskell I think is cabal. It is not just once I got bitten by the dependency hell
01:04idevengblom: stack/nix has solved a lot of that for me
01:04idevall of us haskell sleeper agents have revealed ourselves, the #clojure purists just these logging who's who :-)
01:04dysfunengblom: i think that's true until people start pissing about with advanced type system stuff
01:04dysfunand overuse of typeclasses
01:04engblomdysfun: That is very true
01:05dysfunsee, i still program haskell like a c++ programmer - using the type system to enforce properties of my program
01:05dysfunthat's not to say my haskell looks anything like my c++, obviously
01:05dysfunjust the general theme of using the type system to gain safety
01:06dysfunand part of my problem is i don't understand some of the more advanced typesystem crack
01:06dysfunundecidableinstances and such
01:06idevwhen ghc suggest I use undecidbleinstances, I rewrit emy typecalsses
01:07idevI don't like 'undecidable' in my compilation process
01:07dysfunwell i'm not terribly keen either, but sometimes when you want to do a thing you know regular haskell can't, you go looking in the extensions page
01:08dysfun'oh, that sounds plausible, what's the worst that could happen'
01:08idevanyone have sample code for pdf -> [images] with pdfbox ? :-)
01:08dysfunjust translate the java code you find on stackoverflow to clojure?
01:09dysfunit'll remind you how much less typing you do in clojure than java :)
01:10idevokay, I just need https://gist.github.com/anonymous/3aec465332e06f34326b4630c1c84b44
01:10idevto conver to clojure
01:10engblomI am not a professional programmer, I just write 1-2 small projects a year in my spare time. Because of this I am very slow to progress in a language as there are often more than a half year between the coding sessions. For me, Clojure is the language I am most productive in given the little time I have for programming nowadays.
01:10idevoh yeah, that's why I'm using clojure and not java
01:10idevengblom: haskell has a steep steep learning curve
01:11idevthe other day I was reading LogicT (equiv to scheme's minikanren and clojure's core.logic
01:11idevit took me 2 days to even understand what the types meant
01:13dysfunhaha
01:13dysfuni get bored well before that happens
01:14engblomI think the learning curve for Haskell is not particularly steep if you take a book like "Learn you a Haskell for great good". It all depends on what material you learn from
01:15engblomIt took not long time for me to have the computer to play perfect "NIM" (The real multirow NIM) against me after I read that book.
01:20dysfunidev: i commented on it with most of the hard work done, the rest is just clojure
01:20dysfunyou will need to :import the appropriate things
01:27dysfunengblom: i wish they would put different wording into the books where monads are concerned though
01:27dysfunit's difficult for newbs to figure out how to make io stuff work
01:53idevdoes clojure have C's fprintf ?
01:53idevI want to have a string of the form " .... special chars ... " and then the args after it
01:54dysfunsprintf, you mean?
01:54TEttinger,(doc format)
01:54clojurebot"([fmt & args]); Formats a string using java.lang.String.format, see java.util.Formatter for format string syntax"
01:55TEttinger,(format "%04d then a thing here %04d" 1 10)
01:55clojurebot"0001 then a thing here 0010"
02:10idevokay, got that working
02:10idevthanks!
02:10idevdysfun: TEttinger : yes, got it working :-)
02:10idevhttp://www.oracle.com/technetwork/articles/javaee/jai-142803.html <-- apparently apache pdfbox is complaining I don't have this iamge
02:10dysfun:)
02:10idevthis library installed
02:10idevwhat is the line to add to project.clj for http://www.oracle.com/technetwork/articles/javaee/jai-142803.html ?
02:11idevMay 15, 2016 11:10:52 PM org.apache.pdfbox.filter.JPXFilter decode
02:11idevSEVERE: ImageIO.read() did not return any data - is JAI installed?
02:11dysfunno idea. see if you can find a maven example
02:12idevmaybe https://gist.github.com/anonymous/31ff55d0c259f012174d5ed739f561cf
02:14dysfunthere you go
02:14dysfun[javax.media.jai/com.springsource.javax.media.jai.core "1.1.3"]
02:21ilevdOne line is less than five
02:21dysfunyup
02:29idev:-)
02:29idevthis is something that I know how to do in haskell
02:30idevlet's see if we can do it in clojure
02:30idevI have a function f which has side effects
02:30idevI want to call it 200 different times, on different args, i..e (f a1) (f a2) ... (f a200)
02:30idevnow, I have 8 cores, so I want 8 of these to run at any given time
02:30idevhow do I express this concurrency primitive in clojure?
02:30idev(defn run-8-at-a-time [f lst] .... )
02:32dysfunyou want a thread pool library
02:32idevI don't need to run all 200 at the same time
02:32idevI'm okay with *delaying the fork*
02:32dysfunwhat fork? there won't be a fork
02:33TEttingerthere is a thread pool in java by default
02:34idevthese thigns ar ememory heavy
02:34TEttingerthreads? yes
02:34idevI don't want (f 9) to even start procesing until one of (f 1) -> (f 8) has finished
02:34dysfunright. do you want to list your actual requirements all at once rather than dripfeeding them?
02:34idevsorry
02:35idevthis is my fault
02:35idevlet me wirte up a gist
02:35idevI also want this to be webscale: https://www.youtube.com/watch?v=b2F-DItXtZs
02:35dysfunthere is a video somewhere on the internet of the audience chanting 'web scale' at me every time i say it on stage
02:36dysfun(may have been using my platform as a conference speaker to mock technology again)
02:37TEttingerwebscale is a fun non-meaningful term
02:37TEttingerlike dynamic
02:37dysfunoh dynamic is a well defined term
02:37idevhttps://gist.github.com/anonymous/f0d5bf799975b2e3876f56f76502429f
02:37dysfunit means "moves underneath you unexpectedly a lot". "a dynamic specification"
02:38TEttingerdynamic programming, dynamic typing, like a dynamo
02:38idevdysfun: let me know if any part of that is not clear
02:38idevbasically, I'm after conclbock from zsh http://galvanist.com/post/67095577027/revisiting-shell-concurrency-this-time-in-zsh
02:38TEttingerhttps://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ThreadPoolExecutor.html I believe does this, you'd want a lib that wraps it because it's kinda nasty
02:39dysfunidev: yeah, have a look at the pools listed on clojure-toolbox.com
02:39idevhttp://stackoverflow.com/questions/1768567/how-does-one-start-a-thread-in-clojure
02:39idevI want to wrap a (.start (Thread ... ))
02:39dysfunyou don't start a thread, you use a thread pool
02:40dysfunbecause starting a thread is asking for trouble
02:40idevwhy not? with a thread pool, how can I control when something is started
02:40dysfunyou cap the size of the thread pool and then queue up work
02:41TEttingeryeah
02:43TEttingerhuh, weird I can only find https://github.com/TheClimateCorporation/claypoole/
02:44dysfunthere's also https://github.com/ztellman/dirigiste/
02:46TEttingerdirigiste looks good
02:51engblomidev: Before taking a library into use, you could check if pmap is close enough to your requirements to work in your case. pmap will check how many cores are available and tries to max them out.
02:51TEttingeruh...
02:52dysfunengblom: don't recommend pmap
02:52TEttingernot in this case I wouldn't recommend it
02:52dysfunpmap?
02:52clojurebotpmap is not what you want
02:52TEttingerin most cases
02:52dysfunbotsnack!
02:52TEttingerpmap would try to run I believe 34 instances of his super-memory-using state-affecting fn
02:52engblomThe biggest problem with pmap, in my opinion, is the semi lazyness
02:53TEttingerit was a weird number higher than most core counts I recall, not 34 necessarily
02:55engblomn (+ 2 (.. Runtime getRuntime availableProcessors)) <---- Is from (source pmap)
02:58TEttingerhm. I'd still be careful with it, I haven't yet encountered a problem where pmap actually produces a speedup
03:08engblomhttp://drcabana.org/2011/06/04/a-simple-parallel-computation/ <--- In this case map seem to be 3.5 times slower than pmap
03:09engblomBut I agree it might be difficult to find good cases for pmap
03:14TEttingerthat seems kinda dated, he isn't using +' so that would have been from when + auto-promoted
03:16ilevdSome big tasks, like get and parse html, no?
03:49ben_vulpeshttps://www.youtube.com/watch?v=fA9ZXy4N13s&amp;index=6&amp;list=PLZdCLR02grLq4e8-1P2JNHBKUOLFTX3kb << relevant
05:07idevis there a shorter way to write (fn [x] (.getName x))
05:08dysfun#(.getName x)
05:08ideverr, the x isn't defined in your code
05:08dysfun%
05:08dysfun(.getName %)
05:08M570`#(.getName %)
05:09dysfunalso (memfn getName)
05:10idev#(.getName %) looks familiar
05:10idevworks
05:10idevis what I was trying to recall
05:33idevhow do I check if a string ends in ".pdf"
05:33dysfun(.endsWith string "\\.pdf")
05:34drk_lrd_777_hi is this the correct place to post if I am having a problem with leiningen?
05:34dysfundrk_lrd_777_: it's as good as any
05:34douglarekdrk_lrd_777_:maybe should use a paste
05:34douglarekservice like gists
05:35drk_lrd_777_The issue I am having is that when I compile my file through lein, the resulting jar file does not print to stdout when run.
05:35drk_lrd_777_I can see the code works fine
05:35drk_lrd_777_as it makes a HTTP call
05:35drk_lrd_777_which i have traced usign tcpdump
05:36drk_lrd_777_but the final output is not printed to screen
05:36drk_lrd_777_any help is appreciated
05:36drk_lrd_777_thanks in advance! :)
05:36dysfunthat's weird
05:37dysfunhow are you printing to the screen?
05:38TEttingerdrk_lrd_777_: running with java (java.exe on windows) or javaw (javaw.exe)?
05:39TEttingerif you double click a jar it runs with javaw by default on windows, which suppresses the console
05:39drk_lrd_777_the usual (print "printme")
05:39drk_lrd_777_and im using linux
05:39TEttingerI mean how are you running the jar?
05:39drk_lrd_777_java -jar filename.jar
05:40drk_lrd_777_here is my project.clj in case it may be of any help http://pastebin.com/EhrWcq4h
05:40drk_lrd_777_ill post the code too
05:40TEttingerwas it made with the command "lein uberjar", which is a recommended way to build self-contained runnable jars?
05:40drk_lrd_777_yes
05:40drk_lrd_777_i ran "lein compile && lein uberjar"
05:40TEttingerproject.clj looks solid
05:41TEttingeruberjar should do the first step
05:41TEttingerclean it may not do
05:41drk_lrd_777_main file :: http://pastebin.com/zRFZYjBW
05:41TEttingerdo you have a -main fn in there? I'll look
05:41drk_lrd_777_yes
05:42TEttingerthis looks solid so far... not sure what's up. try changing print to println, it could be a terminal needing to flush a line
05:43drk_lrd_777_okay im trying that
05:44TEttingerwhat does rss/channel-xml do? I'm wondering if the whole of the xml string is empty
05:45drk_lrd_777_it generates an rss feed
05:45drk_lrd_777_it works fine when i run on the REPL
05:45drk_lrd_777_which is why im confused
05:45TEttingerok, maybe try changing the (def xml ...) to (def xml "a placeholder")
05:46TEttingeryou can comment out the current def
05:46TEttingermy favorite way is with #_(def ...)
05:46TEttingerwhich causes the whole form to be ignored as long as the parens match
05:46drk_lrd_777_okay lets see how this goes
05:47drk_lrd_777_im waiting for it to compile to try the println thing first
05:47drk_lrd_777_after that ill try this
05:47TEttingersure
05:47TEttingeris compilation taking a long time? I know uberjar slows things down a bunch
05:47drk_lrd_777_it takes about 2 minutes
05:47TEttingeryou can test with "lein run" as well
05:48TEttingerwhich won't make the jar
05:48drk_lrd_777_but it works fine with lein run
05:48TEttingeroh. weird...
05:48TEttingercan you send the jar over? I don't know what sites host that, https://ge.tt maybe?
05:49drk_lrd_777_wow
05:49drk_lrd_777_the println thing worked
05:49TEttingerhaha whaaaaat
05:49drk_lrd_777_but i dont understand why
05:49TEttingerconsoles are magical snowflakes
05:50TEttingerI think this one wouldn't print a line until the line was finished, println (or printing a newline) should flush the line, but I'm no expert
05:50dysfunhysterical raisins
05:50drk_lrd_777_hahahah weird stuf
05:50TEttingeri'm stealing that dysfun
05:50dysfunsee also gary bernhardt's talk about why the terminal sucks
05:51drk_lrd_777_thanks a lot though
05:51TEttingerglad to help!
05:51TEttingerthat's a weird bug!
05:51dysfunsuch bugs are quite commonplace
05:51TEttingeryour code looks fine, are you just starting out? It looks like the project is new but you already know what libs to use
05:51dysfuna lot of things rely upon the c libraries
05:51drk_lrd_777_yeah
05:52drk_lrd_777_im laerning functional
05:52drk_lrd_777_so started whith clojure
05:52TEttingerit's a good choice
05:52TEttingerthe names of things are so important and clojure mostly has excellent names
05:52drk_lrd_777_my design is not "elegent" though im trying to improve on that
05:52drk_lrd_777_hahah yeahh
05:52TEttingerlike "reductions"
05:53dysfunand not like 'eductions'
05:53TEttingerit's the sequence of stuff produced at each step of reduce
05:53drk_lrd_777_im really happy with the number of libraries it has
05:53TEttingerclojure calls reductions scan or scanl I think
05:53drk_lrd_777_hmm dont know about that yet
05:53TEttingereven though it's clearly related to foldl in haskell, reduce in clojure
05:53TEttingererr
05:54TEttingerhaskell calls reductions scan
05:54dysfunoh, i hadn't realised
05:54TEttingeryou'll use reductions rarely, but the name explains it's related to reduce
05:54drk_lrd_777_yeah i just googled it
05:54drk_lrd_777_reading the first article it shows
05:54TEttinger,[(reduce + [1 2 3 4 5]),(reductions + [1 2 3 4 5])]
05:55clojurebot[15 (1 3 6 10 15)]
05:55TEttinger(put in one vector because clojurebot returns one thing at a time)
05:56dysfun,(let [a (reductions + [1 2 3 4 5])] [a (reduce + a)])
05:56clojurebot[(1 3 6 10 15) 35]
05:56drk_lrd_777_wait .. how did you do that?
05:56TEttingernice thing about clojure's lisp-y stuff, comma is just a whitespace char
05:56drk_lrd_777_I want to use the bot!
05:56TEttingeroh uh
05:56dysfunyou put a comma on the front
05:56drk_lrd_777_,(println "hello")
05:56clojurebothello\n
05:56drk_lrd_777_omg
05:56TEttingercomma then a single clojure form like (+ 1 (* 3 5))
05:56drk_lrd_777_yeah i figured it out
05:56TEttingerit's sandboxed very well
05:57drk_lrd_777_this is awesome!
05:57TEttingerI don't think anyone has broken lazybot
05:57TEttingererr clojurebot
05:57TEttingerlazybot had some flaws but is no longer here
05:57drk_lrd_777_what if someone gives it like the ackerman function?
05:57TEttingerit only prints the first 5 elements
05:57TEttinger,(range)
05:57clojurebot(0 1 2 3 4 ...)
05:57drk_lrd_777_ahh
05:57drk_lrd_777_nice
05:58TEttingerlots of channels have these bots, clojurebot happens to be a very nice one :)
05:58dysfunbut i miss karma
05:59drk_lrd_777_,(print "my jar wont print this")
05:59clojurebotmy jar wont print this
05:59drk_lrd_777_lol
05:59TEttinger,(def PHI (* 0.5 (inc (Math/sqrt 5)))
05:59clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
05:59TEttinger,(def PHI (* 0.5 (inc (Math/sqrt 5))))
05:59clojurebot#'sandbox/PHI
05:59dysfunyeah, clojurebot doesn't support autocompletion or paren matching
05:59TEttinger,(def TAU (* 0.5 (- 1 (Math/sqrt 5))))
05:59clojurebot#'sandbox/TAU
06:00TEttinger,(defn fibonacci [n] (/ (Math/pow PHI n) TAU))
06:00clojurebot#'sandbox/fibonacci
06:00TEttinger,(map fibonacci (range 5))
06:00clojurebot(-1.6180339887498947 -2.618033988749895 -4.23606797749979 -6.854101966249684 -11.090169943749475)
06:00TEttingerugh
06:01dysfun,(def a (agent []))
06:01clojurebot#'sandbox/a
06:02dysfun,(doseq [i (range 10)] (send-off conj :foo))
06:02clojurebot#error {\n :cause "clojure.core$conj__4345 cannot be cast to clojure.lang.Agent"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.core$conj__4345 cannot be cast to clojure.lang.Agent"\n :at [clojure.core$send_via invokeStatic "core.clj" 2009]}]\n :trace\n [[clojure.core$send_via invokeStatic "core.clj" 2009]\n [clojure.core$send_via doInvoke "core.clj" 2009]\n [clojure.lang....
06:02dysfun,(doseq [i (range 10)] (send-off a conj :foo))
06:02clojurebotnil
06:02dysfun,a
06:02clojurebot#object[clojure.lang.Agent 0x298a64c4 {:status :ready, :val []}]
06:03dysfunhrm. i suspect you could probably denial of service. does it have a timeout?
06:03TEttingeryes
06:03TEttingerall defs are erased every 10 minutes
06:05TEttinger,(defn fibonacci [n] (/ (Math/pow (* 0.5 (inc (Math/sqrt 5)) n) (Math/sqrt 5)))
06:05clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
06:05TEttinger,(defn fibonacci [n] (/ (Math/pow (* 0.5 (inc (Math/sqrt 5)) n) (Math/sqrt 5))))
06:06clojurebot#'sandbox/fibonacci
06:06TEttinger,(map fibonacci (range 5))
06:06clojurebot#<ArithmeticException java.lang.ArithmeticException: Divide by zero>
06:06TEttingergah
06:06TEttinger,(map fibonacci (range 1 6))
06:06clojurebot(0.3409490070205292 0.07237122042538442 0.029228994185835057 0.015361809062386312 0.009327064627560907)
06:06TEttingerI screwed up
06:06TEttinger,(defn fibonacci [n] (/ (Math/pow (* 0.5 (inc (Math/sqrt 5))) n) (Math/sqrt 5)))
06:06clojurebot#'sandbox/fibonacci
06:06TEttinger,(map fibonacci (range 1 6))
06:06clojurebot(0.7236067977499789 1.1708203932499368 1.8944271909999157 3.065247584249853 4.959674775249769)
06:06TEttinger,(defn fibonacci [n] (Math/round (/ (Math/pow (* 0.5 (inc (Math/sqrt 5))) n) (Math/sqrt 5))))
06:06clojurebot#'sandbox/fibonacci
06:06TEttinger,(map fibonacci (range 1 6))
06:06clojurebot(1 1 2 3 5)
06:07TEttingerthere we go
06:21ilevd,fibonacci
06:21clojurebot#error {\n :cause "Unable to resolve symbol: fibonacci in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: fibonacci in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: fibon...
06:22ilevd,(def a 1)
06:22clojurebot#'sandbox/a
06:22ilevd,a
06:22clojurebot2
06:22ilevd:D
06:27idevhow do I wrap a function to say "if this function throws an exception, just return :foo-bar instead of having it propogate ?"
06:28idev(try ... (catch Exception e :foo-bar))
06:32dysfunyou have answered your own question?
06:33idevyes
06:33idevI wrote my question, then I wondered "what would dysfun say"
06:33idevand I wrote that down
06:33idevit's like rubber duck debugging
06:33dysfunhaha
06:33idevalso happened to be one of the top results on google
06:33dysfun"what would dysfun say?" would make a great t-shirt
06:35idevhttps://gist.github.com/816e017356c1ad4ce6a303c70079d910
06:35idevthat should, in theory, prevent the exception from propogating upwards right?
06:35idevbecause it's not
06:36dysfunhuh?
06:36dysfunare you sure you haven't just typo'd it somewhere?
06:36dysfuncause that really should
06:37idevlet me check for dumbass mistakes
06:38idevhttps://gist.github.com/anonymous/290358e678edff8d970486b530074b84 is the error
06:39idevit hosuld be catchable right?
06:42idevhmm
06:42idevdoes Excpetion catch *JAVA* exceptions
06:42idevor only Clojure Exceptions ?
06:43dysfunException is a java class
06:43dysfunall Exceptions inherit from it, including Clojure's
06:45shiranaihitodoes something throw a Throwable instead of Exception?
06:45shiranaihito(because IIRC that would not be caught by catching Exception)
06:45idevcode: https://gist.github.com/anonymous/d9a512484242b1c0bc18c95150fedc5b
06:45dysfunthis is ArrayIndexOutOfBoundsException
06:45ideverror: https://gist.github.com/anonymous/91c03f360533477e7c37bc2e2f3dd3d7
06:45idevthere's only one source file
06:47idevsorry for messy code; have not done clj in recent past
06:48shiranaihitowell.. maybe it gets thrown outside of your catch for Exception? .. you have some threading stuff going on there?
06:49idevI don't think taht is problem, but I will single thread it for this
06:50idevwithout future/deref: https://gist.github.com/1d8fc760637081267dc9794c0410f131
06:51idevsame error: https://gist.github.com/anonymous/3c795b4c08523ee4e7cbab632a5d19bf
06:57idevalright; time to get my rubber duck
06:57idevif this was haskell, i'd be thikning laziness issues
06:57idevand returning a thunk that is not caught
06:57idevbut this is clojure
07:02dysfunclojure des have lazy seqs
07:03idevyeah; but IO should not be lazy
07:04dysfunno, it's not
07:04idevhmm; with Throwable, it continues
07:05idevwhoever that told me to try Throwable -- I'm sorry I didn't listen to you
07:05idevbut why does Throwable work ?
07:05dysfunpresumably the exception you got is not a subclass of Exception but implements Throwable
07:06idevhttps://docs.oracle.com/javase/7/docs/api/java/lang/ArrayIndexOutOfBoundsException.html
07:06dysfuni thought all errors in the standard library were subclasses of Exception, however
07:06idevbut taht clearly is an Exception
07:06kwladykaIs there somebody who use atom editor for Clojure?
07:07dysfunyep, it clearly is
07:07MJB47i do
07:07kwladykaI was trying emacs, but in my subjective opinion..... it is step backward not forward (don't banish me please, i know it is like religion)
07:07kwladykaand now i consider atom vs intellij
07:07idevclearly I should println the Throwable
07:08MJB47atom clojure isnt as mature as emacsw
07:08MJB47but lisp paredit is suitable (though noticeably missing raise by default :( )
07:08MJB47and proto-repl is pretty cool
07:08MJB47it works well enough
07:08ridcully_kwladyka: what are your major pain points with intellij that make you look for an alternative?
07:08MJB47though not as feature rich as cider
07:08engblomkwladyka: Have you had a look at https://sekao.net/nightcode/ ?
07:09idevdysfun:
07:09idevdysfun: https://gist.github.com/anonymous/a1383f0a5d7c1d2c133d44e0c84d0306
07:09idevlooks like the ApachePDFBox code prints the eception
07:09idevthen throws an error
07:09idevWTF
07:09engblomkwladyka: While I use vim myself, I have had success in introducing other to Clojure using Nightcode as IDE
07:10dysfunErrors are supposed to be unrecoverable btw
07:11amoeusing prismatic schema, I tried to create a schema which matches either the keyword :all or a list of arbitrary keywords. I came up with this. (s/validate (s/conditional keyword? :all :else [s/Keyword]) :all)
07:11engblomkwladyka: The reload function works quite well in Nightcode, so once you begin writing something, just keep the REPL running and click the "Reload" button to thest the newly written function
07:11amoeBut this fails with the error "IllegalArgumentException No implementation of method: :spec of protocol: #'schema.core/Schema found for class: clojure.lang.Keyword clojure.core/-cache-protocol-fn (core_deftype.clj:568)"
07:14kwladykaI like to have editor with using mouse less as possible like emacs, but with power and usability of intellij and additions. Like for example less file type syntax what sucks in emacs or easy configuration. Something where things are ready. I don't want write my own editors, i want use it :)
07:15kwladykaengblom you made things more complex, now +1 editor to consider :)
07:15shiranaihitoidev: wow.. :p
07:16idevdysfun: I think this is okay in this case, since I'm writing out pages of a pdf
07:16idevso if page 23 fucks up, there's no reason it prevents me from writing page 25
07:16engblomkwladyka: Nightcode can be used with keyboard...
07:17dysfunokay :)
07:17dysfunglad you solved it anyway
07:17dysfunbonkers erorr
07:18amoeactually, more generally
07:18amoewhat's wrong with this: (s/validate {:foo :bar} {:foo :bar})
07:18shiranaihitoidev: so PDFBox swallows an Exception, prints its stacktrace, and then throws an Error instead?
07:19idevshiranaihito: apparently so :-)
07:19shiranaihito.. glorious :P
07:20shiranaihitoare you going to send them a bug report or something?
07:20idevno
07:20idevI don't want to deprive anyone else of the learning experience
07:20shiranaihito:P
07:20idevthis has taught me to be fucking paranoid with try/catch
07:20dysfunit's java, java is shit, end of.
07:20shiranaihitoi'm sure someone will be just as thankful to you as you are to Apache :p
07:21shiranaihitobut i think it would be better to report it
07:21shiranaihitowho knows, maybe they'd even fix it
07:21dysfunlike every boss i've ever had?
07:22shiranaihitoJava itself is not shit, but maybe a programmer somewhere is
07:22amoeAh, I need to use s/eq for the leaf values
07:22dysfunthe apache libraries vary massively in quality
07:23dysfunthe apache foundation these days is a dumping ground for everyone's old unfashionable shit with the occasional gem mixed in
07:23shiranaihitojust like all open source in general? :)
07:24dysfunexactly
07:25shiranaihitoand yet, somehow lots of pretty good libraries have such professional maintainers that they don't mind those eternal apache-commons turdnuggets from the 90's or something among their libs' dependencies!
07:29dysfunfrequently the libraries make it possible but not easy
07:29dysfungreat libraries, terrible APIs
07:29shiranaihitomake what possible?
07:29dysfunwhatever the task they solve is
07:33idevhttps://clojuredocs.org/clojure.core/add-watch
07:33idevwhere is the full watch documentation?
07:33clojurebotIt's greek to me.
07:33idevI'm looking for all ops I can perform on references / watches
07:35shiranaihitodysfun: i'm not sure we were talking about the same thing
07:36justin_smith,(supers clojure.lang.Ref) ; idev
07:36shiranaihitoanyway, i just wanted to take an opportunity to complain about pointless commons libs still being lugged around :)
07:36clojurebot#{java.lang.Comparable clojure.lang.IFn clojure.lang.IReference java.util.concurrent.Callable clojure.lang.ARef ...}
07:36justin_smithidev: it's a larger set, but anyway, the details of each of those interfaces should let you know what they can do.
07:37justin_smith,((ref +) 1 1) ; TIL
07:37clojurebot2
07:37justin_smiththanks idev, I would never have thought to check what a ref would do when used as a function :)
07:37idevI think http://clojure.org/reference/refs is what I wnat
07:38justin_smiththat page doesn't mention the above trick last I checked
07:38justin_smithso you don't want all the operations, just the normal / recommended ones
07:41idevhow do I implement consumer/producerin clojure with a shared queue?
07:41justin_smiththe simplest way is with a shared queue.
07:41justin_smithhaha
07:41idevwhat java calss is that?
07:42justin_smithanyway, people usually use core.async (but many times it's much more than they need)
07:42justin_smithidev: java.util.concurrent.PersistentBlockingQueue
07:42justin_smithyou can read from it in one thread and write to it in another
07:43justin_smitherr
07:43justin_smithjava.util.concurrent.ArrayBlockingQueue https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ArrayBlockingQueue.html
07:45justin_smith,(def q (ref clojure.lang.PersistentQueue/EMPTY)) ; another option
07:45clojurebot#'sandbox/q
08:00idevso clojure does NOT provide tail call recursion
08:00idevbut provides loop/recur ?
08:01dysfunloop/recur implements tail call recursion
08:02idevright
08:02idevbut in scheme I can just recursively call self as last pos
08:02idevin clojure I can't do this due to java stack frames?
08:03dysfunit's a jvm limitation
08:03dysfunit matters less in practice than you'd think
08:03dysfun(idiomatic clojure tends to use builtins)
08:04idevyeah; but I'm implementing my own worker-consumer system
08:04idevand I want to amke sur etaking from the queue does not consume stack sapce :-)
08:05dysfunso use an atom and a PersistentQueue
08:06idevended up using a LinkedBlockingQueue
08:06idevall these "usupported/disable doperation" makes me uncomforable (from apache pdfbox)
08:09idevdamn it robust systems are so hard
08:09idevbut I think I got it owrkking now
08:13shiranaihitoso how rickety is PDFBox in general? :)
08:13idevit's pretty nice
08:13idevmuch better than ghostscript imho
08:13idevI'm just a retard and didn't consdier all possible exceptions/errors that can be thrown
08:13idevfor examle: can't open a pdf file ==> need to catch exception, otherwise a worker thread dies :-(
08:14idevso it's relaly more my incompotencen and not so much pdfbox fault
09:04shiranaihitoidev but throwing Error is pretty nasty
09:05shiranaihitoweird shit
09:29jonathanjidev: what are you using pdfbox for?
09:47dysfunsaving a pdf to images
09:55jonathanjidev: what process are you using to convert pdf documents to images? my experience using PDFRenderer was that it was ridiculously (multiple seconds per page) slow, searching the mailing lists this is kind of a known thing
09:56dysfunjonathanj: if you have a backlog, we discussed this earlier
09:56jonathanjidev: we recently switched to using imagemagick "convert" (which i guess uses ghostscript under the hood?) and now we're getting <2s render times for entire documents
09:57dysfunhe was untrusting of ghostscript
09:58jonathanji see
10:05dimon_hi, guys, do you mind take a look at this https://stackoverflow.com/questions/37255809/how-to-setup-korma-in-luminus-or-compojure-projects ?
10:06dysfundimon_: you'll typically load it from a config file
10:06dysfunnot project.clj, just an ordinary config file
10:07dysfunif you fix it in your project.clj then when you go to production you won't be able to change which db server it points to without rebuilding the artifact!
10:07dimon_dysfun: is there any example?
10:08dysfuni quite like https://github.com/TouchType/conf-er
10:08dysfunbut it depends on your config needs
10:08dimon_dysfun: "if you fix it in your project.clj then when you go to production " -- why not if I setup the production connection string before I build the jar?
10:09dysfunyou'll just have to trust me on this, but when you're in production, you either want something that doesn't need a configuration or a config file
10:10dysfunin fact, i'm an advocate of putting the structure of your application in a config file! https://github.com/irresponsible/oolong/
10:11dimon_dimon_: sorry, I don't understand why not.
10:11dimon_thanks for the links, but that's for configs.
10:11dimon_whereas I'd like to know
10:11dimon_the idiomatic way to setup Korma
10:11dimon_and sorry, I don't understand why I can't use project.clj
10:11dysfunin production, you don't have a project.clj
10:11dimon_for the production connection string
10:12dysfunthe simplest way to deploy an app is java -jar my.jar
10:12dimon_but it's it or its content get embedded into a jar?
10:12dysfunif you put your data in project.clj (as you can do with some libraries), then it's hardbaked in when you build the jar
10:12dysfunno, they do not
10:13dysfunthere is some metadata xml and your clojure files and java files. that is it
10:14dysfunso what you should do instead is deploy a directory containing a jar, a config file and any resources you require that the user might want to update (i.e. that aren't baked into the jar)
10:14dimon_alright, so I can create a config file and copy it on a prod. server?
10:14dysfunyes. at deploy time, you will copy over your jar and config file
10:15dysfunand any resources your jar is dependent on that aren't baked in
10:15dysfun(e.g. html templates)
10:15dimon_ok. but today I deploy only a single jar without the directory "templates" and it worked well.
10:16dysfundid you bake templates into the jar?
10:16dimon_hmmm, I think I haven't copied those template files on the server
10:16dysfun(if you put them in resources, probably)
10:16dimon_dysfun: probably, I just built a jar the way you normally do.
10:16dysfunthat's a perfectly valid strategy, but bear in mind that you can't then change it while the server is running
10:17dimon_ah, yes, they're in the "resources" directory, so I can put my config in it as well. Although I think it's better not to.
10:18dysfuni tend to find it inconvenient rebuilding releases just to change some configuration
10:18dimon_I see. Thanks
10:18dysfunyw :)
10:19dysfunthere are two schools of thought on this btw
10:19dysfunthe other one favours environment variables
10:20dysfunand clojurists who grew up on java might even say properties files
10:20dysfunbut they're wrong ;)
10:22dysfunhttps://github.com/weavejester/environ has support for what you actually asked for if you're convinced i'm wrong
10:23sdegutisGood morning. What are transducers useful for to an app developer (not library developer)
10:23MJB47performance (sometimes)
10:24dysfunreuse of a transform (e.g. across core.async)
10:33sdegutisMJB47_: when?
10:33MJB47_when you chain transducers, they do the transformation without the intermediary data structures
10:33MJB47_so instead of doing map, and then filter, it does them both in 1 go
10:33MJB47_which helps... sometimes
10:36sdegutisMJB47_: Ah, that could be very helpful to me. Thanks!
10:37ilevdCan Clojure be faster than Java?
10:38MJB47_hard to define
10:38MJB47_they both compile down to JVM byte code
10:38MJB47_so in theory they are comparably performant
10:38MJB47_but the thing is
10:38Arieanyone here using re-frame?
10:39MJB47_do you mean perfectly performance tuned clojure vs perfectly performance tunes java? or idiomatic clojure vs idiomatic java? etc
10:39MJB47_in general, clojure will be/can be as or more performant than java
10:39MJB47_there isnt anything necessarily holding it back
10:39ilevdClojure with some magic like transducers vs idiomatic Java
10:40MJB47_well you can do the same sort of thing in java
10:40MJB47_and if performance were a main concern, you probably would
10:41ilevdYeah
10:41ilevdIt's nice that one can add java files to clojure project
10:42ilevdArie, I only read about it and want to use :)
11:05justin_smithidev: dysfun: there's no reason that clojure could not detect tail-calls and turn them into recur automatically, but it's actually useful (and prevents a common source of errors) to require the usage of recur explicitly, so that you can reject it when it's not the tail position
11:05justin_smithnow generalized tail-call elimination (that might not be recursive) - that is a jvm limitation - goto can't cross method boundaries
11:06justin_smithand a good scheme or common lisp can eliminate tail-calls that are not recursive
11:11justin_smithilevd: transducers can help you approach the performance of idiomatic java, but persistent data structures have a cost (though they are very optimized), in clojure code that's in a bottleneck and needs to be faster, sometimes it makes sense to use java arrays and hash-maps for the extra performance boost.
11:12justin_smithBut there's tradeoffs there between performance and correctness / clarity.
11:54wutfanyone using lispy-mode?
11:54wutfi can't figure out how to write a simple defn with args because [ and ] are bound !
11:54wutfsupposedly it's been tuned for clojure
12:09justin_smithwutf: I just skimmed the docs, but shouldn't [ and ] only do their special thing when your cursor is on a paren?
12:11wutfthat's what i thought, but it doesn't work that way
12:53lokien_hey guys, long time no see
12:54lokien_hey guys, long time no see
12:54lokien_what are the best bindings for javafx?
12:56lokien_are you using javafx with clojure at all?
13:27lokien_:^(
15:24Wojciech_K,((fn [f] (f 3)) Math/sqrt)
15:24clojurebot#error {\n :cause "Unable to find static field: sqrt in class java.lang.Math"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to find static field: sqrt in class java.lang.Math, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to find stat...
15:25Wojciech_Ksqrt is Math static field
15:25Wojciech_K(Math/sqrt 3)
15:25Wojciech_K,(Math/sqrt 3)
15:25clojurebot1.7320508075688772
15:25Wojciech_K?
15:29Wojciech_Ka wrapper works fine
15:29Wojciech_K,((fn [f] (f 3)) (fn [x] (Math/sqrt x))
15:29clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
15:29Wojciech_K,((fn [f] (f 3)) (fn [x] (Math/sqrt x)))
15:29clojurebot1.7320508075688772
16:02justin_smithWojciech_K: on the jvm, a static field is not a first class entity
16:02justin_smithas such, you can't pass it as an argument to a function
16:02justin_smitharguably, clojure could implicitly wrap it in a lambda, but the choice was made to make that conversion explicit (it isn't free)
16:03justin_smithWojciech_K: oh, it isn't a field, it's a method - the vm handles those things differently
16:04justin_smitha static field can have its value resolved, and that value can be used as an arg
16:04justin_smith,(* Math/PI Math/E)
16:04clojurebot8.539734222673566
16:04justin_smithsorry for the inaccuracy of the initial reply
16:11herakleitosDoes anyone know if calling keys on a map is stable? I noticed that there's a comment on clojuredocs saying that keys doesn't always return in the same order, but I was wondering if that's been fixed since.
16:12lumathere's no defined order for keys in a map (unless it's a sorted map)
16:12justin_smithherakleitos: "fixed"?
16:12justin_smithherakleitos: there is a guarantee that keys and vals return items in matching order
16:12justin_smithbut no guarantee about order between elements in general
16:13lumafor the same map instance, the order is always the same
16:14herakleitosThanks, that's what I wanted.
16:15justin_smithalso, for code that needs keys and vals to be in the same order, there is often a simpler and more efficient alternative that iterates over the pairs rather than iterating over two separate sequences
16:17herakleitosI'm calling keys on the same map instance at 2 different places in my code and I want to be sure that it'll always return in the same order.
16:18justin_smithfor the same map, yeah
16:31sdegutisSometimes I want (contains-value? val coll)
16:32justin_smithlike contains? but with the args in the wrong order and checking vals not keys?
16:32luma(some #{val} coll)
16:33sdegutisjustin_smith: yes, so that I can chain it at the end of a ->>
16:34sdegutis(->> coll (map :something) (filter wicked-cool?) (some #{needle}))
16:34sdegutisluma: thanks
16:34lumanote: might break if val is falsy
16:34sdegutisright
16:35sdegutisI don't think I've ever run into that use-case yet.
16:35sdegutisNever needed to search for "false" in a collection to date.
16:38justin_smith,(.indexOf [true nil false :a] false) ; sdegutis
16:38clojurebot2
16:38sdegutisjustin_smith: hi
16:52justin_smith,(def contains-value? (comp (complement neg?) #(.indexOf %2 %)))
16:52clojurebot#'sandbox/contains-value?
16:52justin_smith,(contains-value? false [:a :b :c false])
16:52clojurebottrue
16:52justin_smith,(contains-value? false [:a :b :c])
16:52clojurebotfalse
16:55amalloyjustin_smith: .contains
16:56justin_smithd'oh, of course!
16:56justin_smithmuch simpler
17:55sfz-amalloy: you're my hero