#clojure log - Dec 23 2014

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

5:12 sm0ke: need some help with jline2, any repl people here?

6:08 PigDude: I get a strange error when excluding `cons' from clojure.core and defining this in a protocol and a record: https://gist.github.com/anonymous/4d8be8bb37b1f2347351

6:08 I read that this is a Java 8-specific error

6:09 Defining other excluded core functions on protocols and extending those protocols works in other cases, just not with `cons' ...

6:09 Bronsa: PigDude: no, you can't implement inline a method named cons in a defrecord

6:09 PigDude: Bronsa: why is that?

6:09 Bronsa: PigDude: defrecords implement IPersistentCollection which already has a method named cons

6:10 PigDude: either use a deftype instead or extend Cat to ConsAir using extend/extend-type/extend-protocol rather than implementing the protocol inline

6:11 PigDude: Bronsa: why is it important if it is defined inline or not?

6:11 Bronsa: PigDude: if you define it inline, the record will use the interface underlying the protocol and compile your protocol function in a method of the records' class

6:15 PigDude: thanks Bronsa !!

6:21 expez: Bronsa: https://gist.github.com/47527b6ae643928f1863 I run this on all nodes in the AST, trying to find the names of all classes that are used in the file. Does it look reasonable? It looks a bit convoluted to me.

6:22 basically the result of trial and error rather any actual understanding ><

6:24 Bronsa: expez: depends, do you want to catch X in (deftype X [] ) and Y in (Y/foo ..) too?

6:25 expez: yes, all nodes giving me a name I shouldn't remove from the :import clause in the current namespace because the name is in use

6:25 Bronsa: ok so no deftype then, that's imported automatically

6:27 expez: http://sprunge.us/QDNT?clj this should handle all your cases

6:29 expez: btw refer to https://clojure.github.io/tools.analyzer.jvm/spec/quickref.html when you're lost

6:30 expez: Bronsa: tests are green! Thanks! :)

7:32 lxsameer: hey guys, is there any video series to learn clojure around ?

7:41 luxbock: lxsameer: there's https://tbaldridge.pivotshare.com/

7:42 lots of videos on core.async, transducers and core.logic

7:43 lxsameer: luxbock: thanks but I want to learn clojure first , I think these videos is for my next step

7:44 luxbock: lxsameer: maybe these https://www.youtube.com/user/Misophistful/videos

7:45 lxsameer: luxbock: thanks my friend

7:45 luxbock: no problem

8:03 I have a custom type that implements IPersistentMap and ISeq, and I'm trying to define a print-method for it, but I run into "Multiple methods in multimethod 'simple-dispatch' match dispatch value:" exception

8:04 I tried using (prefer-method print-method MyType IPersistentMap/ISeq) but that doesn't work because those two are already preferred

8:04 is there a way around this somehow?

8:17 jonathanj: the readme for clj-aws-s3 mention that there are plenty of s3 clojure clients but doesn't mention them and they're not listed on clojure toolbox

8:17 would anyone be so kind as to point me to a few?

8:25 katratxo: jonathanj: clj-aws-s3 is a s3 client, right?

8:36 _kardan: Anyone got an elegant solution to using Joplin for sql db migrations when using env vars for the connection? Right now I use environ in the app code but additional (System/getenv in the project.clj

8:37 katratxo: jonathanj: https://clojars.org/search?q=s3

8:39 jonathanj: _kardan: i'd love to know the answer to that too

8:39 katratxo: thank you

8:39 katratxo: do you have any experience with any of these?

8:49 borkdude: are there any ring/compojure/liberator etc code/project organization guidelines I may borrow inspiration from?

8:49 katratxo: jonathanj: i'm using clj-aws-s3 check the code https://github.com/akvo/akvo-flow-services/blob/develop/src/akvo/flow_services/uploader.clj#L95-L101

8:55 clrnd: hi guys

8:57 nickenchuggets: clrnd: hi

8:57 clrnd: I was looking for info on Clojure's web server's architecture

8:58 nickenchuggets: heh, sorry, I'm new to the language.

8:58 jonathanj: katratxo: what's the normal way of handling asynchronous uploads?

8:58 nickenchuggets: like, 100% new.

8:58 clrnd: me too, congrats :)

8:58 jonathanj: katratxo: i guess future (?) uses a threadpool, so just create a future for each one?

8:59 borkdude: clrnd there is no "Clojure web server", but there are ring adapters for jetty, etc.

8:59 clrnd: oh so ring is just an adapter for jetty

8:59 and jetty is java

8:59 borkdude: clrnd and there is also http-kit

8:59 clrnd: nice

8:59 what is http-kit?

8:59 borkdude: clrnd there is also more, but jetty and http-kit are widely used. There's also Immutant, which is a web server on top of jboss

9:00 nickenchuggets: I had some questions though, so I guess LISP has its origins in artificial intelligence if I recall correctly...

