How to create a object using two single arrays?

I have two arrays. Those are

let x = [1,2,0,4,7,8,9,1,1,1];
let y = [10,50,80,70,906,80,70,80,15,11]

Important : x = y, That means 1 = 10, 2 = 50, 0 = 80 etc…

I want to find minimum and maximum value of x array and want to get y values related to that data, as well as 0 values (min value should greater than 0 value)

expected output is:

let res = { 
        min : {
                minVal : 1,
                minvalues : [10, 80, 15, 11]
       max :  {
                minVal : 9,
                minvalues : [70]
       empty :[80]

Here is what I tried. this way problem is I couldn’t get only value from filter method it gives object

const res =, index) => {
  return {[key]: y[index]};
}, {});

let info = {
  min : {},
  max : {},
  empty : {}

let min = Math.min.apply(this, x.filter(Number));
let max = Math.max(...x);
info.min['min'] = min
info.min['minVal'] = labelsAndHistoData.filter((el, idx) => el[min])`

How do I get the focussed element in shiny?

Is there a way to find out in shiny whether the focus is on a text-field (or maybe select field)?

My website has a lot of elements like plots, tables, numerical inputs and buttons.

Currently I have something like this:

ui <- fluidPage(
  tags$script('$(document).ready(function(){ $("*").focus( function(e){ Shiny.setInputValue("focusedElement",;}); }); '),
  textInput(inputId = "text1", label = 'Text1', value = ""),
  numericInput(inputId = 'num1',label = 'Num1', value=5),
  selectInput(inputId = 'select1', label='Select1',choices = c(1,2,3)),

server <- function(input, output, session) {
  output$output1 <- renderText({ 
    input$focusedElement })
  output$table<- DT::renderDataTable(iris)

shinyApp(ui, server)

Although I focussed every single input and the empty background, the only thing that works is Text-Input, Numerical-Input and Buttons. Why is that? (Take a look at the console output, select1 was definitely focussed at some point but never printed, also the search-bar and the plot and the background.)

Shiny app after having focussed every element

Please feel free to propose completely different approaches or correct my style.

What I want to know in the end is actually just whether I am in a text-field (like text1 or num1 or the search-bar of the table) or a button at the moment.

vitejs legacy plugin for IE11: Unhandled promise rejection ReferenceError: ‘Symbol’ is undefined

I am trying to configure my vitejs React app to run in IE11 and above. I have the following error viewing in MicroSoft Edge, in Internet Explorer Mode (IEChooser Dev Tools):

   [functions]: ,
   __proto__: { },
   description: "'Symbol' is undefined",
   message: "'Symbol' is undefined",
   name: "ReferenceError",
   number: -2146823279,
   stack: "ReferenceError: 'Symbol' is undefined
   at execute (http://localhost:4173/assets/index-legacy-e7ad95b1.js:1:3100)
   at n (http://localhost:4173/assets/polyfills-legacy-c1ceefe8.js:1:36689)
   at v (http://localhost:4173/assets/polyfills-legacy-c1ceefe8.js:1:36937)
   at Anonymous function (http://localhost:4173/assets/polyfills-legacy-c1ceefe8.js:1:36603)
   at ff (http://localhost:4173/assets/polyfills-legacy-c1ceefe8.js:1:26521)
   at Anonymous function (http://localhost:4173/assets/polyfills-legacy-c1ceefe8.js:1:26752)
   at $u (http://localhost:4173/assets/polyfills-legacy-c1ceefe8.js:1:24220)"

I created a fresh bare-bones app and still get the error:

npm create [email protected]
-- inputs: test-app, React, JavaScript

cd test-app
npm install
npm install --save-dev --save-exact @vitejs/plugin-legacy


import { defineConfig } from 'vite'
import legacy from '@vitejs/plugin-legacy';
import react from '@vitejs/plugin-react'

export default defineConfig({
  plugins: [react(),
      targets: ['ie >= 11'],
      additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
      polyfills: ['es.array.iterator']

npm run build && npm run preview

Open site in edge, turn on IE Mode. Blank screen.
Open “IEChooser” for dev tools by running command %systemroot%system32f12IEChooser.exe, and am given the error above in the console.

How do I fix this error?

How bad is this naive shuffle algorithm? [closed]

I came up with a very simple, naive algorithm to return shuffled array:

const shuffled = <Type,>(array: Type[]): Type[] => {
    const items =
        item => [ item, Math.random() ] as const

    return items
            ([ , a ], [ , b ]) => b - a
            ([ item, ]) => item

It just assigns a random number for each item and then sorts by these numbers. It seems to be 100% random, which is good. It also works without modifying the original array, which is what I want.

How much worse is the computational complexity comparing to more sophisticated shuffling algorithms?

Getting Client side exception on Next.js Multi Tenant application with one tenant but not the other

I have a Web app that im working on running MERN and Next.js. It is a multi tenant app. I have a demo. and a . urls. Everything works fine on both sites until i try and load a page from my drop down menu. On the demo. url everything works fine and allows me to run everything that the page does, but the . url once i click the button i get a black screen that says Application error: a client-side exception has occurred (see the browser console for more information). Every other button works in my drop down menu it is just that one that doesnt work. I have checked my developer tools and i get these errors:

TypeError: is not a function
     NextJS 63
overrideMethod moz-extension://91f638fd-2dc1-44e9-a5c2-7df5092a334f/build/react_devtools_backend.js:4012
NextJS 65
A client-side exception has occurred, see here for more info:      /client-side-exception-occurred

Also i seem to get 200 on all of my statuses in the network side of the developer tools.

I am new to working with this tech stack and i am a new developer on an existing app with no fellow developer support. I am just curious why it would work on the one url fine but then throw this exception at me on the other url. They are both on the same code-base so no difference in code that i could imagine. Any help or pointers or anything would be amazing! problem when deploying my Node.js application

currently I’m deploying a full stack Node.js application to It seems like Render is not connecting to MySQL database. In vsCode, everything works fine but after deploying my application, database is not working and users cannot register or login to system. (I’m using MySQL workbench, not Xampp by the way)

Error is

Error: connect ECONNREFUSED
Feb 7 06:52:58 PM      at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
Feb 7 06:52:58 PM    errno: -111,
Feb 7 06:52:58 PM    code: 'ECONNREFUSED',
Feb 7 06:52:58 PM    syscall: 'connect',
Feb 7 06:52:58 PM    address: '',
Feb 7 06:52:58 PM    port: 3306,
Feb 7 06:52:58 PM    fatal: true
Feb 7 06:52:58 PM  }

My application uses port 3307, MySQL uses port 3306, why am i getting this error ? What should i do handle this error? A user can register and login the system in localhost but cannot login after deploying Render. This is because the application works in locahost ? This is my first time deploying a project. Thanks for your help

Aggregating array of object per category for big dataset

I’m trying to prepare data for a graph, but my library expects each object to be on an aggregated level. At times it can be more than 1000 objects which needs to be processed into one aggregated level, so I’m trying to find a rather performant solution (performant in Javascript..). I want to aggregate and make one object on month level – but my data is on daily level.

What my array looks like now:

const data = [
    name: "1 Jan 2022",
    uv: 2000,
    pv: 400,
    name: "3 Jan 2022",
    uv: 1000,
    pv: 1500,
    name: "4 Jan 2022",
    uv: 1000,
    pv: 500,
..........x 100 similar entries...  

Target array:

const data = [
    name: "Jan 2022",
    uv: 4000,
    pv: 2400,
    name: "Feb 2022",
    uv: 3000,
    pv: 1398,
    name: "Mar 2022",
    uv: 2000,
    pv: 9800,


Any ideas on best practice?

Regular expression to find HTML text script tag’s content and src value

let htmlTEXT = `<h1>page 1</h1>
<input type="text" spellcheck="false" data-ms-editor="true">
<script src="/static/test.js">

// hopeful regex magic to produce the below
// -> /static/test.js
/* -> 
   console.log("goodbye"); */

I have a string which contains HTML, and I would like two regular expressions to get

  1. the script’s src value
  2. the script’s content

Fail to retrieve token via pre-request script in Postman

I would like to have a script running before each request in Postman, which renews the OAuth token, if it is expired (or is about to). So I found this blog on the topic and wanted to implement that.

However, the way I usually request tokens where I work, is by sending information via the body. In this picture, you can see how it looks in Postman.

Screenshot from Postman

This works just fine and retrieves a token for me, when I click send. Now I tried to use this information, to modify the script from the blog, so it now looks like this:

// Refresh the OAuth token if necessary
var tokenDate = new Date(2010,1,1);
var tokenTimestamp = pm.environment.get("OAuth_Timestamp");
  tokenDate = Date.parse(tokenTimestamp);
var expiresInTime = pm.environment.get("ExpiresInTime");
    expiresInTime = 300000; // Set default expiration time to 5 minutes
if((new Date() - tokenDate) >= expiresInTime) 
      url:  pm.variables.get("base_url_token"), 
      method: 'POST',
      header: {
        'Accept': 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded'
      body: {
        grant_type: 'password',
        username: pm.environment.get("username"),
        password: pm.environment.get("password"),
        client_id: pm.environment.get("client_id_practice_app"),
        client_secret: pm.environment.get("client_secret_practice_app")
  }, function (err, res) {
        pm.environment.set("OAuth_Token", res.json().access_token);
        pm.environment.set("OAuth_Timestamp", new Date());
        // Set the ExpiresInTime variable to the time given in the response if it exists
            expiresInTime = res.json().expires_in * 1000;
        pm.environment.set("ExpiresInTime", expiresInTime);

When I run any request, it shows in the console that the pre-request script has correctly sent the auth request. But I get the following error in the response body (from the auth):


I am almost certain that it is getting the correct Id and Secret. I have tried swapping the environment variables for hardcoded values. But I am less sure if I am setting the body correctly.

Can anyone tell me how to get this to work?

is there any idea to download a pdf from sublinks?

i have a website contains many links like this one:
when i click one of them it open a pdf document like this one
my question is How do i get all the documents without click every link ?

i tried to:
no susccess
2-i tried web grabber like httrack but not worked
i am using linux as my OS

maybe i can simulate a mouse click on every link and download the resulting pdf without open it on another tab but i have no javascript experience

Is there a way to remove partial postcodes from GoogleMaps autocomplete dropdown?

I’m not brilliant in Java and am quite new to the GoogleMaps API, I’m hoping this is simple.

I need to remove the partial postcode (in the red box) from the suggestions dropdown on autocomplete, so that users can only select a full postcode.

How do I achieve this or does anyone have a better suggestion?

Things to remove

I think everything works as it should but my client thinks to be able to select a partial postcode is too confusing.

YouTube Data API V3: Unable to get channel uploads

My function works for the first call only; meaning I only get 50 video IDs and then it throw a lot of errors (400 error). And then when I use the nextPageToken, it doesn’t work. I believe it’s because I’m calling the API inside a while loop!

Here’s my current code:

async function getPlaylistItemsById(id = DEFAULT_UPLOADS_ID) {
  try {
    const request = await{
      part: ["snippet, contentDetails"],
      maxResults: 50,
      playlistId: id,
    const response = await request.result;

    for (const item of response.items) {

    let nextPageToken = response?.nextPageToken;
    while (nextPageToken !== undefined) {
          part: ["snippet, contentDetails"],
          maxResults: 50,
          nextToken: nextPageToken,
        .then((response) => {
          for (const item of response.items) {
        .catch((error) => {
          console.log("Something went wrong with getPlaylistItems(): ", error);

  } catch (error) {

Docusaurus failed to build on Linux

Can be successfully built in Windows, but not in Linux.

I’m using docusaurus 2.3.1

Environment in Windows:
Windows 10
node v16.17.0
npm 9.3.0
yarn 1.22.19

Environment in Linux:
Centos 7.9.2009
node v16.18.0
npm 9.4.1
yarn 1.22.19

Code of the component with the problem:
This component is included here:

This is the output built in Windows:

yarn run v1.22.19
$ docusaurus build
[INFO] [zh-Hans] Creating an optimized production build...

✔ Client

✔ Server
  Compiled successfully in 33.45s

 ArtPlayer  4.6.2

✔ Client

● Server █████████████████████████ cache (99%) shutdown IdleFileCachePlugin

Overwriting existing registered function: lunr-multi-trimmer-en-zh
Overwriting existing registered function: lunr-multi-trimmer-en-zh
[SUCCESS] Generated static files in "build".
[INFO] Use `npm

This is the output built in Centos 7.9

yarn run v1.22.19
$ docusaurus build
[INFO] [zh-Hans] Creating an optimized production build...

✖ Client
  Compiled with some errors in 31.84s

● Server █████████████████████████ building (64%) 1/1 entries 2100/2100 dependencies 713/713 modules 
0 active 

Module not found: Error: Can't resolve '@site/src/components/ArtPlayer' in '/data/jenkins_home/workspace/Jerry-Docs/docs/Jerry-MC-Server/device_instruction'
[ERROR] Client bundle compiled with errors therefore further build is impossible.
error Command failed with exit code 1.
info Visit for documentation about this command.

How to set focus on svg element manually

I want to focus svg element manually.
My SVG code

<text class="target-txt" x="200" y="250" fill="blue" font-size="35" tabindex="0">Cute kitten and cat</text>

I tried HTMLElement focus() function., but it doesn’t work

const textSvg = document.querySelector(".target-txt");

Then i try to dispatch event,but again no success:

textSvg.dispatchEvent(new Event("focus"));

I have HTML element over this svg element, that’s why svg text doesn’t focus by user’s click.
How to focus svg element manually??