hi there i need if include in my code right or no

#define _stackSize (6748/4) 
#include <Arduino.h>
#include <EEPROM.h>
#ifdef ESP32
#include <WiFi.h>
#else
#include <ESP8266WiFi.h>
#endif
#include <WiFiClientSecure.h>
#include <UniversalTelegramBot.h>
#include <ArduinoJson.h>
#include <SoftwareSerial.h>
 SoftwareSerial Serial2(0, 2); 

my problem in arduino cloude but in arduino ide no error code bulding ok and circuit work normly
the proplem in arduino cloude her
/usr/local/bin/arduino-cli compile –fqbn esp8266:esp8266:nodemcu:baud=115200,dbg=Disabled,eesz=4M,exception=disabled,ip=lm2f,lvl=None____,vt=flash,wipe=none,xtal=80 –build-cache-path /tmp –output-dir /tmp/3426530251/build –build-path /tmp/arduino-build-D609A4CAF9BB322E283BB8346F7F5867 –library /home/builder/opt/libraries/universaltelegrambot_1_1_0 /tmp/3426530251/sketch_nov1a

/tmp/3426530251/sketch_nov1a/sketch_nov1a.ino:68:15: error: ‘TELEGRAM_CERTIFICATE_ROOT’ was not declared in this scope

X509List cert(TELEGRAM_CERTIFICATE_ROOT);

^

/tmp/3426530251/sketch_nov1a/sketch_nov1a.ino: In function ‘void setup()’:

/tmp/3426530251/sketch_nov1a/sketch_nov1a.ino:183:7: error: use of deleted function ‘UniversalTelegramBot& UniversalTelegramBot::operator=(UniversalTelegramBot&&)’

bot = UniversalTelegramBot(BOTtokenChar, client);

^

In file included from /tmp/3426530251/sketch_nov1a/sketch_nov1a.ino:9:0:

/home/builder/opt/libraries/universaltelegrambot_1_1_0/src/UniversalTelegramBot.h:49:7: note: ‘UniversalTelegramBot& UniversalTelegramBot::operator=(UniversalTelegramBot&&)’ is implicitly deleted because the default definition would be ill-formed:

