How do I clear an array in Node JS?

I am writing a server on NodeJS and I am desperate XD An approximate description of my plan sounds like this: User 1 sends a request to add a message (it is placed in an array). User 2 sends a message request. After that, the message array should be cleared. And there is one catch…. it is not being cleaned… no way…

let express = require('express');
let app = express();
let Messages = [];

class Message {

  constructor(text, author) {
    this.text = text;
    this.author = author;
  }

}

app.use('/new_message_dev', (req, res) => {

  try {
    
    Messages.push(new Message(req.query.msgTxt, 'dev'));
    res.send('Its ok');
  
  } catch (err) {
    res.send('Error');
  }
  
});

app.get('/get_message_root', (req, res) => {

  try {
    
    let ResArr = [];

    Messages.forEach((element, index) => {
      
      if(element.author === 'dev'){
        ResArr.push(element.text);
      };
      
    });

    Messages.length = 0;
    res.json({ anArray: ResArr });
  
  } catch (err) {
  
    res.send('Error');
  
  }
  
});

I’ve tried splice, slice, delete, .length = 0. Declaring a new array.

I understand that the fact is that I am not working with the array itself, but with a reference to it in this function. But I don’t understand, is there no way I can clean it up here?

Smooth scrolling through components in React JS

I want to smooth scroll my landing page, I tried different npm like smooth scrollbar but its not working. How do I smooth scroll when there are different components? This is my landing page.

import React from 'react';
import { ParallaxProvider } from 'react-scroll-parallax';
import MainSlider from '../components/MainSlider';
import Find from '../components/Find';
import Counter from '../components/Counter';
import Adoption from '../components/Adoption';
import BreedServices from '../components/BreedServices';
import Brand from '../components/Brand';
import AdoptionFaq from '../components/adoption/AdoptionFaq';
import AdoptionShop from '../components/AdoptionShop';
import Testimonial from '../components/Testimonial';
import BlogsHome from '../components/BlogsHome';

function Home() {
    return (
        <main>
            <ParallaxProvider>
                <MainSlider />
                <Find />
                <Counter />
                <Adoption />
                <BreedServices />
                <Brand />
                <AdoptionFaq/>
                <AdoptionShop />
                <Testimonial />
                <BlogsHome />
            </ParallaxProvider>
        </main>
    );
}

export default Home;

Jquery Ajax Call is not working in Asp.net

I have searched many solution but nothing worked. I am doing just a simple Ajax call using Jquery in Visual studio 2019 but my code is not hitting Ajax call. Here is my code

 <script src="Scripts/jquery-1.11.3.min.js"></script>
 <script type="text/javascript">
    
    function GetDataDetails() {            
        $.ajax({
            type: "POST",
            url: "WebForm1.aspx/GetData",
            data: '{}',
            contentType: "application/json; charset=utf-8",
            dataType: "json",               
            success: function (response) {
                var xmlDoc = $.parseXML(response.d);
                var xml = $(xmlDoc);
                var Records = xml.find("Table");
                if (Records.length > 0) {
                    alert(Records.length);
                }
            },                
            error: function (d) {
                alert(d.responseText);
            }
        });
    }

    $(function () {
        $("[id*=Button1]").bind("click", function () {
            GetDataDetails();
            return false;
        });            
    });
</script>

c# code

[WebMethod]
        public static string GetData()
        {
            using (SqlCommand Cmd = new SqlCommand())
            {
                using (SqlConnection Con = Connections.Create())
                {
                    Cmd.Connection = Con;
                    Cmd.CommandText = "GetColumnList_pro".Trim();
                    Cmd.CommandType = CommandType.StoredProcedure;
                    Cmd.Parameters.AddWithValue("Option", "GetColumnList".Trim());
                    using (SqlDataAdapter Adp = new SqlDataAdapter())
                    {
                        using (DataSet Ds = new DataSet())
                        {
                            Con.Open();
                            Adp.SelectCommand = Cmd;
                            Adp.Fill(Ds);
                            return Ds.GetXml();
                        }
                    }
                }
            }
        }