9:00 clrnd: borkdude, this is the info I wanted thank you very much :D

9:00 borkdude: clrnd here is a more complete list (with benchmarks) https://github.com/ptaoussanis/clojure-web-server-benchmarks

9:01 clrnd: thanks again

9:01 nickenchuggets: although googling around tells me that lisp sort of lost popularity in AI around the 80s.

9:02 tcrayford____: jonathanj: yeah, that is pretty normal. Depends on the volume you're doing etc

9:03 clrnd: nickenchuggets, lisp lost popularity everywhere I think

9:14 nickenchuggets: probably way off topic, but, I'm trying to find someone who is familiar with the area of artificial intelligence and ask them questions.

9:23 luxbock: nickenchuggets: AI is a pretty large field, is there something you are interested in particular?

9:28 ,(filter (comp (partial = "1.7") :added meta) (vals (ns-publics 'clojure.core)))

9:28 clojurebot: (#'clojure.core/eduction #'clojure.core/dedupe #'clojure.core/vswap! #'clojure.core/vreset! #'clojure.core/cat ...)

9:36 nickenchuggets: luxbock: hahaha, well, I've been reading about "futurology", and I've heard some pretty... wild things.

9:36 luxbock: that is, "the singularity"

9:37 luxbock: nickenchuggets: so you are interested in general or strong AI as opposed to weak AI

9:38 nickenchuggets: I'm wondering what someone who actually works in AI thinks about all of this "singularity" stuff

9:38 luxbock: strong, general, impossible(?) vs. weak, practical, applied AI :)

9:40 nickenchuggets: I have only worked with weak AI stuff, so I don't have much to say, but you might try asking this question over at #lesswrong

9:40 I think it's the type of thing they like to talk about

9:41 nickenchuggets: sweet, thanks

9:42 luxbock: the only general AI related project in Clojure that I know of is http://inbits.com/category/clortex-htm-in-clojure/

9:52 spuz: nickenchuggets: I haven't worked in AI but as a programmer I think the 'singularity' is nonsense

9:54 clrnd: nickenchuggets, the singularity is just a pop term for when the understanding of the process of counsciousness let's us reproduce it

9:54 spuz: if you take the current trends in both AI and computing power you have to go way outside of the realm of feasibility to get to an AI that is more intelligent than a human

9:54 clrnd: nickenchuggets, I think it will happen, in this century probably, but it will not be a breaktrough of any kind, the process will be gradual just like now everyone has a smartphone

9:55 I think it's more of a neuroscience problem than a CS one, at list for now

9:56 spuz: if you look at where the developments in AI and computing are coming from today, it doesn't follow that they will ever reach the scale and speeds necessary

9:58 I think further development will happen in modelling neural networks but it would have to use new technology in order to get the efficiency needed

10:00 clrnd: it will be new technogoly but based on the understading of the human brain, I don't think we don't have the materials, just we lack direction

10:02 bacon198`: spuz: I think you're forgetting how far we've come in the past 20 years

10:03 computers are now impressively powerful compared to back then

10:03 and using the same exact silicon manufacturing techniques

10:03 Morgawr: and yet we still use c++

10:04 Glenjamin: zing!

10:04 bacon198`: Morgawr: we still use COBOL

10:04 mgaare: if there is strong AI, it won't run on intel chips. The branch predictor would get jealous and stop it

10:04 bacon198`: c++ is the least of our problems

10:05 i've been writing classic vb6

10:05 c++ would be a godsend

10:08 Glenjamin: classic vb6 can't buffer overflow

10:08 can it?

10:08 i hope it cant

10:08 clrnd: the brain is like ultra-mega-parallel, we will need the cloud or smthg

10:08 bacon198`: I don't know, it doesn't seem to mind profanity

10:09 pretty sure there have already been new computing architectures to resemble the brain

10:09 it's one thing to 'simulate' a brain, rather than just simply build it

10:10 sortof like how emulating an snes on an x86 computer takes more computing power than the hardware

10:33 SagiCZ1: isnt the whole theory of artificial neural netowrk about simulating brain?

10:34 p_l: SagiCZ1: not exactly, but biological structures were the inspiration

10:34 SagiCZ1: it's just about applying local rules and getting some complex macro behavior.. which is probably what the real brain does

10:34 or a flock of birds for that matter

11:28 mi6x3m: hey clojure, how would you position the newline when calling a function with named arguments. (foo\n:bla val\nbla val) or (foo :bla val\n:bla val) ?

11:28 i.e. first pair on the same line

11:29 chouser: Those both look fine to me.

11:30 mi6x3m: personally i use the second variant

11:31 tcrayford____: mi6x3m: I really *really* prefer taking a map over named arguments these days, but maybe that's just me

11:31 mi6x3m: tcrayford____: it's technically a map :)

11:32 chouser: tcrayford____: I think that's sane.

11:33 tcrayford____: mi6x3m: the named-args style can lead to perf problems in some cases (e.g. if the map is static for your users, they can allocate it once rather than on each call)

11:33 mi6x3m: it also leads to much easier of passing options through wrappers

11:33 if I wanna wrap a function that takes named args and do something with the arg, we're each worrying about creating the map. With just taking a map, you can just assoc onto it or whatever in your wrapper

11:33 mi6x3m: tcrayford____: I'm a conformist :>

11:34 hellofunk: mi6x3m: for larger nested forms, the first variant since it causes subsequent lines to indent further to the left so minimize line wrapping in my large-resolution editor

11:34 tcrayford____: mi6x3m: quite a buncha folk do the map over named arg thing these days, think it's getting pretty common

11:35 hellofunk: mi6x3m: indeed Om is based all around that idea

11:35 mi6x3m: interesting

11:36 chouser: map over named args?

11:36 oh, "prefer [hash]map over named args"

11:36 tcrayford____: (foo {:a 1 :b 2}) instead of (foo :a 1 :b 2)

11:36 yeah haha

11:37 chouser: Sorry, for a moment I was trying to think (map ??? (apply hash-map args))

11:37 tcrayford____: yeah :D

11:38 hellofunk: chouser don't feel too bad, i was quite perplexed at first when reading about adding a newline character to a function call

11:38 chouser: :-)

11:39 mi6x3m: i like to break right after the name

11:39 hellofunk: i thought you guys were talkinga bout some weird DSL that mixed string formatting with clojure inline

11:39 mi6x3m: but for named args i usually wait till after the first pair

11:42 chouser: I'm sad we still don't have ubiquitous auto-indenters that never require manual tweaking.

11:44 hellofunk: chouser you mean a "global standard" on the art of proper indenting of clojure code? like a style guide?

11:44 Bronsa: +1 for maps over named args

11:45 hellofunk: maps are also quite nice for returning multiple values from a single fn. use them all the time now for that.

11:45 chouser: hellofunk: no, no, tools in all our text editors so we never half to worry about max width, indent amount, newline placement, etc.

11:45 s/half/have/

11:46 hellofunk: chouser well at some point a line is going wrap and there's nothing to be done about it.

11:47 chouser: hellofunk: right, but that should be a display-time thing that Does The Right Thing, rather than an edit-time decision that gets checked into source control.

11:47 Well, to soften that, not "should" but it seems like it might be possible and if so I'd love to see it in all editors.

11:47 hellofunk: chouser so in my example, if the line is going to wrap, the editor automatically places the new line after a function name rather than it's args, to minimize chances of a particular line wrapping, otherwise it would know not to do this.

11:48 and it might change newline position for parent forms to aid with this, otherwise, it wouldn't.

11:48 chouser: not to minimize the chances, but when displaying if it actually *would* wrap at your current terminal width, then display newlines and re-indent to make it look right.

11:49 and yes, push back up into parent forms as needed.

11:49 Basically a really nice pretty-printer with live editing capability. Sounds easy, right? :-)

11:49 hellofunk: chouser i see what you mean. couldn't that easily be added to Cider functionality somehow? doesn't seem too far beyond other crazy stuff emacs does.

11:50 though, i think the editor with the most power for that type of display/syntax interaction would be Cursive. cfleming can take note!

11:50 chouser: yes, I'm sure it's within reach of all extensible text editors. Maybe could even be written in such a way that all editors could use the same code.

11:51 Glenjamin: ideally tools could work on a cannonical representation check internally, but then display could vary based on preference

11:51 chouser: right. keeps sounding easier and easier.

11:51 Glenjamin: heh

11:52 hellofunk: we definitely support cfleming's comment about writing text itself is not the best way to represent programming ideas

11:52 chouser: well, maybe, though I actually think that's different.

11:53 mi6x3m: another one

11:53 how do you call your listener fns_

11:53 chouser: There are benefits to writing the same stuff that we read, which is text.

11:53 mi6x3m: on-xyz

11:53 xyz-listener?

11:53 xyz-fn?

11:53 hellofunk: i mean everything we are talking about is how text writing or display gets in the way of actually implementing ideas

11:53 mi6x3m: well style is important hellofunk

11:54 hellofunk: no, i mean well beyond "style" because of being beyond "text" entirely

11:55 donbonifacio: anyone using test.check? I already have a random function, and I'm having trouble converting it to a generator

11:56 tcrayford____: donbonifacio: test.check generators *aren't* just random functions :(

11:56 hellofunk: to me, the initial attraction to lisp was about the improved relationship of an idea to how you could implement it. the symbols, patterns, homoiconicity, the whole works seemed closer to your idea factory, than say, churning out huge c++ template to get anything started. and i think you can get well beyond lisp and away from text entirely to work with ideas.

11:57 donbonifacio: tcrayford____: does that mean that I can't _incorporate_ my scenario?

11:58 tcrayford____: donbonifacio: if your scenario is a random function right now, you'll have to rewrite it in test.check's generator syntax

11:58 donbonifacio: can't to that, too complicated, would need a lot of work

11:58 imagine that I'm testing a chess engine and I already have a funciona that generates games

11:59 tcrayford____: so you can incorporate it, but you'd have to lose shrinking

11:59 which is most of the point of test.check

11:59 shrinking comes out of the generators

12:00 (well, or you can write your own shrinking logic)

12:01 donbonifacio: I see

12:02 arohner: does a/put! ever block? I'm confused by it claiming to be async, but also that core.async channels block when full

12:20 ghadishayban: Bronsa: I'm not sure the non-deterministic protocol dispatch is an issue anymore..

12:20 Bronsa: ghadishayban: ?

12:21 ghadishayban: If clojure.lang.MyMagicIReduce is also Iterable, as long as it there is an entry for MyMagicIReduce inside CollReduce as well,

12:21 it doesn't matter that it is also iterable

12:22 dispatch is only non-deterministic for superclasses AFAICT

12:22 Bronsa: ghadishayban: right, a prefer-dispatch would allow us to just prefer IReduce over Iterable rather than having to hard-code all the classes..

12:23 ghadishayban: Wouldn't it be better to simply add the classes? I'd think prefer-dispatch would be slow

12:23 Bronsa: ghadishayban: right now we have to extend MyCollection to CollReduce to make sure it will get routed through IReduce rather than through Iterable

12:24 ghadishayban: not sure that would be slower. there's a cache

12:25 ghadishayban: yeah it might not be. it's acceptable to me to extend MyCollection to CollReduce.

12:25 Bronsa: once the Class -> impl is determined once you can safely reuse that. it's invalidated only by other extend/prefer-dispatch like for multimethods

12:27 ghadishayban: yeah, I guess manually extending colls to CollReduce is good enough for now :) I certainly don't have the time to implement/test prefer-dispath