class UniversalTelegramBot {

^

/home/builder/opt/libraries/universaltelegrambot_1_1_0/src/UniversalTelegramBot.h:49:7: error: non-static const member ‘const int UniversalTelegramBot::maxMessageLength’, can’t use default assignment operator

/tmp/3426530251/sketch_nov1a/sketch_nov1a.ino: In function ‘void loop()’:

/tmp/3426530251/sketch_nov1a/sketch_nov1a.ino:242:12: error: ‘result’ was not declared in this scope

result();

^

In file included from /home/builder/Arduino/libraries/arduinojson_6_21_4/src/ArduinoJson/Numbers/FloatTraits.hpp:13:0,

from /home/builder/Arduino/libraries/arduinojson_6_21_4/src/ArduinoJson/Numbers/convertNumber.hpp:15,

from /home/builder/Arduino/libraries/arduinojson_6_21_4/src/ArduinoJson/Variant/VariantData.hpp:9,

from /home/builder/Arduino/libraries/arduinojson_6_21_4/src/ArduinoJson/Variant/VariantFunctions.hpp:9,

from /home/builder/Arduino/libraries/arduinojson_6_21_4/src/ArduinoJson/Variant/JsonVariantConst.hpp:15,

from /home/builder/Arduino/libraries/arduinojson_6_21_4/src/ArduinoJson/Variant/VariantRefBase.hpp:9,

from /home/builder/Arduino/libraries/arduinojson_6_21_4/src/ArduinoJson/Array/ElementProxy.hpp:7,

from /home/builder/Arduino/libraries/arduinojson_6_21_4/src/ArduinoJson/Array/JsonArray.hpp:7,

from /home/builder/Arduino/libraries/arduinojson_6_21_4/src/ArduinoJson.hpp:29,

from /home/builder/Arduino/libraries/arduinojson_6_21_4/src/ArduinoJson.h:9,

from /home/builder/opt/libraries/universaltelegrambot_1_1_0/src/UniversalTelegramBot.h:26,

from /tmp/3426530251/sketch_nov1a/sketch_nov1a.ino:9:

/home/builder/Arduino/libraries/arduinojson_6_21_4/src/ArduinoJson/Polyfills/pgmspace_generic.hpp: In instantiation of ‘const T* ArduinoJson::V6214PB2::detail::pgm_read(const T* const*) [with T = char]’:

/home/builder/Arduino/libraries/arduinojson_6_21_4/src/ArduinoJson/Deserialization/DeserializationError.hpp:85:42: required from here

/home/builder/Arduino/libraries/arduinojson_6_21_4/src/ArduinoJson/Polyfills/pgmspace_generic.hpp:25:52: error: ‘const void*’ is not a pointer-to-object type

return reinterpret_cast<const T*>(pgm_read_ptr(p));

^

Multiple libraries were found for “EEPROM.h”

Used: /home/builder/.arduino15/packages/esp8266/hardware/esp8266/2.5.0/libraries/EEPROM

Not used: /home/builder/opt/libraries/atmac_eeprom_1_0_0

Not used: /home/builder/opt/libraries/arduino_nvm_0_9_1

Not used: /home/builder/opt/libraries/hello_drum_0_7_7

Multiple libraries were found for “UniversalTelegramBot.h”

Used: /home/builder/opt/libraries/universaltelegrambot_1_1_0

Not used: /home/builder/opt/libraries/universaltelegrambot_1_3_0

Multiple libraries were found for “ArduinoJson.h”

Used: /home/builder/opt/libraries/arduinojson_6_21_4

Not used: /home/builder/opt/libraries/antares_esp8266_mqtt_0_9_2

Not used: /home/builder/opt/libraries/balemessengerbot_arduino_0_1_0

Not used: /home/builder/opt/libraries/allthingstalk_lte_m_sdk_2_0_4

Not used: /home/builder/opt/libraries/cmmc_mqtt_connector_1_3_3

Not used: /home/builder/opt/libraries/coogleiot_1_3_1

Not used: /home/builder/opt/libraries/iotkme_3_0_1

Not used: /home/builder/opt/libraries/thingesp_1_3_0

Not used: /home/builder/opt/libraries/antares_esp8266_http_1_3_3

Not used: /home/builder/opt/libraries/thingsiot_1_2_0

Multiple libraries were found for “SoftwareSerial.h”

Used: /home/builder/.arduino15/packages/esp8266/hardware/esp8266/2.5.0/libraries/SoftwareSerial

Not used: /home/builder/opt/libraries/mcci_sofwareserial_3_0_0

Not used: /home/builder/opt/libraries/printoo_library_1_0_2

Not used: /home/builder/opt/libraries/vega_softwareserial_1_0_0

Not used: /home/builder/opt/libraries/dabble_1_5_2

Not used: /home/builder/opt/libraries/espsoftwareserial_8_1_0

Error during build: exit status 1

try delete liabrary same proplem

Console clears after making changes in is file

I started learning Java script very recently and I’m very knew to it. I was trying to learn how to use console but every time I make changes in my js. file in visual studio code, console clears and browser forces the website to reload infinitely until i basically cancel the reload. After closing console window and opening it again only then I see the changes I made in my is. file.
I will highly appreciate your help!

I tried enabling preserve log checkbox in console settings but it didn’t change anything.

JQuery Capitalize First Letter Of Each Word In A Sentence [duplicate]

I’m trying to capitalize first letter of each word from a text field using JQuery but unfortunately I’m unable to.

Below is the Bootstrap code I currently have to get data from a text field from a submitted button

<button class="btn btn-primary" type="button" id="btn4" value="alternatingCase">Alternating Case</button>

Below JQuery code converts only the first letter of the paragraph to caps

$("#btn4").click(function(){
  var input = $("#input1");
  input.val(input.val().charAt(0).toUpperCase() + input.val().substr(1).toLowerCase());
  });

JavaScript error: dataDetailSkill[item].data.map is not a function

export default function DetailSkill() {
const { item } = useParams();
return (
    <div className="w-screen min-h-screen flex flex-col p-[30px] bg-slate-100  overflow-hidden">
        <Header title={item} />
        <div className="mt-12 flex flex-col gap-4">
            <img src={dataDetailSkill[item].bannerImg} alt="" className="w-full h-[200px] object-cover rounded-lg" />
            <p>{dataDetailSkill[item].description}</p>
            <div className="flex flex-col gap-4">
                {dataDetailSkill[item].data.map((v) => {
                    return <SkillCard title={item} content={v.title} img={v.img} link={v.github} key={v.id} />;
                })}
            </div>
        </div>
        <ModalMenu />
    </div>
);

}

what’s wrong with the code. chrome says dataDetailSkill[item].data.map is not a function. I use Vite React. sorry newbie

dataDetailSkill.js
I want to do mapping on the dataDetailSkill.js file but there is an error

export default {
    html: {
        description: "Membuat website sederhana",
        bannerImg: "https://images.pexels.com/photos/4439901/pexels-photo-4439901.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1",
        data: {
            id: 1,
            title: "Membuat website landing page",
            github: "",
            img: "https://images.pexels.com/photos/114907/pexels-photo-114907.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1",
        },
    },
    frontend: {
        description: "Membuat website dengan React JS",
        bannerImg: "https://images.pexels.com/photos/4439901/pexels-photo-4439901.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1",
        data: {
            id: 1,
            title: "Membuat website film",
            github: "",
            img: "https://images.pexels.com/photos/114907/pexels-photo-114907.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1",
        },
    },
    it: {
        description: "Sertifikat Kepelatihan saya dalam IT",
        bannerImg: "https://images.pexels.com/photos/4439901/pexels-photo-4439901.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1",
        data: {
            id: 1,
            title: "IT Support",
            github: "",
            img: "https://images.pexels.com/photos/196644/pexels-photo-196644.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1",
        },
    },
    web: {
        description: "Project membuat web design",
        bannerImg: "https://images.pexels.com/photos/4439901/pexels-photo-4439901.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1",
        data: {
            id: 1,
            title: "Project saya",
            github: "",
            img: "https://images.pexels.com/photos/196644/pexels-photo-196644.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1",
        },
    },
};

I’ve followed the tutorial on YouTube but the error still persists

EJS dynamic hyperlink issue

I’m trying to make a hyperlink that grabs the post id from my database and creates a link based on the postID but it doesn’t seem to work

posts.ejs

