Fork me on GitHub
#clojurescript
<
2020-09-21
>
scythx10:09:16

Is there any Promise.all alternatives? let's says i have list of chan '(c1, c2, c3) and i want to wait all of them to be resolved before i do operation to the list

Aron11:09:16

is there any way to define regexes in clojurescript without using the string format?

p-himik11:09:50

You mean, you want to avoid using #"..." and (re-pattern "...")?

Aron11:09:06

I want to avoid having to use escape characters

Aron11:09:37

this is the javascript regex I want to use /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/

p-himik11:09:04

Right. I hope I'm wrong but I'm pretty sure that's impossible.

Aron11:09:21

Well, at least I know. The bigger problem is that I am unable to transcribe it to clojurescript it seems. Need to rebuild it from ground up :-<

Aron11:09:38

it's not as bad as it could be, I just don't want to cook up my own email regex

p-himik11:09:56

You probably should use a library for that. A JS one, likely. Emails are notoriously hard to get right.

p-himik11:09:01

Yep, that regex fails on e.g. Abc@[email protected].

p-himik11:09:56

"Note there is no perfect email regex" - yeah, that's what I don't like about all that. :)

Aron11:09:22

correct way would be "Abc@def"@example.com

Aron11:09:41

which passes this

p-himik11:09:50

Hmm, maybe. In this case, that article is wrong. TBH I didn't really delve into the RFC, but I remember distinctly battling with quite a few regexes to get some emails right.

Aron11:09:05

Same here, so I am not arguing, just presenting my own anchors to the topic 🙂

p-himik11:09:02

If I were to start parsing email addresses from the ground up, I would probably generate the parser straight from the grammar defined in the RFC. No regexes allowed. :)

Aron11:09:22

you know, RFC is request for comments, not a standard, it really doesn't solve the problem

Aron11:09:49

there are more than one, I believe, and not everyone adheres to it. The backend people - not me - have to decide what email formats they let in the database. But then, they use Django ORM with something pre-baked, that I couldn't find it was coming from postgres or anything, so this regex is my attempt to move them into action, since if they have to support something like this, that is probably worse than anything they come up with by themselves

p-himik11:09:34

> RFC is request for comments, not a standard That's a very good point. I keep glancing over what "RFC" stands for. > there are more than one, I believe Oh, I've never heard about alternatives. Do you have any links?

p-himik11:09:43

> they use Django ORM with something pre-baked Ah, I would then immediately assume that it does something absolutely wrong. When it comes to Django, such reasoning has never failed me.

Aron11:09:51

Well, we are just building several financial products with old django, so it's all fine

💥 3
p-himik12:09:22

As to why that RegEx above doesn't work with CLJS. To convert it to a properly escaped string: JSON.stringify(/.../.source). And then replace the [a-zA-Z\-0-9] part with [a-zA-Z0-9-]. Not sure why CLJS doesn't like - in the middle.

Aron12:09:21

Thanks, I will try it. Right now I am just trying to boot up my dev env. For half an hour now. The joys of development that apparently evades everyone but me.

p-himik12:09:10

Not really, but usually it doesn't happen once you set it up properly. O(1), so not many are vocal about it.

Aron12:09:06

But that's unreasonable.

Aron12:09:25

i have 3 or 4 machine setups every year. Every language + every editor it's own problem.

Aron12:09:33

it happens dozens of time yearly

p-himik12:09:49

"3 or 4 machine setups every year" doesn't sound like your regular Joe's workflow. Same for "every language + every editor" - except for a few corner cases, I always use the same combinations.

p-himik12:09:27

Out of interest - why do you have to do 3 or 4 machine setups every year?

Aron12:09:02

I don't "have to", it just happened that way.

Aron12:09:35

Like, this last one was because I needed a machine with a GPU.

p-himik12:09:19

Time to write some scripts I guess. :) Quite a few people do that to make any new setup as painless as possible. I don't do that - I change machines once every few years, so it's not a big deal for me.

Aron12:09:03

Right, because scripts will not add complexity but reduce it. I like how that goes. Tell me which scripting should I use. I want to to work for macos, win10 and linux only

Aron12:09:08

no arm64 yet

Aron12:09:59

I can't even use a single editor for all the languages I need to write.

p-himik12:09:43

Well, I'm afraid I'm out of suggestions for those kinds of Swiss knives. :) Except for some meta-measures, like simply avoiding doing work that requires a bazillion of setups. But those are obvious.

3
Aron16:09:37

and now we have backend validation for emails 😄

👍 3
Aron05:09:58

just to save some face for django, here is their regex https://docs.djangoproject.com/en/2.2/_modules/django/core/validators/

Erkan17:09:51

How do you provide environment specific configuration to a Clojurescript app?

Erkan17:09:11

exactly what I'm looking for! Not using shadow-cljs though, do you know anything similar for figwheel?

p-himik17:09:09

Nope, you'd have to search its documentation for that. I stopped using it years ago.