问:
Python streamlit: When using element (here selectbox) within empty().container() doesn't update the variable value outside
As an example to recreate my issue I use the following code:

```<code>import streamlit as st
from time import sleep
pg = st.empty()
with pg.container():
    start = st.button("start")
if start:
    pg.empty()
    sleep(0.02)
    with pg.container():
        num = st.selectbox("select num",[0,1,2,3,4])
        print(num)
    print(f'value of num outside is: {num}')
    if num:
        pg.empty()
        sleep(0.02)
        with pg.container():
            st.text(f"you selected: {num}")
</code>```

Thank you in advance.

expected output is:
start button -> on clicked -> selectbox element (prints "0" and "value of num outside is 0" in cmd as it is the default selected option) -> on selecting any number except 0,example 2, container is emptied of the selectbox and replaced with a textbox displaying the selected number (prints "2" and "value of num outside is 2" in cmd)

what happens is:
start button -> on clicked -> selectbox element (prints "0" and "value of num outside is 0" in cmd as it is the default selected option) -> on selecting any number except 0,example 2, the selectbox is emptied from the container but no text box is displayed. And "2" or "value of num outside is 2" is not shows on cmd as well. Instead the start button is displayed again.

Body:
As an example to recreate my issue I use the following code:

import streamlit as st
from time import sleep
pg = st.empty()
with pg.container():
    start = st.button("start")
if start:
    pg.empty()
    sleep(0.02)
    with pg.container():
        num = st.selectbox("select num",[0,1,2,3,4])
        print(num)
    print(f'value of num outside is: {num}')
    if num:
        pg.empty()
        sleep(0.02)
        with pg.container():
            st.text(f"you selected: {num}")

Thank you in advance.

expected output is:
start button -> on clicked -> selectbox element (prints "0" and "value of num outside is 0" in cmd as it is the default selected option) -> on selecting any number except 0,example 2, container is emptied of the selectbox and replaced with a textbox displaying the selected number (prints "2" and "value of num outside is 2" in cmd)

what happens is:
start button -> on clicked -> selectbox element (prints "0" and "value of num outside is 0" in cmd as it is the default selected option) -> on selecting any number except 0,example 2, the selectbox is emptied from the container but no text box is displayed. And "2" or "value of num outside is 2" is not shows on cmd as well. Instead the start button is displayed again.


来源: stackexchange

问:
woocommerce custom query string problem in filter widget
I created a widget to add query var to URL to query and filter the instock products in woocommerce shop page, the query string works and return result, but when another filter such as layered navigation or sort (eg based on lower to higher price) is selected, my custom query var (instock query, ?stockstatus=instock) removed from url, and I have to select it again, then both instock and other query strings works.

my custom href tag is in this form Show In Stock Products

How can I solve this problem? any idea?

ContentLicense: CC BY-SA 4.0


问:
Problem using c.Sendfile(path) in fiber (golang web framework)
I have saved some of videos in specific paths. I want the video to be displayed when the API is called. I do this using c.SendFile(). The problem is that by calling the API once by vlc or browser, it is called several times. I realized this from fmt.Println("called").

What is the problem?

```<code>func main() {

    app := fiber.New()

    app.Get("/video", func(c *fiber.Ctx) error {
        fmt.Println("called")
        return c.SendFile("./videos/2022/12/17/1a191775-a3ab-427a-932e-ebbb3d2879b1/video-360.mp4");

      })

    app.Listen(":3030")
}
</code>```

Body:
I have saved some of videos in specific paths. I want the video to be displayed when the API is called. I do this using c.SendFile(). The problem is that by calling the API once by vlc or browser, it is called several times. I realized this from fmt.Println("called").

What is the problem?

func main() {

    app := fiber.New()

    app.Get("/video", func(c *fiber.Ctx) error {
        fmt.Println("called")
        return c.SendFile("./videos/2022/12/17/1a191775-a3ab-427a-932e-ebbb3d2879b1/video-360.mp4");

      })

    app.Listen(":3030")
}


问:
It wont show the false statement with a component in react native
so I have an interface to a site where they show us the times when to save energy. Yesterday, that still worked, but sadly today, it wont show the dates anymore.
The bigger problem is, that now, it wont even show the "false" statement anymore (ActivityIndicator) when it is not loading.

```<code>import React from 'react';
import {
  ImageBackground,
  StyleSheet,
  Text,
  View,
  Image,
  Dimensions,
} from 'react-native';
import NavigationBar from './components/NavigationBar';
import EnergySavingTimes from './components/EnergySavingTimes';

function HomeScreen({navigation}) {
  let DateMonth = new Date().getMonth() + 1;
  let DateDay = new Date().getDate();
  let DateYear = new Date().getFullYear();
  return (
    <View>
      <ImageBackground
        source={require('./components/images/BackgroundCropped.png')}
        style={styles.img}>
        <Image
          style={styles.logoEnergie}
          source={require('./components/images/BMIBild.png')}
        />
        <Text style={styles.VigorisStyle}>Vigoris</Text>
        <Text style={styles.title}>Energie-Spar-Tipp des Tages !</Text>
        <Image
          style={styles.logo}
          source={require('./components/images/EnergieSparTipp3.png')}
        />
        <Image
          style={styles.IdeaGuy}
          source={require('./components/images/IdeaGuy.png')}
        />
        <Text style={styles.titleStromsparen}>Aktuelle Stromsparzeiten</Text>
        <Text style={styles.titleProg}>
          Prognose der Stromspar-{'\n'}Stunden für {DateDay}.{DateMonth}.
          {DateYear}
        </Text>
        <Image
          style={styles.Clock}
          source={require('./components/images/Clock.png')}
        />
        <View style={styles.energySaving}>
          <EnergySavingTimes />
        </View>
        <View style={styles.NaviBar}>
          <NavigationBar navigation={navigation} />
        </View>
      </ImageBackground>
    </View>
  );
}
</code>```
```<code>import React, {Text, FlatList, View, StyleSheet} from 'react-native';
import {ActivityIndicator} from 'react-native-paper';
import {useEffect, useState} from 'react';

function EnergySavingTimes() {
  const [isLoading, setLoading] = useState(true);
  const [data, setData] = useState([]);
  const getSavingTimes = async () => {
    try {
      const response = await fetch(
        'https://awareness.cloud.apg.at/api/v1/PeakHourStatus',
      );
      const json = await response.json();
      setData(json.StatusInfos);
    } catch (error) {
      console.error(error);
    } finally {
      setLoading(false);
    }
  };

  useEffect(() => {
    getSavingTimes();
  }, []);

  let items = data.map(status => {
    return new Date(status.utc);
  });
  items = items.filter(status => {
    return status.getDay() === new Date().getDay();
  });
  let times = [];
  while (items.length > 0) {
    let startDate = items[0];
    let endDate = null;
    for (var i = 1; i < items.length; i++) {
      if (
        items[i - 1].getHours().valueOf() ===
          items[i].getHours().valueOf() - 1 &&
        items[i + 1].getHours().valueOf() === items[i].getHours().valueOf() + 1
      ) {
        continue;
      }
      endDate = items[i];
      break;
    }
    items = items.slice(i + 1, items.length);
    if (endDate === null) {
      endDate = new Date();
      endDate.setMinutes(0);
      endDate.setHours(startDate.getHours());
    }
    endDate.setHours(endDate.getHours() + 1); // we always get the beginning of the hour, we need the end
    times.push({startDate: startDate, endDate: endDate});
  }
  return (
    <View style={styles.container}>
      {isLoading ? (
        <ActivityIndicator />
      ) : (
        <FlatList
          data={times}
          renderItem={({item}) => (
            <Text style={styles.text}>
              Von {item.startDate.getHours()}:{item.startDate.getMinutes()}
              {item.startDate.getMinutes()} bis {item.endDate.getHours()}:
              {item.endDate.getMinutes()}
              {item.startDate.getMinutes()}
            </Text>
          )}
        />
      )}
    </View>
  );
}
</code>```

I tried to enter a Text instead of the  but it wont even show a Text on the HomeScreen.js