 <% for (let post of userPosts) { %>
            <% if (currentTopic !== post.name) { %>
                <li><strong><%= post.name %></strong></li>
                <% currentTopic = post.name; %>
            <% } %>
            <li>
                <a href="/article/<%= post.post_id %>"><%= post.post_name %> - <%= post.username %></a>

            </li>
        <% } %>

main.js

  app.get('/article/:postId', function(req, res) {
        const postId = req.params.postId;
        const sqlQuery = 'SELECT * FROM posts WHERE post_id = ?';
    
        db.query(sqlQuery, [postId], (err, result) => {
            if (err || result.length === 0) {
                // Handle error or post not found
                res.send('Post not found.');
            } else {
                const post = result[0];
                res.render('article.ejs', { post });
            }
        });
    });

I can’t seem to find the issue

Database

*create posts table
CREATE TABLE `posts` (
  `post_id` int NOT NULL AUTO_INCREMENT,
  `user_id` int NOT NULL,
  `topic_id` int NOT NULL,
  `post_name` varchar(45) NOT NULL,
  `article` varchar(1000) NOT NULL,
  PRIMARY KEY (`post_id`),
  UNIQUE KEY `post_id_UNIQUE` (`post_id`)
) 

I’ve logged my errors down but i do not get anything when i click on the hyperlink

If I press Ctrl+S on a website and download it to my desktop, then open it in Firefox, can it access my desktop files or install malware?

I downloaded a not-so-reputable website to my desktop as a way to grab the images on the site. I tried opening the HTML and then I remembered hearing that opening a local file in a browser is different from opening a website. Something about http:// and file:/// allowing different levels of access to my computer. Unsure if I should just re-install windows just to be safe.

I tried scanning the website folder with microsoft defender and it said that no threats were found but IDK how foolproof microsoft defender is.

Extracting and Exporting data to a csv file using javascript

I’m trying to extract data or number from a webpage and export it to a csv file by a push of a button. Here is the code I’m using but it doesn’t do anything when you click the button. Hoping that someone can help me resolve the issue if this is possible.

Kindly change the webpage as I have tested it with mine. Thank you very much in advance.

// ==UserScript==
// @name         Extract and Export Data
// @namespace    http://your-website.com
// @version      1.0
// @description  Extract data and export to CSV
// @author       Your Name
// @match        *://*/*
// @grant        GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

// Function to extract the number before "Data1 and Data2"
function extractData() {
    const textContent = document.body.textContent || document.body.innerText;
    const match = /(d+)s*Data1s*ands*Data2/i.exec(textContent);
    const extractedNumber = match && match[1] ? match[1] : '';

    return extractedNumber;
}

// Function to export data to CSV
function exportToCSV(data) {
    const csvContent = 'data:text/csv;charset=utf-8,' + encodeURIComponent(data);
    const link = document.createElement('a');
    link.href = csvContent;
    link.target = '_blank';
    link.download = 'exported_data.csv';
    link.click();
}

// Function to handle the button click
function handleClick() {
    const extractedNumber = extractData();

    if (extractedNumber) {
        // Example: You can customize the CSV format based on your needs
        const csvData = `Number Before Data1 and Data2n${extractedNumber}`;

        // Trigger the CSV export
        exportToCSV(csvData);
    } else {
        console.error('Data extraction failed. Check the page structure.');
    }
}

// Create a button and append it to the page
const button = document.createElement('button');
button.textContent = 'Export Data to CSV';
button.addEventListener('click', handleClick);

// You can customize the button's style here
GM_addStyle(`
    button {
        background-color: #4CAF50;
        color: white;
        padding: 10px;
        font-size: 16px;
        cursor: pointer;
    }
`);

// Append the button to the body of the webpage
document.body.appendChild(button);
})();

