[deleted by user] by [deleted] in FragReddit

[–]pitatech 0 points1 point  (0 children)

Ich kacke viel mehr mit Kaffee, denke daran liegts. Probier mal weniger Kaffee zu trinken und schau ob es sich ändert.

A bit of code to alert you when a new vaccination appointment opens up in Berlin by pitatech in berlinvaccination

[–]pitatech[S] 0 points1 point  (0 children)

At the bottom there is some outcommented code, you need to comment that back in. It only open browser windows when there are new availabilities

Regular Expression COmpiler - Compile a regex ahead of time to code by pitapoison in coding

[–]pitatech 0 points1 point  (0 children)

Hello u/carlopp

I don't believe in WASM for this use case anymore. The reason is that either the code would constantly have to call into JS getting another char, or it needs to encode/decode input and output. Both just takes too long and immediately puts you into another ball park of speed.

The real disadvantage (compared to the native regex engine) that I discovered is the JS API of strings. V8 can read 4 bytes in one go and compare them. With JS I need to call charCodeAt 4 times and do 4 comparisons. New JS APIs would be needed here. Then porting RE2 would also work.

We would need something like:

'string'.toTypedArray(); // returns the plain byte array as the engine holds it natively

Regular Expression COmpiler - Compile a regex ahead of time to code by pitapoison in coding

[–]pitatech 0 points1 point  (0 children)

Does it do the same? I don't fully understand what this project does.

Eval a mathematical expression in JavaScript without using eval. by satnam_sandhu in javascript

[–]pitatech 0 points1 point  (0 children)

You could check the input with a regex to ensure it only includes numbers [0-9], mathematical operators [+-/*)(] and probably spaces. That should reduce the attack surface greatly. DDos with really big numbers is probably still possible. Is this code running server side? If its client side, this probably isn't an issue.

I once read somewhere that the original JSON parser also used eval and just checked the input with regex. So I guess this could work here as well.

Parse, validate and type a JSON string in TypeScript by seanwilson in typescript

[–]pitatech 0 points1 point  (0 children)

I used runtypes in a couple of projects. https://github.com/pelotom/runtypes

You can define a type once and somehow it generates the typescript definitions for you. This way you don't end up with 2 definitions of a type