Fork me on GitHub
#off-topic
<
2022-09-08
>
Jan ariane16:09:54

How to print one line at a time from a text file on any active window top bar using Javascript?

Jan ariane16:09:58

is it possible in js/html?

p-himik16:09:49

> on any active window top bar What do you mean by that?

cvetan22:09:00

can someone recommend some webscrapper library but with accent on javascript rendered content?

cvetan22:09:23

I tried using enlive, but looks like isn't picking up js rendered content

john22:09:05

@cvetan.simsic a lot of folks just drive a headless browser with https://github.com/clj-commons/etaoin or something similar

cvetan23:09:52

I think I need something more distributable. I need to implement this as part of colledge project. And prerequesite of using this is installing driver for specific web browser.

cvetan23:09:15

I don't know how would I submit project, when this assumes driver installed on host os.

cvetan00:09:56

actually this might work. @U050PJ2EU thanks for suggestion

🍺 1
cvetan00:09:23

has really intuitive API, I think I might use this

Carsten Behring09:09:19

In my view the etaoin/ webdriver approach is the most useful. It uses a "real" browser (headless), so at least you know that it does teh same as a browser, specially regarding javascript.

Richie23:09:47

cljs

{(random-uuid) nil
 (random-uuid) nil}
;; Duplicate key: (random-uuid)
lol

dpsutton23:09:26

this is true in clojure as well. the reader enforces this in the reader literals.

{(random-uuid) nil
 (random-uuid) nil}
Syntax error reading source at (REPL:655:20).
Duplicate key: (random-uuid)

Richie23:09:44

It surprised me.

dpsutton23:09:33

understandable

Richie23:09:51

And then it made me laugh.

dpsutton23:09:10

it is a little surprising since there’s also a run-time check

(let [a :a b :a] {a 1 b 2})
Execution error (IllegalArgumentException) at metabase.prometheus-test/eval138632 (REPL:657).
Duplicate key: :a

Richie00:09:57

Interesting!

Noah Bogart00:09:48

You can't call the same function twice in a map literal? That’s wild

adi02:09:13

Oooh, I did not know this. Thanks for posting @UPD88PGNT, and for the explanation, @U11BV7MTK

phronmophobic05:09:19

It makes sense since read is a separate step from eval, especially when you consider macros. If you tried to read:

{(random-uuid) nil
 (random-uuid) nil}
What would expect to get? If you called a macro with with that value, what should happen?

👍 1
Drew Verlee00:09:28

i'm not sure, why is read concerned about duplicate keys? I thought the point of the separation is because we hadn't decided how to evaluate it yet.

Drew Verlee00:09:01

as in, nothing about those characters can't be parsed, so i'm not sure why its necessary to throw at that point. the macro might check the map and do something with the duplicates for instance.

Drew Verlee00:09:26

though i can't see why that would be useful, it would make more sense to pass a list then, which wouldn't have the issue in the first place.

phronmophobic00:09:57

> the macro might check the map and do something with the duplicates for instance. that's my point. maps can't have duplicate keys so you can't read that data structure without throwing away information, which would be wrong in this context.

;; make sense
> (read-string "{(random-uuid) nil}")
{(random-uuid) nil}

;; doesn't make sense
> (read-string "{(random-uuid) nil, (random-uuid) nil}")

☝️ 1
Drew Verlee01:09:43

I guess it's interesting because we're evaling/considering the structure even in "read". I'm used to thinking about lists where everything can pass through.

phronmophobic02:09:51

hopefully, it's not too pedantic, but there is no evaling happening during read. it's one of the key features and differentiators of lisp that it is defined in terms of data, rather than text. the data can be parsed from text (ie. read), but it can also be produced through normal usage (eg. (eval (list '+ 1 2)) ;; 3))

phronmophobic02:09:14

the problem with (read-string "{(random-uuid) nil, (random-uuid) nil}") is the same problem you would have if you tried to do JSON.parse('{"a":1, "a":2}') (although javascript doesn't complain and happily throws away data).

Drew Verlee02:09:25

no, it's not to pedantic. Or at least i should say, i have come to enjoy being pedantic, if that just means being clear in my communication 🙂 I like to think about what words commonly mean, when considering what they mean in context. In this case, I guess the terminology conundrum is best exemplified by asking someone to "read a sentence, but don't evaluate it" How can one absorb information without having some idea of it's worth? In this case the parser does do some initial determination of the structure (that it's a map) to understand how to parse it. I don't see how it could be otherwise. That's part of what makes lists so useful, is they don't impose much structure beyond order which is very natural to humans in the first place. Hense why :

{(random-uuid) nil
 (random-uuid) nil}
failing causes some confusion. Meanwhile, it's not clear how to break a list, except for maybe not closing it? Similarly, the read-string had to consider (somehow different then "eval") the structure (the list) and found that it, like the map, couldn't because it couldn't find when it ended. Though i guess a parser could just assuming an ending when it ran out of characters.
(read-string "(1 2")
But i think rarely would that example catch people off guard. No real point here except i'm just solidifying the idea in my mind.

phronmophobic03:09:16

You may find this exchange between rich and alan kay on Hacker News interesting, https://news.ycombinator.com/item?id=11941656

👀 1
phronmophobic03:09:05

> Data - something given, seems the raw material of pretty much everything else interesting, and interpreters are secondary, and perhaps essentially, varied. The exchange covers some of the topics you're expressing. I think the above quote gives a succinct case for lisp's separation of read and eval.

Drew Verlee03:09:49

I suppose i find myself understanding Alan better this time around. i would argue a list or a hashmap is an "ambassador" across systems.

Drew Verlee04:09:54

the real lesson is to not start a conversation with a "X is bad" statement unless that x=bad.

Drew Verlee04:09:17

and if you say "bad is bad" you have to follow it up with an old timer western spit.

2