Parent Pages and Child Pages in Html

So I was wondering how to link multiple pages together for a single website. For example we have a website : www.example.com and I want to redirect it to feedback page, the path is www.example.com/feedback

So I am trying to achieve that path system but dont know exactly how to

I tried to name the files according to name of main site. But I am sure that’s not exactly how it is done. I want the name of the page after the domain. www.example.com/feedback

Filter array of array (substring)

I have an array of array and I want to show only array with the substring from a search bar.

My code :

In the first part (not show) I get value from search bar and had a space before (to see all arrays if nothing is write)

 const Arrays = [
 [
  { text: " first ", image: "1.jpg", },
  " hello"," world"," ",
],
[
  {text: " second",image: "https://www.wikipedia.org/portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png",},
  " goodbye"," world"," ",
],
[
  { text: " Salut", image: "bass.jpg", },
  " Ca va"," au revoir"," ",
],
];

const showArrays = Arrays.filter(function(array) {return array.includes(searchimp) })

That is my filter fonction, it work only if searchimp was exactly same with an element from an subarray

With searchimp my const from search bar.

At end I have a function (not show) to show “showArrays” and format each first element from each array to show pictures and there alt

It run, when I write “goodbye” it return the second array but when I write “goo” it did’nt return anything.

How to iterate through table and insert records in corresponding table using for loop in javascript in snowflake?

Somehow my code only insert row 1 and colum1,2,3 records into output table.
unfortutely it doesn’t insert records row2 onwards.
could someone please help?

unforutely my code only insert the first row’s column only.
it is not iterating through remaing rows to get corrsponding coulmns inserted into the output table.
code is as below:

create or replace procedure proc3()
returns varchar
language javascript
as
$$
var query1= 'select * from test2'
var query1_s = snowflake.createStatement({sqlText: query1});
var query1_s_res = query1_s.execute();
for (i = 1; i <= query1_s_res.getRowCount(); i++){
query1_s_res.next()
X=  query1_s_res.getColumnValue(1)
Y = query1_s_res.getColumnValue(2)
Z = query1_s_res.getColumnValue(3)
var sql_source_table =
"INSERT INTO test3 VALUES (?,?,?)";
var source_max_day = snowflake.execute ({sqlText: sql_source_table, binds: [X,Y,Z]});  
return "Done";}
$$
;
call proc3()

Could not resolve all artifacts for configuration ‘:classpath’. > Could not find com.google.firebase:firebase-plugins:1.1.1

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring root project ‘appname’.

Could not resolve all artifacts for configuration ‘:classpath’.
Could not find com.google.firebase:firebase-plugins:1.1.1.
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/google/firebase/firebase-plugins/1.1.1/firebase-plugins-1.1.1.pom
https://jcenter.bintray.com/com/google/firebase/firebase-plugins/1.1.1/firebase-plugins-1.1.1.pom
https://maven.fabric.io/public/com/google/firebase/firebase-plugins/1.1.1/firebase-plugins-1.1.1.pom
Required by:
project :

  • Try:
    Run with –stacktrace option to get the stack trace. Run with –info or –debug option to get more log output. Run with –scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 31s
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html

React natice developer

How does If Else statement in JS replace a with another using a dropdown? [duplicate]

// if selectLang.value is spanish display: spanish-lyrics

const selectLang = document.querySelector("select");
const spanishLyrics = document.getElementById("spanish-lyrics");
let lyricText = document.getElementsByClassName("lyric-text");

selectLang.addEventListener("change", setLang);

function setLang(){
  const choice = selectLang.value;
  if (choice === "spanish"){
    lyricText.innerHTML = spanishLyrics.innerHTML;
    console.log("changed");
  } else {
    console.log("not changed");
  }
}
<div class="lang-title">
  <select>
    <option value="english">English</option>
    <option value="spanish">Spanish</option>
  </select>
</div>

<div class="lyric-text">
  <p class="verse">
    [VERSE 1]
  </p>
</div>

<div id="spanish-lyrics">
  <p class="verse">
    [VERSO 1]
  </p>
</div>

Attempted displaying results using console.log() and the console displays the <select> was changed but the change does not occur on the the webpage.

How to post latest data immediately, from firestore database?

here’s my code:

script inside html:

