Fork me on GitHub
#off-topic
<
2021-08-10
>
Max01:08:13

With all of the system management discussion recently, I’ve noticed that some people tend to componentize just the most low-level “effects” (eg database connection pool, in-memory cache) while others make components for higher-level subsystems that themselves use lower-level effects. I haven’t seen a lot of discussion or recommendations online or from the tools themselves on this topic, so question for the room: how do you architect your components?

vemv08:08:46

it's components all the way down 🌀 nothing much to add myself, I've used Component to model modules in a modular app (Polylith style), or "repositories" as in data stores, etc. I guess there's no universal answer as there are many ways of an architecting an app.

jkrasnay11:08:04

I maintain a fairly large (~50kloc) web app/SPA in Clojure/Script. Initially I used Component but just for stateful things: web server, DB connection pool, and a handful of thread pools, but I recently decided that Component really wasn’t helpful for such a small number of components. Now I just have functions to start/stop the app by starting those components and passing the dependencies explicitly. For example, the thread pools usually need the DB connection pool, so I start the DB pool first, then pass it to each thread pool as I start it.

jkrasnay11:08:27

I created some Ring middleware to inject all the components into the request map so that web endpoint handlers can pull in whatever they need (typically just the DB pool).

Chase20:08:45

Silly question but why do folks often throw a $ in front of their terminal instructions? like $ curl ... prevents me from doing a quick copy/paste of the instruction line. I figure I'm missing something here

Chase20:08:19

I'm tempted to throw an alias in of alias $=' ' but I imagine that has some unforeseen consequences

p-himik20:08:14

$ signifies the prompt, mostly to distinguish user input from a program output.

✔️ 2
p-himik20:08:22

Compare e.g.

$ echo yes
yes
to
echo yes
yes
Run the latter to have the terminal keep agreeing with anything you say. :)

p-himik20:08:00

Also, $ often means "unprivileged user" and # means root.

dpsutton20:08:04

hadn't realized that convention. neat. thanks

Chase20:08:04

Ooh, now that is a good reason there. I can get behind that

Ben Sless20:08:19

At least when the prompt is # you can always safely copy-paste the prompt, but there's historical circumstance to consider. in csh it's %

seancorfield20:08:31

I've had several folks request that I remove the $ from documentation and just separate commands from output more clearly. I believe there is also a CSS trick you can do to display $ on the web but make it not part of the string you actually copy'n'paste.

seancorfield20:08:12

Similarly, I've had folks request that long lines not be broken up with \ because that only works on macOS/Linux and produces "bizarre" behavior/errors on Windows.

p-himik20:08:12

> I believe there is also a CSS trick you can do to display `$ ` on the web but make it not part of the string you actually copy'n'paste. The ::before pseudo-element can do that: https://developer.mozilla.org/en-US/docs/Web/CSS/::before

.terminal-command-input-line::before {
  content: "$ ";
}

2
noisesmith20:08:39

I don't think making it easy to do quick copy paste from a document into a terminal is actually a good thing. you should be putting more effort into reading the thing you are copying than it takes to avoid grabbing the $

seancorfield20:08:28

Sure. You can tell that to beginners all you like but it won't stop them doing it 🙂

👍 3
noisesmith21:08:23

I'm just suggesting it's a "good friction"

👏 2
walterl21:08:58

Yes! What @U051SS2EU said. Copy and pasting into a terminal is a bad habit, similar to curl ... | sudo bash.

walterl21:08:59

> ... just separate commands from output more clearly. This is a lot harder when you're documenting a back-and-forth command/response "conversation".

lilactown20:08:44

2 reasons I can think of: the first and major reason is to tell the user what command is being run vs. output the second is much lesser and a bit more patronizing but I've heard people say that generally we should not be copying + pasting random snippets into our shell :<

Chase20:08:18

I get that to a sense. I try to do that when following a coding tutorial or what not. But something like this $ curl -LO https://github.com/BurntSushi/ripgrep/releases/download/12.1.1/ripgrep_12.1.1_amd64.deb`` and it even has a literal copy to the clipboard button next to it. I don't like it! haha

dpsutton20:08:56

i think github has made the copy not include the $ prompt right?

Chase20:08:23

I still get the prompt from github. Nbd of course, I was just curious of the historical reasons

dharrigan21:08:41

I think, the reason is to differentiate between a normal user, i.e., "$" and a root user "#". Of course, nowadays, the actual prompt is rewritten/redisplayed by some useful plugins, like powerline etc.., but on a naked shell, it really helps.

dharrigan21:08:35

(and, # is also treated as a comment character, so if you're copying commands with abandon, it can really save your bacon, i.e, # rm -rf / 🙂 )

dharrigan21:08:50

It's detailed on the POSIX guidelines too:

dharrigan21:08:58

PS1
    This variable is used for interactive prompts. Historically, the "superuser" has had a prompt of '#'. Since privileges are not required to be monolithic, it is difficult to define which privileges should cause the alternate prompt. However, a sufficiently powerful user should be reminded of that power by having an alternate prompt.

Antonio Bibiano15:08:08

It works well in zsh, I decided to try it and in bash I went for :; to get the same functionality

Antonio Bibiano15:08:01

I discovered that : works like a no-op in bash

hiredman21:08:04

I've seen clojure repls that print a prompt like #_=> for similar reasons

4
hiredman21:08:31

maybe cider does that for multiline input?

didibus22:08:16

Anyone tried https://jreleaser.org/ with Clojure? Seems like it could still be useful, auto-announce, auto-git-tag, auto-update homebrew, etc.