beginners

Getting started with Clojure/ClojureScript? Welcome! Also try: https://ask.clojure.org. Check out resources at https://gist.github.com/yogthos/be323be0361c589570a6da4ccc85f58f.
Dave Suico 2021-03-01T05:46:03.016400Z

Good day everyone! Has anyone known some code samples or articles on how to use this library? I'm having a hard time using this especially when I'm new to the syntax. Thank you! https://github.com/SparkFund/google-apps-clj

Dave Suico 2021-03-01T08:01:26.019500Z

@dharrigan awesome man thanks! your code is nice to read, gonna try it soon.

Dave Suico 2021-03-01T08:06:05.019700Z

Hello @adrianimanuel thanks man for the extended help, remember the last time I asked about this, and then I ended up using HTTP? turns out my senior wasn't impressed and instead wanted me to use that library since he uses this a lot. πŸ˜…

2021-03-01T08:08:57.019900Z

Yes, i've searching a lot of method as well, but this one is good. the hiccups i've met (that made me struggle for 3 wks is this part) lol... so I made the complimentary guidance with screenshot to make it easier https://clojurians.slack.com/archives/C053AK3F9/p1614308927419900

Dave Suico 2021-03-01T16:32:02.027100Z

hey guys I tried to call get-auth-map and now I'm getting this

Dave Suico 2021-03-01T16:44:17.027300Z

Okay guys i'm good now i just need to publish my project

Dave Suico 2021-03-01T17:09:12.027500Z

so yeah I can see my token now from the webpage but whenever I paste it in the console(VSCode) I'm getting this

Dave Suico 2021-03-01T17:09:28.027700Z

or when i paste the code nothing happens

Dave Suico 2021-03-01T18:35:01.028100Z

2021-03-02T09:03:12.040600Z

I don't know any other IDE besides emacs... as in emacs i paste in stdin : PasteTheAuthCodeHere . you should ask others who use vscode where to paste the authcode

Dave Suico 2021-03-02T12:07:43.041900Z

Finally got it guys, it needs to be run in repl

Dave Suico 2021-03-01T06:22:49.016900Z

Hey men, thanks a lot I haven't thought of that trick:sweat_smile:

phronmophobic 2021-03-01T06:26:46.017200Z

yea, it's great. you just find someone else that already wrote the code you need πŸ˜„

dharrigan 2021-03-01T07:03:05.017900Z

Here's a very very basic exmaple using authentication and listing the contents of your google drive. Someone else was asking about the google library a few weeks ago, so I put together an example: https://github.com/dharrigan/google-apis-example

2021-03-01T07:52:24.018600Z

Hi @suico.dave, i personally use this just recently (been through hard times as well to understand this around 3 wks of on & off struggle), and this is a complimentary guidance for SparkFund, to make it much more simple, no need to use Googlecreds.edn, just specify it using (def) like @dharrigan guidance (he helped me before too). https://github.com/aimanuel/Google-Oauth2-Clojure

2021-03-01T07:54:25.018900Z

@suico.dave you can personal chat me if it's still unclear πŸ˜‰

sb 2021-03-01T12:56:27.020800Z

Is there equivalent like clj-jwt lib in Clojurescript?

sb 2021-03-01T12:57:17.021500Z

exactly generate with jwt/sign with :RS256 , without nodejs libs (shadow-cljs)

sb 2021-03-01T13:05:45.021700Z

I saw this: https://github.com/google/closure-library/tree/master/closure/goog/crypt but I can’t find rs256

2021-03-01T14:58:02.023900Z

I implemented such a function for one of my projects - https://github.com/xapix-io/axel-f/blob/master/src/axel_f/buddy/jwt.cljc

2021-03-01T14:58:55.024100Z

@sb it is written as cljc so the code can be shared between cljs and clj and it is compatible with buddy

sb 2021-03-01T14:59:35.024300Z

@delaguardo thank you very much!!

sb 2021-03-01T14:59:39.024500Z

I check it!

2021-03-01T15:01:04.024900Z

https://github.com/xapix-io/axel-f/blob/master/test/axel_f/jwt_test.cljc there are some tests available, but they mainly for testing of my dsl. but you can get some understanding how arguments should look like πŸ™‚

2021-03-01T15:01:35.025200Z

and fill free to copy-paste or ping me in case of any questions

sb 2021-03-01T15:02:37.025400Z

Ok, thanks! I try out! πŸ™‚

2021-03-01T15:02:56.025600Z

