Fork me on GitHub
#clojure
<
2016-03-22
>
mikera00:03:52

@seb321 glad you found core.matrix helpful! Please do send issues / PRs my way if you find any use cases in which it could be improved, trying to make it as generally useful for everyone as possible

Alex Miller (Clojure team)02:03:37

@bfabry: I don't think you should expect that to necessarily work forever

bfabry05:03:59

@alexmiller fair enough, I don't think I would simple_smile metaprogramming stuff seems to be inherently like that

vikeri08:03:02

Is there a collection library of schemas for plumatic schema? Looking for common things like URL, email etc.

rm08:03:15

[kixi/schema-contrib "0.2.0"]

rm08:03:24

vikeri: ^

vikeri08:03:14

@rm: A bit worrying that they have not merged pull requests and not updated since Aug 2014 though. The whole point of this kind of lib is to have everyone contribute...

rm08:03:35

I don't know, I'm not involved into development, I just use the lib, it works

acron09:03:11

is there a form similar to cond-> but that uses the 'running value' as input to each predicate?

acron09:03:30

(magicond-> 1
   true (* 2)
   even? inc
   #(= 3 %) (fn[_] "seven")
   string? clojure.string/upper-case)
something like this?

acron10:03:23

@rauh: perfect! thanks so much

munen12:03:59

Hi there I'm struggling with a simple import of a Java class. I suspect the problem is that this Class has a . in it's name. (import ) will yield a ClassNotFoundException. However, it looks to me to be the correct classname regarding the JavaDoc: http://docs.oracle.com/javase/8/docs/api/javax/sound/sampled/Port.Info.html Java Interop beginners help is much appreciated(;

zcaudate12:03:59

@munen: try import javax.sound.sampled.Port$Info

munen12:03:44

@zcaudate: This works! Thank you very much! May I know where you learned about that? I actually did some digging before I asked here and didn't get a clue.

zcaudate12:03:20

@munen: ummm… that’s a very good question…

zcaudate12:03:17

i kinda just picked it up reading source code

munen12:03:52

@zcaudate: That's a very good answer that I can relate to. I have written a couple Clojure and CLJS apps so far, but I still am just a beginner regarding Clojure. In time I do hope to be able to help other people here as quickly as you just did. Again, thank you very much^^

jmayaalv12:03:22

@munen this is hidden in the java interop documentation. http://clojure.org/reference/java_interop. "Note that nested classes are named EnclosingClass$NestedClass, per the JVM spec."

munen12:03:23

@jmayaalv: Now I'm a bit embarrassed. I did have that page open, of course. This is one of those times to just RTFM better... I skimmed it multiple times, but I didn't read everything in that chapter, because I didn't deem it relevant. How wrong I was. I'll re-read the whole page right now just in case. You have my gratitude!

nberger12:03:07

@munen this post explains this and many other "special" characters very well: https://yobriefca.se/blog/2014/05/19/the-weird-and-wonderful-characters-of-clojure/ . And I just noticed it has a search feature at the top!

zcaudate12:03:38

does anyone still use textmate for clojure?

zcaudate12:03:46

atom’s too slow… and I’m too cheap to pay for sublime

zcaudate12:03:53

the textmate bundle hasn’t been updated in 5 years

erichmond12:03:40

I use intellij + cursive

munen12:03:50

@nberger: I remember seeing this one on HackerNews a good while ago. Back then I didn't have the chance to do much in Clojure, though. I'll get into that one today and learn me some internals. Thanks for the reference!

featalion12:03:39

I use emacs + cider and like the pair. Unfortunately, it is not easy to start with.

borkdude12:03:43

I found Prelude a good starting point

borkdude12:03:51

from the same creator as CIDER

zcaudate12:03:03

@borkdude: I use emacs too but I have mate . programmed into my muscle memory

munen12:03:27

@zcaudate: Even though I disqualified myself a bit here, I'm a bit of an editor Nerd. I've been using and pushing VIM for 14 years, but for Clojure I switched to Emacs+Cider and wouldn't look back. Also Emacs is a wonderful operating system, not just an awesome editor^^

featalion12:03:11

@zcaudate: alias mate=emacs

zcaudate12:03:20

yeah… @twashing got me onto spacemacs

featalion12:03:23

