Why doesn’t my arrow function return a value?

I have an arrow function that looks like this (simplified): const f = arg => { arg.toUpperCase(); }; But when I call it, I get undefined: console.log(f(“testing”)); // undefined Why? Example: const f = arg => { arg.toUpperCase(); }; console.log(f(“testing”)); (Note: This is meant to be a clean, canonical dupetarget for the specific issue with … Read more

React stop function with useState

I have a button with which I start a test function: <button type=”button” onClick={startTestFrequencyList}>{ frequenciesTestRunning ? ‘Stop Test Frequency’ : ‘Start Test Frequency’ }</button> The startTestFrequencyList either starts the testFrequencyList or stops it. const [stopTest, setStopTest] = useState(false); const [frequenciesTestRunning, setFrequenciesTestRunning] = useState(false); const startTestFrequencyList = () => { if (frequenciesTestRunning) { window.alert(“Already testing”) setStopTest(true); … Read more

Pagination by compound key

I am trying to optimize my query which runs on Postgresql version 13 or 14. Let’s say we have table with corresponding index: CREATE TABLE journal ( account_id TEXT NOT NULL, event_at TEXT NOT NULL, id INTEGER PRIMARY KEY ); CREATE INDEX journal_account_id_event_at_id_idx ON journal (account_id, event_at, id); INSERT INTO journal VALUES (‘A’, ‘2023-01-01’, 1); … Read more

Why doesn’t TypeORM skip() and take() function work?

The Delivery table has got more than 4 million rows. I used MySQL database. async adminDeliveriesViewCount (data) { try { const batchSize = 10; let batchIndex = 0, totalDeliveries = 0; while(true) { let total = await Delivery.createQueryBuilder().skip(batchIndex * batchSize).take(batchSize) .getCount(); if(total == 0) break; totalDeliveries += total; ++ batchIndex; } return totalDeliveries; } catch … Read more

ExopPlayer can not play some m3u8 stream but MX Player / VLC can

I am using Exoplayer to play some m3u8 files. But some of the files are getting played and some can not be played. But the MX Player / VLC player played all the files successfully. This is how I am playing the stream :- player = new ExoPlayer.Builder(this).build(); playerView.setPlayer(player); playerView.setShowNextButton(false); playerView.setShowPreviousButton(false); playerView.setKeepScreenOn(true); MediaItem mediaItem = … Read more

Difference between a distributed lock manager and distributed database

In the Bigtable paper, Google explains page 4 : “Bigtable relies on a highly-available and persistent distributed lock service called Chubby”. They also say they developped it in-house, based on the Paxos algorithm. I find these precisions strange, because the entirety of Bigtable should be highly-available, persistent and distributed, not just the locks. But the … Read more

How should character arrays be used as strings?

I understand that strings in C are just character arrays. So I tried the following code, but it gives strange results, such as garbage output or program crashes: #include <stdio.h> int main (void) { char str [5] = “hello”; puts(str); } Why doesn’t this work? It compiles cleanly with gcc -std=c17 -pedantic-errors -Wall -Wextra. Note: … Read more