#clojure logs

2016-03-06

02:08aleogenI think I might be addicted to caffeine
02:08aleogenor coffee
02:25TEttingeraleogen: not unreasonable. it is addictive, caffeine. but on the plus side, you drink coffee, which is the #1 source of antioxidants in the american diet
02:26TEttingerdark pigments in food tend to be antioxidant. coffee is black. blueberries and blackberries are similarly dark
02:32aleogenTEttinger: I actually drink matcha green tea with bacopa, lions mane, and ashgadawa
02:32TEttingeralso good for antioxidants!
02:32TEttingerI don't know what most of that is!
02:33aleogena take a vitamin b complex supplement and meditate for a bit, but maybe I need to meditate before I go to sleep, which requires me to actually plan on going to sleep rather that constantly falling asleep
02:33aleogenbut I think the cofee withdrawl makes me feel depressed or something
02:35TEttingerbacopa is antioxidant and appears to help resistance to dementia, but also apparently has some sorta bad side effects in large doses. I hadn't heard of it before
02:35TEttingeralso helps with memory, it seems
02:36aleogenoh, I actually make lueberry smoothies regularly too! with raspberry, honey, goji berries (I blend it up and make a fine powder that I mix with some spirulina), banana, strawberry, kiwi, sometimes apple or orange, a bit bit of cherry tart and almond milk (sometimes coconut as well if I have it)
02:37TEttingerwow, with a tea like that it looks like alzheimers is gonna be the least of your concerns
02:37aleogenyou think so?
02:37TEttingerthe lions mane mushroom seems to have some "woah" effects for protecting the brain
02:39TEttingerthis is like the laundry list of "is there a cure for it yet" conditions that this can help with https://en.wikipedia.org/wiki/Hericium_erinaceus#Medical_research_and_use
02:40TEttingergood to know, i might recommend it to some relatives who are concerned about that stuff
02:43aleogenyeah, I take about a 1/4th tsp of it and an 1/8th tsp of bacopa and ashwagandha
02:43aleogenseems to taste nice, and has a very distinct color worth staring at
02:44aleogenbut, I think coffee gives me a weird symptom
05:25Empperihmm, is there any CI service which supports a) boot b) bitbucket?
05:25Empperidrone.io supports bitbucket but not boot
05:26Empperioh, and mercurial support too
05:27Empperiand phantomjs :)
05:27Empperilot's of requirements :)
05:27Empperimaybe I should just make my own CI environment into my server with http://www.lambda.cd/
05:45spuzEmpperi, lambdacd looks interesting
05:45spuzbut how do you actually execute your build?
05:45spuzi guess you need to host it yourself?
05:45Empperiyes
05:49ConfusionistIf I have a file data_readers.clj containing {core/foo app.core/foo} and app.core/foo is correctly defined (I can call it from a repl and it executes the function as I expect), then why does #core/foo [+ 1 2] result in IllegalStateException Attempting to call unbound fn: #'app.core/foo ?
05:50Confusionist(as far as I can see I am doing exactly what it says under 'Tagged Literals' on http://clojure.org/reference/reader)
07:33TrioxinI've moved to using linux as my dev environment. openjdk/jre comes installed. Is it best to use Oracle?
07:33Trioxinfor clojure that is of course
07:34arrdemClojure'll run fine on OpenJDK
07:34arrdemThat's what most Linux distributions come with anyway.
07:35arrdemThe Oracle JVMs are somewhat better performance/memory wise, but I've never had them be worth the bother.
09:11narwhal01hi guys
09:12narwhal01,(flatten [[[1 2] [3 4]] [[5]]])
09:12clojurebot(1 2 3 4 5)
09:12narwhal01how can i flatten but keep the inner list as its?
09:13narwhal01so i got [[1 2] [3 4] [5]]
09:13justin_smithnarwhal01: by using concat instead of flatten
09:13narwhal01ah
09:13narwhal01thanks justin_smith
09:13justin_smith,(apply concat [[[1 2] [3 4]] [[5]]])
09:13clojurebot([1 2] [3 4] [5])
09:13justin_smithnarwhal01: almost forgot to mention the apply part
09:14luma~flatten
09:14clojurebotflatten is rarely the right answer. Suppose you need to use a list as your "base type", for example. Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with.
09:19TimMcor for!
10:54audriusis the interactive programming a thing? can I modify the code at runtime?
11:04Kah0onaaudrius: yes and yes
11:04Kah0onayou can modify code, eval it in the REPL, and then the next time you call that function it 'll behave different
11:05audriusyh, nice I have seen something on Youtube, but cannot find it again
11:05Kah0onayeah so, i think just reading an introductory tutorial on clojure (or viewing a video) will explain these things
11:06Kah0onaand also explain WHY it is nice
11:06audriusAs it runs on JVM, I am thinking to be able to develop my Java/Spring apps and be able to hotswap my classes and functionality this way.
11:07Kah0onahm I don't know about that, but i'm not really an expert. What COULD work is, write new features in clojure, and make it a library, and then call that from your spring app
11:08Kah0onathe idea of clojure is that it's a different language, so I don't think it was built with your idea in mind
11:09Kah0onaon the other hand, when you develop in clojure (with its interactive development etc.) you CAN use / call java libraries
11:09justin_smithonce you are using clojure, you might not actually need spring
11:09Kah0onayes indeed, but when you got a legacy app that is completely built on spring, building new features as libraries in clojure could work
11:09audriusyah I know, but we still have legacy project
11:09justin_smiththings that are convenient in spring are not always easy in clojure, and things that are hard in java (thus needing spring) are often easy in clojure
11:09Kah0onaand then building those libraries can be done in clojure
11:09Kah0onaand for that part you get the REPL/interactive programming goodness
11:10Kah0onabuilding is wrong word, i meant developing
11:10Kah0onaor rather 'writing'
11:10audriusI am much more interested in mixing interactivity with legacy :)
11:11Kah0onaare you sure? ;-)
11:11audriussounds cool :d
11:11Empperihmmh, is palletops basically dead?
11:11Empperiit still uses clojure 1.4, it doesn't even work on clojure 1.8
11:11Kah0onabut i see your point; because I also have some legacy spring stuff that need extra features
11:11Empperiit uses clj-ssh which uses an invalid format of throw which won't compile
11:12Kah0onaand then i'm thinking whether to build those in clojure
11:12Kah0onaand calling it from a servlet or whatever
11:12Kah0onaie. some export feature that exports data to excel
11:12Kah0onabut that's starting next week, so will worry about it then ;-)
11:13justin_smithKah0ona: the easiest way to extend a java program with clojure, is to pull in the clojure dep via maven, then invoke clojure.lang.RT to create your namespaces. After that you can use the return values from clojure.lang.RT calls to invoke clojure code
11:14Kah0onaaah okay thanks
11:14justin_smiththe docs for calling clojure from java are well explained, and it's actually a simple process
11:15Kah0onayeah i'll figure that out; just haven't read into it yet
11:23Kah0onathanks though:)
11:25Empperigot to say the documentation of palletops is in horrid state
11:25Empperitons of old documentation which doesn't reflect to the current APIs
11:25Empperialso found that clojure 1.7 works but clojure 1.8 doesn't
11:26EmpperiI had high hopes of pallet but right now the initial start isn't actually all that flattering :(
11:33OscarZif i have some function, say open-db-connection [host port], whats the best way to create a new function where those parameters would be already "locked", a bit like currying.. so i could call it just (open-conn) or something..
11:34OscarZi guess #() would work .. but what if i want to "lock" just one parameter
11:35j-pbpartial
11:35j-pb,(partial + 1 2)
11:35clojurebot#object[clojure.core$partial$fn__4761 0x7f0d7ffc "clojure.core$partial$fn__4761@7f0d7ffc"]
11:35j-pb,((partial + 1 2) 3)
11:35clojurebot6
11:35justin_smith((partial +))
11:35justin_smith,((partial +))
11:35clojurebot0
11:36OscarZok thanks
11:36j-pbOscarZ: clojure doesn't have currying since that is incompatible with a variable number of arguments
11:37justin_smith,(apply apply (repeat 3 (partial *)))
11:37clojurebot#error {\n :cause "Don't know how to create ISeq from: clojure.core$_STAR_"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Don't know how to create ISeq from: clojure.core$_STAR_"\n :at [clojure.lang.RT seqFrom "RT.java" 542]}]\n :trace\n [[clojure.lang.RT seqFrom "RT.java" 542]\n [clojure.lang.RT seq "RT.java" 523]\n [clojure.lang.RT cons "RT.java" 662]\n [clojure.core$con...
11:37justin_smithergh
11:37OscarZyeah i was thinking + takes more than 2 params..
11:37justin_smithor less!
11:37justin_smith,(apply apply ((juxt first rest) (repeat 3 (partial *))))
11:37clojurebot#error {\n :cause "clojure.core$_STAR_ cannot be cast to java.lang.Number"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.core$_STAR_ cannot be cast to java.lang.Number"\n :at [clojure.lang.Numbers multiply "Numbers.java" 148]}]\n :trace\n [[clojure.lang.Numbers multiply "Numbers.java" 148]\n [clojure.core$_STAR_ invokeStatic "core.clj" 997]\n [clojure.core$_STAR_ invoke "...
11:39OscarZhehe :) how does it work with partial and + which takes n parameters
11:39j-pbOscarZ: partial binds the first m parameters, and takes itself n parameters, which are then concatenated to the m and the function is applied to that
11:39j-pbor rather the function returned takes n
11:40OscarZhmm ok.. i kinda get that.. maybe i need to check out the source if thats not too complicated
11:40j-pbyeah super siple
11:42OscarZyes, ran into this: http://stackoverflow.com/questions/30818602/why-such-implementation-of-partial-in-clojure-core
11:42j-pb,(apply apply ((juxt first (comp (partial map apply) rest)) (repeat 3 (partial *))))
11:42clojurebot#error {\n :cause "Wrong number of args (1) passed to: core/apply"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (1) passed to: core/apply"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.RestFn invoke "RestFn.java" 412]\n [clojure.core$map$fn__4785 invoke "core.clj" 2646]\n [clojur...
11:43j-pbmeh
11:44OscarZif [& args] is used, is args just a normal list?
11:46OscarZwhen its used like (apply f arg1 args) does it get "expanded" somehow
11:47OscarZah.. sorry, apply is taking a list and it does the expanding
11:48OscarZin a ring application, if i have a db connection that gets opened at first when processing a request, whats recommended / good approach to pass the connection along ?
11:49OscarZi guess i could add it to the map that the handlers are passing around and then pass it to functions etc.
11:49TimMcOscarZ: You could do worse than attaching it to the request map, yeah.
11:50OscarZi was thinking of maybe using some kind of thread local thing that i wouldnt need to pass it along but maybe thats a bad practice
11:53OscarZi guess its more functional to always pass it explicitly but there will be lot of boilerplate because of that..
12:35ucba quick question, and I suspect I probably know the answer already but: if I have a cyclic load dependency, that's normally/generally a sign of poor design, right?
12:38justin_smithright, it's also an error
12:39justin_smiththe common solution is to move your abstractions to the bottom of the load dependency tree, and the implementations on the next level up, and the usage on the top level
12:42OscarZjustin_smith, err do have any good example in mind? :) maybe i could check out some sources
12:47ucbjustin_smith: that's what I was thinking. Move the stuff used elsewhere to blah-blah.core, then start building up. Thanks.
12:47ucbPS: yes, it's an error, the compiler told me as much :)
12:48ucbno, phew
12:48milialol
12:48justin_smithucb: .core is an annoyingly ambiguous name, in most clojure libs .core is where you find the top level stuff you expect clients to use, not the bottom level abstractions that the other things implement
12:49justin_smithwhich makes it the shell layer, not the core!
12:55ucbhrm
12:55ucbright
12:55ucbfair enough
15:45backnforthhow to I use string indexing/charat?
15:46ridcully,(.charAt "LERL" 1)
15:46clojurebot\E
15:46ridcully,(get "LERL" 1)
15:46clojurebot\E
15:48backnforthand to put that value into a variable?
15:49amalloybacknforth: how do you put other values into variables?
15:50backnforth,lol. I'm new to clojure.. let me try
15:51clojurebot#error {\n :cause "lol."\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.ClassNotFoundException: lol., compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.ClassNotFoundException\n :message "lol."\n :at [java.net.URLClassLoader$1 run "URLClassLoader.java" 366]}]\n :trace\n [[java.net.URLClassLoader$1 ...
15:51backnforth(variable get "someStrinf"
15:52backnforth(variable get "some variable" 1)
15:54backnforthI assume variable would equal 1 in this case?
15:56ridcully,(doc variable)
15:56clojurebotNo entiendo
15:59backnforthhow do I get the size of a string?
15:59justin_smithbacknforth: in characters or bytes?
15:59backnforthcharacters
15:59justin_smithcount
16:00ridcully,(count "lërl")
16:00clojurebot4
16:01amalloyjustin_smith: well, a character is two bytes. the more interesting question is, characters or code points
16:02justin_smithahh, right, I made the wrong distinction there
16:39TMAcharacter is an abstract entity (ë is one character irrespective of whether it is one code point ("latin small letter e with diaeresis" or some such) or two code points ("latin small letter e" + "combining mark diaeresis"), char is two bytes
16:41TMArepresenting writing is HARD, mostly because the pesky humans started before there was a good underlying theory developed and we are stuck with layers upon layers of backwards compatibility
17:00amalloyTMA: conceptually you're right, but in java a char is defined as two bytes
17:06maya__Hi
17:07maya__Juste found that gist (https://gist.github.com/tmatinla/5026427) can you explain the result ? is that normal ?
17:10ddellacostamaya__: are you confused by what .generateTest is returning in the Clojure proxy example?
17:10ddellacostaor something else?
17:11maya__ddellacosta: By the getTest returning the old value
17:11ddellacostaah
17:12ddellacostaI wonder what happens if you change generateTest to public in the original class
17:19ddellacostamaya__: this is an interesting thread, although it doesn't directly address your question: https://groups.google.com/forum/#!searchin/clojure/Re$3A$20Proxies$20and$20overriding$20protected$20methods/clojure/oeL8pFr2wa8/J-QN0tYNuNAJ
17:20ddellacostaunfortunately I'm not sure what's going on, but would love to hear from someone who knows more about the internals of proxy
17:20maya__ddellacosta: yeah I saw that
17:20ddellacostabut yeah, good question
17:20ddellacostainteresting
17:20cortexman@justin_smith, you can indeed put a volatile hash map in a let and access it from all nested structures!