#clojure log - Mar 06 2016

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

2:08 aleogen: I think I might be addicted to caffeine

2:08 or coffee

2:25 TEttinger: aleogen: 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

2:26 dark pigments in food tend to be antioxidant. coffee is black. blueberries and blackberries are similarly dark

2:32 aleogen: TEttinger: I actually drink matcha green tea with bacopa, lions mane, and ashgadawa

2:32 TEttinger: also good for antioxidants!

2:32 I don't know what most of that is!

2:33 aleogen: a 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

2:33 but I think the cofee withdrawl makes me feel depressed or something

2:35 TEttinger: bacopa 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

2:35 also helps with memory, it seems

2:36 aleogen: oh, 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)

2:37 TEttinger: wow, with a tea like that it looks like alzheimers is gonna be the least of your concerns

2:37 aleogen: you think so?

2:37 TEttinger: the lions mane mushroom seems to have some "woah" effects for protecting the brain

2:39 this 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

2:40 good to know, i might recommend it to some relatives who are concerned about that stuff

2:43 aleogen: yeah, I take about a 1/4th tsp of it and an 1/8th tsp of bacopa and ashwagandha

2:43 seems to taste nice, and has a very distinct color worth staring at

2:44 but, I think coffee gives me a weird symptom

5:25 Empperi: hmm, is there any CI service which supports a) boot b) bitbucket?

5:25 drone.io supports bitbucket but not boot

5:26 oh, and mercurial support too

5:27 and phantomjs :)

5:27 lot's of requirements :)

5:27 maybe I should just make my own CI environment into my server with http://www.lambda.cd/

5:45 spuz: Empperi, lambdacd looks interesting

5:45 but how do you actually execute your build?

5:45 i guess you need to host it yourself?

5:45 Empperi: yes

5:49 Confusionist: If 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 ?

5:50 (as far as I can see I am doing exactly what it says under 'Tagged Literals' on http://clojure.org/reference/reader)

7:33 Trioxin: I've moved to using linux as my dev environment. openjdk/jre comes installed. Is it best to use Oracle?

7:33 for clojure that is of course

7:34 arrdem: Clojure'll run fine on OpenJDK

7:34 That's what most Linux distributions come with anyway.

7:35 The Oracle JVMs are somewhat better performance/memory wise, but I've never had them be worth the bother.

9:11 narwhal01: hi guys

9:12 ,(flatten [[[1 2] [3 4]] [[5]]])

9:12 clojurebot: (1 2 3 4 5)

9:12 narwhal01: how can i flatten but keep the inner list as its?

9:13 so i got [[1 2] [3 4] [5]]

9:13 justin_smith: narwhal01: by using concat instead of flatten

9:13 narwhal01: ah

9:13 thanks justin_smith

9:13 justin_smith: ,(apply concat [[[1 2] [3 4]] [[5]]])

9:13 clojurebot: ([1 2] [3 4] [5])

9:13 justin_smith: narwhal01: almost forgot to mention the apply part

9:14 luma: ~flatten

9:14 clojurebot: flatten 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.

9:19 TimMc: or for!

10:54 audrius: is the interactive programming a thing? can I modify the code at runtime?

11:04 Kah0ona: audrius: yes and yes

11:04 you can modify code, eval it in the REPL, and then the next time you call that function it 'll behave different

11:05 audrius: yh, nice I have seen something on Youtube, but cannot find it again

11:05 Kah0ona: yeah so, i think just reading an introductory tutorial on clojure (or viewing a video) will explain these things

11:06 and also explain WHY it is nice

11:06 audrius: As 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:07 Kah0ona: hm 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:08 the idea of clojure is that it's a different language, so I don't think it was built with your idea in mind

11:09 on the other hand, when you develop in clojure (with its interactive development etc.) you CAN use / call java libraries

11:09 justin_smith: once you are using clojure, you might not actually need spring

11:09 Kah0ona: yes indeed, but when you got a legacy app that is completely built on spring, building new features as libraries in clojure could work

11:09 audrius: yah I know, but we still have legacy project

11:09 justin_smith: things 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:09 Kah0ona: and then building those libraries can be done in clojure

11:09 and for that part you get the REPL/interactive programming goodness

11:10 building is wrong word, i meant developing

11:10 or rather 'writing'

11:10 audrius: I am much more interested in mixing interactivity with legacy :)

11:11 Kah0ona: are you sure? ;-)

11:11 audrius: sounds cool :d

11:11 Empperi: hmmh, is palletops basically dead?

11:11 it still uses clojure 1.4, it doesn't even work on clojure 1.8

11:11 Kah0ona: but i see your point; because I also have some legacy spring stuff that need extra features

11:11 Empperi: it uses clj-ssh which uses an invalid format of throw which won't compile

11:12 Kah0ona: and then i'm thinking whether to build those in clojure

11:12 and calling it from a servlet or whatever

11:12 ie. some export feature that exports data to excel

11:12 but that's starting next week, so will worry about it then ;-)

11:13 justin_smith: Kah0ona: 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:14 Kah0ona: aah okay thanks

11:14 justin_smith: the docs for calling clojure from java are well explained, and it's actually a simple process

11:15 Kah0ona: yeah i'll figure that out; just haven't read into it yet

11:23 thanks though:)

