Fork me on GitHub
#clojure
<
2018-08-24
>
kaosko05:08:31

anybody used google apis with clojure, especially youtube? I need to upload videos programmatically and already started doing it with the java libraries, but oh dear god, there are so many types... didn't find any good pure clojure wrappers, anyone?

jeroenvandijk09:08:11

@kaosbeat I've worked with this one for Google docs. Especially the authentication part felt smooth (openin a browser window for you etc) https://github.com/SparkFund/google-apps-clj

jeroenvandijk09:08:26

Does someone have experience with instaparse and (external) bnf grammars? I was thinking to use instaparse with an AWS grammar, but it is not compatible https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_grammar.html#policies-grammar-bnf

pbaille10:08:44

Hello, i've came across one strange behavior:

(defprotocol A (-a [_]))
(def a -a)
(extend-protocol A Object (-a [x] x))
(a {}) ;; => No implementation of method: :-a ....
it works as intended with a defn instead of a def

bronsa10:08:13

that makes sense

bronsa10:08:44

when you do (def a -a), you're assigning to a the dereferenced value of -a at the point in time of the assignment

pbaille10:08:14

i should use #'-a

grav10:08:52

Clojure:

user=> (.replace "foo" "o" "x")
"fxx"
Cljs:
cljs.user=> (.replace "foo" "o" "x")
"fxo"
Gotta be careful with interop! clojure.string/replace solves it, luckily 🙂

bronsa10:08:53

it's a bit of an internal detail that extend-protocol works by resetting the root binding of the method vars

bronsa10:08:03

but not a bug

pbaille10:08:13

ok nice to know

pbaille12:08:44

is there a valid syntax for doing something like that? (ns foo (:refer-clojure :exclude :all) (:require [clojure.core :as c]))

dominicm12:08:10

is that invalid?

pbaille12:08:45

it seems, i will double check

pbaille12:08:08

CompilerException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword

dominicm12:08:38

(ns foo ...)

pbaille12:08:50

yes sorry, this is not the problem

dominicm12:08:33

Oh, I just realised :exclude :all.

pbaille12:08:45

i have to use :only

pbaille12:08:57

with empty vec i think

jmromrell13:08:49

Is there a way to create a global var in the same fashion as *warn-on-reflection* on which I can call (set! *my-var* true)?

jmromrell13:08:02

When I do it like (def ^:dynamic *my-var* false) and then do (set! *my-var* true) I get IllegalStateException Can't change/establish root binding of: *my-var* with set clojure.lang.Var.set (Var.java:221), presumably because it is a local binding, as mentioned here: https://clojuredocs.org/clojure.core/set!

bronsa13:08:18

the reason why you can set! *warn-on-reflection* is that the evaluation context of clojure has *warn-on-reflection* local-bound, it's not a "special" type of Var

bronsa13:08:41

so no, without an existing thread binding you just can't set! a var

bronsa13:08:46

you can alter-var-root it

bronsa13:08:52

but that's a different operation

jmromrell13:08:57

(set! *warn-on-reflection* true)
=> true

bronsa13:08:08

what about that?

bronsa13:08:44

>the evaluation context of clojure has *warn-on-reflection* local-bound by that I meant that there is an implicit (binding [*warn-on-reflection* *warn-on-reflection*] ..) wrapping your repl session

bronsa13:08:12

there's a handful of clojure.core Vars that get that special treatment of being thread-bound by the compiler environment

bronsa13:08:53

but there's nothing special about the Vars themselves

bronsa13:08:21

a Var has to be thread-bound if you want to set! it

jmromrell13:08:21

Perhaps I should describe what I'm trying to accomplish. I am writing a library that has a Java-consumable interface. I'm wanting to provide a setting that will disable a specific validity check, if needed, for performance reasons. I'd like it to be possible to set this permanently or as a binding, if possible.

jmromrell13:08:36

It would be unwieldy to have to wrap your entire app in a binding to disable it globally - especially from Java where you'd likely have to pass your entire program logic in as a Runnable or something