12:27 tch*

12:30 ghadishayban: btw I didn't understand how your comment related to the PV IReduce/1 question, were you just misremembering?

12:30 ghadishayban: brainfart

12:30 Bronsa: hah, ok

12:34 ghadishayban: I think the golden rule is, if you are IReduce/IReduceInit, you must be also extended to CollReduce to prevent ambiguity

12:36 Despite the special-casing fast path of IReduceInit inside reduce/transduce, think of CollReduce as primary, and the IReduce as an optimization

12:39 maacl: Does it betray a lack of understanding of transients to ask why I cannot find a assoc-in! function anywhere?

12:41 TimMc: maacl: No, I don't think so.

12:42 That seems like quite an omission.

12:43 maacl: TimMc: Yes, I thought so.

12:45 TimMc: I don't even see a Jira issue for it.

12:46 chouser: maacl: are all the maps in the path transients, or only the root? Or only the leaf?

12:48 TimMc: oh right

12:53 maacl: chouser: All of them.

12:54 chouser: maacl: And you're going to go through later and persistent! them all? Have you measure the perf of this approach?

12:56 maacl: chouser: Not yet. Just started, and failed to find the assoc-in! function, which made me wonder if I was missing something.

13:03 chouser: I will do some testing and see what the performance looks like.

13:05 wamilton: hi all, I have a lazy-seq problem where it's giving me an out of bounds exception instead of being lazy. Is this a normal problem?

