Fork me on GitHub
#beginners
<
2021-09-04
>
John Bradens02:09:31

What is the difference between running shadow-cljs vs npx shadow-cljs? What does the npx do?

vncz02:09:17

npx download the software on the fly from npm in case it’s necessary @bradj4333

John Bradens02:09:26

Ok thanks! So if I do npm install, then I don't have to use npx, but if I add more dependencies, then I would use npx?

vncz02:09:20

If you do npm install it usually installs all the dependencies in the package.json and you should be good to go

vncz02:09:41

npx will also look into the binary directory of node_modules, otherwise you’d either need to pretend the path or install the package globally

John Bradens02:09:28

Ok cool thank you

vncz02:09:17

npx download the software on the fly from npm in case it’s necessary @bradj4333

simonacca13:09:18

Hi Clojurians! I often find myself at odds with Clojure comments (`; this kind of comments`) for several reasons: • they are not formatted automatically by cljfmt (the problem here is mostly that indentation is often broken) • they are awkward to select/move with paredit clojure.core/comment solves the first issue, but not the second (i.e. the comment would still be just a sibling of the expression it refers to) So I've resorted to my own macro:

(defmacro ic
  "Inline comment.
   Ignores first argument.
   for example: (ic \"sum 1 and 2\" (+ 1 2))
   expands to (+ 1 2)"
  [comment expr]
  expr)
Usage example:
(defn component-xyz
  [prop1 prop2]

  [:div {:class "myclass1"}

   ; a typical comment
   [:span "sub-component-1"]

   (ic "an inline comment"
       [:span "sub-component-2"])

   
   [:span "sub-component-3"]]
)
It seems like such a common problem that I'm left wondering: • Is there already something like this out there that I've missed? • Is this a bad idea for some reason that I haven't considered? Thanks!

hiredman14:09:53

Maybe checkout #_

hiredman14:09:07

It causes the reader to read the following form (so it must be well formed) then discard it

practicalli-john14:09:54

The defacto line Clojure comment is ;; (two semi-colons). This is formatted correctly by all Clojure tools and editors I believe

simonacca14:09:07

Thanks, didn't know about ;;

practicalli-john14:09:15

I think Cursive defaults to the singe quote, which is interpreted differently by many Clojure tools The single ; is typically used for end of line comment ;; for the whole line

✔️ 6
noisesmith16:09:32

the old school convention from LISP was ; - at the end of the line of code ;; - on its own line, indented the same as any sibling forms ;;; - a "section heading", always indented to column 0

practicalli-john14:09:48

I use a rich comment block (comment ) at the end of my code to show examples of calling key functions #_ I use throughout the code, within threading macros, etc. It can also be doubled, tripped up and be on previous lines

👍 2
Benjamin15:09:44

what is the closest to emacs buffers in clojure? Some convinient way to do something like skip-chars-forward , forward-line and such with a clojure string (from a file) would be nice for my problem right now

Benjamin06:09:51

that is cool

fullNameHere19:09:23

Hey guys a while ago I made minesweeper in reactJs and Id like to recreate it in clojure. I had these two functions which made it easy to change the screen of the cell/handle onclicks. I was wondering which templating library (hiccup/selmer/enlive/ or any other im might not be aware of) would make it the easiest to replicate something like this, and how? createNestedArray = (x, y) => { //x is how many arrays // y is how many objects in x array //ex x = 3, y = 2 //[ //[{}, {}], //[{}, {}], //[{}, {}] //] let nestedArray = []; for (let i = 0; i < x; i++) { nestedArray.push([]); for (let j = 0; j < y; j++) { //information of individual cell nestedArray[i][j] = { screen: "?", id: ${i}-${j} }; } } this.setState({ //keeps track of board and some bomb info board: nestedArray }) } //for every item in array creates cell //[[],creates row from array //[{randomObj}], creates cell from randomObj //[{}, {}, {}] row with 3 cells tablerows = (nestedArray) => { if (!this.state.board) { return; }//if a board already exist return return nestedArray.map((rows, x) => { let row = rows.map((cell, y) => <td id={`${x}-${y}`} onClick={(e) => { this.cellClick(e); }} onContextMenu={(e) => this.handleRightClick(e)}> {this.state.board[x][y].screen} </td>); return ( <tr> {row} </tr> ); }); }

drewverlee20:09:04

Maybe try helix, it cookies complies to react hooks.

fullNameHere20:09:28

Im open to the idea of using cljs, but I havent found a good/easy setup yet. Id like to stick to clojure for a little longer.