My react project isn’t displaying anything even though I have my components

I had a question since I am very confused on why my code isn’t running at all. I am running my react webpage on mongoDB to store data, and using nodemon to run the page. So currently my issue is that I created a navbar in which is supposed to be able to see the loginpage once you run up the sevrer and I don’t see it at all. After creating dummy data, checking the DOM, i couldn’t figure out whats bugging my code.

import { BrowserRouter, Routes, Route } from 'react-router-dom';
import HomePage from './Scene/homePage'; // Adjust the path as needed
import LoginPage from './Scene/loginPage'; // Adjust the path as needed
import ProfilePage from './Scene/profilePage'; // Adjust the path as needed
import { useMemo } from "react";
import { useSelector } from 'react-redux';
import { CssBaseline, ThemeProvider, createTheme } from '@mui/material';
import { themeSettings } from './theme';

function App() {
  const mode = useSelector((state) => state.mode);
  const theme = useMemo(() => createTheme(themeSettings(mode)), [mode]);
  return (
    <div className="app">
      <BrowserRouter>
        <ThemeProvider theme={theme}>
          <CssBaseline />
          <Routes>
            <Route path="/" element={<LoginPage />} />
            <Route path="/home" element={<HomePage />} />
            <Route path="/profile/:userId" element={<ProfilePage />} />
          </Routes>
        </ThemeProvider>
      </BrowserRouter>
    </div>
  );
}

export default App;

here is my app.js in wh9ich I defined all my paths

import { Box, Typography, useTheme, useMediaQuery } from "@mui/material";
import Form from "./form";

const LoginPage = () => {
  const theme = useTheme();
  const isNonMobileScreens = useMediaQuery("(min-width: 1000px)");
  return (
    <Box>
      <Box
        width="100%"
        backgroundColor={theme.palette.background.alt}
        p="1rem 6%"
        textAlign="center"
      >
        <Typography fontWeight="bold" fontSize="32px" color="primary">
          Sociopedia
        </Typography>
      </Box>

      <Box
        width={isNonMobileScreens ? "50%" : "93%"}
        p="2rem"
        m="2rem auto"
        borderRadius="1.5rem"
        backgroundColor={theme.palette.background.alt}
      >
        <Typography fontWeight="500" variant="h5" sx={{ mb: "1.5rem" }}>
          Welcome to Blogit! Reinventing Blogging with style!
        </Typography>
        <Form />
      </Box>
    </Box>
  );
};