There is no error when I debug my code. It’s hitting the method also but out from here $.ajax({.
What am I missing?

Fetch data in a client component [closed]

i want the best practice to fetch data in a client component in nextJS app

Iam learning next js i want to see the best practice to fetch data in a client component …………………………………………………………………………………………………………………………………………………….

Can i convert this python script to javascript? (cryptography blake2b)

Hello I’m trying to convert the following python script into javascript, but not sure if this is even possible.
I’m not really into cryptography so my failure could be related to the nature of cryptography algorithm itself.

I tried different crypto libraries, but the output is always non consistent with the original script.

Do you know if this is possible to achieve? If so, can you provide a solution?
Thanks

Here’s the script

import math, pyblake2

global_seed = bytes.fromhex("00000000000000000004ab6468e03c35500b5f59b8ef58ef9873f67ffbf12bcd")
round = 3
round_hash = bytes.fromhex("d676fe6e808727a783f4ac159cb250f05373a57b5c40fcddd37cde0c5960d1b3 ")

for i in range (round, 0, -1):
    round_final_hash = pyblake2.blake2b(round_hash + global_seed, digest_size=32).digest()
    x = float(int.from_bytes(round_final_hash[:8], byteorder='little', signed=False)) / float(2**64 - 1)
    outcome = min(1e6, max(1.0, math.floor(100.0*(1.0-0.05)/x) / 100.0))
    print("Round: ", i)
    print("Round Hash: ", round_hash.hex())
    print("Round Outcome: ", outcome)
    round_hash = pyblake2.blake2b(round_hash, digest_size=32).digest()

the output is

Round:  3
Round Hash:  d676fe6e808727a783f4ac159cb250f05373a57b5c40fcddd37cde0c5960d1b3
Round Outcome:  3.73
Round:  2
Round Hash:  d5ea567ef96d10bd9ba8f3d4d883c18a1c6a059360e835195fffa108018d879c
Round Outcome:  2.17
Round:  1
Round Hash:  b09f1a41219ca669f27a277de5102020690c5d6e208e78f3ecb5b5338cf32e85
Round Outcome:  1.07

Create order for fetching and parsing scripts dynamically

I am trying to optimize website with multiple frontend applications. I would like to dynamically download (parse) application and set order for critical application for our system.

I was thinking about fetchpriority:

function appendScriptWithPriority(src, priority) {
  return new Promise((resolve, reject) => {
    const script = document.createElement('script');
    script.src = src;
    script.async = true;
    script.fetchpriority = 'low';

    script.onload = () => {
      resolve();
    };

    script.onerror = (error) => {
      reject(error);
    };

    // Append the script to the head of the document
    document.head.appendChild(script);
  });
}

In DOM, I can see script without fetchpriority:

<script src='src' async></script>

Is there any way, how can I set fetchpriority for script dynamically? Or should I go completely different way ?

how to animate an element with a sticky position

Tell me how to animate an element with a sticky position

I want the animation not to play in the initial position, but when the element is in motion, the animation goes smoothly to the top value.

let’s say rotate(900deg);
and depending on where we scrolled, down or up, the direction of the animation changed.

I understand that you can track the initial coordinates of an element in a block and if some value is added to the coordinates along the Y axis, then we start scrolling, but I can’t implement this so that
in the initial position rotate was 0 and in the final position 900, which would allow the animation to play at different speeds at different scrolling speeds

body {
  display: flex;
  width: 100%;
  height: -moz-max-content;
  height: max-content;
  background: rgb(22, 22, 22);
}

.main {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: -moz-max-content;
  height: max-content;
}

.main__start-page {
  width: 100%;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  background-color: palegreen;
}

.main__start-page p:first-child {
  font-size: 114px;
  color: white;
  font-weight: 900;
  text-shadow: 2px 2px black;
}

.main__start-page p:last-child {
  font-size: 114px;
  color: white;
  font-weight: 900;
  text-shadow: 2px 2px black;
}

.main__center-page {
  width: 100%;
  height: 100vh;
  background-color: plum;
}

.main__end-page {
  width: 100%;
  height: 100vh;
  background-color: palegoldenrod;
}

.main__lorem-center-page {
  width: 50%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  & p {
    padding-left: 50px;
  }
}

.main__wrapper {
  width: 100%;
  height: max-content;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  position: relative;
}

.asterisk__wrapper {
  display: flex;
  justify-content: center;
  position: absolute;
  right: 20px;
  width: 200px;
  height: 50%;
}

.asterisk__wrapper::before {
  content: "start";
  position: absolute;
  top: -60px;
}

.asterisk__wrapper::after {
  content: "stop";
  position: absolute;
  bottom: -60px;
}

.asterisk {
  font-size: 500px;
  position: sticky;
  width: 100px;
  border-radius: 99px;
  height: 100px;
  top: 50%;
  background-color: white;
}
<div class="main">
  <div class="main__wrapper">
    <div class="main__start-page">
      <p>ПРИВЕТ</p>
      <p>МИР</p>
    </div>

    <div class="main__center-page">
      <div class="main__lorem-center-page">
        <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Fugit deserunt, eaque laudantium inventore magni perferendis saepe reprehenderit possimus quam rerum officia quis veritatis cum est, esse sapiente tempora voluptatum tempore!
        </p>
      </div>
    </div>

    <div class="asterisk__wrapper">
      <div class="asterisk"></div>
    </div>
  </div>
  <div class="main__end-page">
    <div class="main__lorem-center-page">
      <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Sequi aperiam alias fugiat itaque dicta cumque sed soluta possimus reiciendis. Quidem ad voluptatum possimus labore iure magnam quaerat non minus dolore.
      </p>
    </div>
  </div>
</div>

enter image description here

How to import 3D models in Zappar WebAR Project based from user select?

I want to import different 3D models in my webAR Zappar project based from user chose; When user select a character name, modelPath Variable must be change to selected model file path. my question is how i can use a string for changing the path and model file?

I tried through the following method.

let modelPath  ='../assets/model.glb';
let model = new URL(modelPath , import.meta.url).href;

Result of above codes is : file:///assets/model.glb

But when i change codes to

let model = new URL('../assets/model.glb', import.meta.url).href;

result is (I need this result) : https://IPADDRESS:PORT/model.01234567.glb?12345678901234

for more information you can see https://github.com/zappar-xr/threejs-example-instant-tracking-gltf-loader/tree/master

Compiler Options Lib in tsconfig.json File – Typescript-config/is-valid

I get this error when initalizing my react native android project from the tsconfig.json file:

‘compilerOptions/lib/2’ must be equal to one of the allowed values ‘ES5, ES6, ES2015, ES2015.Collection, ES2015.Core, ES2015.Generator, ES2015.Iterable, ES2015.Promise, ES2015.Proxy, ES2015.Reflect, ES2015.Symbol.WellKnown, ES2015.Symbol, ES2016, ES2016.Array.Include, ES2017, ES2017.Intl, ES2017.Object, ES2017.SharedMemory, ES2017.String, ES2017.TypedArrays, ES2018, ES2018.AsyncGenerator, ES2018.AsyncIterable, ES2018.Intl, ES2018.Promise, ES2018.Regexp, ES2019, ES2019.Array, ES2019.Intl, ES2019.Object, ES2019.String, ES2019.Symbol, ES2020, ES2020.BigInt, ES2020.Promise, ES2020.String, ES2020.Symbol.WellKnown, ESNext, ESNext.Array, ESNext.AsyncIterable, ESNext.BigInt, ESNext.Intl, ESNext.Promise, ESNext.String, ESNext.Symbol, DOM, DOM.Iterable, ScriptHost, WebWorker, WebWorker.ImportScripts, Webworker.Iterable, ES7, ES2021, ES2020.SharedMemory, ES2020.Intl, ES2021.Promise, ES2021.String, ES2021.WeakRef, ESNext.WeakRef, es2021.intl, ES2022, ES2022.Array, ES2022.Error, ES2022.Intl, ES2022.Object, ES2022.String’. Value found ‘”es2020.date”‘. Or ‘compilerOptions/lib/2’ must match pattern ‘^[Ee][Ss]5|[Ee][Ss]6|[Ee][Ss]7$’. Value found ‘es2020.date’ Or ‘compilerOptions/lib/2’ must match pattern ‘^[Ee][Ss]2015(.([Cc][Oo][Ll][Ll][Ee][Cc][Tt][Ii][Oo][Nn]|[Cc][Oo][Rr][Ee]|[Gg][Ee][Nn][Ee][Rr][Aa][Tt][Oo][Rr]|[Ii][Tt][Ee][Rr][Aa][Bb][Ll][Ee]|[Pp][Rr][Oo][Mm][Ii][Ss][Ee]|[Pp][Rr][Oo][Xx][Yy]|[Rr][Ee][Ff][Ll][Ee][Cc][Tt]|[Ss][Yy][Mm][Bb][Oo][Ll].[Ww][Ee][Ll][Ll][Kk][Nn][Oo][Ww][Nn]|[Ss][Yy][Mm][Bb][Oo][Ll]))?$’. Value found ‘es2020.date’ Or ‘compilerOptions/lib/2’ must match pattern ‘^[Ee][Ss]2016(.[Aa][Rr][Rr][Aa][Yy].[Ii][Nn][Cc][Ll][Uu][Dd][Ee])?$’. Value found ‘es2020.date’ Or ‘compilerOptions/lib/2’ must match pattern ‘^[Ee][Ss]2017(.([Ii][Nn][Tt][Ll]|[Oo][Bb][Jj][Ee][Cc][Tt]|[Ss][Hh][Aa][Rr][Ee][Dd][Mm][Ee][Mm][Oo][Rr][Yy]|[Ss][Tt][Rr][Ii][Nn][Gg]|[Tt][Yy][Pp][Ee][Dd][Aa][Rr][Rr][Aa][Yy][Ss]))?$’. Value found ‘es2020.date’ Or ‘compilerOptions/lib/2’ must match pattern ‘^[Ee][Ss]2018(.([Aa][Ss][Yy][Nn][Cc][Ii][Tt][Ee][Rr][Aa][Bb][Ll][Ee]|[Ii][Nn][Tt][Ll]|[Pp][Rr][Oo][Mm][Ii][Ss][Ee]|[Rr][Ee][Gg][Ee][Xx][Pp]))?$’. Value found ‘es2020.date’ Or ‘compilerOptions/lib/2’ must match pattern ‘^[Ee][Ss]2019(.([Aa][Rr][Rr][Aa][Yy]|[Oo][Bb][Jj][Ee][Cc][Tt]|[Ss][Tt][Rr][Ii][Nn][Gg]|[Ss][Yy][Mm][Bb][Oo][Ll]))?$’. Value found ‘es2020.date’ Or ‘compilerOptions/lib/2’ must match pattern ‘^[Ee][Ss]2020(.([Bb][Ii][Gg][Ii][Nn][Tt]|[Pp][Rr][Oo][Mm][Ii][Ss][Ee]|[Ss][Tt][Rr][Ii][Nn][Gg]|[Ss][Yy][Mm][Bb][Oo][Ll].[Ww][Ee][Ll][Ll][Kk][Nn][Oo][Ww][Nn]))?$’. Value found ‘es2020.date’ Or ‘compilerOptions/lib/2’ must match pattern ‘^[Ee][Ss]2021(.([Ii][Nn][Tt][Ll]|[Pp][Rr][Oo][Mm][Ii][Ss][Ee]|[Ss][Tt][Rr][Ii][Nn][Gg]|[Ww][Ee][Aa][Kk][Rr][Ee][Ff]))?$’. Value found ‘es2020.date’ Or ‘compilerOptions/lib/2’ must match pattern ‘^[Ee][Ss]2022(.([Aa][Rr][Rr][Aa][Yy]|[Ee][Rr][Rr][Oo][Rr]|[Ii][Nn][Tt][Ll]|[Oo][Bb][Jj][Ee][Cc][Tt]|[Ss][Tt][Rr][Ii][Nn][Gg]))?$’. Value found ‘es2020.date’ Or ‘compilerOptions/lib/2’ must match pattern ‘^[Ee][Ss][Nn][Ee][Xx]Tt?$’. Value found ‘es2020.date’ Or ‘compilerOptions/lib/2’ must match pattern ‘^[Dd][Oo]Mm?$’. Value found ‘es2020.date’ Or ‘compilerOptions/lib/2’ must match pattern ‘^[Ss][Cc][Rr][Ii][Pp][Tt][Hh][Oo][Ss][Tt]$’. Value found ‘es2020.date’ Or ‘compilerOptions/lib/2’ must match pattern ‘^[Ww][Ee][Bb][Ww][Oo][Rr][Kk][Ee]Rr?$’. Value found ‘es2020.date’

This occurs from this code:

{
  "extends": "@tsconfig/react-native/tsconfig.json"
}

I tried adding the compiler options as requested this is through doing some research on forums and also looking closely on the error/problem.

{
  "extends": "@tsconfig/react-native/tsconfig.json",
  "compilerOptions": {
    "lib": ["ES2022"]
  }
}

Though i still get issues in my code with the same error.

I also tweaked the lib to “ES2015”, “ES2021” e.t.c but still error persists

React native cli(yarn) version 0.67 and node version 16.20

my package used
“dependencies”: {
“@notifee/react-native”: “5.3.0”,
“@react-native-async-storage/async-storage”: “^1.19.3”,
“@react-native-community/checkbox”: “^0.5.15”,
“@react-native-community/clipboard”: “^1.5.1”,
“@react-native-community/netinfo”: “^9.4.1”,
“@react-native-community/slider”: “^4.4.3”,
“@react-native-picker/picker”: “^2.4.10”,
“@react-navigation/bottom-tabs”: “^6.5.7”,
“@react-navigation/drawer”: “^6.6.2”,
“@react-navigation/native”: “^6.1.7”,
“@react-navigation/native-stack”: “^6.9.13”,
“@react-navigation/stack”: “^6.3.16”,
“@reduxjs/toolkit”: “^1.9.5”,
“@svanboxel/visibility-sensor-react-native”: “^1.0.2”,
“@twotalltotems/react-native-otp-input”: “^1.3.11”,
“@zegocloud/react-native-callkeep”: “^4.3.9”,
“@zegocloud/zego-uikit-prebuilt-call-rn”: “^4.2.7”,
“@zegocloud/zego-uikit-rn”: “^2.2.4”,
“axios”: “^1.4.0”,
“moment”: “^2.29.4”,
“prop-types”: “^15.8.1”,
“react”: “17.0.2”,
“react-delegate-component”: “^1.0.0”,
“react-hook-form”: “^7.45.1”,
“react-native”: “0.67.4”,
“react-native-actions-sheet”: “^0.9.0-alpha.21”,
“react-native-audio”: “^4.3.0”,
“react-native-config”: “^1.5.1”,
“react-native-device-info”: “^10.9.0”,
“react-native-document-picker”: “^9.0.1”,
“react-native-encrypted-storage”: “^4.0.3”,
“react-native-gesture-handler”: “^2.9.0”,
“react-native-image-crop-picker”: “^0.40.0”,
“react-native-insta-story”: “^1.1.9”,
“react-native-instagram-reels”: “^1.0.1”,
“react-native-linear-gradient”: “^2.8.1”,
“react-native-maps”: “^1.8.0”,
“react-native-mmkv”: “2.5.1”,
“react-native-modal”: “^13.0.1”,
“react-native-network-logger”: “^1.15.0”,
“react-native-paper”: “^5.7.0”,
“react-native-permissions”: “^3.10.1”,
“react-native-phone-number-input”: “^2.1.0”,
“react-native-picker-select”: “^8.0.4”,
“react-native-push-notification”: “^8.1.1”,
“react-native-reanimated”: “^2.10.0”,
“react-native-reanimated-carousel”: “^3.3.0”,
“react-native-safe-area-context”: “^4.7.2”,
“react-native-screens”: “^3.25.0”,
“react-native-sound”: “^0.11.2”,
“react-native-splash-screen”: “^3.3.0”,
“react-native-svg”: “^13.9.0”,
“react-native-vector-icons”: “^10.0.0”,
“react-native-video”: “^5.2.1”,
“react-native-vision-camera”: “^2.14.1”,
“react-redux”: “^8.1.1”,
“redux-observable”: “^2.0.0”,
“rxjs”: “^7.8.1”,
“socket.io-client”: “^4.7.2”,
“zego-express-engine-reactnative”: “3.2.0”,
“zego-zim-react-native”: “2.9.0”,
“zego-zpns-react-native”: “2.4.0”
},

What went wrong:
Execution failed for task ‘:app:mergeDebugResources’.

C:UsersMy_Pc.gradlecachestransforms-3fbfc0721a09734f7b11e11d237377133transformedmaterial-1.9.0resvaluesvalues.xml: Error: Can’t determine type for tag ‘?attr/shapeAppearanceCornerSmall’

project is not run, but i want to run the project perpertly

How to add timestamps and screenshot in player seek-bar in a video using html and JavaScript

I am working on a project where i need to add timestamps in the given video and attach screenshot on player Seek-bar like YouTube video. Whenever i scroll player Seek-bar the video should start form there. There should be a function that let the user scroll to the start of that specific segment. The player Seek-bar should get divided into these segments.

Better way to store user access token in angular applications

What is the best way of storing the user token for accessing my app? I’ve seen an online Angular course where he explains how to store user id and access token in the local storage but i see risks in doing this. It’s easy to gather the token for another user who wants to log in as the victim, so what’s the best way of doing it securely?

Thank you in advice

I’ve not tried anything yet but there must be another solution. Or maybe is it the best way?

How to init a module by a service?

I have a Angular App with main-component AppComponent that uses a module MyMod that needs config information at start.

I also have a service MyServ that provides these information.

app.module.ts

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
  
    MyMod.forRoot ({
         param: "12345"             // the parameter!
            })
  ],
  providers: [MyServ],
  bootstrap: [AppComponent]
})

myserv.service.ts

@Injectable ()
export class MyServ
{
 
  getParam () : string
  {
    return "12345";
  }
}

Is it possible I can use myserv.getParam () in app.modules.ts to init MyMod??