Body:
so I have an interface to a site where they show us the times when to save energy. Yesterday, that still worked, but sadly today, it wont show the dates anymore.
The bigger problem is, that now, it wont even show the "false" statement anymore (ActivityIndicator) when it is not loading.

import React from 'react';
import {
  ImageBackground,
  StyleSheet,
  Text,
  View,
  Image,
  Dimensions,
} from 'react-native';
import NavigationBar from './components/NavigationBar';
import EnergySavingTimes from './components/EnergySavingTimes';

function HomeScreen({navigation}) {
  let DateMonth = new Date().getMonth() + 1;
  let DateDay = new Date().getDate();
  let DateYear = new Date().getFullYear();
  return (
    <View>
      <ImageBackground
        source={require('./components/images/BackgroundCropped.png')}
        style={styles.img}>
        <Image
          style={styles.logoEnergie}
          source={require('./components/images/BMIBild.png')}
        />
        <Text style={styles.VigorisStyle}>Vigoris</Text>
        <Text style={styles.title}>Energie-Spar-Tipp des Tages !</Text>
        <Image
          style={styles.logo}
          source={require('./components/images/EnergieSparTipp3.png')}
        />
        <Image
          style={styles.IdeaGuy}
          source={require('./components/images/IdeaGuy.png')}
        />
        <Text style={styles.titleStromsparen}>Aktuelle Stromsparzeiten</Text>
        <Text style={styles.titleProg}>
          Prognose der Stromspar-{'\n'}Stunden für {DateDay}.{DateMonth}.
          {DateYear}
        </Text>
        <Image
          style={styles.Clock}
          source={require('./components/images/Clock.png')}
        />
        <View style={styles.energySaving}>
          <EnergySavingTimes />
        </View>
        <View style={styles.NaviBar}>
          <NavigationBar navigation={navigation} />
        </View>
      </ImageBackground>
    </View>
  );
}

import React, {Text, FlatList, View, StyleSheet} from 'react-native';
import {ActivityIndicator} from 'react-native-paper';
import {useEffect, useState} from 'react';

function EnergySavingTimes() {
  const [isLoading, setLoading] = useState(true);
  const [data, setData] = useState([]);
  const getSavingTimes = async () => {
    try {
      const response = await fetch(
        'https://awareness.cloud.apg.at/api/v1/PeakHourStatus',
      );
      const json = await response.json();
      setData(json.StatusInfos);
    } catch (error) {
      console.error(error);
    } finally {
      setLoading(false);
    }
  };

  useEffect(() => {
    getSavingTimes();
  }, []);

  let items = data.map(status => {
    return new Date(status.utc);
  });
  items = items.filter(status => {
    return status.getDay() === new Date().getDay();
  });
  let times = [];
  while (items.length > 0) {
    let startDate = items[0];
    let endDate = null;
    for (var i = 1; i < items.length; i++) {
      if (
        items[i - 1].getHours().valueOf() ===
          items[i].getHours().valueOf() - 1 &&
        items[i + 1].getHours().valueOf() === items[i].getHours().valueOf() + 1
      ) {
        continue;
      }
      endDate = items[i];
      break;
    }
    items = items.slice(i + 1, items.length);
    if (endDate === null) {
      endDate = new Date();
      endDate.setMinutes(0);
      endDate.setHours(startDate.getHours());
    }
    endDate.setHours(endDate.getHours() + 1); // we always get the beginning of the hour, we need the end
    times.push({startDate: startDate, endDate: endDate});
  }
  return (
    <View style={styles.container}>
      {isLoading ? (
        <ActivityIndicator />
      ) : (
        <FlatList
          data={times}
          renderItem={({item}) => (
            <Text style={styles.text}>
              Von {item.startDate.getHours()}:{item.startDate.getMinutes()}
              {item.startDate.getMinutes()} bis {item.endDate.getHours()}:
              {item.endDate.getMinutes()}
              {item.startDate.getMinutes()}
            </Text>
          )}
        />
      )}
    </View>
  );
}

I tried to enter a Text instead of the  but it wont even show a Text on the HomeScreen.js


问:
How to map unknown property by using Automapper?
I am new to Automapper. I got stack to map unknown property.

Here is my entity class

company entity

`

```<code>public string CompanyName { get; set; }
        public string CompanyCode {get; set;}

        [ForeignKey("CityId")]
        public int CityId {get; set;}
        public City City {get; set;}
        public string Address {get; set;}
</code>```

`

CompanyDto

`

```<code>      public string CompanyName {get; set;}

        public string CompanyCode {get; set;}

        public int CityId {get; set;}

        public string Address {get; set;}

        publig Hashset<Bank> BankList = new Hashset<Bank>()
</code>```

`

in my companyDto banklist is new property which is not available in company entity. so how do I map this by using automapper. I've tried from different sources. and I tried with projectTo method but didn't get proper result. I just want to return the company entity with bank list.

Body:
I am new to Automapper. I got stack to map unknown property.

Here is my entity class

company entity

`

public string CompanyName { get; set; }
        public string CompanyCode {get; set;}

        [ForeignKey("CityId")]
        public int CityId {get; set;}
        public City City {get; set;}
        public string Address {get; set;}

`

CompanyDto

`

      public string CompanyName {get; set;}

        public string CompanyCode {get; set;}

        public int CityId {get; set;}

        public string Address {get; set;}

        publig Hashset<Bank> BankList = new Hashset<Bank>()

`

in my companyDto banklist is new property which is not available in company entity. so how do I map this by using automapper. I've tried from different sources. and I tried with projectTo method but didn't get proper result. I just want to return the company entity with bank list.


问:
sorting messages, obj comparison is greyed out and is asking to be replaced with "comparator.comparing", which doesn't work
this code here, after the sort method, the obj1 and obj2 comparison is greyed out, and the editor suggests to convert it into Comparator.comparing, which does not do the job and the chats of the reciever stays as a sticky constant, while sender chats keep going above it,

