clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
scythx 2020-09-21T10:46:16.058200Z

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

Aron 2020-09-21T11:10:16.059100Z

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

p-himik 2020-09-21T11:12:50.059700Z

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

Aron 2020-09-21T11:13:06.059900Z

I want to avoid having to use escape characters

Aron 2020-09-21T11:13:37.060200Z

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-himik 2020-09-21T11:15:04.060400Z

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

Aron 2020-09-21T11:17:21.060600Z

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 :-<

Aron 2020-09-21T11:17:38.060800Z

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

p-himik 2020-09-21T11:18:56.061Z

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

p-himik 2020-09-21T11:24:01.061200Z

Yep, that regex fails on e.g. Abc@def@example.com.

p-himik 2020-09-21T11:24:32.061400Z

Some other examples are here: https://haacked.com/archive/2007/08/21/i-knew-how-to-validate-an-email-address-until-i.aspx/

Aron 2020-09-21T11:24:41.061700Z

http://emailregex.com/

p-himik 2020-09-21T11:25:56.062Z

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

Aron 2020-09-21T11:26:22.062200Z

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

Aron 2020-09-21T11:26:41.062400Z

which passes this

p-himik 2020-09-21T11:28:50.062600Z

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.

Aron 2020-09-21T11:31:05.062800Z

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

p-himik 2020-09-21T11:34:02.063Z

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. :)

Aron 2020-09-21T11:36:22.063200Z

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

Aron 2020-09-21T11:37:49.063400Z

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-himik 2020-09-21T11:41:34.063600Z

> 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-himik 2020-09-21T11:42:43.063800Z

> 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.

Aron 2020-09-21T11:44:47.064200Z

https://en.wikipedia.org/wiki/List_of_RFCs

Aron 2020-09-21T11:45:51.064600Z

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

💥 1
p-himik 2020-09-21T12:12:22.065100Z

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.

Aron 2020-09-21T12:13:21.065300Z

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-himik 2020-09-21T12:15:10.065500Z

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

Aron 2020-09-21T12:17:06.065700Z

But that's unreasonable.

Aron 2020-09-21T12:17:25.065900Z

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

Aron 2020-09-21T12:17:33.066100Z

it happens dozens of time yearly

p-himik 2020-09-21T12:18:49.066300Z

"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-himik 2020-09-21T12:19:27.066500Z

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

Aron 2020-09-21T12:20:02.066700Z

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

Aron 2020-09-21T12:20:35.066900Z

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

p-himik 2020-09-21T12:22:19.067100Z

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.

Aron 2020-09-21T12:23:03.067300Z

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

Aron 2020-09-21T12:23:08.067500Z

no arm64 yet

Aron 2020-09-21T12:23:10.067700Z

😄

Aron 2020-09-21T12:23:59.067900Z

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

p-himik 2020-09-21T12:31:43.068100Z

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.

1
Aron 2020-09-21T16:06:37.068600Z

and now we have backend validation for emails 😄

👍 1
alpox 2020-09-21T17:07:25.069600Z

@raefaldhiamartya I only know of p/all from promesa: https://github.com/funcool/promesa

Erkan 2020-09-21T17:21:51.070500Z

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

p-himik 2020-09-21T17:25:45.070600Z

If you're using shadow-cljs: https://shadow-cljs.github.io/docs/UsersGuide.html#shadow-env

Erkan 2020-09-21T17:33:11.070800Z

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

p-himik 2020-09-21T17:37:09.071Z

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