export default LoginPage;

here is my index.jsx for my loginPage in which takes a form.

import { Box } from "@mui/material";
import Navbar from "Scene/navbar"; 

const HomePage = () => {
    return (
        <Box>
            <Navbar />
        </Box>
    );   
};

export default HomePage;

Here is the homepage.jsx in which is supposed to display my loginpage.

Microsoft Windows [Version 10.0.22631.2861]
(c) Microsoft Corporation. All rights reserved.

C:WindowsSystem32>cd C:UsersivatuDownloadsBlogiT

C:UsersivatuDownloadsBlogiT>dir
 Volume in drive C is Windows-SSD
 Volume Serial Number is FC6D-6677

 Directory of C:UsersivatuDownloadsBlogiT

12/15/2023  09:14 PM    <DIR>          .
12/14/2023  10:23 PM    <DIR>          ..
12/15/2023  09:03 PM                15 .gitignore
12/14/2023  09:43 PM    <DIR>          client
12/07/2023  11:24 AM    <DIR>          node_modules
12/07/2023  11:24 AM           153,560 package-lock.json
12/07/2023  11:24 AM               226 package.json
12/08/2023  02:44 PM    <DIR>          server
               3 File(s)        153,801 bytes
               5 Dir(s)  26,916,519,936 bytes free

C:UsersivatuDownloadsBlogiT>cd client

C:UsersivatuDownloadsBlogiTclient>dir
 Volume in drive C is Windows-SSD
 Volume Serial Number is FC6D-6677

 Directory of C:UsersivatuDownloadsBlogiTclient

12/14/2023  09:43 PM    <DIR>          .
12/15/2023  09:14 PM    <DIR>          ..
12/15/2023  09:01 PM               310 .gitignore
12/14/2023  12:28 PM                88 jsconfig.json
12/14/2023  03:13 PM    <DIR>          node_modules
12/14/2023  12:19 PM           732,866 package-lock.json
12/14/2023  12:18 PM             1,180 package.json
12/14/2023  03:11 PM    <DIR>          public
12/14/2023  11:44 AM             3,359 README.md
12/15/2023  03:30 PM    <DIR>          src
               5 File(s)        737,803 bytes
               5 Dir(s)  26,915,930,112 bytes free

C:UsersivatuDownloadsBlogiTclient>cd sec
The system cannot find the path specified.

C:UsersivatuDownloadsBlogiTclient>cd src

C:UsersivatuDownloadsBlogiTclientsrc>dir
 Volume in drive C is Windows-SSD
 Volume Serial Number is FC6D-6677

 Directory of C:UsersivatuDownloadsBlogiTclientsrc

12/15/2023  03:30 PM    <DIR>          .
12/14/2023  09:43 PM    <DIR>          ..
12/15/2023  03:39 PM             1,049 App.js
12/14/2023  08:59 PM    <DIR>          components
12/14/2023  12:27 PM               187 index.css
12/14/2023  03:05 PM               901 index.js
12/14/2023  03:11 PM    <DIR>          Scene
12/15/2023  03:30 PM    <DIR>          state
12/14/2023  03:05 PM             2,972 theme.js
               4 File(s)          5,109 bytes
               5 Dir(s)  26,915,930,112 bytes free

C:UsersivatuDownloadsBlogiTclientsrc>cd Scene

C:UsersivatuDownloadsBlogiTclientsrcScene>dir
 Volume in drive C is Windows-SSD
 Volume Serial Number is FC6D-6677

 Directory of C:UsersivatuDownloadsBlogiTclientsrcScene