13:12 crash_ep: it is if you are accessing an element beyond some collection's bounds

13:13 wamilton: crash_ep: right, but this is just the instantiation of the lazy-seq... I've not tried to get anything out afaict

13:14 crash_ep: what's your code look like

13:16 wamilton: crash_ep: like so https://gist.github.com/winmillwill/ace2ae2f2fa2eeb5d50d

13:18 crash_ep: the data in question is a bunch of html tables with an xpath like this: /html/page/table hence my desire to iterate over just the tables

13:18 crash_ep: what table number are you trying to access when you call (tables) ?

13:19 and do you have n-1 elements in the collection at (-> root :content) to do so?

13:20 wamilton: I'm trying to get the first one, like so: (-> "short.html" root (tables 1) count)

13:23 crash_ep: The `tables` function is lazily recursive, but is it intended to be infinite? Eventually it will call `(tables root (inc n))` when n is the last element in the XML, at which point the _next_ call will cause an out of bounds exception.

13:23 Unless either you're careful to only take as many as you need, or your XML also contains an infinite number of values.

13:23 s/need/can/

13:25 wamilton: right, the xml data source is not infinite, still, I've got ~300 nodes at /html/page/table, so I don't see why the function is recursing in spite of the guarantee that it not do so until called again

13:26 I screwed around and did the (do ...) and (print ...) wrapping and debugging, and n definitely went all the way up, which seems wrong

13:26 crash_ep: count

13:26 you are calling count on the thing returned from your tables function

13:27 that will try to evaluate the entire sequence

