Fork me on GitHub
#beginners
<
2018-11-30
>
adam00:11:27

(ns myns
  (:require [clojure.java.shell :only [sh]]))

(sh "ls" "-aul")
CompilerException java.lang.RuntimeException: Unable to resolve symbol: sh in this context Any idea why?

adam00:11:47

Changing :only to :refer does work but I don't see why :only is not working as described in the docs.

bronsa00:11:15

:only works with :use, not :require

adam00:11:54

@bronsa aha got it, thanks

peter-kehl01:11:31

Thank you @alexmiller and @joseph.guhlin.

Ali Ebadian08:11:53

This is great talk, I thought. so I thought some here would find as useful as I did

JanisOlex09:11:11

hello, good people. Is there some good online resource of "clojure cookbooking", like code snippers, examples of everyday tasks performed by idiomatic clojure... Coz one is to know clojure syntax, another thing is to learn actual libraries, and third - know how to bind them togeather... like classical REST api client/server impls, drawing something on screen, making network calls, making data transformations, sound, video and zillion of other nice cool things people do every day

jaihindhreddy11:11:06

As far as libraries are concerned, is a good one.

JanisOlex09:11:38

I am asking, coz myself not so long ago learned kotlin, and then soon become "expert" (local) on that, and I noticed, that new people try to write kotlin but using their own language idioms (usually Java), and from my point of view, their code look dirty and silly, which means - most likely my beginner clojure looks as silly

cklaou09:11:27

@olekss.janis Sounds that you're looking for sth like clojure cookbook: https://github.com/clojure-cookbook/clojure-cookbook

JanisOlex09:11:49

ahh really, and it's free 🙂 Niice downloaded THanks

SoV415:11:53

Let's say I have a thread that starts with one post, and can take comments

SoV415:11:04

I'd like to: store all the comments &

SoV415:11:43

recursively render the parent->(comment->8<-comment)s

SoV415:11:48

in hiccup

SoV415:11:03

so I'm thinking for each comment level I can just create a new [:li ""] element...

SoV415:11:18

I want to store my data not like a comment tree, but by reference. :post_id Xxxx, :parent_id Yyyy, :child_id Zzzz so there's flexibility in how I choose to render them

SoV415:11:35

so my real question...

SoV415:11:54

if I have an atom that looks like (atom { :posts [{:pid 555 :cid 777 :this_id 657} {:p 9 :c 8 :tid 7} {:p 12 :c 16 :d 82} {post 4 ...} { post 5} ...]} how can I functionally render the page component that holds a parent and all its child components?

SoV415:11:25

>
>>
>>>                                        (demonstration of nested comments,
>>>                                         or happy-lil portrait-orientation trees)
>
>>
>>>
>
>>

potetm15:11:56

Anyone who’s interested in learning some clojure is welcome to join my stream of Advent of Code! It will be M-F @ 12:00 CST. I’ll be starting a day early with https://adventofcode.com/2017/day/5.

SoV416:11:22

works great! but how do i print out more intricately nested maps with multiple attributes and collections of children?

SoV417:11:14

Now I want to recursively print something like this... well, make a list for html land..

SoV417:11:55

how to shot web?

Eccentric J17:11:00

(defn webhook-api
  [{:keys [path-params]}]
  (if-let [id (str->int (get path-params :id))]
    (if-let [webhook (db/get-webhook {:id (Integer. id)})]
      {:body webhook}
      (error-page))
    (error-page)))

Eccentric J17:11:06

Is there a better way to write that?

dpsutton17:11:47

you could make a single function that takes path-params and returns either {:id ...} or nil and have only one if-let

Eccentric J17:11:20

Oooh that’s a great idea. Then I can reuse it in the other routes that require an id.

dpsutton17:11:42

and in combination with some-> you can only look for the webhook if you have the id, etc