#clojure logs

2014-12-23

05:12sm0keneed some help with jline2, any repl people here?
06:08PigDudeI 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
06:08PigDudeI read that this is a Java 8-specific error
06:09PigDudeDefining other excluded core functions on protocols and extending those protocols works in other cases, just not with `cons' ...
06:09BronsaPigDude: no, you can't implement inline a method named cons in a defrecord
06:09PigDudeBronsa: why is that?
06:09BronsaPigDude: defrecords implement IPersistentCollection which already has a method named cons
06:10BronsaPigDude: either use a deftype instead or extend Cat to ConsAir using extend/extend-type/extend-protocol rather than implementing the protocol inline
06:11PigDudeBronsa: why is it important if it is defined inline or not?
06:11BronsaPigDude: 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
06:15PigDudethanks Bronsa !!
06:21expezBronsa: 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.
06:22expezbasically the result of trial and error rather any actual understanding ><
06:24Bronsaexpez: depends, do you want to catch X in (deftype X [] ) and Y in (Y/foo ..) too?
06:25expezyes, all nodes giving me a name I shouldn't remove from the :import clause in the current namespace because the name is in use
06:25Bronsaok so no deftype then, that's imported automatically
06:27Bronsaexpez: http://sprunge.us/QDNT?clj this should handle all your cases
06:29Bronsaexpez: btw refer to https://clojure.github.io/tools.analyzer.jvm/spec/quickref.html when you're lost
06:30expezBronsa: tests are green! Thanks! :)
07:32lxsameerhey guys, is there any video series to learn clojure around ?
07:41luxbocklxsameer: there's https://tbaldridge.pivotshare.com/
07:42luxbocklots of videos on core.async, transducers and core.logic
07:43lxsameerluxbock: thanks but I want to learn clojure first , I think these videos is for my next step
07:44luxbocklxsameer: maybe these https://www.youtube.com/user/Misophistful/videos
07:45lxsameerluxbock: thanks my friend
07:45luxbockno problem
08:03luxbockI 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
08:04luxbockI tried using (prefer-method print-method MyType IPersistentMap/ISeq) but that doesn't work because those two are already preferred
08:04luxbockis there a way around this somehow?
08:17jonathanjthe 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
08:17jonathanjwould anyone be so kind as to point me to a few?
08:25katratxojonathanj: clj-aws-s3 is a s3 client, right?
08:36_kardanAnyone 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
08:37katratxojonathanj: https://clojars.org/search?q=s3
08:39jonathanj_kardan: i'd love to know the answer to that too
08:39jonathanjkatratxo: thank you
08:39jonathanjkatratxo: do you have any experience with any of these?
08:49borkdudeare there any ring/compojure/liberator etc code/project organization guidelines I may borrow inspiration from?
08:49katratxojonathanj: 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
08:55clrndhi guys
08:57nickenchuggetsclrnd: hi
08:57clrndI was looking for info on Clojure's web server's architecture
08:58nickenchuggetsheh, sorry, I'm new to the language.
08:58jonathanjkatratxo: what's the normal way of handling asynchronous uploads?
08:58nickenchuggetslike, 100% new.
08:58clrndme too, congrats :)
08:58jonathanjkatratxo: i guess future (?) uses a threadpool, so just create a future for each one?
08:59borkdudeclrnd there is no "Clojure web server", but there are ring adapters for jetty, etc.
08:59clrndoh so ring is just an adapter for jetty
08:59clrndand jetty is java
08:59borkdudeclrnd and there is also http-kit
08:59clrndnice
08:59clrndwhat is http-kit?
08:59borkdudeclrnd 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
09:00nickenchuggetsI had some questions though, so I guess LISP has its origins in artificial intelligence if I recall correctly...
09:00clrndborkdude, this is the info I wanted thank you very much :D
09:00borkdudeclrnd here is a more complete list (with benchmarks) https://github.com/ptaoussanis/clojure-web-server-benchmarks
09:01clrndthanks again
09:01nickenchuggetsalthough googling around tells me that lisp sort of lost popularity in AI around the 80s.
09:02tcrayford____jonathanj: yeah, that is pretty normal. Depends on the volume you're doing etc
09:03clrndnickenchuggets, lisp lost popularity everywhere I think
09:14nickenchuggetsprobably way off topic, but, I'm trying to find someone who is familiar with the area of artificial intelligence and ask them questions.
09:23luxbocknickenchuggets: AI is a pretty large field, is there something you are interested in particular?
09:28luxbock,(filter (comp (partial = "1.7") :added meta) (vals (ns-publics 'clojure.core)))
09:28clojurebot(#'clojure.core/eduction #'clojure.core/dedupe #'clojure.core/vswap! #'clojure.core/vreset! #'clojure.core/cat ...)
09:36nickenchuggetsluxbock: hahaha, well, I've been reading about "futurology", and I've heard some pretty... wild things.
09:36nickenchuggetsluxbock: that is, "the singularity"
09:37luxbocknickenchuggets: so you are interested in general or strong AI as opposed to weak AI
09:38nickenchuggetsI'm wondering what someone who actually works in AI thinks about all of this "singularity" stuff
09:38luxbockstrong, general, impossible(?) vs. weak, practical, applied AI :)
09:40luxbocknickenchuggets: 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
09:40luxbockI think it's the type of thing they like to talk about
09:41nickenchuggetssweet, thanks
09:42luxbockthe only general AI related project in Clojure that I know of is http://inbits.com/category/clortex-htm-in-clojure/
09:52spuznickenchuggets: I haven't worked in AI but as a programmer I think the 'singularity' is nonsense
09:54clrndnickenchuggets, the singularity is just a pop term for when the understanding of the process of counsciousness let's us reproduce it
09:54spuzif 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
09:54clrndnickenchuggets, 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
09:55clrndI think it's more of a neuroscience problem than a CS one, at list for now
09:56spuzif 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
09:58spuzI 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:00clrndit 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:02bacon198`spuz: I think you're forgetting how far we've come in the past 20 years
10:03bacon198`computers are now impressively powerful compared to back then
10:03bacon198`and using the same exact silicon manufacturing techniques
10:03Morgawrand yet we still use c++
10:04Glenjaminzing!
10:04bacon198`Morgawr: we still use COBOL
10:04mgaareif there is strong AI, it won't run on intel chips. The branch predictor would get jealous and stop it
10:04bacon198`c++ is the least of our problems
10:05bacon198`i've been writing classic vb6
10:05bacon198`c++ would be a godsend
10:08Glenjaminclassic vb6 can't buffer overflow
10:08Glenjamincan it?
10:08Glenjamini hope it cant
10:08clrndthe brain is like ultra-mega-parallel, we will need the cloud or smthg
10:08bacon198`I don't know, it doesn't seem to mind profanity
10:09bacon198`pretty sure there have already been new computing architectures to resemble the brain
10:09bacon198`it's one thing to 'simulate' a brain, rather than just simply build it
10:10bacon198`sortof like how emulating an snes on an x86 computer takes more computing power than the hardware
10:33SagiCZ1isnt the whole theory of artificial neural netowrk about simulating brain?
10:34p_lSagiCZ1: not exactly, but biological structures were the inspiration
10:34SagiCZ1it's just about applying local rules and getting some complex macro behavior.. which is probably what the real brain does
10:34SagiCZ1or a flock of birds for that matter
11:28mi6x3mhey 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:28mi6x3mi.e. first pair on the same line
11:29chouserThose both look fine to me.
11:30mi6x3mpersonally i use the second variant
11:31tcrayford____mi6x3m: I really *really* prefer taking a map over named arguments these days, but maybe that's just me
11:31mi6x3mtcrayford____: it's technically a map :)
11:32chousertcrayford____: I think that's sane.
11:33tcrayford____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:33tcrayford____mi6x3m: it also leads to much easier of passing options through wrappers
11:33tcrayford____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:33mi6x3mtcrayford____: I'm a conformist :>
11:34hellofunkmi6x3m: 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:34tcrayford____mi6x3m: quite a buncha folk do the map over named arg thing these days, think it's getting pretty common
11:35hellofunkmi6x3m: indeed Om is based all around that idea
11:35mi6x3minteresting
11:36chousermap over named args?
11:36chouseroh, "prefer [hash]map over named args"
11:36tcrayford____(foo {:a 1 :b 2}) instead of (foo :a 1 :b 2)
11:36tcrayford____yeah haha
11:37chouserSorry, for a moment I was trying to think (map ??? (apply hash-map args))
11:37tcrayford____yeah :D
11:38hellofunkchouser don't feel too bad, i was quite perplexed at first when reading about adding a newline character to a function call
11:38chouser:-)
11:39mi6x3mi like to break right after the name
11:39hellofunki thought you guys were talkinga bout some weird DSL that mixed string formatting with clojure inline
11:39mi6x3mbut for named args i usually wait till after the first pair
11:42chouserI'm sad we still don't have ubiquitous auto-indenters that never require manual tweaking.
11:44hellofunkchouser you mean a "global standard" on the art of proper indenting of clojure code? like a style guide?
11:44Bronsa+1 for maps over named args
11:45hellofunkmaps are also quite nice for returning multiple values from a single fn. use them all the time now for that.
11:45chouserhellofunk: no, no, tools in all our text editors so we never half to worry about max width, indent amount, newline placement, etc.
11:45chousers/half/have/
11:46hellofunkchouser well at some point a line is going wrap and there's nothing to be done about it.
11:47chouserhellofunk: 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:47chouserWell, 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:47hellofunkchouser 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:48hellofunkand it might change newline position for parent forms to aid with this, otherwise, it wouldn't.
11:48chousernot 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:49chouserand yes, push back up into parent forms as needed.
11:49chouserBasically a really nice pretty-printer with live editing capability. Sounds easy, right? :-)
11:49hellofunkchouser 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:50hellofunkthough, i think the editor with the most power for that type of display/syntax interaction would be Cursive. cfleming can take note!
11:50chouseryes, 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:51Glenjaminideally tools could work on a cannonical representation check internally, but then display could vary based on preference
11:51chouserright. keeps sounding easier and easier.
11:51Glenjaminheh
11:52hellofunkwe definitely support cfleming's comment about writing text itself is not the best way to represent programming ideas
11:52chouserwell, maybe, though I actually think that's different.
11:53mi6x3manother one
11:53mi6x3mhow do you call your listener fns_
11:53chouserThere are benefits to writing the same stuff that we read, which is text.
11:53mi6x3mon-xyz
11:53mi6x3mxyz-listener?
11:53mi6x3mxyz-fn?
11:53hellofunki mean everything we are talking about is how text writing or display gets in the way of actually implementing ideas
11:53mi6x3mwell style is important hellofunk
11:54hellofunkno, i mean well beyond "style" because of being beyond "text" entirely
11:55donbonifacioanyone using test.check? I already have a random function, and I'm having trouble converting it to a generator
11:56tcrayford____donbonifacio: test.check generators *aren't* just random functions :(
11:56hellofunkto 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:57donbonifaciotcrayford____: does that mean that I can't _incorporate_ my scenario?
11:58tcrayford____donbonifacio: if your scenario is a random function right now, you'll have to rewrite it in test.check's generator syntax
11:58donbonifaciocan't to that, too complicated, would need a lot of work
11:58donbonifacioimagine that I'm testing a chess engine and I already have a funciona that generates games
11:59tcrayford____so you can incorporate it, but you'd have to lose shrinking
11:59tcrayford____which is most of the point of test.check
11:59tcrayford____shrinking comes out of the generators
12:00tcrayford____(well, or you can write your own shrinking logic)
12:01donbonifacioI see
12:02arohnerdoes a/put! ever block? I'm confused by it claiming to be async, but also that core.async channels block when full
12:20ghadishaybanBronsa: I'm not sure the non-deterministic protocol dispatch is an issue anymore..
12:20Bronsaghadishayban: ?
12:21ghadishaybanIf clojure.lang.MyMagicIReduce is also Iterable, as long as it there is an entry for MyMagicIReduce inside CollReduce as well,
12:21ghadishaybanit doesn't matter that it is also iterable
12:22ghadishaybandispatch is only non-deterministic for superclasses AFAICT
12:22Bronsaghadishayban: right, a prefer-dispatch would allow us to just prefer IReduce over Iterable rather than having to hard-code all the classes..
12:23ghadishaybanWouldn't it be better to simply add the classes? I'd think prefer-dispatch would be slow
12:23Bronsaghadishayban: right now we have to extend MyCollection to CollReduce to make sure it will get routed through IReduce rather than through Iterable
12:24Bronsaghadishayban: not sure that would be slower. there's a cache
12:25ghadishaybanyeah it might not be. it's acceptable to me to extend MyCollection to CollReduce.
12:25Bronsaonce the Class -> impl is determined once you can safely reuse that. it's invalidated only by other extend/prefer-dispatch like for multimethods
12:27Bronsaghadishayban: 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:27Bronsatch*
12:30Bronsaghadishayban: btw I didn't understand how your comment related to the PV IReduce/1 question, were you just misremembering?
12:30ghadishaybanbrainfart
12:30Bronsahah, ok
12:34ghadishaybanI think the golden rule is, if you are IReduce/IReduceInit, you must be also extended to CollReduce to prevent ambiguity
12:36ghadishaybanDespite the special-casing fast path of IReduceInit inside reduce/transduce, think of CollReduce as primary, and the IReduce as an optimization
12:39maaclDoes it betray a lack of understanding of transients to ask why I cannot find a assoc-in! function anywhere?
12:41TimMcmaacl: No, I don't think so.
12:42TimMcThat seems like quite an omission.
12:43maaclTimMc: Yes, I thought so.
12:45TimMcI don't even see a Jira issue for it.
12:46chousermaacl: are all the maps in the path transients, or only the root? Or only the leaf?
12:48TimMcoh right
12:53maaclchouser: All of them.
12:54chousermaacl: And you're going to go through later and persistent! them all? Have you measure the perf of this approach?
12:56maaclchouser: Not yet. Just started, and failed to find the assoc-in! function, which made me wonder if I was missing something.
13:03maaclchouser: I will do some testing and see what the performance looks like.
13:05wamiltonhi 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:12crash_epit is if you are accessing an element beyond some collection's bounds
13:13wamiltoncrash_ep: right, but this is just the instantiation of the lazy-seq... I've not tried to get anything out afaict
13:14crash_epwhat's your code look like
13:16wamiltoncrash_ep: like so https://gist.github.com/winmillwill/ace2ae2f2fa2eeb5d50d
13:18wamiltoncrash_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:18crash_epwhat table number are you trying to access when you call (tables) ?
13:19crash_epand do you have n-1 elements in the collection at (-> root :content) to do so?
13:20wamiltonI'm trying to get the first one, like so: (-> "short.html" root (tables 1) count)
13:23crash_epThe `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:23crash_epUnless either you're careful to only take as many as you need, or your XML also contains an infinite number of values.
13:23crash_eps/need/can/
13:25wamiltonright, 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:26wamiltonI screwed around and did the (do ...) and (print ...) wrapping and debugging, and n definitely went all the way up, which seems wrong
13:26crash_epcount
13:26crash_epyou are calling count on the thing returned from your tables function
13:27crash_epthat will try to evaluate the entire sequence
13:27crash_epI think what you wanted is `(-> "short.html" root (tables 1) first)`
13:29wamiltonoh, duh, so count causes the lazy sequence to basically be immediately un-lazy? industrious()
13:29wamiltons/\(\)/?
13:32wamiltonbut yeah, even this causes an out of bounds: (-> "short.html" root (tables 1) first)
13:32wamiltonnm, 0 indexing on nth, my bad
13:33wamiltoncrash_ep: thanks
13:33crash_epnp
13:34schonehello #clojure
13:35schonewhat 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:35schoneim sorry, what would be assgiend into var-a var-b var-c
14:05justin_smithnickenchuggets: 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:06mikerodIs 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:07mikerodI 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:07mikerodit is sort of like how Maven shade has http://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html#IncludeResourceTransformer
14:08mikerodbut I'd like to "include the resource under a given name" only during REPL time
14:08mikerodI know it could be in my test resources to fix this issue. That is currently what I'm doing.
14:09AdmiralBumbleBeehas 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:13dark4eghow to create instance generic object use clojure?
14:13justin_smithmikerod: you can have as many resource paths as you like
14:14dark4eg(com.google.common.collect ImmutableList<String>.) ?
14:14dark4egbut this is not the correct version(
14:14justin_smithmikerod: example of dev only resource-paths addition here https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L160
14:15justin_smithdark4eg: generics are a fiction
14:16justin_smithignore the type
14:16justin_smithit's called "type erasure" from the point of view of the java compiler
14:16dark4egthx
14:16justin_smithbut we don't use the java compiler, so instead of having a type and erasing it, we just don't have a type
14:17justin_smith(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:17mikerodjustin_smith: Yes, I mean that I'd like to change the classpath "location" of it.. this likely isn't possible
14:17justin_smithbut there is no syntactic / structural aspect to that, because the jvm has no such concept
14:17mikerodI 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:18justin_smithmikerod: 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:18mikerodjustin_smith: probably not :P
14:18mikerodit would have just been smoother for the REPL stuff I'm doing here
14:18justin_smithoh, not just relative path, but directly in the working dir? that sucks
14:18mikerodbut it isn't essential
14:19mikerodYeah, 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:19mikerodbut in my REPL context I just want to point elsewhere, but make it look like it is in the working dir
14:19mikerodI know its weird
14:20justin_smithhmm, I would attempt to abstract out the code that finds the thing, or add a classpath-relative path to look under
14:20justin_smithwouldn't "root level of classpath" be as good as "working dir" ?
14:20mikerodI 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:20mikerodjustin_smith: I mean the "root level" when I said that
14:20mikerodexample
14:21mikeroddoing (clojure.java.io/resource "my-resource.txt")
14:21justin_smithright
14:21mikerodI'd want that to return non-nil
14:21mikerodnot having to do (clojure.java.io/resource "some/nested/spot/my-resource.txt")
14:21justin_smithso make dev-resources/my-resource.txt and add dev-resources to resource-paths
14:21justin_smiththat suffices right?
14:21mikerodyes
14:21mikerodjust requires I copy files to that place
14:21justin_smithmake a symlink if it needs to be in three places at once :)
14:21justin_smithor more than one even
14:21mikerodtrue
14:21mikerodso the answer is - just don't do something stupid like this :P
14:22mikerodand use the filesystem appropriately hah
14:23justin_smithwell, 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:24mikerodTrue
14:26dark4egjustin_smith (new com.google.common.collect.ImmutableList) -> No matching ctor found for class com.google.common.collect.ImmutableList
14:26justin_smithdark4eg: for starters, direct usage of "new" is considered depricated, use (c.g.c.c.ImmutableList. ...)
14:27justin_smiththen, 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:27justin_smithyou should probably be using (ImmutableList$Builder.), manipulating that, then implementing and ImmutableList from that
14:28justin_smithany particular reason you are using this class instead of the Clojure built in immutable collections?
14:29dark4egorg.openqa.selenium.phantomjs
14:29justin_smithOk
14:30justin_smithso (let [builder (com.google.common.collect.ImmutableList$Builder)] (doto builder (.add 1) (.add 2) (.add 3)) (.build builder))
14:31justin_smiththat (or something very close to it) should get you an ImmutableList of (1 2 3)
14:31justin_smithoh, I missed a .
14:31justin_smithso (let [builder (com.google.common.collect.ImmutableList$Builder.)] (doto builder (.add 1) (.add 2) (.add 3)) (.build builder))
14:33justin_smiththough in practice you likely just want (.addAll builder [1 2 3])
14:54devn,(range 0 1 0.1)
14:54clojurebot(0 0.1 0.2 0.30000000000000004 0.4 ...)
14:54justin_smith,3/10 the ratio of the devil
14:54clojurebot3/10
14:55justin_smith,(range 0 1 1/10)
14:55clojurebot(0 1/10 1/5 3/10 2/5 ...)
15:47Pistahhre
16:10DomKMI 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:25dbacarHi everyone
16:27justin_smithDomKM: what isn't working as expected?
16:29dbacarhi I cannot find the keyboard shortcut for cider- show clojure source, any ideas?
16:29nullptrM-. runs the command cider-jump-to-var, which is an interactive compiled Lisp function in `cider-interaction.el'.
16:29justin_smithdbacar: it should be M-.
16:29justin_smithjynx
16:31dbacarthanks a lot
16:37danielglauserDomKM: prep-task runs a leiningen task, I believe the way to create those is through a plugin. Did you write a plugin?
16:39danielglauserDomKM: Here's a sample plugin: https://github.com/denofclojure/lein-validate
16:43DomKMhttps://www.irccloud.com/pastebin/iDRU6D2y
16:44DomKMoops, I seem to have just told IRCCloud to make a pastebin of that message
16:44DomKMsorry about that
16:44justin_smithit's readable enough there though
16:44justin_smithbetter that rather than multi line message here
16:44DomKMtrue :)
16:45DomKManyway, 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:59danielglauserDomKM: Weird. I'm sure I have a bit to learn about leiningen, recently started poking around the code.
17:01danielglauserDomKM: I wonder if the alias is already "used": https://github.com/technomancy/leiningen/blob/master/leiningen-core/src/leiningen/core/main.clj#L43
17:22donbonifacioin 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:24reiddraperdonbonifacio: check out `subset` in https://github.com/gfredericks/test.chuck#generators
17:25reiddraperdonbonifacio: https://github.com/gfredericks/test.chuck/blob/master/src/com/gfredericks/test/chuck/generators.clj#L141-L149
17:26donbonifacioreiddraper: what If I'd like to specify the size of the new collection (for example, with another gen)
17:27reiddraperdonbonifacio: 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:28donbonifacioyes
17:28donbonifacioI still can't figure it out, may be missing something
17:29donbonifacioI could gen/shuffle and then take X, but can't find a gen that does the take
17:29nullptrgen/sized?
17:30reiddraperdonbonifacio: i'll write you a simple example of exactly that
17:30donbonifacioalso tried gen/elements, but couldn't generate a distinct vector
17:30donbonifacioalso tried sized and resize
17:30donbonifaciomaybe I'm just too tired :)
17:32reiddraperdonbonifacio: (defn subgen [coll] (gen/fmap (fn [[shuffled len]] (take len shuffled)) (gen/tuple (gen/shuffle coll) (gen/choose 0 (count coll)))))
17:34donbonifaciothat's it reiddraper, thanks :)
17:35reiddraperdonbonifacio: np
17:35reiddraperyou'll often see gen/tuple, gen/fmap and gen/bind used for more complex generators
17:39donbonifacioyes, your example is showing me some light
18:08OscarZ_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:11OscarZ_java application of course
18:35justin_smithOscarZ_: 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:35justin_smithhell, only listen to a local port if you trust everyone with a login :)
18:35justin_smithyou can use an ssh tunnel to make a secure nrepl connection
18:36OscarZ_hehe yes, thats a good point :)
18:36OscarZ_cool, so theres some library for that already
18:36justin_smithOscarZ_: that's the same lib lein uses for the "lein repl" task
18:37OscarZ_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:37justin_smithamalloy_: picassoo is spamming, still (note the extra o, of course)
18:37OscarZ_a bit like Jackson JSON mapper works with Java classes and JSON
18:37justin_smithOscarZ_: ##(bean (java.util.Date.))
18:37lazybot⇒ {:day 2, :date 23, :time 1419377694183, :month 11, :seconds 54, :year 114, :class java.util.Date, :timezoneOffset 0, :hours 23, :minutes 34}
18:38justin_smithin general, if it uses standard getFoo / setFoo bean will work
18:38OscarZ_cool :)
18:38justin_smiththough bean is a bit expensive (it is reflection based) and you can improve performance by making your own custom class based transformation
18:38OscarZ_ok, i dont worry about performance much in this case..
18:39justin_smiththen for a standard pojo with your normal getters and setters, bean will just work
18:39OscarZ_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:39justin_smithyup, clojure is a nice way to interact with the jvm
18:40OscarZ_whats this ## thingy called ?
18:40justin_smith"tell lazybot to evaluate an expression ##(println "hi") mid sentence"
18:40lazybot⇒ hi nil
18:42OscarZ_oh sorry.. i was after "bean"
18:42justin_smithhaha, OK
19:20akkadahh, it's an acronym: Common Lisp On Java Using Rich's Experience
19:28justin_smithwell, 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:29justin_smith*feature
19:30justin_smith"The name was chosen to be unique. I wanted to involve c (c#), l (lisp)
19:30justin_smithand j (java)."
19:31justin_smithhttps://groups.google.com/forum/#!topic/clojure/4uDxeOS8pwY
21:06gfredericksjustin_smith: doing clojure history research?
21:10justin_smithcorrecting what may in retrospect have been a joke
21:11justin_smithand picassoo is still at it
21:33visofhi guys
21:33kenrestivohis nose is not centered
21:33kenrestivoand everytihng is two dimensional
21:34visofthere 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:34visofthere 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:34visofdon't work
21:35andyfwhat happens?
21:35visofcan anybody help in this?
21:36andyfvisof: There are many ways that it might not work, but you haven't told us what it does do when you try that.
21:37visof(.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:37andyfmap is lazy
21:38andyfit will only call the function on elements of the sequence if you do something that consumes the return values
21:38andyfif you want side effects, consider doseq instead.
21:38andyfor put map inside (doall ...)
21:40andyf(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:41visofandyf: how can i pick k and v for hash in doseq?
21:41andyf(doseq [[k v] hash-map] (.field doc k v)) should do it, I think.
21:41gfrederickshi andyf
21:42andyfI was going to say "howdy gf", but that might not sound right.
21:43gfredericks~gf
21:43clojurebotCool story bro.
21:43gfredericks~gf is greasy fries
21:43clojurebotRoger.
21:44andyfIt reminded me of "girlfriend", which would definitely send the wrong impression
21:45gfredericksyeah
21:46gfredericksmy name has mostly nonflattering variations
21:46andyfGrade school is a little weird at times when your last name is "Fingerhut" :-)
21:48gfredericksapparently Fingerhut is a sleazy company of some sort
21:51andyfA 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:54gfredericksI once got an email with the subject "Infringement of Frederick's of Hollywood domain names
21:55gfredericksand 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:55gfredericksbut 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:55andyfYou had fredericks.com or something?
21:56gfredericksno I think they've had that one for a long time
21:56gfredericksthis was presumably about gfredericks.com
21:56andyfG. Fredericks of Hollywood
21:57gfrederickswas about to make a joke about Gfredericks of Ghollywood but now I won't.
21:58andyfMan, that site is totally developed. I don't know what that email was talking about.
21:58gfredericksI'm thinking they didn't even look
21:59gfredericksjust somebody scraping a whole bunch of squatter-looking dns entries
21:59gfredericksand sending out bulk emails to see what happens
21:59gfredericksthe "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:00kenrestivoandyf: there is, as i recall, a rather large corporation named after you
22:01kenrestivohttp://en.wikipedia.org/wiki/Fingerhut
22:01andyfWell, I think they came first :)
22:01gfredericksandyf was in fact named after the Fingerhut company
22:01andyfYeah, my parent's owed them big time.
22:01andyfs/'//
22:02gfrederickswait can I pay off my mortgage this way?
22:03andyfNaming your kids for fun an profit (or at least avoidance of loss)
22:04kenrestivothere are many stories of corporations suing people who had legit rights to their domain name
22:05andyfIn the USA, and probably other countries, you can sue any one for just about any reason. Doesn't mean you win.
22:05kenrestivolike the guy who was named mcdonalds who had mcdonalds.com.... until the lawywers attacked...
22:08andyfAll right, another Eastwood linter just about ready to commit. Checking for wrong pre/postconditions.
22:10gfrederickswrong?
22:10clojurebotIt can only be attributable to human error.
22:13andyfe.g. there's this fun find in the Criterium library: {:pre (>= 0 index 32)}
22:13andyfNever fails, but if you write it correctly as {:pre [(>= 0 index 32)]} it would never succeed.
22:15andyfI haven't found much else in the wild yet -- pre/postconditions are not terribly widely used.
22:16TimMcgfredericks: 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:17TimMcamalloy_: Ban picassoo for spam?
22:18gfredericksTimMc: okay I'll come to you if I have any issues :P
22:18TimMcgfredericks: I felt very lucky, although honestly I could have just ignored them.
22:19TimMcUnfortunately I can no longer find the awesome response letter that was sent.
22:29TEttingerandyf, can you explain why that :pre thing in criterium works or doesn't work?
22:29TEttingerI hbave never used pre/post condition
22:30yguanis 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:31sm0ke,(concat [1] [2])
22:31clojurebot(1 2)
22:31sm0keyguan: you want the result to be a vector also?
22:31yguansm0ke: but it returns a seq, right? yeah...
22:31yguansm0ke: vector to vector, all in vector
22:31sm0ke,(into [1] [2 3])
22:31clojurebot[1 2 3]
22:32yguansm0ke: :)
22:32AWizzArdNote tho that this still is not O(1).
22:33sm0keyep not at all, this should be worst than concat
22:33sm0kebut is quite concise
22:33andyfyguan: There is a core.rrb-vectors lib that can do vector concat in O(log n)
22:33yguanAWizzArd: thanks for mention that
22:34yguansm0ke: actually, since no concat there, it's much better
22:34sm0ke,(source concat)
22:34clojurebotSource not found\n
22:34yguanandyf: thanks, I'll take a look
22:36sm0kelooking at the source of concat i wonder why (if-let ) is not used instead of a (let [s (seq x)] (if s..)
22:37sm0kemay be if-let is not available before concat?
22:38sm0keanyhow it would be same end result i guess
22:38sm0ke,(macroexpand-1 '(if-let [x 1] x 1))
22:38clojurebot(clojure.core/let [temp__4386__auto__ 1] (if temp__4386__auto__ (clojure.core/let [x temp__4386__auto__] x) 1))
22:41sm0keconcat looks kind of horrible in terms of performance, its rescursive
22:41sm0kei wonder if that was necessary
23:13yguanandyf: run some test over rrb-vector, it's LOT faster, thx
23:55andyfyguan: glad to hear it