12/14/2023  03:11 PM    <DIR>          .
12/15/2023  03:30 PM    <DIR>          ..
12/14/2023  03:11 PM    <DIR>          homePage
12/15/2023  02:38 PM    <DIR>          loginPage
12/14/2023  03:11 PM    <DIR>          navbar
12/14/2023  03:11 PM    <DIR>          profilePage
12/14/2023  12:35 PM    <DIR>          widgets
               0 File(s)              0 bytes
               7 Dir(s)  26,915,930,112 bytes free

C:UsersivatuDownloadsBlogiTclientsrcScene>

here is the file directory if you’re wondering.

Looping through large array without freezing in JavaScript

Let’s say I have an array of 10000 random integers. I want to while loop through it and add each number to a ul. The thing is, if I do something like this:

const myArray = [/* 10000 totally random integers! */];
let pos = 0;
while (pos < myArray.length) {
  document.getElementById("unorderedList").innerHTML += `<li>${pos}</li>`;
  pos++;
}
console.log("done!");

It freezes the whole window until it finishes, then it logs everything. How can I make it so the loop adds the number every iteration until it finishes instead of finishing the loop then printing everything?
Note: this hypothetical function also needs to interact with a Window created with window.open, so I don’t think I can use workers since that interacts with the DOM.

Playwright: Simulating Ctrl+Shift+M for Toggling Device Toolbar in CDP not working

I’m trying to simulate mobile page rendering and testing in Chrome using Playwright. I need to activate the Toggle Device Toolbar via the Ctrl+Shift+M keyboard shortcut within the DevTools panel.

Here’s my code:

const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch({
    headless: false,
    devtools: true // enable developer tools
  });

  const context = await browser.newContext();
  const page = await context.newPage();
  
  // create cdp session
  const client = await context.newCDPSession(page);

  // activate devtools
  await client.send('Page.enable');
  await client.send('Page.bringToFront');
  await client.send('Page.navigate', { url: 'Some url' });
  
  // get devTools targetId
  const targets = await client.send('Target.getTargets', {});
  const devToolsTargetId = targets.targetInfos.find((info) => info.type === 'other').targetId;
  
  // focus on devtools panel
  // await client.send('Target.activateTarget', { targetId: devToolsTargetId });
  await client.send('Target.attachToTarget', { targetId: devToolsTargetId });

  // simulate shortcuts: Ctrl + Shift + M
  await client.send('Input.dispatchKeyEvent', {
    type: 'keyDown',
    modifiers: 8, // means 'Ctrl+Shift'
    windowsVirtualKeyCode: 77, // means key 'M'
    nativeVirtualKeyCode: 77,
    autoRepeat: false,
    isKeypad: false,
    targetId: devToolsTargetId,
  });
  await client.send('Input.dispatchKeyEvent', {
    type: 'keyUp',
    modifiers: 8,
    windowsVirtualKeyCode: 77,
    nativeVirtualKeyCode: 77,
    autoRepeat: false,
    isKeypad: false,
    targetId: devToolsTargetId,
  });

  // Do something on the page, e.g., take a screenshot
  await page.screenshot({ path: 'screenshot.png' });

  // await browser.close();
})();

This code opens Chrome with DevTools, navigates to a URL, attempts to focus on the DevTools panel with ‘Target.attachToTarget’, and sends the simulated key events for ‘Ctrl+Shift+M’ with ‘Input.dispatchKeyEvent’. However, the Toolbar doesn’t get activated.

The output of ‘targets.targetInfos’ is:

[
  {
    targetId: 'CBF44E36684FD28034D2543C684754A5',
    type: 'other',
    title: '',
    url: 'devtools://devtools/bundled/devtools_app.html?remoteBase=https://chrome-devtools-frontend.appspot.com/serve_file/@f4095e9665f7d7a2531edefcea119d45d899d95b/&can_dock=true&targetType=tab',
    attached: true,
    canAccessOpener: false,
    browserContextId: '91C311D78E340D26C7A07F56F6EE4198'
  },
  {
    targetId: '214735BD67A2224755912F57CDBF353E',
    type: 'page',
    title: 'about:blank',
    url: 'Some url',
    attached: true,
    canAccessOpener: false,
    browserContextId: '68E0C79153C5A7951F11E74D4482AE57'
  }
]

