JavaScript

Topic: Anything JavaScript, ECMAScript including Node, React, ...
May 24, 2023 13:16
@OlegValteriswithUkraine In all honesty: Most of the time it seems to me and others that I know what I'm doing, in some cases where I'm unsure I ask others and in rare cases I'll take the 'fake it till you make it' approach, learning along the way.. ;)
May 24, 2023 11:57
@OlegValteriswithUkraine Thanks for your suggestions - On a different note: When we have to deal with near-real-time/time-sensitive requirements we normally write micro-services in Erlang/OTP and use some interface-funcs that share the data/results instead of using pure node - works quite well and also allows hot-swapping in case of code-updates where our apps are already in prod..
May 24, 2023 11:35
@OlegValteriswithUkraine VLAZ's point to keep logic and storage seperate convinced me. For now I'm declaring a global date-obj which is updated on each insert, using an additional comparision-func that returns true or false. Next approach is via a cron job where a global var stores the latest probe-values and the cron interval will call the insert proceedure which uses the leatest value strored in the g-var. I'll propose both solutions to my team and let them decide which goes into prod.. ;)
May 24, 2023 10:48
@VLAZ Valid point with seperating storage from logic!
May 24, 2023 10:27
@OlegValteriswithUkraine I thought of maybe using some pg trigger funcs on insert as well to achieve that behavior on the db-level instead of node- unfortunately I'm not too firm on trigger funcs and internal proceedures in pg..
May 24, 2023 10:25
@OlegValteriswithUkraine Postgres 15 on a stripped/bare debian jessie
May 24, 2023 09:38
@OlegValteriswithUkraine No - ain't that critical - it's more about db-size and hence running out of diskspace on my embedded SBC (I think i will implement a watchdog as well checking available and total diskspace periodically and send out a msg via node-mailer in case a certain treshold is reached). But thanks for the idea with cron-jobs - I might implement it via cron or node-schedule anyway..
May 24, 2023 09:27
@OlegValteriswithUkraine Thanx for your thoughts - how about using a global var and assigning a datetime-obj to it and check on each emitted event via Date.now() comparison if 10 mins have passed (maybe via dayjs) since the last written values (where the global var has been updated to that date-time when the val was last written)?
May 24, 2023 09:02
I also thought about implementing a counter but on the other hand I can't rely on the 30 second interval that those events are emitted..
Any ideas beyond settimeout / setinterval that are more native to emitter.on.. ?
May 24, 2023 09:02
I'm looking for some ideas for following scenario: I have events emitted every 30 secs (some probe values). In my Emitter.on... I'm writing those values in a db. Now I only want to write the emitted values every 10 mins and disregard any of the values before/between. I was thinking about interval or settimeout to get this accomplished but this looks a little dirty to me.
Nov 30, 2022 16:13
thanks for the insights ;)
Nov 30, 2022 16:12
@KevinB Nope, for now there's just a simple console.log to see if the function even gets invoked..
Nov 30, 2022 16:09
I'm currently struggling with two methods (one works the other one doesn't) to attach an event to an input field within shadow-root. Any explaination is highly appreciated - here's the snippet, function is declared in head via script tag:

// Menu for table with search field within shadow-root
let menu = document.createElement("div");