this is the smallest issue ( ;

munen12:03:32

@zcaudate: Just start Emacs once and never quit it again^^

zcaudate13:03:27

@munen: it’s too powerful… I serious don’t know what to do with it at times

featalion13:03:06

@munen: yeah, true. I have been using emacs since '03. Each year I try to find better alternative, but failed.

munen13:03:51

@zcaudate: When I started, I did move everything I did in Mail, Evernote and Things (GTD Tool) into Emacs within the week. Now I don't have to leave it for the occasional look at the browser*g*

munen13:03:02

@featalion: I'm not sure it's possible. The underlying concept of being similar to a LISP machine is hard to improve upon. Took me a long time to figure out that VIM might be the best Editor, but it could just be one of the programs that I run inside Emacs^^

munen13:03:59

I was stupid and never looked into Emacs, because I wasn't doing Lisp and the shortcuts of Emacs looked just too clumsy compared to VIM's modal editing. It's interesting, though, how many friends I could interest with a couple of demos or talks during coffee(;

featalion13:03:01

@munen: it is only true in common, but not to execute specific tasks. I haven't found better solution for programming, but I still prefer google's interface for email and trello web interface, for example.

munen13:03:35

@featalion: I have to admit, that I'm in Love with Mu4e (the mail client). I have 5 mail addresses for different companies and none of them is from Google. So far I was lucky not to have to use it. I know it of course, I did use it some years ago for work and didn't like it for the reason that it didn't fit well into my GTD workflow of being able to cross-reference Mails, Notes and Todos. Now, that's even more awesome with Org-Mode and Mu4e^^ I'm not using Trello, but Pivotal - and for that I confess to also use the web client, because it is really well done.

munen13:03:11

Being a web-dev, there's certainly a couple pages that I still visit from time to time^^

featalion13:03:53

@munen: all my last customers use google apps for business. and it is very easy to forward email to master address and filter them there. it is also possible to send messages from "remote" email addresses. But in your case emacs rocks for sure ( ;

munen13:03:36

@featalion: Yeah, I'm not going to argue against Google Apps^^ I also did what you just explained some years ago and have friends who still do it. I do like the option to not share everything with Google, though. Plus, I really like the workflow of Mu4e - and did tweak it with some Elisp goodness to make i even better^^

moxaj13:03:24

hey people, quick question: how do I place type hints with reader conditionals?

moxaj13:03:25

for example, I'd like x to be type-hinted with Foo when compiled to clojure in (fn [x] 42)

moxaj13:03:00

the solution seems to be: (fn [#?(:clj ^Foo x :default x)] 42)

darnok14:03:27

hi, how does partition work? I tried (partition 30 (range 5)) and it returned me empty list.

moxaj14:03:02

@darnok use partition-all

fadrian14:03:42

According to ClojureDocs, defn has this as a function signature: (defn name doc-string? attr-map? [params*] prepost-map? body), where supposedly, the attributes in attr-map are added to the var metadata. I've defined a function: (defn foo {:a :b} [] nil), which matches the signature, but when I check the metadata using (meta 'foo), all that is returned is the standard function compilation metadata. Any idea why this is not acting as the documentation specifies?

schaueho14:03:03

works for me -- but you need to call (meta #'foo) to see it

fadrian14:03:44

Thanks. It's the var metadata. Now I understand.

thiagofm16:03:31

Let's say I have the following: (def k '[(:aaa 1 :bbb 2 :ccc 3)]) What would be a nice and clean way to update the value after :aaa, or :bbb, :ccc? (I know it could be easy if the list '() was a map, but sadly it's not)

matthavener17:03:58

thiagofm: if the order doesn’t matter, it would be pretty simple to transform it into {:aaa 1 :bbb 2 :ccc 3}, update it, and then concat it back together

thiagofm17:03:00

@matthavener: (into {} k) wouldn't work for this. I'm thinking about just mapping over and do what I want

thiagofm17:03:15

But I was looking for the "woooah" solution

matthavener17:03:32

(into {} (map vec (partition 2 k))

thiagofm17:03:12

cljs.user> (into {} (map vec (partition 2 k))) {} 😞

thiagofm17:03:27

I'll go with the map, it's okay

cmcfarlen17:03:47

@thiagofm: If you are often updating the value after one of those, then the map will be your best bet (using update-in or assoc). If you need to keep it as a list and you can write your own update-after fn and it will still feel pretty clean when you use it.

cmcfarlen17:03:53

I think you want to partition (first k) for @matthavener's suggestion

crankyadmin17:03:46

Hi, could any give me any ideas why when I call my (-main "--input" "something" "--output" "something") works fine from the repl but when I launch (after using lein uberjar) with the args passed in as java -jar --input" "something" --output "something" it dosen't do anything...

crankyadmin17:03:49

(defn -main
  [& args]
  (let [args-map (parse-opts args cli-options)
        input-path (get-in args-map [:options :input-path])
        file-list (list-directory-from-HDFS input-path)]
    (pmap upload->file-storage file-list)))

hiredman17:03:16

well, pmap is sort of lazy

hiredman17:03:28

(also terrible)

matthavener17:03:24

crankyadmin: check out doall

crankyadmin17:03:37

Thanks both. I was looking for any easy to do it in parallel. pmap seemed like a sensible idea. Whats a better approach

matthavener17:03:19

hiredman: doesn’t pmap use executors behind the scenes?

crankyadmin17:03:33

Cool. In the above snippet; where would the doall be place? Do I wrap the pmap or dump it all together?

matthavener17:03:59

yeah, wrap the pmap which forces realization of the seq, which forces the execution of upload->file-storage

crankyadmin17:03:25

Sweet! Thank you.

crankyadmin17:03:43

Yep. That fixed it! Thanks again guys simple_smile

josh.freckleton18:03:04

I'm studying about declarative databases, and abstracting away from REST backends, and it's led me to decision overload with Falcor, GraphQL, Relay, and DataScript all thrown in the mix. What should I use if I want have a more declarative database, where I can request with JSON syntax from the client side, and avoid many REST endpoints? And are these solutions a layer over, ex Mongo, or Postgres, or something else entirely?

matthavener19:03:19

josh.freckleton: you should probably look at om.next simple_smile and join #C06DT2YSY

josh.freckleton19:03:49

@matthavener: I'v been reading up on it and from what I can tell, om.next is still not production ready, no? Something like reagent feels a bit more stable, is there anything that would work if I went the reagent route, or is it really just om.next?

matthavener19:03:26

sorry, I don’t know enough about reagent to know if it would work. my limited understand of reagent suggests you’d have to write a lot of the equivalent falcor/relay functionality yourself

josh.freckleton20:03:35

@smw: thanks, I love re-frame! How do you build a non-REST backend for doing declarative database requests in re-frame??

smw20:03:12

Not something I’ve thought about simple_smile You might consider asking in #C073DKH9P or #C0620C0C8

josh.freckleton20:03:41

is there an idiomatic way to accomplish this, taking a vector and converting it to a map?:

(defn make-entry [id name contact description]
  {:id          id
   :name        name
   :contact     contact
   :description description})

josh.freckleton20:03:07

I'd like to make many of these maps dynamically, and i'd love if I could add/remove things from the parameters without duplicating the effort by creating an entry that pointst to that...

jr20:03:17

you’ll have to write a macro for that

josh.freckleton20:03:18

good point, just curious if there was a better way simple_smile

josh.freckleton20:03:20

ah nice, so would you think like this:?

(defn make-entry [& rest]
  (zipmap [:id :name :contact :description] rest))
(make-entry "a" "josh" "123-4567" "hi there")

josh.freckleton20:03:33

that looks a lot better

lvh22:03:01

I’m trying to simplify some with-redefs(-fn) code — how do I go from a fully qualified symbol to a var?

lvh22:03:55

I think it’s ns-resolve?

lvh22:03:16

Oh, resolve!

base69822:03:26

is there an easy way to get a limited collection? maybe just (take 5 (into [] items)) ?

cky23:03:30

@base698: Surely in that case you’d use (into [] (take 5 items)) instead?

cky23:03:02

unless you’re really trying to materalise the rest of the items sequence unnecessarily.

danielsz23:03:58

Is there an issue with clojars? I just pushed a SNAPSHOT version, it uploaded it just fine, but when I try to use it from a project, I get an error that says: org.sonatype.aether.transfer.ArtifactNotFoundException: Could not find artifact org.danielsz:system:jar:0.3.0-20160322.233127-13 in clojars (https://clojars.org/repo/)

andrewboltachev23:03:55

@danielsz: Is [org.danielsz/system "0.3.0-SNAPSHOT"] your artifact?

andrewboltachev23:03:04

➜  system1 lein deps 
Retrieving org/danielsz/system/0.3.0-SNAPSHOT/system-0.3.0-20160322.233148-13.pom from clojars
Retrieving reloaded/repl/reloaded.repl/0.1.0/reloaded.repl-0.1.0.pom from clojars
Retrieving com/stuartsierra/component/0.2.1/component-0.2.1.pom from clojars
Retrieving prismatic/schema/1.0.4/schema-1.0.4.pom from clojars
Retrieving com/stuartsierra/component/0.3.1/component-0.3.1.pom from clojars
Retrieving org/danielsz/system/0.3.0-SNAPSHOT/system-0.3.0-20160322.233148-13.jar from clojars
Retrieving prismatic/schema/1.0.4/schema-1.0.4.jar from clojars
Retrieving reloaded/repl/reloaded.repl/0.1.0/reloaded.repl-0.1.0.jar from clojars
Retrieving com/stuartsierra/component/0.3.1/component-0.3.1.jar from clojars

andrewboltachev23:03:17

for fresh project

andrewboltachev23:03:09

@danielsz: may be your ~/.m2 is wrong or there're some DNS issues?

andrewboltachev23:03:03

@danielsz: I think you might try renaming ~/.m2 it and then lein deps too

danielsz23:03:57

@andrewboltachev: Ah, you don't have any trouble retrieving it? It's only me?

danielsz23:03:51

@andrewboltachev: That's already good news simple_smile

andrewboltachev23:03:06

sorry, Slack is very slow for some reason for me. JS hangs while I type

danielsz23:03:06

@andrewboltachev: no problem. Thanks. I don't get it. Clojars is accessible to me (so not a DNS issue). I'm using Boot in my project, but I never had this problem before.