<script src="https://www.gstatic.com/firebasejs/10.7.1/firebase-app-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/10.7.1/firebase-firestore-compat.js"></script>
async function fetchWeatherData() {
    console.log("testing");

    //const table = document.getElementById("weather-table");
    //const collectionRef = firebase.query(
    //     db.collection("weather_data")
    //     // orderBy("datetime", "desc")
    // );
    // onSnapshot(collectionRef, (snapshot) => {
    const lists = [];

    const snapshot = await db.collection("weather_data").get();

    snapshot.docs.forEach((doc) => {
        const list = doc.data();

        if (!lists.find((l) => l.id === doc.id)) {
            lists.push({
                ...list,
                id: doc.id,
            });
        }
    });

    // const snapshot = await db.collection("weather_data").get();

    console.log("weather data", { lists });

    // const body = table.querySelector("parameter");

    // while (body.firstChild) {
    //     body.removeChild(body.firstChild);
    // }

    const list = lists?.[0];

    console.log("data", list);

    const date = list.datetime?.toDate().toDateString();
    const time = list.datetime?.toDate().toLocaleTimeString("id-Id");
    // Create a new row
    //const newRow = document.createElement("tr");

    // Create new cells and add content to them
    const timeCell = document.getElementById("waktu-kapan");
    const humidityCell = document.getElementById("humidity-value");
    const windCell = document.getElementById("kecepatan-angin-value");
    const rainfallCell = document.getElementById("curah-hujan-value");
    const soilCell = document.getElementById("kelembapan-tanah-value");
    const tempCell = document.getElementById("suhu-value");

    try {
        console.log("timeval", (list?.ts?.seconds ?? 0) * 1000);
        timeCell.textContent = `${Intl.DateTimeFormat("id-ID", {
            dateStyle: "long",
            timeStyle: "short",
        }).format(new Date((list?.ts?.seconds ?? 0) * 1000 ))}`;
    } catch (e) {
        console.error(e);
    }

    humidityCell.textContent = `${list.hum} %`;
    windCell.textContent = `${list.anemo} km/h`;
    rainfallCell.textContent = `${list.r} mm`;
    soilCell.textContent = `${list.soil}`;
    tempCell.textContent = `${list.temp} C`;

    // Append the cells to the new row
    // newRow.appendChild(timeCell);
    // newRow.appendChild(humidityCell);
    // newRow.appendChild(windCell);
    // newRow.appendChild(rainfallCell);
    // newRow.appendChild(soilCell);
    // newRow.appendChild(tempCell);

    // Append the new row to the table
    // const firstTr = table.getElementsByTagName("tbody tr")[0];
    // if (firstTr) {
    //     body.insertBefore(newRow, firstTr);
    // } else {
    //     body.appendChild(newRow);
    // }
    // });
}

// Call the function to fetch data
fetchWeatherData();

The code is working actually, but it took a long time to post data in web from firestore database. What should i do to make that latest data inside firestore database will post immediately in web?

NgInx & NodeJs deployment Getting Response Code 418

I create Application in NodeJS, EJS and deployed on Ec2 with Nginx. I used default nginx configuration for deployment. every thing is working properly but, while testing on facebook debug tool I am getting 418 response code error

enter image description here

Because of this response code Meta tag is not loading.

I tried changed configuration but it’s coludn’t work

nginx config file:

server {
     listen 80 default_server;
     listen [::]:80 default_server;
     return 301 https://$host$request_uri; 
} 
server {     
    listen 443 ssl default_server;
    listen [::]:443 ssl default_server;
    ssl_certificate **path**;
    ssl_certificate_key /etc/ssl/private/****.key;
    server_name default_server;
    # Replace with your actual domain or IP
    location / {         
    proxy_pass http://localhost:4000/;         
    proxy_set_header Host $host;         
    proxy_set_header X-Real-IP $remote_addr;         
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;         
    proxy_set_header X-Forwarded-Proto $scheme;
    }     
    # Additional SSL settings for better security
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers off;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    add_header Strict-Transport-Security "max-age=31536000" always;
    add_header X-Content-Type-Options nosniff;
    add_header X-Frame-Options SAMEORIGIN;
    add_header X-XSS-Protection "1; mode=block"; 
}

Where can I find the JavaScript file regarding to block out of stock variations in product page woocommerce

I need to modify this file in order prevent blocking some combinations out of stock

I tried to manipulate “add-to-cart-variation.js” in woocommerce/assets/js/frontend, but nothing occurs(I cleared it and javascript still works), I also tried to manipulate some php files regarding my theme but they dont change the class value to “disabled” (block product variation) but when I manually do:

wp_deregister_script( 'wc-add-to-cart-variation' );

The target javascript is died, but I can’t find the file where wc-add-to-cart-variation is recorded

using .match() to find occurrences of a character in a string. receiving null instead of matching character [duplicate]

const fdChar = (string, char) => {
  let regex = /char/gi; 
  console.log(string.match(regex)); 
}
fdChar('bacon', 'a'); 

Hello everyone,

New to coding. Reintroducing myself to regular expressions. The above function is just a test for what will be implemented into a larger piece of code for a JavaScript coding challenge. I keep receiving null in the console. I want to target certain characters in a string. Am I not able to store the argument value in my regex variable?

function call fdChar(‘bacon’, ‘a’);

expected console output: ‘a’;

received output: null

Capacitor IOS/Android: How to load images from app/play store after the app was already downloaded

I heard there is:

  • On-Demand Resources (iOS-Specific)
  • Split APKs (Android-Specific)

Which allow to download content after the initial app download, to reduce the initial bundle size. I have 1000 HQ images inside my Ionic Capacitor mobile app, the bundle size would explode. How can I host them on the respective app & play store and have the app download the resources aftwards?

I think the two mentioned methods above could do that. I think they are free to use as much as one wants, which is why I prefer them over hosting my own backend, since hosting 1000 HQ images to multiple users could make hosting the backend very expensive I think, since I think the app could reach more than 100,000 users at some point. Even when caching the images after a download, I think the single download alone could become very expensive with many users.

Is there a plugin for capacitor for those two? Afaik the two listed services are pretty similar, so a plugin could likely target both in an abstract platform-agnostic way.

If such a plugin does not exist:
what are some other ways I can use those services in my ionic capacitor app? Can I download them from within the WebView maybe? Or is there some workaround that I can use?

I would also consider writing my own plugin, but it is hard for me to estimate how much work this would be, especially to make the interface as abstract as possible to provide a pretty generic interface for both platforms. Maybe someone with experience could tell how hard of a job that would be.

Sources:

https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/On_Demand_Resources_Guide/

https://developer.android.com/build/configure-apk-splits

Why is this HTMLCollection object not allowing iteration? [closed]

I have a page with six <pre> tags on it. I want to iterate over them and do something to them. (It doesn’t really matter what, as I’ve got a minimum demonstration of the problem below.)

Unfortunately, in the code below, execution appears to halt right after I do a console.log() of the HTMLCollection. Here’s the code:

function getComparisons() {
  preTags = document.getElementsByTagName('pre');
  console.log(preTags); //Correctly shows that we have six <pre> tags on our page.
  for (i = 0; i < preTags.length; i++) {
    console.log("start"); //Also does not do anything. Let's try making our HTMLCollection object into an array instead ...
  }
  let myIterable = Array.from(preTags);
  myIterable.forEach(function (item) {
    window.console.log("finally!"); //Also does not do anything.
  });
}
getComparisons();
<tbody>

    <tr role="row" class="odd"><td data-th-text="Editor">dku</td><td data-th-text="Action">changed</td><td data-th-text="Field">ability</td><td data-th-text="JobConfiguration">66892</td><td data-th-text="Old"><pre>{
  "somekey": "someoldvalue",
  ...
  "someotherkey": "someotheroldvalue"
}</pre></td><td data-th-text="New"><pre>{
  "somekey": "someoldvalue",
  ...
  "someotherkey": "someotherNEWvalue"
}</pre></td><td data-th-text="IP">127.0.0.1</td><td class="text-right" data-th-text="Date">2023-12-28 12:00:00<a href="javascript:void(0);" data-toggle="tooltip" title="" data-original-title="Date/Time in timezone 'UTC'"><i class="fa fa-globe fa-fw"></i></a></td></tr><tr role="row" class="even"><td data-th-text="Editor">dku</td><td data-th-text="Action">changed</td><td data-th-text="Field">ability</td><td data-th-text="JobConfiguration">66893</td><td data-th-text="Old"><pre>{
  "somekey": "someoldvalue",
  "someotherkey": "someotheroldvalue"
}</pre></td><td data-th-text="New"><pre>{
  "somekey": "someoldvalue",
  "someotherkey": "someotherNEWvalue"
}</pre></td><td data-th-text="IP">127.0.0.2</td><td class="text-right" data-th-text="Date">2023-12-28 12:00:00<a href="javascript:void(0);" data-toggle="tooltip" title="" data-original-title="Date/Time in timezone 'UTC'"><i class="fa fa-globe fa-fw"></i></a></td></tr><tr role="row" class="odd"><td data-th-text="Editor">dku</td><td data-th-text="Action">changed</td><td data-th-text="Field">ability</td><td data-th-text="JobConfiguration">66894</td><td data-th-text="Old"><pre>{
  "somekey": "someoldvalue",
  "someotherkey": "someotheroldvalue"
}</pre></td><td data-th-text="New"><pre>{
  "somekey": "someoldvalue",
  "someotherkey": "someotherNEWvalue"
}</pre></td><td data-th-text="IP">127.0.0.3</td><td class="text-right" data-th-text="Date">2023-12-28 12:00:00<a href="javascript:void(0);" data-toggle="tooltip" title="" data-original-title="Date/Time in timezone 'UTC'"><i class="fa fa-globe fa-fw"></i></a></td></tr></tbody>

The problem is occurring in Chrome version 120, along with other similar browsers. I’ve tried it with and without a let in the initial loop declarations. Any ideas on other things I can try?

div not displaying results [duplicate]

I have a problem with a rock, paper, scissors game.

I get an error in chrome console saying 'Uncaught TypeError: Cannot read properties of null (reading 'addEventListener')' without even clicking on anything. And my div DOM content isn’t loaded. Here is it in codepen, however the 1st problem isn’t showing here: https://codepen.io/mofodreamer/pen/WNmvaGN

document.getElementById("rock").addEventListener("click", () => game("rock"));
document.getElementById("paper").addEventListener("click", () => game("paper"));
document.getElementById("scissors").addEventListener("click", () => game("scissors"));
function updateResult(result) {
    const resultDiv = document.getElementById("result");
    resultDiv.textContent = result;
    resultDiv.textContent = (`Your choice: ${userChoice}, the computer's: ${computerChoice}. ${result} Your score is ${userScore}, computer's score is ${computerScore}`);
}

Any ideas?

Erratic calculation of implied volatility [closed]

This function calculates implied volatility for option trading and works most of the time but during iteration, when vega = 0, it fails. I am not sure if this is the best way to find implied volatility in javascript. Can anyone help me out?

function impliedVolatility(price, S, K, T, optionType, initialGuess = 0.2) {
   
    let tolerance = 0.001;
    let maxIterations = 1000;
    let vega;
    let priceDifference;

    let sigma = initialGuess; // Reset sigma for each price
    let i = 0; // Reset iteration counter for each price
    while (i < maxIterations) {
       bsp = blackScholes(S,K,T,sigma, optionType)
       priceDifference = bsp - price;
       if (Math.abs(priceDifference) < tolerance) {
          return sigma;
       }
       let d1 = (Math.log(S / K) + (r + sigma * sigma / 2) * T) / (sigma *Math.sqrt(T));
       vega = S * distribution.pdf(d1) * Math.sqrt(T);
       if (vega === 0) {break; 
       sigma = sigma - priceDifference / vega;
       i++;
   }
    console.error('Failed to calculate implied volatility for option');
    return null;
}

Run promises sequentially in javascript

I need to run promises sequentially in this code, However console.log shows 1900 instead of showing the sum of all delays. wondering why the promises are not run in sequence?

const delay = (time: number) =>
  new Promise(res => {
    setTimeout(() => res(`promise resolved in ${time / 1000}s`), time);
  });

const times = [1000, 1000, 1000, 1900, 1150, 1000];

const samplePromises = times.map(t => delay(t));

const sequence = (promises: Promise<any>[]) => {
  return promises.reduce((chain, task) => chain.then(results => task.then(result => [...results, result])), Promise.resolve([] as any[]));
};

const start = performance.now();
sequence(samplePromises).then(res => {
  const end = performance.now();
  console.log('Time:', end - start);
  console.log(res);
});

I can see the results in an array, however console.log for Time does not show the sum of delays