```<code>```
Collections.sort(chatMessages,
                    (obj1, obj2) -> obj1.dateObject.compareTo(obj2.dateObject));
            if(count == 0) {
                chatAdapter.notifyDataSetChanged();

} else {
}
```
```//new lines of code that seem to work
chatMessages.sort(Comparator.comparing(obj -> obj.dateObject));
            if(count == 0) {
                chatAdapter.notifyDataSetChanged();
```

and the last part, to be more specific with change of events, and use notifyDataSetChanged() as a last resort.

Body:
this code here, after the sort method, the obj1 and obj2 comparison is greyed out, and the editor suggests to convert it into Comparator.comparing, which does not do the job and the chats of the reciever stays as a sticky constant, while sender chats keep going above it,

```
Collections.sort(chatMessages,
                    (obj1, obj2) -> obj1.dateObject.compareTo(obj2.dateObject));
            if(count == 0) {
                chatAdapter.notifyDataSetChanged();

} else {
}

//new lines of code that seem to work
chatMessages.sort(Comparator.comparing(obj -> obj.dateObject));
            if(count == 0) {
                chatAdapter.notifyDataSetChanged();

and the last part, to be more specific with change of events, and use notifyDataSetChanged() as a last resort.


问:
Filterable Image Gallery Matching Problem
The problem is exactly when I click on the buttons above, I want the places I assign "data-category" to come, but there may be a problem with the codes I wrote in javascript. I tried a question class problem. I don't want you to get stuck on the hover feature, that's not the problem. I just want the items to come up when I click. thanks.

const imageGallery = document.querySelector("#img-filter");
const filterOptions = imageGallery.querySelectorAll(".filter-options button");
const parentinner = document.querySelectorAll("[data-category]");

const showImages = (category) => {
  parentinner.forEach((image) => {
    if (
      image.getAttribute("data-category") === category ||
      category === "all"
    ) {
      image.style.display = "block";
    } else {
      image.style.display = "none";
    }
  });
};

filterOptions.forEach((button) => {
  button.addEventListener("click", () => {
    const category = button.getAttribute("data-filter");
    showImages(category);
  });
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>section .projects .filter-options button {
  border: none;
  border: 1px solid #c4c2c2;
  font-size: 13px;
  font-weight: 500;
  background: #fff;
}

section .projects .filter-options button:hover {
  background: #0d6efd;
  color: #fff;
}

section .parent {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
  grid-column-gap: 0px;
  grid-row-gap: 0px;
}

section .div1 {
  grid-area: 1 / 1 / 2 / 2;
  display: none;
}

section .div2 {
  grid-area: 1 / 2 / 3 / 3;
  display: none;
}

section .div3 {
  grid-area: 1 / 3 / 2 / 4;
  display: none;
}

section .div4 {
  grid-area: 1 / 4 / 3 / 5;
  display: none;
}

section .div5 {
  grid-area: 2 / 1 / 3 / 2;
  display: none;
}

section .div6 {
  grid-area: 2 / 3 / 3 / 4;
  display: none;
}

section .parent .div1,
section .parent .div2,
section .parent .div3,
section .parent .div4,
section .parent .div5,
section .parent .div6 {
  position: relative;
  display: block;
}

section .parent .info-hover {
  position: absolute;
  width: 100%;
  height: 100%;
  background: rgba(161, 0, 161, 0.75);
  opacity: 0;
  transition: opacity ease-in-out 0.5s;
}

section .parent .info-hover h6 {
  padding: 5px 12px;
  font-size: 13px;
  border: none;
  background: #fff;
  border-radius: 13px;
  width: 86.5px;
}

section .parent .info-hover .a-down {
  background-color: #fff;
  width: 40px;
  height: 40px;
  text-align: center;
}

section .parent .info-hover .a-sub a:hover {
  opacity: 0.8;
}

section .parent .div1:hover .info-hover,
section .parent .div2:hover .info-hover,
section .parent .div3:hover .info-hover,
section .parent .div4:hover .info-hover,
section .parent .div5:hover .info-hover,
section .parent .div6:hover .info-hover {
  opacity: 1;
}

@media (max-width: 991.98px) {
  section .parent {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(4, 1fr);
    grid-column-gap: 0px;
    grid-row-gap: 0px;
  }
  section .div1 {
    grid-area: 1 / 1 / 2 / 2;
  }
  section .div2 {
    grid-area: 1 / 2 / 3 / 3;
  }
  section .div3 {
    grid-area: 2 / 1 / 3 / 2;
  }
  section .div4 {
    grid-area: 3 / 1 / 5 / 2;
  }
  section .div5 {
    grid-area: 3 / 2 / 4 / 3;
  }
  section .div6 {
    grid-area: 4 / 2 / 5 / 3;
  }
}

@media (max-width: 767.98px) {
  section .parent {
    display: grid;
    grid-template-columns: repeat(1fr);
    grid-template-rows: repeat(8, 1fr);
    grid-column-gap: 0px;
    grid-row-gap: 0px;
  }
  section .div1 {
    grid-area: 1 / 1 / 2 / 3;
  }
  section .div2 {
    grid-area: 2 / 1 / 4 / 3;
  }
  section .div3 {
    grid-area: 4 / 1 / 5 / 3;
  }
  section .div4 {
    grid-area: 5 / 1 / 7 / 3;
  }
  section .div5 {
    grid-area: 7 / 1 / 8 / 3;
  }
  section .div6 {
    grid-area: 8 / 1 / 9 / 3;
  }
}</code>```

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="style.css">
<link href="https://cdn.lineicons.com/3.0/lineicons.css" rel="stylesheet">

          <button type="button" class="bg-primary text-white rounded-5 px-3 py-2 me-2" data-filter="all">Show All</button>

          <button type="button" class="rounded-5 px-3 py-2 me-2" data-filter="marketing">Marketing</button>

          <button type="button" class="rounded-5 px-3 py-2 me-2" data-filter="business">Business</button>

          <button type="button" class="rounded-5 px-3 py-2 me-2 mt-3 mt-sm-0" data-filter="finance">Finance</button>

          <button type="button" class="rounded-5 px-3 py-2 mt-3 mt-md-0" data-filter="consulting">Consulting</button>

Marketing

              Stock Market Analysis

Business

              Sales Analysis

Marketing

              Stock Investments

Business

              Big Data Services

Finance

              Sales Enablement

Consulting

              Consulting Services

```

Body:
The problem is exactly when I click on the buttons above, I want the places I assign "data-category" to come, but there may be a problem with the codes I wrote in javascript. I tried a question class problem. I don't want you to get stuck on the hover feature, that's not the problem. I just want the items to come up when I click. thanks.

const imageGallery = document.querySelector("#img-filter");
const filterOptions = imageGallery.querySelectorAll(".filter-options button");
const parentinner = document.querySelectorAll("[data-category]");

const showImages = (category) => {
  parentinner.forEach((image) => {
    if (
      image.getAttribute("data-category") === category ||
      category === "all"
    ) {
      image.style.display = "block";
    } else {
      image.style.display = "none";
    }
  });
};

filterOptions.forEach((button) => {
  button.addEventListener("click", () => {
    const category = button.getAttribute("data-filter");
    showImages(category);
  });
});

section .projects .filter-options button {
  border: none;
  border: 1px solid #c4c2c2;
  font-size: 13px;
  font-weight: 500;
  background: #fff;
}

section .projects .filter-options button:hover {
  background: #0d6efd;
  color: #fff;
}

section .parent {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
  grid-column-gap: 0px;
  grid-row-gap: 0px;
}

section .div1 {
  grid-area: 1 / 1 / 2 / 2;
  display: none;
}

section .div2 {
  grid-area: 1 / 2 / 3 / 3;
  display: none;
}

section .div3 {
  grid-area: 1 / 3 / 2 / 4;
  display: none;
}

section .div4 {
  grid-area: 1 / 4 / 3 / 5;
  display: none;
}

section .div5 {
  grid-area: 2 / 1 / 3 / 2;
  display: none;
}

section .div6 {
  grid-area: 2 / 3 / 3 / 4;
  display: none;
}

section .parent .div1,
section .parent .div2,
section .parent .div3,
section .parent .div4,
section .parent .div5,
section .parent .div6 {
  position: relative;
  display: block;
}

section .parent .info-hover {
  position: absolute;
  width: 100%;
  height: 100%;
  background: rgba(161, 0, 161, 0.75);
  opacity: 0;
  transition: opacity ease-in-out 0.5s;
}

section .parent .info-hover h6 {
  padding: 5px 12px;
  font-size: 13px;
  border: none;
  background: #fff;
  border-radius: 13px;
  width: 86.5px;
}

section .parent .info-hover .a-down {
  background-color: #fff;
  width: 40px;
  height: 40px;
  text-align: center;
}

section .parent .info-hover .a-sub a:hover {
  opacity: 0.8;
}

section .parent .div1:hover .info-hover,
section .parent .div2:hover .info-hover,
section .parent .div3:hover .info-hover,
section .parent .div4:hover .info-hover,
section .parent .div5:hover .info-hover,
section .parent .div6:hover .info-hover {
  opacity: 1;
}

@media (max-width: 991.98px) {
  section .parent {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(4, 1fr);
    grid-column-gap: 0px;
    grid-row-gap: 0px;
  }
  section .div1 {
    grid-area: 1 / 1 / 2 / 2;
  }
  section .div2 {
    grid-area: 1 / 2 / 3 / 3;
  }
  section .div3 {
    grid-area: 2 / 1 / 3 / 2;
  }
  section .div4 {
    grid-area: 3 / 1 / 5 / 2;
  }
  section .div5 {
    grid-area: 3 / 2 / 4 / 3;
  }
  section .div6 {
    grid-area: 4 / 2 / 5 / 3;
  }
}

@media (max-width: 767.98px) {
  section .parent {
    display: grid;
    grid-template-columns: repeat(1fr);
    grid-template-rows: repeat(8, 1fr);
    grid-column-gap: 0px;
    grid-row-gap: 0px;
  }
  section .div1 {
    grid-area: 1 / 1 / 2 / 3;
  }
  section .div2 {
    grid-area: 2 / 1 / 4 / 3;
  }
  section .div3 {
    grid-area: 4 / 1 / 5 / 3;
  }
  section .div4 {
    grid-area: 5 / 1 / 7 / 3;
  }
  section .div5 {
    grid-area: 7 / 1 / 8 / 3;
  }
  section .div6 {
    grid-area: 8 / 1 / 9 / 3;
  }
}

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="style.css">
<link href="https://cdn.lineicons.com/3.0/lineicons.css" rel="stylesheet">

          <button type="button" class="bg-primary text-white rounded-5 px-3 py-2 me-2" data-filter="all">Show All</button>

          <button type="button" class="rounded-5 px-3 py-2 me-2" data-filter="marketing">Marketing</button>

          <button type="button" class="rounded-5 px-3 py-2 me-2" data-filter="business">Business</button>

          <button type="button" class="rounded-5 px-3 py-2 me-2 mt-3 mt-sm-0" data-filter="finance">Finance</button>

          <button type="button" class="rounded-5 px-3 py-2 mt-3 mt-md-0" data-filter="consulting">Consulting</button>

Marketing

              Stock Market Analysis

Business

              Sales Analysis

Marketing

              Stock Investments

Business

              Big Data Services

Finance

              Sales Enablement

Consulting

              Consulting Services


问:
How to test props passed from parent component in Jest
when testing props passed down from the parent component, the props (useState) does not update. I have tried update API form Enzyme but not to avail. I need to handle state in the parent component (home.tsx) for when I make api call. I am honestly pretty new to testing and wonder if using Cypress would be more beneficial in this specific case. Appreciate your help in advance.

```<code>// home.tsx

function Home() {
  const [userInfo, setUserInfo] = useState({
    firstName: "",
    lastName: "",
    emailAddress: "",
  });

  const handleSubmit = async (e: FormEvent<HTMLFormElement>) => {
    e.preventDefault();
    // handle submit
  };

  return (
    <>
      <form onSubmit={handleSubmit}>
          <UserInputForm
            userInfo={userInfo}
            setUserInfo={setUserInfo}
          />
      </form>
    </>
  );
}

export default Home;
</code>```
```<code>// user-input-form.tsx

import React, { useState } from "react";
import ErrorMessageDisplay from "../commons/error-message/error-message";
import { ButtonContainer } from "../commons/nav-button/style";

interface UserInputFormProps {
  userInfo: UserInputFormType;
  setUserInfo: React.Dispatch<React.SetStateAction<UserInputFormType>>;
}

export interface UserInputFormType {
  firstName: string;
  lastName: string;
  emailAddress: string;
}

function UserInputForm({
  userInfo,
  setUserInfo,
}: UserInputFormProps) {
  const [errorMessage, setErrorMessage] = useState({
    firstName: "",
    lastName: "",
    emailAddress: "",
  });

  const handleSetErrorMessage = (key: string, message: string) => {
    setErrorMessage((prevUserInfo) => ({
      ...prevUserInfo,
      [key]: message,
    }));
  };

  const handleUserInfo = (
    e: React.ChangeEvent<HTMLInputElement | HTMLSelectElement>
  ) => {
    setUserInfo((prevUserInfo) => ({
      ...prevUserInfo,
      [e.target.name]: e.target.value,
    }));
  };

  return (
    <Container>
      <Title>Please Enter User Information</Title>
      <label>
        <FieldContainer>
          <LabelTextBox>
            <LabelText>First Name</LabelText>
            <ErrorMessageDisplay text={errorMessage.firstName} />
          </LabelTextBox>
          <InputBox data-testid="user-information-input">
            <input
              name="firstName"
              type="text"
              placeholder="First Name"
              aria-label="firstName-input"
              onChange={handleUserInfo}
              value={userInfo.firstName}
              aria-label="firstName-input"
            />
          </InputBox>
        </FieldContainer>
      </label>
      <label>
        <FieldContainer>
          <LabelTextBox>
            <LabelText>Last Name</LabelText>
            <ErrorMessageDisplay text={errorMessage.lastName} />
          </LabelTextBox>
          <InputBox>
            <input
              name="lastName"
              type="text"
              placeholder="Last Name"
              onChange={handleUserInfo}
              value={userInfo.lastName}
              aria-label="lastName-input"
            />
          </InputBox>
        </FieldContainer>
      </label>
      <label>
        <FieldContainer>
          <LabelTextBox>
            <LabelText>Email</LabelText>
            <ErrorMessageDisplay text={errorMessage.emailAddress} />
          </LabelTextBox>
          <InputBox>
            <input
              name="emailAddress"
              type="email"
              value={userInfo.emailAddress}
              onChange={handleUserInfo}
              aria-label="emailAddress-input"
            />
          </InputBox>
        </FieldContainer>
      </label>
      <ButtonContainer>
         <button>submit</button>
      </ButtonContainer>
    </Container>
  );
}

export default UserInputForm;

</code>```
```<code>// user-input-form.test.tsx
import { fireEvent, render, screen } from "@testing-library/react";
import React from "react";
import userEvent from "@testing-library/user-event";

const setup = () => {
  const onClickCallback = jest.fn();
  const myInitialState = {
    firstName: "",
    lastName: "",
    fnameKana: "",
    lnameKana: "",
    gender: "",
    age: "",
    vehicleType: "",
    postCode: "",
    city: "",
    address: "",
    emailAddress: "",
  };
  const utils = render(
    <UserInputForm
      userInfo={myInitialState}
      setUserInfo={onClickCallback}
    />
  );
  const input = utils.getByLabelText('firstName-input')
  return {
    input,
    ...utils,
  };
};

test("it checks input validation", () => {
  const { input, ...utils } = setup();
  fireEvent.change(input, { target: { value: "not so test" } });
  expect((input as HTMLInputElement).value).toBe("not so test");
});
</code>```

test props from parent component. state did not update after simulating change in test.

Body:
when testing props passed down from the parent component, the props (useState) does not update. I have tried update API form Enzyme but not to avail. I need to handle state in the parent component (home.tsx) for when I make api call. I am honestly pretty new to testing and wonder if using Cypress would be more beneficial in this specific case. Appreciate your help in advance.

// home.tsx

function Home() {
  const [userInfo, setUserInfo] = useState({
    firstName: "",
    lastName: "",
    emailAddress: "",
  });

  const handleSubmit = async (e: FormEvent<HTMLFormElement>) => {
    e.preventDefault();
    // handle submit
  };

  return (
    <>
      <form onSubmit={handleSubmit}>
          <UserInputForm
            userInfo={userInfo}
            setUserInfo={setUserInfo}
          />
      </form>
    </>
  );
}

export default Home;

// user-input-form.tsx

import React, { useState } from "react";
import ErrorMessageDisplay from "../commons/error-message/error-message";
import { ButtonContainer } from "../commons/nav-button/style";

interface UserInputFormProps {
  userInfo: UserInputFormType;
  setUserInfo: React.Dispatch<React.SetStateAction<UserInputFormType>>;
}

export interface UserInputFormType {
  firstName: string;
  lastName: string;
  emailAddress: string;
}

function UserInputForm({
  userInfo,
  setUserInfo,
}: UserInputFormProps) {
  const [errorMessage, setErrorMessage] = useState({
    firstName: "",
    lastName: "",
    emailAddress: "",
  });

  const handleSetErrorMessage = (key: string, message: string) => {
    setErrorMessage((prevUserInfo) => ({
      ...prevUserInfo,
      [key]: message,
    }));
  };

  const handleUserInfo = (
    e: React.ChangeEvent<HTMLInputElement | HTMLSelectElement>
  ) => {
    setUserInfo((prevUserInfo) => ({
      ...prevUserInfo,
      [e.target.name]: e.target.value,
    }));
  };

  return (
    <Container>
      <Title>Please Enter User Information</Title>

        <FieldContainer>
          <LabelTextBox>
            <LabelText>First Name</LabelText>
            <ErrorMessageDisplay text={errorMessage.firstName} />
          </LabelTextBox>
          <InputBox data-testid="user-information-input">
            <input
              name="firstName"
              type="text"
              placeholder="First Name"
              aria-label="firstName-input"
              onChange={handleUserInfo}
              value={userInfo.firstName}
              aria-label="firstName-input"
            />
          </InputBox>
        </FieldContainer>

        <FieldContainer>
          <LabelTextBox>
            <LabelText>Last Name</LabelText>
            <ErrorMessageDisplay text={errorMessage.lastName} />
          </LabelTextBox>
          <InputBox>
            <input
              name="lastName"
              type="text"
              placeholder="Last Name"
              onChange={handleUserInfo}
              value={userInfo.lastName}
              aria-label="lastName-input"
            />
          </InputBox>
        </FieldContainer>

        <FieldContainer>
          <LabelTextBox>
            <LabelText>Email</LabelText>
            <ErrorMessageDisplay text={errorMessage.emailAddress} />
          </LabelTextBox>
          <InputBox>
            <input
              name="emailAddress"
              type="email"
              value={userInfo.emailAddress}
              onChange={handleUserInfo}
              aria-label="emailAddress-input"
            />
          </InputBox>
        </FieldContainer>

      <ButtonContainer>
         <button>submit</button>
      </ButtonContainer>
    </Container>
  );
}

export default UserInputForm;

// user-input-form.test.tsx
import { fireEvent, render, screen } from "@testing-library/react";
import React from "react";
import userEvent from "@testing-library/user-event";

const setup = () => {
  const onClickCallback = jest.fn();
  const myInitialState = {
    firstName: "",
    lastName: "",
    fnameKana: "",
    lnameKana: "",
    gender: "",
    age: "",
    vehicleType: "",
    postCode: "",
    city: "",
    address: "",
    emailAddress: "",
  };
  const utils = render(
    <UserInputForm
      userInfo={myInitialState}
      setUserInfo={onClickCallback}
    />
  );
  const input = utils.getByLabelText('firstName-input')
  return {
    input,
    ...utils,
  };
};

test("it checks input validation", () => {
  const { input, ...utils } = setup();
  fireEvent.change(input, { target: { value: "not so test" } });
  expect((input as HTMLInputElement).value).toBe("not so test");
});

test props from parent component. state did not update after simulating change in test.


问:
Scrape API service for multiple users with Nodejs
I need to create a service that scrapes a 3rd party site using the cookies/session of each user that makes the request.

I need this service to handle only 1 request at the time and then put the other requests in queue, because I want to avoid the users getting flagged or banned and my server from getting blocked.

For this purpose I was naively using setTimeouts to hardcode delays between each GET and POST request that my server made.

After a moment I remembered that NodeJS is async by nature and doesn't offer a way to handle threads right away. I'm not sure if the setTimeouts are doing what I'm thinking because my server is not pausing for the time I coded the setTimeouts between GET and POST requests to the 3rd party server.

Is NodeJS a good fit for this?

How can I code it in my Express server?

What are my alternatives?

Can you provide an example?


问:
Calculated data return NaN even it is number
I develop a car rental system. I want to calculate the total price which is rental price times days. The price is from the Car model database in MongoDB and the days are from the search date range.

I use the react-date-range for user to select date input.

```<code>const [date, setDate] = useState([
    {
      startDate: new Date(),
      endDate: new Date(),
      key: "selection",
    },
  ]);

// form for get date range
<div className="w-full flex gap-4 items-center  border border-main-color-alt rounded-full py-3 px-4 relative">
    <FaCalendarAlt className="text-lg main-color-alt" />
    <span onClick={() => setOpenDate(!openDate)}>
        {`${format(date[0].startDate, "MM/dd/yyyy")} to
               ${format(date[0].endDate,"MM/dd/yyyy")}`}
    </span>
    {openDate && (
        <DateRange
         className="absolute top-10 left-4 z-20"
         editableDateInputs={true}
         onChange={(item) => setDate([item.selection])}
         moveRangeOnFirstSelection={false}
         ranges={date}/>)}
</div>
</code>```

Then I calculate the input date to get the total days

 // calculate days
  const MILISECONDS_PER_DAY = 1000 * 60 * 60 * 24;
  function dayDifference(date1, date2) {
    const timeDiff = Math.abs(date2.getTime() - date1.getTime());
    const diffDays = Math.ceil(timeDiff / MILISECONDS_PER_DAY);
    return diffDays;
  }

  const days = dayDifference(date[0].endDate, date[0].startDate);

// calculate total price
  const tPrice = days * data.price;

// get start date
  const start = date[0].startDate;

// get end date
  const end = date[0].endDate;
```
<p>The price is in the <code>Car</code> model database that store in MongoDB. Below are the <code>Car</code> model.</p>
```import mongoose from "mongoose";

const CarSchema = new mongoose.Schema(
  {
    name: {
      type: String,
      required: true,
    },
    seater: {
      type: String,
      required: true,
    },
    petrol: {
      type: String,
      required: true,
    },
    transmission: {
      type: String,
      required: true,
    },
    price: {
      type: Number,
      required: true,
    },
    location: {
      type: String,
      required: true,
    },
    pickUpLocation: {
      type: String,
      required: true,
    },
    dropOffLocation: {
      type: String,
      required: true,
    },
    frontPic: {
      type: String,
    },
    backPic: {
      type: String,
    },
    interiorPic: {
      type: String,
    },
    booking: {
      type: [String],
    },
    ratings: {
      type: [String],
    },
  },
  { timestamps: true }
);

export default mongoose.model("Car", CarSchema);
```
<p>I fetch data from mongoDB and then I create a <code>useState</code> to get the input data to insert into <code>Booking</code> model database. I try to console log the <code>input</code> but the price return <code>Nan</code>.</p>
<pre class="lang-js prettyprint-override"><code>  // get input for db
  const [input] = useState({
    totalDays: days,
    // totalPrice: tPrice,
    pickUpDate: start,
    dropOffDate: end,
  });
</code>```

But when I console log the days, data.price and tPrice which is the calculated total price, it return the value. Below are the result when I console log

```<code>  console.log(input);
  console.log(days, data.price, tPrice);
</code>```

console.log

Was it because the type is Number? But when I change it to String, it return undefined.

Body:
I develop a car rental system. I want to calculate the total price which is rental price times days. The price is from the Car model database in MongoDB and the days are from the search date range.

I use the react-date-range for user to select date input.

const [date, setDate] = useState([
    {
      startDate: new Date(),
      endDate: new Date(),
      key: "selection",
    },
  ]);

// form for get date range

    <FaCalendarAlt className="text-lg main-color-alt" />
     setOpenDate(!openDate)}>
        {`${format(date[0].startDate, "MM/dd/yyyy")} to
               ${format(date[0].endDate,"MM/dd/yyyy")}`}

    {openDate && (
        <DateRange
         className="absolute top-10 left-4 z-20"
         editableDateInputs={true}
         onChange={(item) => setDate([item.selection])}
         moveRangeOnFirstSelection={false}
         ranges={date}/>)}

Then I calculate the input date to get the total days

 // calculate days
  const MILISECONDS_PER_DAY = 1000 * 60 * 60 * 24;
  function dayDifference(date1, date2) {
    const timeDiff = Math.abs(date2.getTime() - date1.getTime());
    const diffDays = Math.ceil(timeDiff / MILISECONDS_PER_DAY);
    return diffDays;
  }

  const days = dayDifference(date[0].endDate, date[0].startDate);

// calculate total price
  const tPrice = days * data.price;

// get start date
  const start = date[0].startDate;

// get end date
  const end = date[0].endDate;

The price is in the Car model database that store in MongoDB. Below are the Car model.

import mongoose from "mongoose";

const CarSchema = new mongoose.Schema(
  {
    name: {
      type: String,
      required: true,
    },
    seater: {
      type: String,
      required: true,
    },
    petrol: {
      type: String,
      required: true,
    },
    transmission: {
      type: String,
      required: true,
    },
    price: {
      type: Number,
      required: true,
    },
    location: {
      type: String,
      required: true,
    },
    pickUpLocation: {
      type: String,
      required: true,
    },
    dropOffLocation: {
      type: String,
      required: true,
    },
    frontPic: {
      type: String,
    },
    backPic: {
      type: String,
    },
    interiorPic: {
      type: String,
    },
    booking: {
      type: [String],
    },
    ratings: {
      type: [String],
    },
  },
  { timestamps: true }
);

export default mongoose.model("Car", CarSchema);

I fetch data from mongoDB and then I create a useState to get the input data to insert into Booking model database. I try to console log the input but the price return Nan.

  // get input for db
  const [input] = useState({
    totalDays: days,
    // totalPrice: tPrice,
    pickUpDate: start,
    dropOffDate: end,
  });

But when I console log the days, data.price and tPrice which is the calculated total price, it return the value. Below are the result when I console log

  console.log(input);
  console.log(days, data.price, tPrice);

console.log

Was it because the type is Number? But when I change it to String, it return undefined.


问:
One of my WordPress website pages is not loading -- The Contact Page
The Contact page of my WordPress website is not loading. It is a simple page that contains a contact form (from fleunt forms plug in) and contact information such as email, phone number, and address. All my other pages use the same plugins (except fluent forms) used for the contact page. I had disabled and enabled "fluent forms" but still didn't fix the issue.

Kindly help!


问:
Missing script :"start" while using npm start
After creating a React app, while running a React app using npm start, raising error:

npm ERR! Missing script: "start"
npm ERR!
npm ERR! Did you mean one of these?
npm ERR!     npm star # Mark your favorite packages
npm ERR!     npm stars # View packages marked as favorites
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR!   npm run

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\91910\AppData\Local\npm-cache\_logs\2022-12-17T09_33_29_043Z-debug-0.log
```
<p>package.json has "start" already:</p>
<pre class="lang-json prettyprint-override"><code>"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
</code>```

Body:
After creating a React app, while running a React app using npm start, raising error:

npm ERR! Missing script: "start"
npm ERR!
npm ERR! Did you mean one of these?
npm ERR!     npm star # Mark your favorite packages
npm ERR!     npm stars # View packages marked as favorites
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR!   npm run

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\91910\AppData\Local\npm-cache\_logs\2022-12-17T09_33_29_043Z-debug-0.log

package.json has "start" already:

"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },


问:
How to use exclamation in HTML using replit
How to use "!" option in replit like we use it in VS code?
If we type ! in VS code it will autofill the program like in the provided image but i can see that option in replit and i can't fill it</p>


问:
sbt and Java compatibility
I've download sbt-1.8.0, when I try to run sbt I receive error :

```<code>\Downloads\sbt-1.8.0>sbt
[warn] Neither build.sbt nor a 'project' directory in the current directory: C:\Users\fff\Downloads\sbt-1.8.0
c) continue
q) quit
? c
Unrecognized VM option 'MaxPermSize=256m'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
The filename, directory name, or volume label syntax is incorrect.
Unrecognized VM option 'MaxPermSize=256m'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Unrecognized VM option 'MaxPermSize=256m'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
</code>```

I'm using Java 11 version :

```<code>\Downloads\sbt-1.8.0>java -version
openjdk version "11.0.16.1" 2022-08-12
OpenJDK Runtime Environment Temurin-11.0.16.1+1 (build 11.0.16.1+1)
OpenJDK 64-Bit Server VM Temurin-11.0.16.1+1 (build 11.0.16.1+1, mixed mode)
</code>```

My understanding is that MaxPermSize support has been removed from Java post version 8 ? Is sbt1.8 not compatible with Java 11 ?

Title: sbt and Java compatibility

Body:
I've download sbt-1.8.0, when I try to run sbt I receive error :

\Downloads\sbt-1.8.0>sbt
[warn] Neither build.sbt nor a 'project' directory in the current directory: C:\Users\fff\Downloads\sbt-1.8.0
c) continue
q) quit
? c
Unrecognized VM option 'MaxPermSize=256m'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
The filename, directory name, or volume label syntax is incorrect.
Unrecognized VM option 'MaxPermSize=256m'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Unrecognized VM option 'MaxPermSize=256m'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

I'm using Java 11 version :

\Downloads\sbt-1.8.0>java -version
openjdk version "11.0.16.1" 2022-08-12
OpenJDK Runtime Environment Temurin-11.0.16.1+1 (build 11.0.16.1+1)
OpenJDK 64-Bit Server VM Temurin-11.0.16.1+1 (build 11.0.16.1+1, mixed mode)

My understanding is that MaxPermSize support has been removed from Java post version 8 ? Is sbt1.8 not compatible with Java 11 ?


问:
How to change the MediaWiki base URL?
I installed the Bitnami MediaWiki on Google Cloud and registered a new domain name (e.g. http://example.com) then redirected it to my MediaWiki IP.

I then changed $wgServer in LocalSettings.php to reflect my new domain.

The $wgScriptPath variable in LocalSettings.php remained $wgScriptPath = '' as before.

Typing http://example.com in the browser gets me to my MediaWiki site, however the URL still remains an IP address (i.e. http://xx.xxx.xx.xx/wiki/Main_Page).

How do I make it such that the base URL changes to the new domain name (i.e. http://example.com/wiki/Main_Page)?

Title: How to change the MediaWiki base URL?


问:
Eureka Server cannot register clients
I am new in the microservices world and I came up with a weird problem. The eureka Discovery Server works properly but i cannot register my clients on it.

This is my parent Pom file

Client Pom File

Client Properties

Api-Gateway Pom File

Api-Gateway Properties

Those are all my versioning and properties files, i will also add some screenshots with the logs were the problems occurs:

Service Logs following:

Service log1

Service log2

Thank you very much for your time! If there is any solution please help me here since im running into a deadline and the problem occured suddenly!

Title: Eureka Server cannot register clients


问:
Problems with ckanext for searching by the date
I am trying to use extension which allows searching by the date. I managed to addopt the extension that is working on ckan 2.9, but unfortunately it is not working as it should. I can not select any dates and I don't know where I should search for the problem.
Can someone help? Or maybe the idea where should I search for the problem?

I tried to add this https://github.com/dangrossman/daterangepicker to my flask app


问:
CSS: How to make wrapping column-direction flexbox as short as possible
I'm creating a flexbox containing divs with different heights. The direction of the flexbox is column and to make it wrap, I set a fixed height for it (I wasn't able to make it wrap in any different way):

.flex {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  height: 100vh;
}

.flex div {
  width: 200px;
  background: red;
  margin: 4px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="flex">
  <div style="height:50px"></div>
  <div style="height:200px"></div>
  <div style="height:2px"></div>
  <div style="height:30px"></div>
  <div style="height:100px"></div>
  <div style="height:150px"></div>
  <div style="height:40px"></div>
  <div style="height:70px"></div>
</div></code>```

However, the result doesn't look like what I need. I need to minimize height of the flexbox.

Eg. when the window is big, there are only one or two columns, even when more columns would fit there, which results in a higher flexbox, than the shortest possible.

When the window is narrow, then the flexbox exceeds the window width and a horizontal scrollbar appears, but I want rather a vertical scrollbar to appear.

The case
What I want
What actually happens

Window is wide and tall

 Here, the flexbox height is as small as possible

Window is narrow and short

 Here, the flexbox doesn't horizontally exceed the viewport

How can I minimize the height of the column-wrapping-flexbox without exceeding width of the viewport?

Body:
I'm creating a flexbox containing divs with different heights. The direction of the flexbox is column and to make it wrap, I set a fixed height for it (I wasn't able to make it wrap in any different way):

.flex {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  height: 100vh;
}

.flex div {
  width: 200px;
  background: red;
  margin: 4px;
}

However, the result doesn't look like what I need. I need to minimize height of the flexbox.

Eg. when the window is big, there are only one or two columns, even when more columns would fit there, which results in a higher flexbox, than the shortest possible.

When the window is narrow, then the flexbox exceeds the window width and a horizontal scrollbar appears, but I want rather a vertical scrollbar to appear.

The case
What I want
What actually happens

Window is wide and tall

 Here, the flexbox height is as small as possible

Window is narrow and short

 Here, the flexbox doesn't horizontally exceed the viewport

How can I minimize the height of the column-wrapping-flexbox without exceeding width of the viewport?


问:
how to connect MYSQL database to localhost using terminal
I wanted to connect my login page to a database to after searching I figured to use phpmyadmin and to use that I installed XAMPP and there MYSQL server is not running so I saw that you had to connect the MSQL server to the localhost in terminal first to did it by a command I saw on a website and it did not work it said that there was a error but did not tell me what error it is. so any help would be appreciated!

I tried this command "XAMPP/xamppfiles/bin/mysql -u root -h localhost" to connect the server to the localhost but an error message popped up in my terminal and I'm stuck!. I want to connect this so that I can use phpmyadmin to to store the data from my website.


问:
How to use nhanes data to do mediation analysis
I have been trying to use nhanes data to do a mediation analysis. The main model is a logistic regression model.

I tried the mediation package first, but it can't use the weights of the nhanes data. I also tried the lavaan.survey package, but it doesn't fit a logistics regression model. Which R package should I use?


问:
How to protect my RESR Api calls in Flutter?
I am developing an app in flutter which will have in app purchases. I am keeping track of user credits and some other things on my node server.

I am concerned that if I call my node api to increase user credits in my app code, it can be accessed by decompiling the apk. I don't know how to call my api securely and protect it.

I am currently calling my api simply from my app.I read that an app's source code can be accessed by decompiling the APK? If that is the case then my code can be altered to call my node server without the in app purchases.

I don't know if it is even possible or not or if this is even a concern. I don't know much about security because I am still a student. If anyone can guide me, I would appreciate it greatly. Thanks!


问:
Infix expression evaluation in C, the code compiles but it crashes
So I wrote this code to evaluate infix expression like (5*2) + 3 which should return answer 13, and the cde compiles but it crashes in between due to some weird error. I did try debugging it and I think there must be some fault with the logic. But I cant figure it out...
I wrote this code by myself and with some help from the internet. Can you help me find mistake in here? Is the mistake in the logic or some syntax or semantics ?
I tried putting it on code review but it was deleted as my code was 'not working'. I use DevC++ IDE and the error shows  "infivEval.c has stopped working, windows is trying to find a solution" something something...</p>
```<code>//header files
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

//global variables
int numbers[50], tn=-1, to=-1;
char op[50];

//is it digit?
int isItDigit(char c)
{
    switch(c)
    {
        case '1':
            return 1;
        case '2':
            return 2;
        case '3':
            return 3;
        case '4':
            return 4;
        case '5':
            return 5;
        case '6':
            return 6;
        case '7':
            return 7;
        case '8':
            return 8;
        case '9':
            return 9;
    }
    return 0;
}

//function to push digits
void pushNum(int n)
{
    numbers[++tn]=n;
}

//function to push operators
void pushOp(char ch)
{
    op[++to]=ch;
}

//function to pop digits
int popNum()
{
    return numbers[--tn];
}

//function to pop operators
char popOp()
{
    return op[--tn];
}

//actual operation
int actualOperation(int numbers[50], char op[50])
{
    int x,y;
    char opr;
    x=popNum();
    y=popNum();
    opr=popOp();

    switch(opr)
    {
        case '+':
            return x+y;
        case '-':
            return y-x;
        case '*':
            return x*y;
        case '/':
            if(x==0)
            {
                printf("\nCannot divide by zero");
                exit(0);
            }
            else
            {
                return y/x;
            }
    }
    return 0;
}

//function to check if character is an operator or not
int isOperator(char ch)
{
    switch(ch)
    {
        case '+':
            return '+';
        case '-':
            return '-';
        case '*':
            return '*';
        case '/':
            return '/';
    }
}

//precedence of the operators
int precedence(char ch)
{
    switch (ch)
    {
        case '+':
            return 1;
        case '-':
            return 1;
        case '*':
            return 2;
        case '/':
            return 2;
        case '^':
            return 3;

    }

    return -1;
}

//to evaluate an infix expression
int evaluateInfix(char expr[50])
{
    int i, num, output, r;
    char c;

    for(i=0;expr[i]!=0;i++)
    {
        c = expr[i];

        if(isItDigit(c)!=0)
        {
            num = 0;
            while(isItDigit(c))
            {
                num = isItDigit(c);
                i++;
                if(i < strlen(expr))
                {
                    c = expr[i];
                }
                else
                break;
            }
            i--;
            pushNum(num);
        }
        else if(c=='(')
        {
            pushOp(c);
        }
        else if(c==')')
        {
            while(op[to++]!='(')
            {
                r = actualOperation(numbers, op);
                pushNum(r);
            }
            popOp();
        }
        else if(isOperator(c))
        {
            while(to!=-1 && precedence(c)<=precedence(op[to]))
            {
                output = actualOperation(numbers, op);
                pushNum(output);
            }
            pushOp(c);
        }

    }
    while(to!=-1)
    {
            output = actualOperation(numbers, op);
            pushNum(output);
    }
    return popNum();
}

//main function
int main()
{
    char expr[50] = "(7-2)+(3*4)";
    int ans = evaluateInfix(expr);
    printf("Answer = %d", ans);
}
</code>```

Body:
So I wrote this code to evaluate infix expression like (5*2) + 3 which should return answer 13, and the cde compiles but it crashes in between due to some weird error. I did try debugging it and I think there must be some fault with the logic. But I cant figure it out...
I wrote this code by myself and with some help from the internet. Can you help me find mistake in here? Is the mistake in the logic or some syntax or semantics ?
I tried putting it on code review but it was deleted as my code was 'not working'. I use DevC++ IDE and the error shows  "infivEval.c has stopped working, windows is trying to find a solution" something something...

//header files
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

//global variables
int numbers[50], tn=-1, to=-1;
char op[50];

//is it digit?
int isItDigit(char c)
{
    switch(c)
    {
        case '1':
            return 1;
        case '2':
            return 2;
        case '3':
            return 3;
        case '4':
            return 4;
        case '5':
            return 5;
        case '6':
            return 6;
        case '7':
            return 7;
        case '8':
            return 8;
        case '9':
            return 9;
    }
    return 0;
}

//function to push digits
void pushNum(int n)
{
    numbers[++tn]=n;
}

//function to push operators
void pushOp(char ch)
{
    op[++to]=ch;
}

//function to pop digits
int popNum()
{
    return numbers[--tn];
}

//function to pop operators
char popOp()
{
    return op[--tn];
}

//actual operation
int actualOperation(int numbers[50], char op[50])
{
    int x,y;
    char opr;
    x=popNum();
    y=popNum();
    opr=popOp();

    switch(opr)
    {
        case '+':
            return x+y;
        case '-':
            return y-x;
        case '*':
            return x*y;
        case '/':
            if(x==0)
            {
                printf("\nCannot divide by zero");
                exit(0);
            }
            else
            {
                return y/x;
            }
    }
    return 0;
}

//function to check if character is an operator or not
int isOperator(char ch)
{
    switch(ch)
    {
        case '+':
            return '+';
        case '-':
            return '-';
        case '*':
            return '*';
        case '/':
            return '/';
    }
}

//precedence of the operators
int precedence(char ch)
{
    switch (ch)
    {
        case '+':
            return 1;
        case '-':
            return 1;
        case '*':
            return 2;
        case '/':
            return 2;
        case '^':
            return 3;

    }

    return -1;
}

//to evaluate an infix expression
int evaluateInfix(char expr[50])
{
    int i, num, output, r;
    char c;

    for(i=0;expr[i]!=0;i++)
    {
        c = expr[i];

        if(isItDigit(c)!=0)
        {
            num = 0;
            while(isItDigit(c))
            {
                num = isItDigit(c);
                i++;
                if(i < strlen(expr))
                {
                    c = expr[i];
                }
                else
                break;
            }
            i--;
            pushNum(num);
        }
        else if(c=='(')
        {
            pushOp(c);
        }
        else if(c==')')
        {
            while(op[to++]!='(')
            {
                r = actualOperation(numbers, op);
                pushNum(r);
            }
            popOp();
        }
        else if(isOperator(c))
        {
            while(to!=-1 && precedence(c)<=precedence(op[to]))
            {
                output = actualOperation(numbers, op);
                pushNum(output);
            }
            pushOp(c);
        }

    }
    while(to!=-1)
    {
            output = actualOperation(numbers, op);
            pushNum(output);
    }
    return popNum();
}

//main function
int main()
{
    char expr[50] = "(7-2)+(3*4)";
    int ans = evaluateInfix(expr);
    printf("Answer = %d", ans);
}


问:
Allow access Cors missing acitx web + Sveltekit
So i am writing a fullstack web app using actix as the backend and Sveltekit as the frontend. When i try to make a POST request to the /login route on the backend it returns the following error with StatusCode 400: Cross-Origin Request Blocked: The same-origin policy does not allow reading the remote resource from http://0.0.0.0:4000/login. (Cause: "Access-Control-Allow-Origin" CORS header is missing). Status code: 400. On the actix side i have

//...
let cors = Cors::default().allow_any_origin();

App::new()
    /* services, scopes, etc... */
    .wrap(cors)
// ...
```

On the svelte side the following function handles login: https://pastebin.com/RzbAdww7

The actual "resp" looks like this: https://pastebin.com/jPZnkJm2

Body:
So i am writing a fullstack web app using actix as the backend and Sveltekit as the frontend. When i try to make a POST request to the /login route on the backend it returns the following error with StatusCode 400: Cross-Origin Request Blocked: The same-origin policy does not allow reading the remote resource from http://0.0.0.0:4000/login. (Cause: "Access-Control-Allow-Origin" CORS header is missing). Status code: 400. On the actix side i have

//...
let cors = Cors::default().allow_any_origin();

App::new()
    /* services, scopes, etc... */
    .wrap(cors)
// ...

On the svelte side the following function handles login: https://pastebin.com/RzbAdww7

The actual "resp" looks like this: https://pastebin.com/jPZnkJm2


问:
Cloudfront behavior not redirecting traffic to ELB
I have a problem with a Cloudfront distribution.

This distribution has 3 origins:

An S3 Bucket containing a static website

An ELB containing CMS and API

A custom Lambda function (not part of the problem I think)

I have 2 behaviors:

/cms/* routing all traffic via HTTPS to my ELB.

* Default behavior routing request to my S3 Bucket.

However when accessing any URL like https://host.com/cms/assets/img.jpg I get to see the 404 page that is contained in my S3 bucket. I'm currently forwarding headers to my ELB via AllViewer policy. Also when I put the ELB as origin of the default behavior everything works perfectly.

It seems that Cloudfront just doesn't follow the path pattern defined in my behavior.

Some more facts:

Traffic from CF to my ELB is HTTPS-only

Cloudfront is using TLS-certificate from ACM for my domain.

ELB also has TLS-certificate for domain from ACM

I don't think it's an HTTPS related error, as ELB as origin works when used through default behavior


问:
How to implement dashed progress bar with antd
is there a way to create a dashed progress bar, something like attached with Ant Design. I've not seen any help on the Ant Design documentation


问:
sql plus connect \ as sysdba ora-12560
After installing Oracle XE, I am struggling trying to connect with SQL Plus.

I want to connect the database with SQL Plus (and also with connectionstring) but it seems that I don't have the right login.

```<code>SQL> connect \ as sysdba
Entrez le mot de passe :
ERROR:
ORA-12560: TNS : erreur d'adaptateur de protocole`
</code>```

I have tried every password I used during installation and configuration but I always get the same error.

Every oracle service is running :

And I can even connect the schemas in SQL Developer with the passwords I used when configuring the database :

I've never managed to connect as sysdba in SQL Plus as suggested in Oracle's "Getting Started".

Title: sql plus connect \ as sysdba ora-12560

Body:
After installing Oracle XE, I am struggling trying to connect with SQL Plus.

I want to connect the database with SQL Plus (and also with connectionstring) but it seems that I don't have the right login.

SQL> connect \ as sysdba
Entrez le mot de passe :
ERROR:
ORA-12560: TNS : erreur d'adaptateur de protocole`

I have tried every password I used during installation and configuration but I always get the same error.

Every oracle service is running :

And I can even connect the schemas in SQL Developer with the passwords I used when configuring the database :

I've never managed to connect as sysdba in SQL Plus as suggested in Oracle's "Getting Started".


问:
I can't access Drawable folders and view an asset
everyone. I want to access my drawable folder to get a vector asset from there. But I can't figure it out, see picture. What am I doing wrong?


问:
Aggregate and non aggregate calculation tableau
The following calculated field is returning a non agg, agg error:

(
IF
[MaxDate] = TRUE
THEN
AVG(CASE[Sales]
WHEN 1
THEN ([Pending Revenue])

END
)
ELSE
0
END
)

I have tried using ATTR, but it says it cant further be aggregated, any ideas?

Thanks


问:
How can I get chart.js to space values according to the gap between labels?
I have no idea what to call the thing I'm asking about, and so I'm incapable of searching for other questions.

If I have a set of labels: 0,1,3,7,8, and a dataset with values: 1,2,3,4,5, then I want the value 2 on my chart.js line graph to be 1 unit to the right of the value 1, but the value 3 to be 2 units to the right of the value 2, because there is a bigger gap between the labels.  The default behaviour is that all datapoints are equally horizontally spaced.  I want them to be spaced according to the numeric spacing between label values.

What do I call this so that I can search for it, or better yet, just how do I do it?


问:
why do we have to set value of extended to true in body-parser in express
```<code>const express = require("express");
const bodyParser = require("body-parser");

const app = express();
app.use(bodyParser.urlencoded({extended:true}));

</code>```

I want to know why we have to set the value of extended to true in the code above for accepting form inputs

Body:
const express = require("express");
const bodyParser = require("body-parser");

const app = express();
app.use(bodyParser.urlencoded({extended:true}));

I want to know why we have to set the value of extended to true in the code above for accepting form inputs


问:
TypeScript using Strapi types inappropriate strings
I am using the generated TS types with npm run strapi ts:generate-types --verbose. Problem is TypeScript complains about pretty much any attribute being a StringAttribute instead of string | undefined.

Error

Type 'StringAttribute' is not assignable to type 'string | undefined'.

Simplest example with the alt attribute

```<code>const { attributes: { name }} = ApiProductProduct;

return <img src={fromImageToUrl(image)} alt={name} />;

</code>```

What shall I do to make TypeScript accept the types?

Body:
I am using the generated TS types with npm run strapi ts:generate-types --verbose. Problem is TypeScript complains about pretty much any attribute being a StringAttribute instead of string | undefined.

Error

Type 'StringAttribute' is not assignable to type 'string | undefined'.

Simplest example with the alt attribute

const { attributes: { name }} = ApiProductProduct;

return ;

What shall I do to make TypeScript accept the types?


问:
My functions always return me undefined, it should be true
It always return me undefined but i don't know why

```<code>const whitelistWord = isWhitelist(message)
console.log(whitelistWord)

function isWhitelist(message) {
  db.query(`SELECT * FROM whitelist WHERE guild="${message.guild.id}"`, function(error, result) {
    if (error) throw error
    for (let i = 0; i < result.length; i++) {
      if (message.content.includes(result[i].word)) {
        response = result[i].word
        return response
      }
    }
    response = false
    return response
  })
}

</code>```

I want to scan a message, if the message include a defined word it should be return True

Body:
It always return me undefined but i don't know why

const whitelistWord = isWhitelist(message)
console.log(whitelistWord)

function isWhitelist(message) {
  db.query(`SELECT * FROM whitelist WHERE guild="${message.guild.id}"`, function(error, result) {
    if (error) throw error
    for (let i = 0; i < result.length; i++) {
      if (message.content.includes(result[i].word)) {
        response = result[i].word
        return response
      }
    }
    response = false
    return response
  })
}

I want to scan a message, if the message include a defined word it should be return True


Title: JavaFX - java.lang.reflect.InvocationTargetException when executing WebView exemple code