13:27 I think what you wanted is `(-> "short.html" root (tables 1) first)`

13:29 wamilton: oh, duh, so count causes the lazy sequence to basically be immediately un-lazy? industrious()

13:29 s/\(\)/?

13:32 but yeah, even this causes an out of bounds: (-> "short.html" root (tables 1) first)

13:32 nm, 0 indexing on nth, my bad

13:33 crash_ep: thanks

13:33 crash_ep: np

13:34 schone: hello #clojure

13:35 what happend gets assigned into these variables in a case where you write let ([var-a var-b var-c (.remove mymap id)] ….) if mymap returned null from java world ?

13:35 im sorry, what would be assgiend into var-a var-b var-c

14:05 justin_smith: nickenchuggets: re "Lisp has origins in AI" - AI and Lisp came about together, in the mid 1950s. It would make as much sens to say AI has origins in Lisp.

14:06 mikerod: Is there anyway to add resources to the classpath under a certain name in leiningen, when they don't actually exist in a directory in that same location? (This may be confusing)

14:07 I have some directory "my/resources/over/here/resource.txt", I want to get it on the :dev profile classpath just for REPL time and I want it to be just referred to as a "resource.txt" on the classpath

14:07 it is sort of like how Maven shade has http://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html#IncludeResourceTransformer

14:08 but I'd like to "include the resource under a given name" only during REPL time

14:08 I know it could be in my test resources to fix this issue. That is currently what I'm doing.

14:09 AdmiralBumbleBee: has anyone here worked with eclipse's windowbuilder and clojure without using seesaw? I'm curious how you are using the form and if you're using a java intermediary

14:13 dark4eg: how to create instance generic object use clojure?

14:13 justin_smith: mikerod: you can have as many resource paths as you like

14:14 dark4eg: (com.google.common.collect ImmutableList<String>.) ?

14:14 but this is not the correct version(

14:14 justin_smith: mikerod: example of dev only resource-paths addition here https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L160

14:15 dark4eg: generics are a fiction

14:16 ignore the type

14:16 it's called "type erasure" from the point of view of the java compiler

14:16 dark4eg: thx

14:16 justin_smith: but we don't use the java compiler, so instead of having a type and erasing it, we just don't have a type

14:17 (all that said, it's probably still a good idea to make note of what type you are using that collection for, and stick to that one type)

14:17 mikerod: justin_smith: Yes, I mean that I'd like to change the classpath "location" of it.. this likely isn't possible

14:17 justin_smith: but there is no syntactic / structural aspect to that, because the jvm has no such concept

14:17 mikerod: I have a resource nested somewhere in a directory. I need it to be directly in the working directory for some other lib to find it

14:18 justin_smith: mikerod: yeah, I would just put it on the relative path I want it to be on, in it's own directory structure... but maybe there is some crazy hack? I wonder if it would actually be helpful though in the long run.

14:18 mikerod: justin_smith: probably not :P

14:18 it would have just been smoother for the REPL stuff I'm doing here

14:18 justin_smith: oh, not just relative path, but directly in the working dir? that sucks

14:18 mikerod: but it isn't essential

14:19 Yeah, I don't want to change the code that looks for it in working dir, it'll be in working dir in the "real" context

14:19 but in my REPL context I just want to point elsewhere, but make it look like it is in the working dir

14:19 I know its weird

14:20 justin_smith: hmm, I would attempt to abstract out the code that finds the thing, or add a classpath-relative path to look under

14:20 wouldn't "root level of classpath" be as good as "working dir" ?

14:20 mikerod: I was mostly curious. I just copied over some test resources for this to a test resources dir added to :resource-paths in a :dev profile

14:20 justin_smith: I mean the "root level" when I said that

14:20 example

14:21 doing (clojure.java.io/resource "my-resource.txt")

14:21 justin_smith: right

14:21 mikerod: I'd want that to return non-nil

14:21 not having to do (clojure.java.io/resource "some/nested/spot/my-resource.txt")

14:21 justin_smith: so make dev-resources/my-resource.txt and add dev-resources to resource-paths

14:21 that suffices right?

14:21 mikerod: yes

14:21 just requires I copy files to that place

14:21 justin_smith: make a symlink if it needs to be in three places at once :)

14:21 or more than one even

14:21 mikerod: true

14:21 so the answer is - just don't do something stupid like this :P

14:22 and use the filesystem appropriately hah

14:23 justin_smith: well, stupid is relative, our development and deployment stacks are full of small stupidities, but at least we can be vigilant about smartening things when we can figure out how :)

14:24 mikerod: True

14:26 dark4eg: justin_smith (new com.google.common.collect.ImmutableList) -> No matching ctor found for class com.google.common.collect.ImmutableList

14:26 justin_smith: dark4eg: for starters, direct usage of "new" is considered depricated, use (c.g.c.c.ImmutableList. ...)

14:27 then, it looks as if there is no direct constructor for that class http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/ImmutableList.html