11:25 Empperi: got to say the documentation of palletops is in horrid state

11:25 tons of old documentation which doesn't reflect to the current APIs

11:25 also found that clojure 1.7 works but clojure 1.8 doesn't

11:26 I had high hopes of pallet but right now the initial start isn't actually all that flattering :(

11:33 OscarZ: if 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:34 i guess #() would work .. but what if i want to "lock" just one parameter

11:35 j-pb: partial

11:35 ,(partial + 1 2)

11:35 clojurebot: #object[clojure.core$partial$fn__4761 0x7f0d7ffc "clojure.core$partial$fn__4761@7f0d7ffc"]

11:35 j-pb: ,((partial + 1 2) 3)

11:35 clojurebot: 6

11:35 justin_smith: ((partial +))

11:35 ,((partial +))

11:35 clojurebot: 0

11:36 OscarZ: ok thanks

11:36 j-pb: OscarZ: clojure doesn't have currying since that is incompatible with a variable number of arguments

11:37 justin_smith: ,(apply apply (repeat 3 (partial *)))

11:37 clojurebot: #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:37 justin_smith: ergh

11:37 OscarZ: yeah i was thinking + takes more than 2 params..

11:37 justin_smith: or less!

11:37 ,(apply apply ((juxt first rest) (repeat 3 (partial *))))

11:37 clojurebot: #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:38 * justin_smith is done

11:39 OscarZ: hehe :) how does it work with partial and + which takes n parameters

11:39 j-pb: OscarZ: 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:39 or rather the function returned takes n

11:40 OscarZ: hmm ok.. i kinda get that.. maybe i need to check out the source if thats not too complicated

11:40 j-pb: yeah super siple

11:42 OscarZ: yes, ran into this: http://stackoverflow.com/questions/30818602/why-such-implementation-of-partial-in-clojure-core

11:42 j-pb: ,(apply apply ((juxt first (comp (partial map apply) rest)) (repeat 3 (partial *))))

11:42 clojurebot: #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:43 j-pb: meh

11:44 OscarZ: if [& args] is used, is args just a normal list?

11:46 when its used like (apply f arg1 args) does it get "expanded" somehow

11:47 ah.. sorry, apply is taking a list and it does the expanding

11:48 in 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:49 i guess i could add it to the map that the handlers are passing around and then pass it to functions etc.

11:49 TimMc: OscarZ: You could do worse than attaching it to the request map, yeah.

11:50 OscarZ: i 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:53 i guess its more functional to always pass it explicitly but there will be lot of boilerplate because of that..

12:35 ucb: a 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:38 justin_smith: right, it's also an error

12:39 the 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:42 OscarZ: justin_smith, err do have any good example in mind? :) maybe i could check out some sources

12:47 ucb: justin_smith: that's what I was thinking. Move the stuff used elsewhere to blah-blah.core, then start building up. Thanks.

12:47 PS: yes, it's an error, the compiler told me as much :)

12:47 * ucb . o O { I hope there's nobody nicknamed PS in here }

12:48 * ucb tab-completes

12:48 ucb: no, phew

12:48 milia: lol

12:48 justin_smith: ucb: .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:49 which makes it the shell layer, not the core!

12:55 ucb: hrm

12:55 right

12:55 fair enough

15:45 backnforth: how to I use string indexing/charat?

15:46 ridcully: ,(.charAt "LERL" 1)

15:46 clojurebot: \E

15:46 ridcully: ,(get "LERL" 1)

15:46 clojurebot: \E

15:48 backnforth: and to put that value into a variable?

15:49 amalloy: backnforth: how do you put other values into variables?

15:50 backnforth: ,lol. I'm new to clojure.. let me try

15:51 clojurebot: #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:51 backnforth: (variable get "someStrinf"

15:52 (variable get "some variable" 1)

15:54 I assume variable would equal 1 in this case?

15:56 ridcully: ,(doc variable)

15:56 clojurebot: No entiendo

15:59 backnforth: how do I get the size of a string?

15:59 justin_smith: backnforth: in characters or bytes?

15:59 backnforth: characters

15:59 justin_smith: count

16:00 ridcully: ,(count "lërl")

16:00 clojurebot: 4

16:01 amalloy: justin_smith: well, a character is two bytes. the more interesting question is, characters or code points

16:02 justin_smith: ahh, right, I made the wrong distinction there

16:39 TMA: character 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:41 representing 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:00 amalloy: TMA: conceptually you're right, but in java a char is defined as two bytes

17:06 maya__: Hi

17:07 Juste found that gist (https://gist.github.com/tmatinla/5026427) can you explain the result ? is that normal ?

17:10 ddellacosta: maya__: are you confused by what .generateTest is returning in the Clojure proxy example?

17:10 or something else?

17:11 maya__: ddellacosta: By the getTest returning the old value

17:11 ddellacosta: ah

17:12 I wonder what happens if you change generateTest to public in the original class

17:19 maya__: 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:20 unfortunately I'm not sure what's going on, but would love to hear from someone who knows more about the internals of proxy

17:20 maya__: ddellacosta: yeah I saw that

17:20 ddellacosta: but yeah, good question

17:20 interesting

17:20 cortexman: @justin_smith, you can indeed put a volatile hash map in a let and access it from all nested structures!

Logging service provided by n01se.net