argh, the sign function is actually missing in cljs

sb 2021-03-01T15:03:13.025800Z

ahh

2021-03-01T15:03:18.026Z

it is not yet published (

sb 2021-03-01T15:07:29.026200Z

Yes, this what I saw. Because I would like to create β€œAnother Clojure/script Google api lib..” and I stopped at this point.., because I need to use RS256 sign. I re-check the documentation too.. Maybe I will use nodejs at Clojurescript part to solve this.. but I don’t know that is the best idea...

sb 2021-03-01T15:08:33.026400Z

btw thank you very much! πŸ™‚

2021-03-01T19:24:37.028500Z

Good afternoon fellow beginners! I'm going to be livestreaming another Clojure coding challenge in about 10-15 minutes if you'd like to join me and check it out. Stream link is here: https://www.twitch.tv/a_fry_ This afternoon's challenge comes from the most recent Eric Normand newsletter challenge: implementing a filter indexed function. Link to the challenge here: https://purelyfunctional.tv/issues/purelyfunctional-tv-newsletter-416-why-do-we-program-in-hard-mode/ After the challenge, I'll be live-coding my startup product for this month. If you'd like to learn more about THAT (or the Startup in a Month project in general), inquiring minds will be kindly directed here: https://startupinamonth.net/pic-story-pitch/

2021-03-01T20:06:15.029100Z

A silly version of the challenge with zipmap

(defn filter-index-2 [f xs]
  (->> (zipmap (range (count xs)) xs)
       (sort-by key)
       (filter (fn [[k _]] (f k)))
       (vals)))
And with reduce:
(defn filter-index [f xs]
  (reduce (fn [acc i]
            (let [n (nth xs i)]
              (if (f i)
                (conj acc n)
                acc))) [] (range (count xs))))

1
dharrigan 2021-03-01T21:58:08.032500Z

Namespaces, I see, cannot start with a numeric, i.e., (ns 01-foo-bar) Is that a limitation of the JVM or a restriction on Clojure itself?

dpsutton 2021-03-01T21:59:41.032700Z

its not a valid symbol > Symbols begin with a non-numeric character and can contain alphanumeric characters and *, +, !, -, _, ', ?, <, > and = (other characters may be allowed eventually).

dpsutton 2021-03-01T22:01:19.034Z

so Clojure itself

dharrigan 2021-03-01T22:02:42.034300Z

Thank you.

dharrigan 2021-03-01T22:03:04.034600Z

I'll whack a char in front πŸ™‚

ghadi 2021-03-01T22:05:00.035Z

I believe java classfiles also cannot start with a number

phronmophobic 2021-03-01T22:10:05.035100Z

they also can't have !, dashes or asterisks, but those issues can be worked around with munging

2021-03-01T22:19:27.035600Z

this is only a restriction on symbols that the reader reads, you can create symbols with arbitrary names and create namespaces with those symbols as names as long as you don't care about mapping them to files or reading the names, or aot compilation, etc

2021-03-01T22:20:46.035800Z

~ % clj
Clojure 1.10.1
user=&gt; (in-ns (symbol "hello world"))
#object[clojure.lang.Namespace 0x7b02e036 "hello world"]
hello world=&gt; (refer 'clojure)
Syntax error compiling at (REPL:1:1).
Unable to resolve symbol: refer in this context
hello world=&gt; (clojure.core/refer-clojure)
nil
hello world=&gt; (+ 1 2)
3
hello world=&gt; (def x 1)
#'hello world/x
hello world=&gt; #'x
#'hello world/x
hello world=&gt; (.ns #'x)
#object[clojure.lang.Namespace 0x7b02e036 "hello world"]
hello world=&gt; *ns*
#object[clojure.lang.Namespace 0x7b02e036 "hello world"]
hello world=&gt;

borkdude 2021-03-01T22:34:40.036200Z

@dharrigan I totally recommend this:

(ns Ø123)

(defn hello [] 'Ø123)
(prn (hello))

πŸ˜‚ 1
borkdude 2021-03-01T22:35:13.036300Z

Not really, j/k ;)

robertfw 2021-03-01T22:36:46.036500Z

They do say that the hardest problem in programming is naming things, maybe we can give ourselves some new tools by using emoji

2021-03-01T22:52:02.036800Z

And here's what I built on the stream!

(defn filter-indexed [predicate collection]
  (reduce-kv
   (fn [res idx itm] (if (predicate idx itm) (conj res itm) res))
   []
   collection))