// Vers. 1 via innerHTML -------------------------> WORKS - FUNCTION GETS INVOKED
menu.innerHTML =
`<span style="margin-left:4px; margin-right:4px;">Suche: </span>
Sep 1, 2022 15:44
The solution I came up with looks a bit bulky/ugly, any idea if it could be simplified?

SELECT * FROM test WHERE id = (
SELECT max(id) FROM (
SELECT * FROM (
SELECT elems.value ->> 'value' AS tmp, id
FROM test,
json_array_elements(data) elems
WHERE elems.value ->> 'name' = 'product-volume' ) AS derivedTable1
WHERE tmp IS NOT NULL )
as derivedTable2 );
Sep 1, 2022 13:55
Never mind, found the solution here: postgresql.org/docs/current/functions-json.html
Sep 1, 2022 13:40
How to adapt following SQL Select statement (taking latest entry) to cover the case when a row is missing a prop in the json column to take the latest one that has that prop? The table has three columns (id, json, timestamp) and the json is an array of objects ([{name:'foo', value:23}, {'name':'bar', value:100}]). Currently I have: `SELECT * FROM someTable
WHERE id = (SELECT max(id) FROM someTable )`
Sep 1, 2022 13:28
@SuperUberDuper see here -> stackoverflow.com/questions/31354559/…
Feb 10, 2022 17:21
@SPArcheon If you supply all the details of your setup (versions,etc), link your question on SO and it's somehow reproducable one might hope that it will attract some attention of the devs there. And if it's something obvious (which I doubt) maybe they can point you to the right direction..
Feb 10, 2022 16:36
@SPArcheon You could also give a feedback/report your issue at VS's dev-community page: developercommunity2.visualstudio.com/…
Feb 10, 2022 16:34
@EdGzi For android you could use Google Play Console, Ubertesters, TestFairy, Appaloosa etc..
Feb 10, 2022 15:13
@SPArcheon I searched some question on SO about it - you don't seem to be the only person having that issue -> Google 'VS 2022 intellisense typescript optional chaining'
Feb 10, 2022 15:07
@SPArcheon From what I read for the compilation of TypeScript, VS 2022 gives you the flexibility to choose which version of TypeScript to use on a per-project basis. Projects configured for npm can specify their own version of the TypeScript language service by adding the TypeScript npm package. You can specify the version using the npm manager in supported projects. Note: The minimum supported version of this package is 2.1.

The TypeScript SDK has been deprecated in Visual Studio 2022. Existing projects that rely on the SDK should be upgraded to using the NuGet package. For projects that
Feb 10, 2022 14:12
Looking for some binary compiler alternative to pkg since we want to use imports instead of requires, should target win, osX and linux - any ideas besides nexe?
Jan 26, 2022 17:38
@Alex Thanks for the suggestion - looks like what I was looking for ;)
Jan 26, 2022 14:43
Anyone got a recommendation for a tree-library similar to jstree.com/demo or filer.vregistry.com/jsfiler but just without jquery? Should have drag and drop of nodes and leaves, create, remove, etc..
Aug 26, 2021 15:17
Anyone here that knows a js-library for smtp2mqtt? I found one on github but that's written in Go..
Mar 19, 2021 14:16
@paul23 or here openbase.com/js/udp-request/…; for a list of other alternatives
Mar 19, 2021 14:14
@paul23 try npmjs.com/package/dgram-as-promised as a promisified alternative
Mar 19, 2021 14:13
@paul23 "it's not working" -> like our govs? ;)
Mar 19, 2021 14:12
@LoopingDev yeah, what a gain
Mar 19, 2021 14:12
Mar 19, 2021 14:08
wouldnt recommend it thou
Mar 19, 2021 14:08
@VLAZ You can replace jquery with vanilla for bs -> One example here with BS5 freecodecamp.org/news/bootstrap-5-vanilla-js-tutorial
 

SO Close Vote Reviewers

This room is for support and discussion about reviewing and co...
Dec 28, 2021 14:35
Does the poor answer to stackoverflow.com/questions/70507956/… qualify to be flagged as very low quality?
 
Sep 2, 2021 15:41
I mean Yousufs
Sep 2, 2021 15:40
look at yousefs answer
Sep 2, 2021 15:40
;)
Sep 2, 2021 15:40
You already have an answer
Sep 2, 2021 15:39
where's the problem with switchMap then?
Sep 2, 2021 15:38
Yes
Sep 2, 2021 15:34
this question was asked by techguy, can you clarify
Sep 2, 2021 15:33
I'll have a look..
Sep 2, 2021 15:31
What's your problem?
Sep 2, 2021 15:30
@Manisha Yes ;)
 

SQL

Got a SQL question? Any SQL flavor here, just ask. Indicate yo...
Apr 13, 2021 14:31
thx got it - bs ;)
Apr 13, 2021 14:17
INSERT INTO... pwd VALUES ('$foobar$eatsbarfood') for example
Apr 13, 2021 14:15
I'm running a bash script to setup a db, schema and tables as well as insertin a standard admin user with a hashed pwd that includes $-sign - how do i escape it?
Apr 13, 2021 14:01
@AndyK Are you around?