jmromrell13:08:24

However, I can see there being cases where you might want to disable the setting for one use case while preserving it for others

kaosko13:08:19

thanks @jeroenvandijk hmm it really wraps Google's java client apis and no youtube, but looks fairly complete. youtube's inserting must be pretty similar to drive insert.. perhaps I should add to that

bmcferren15:08:03

might you guys have a solution for a java.lang.NullPointerException each time to try evaluating an expression while in a breakpoint window, using Cursive/Intellij?

seancorfield17:08:50

Did you trying asking in the #cursive channel? Colin's usually very responsive there.

bmcferren15:08:31

also, what happened to the IRC channel? It seems that all messages are now blocked. Have the moderators from the irc channel moved to this slack channel?

hiredman16:08:38

freenode (the irc network that the channel is on) has been experiencing a pretty bad spam attack, so many channels there are +R meaning you must have a registered nick https://freenode.net/kb/answer/registration

sroller18:08:49

newbie question: I want to process a csv file. I defined the dependency in my project.clj file [clojure-csv/clojure-csv "2.0.1"]

sroller18:08:14

how do I know what I need to require in the repl or in my source.

sroller18:08:32

(require 'clojure-csv/clojure-csv) throws an error.

sroller18:08:43

same for clojure.csv

sroller18:08:00

what's the "canonical" way to find that magical word?

Graham Seyffert18:08:14

(require '[clojure-csv/clojure-csv :as csv])

Graham Seyffert18:08:59

Assuming that’s the correct namespace to require

Graham Seyffert18:08:52

According to the readme looks like you want clojure-csv.core

Graham Seyffert18:08:45

(there’s no real way to discover that (that I know of) other than looking through the code or in the library’s README; people usually put it right at the top of the README though)

sroller18:08:23

thank you. I found something in <test> directory. I should have looked earlier before asking here.

sroller18:08:33

... in the <test> ...

sroller18:08:41

@gseyffert My understanding is, that I provide the name of the namespace of said module? So I'd look into src/<projectname>/core.clj of said module to find out what's in "(ns ...)"?

ghadi18:08:53

there are a ton of people eager to help out in #beginners . I suggest joining that room if you're not in there

ghadi18:08:17

(I know that doesn't answer your immediate question) 🙂

sroller18:08:40

np, I guess room == Channel in Slack?

alexmiller18:08:06

hey all, as has been mentioned in various places, the core team is currently working on some improvements around error reporting, etc. I think this is really starting to pay off and I look forward to getting it out into the wild. I have a variety of error examples I am looking at but right now I would be very interested in collecting some more examples that are core macro syntax spec errors (let, if-let, when-let, defn, defn-, fn, ns, import, refer-clojure).

❤️ 18
alexmiller18:08:24

I just want code examples, I don’t need the spec error message. I’ve got so many changes in play that the old output is not helpful.

alexmiller18:08:09

some examples: (let [x]), (ns), (defn [x]), etc

dadair19:08:43

(defprotocol Foo
  (x
    ([foo])
    ([foo bar])))

alexmiller19:08:45

good, thx :)

timothypratley21:08:34

(let [{:keys [a b]} 1]
  a)

timothypratley21:08:12

(let [baz 1
      [foo bar] baz]
  (+ foo bar))

timothypratley21:08:20

(use 'clojure.test)
(deftest (is true))

alexmiller21:08:07

I’ve seen that but many of those are not in this narrow scope of spec macro errors

alexmiller21:08:27

none of the other examples above are macro spec errors either

alexmiller21:08:13

the first and last are compiler errors and middle is a runtime evaluation error

alexmiller21:08:55

the first one is particularly weird

donaldball01:08:17

(defprotocol Fooable
  (foo
    "I often make this mistake"
    [_]))

alexmiller03:08:06

good one, thx

donaldball15:08:01

A coworker just lamented: (defn foo "bar")