My question is: why isn’t the Toggle Device Toolbar activating when I simulate the Ctrl+Shift+M shortcut in the DevTools panel? How can I fix this behavior?

How to access https://www.midjourney.com/api/app/vector-search?

curl 'https://www.midjourney.com/api/app/vector-search?prompt=dog&page=1&_ql=explore&_q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ZDFtaHl5bzFSZTRHVlpYLUNGMm8xY3VTVEpyTGVabV95LUJlT1prRzFlSVhaaVRuU0R4dDNMWHlaRGxiRTBaQXFMcm56RlI5aU1QQU1wQVQ4ZkVoZ0VuRkpJdDJSaXZJQWNrWFBqMHJyS2ZVai1vX1lCVkFlU0tDLUdwU3hweUV2WnAyZzdTb1luYTBxR1pROTcxMlE5Z0YtNjdxdTNHcGdnVDd0dERQczREX1oxNlAta0dfR3kxbnRtYWFMTFBvIn0; __Host-Midjourney.AuthUserToken.sig=1ZO2kZdtmyswOmJmMjqII-qRNG89TofG5nUhmtT_-NU; cf_clearance=ywRQ5cABCIDKH97O5_qh1U.5x_IhJ4UmYlSMP7W2rDg-1702527728-0-1-e49e671c.ed280698.b39f38fc-0.2.1702527728; AMP_MKTG_437c42b22c=JTdCJTdE; __cf_bm=at9zog9nMk0wJRJr1uxiPnXE8AJTlp5rroyC9FnBqE8-1702527726-1-AdRfktooTgSPWXkrVbanTAnsmNgVz3GABk4OP3mGk6HZqanixb75izr29lUC6e11qg/2V+linMlWMhWldw7cpfo= ' 
-H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/[121.0.0.0](http://121.0.0.0/) Safari/537.36 Edg/[121.0.0.0](http://121.0.0.0/)' 
-H 'x-csrf-protection: 1'


I get the right server results on my mac, and I get error server results html content back on my linux cloud server!!Do you know how to fix it?

right res

enter image description here

error res

enter image description here

can get right res on linux cloud server.

Create the opossum circuit breaker in node js as a Singleton instance

Am trying to implement a circuit breaker in node js as a singleton class using https://nodeshift.dev/opossum/

For some reason, breaker metrics always start from 0 and the circuit never opens after the threshold failure.

REF: https://github.com/nodeshift/opossum/issues/593 -> The author seems to suggest using closure to achieve singleton property but doesn’t work for me. Any reason why or pointers I can check?

Quick test link: https://filebin.net/zbjhntvjnqwdobns (download and use the command (npm install && node src/singleton.js) to run it locally)

singleton.js

let Adapter = require('./adapter');
let routerHandlerWrapper = require('./handler-wrapper');

const start = async function () {
  let i=0;
  for (i = 0; i < 100; i++) {
    const adapter = new Adapter(routerHandlerWrapper);
    await adapter.callPartner(i);
    console.log("attempt: " + i);
  }
}
start();

handler-wrapper.js

const { breaker } = require('./circuit-breaker');
module.exports = function (routerController, next) {
  console.log("Creating controller circuit");
  const breakerController = breaker(routerController);
  breakerController.on('open', () => {
    console.log('The circuit is open ' + JSON.stringify(breakerController.stats));
  });

  return async function (req, res, i) {
    try {
      // console.log(breakerController.stats);
      await breakerController.fire(req, res, i);
    } catch (err) {
      next(err);
    }
  };
};

circuit-breaker.js

const CircuitBreaker = require('opossum');

const circuitBreakerOptions = {
  enabled: true,
  timeout: 10000, // If our function takes longer than 10 seconds, trigger a failure
  errorThresholdPercentage: 50, // When 50% of requests fail, trip the circuit
  volumeThreshold: 5,
  rollingCountTimeout: 300000,
  resetTimeout: 20000 // After 60 seconds, try again.
}

const options = {
  // errorFilter: err => ((!err || !err.code)
  //   ? false // open circuit breaker
  //   : (err.code >= 300 && err.code < 500))
  ...circuitBreakerOptions
};

module.exports = {
  breaker: asyncFunc => new CircuitBreaker(asyncFunc, options)
};

adapter.js

class Adapter {
  constructor(routerHandlerWrapper) {
    this.routerHandlerWrapper = routerHandlerWrapper
  }
  async asyncFunctionThatCouldFail(x, y, i) {
    if (i > 40) {
      return await new Promise((resolve, reject) => setTimeout(() => resolve("positive"), 1000));
    }
    await new Promise((resolve, reject) => setTimeout(() => reject(new Error('timeout')), 1000));
    console.log("the args: " + x + " " + y + " " + i);
    throw "error";
  }

  async callPartner(i) {
    const x = "value1", y = "value2";
    let wrappedFunc = this.routerHandlerWrapper(this.asyncFunctionThatCouldFail, console.error);
    await wrappedFunc(x, y, i);
  }
}

module.exports = Adapter;

Unexpected strict mode reserved word [closed]

let lettuceNeeded;

let tomatoNeeded;

let cucumberNeeded;

let dressingNeeded;

let servings;

let recipe;

function calcLettuce(numServings)

let numServings = 2;

let lettuce = 1;

let totalLettuce = lettuce * numServings;

return totalLettuce;

}