14:27 you should probably be using (ImmutableList$Builder.), manipulating that, then implementing and ImmutableList from that

14:28 any particular reason you are using this class instead of the Clojure built in immutable collections?

14:29 dark4eg: org.openqa.selenium.phantomjs

14:29 justin_smith: Ok

14:30 so (let [builder (com.google.common.collect.ImmutableList$Builder)] (doto builder (.add 1) (.add 2) (.add 3)) (.build builder))

14:31 that (or something very close to it) should get you an ImmutableList of (1 2 3)

14:31 oh, I missed a .

14:31 so (let [builder (com.google.common.collect.ImmutableList$Builder.)] (doto builder (.add 1) (.add 2) (.add 3)) (.build builder))

14:33 though in practice you likely just want (.addAll builder [1 2 3])

14:54 devn: ,(range 0 1 0.1)

14:54 clojurebot: (0 0.1 0.2 0.30000000000000004 0.4 ...)

14:54 justin_smith: ,3/10 the ratio of the devil

14:54 clojurebot: 3/10

14:55 justin_smith: ,(range 0 1 1/10)

14:55 clojurebot: (0 1/10 1/5 3/10 2/5 ...)

15:47 Pistahh: re

16:10 DomKM: I want to run a function to compile SCSS before uberjar creation. It seems like prep-tasks might be the right place to look but it isn't working as I'd expect. Any advice on how to create build steps with Leiningen?

16:25 dbacar: Hi everyone

16:27 justin_smith: DomKM: what isn't working as expected?

16:29 dbacar: hi I cannot find the keyboard shortcut for cider- show clojure source, any ideas?