function calcTomato()

{

let tomato = .5;

let totalTomato = tomato * numServings;

return totalTomato;

}

function calcCucumber(numServings)

{

let cucumber = .25;

let totalCucumber = cucumber * numServings;

return totalCucumber;

}

function calcDressing(numServings)

{

let dressing = 1;

let totalDressing = dressing * numServings;

return totalDressing;

}

console.log(“~~~Welcome to the Recipe Calculator~~~”)

recipe = prompt(“Enter the name of your recipe: “);

servings = Number(prompt(“Enter the number of servings: “));

console.log();

lettuceNeeded = calcLettuce(servings);

tomatoNeeded = calcTomato(servings);

cucumberNeeded = calcCucumber(servings);

dressingNeeded = calcDressing();

console.log(“For ” + servings + ” servings of “+recipe+”, you will need to buy the following ingredients: “);

console.log(lettuceNeeded + ” cups of lettuce”);

console.log(tomatoNeeded + ” tomatoes”);

console.log(cucumberNeeded + ” cucumbers”);

console.log(dressingNeeded + ” ounces of dressing”);

The syntax it hard to find

Error while fetching JSON with JavaScript

So I’m new to JSON fetching here, and currently implementing a JSON API in my current project. My code works fine when using a direct .json-file link, but when trying to fetch from the live link (ending with my API key and the parameters, rather than the file extension) it shows nothing. The log shows that the JSON fetching was successful but it obviously doesn’t get any data.

Here is my current code:

fetch('https://api.dropinblog.com/v1/json/?b=XXXXXXXXXXXXXXXXXX&limit=2')
            .then(function (response) {
                return response.json();
            })
            .then(function (data) {
                appendData(data);
                console.log('Success!');
            })
            .catch(function (err) {
                console.log('error: ' + err);
                alert('Error: ' + err);
            });
        function appendData(data) {
            var mainContainer = document.getElementById("myData");
            for (var i = 0; i < data.length; i++) {
                var div = document.createElement("div");
                div.innerHTML = "Status: " + data[0].status + "<br />" + "ID: " + data[0].data["posts"][i].id + "<br /><br />" + "<img src=" + data[0].data["posts"][i].featuredImage.split('"').join('') + "><br /><br />" + data[0].data["posts"][i].title;
                mainContainer.appendChild(div);
            }
        }

As you can see I am still just playing around with the code and trying to figure out how to fetch the data. I would like to keep it Vanilla JS as much as possible!


Also – I am using a CORS-anywhere addon in Chrome at the moment -, I am aware that I am going to need a proxy or similar for fetching later, when it’s uploaded to the host. I have been looking around a lot for the best ways to do this and even setup a localhost proxy the other day but could not get it to work. Is there any easy and simple workaround for the CORS-problem?