16:29 nullptr: M-. runs the command cider-jump-to-var, which is an interactive compiled Lisp function in `cider-interaction.el'.

16:29 justin_smith: dbacar: it should be M-.

16:29 jynx

16:31 dbacar: thanks a lot

16:37 danielglauser: DomKM: prep-task runs a leiningen task, I believe the way to create those is through a plugin. Did you write a plugin?

16:39 DomKM: Here's a sample plugin: https://github.com/denofclojure/lein-validate

16:43 DomKM: https://www.irccloud.com/pastebin/iDRU6D2y

16:44 oops, I seem to have just told IRCCloud to make a pastebin of that message

16:44 sorry about that

16:44 justin_smith: it's readable enough there though

16:44 better that rather than multi line message here

16:44 DomKM: true :)

16:45 anyway, the follow up to that is that another profile is required to turn off the built-in prep tasks: `:no-prep-tasks {:prep-tasks ^:replace []}`

16:59 danielglauser: DomKM: Weird. I'm sure I have a bit to learn about leiningen, recently started poking around the code.

17:01 DomKM: I wonder if the alias is already "used": https://github.com/technomancy/leiningen/blob/master/leiningen-core/src/leiningen/core/main.clj#L43

17:22 donbonifacio: in test.check, how could I make a generator that generates distinct collections from another collection? Example, with [1 2 3], it would generate [1], [1 2], etc

17:24 reiddraper: donbonifacio: check out `subset` in https://github.com/gfredericks/test.chuck#generators

17:25 donbonifacio: https://github.com/gfredericks/test.chuck/blob/master/src/com/gfredericks/test/chuck/generators.clj#L141-L149

17:26 donbonifacio: reiddraper: what If I'd like to specify the size of the new collection (for example, with another gen)

17:27 reiddraper: donbonifacio: have you read through https://github.com/clojure/test.check/blob/master/doc/intro.md and https://github.com/clojure/test.check/blob/master/doc/generator-examples.md?

17:28 donbonifacio: yes

17:28 I still can't figure it out, may be missing something

17:29 I could gen/shuffle and then take X, but can't find a gen that does the take

17:29 nullptr: gen/sized?

17:30 reiddraper: donbonifacio: i'll write you a simple example of exactly that

17:30 donbonifacio: also tried gen/elements, but couldn't generate a distinct vector

17:30 also tried sized and resize

17:30 maybe I'm just too tired :)

17:32 reiddraper: donbonifacio: (defn subgen [coll] (gen/fmap (fn [[shuffled len]] (take len shuffled)) (gen/tuple (gen/shuffle coll) (gen/choose 0 (count coll)))))

17:34 donbonifacio: that's it reiddraper, thanks :)

17:35 reiddraper: donbonifacio: np

17:35 you'll often see gen/tuple, gen/fmap and gen/bind used for more complex generators

17:39 donbonifacio: yes, your example is showing me some light

18:08 OscarZ_: is it easy to setup Clojure remote REPL server into some application ? i mean, i have access to the code.. i guess i need to listen to some port etc..

18:11 java application of course

18:35 justin_smith: OscarZ_: you can use clojure.tools.nrepl.server/start-server Don't listen to an outfacing port unless you would like everyone to root your box

18:35 hell, only listen to a local port if you trust everyone with a login :)

18:35 you can use an ssh tunnel to make a secure nrepl connection

18:36 OscarZ_: hehe yes, thats a good point :)

18:36 cool, so theres some library for that already

18:36 justin_smith: OscarZ_: that's the same lib lein uses for the "lein repl" task

18:37 OscarZ_: i was thinking.. if you have some simple API that uses POJOs for domain model.. is there an easy way to convert these into Clojure maps and other structures ?

18:37 justin_smith: amalloy_: picassoo is spamming, still (note the extra o, of course)

18:37 OscarZ_: a bit like Jackson JSON mapper works with Java classes and JSON

18:37 justin_smith: OscarZ_: ##(bean (java.util.Date.))

18:37 lazybot: ⇒ {:day 2, :date 23, :time 1419377694183, :month 11, :seconds 54, :year 114, :class java.util.Date, :timezoneOffset 0, :hours 23, :minutes 34}

18:38 justin_smith: in general, if it uses standard getFoo / setFoo bean will work

18:38 OscarZ_: cool :)

18:38 justin_smith: though bean is a bit expensive (it is reflection based) and you can improve performance by making your own custom class based transformation

18:38 OscarZ_: ok, i dont worry about performance much in this case..

18:39 justin_smith: then for a standard pojo with your normal getters and setters, bean will just work

18:39 OscarZ_: was just thinking it would be cool to plug in to some java application and work on it with REPL, view and modify its state etc..

18:39 justin_smith: yup, clojure is a nice way to interact with the jvm

18:40 OscarZ_: whats this ## thingy called ?

18:40 justin_smith: "tell lazybot to evaluate an expression ##(println "hi") mid sentence"

18:40 lazybot: ⇒ hi nil

18:42 OscarZ_: oh sorry.. i was after "bean"

18:42 justin_smith: haha, OK

19:20 akkad: ahh, it's an acronym: Common Lisp On Java Using Rich's Experience

19:28 justin_smith: well, it's not common lisp at all (scheme would be a closer comparison, but it isn't that either) and the name was chosen because it had a j (for jvm) and clr (for the clr) and sounded like a commonly used fp featuer (closure)

19:29 *feature

19:30 "The name was chosen to be unique. I wanted to involve c (c#), l (lisp)

19:30 and j (java)."

19:31 https://groups.google.com/forum/#!topic/clojure/4uDxeOS8pwY

21:06 gfredericks: justin_smith: doing clojure history research?

21:10 justin_smith: correcting what may in retrospect have been a joke

21:11 and picassoo is still at it

21:33 visof: hi guys

21:33 kenrestivo: his nose is not centered

21:33 and everytihng is two dimensional

21:34 visof: there is something strange i can't figure it out, when i do (.field doc "Hello" "World") (.field doc "Hello" "Clojure") it's working, but when i do (map () {"Hello" "World" })

21:34 there is something strange i can't figure it out, when i do (.field doc "Hello" "World") (.field doc "Hello" "Clojure") it's working, but when i do (map (fn [[k v]] (.field doc k v)) {"Hello" "World" "Hello" "Clojure"})

21:34 don't work

21:35 andyf: what happens?

21:35 visof: can anybody help in this?

21:36 andyf: visof: There are many ways that it might not work, but you haven't told us what it does do when you try that.

21:37 visof: (.field doc k v) is orientdb API which set key and value for specific document, so what i meant by working is: it's setted else isn't setted

21:37 andyf: map is lazy

21:38 it will only call the function on elements of the sequence if you do something that consumes the return values

21:38 if you want side effects, consider doseq instead.

21:38 or put map inside (doall ...)

21:40 (dorun ...) would be somewhat better than (doall ...) in this case, since you don't care about the return values, but I'd recommend doseq over either of those.

21:41 visof: andyf: how can i pick k and v for hash in doseq?

21:41 andyf: (doseq [[k v] hash-map] (.field doc k v)) should do it, I think.

21:41 gfredericks: hi andyf

21:42 andyf: I was going to say "howdy gf", but that might not sound right.

21:43 gfredericks: ~gf

21:43 clojurebot: Cool story bro.

21:43 gfredericks: ~gf is greasy fries

21:43 clojurebot: Roger.

21:44 andyf: It reminded me of "girlfriend", which would definitely send the wrong impression

21:45 gfredericks: yeah

21:46 my name has mostly nonflattering variations

21:46 andyf: Grade school is a little weird at times when your last name is "Fingerhut" :-)

21:48 gfredericks: apparently Fingerhut is a sleazy company of some sort

21:51 andyf: A mail order company, but I haven't ever done business with them, and no relation (or none I know of). I heard that they were very good at figuring out how much credit they could extend to people of limited means, so that they could usually pay it back. Someone else bought it in early 2000s and started extending way more credit, and many didn't pay back their loans.

21:54 gfredericks: I once got an email with the subject "Infringement of Frederick's of Hollywood domain names

21:55 and only now looking back on it do I notice there's not necessarily any good reason to think the email came from anybody associated with the company

21:55 but the body just said "Your website does not seem to be developed, and I thought you might be willing to let it go for reimbursement of registration fees?"

21:55 andyf: You had fredericks.com or something?

21:56 gfredericks: no I think they've had that one for a long time

21:56 this was presumably about gfredericks.com

21:56 andyf: G. Fredericks of Hollywood

21:57 gfredericks: was about to make a joke about Gfredericks of Ghollywood but now I won't.

21:58 andyf: Man, that site is totally developed. I don't know what that email was talking about.

21:58 gfredericks: I'm thinking they didn't even look

21:59 just somebody scraping a whole bunch of squatter-looking dns entries

21:59 and sending out bulk emails to see what happens

21:59 the "Infringement of Frederick's of Hollywood domain names" subject in particular seems pretty suspicious -- what the heck is an infringement on a domain name?

22:00 kenrestivo: andyf: there is, as i recall, a rather large corporation named after you

22:01 http://en.wikipedia.org/wiki/Fingerhut

22:01 andyf: Well, I think they came first :)

22:01 gfredericks: andyf was in fact named after the Fingerhut company

22:01 andyf: Yeah, my parent's owed them big time.

22:01 s/'//

22:02 gfredericks: wait can I pay off my mortgage this way?

22:03 andyf: Naming your kids for fun an profit (or at least avoidance of loss)

22:04 kenrestivo: there are many stories of corporations suing people who had legit rights to their domain name

22:05 andyf: In the USA, and probably other countries, you can sue any one for just about any reason. Doesn't mean you win.

22:05 kenrestivo: like the guy who was named mcdonalds who had mcdonalds.com.... until the lawywers attacked...

22:08 andyf: All right, another Eastwood linter just about ready to commit. Checking for wrong pre/postconditions.

22:10 gfredericks: wrong?

22:10 clojurebot: It can only be attributable to human error.

22:13 andyf: e.g. there's this fun find in the Criterium library: {:pre (>= 0 index 32)}

22:13 Never fails, but if you write it correctly as {:pre [(>= 0 index 32)]} it would never succeed.

22:15 I haven't found much else in the wild yet -- pre/postconditions are not terribly widely used.

22:16 TimMc: gfredericks: Some jerk once had their lawyer send me a cease and desist notice to me about my brainonfire.net website. I happened to be friends with an IP lawyer who sent them back a notice saying that they could be found guilty under cyberslapp provisions and thus fined up to $10,000 or something.

22:17 amalloy_: Ban picassoo for spam?

22:18 gfredericks: TimMc: okay I'll come to you if I have any issues :P

22:18 TimMc: gfredericks: I felt very lucky, although honestly I could have just ignored them.

22:19 Unfortunately I can no longer find the awesome response letter that was sent.

22:29 TEttinger: andyf, can you explain why that :pre thing in criterium works or doesn't work?

22:29 I hbave never used pre/post condition

22:30 yguan: is there a quick way to concat two vector? (into [] (concat v1 v2)) seems do it in O(n), subvec is quite quick, wish there is also quick way to do the concat also

22:31 sm0ke: ,(concat [1] [2])

22:31 clojurebot: (1 2)

22:31 sm0ke: yguan: you want the result to be a vector also?

22:31 yguan: sm0ke: but it returns a seq, right? yeah...

22:31 sm0ke: vector to vector, all in vector

22:31 sm0ke: ,(into [1] [2 3])

22:31 clojurebot: [1 2 3]

22:32 yguan: sm0ke: :)

22:32 AWizzArd: Note tho that this still is not O(1).

22:33 sm0ke: yep not at all, this should be worst than concat

22:33 but is quite concise

22:33 andyf: yguan: There is a core.rrb-vectors lib that can do vector concat in O(log n)

22:33 yguan: AWizzArd: thanks for mention that

22:34 sm0ke: actually, since no concat there, it's much better

22:34 sm0ke: ,(source concat)

22:34 clojurebot: Source not found\n

22:34 yguan: andyf: thanks, I'll take a look

22:36 sm0ke: looking at the source of concat i wonder why (if-let ) is not used instead of a (let [s (seq x)] (if s..)

22:37 may be if-let is not available before concat?

22:38 anyhow it would be same end result i guess

22:38 ,(macroexpand-1 '(if-let [x 1] x 1))

22:38 clojurebot: (clojure.core/let [temp__4386__auto__ 1] (if temp__4386__auto__ (clojure.core/let [x temp__4386__auto__] x) 1))

22:41 sm0ke: concat looks kind of horrible in terms of performance, its rescursive

22:41 i wonder if that was necessary

23:13 yguan: andyf: run some test over rrb-vector, it's LOT faster, thx

23:55 andyf: yguan: glad to hear it

Logging service provided by n01se.net