问:
OpenLayers with React
I'm having trouble with a simple task, add points to a map and connect them with a line. But the coordinate function is not working normally. How could I solve this problem? I have no general representation of how this library work. In details, why line not connect 2 point? And how i can get coordinates from map click event?

```<code>import Map from 'ol/Map';
import OSM from 'ol/source/OSM';
import View from 'ol/View';
import MousePosition from 'ol/control/MousePosition';
import { createStringXY } from 'ol/coordinate';
import { Component, Fragment } from 'react';
import {defaults as defaultControls} from 'ol/control';
import {Vector as VectorSource} from 'ol/source';
import {Tile as TileLayer, Vector as VectorLayer} from 'ol/layer';
import {Draw, Modify} from 'ol/interaction';
import "./App.css";
import Feature from 'ol/Feature';
import LineString from 'ol/geom/LineString';

let draw;

const mousePositionControl = new MousePosition({
  coordinateFormat: createStringXY(4),
  projection: 'EPSG:4326',
  // comment the following two lines to have the mouse position
  // be placed within the map.
  className: 'custom-mouse-position',
  target: "",
});

const raster = new TileLayer({
  source: new OSM(),
});

const source = new VectorSource();
const vector = new VectorLayer({
  source: source,
  style: {
    'fill-color': 'rgba(255, 255, 255, 0.2)',
    'stroke-color': '#ffcc33',
    'stroke-width': 2,
    'circle-radius': 7,
    'circle-fill-color': '#ffcc33',
  },
});

const initialMap = {
  simpleMap: new Map({
    controls: defaultControls().extend([mousePositionControl]),
    target: "",
    layers: [raster, vector],
    view: new View({
      center: [0, 0],
      zoom: 0,
    })
})
};
const modify = new Modify({source: source});

export default class App extends Component {

  constructor(props) {
    super(props);
    this.state = {...initialMap, markers: [], counter: 0}
    this.addInteractions = this.addInteractions.bind(this);
    this.removeInteractions = this.removeInteractions.bind(this);
    this.addMarkers = this.addMarkers.bind(this);
  }

  componentDidMount() {
    this.state.simpleMap.setTarget("map-container");
    this.state.simpleMap.addInteraction(modify);
  }

  addInteractions() {
      draw = new Draw({
        source: source,
        type: "Point",
      });
      this.state.simpleMap.addInteraction(draw);
  }

  addMarkers() {
    this.setState({...this.state, markers: [...this.state?.markers, mousePositionControl.renderedHTML_]});
    console.log(mousePositionControl.renderedHTML_)

    if(this.state.markers.length > 1 && this.state.markers.length % 2 === 0) {
      let coordinates = [[parseFloat(this.state.markers[this.state.counter]), parseFloat(this.state.markers[this.state.counter]?.slice(8))], [parseFloat(this.state.markers[this.state.counter + 1]), parseFloat(this.state.markers[this.state.counter + 1]?.slice(8))]];

      console.log(coordinates);

      const layerLines = new VectorLayer({
          source: new VectorSource({
              features: [new Feature({
                  geometry: new LineString(coordinates),
                  name: 'Line'
              })]
          }),
      });

      this.state.simpleMap.addLayer(layerLines);
      // this.setState({...this.state, simpleMap: {...this.state.simpleMap, layers: [this.state.simpleMap.layers, layerLines]}});
      this.setState({...this.state, counter: this.state.counter + 2});
      console.log(this.state.counter)
    }
  }

  removeInteractions() {
    this.state.simpleMap.removeInteraction(draw);
    draw = null;
  }

  render() {
    return (
      <Fragment>
        <div id="map-container" className="map-container" onClick={() => {if(draw) this.addMarkers()}}/>
        <div className='buttons ol-unselectable ol-control'>
          <button onClick={() => this.addInteractions()}>D</button>
          <button onClick={() => this.removeInteractions()}>C</button>
        </div>
    </Fragment>
    );
  }
}
</code>```

I've developed some features like a draw button and a draw cancel button, but I'm definitely too far away from my main task.

Solved

Title: OpenLayers with React

Body:
I'm having trouble with a simple task, add points to a map and connect them with a line. But the coordinate function is not working normally. How could I solve this problem? I have no general representation of how this library work. In details, why line not connect 2 point? And how i can get coordinates from map click event?

import Map from 'ol/Map';
import OSM from 'ol/source/OSM';
import View from 'ol/View';
import MousePosition from 'ol/control/MousePosition';
import { createStringXY } from 'ol/coordinate';
import { Component, Fragment } from 'react';
import {defaults as defaultControls} from 'ol/control';
import {Vector as VectorSource} from 'ol/source';
import {Tile as TileLayer, Vector as VectorLayer} from 'ol/layer';
import {Draw, Modify} from 'ol/interaction';
import "./App.css";
import Feature from 'ol/Feature';
import LineString from 'ol/geom/LineString';

let draw;

const mousePositionControl = new MousePosition({
  coordinateFormat: createStringXY(4),
  projection: 'EPSG:4326',
  // comment the following two lines to have the mouse position
  // be placed within the map.
  className: 'custom-mouse-position',
  target: "",
});

const raster = new TileLayer({
  source: new OSM(),
});

const source = new VectorSource();
const vector = new VectorLayer({
  source: source,
  style: {
    'fill-color': 'rgba(255, 255, 255, 0.2)',
    'stroke-color': '#ffcc33',
    'stroke-width': 2,
    'circle-radius': 7,
    'circle-fill-color': '#ffcc33',
  },
});

const initialMap = {
  simpleMap: new Map({
    controls: defaultControls().extend([mousePositionControl]),
    target: "",
    layers: [raster, vector],
    view: new View({
      center: [0, 0],
      zoom: 0,
    })
})
};
const modify = new Modify({source: source});

export default class App extends Component {

  constructor(props) {
    super(props);
    this.state = {...initialMap, markers: [], counter: 0}
    this.addInteractions = this.addInteractions.bind(this);
    this.removeInteractions = this.removeInteractions.bind(this);
    this.addMarkers = this.addMarkers.bind(this);
  }

  componentDidMount() {
    this.state.simpleMap.setTarget("map-container");
    this.state.simpleMap.addInteraction(modify);
  }

  addInteractions() {
      draw = new Draw({
        source: source,
        type: "Point",
      });
      this.state.simpleMap.addInteraction(draw);
  }

  addMarkers() {
    this.setState({...this.state, markers: [...this.state?.markers, mousePositionControl.renderedHTML_]});
    console.log(mousePositionControl.renderedHTML_)

    if(this.state.markers.length > 1 && this.state.markers.length % 2 === 0) {
      let coordinates = [[parseFloat(this.state.markers[this.state.counter]), parseFloat(this.state.markers[this.state.counter]?.slice(8))], [parseFloat(this.state.markers[this.state.counter + 1]), parseFloat(this.state.markers[this.state.counter + 1]?.slice(8))]];

      console.log(coordinates);

      const layerLines = new VectorLayer({
          source: new VectorSource({
              features: [new Feature({
                  geometry: new LineString(coordinates),
                  name: 'Line'
              })]
          }),
      });

      this.state.simpleMap.addLayer(layerLines);
      // this.setState({...this.state, simpleMap: {...this.state.simpleMap, layers: [this.state.simpleMap.layers, layerLines]}});
      this.setState({...this.state, counter: this.state.counter + 2});
      console.log(this.state.counter)
    }
  }

  removeInteractions() {
    this.state.simpleMap.removeInteraction(draw);
    draw = null;
  }

  render() {
    return (
      <Fragment>

 {if(draw) this.addMarkers()}}/>

          <button onClick={() => this.addInteractions()}>D</button>
          <button onClick={() => this.removeInteractions()}>C</button>

    </Fragment>
    );
  }
}

I've developed some features like a draw button and a draw cancel button, but I'm definitely too far away from my main task.

Solved


来源: stackexchange

问:
How to iterate through this collection in Laravel 9?
An API returns this data when I do dd().
How do I iterate through results and retrieve eg. originalFileUrl?

```<code>MyApp\Response\FileListResponse {#2160 ▼ // app/Http/Controllers/MyController.php:24
  -next: null
  -previous: null
  -total: 43
  -perPage: 100
  -results: MyApp\FileCollection {#2551 ▼
    -inner: MyApp\File\FileCollection {#2278 ▶}
    -api: MyApp\Apis\FileApi {#2077 ▶}
    #elements: array:43 [▶]
  }
}
</code>```

Or result of print_r:

```<code>Uploadcare\Response\FileListResponse Object
(
    [next:Uploadcare\Response\FileListResponse:private] =>
    [previous:Uploadcare\Response\FileListResponse:private] =>
    [total:Uploadcare\Response\FileListResponse:private] => 43
    [perPage:Uploadcare\Response\FileListResponse:private] => 100
    [results:Uploadcare\Response\FileListResponse:private] => Uploadcare\FileCollection Object
        (
            [inner:Uploadcare\FileCollection:private] => Uploadcare\File\FileCollection Object
                (
                    [elements:protected] => Array
                        (
                            [0] => Uploadcare\File\File Object
                                (
                                    [datetimeRemoved:Uploadcare\File\File:private] =>
                                    [datetimeStored:Uploadcare\File\File:private] => DateTime Object
                                        (
                                            [date] => 2022-10-15 20:34:58.555665
                                            [timezone_type] => 3
                                            [timezone] => UTC
                                        )

                                    [datetimeUploaded:Uploadcare\File\File:private] => DateTime Object
                                        (
                                            [date] => 2022-10-15 20:34:58.501702
                                            [timezone_type] => 3
                                            [timezone] => UTC
                                        )

                                    [isImage:Uploadcare\File\File:private] => 1
                                    [isReady:Uploadcare\File\File:private] => 1
                                    [mimeType:Uploadcare\File\File:private] => image/png
                                    [originalFileUrl:Uploadcare\File\File:private] => https://ucarecdn.com/3d7c1845-0193-4425-e6ad-ec1f1f366fc3/IMG_0643.PNG
</code>```

ContentLicense: CC BY-SA 4.0

Body:
An API returns this data when I do dd().
How do I iterate through results and retrieve eg. originalFileUrl?

MyApp\Response\FileListResponse {#2160 ▼ // app/Http/Controllers/MyController.php:24
  -next: null
  -previous: null
  -total: 43
  -perPage: 100
  -results: MyApp\FileCollection {#2551 ▼
    -inner: MyApp\File\FileCollection {#2278 ▶}
    -api: MyApp\Apis\FileApi {#2077 ▶}
    #elements: array:43 [▶]
  }
}

Or result of print_r:

Uploadcare\Response\FileListResponse Object
(
    [next:Uploadcare\Response\FileListResponse:private] =>
    [previous:Uploadcare\Response\FileListResponse:private] =>
    [total:Uploadcare\Response\FileListResponse:private] => 43
    [perPage:Uploadcare\Response\FileListResponse:private] => 100
    [results:Uploadcare\Response\FileListResponse:private] => Uploadcare\FileCollection Object
        (
            [inner:Uploadcare\FileCollection:private] => Uploadcare\File\FileCollection Object
                (
                    [elements:protected] => Array
                        (
                            [0] => Uploadcare\File\File Object
                                (
                                    [datetimeRemoved:Uploadcare\File\File:private] =>
                                    [datetimeStored:Uploadcare\File\File:private] => DateTime Object
                                        (
                                            [date] => 2022-10-15 20:34:58.555665
                                            [timezone_type] => 3
                                            [timezone] => UTC
                                        )

                                    [datetimeUploaded:Uploadcare\File\File:private] => DateTime Object
                                        (
                                            [date] => 2022-10-15 20:34:58.501702
                                            [timezone_type] => 3
                                            [timezone] => UTC
                                        )

                                    [isImage:Uploadcare\File\File:private] => 1
                                    [isReady:Uploadcare\File\File:private] => 1
                                    [mimeType:Uploadcare\File\File:private] => image/png
                                    [originalFileUrl:Uploadcare\File\File:private] => https://ucarecdn.com/3d7c1845-0193-4425-e6ad-ec1f1f366fc3/IMG_0643.PNG


问:
Remove youtube context menu from iframe android webview
When load a url in webview which contains iframe and embedded youtube video in it youtube doesn't show context menu. But when i load iframe with embeded youtube using HTML in webview it shows context menu on scroll.

i have tried disabling long click on webview it still shows context menu. I don't want to use youtube api cause in webview there will be other elements as well.


问:
KEYCLOAK ERROR: Input byte array has incorrect ending byte at 64
```<code># Error during startup: java.lang.RuntimeException: java.lang.IllegalArgumentException: Input byte array has incorrect ending byte at 64

Ubuntu 20.04 operating system

Keycloak - Version 18.0.2

Java 8
</code>```

In the keycloak working directory, I edited the license.txt and product.txt files in ~/bin. Then I run the command "pm2 start"

Result:

enter image description here

Please help me, meanwhile I am running on mac and windows is working fine, 2 files license vs product still work fine on Mac and Windows.

I've been looking for documentation regarding the error but can't seem to find it.

Body:
# Error during startup: java.lang.RuntimeException: java.lang.IllegalArgumentException: Input byte array has incorrect ending byte at 64

Ubuntu 20.04 operating system

Keycloak - Version 18.0.2

Java 8

In the keycloak working directory, I edited the license.txt and product.txt files in ~/bin. Then I run the command "pm2 start"

Result:

enter image description here

Please help me, meanwhile I am running on mac and windows is working fine, 2 files license vs product still work fine on Mac and Windows.

I've been looking for documentation regarding the error but can't seem to find it.


问:
How do I pass a parameter to a TADO query
I am writing a script using Pascal in our ERP system.

I am connecting to a MS Access database which has two tables. TIMESHEETHEADER and TIMESHEETLINES.

I have a query that is reading from the database. I would like to pass some variables to the query, but not entirely sure how.

If I have the sql:

```<code>ADOQRY.SQL.ADD('select FIRSTNAME, LASTNAME from TIMESHEETHEADER where LASTNAME = :LASTNAME');
ADOQRY.PN('LASTNAME') := EMP_LASTNAME;
</code>```

I have also tried:

```<code>ADOQRY.Parameters.ParamByName('EMP_LASTNAME');
</code>```

I get a error during compiling which is "Undeclared identifier:'PN' at 156:17" (156:17 represents the line number and number of characters in from the left)

I can get it working with the following:
ADOQRY.SQL.ADD('select FIRSTNAME, LASTNAME from TIMESHEETHEADER where LASTNAME = ' + EMP_LASTNAME );
But I don't think that is the best way of doing it. I believe it could be compromised via SQL injection.

I use the following to declare the connection:

```<code> ADO.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + TimeSheetFolder + 'TimeSheetRecharge.mdb';
 ADO.LoginPrompt := False;
 ADO.Connected := true;
 ADOQry.Connection := ADO;
</code>```

I have no problem when accessing a firebird database.

What is the correct syntax for passing a parameter to the SQL query?

Body:
I am writing a script using Pascal in our ERP system.

I am connecting to a MS Access database which has two tables. TIMESHEETHEADER and TIMESHEETLINES.

I have a query that is reading from the database. I would like to pass some variables to the query, but not entirely sure how.

If I have the sql:

ADOQRY.SQL.ADD('select FIRSTNAME, LASTNAME from TIMESHEETHEADER where LASTNAME = :LASTNAME');
ADOQRY.PN('LASTNAME') := EMP_LASTNAME;

I have also tried:

ADOQRY.Parameters.ParamByName('EMP_LASTNAME');

I get a error during compiling which is "Undeclared identifier:'PN' at 156:17" (156:17 represents the line number and number of characters in from the left)

I can get it working with the following:
ADOQRY.SQL.ADD('select FIRSTNAME, LASTNAME from TIMESHEETHEADER where LASTNAME = ' + EMP_LASTNAME );
But I don't think that is the best way of doing it. I believe it could be compromised via SQL injection.

I use the following to declare the connection:

 ADO.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + TimeSheetFolder + 'TimeSheetRecharge.mdb';
 ADO.LoginPrompt := False;
 ADO.Connected := true;
 ADOQry.Connection := ADO;

I have no problem when accessing a firebird database.

What is the correct syntax for passing a parameter to the SQL query?


问:
How to do a binary split on a categorical variable with 5 levels
I'm new to data science and machine learning, I came accros a task where i was to do a binary split on a categorical variable that has 5 levels, I'm supposed to only slit into two, please how do i go about this?

Thank you

I tried thinkink of it as getting every possible two-way split combination of 5 levels i.e

Column A
Column B

LEVEL 1,
LEVEL 2,LEVEL 3,LEVEL 4,LEVEL 5,

LEVEL 1, LEVEL 2,
LEVEL 3,LEVEL 4,LEVEL 5,

etc... but this might grow up to 16 combinations.
Then i find the eentropy of the 16 columns + the target variable but i'm not sure if that's the way to do it. It looks long and will take time.


问:
Flutter WebRTC can't create datachannel
I'm trying to create WebRTC datachannel with flutter_webrtc package but have some Issues.

What I'm doing:

I'm creating RTCPeerConnection? _peerConnection;. I have working video and audio stream.
But then I'm trying to add dataChannels.

On Offer side I do:

  _createDataChanel() async {
    final chanInit = RTCDataChannelInit()
      ..negotiated = true
      ..maxRetransmits = 30;

    _dataChannel = await _peerConnection!.createDataChannel('chat', chanInit);
    _dataChannel!.onMessage = (data) {
      print(data);
    };
  }
```
<p>On Answer side I do:</p>
<pre class="lang-dart prettyprint-override"><code>  _subscribeDataChanel() {
    _peerConnection!.onDataChannel = (channel) {
      _dataChannel = channel;
      _dataChannel!.onMessage = (data) {
        print(data);
      };
    };
  }
</code>```

And nothing happens. It will never send any events to onDataChannel. May be I do something wrong?

UPD: I made some experiments and figure how to solve.

Solution: We should firstly create DataChannel and then create Offer or Answer. So in code it will be something like:

Offer side:

```<code>createOffer(Connection connection) async {
    await _createDataChanel();

    final offerDesc = await _peerConnection!.createOffer(offerSdpConstraints);
    await _peerConnection!.setLocalDescription(offerDesc);
    // send to signaling server and so on...
}
</code>```

Answer side:

```<code>createAnswer(Connection connection) async {
    _subscribeDataChanel();
    // get offer from signaling server and so on ...
}
</code>```

Title: Flutter WebRTC can't create datachannel

Body:
I'm trying to create WebRTC datachannel with flutter_webrtc package but have some Issues.

What I'm doing:

I'm creating RTCPeerConnection? _peerConnection;. I have working video and audio stream.
But then I'm trying to add dataChannels.

On Offer side I do:

  _createDataChanel() async {
    final chanInit = RTCDataChannelInit()
      ..negotiated = true
      ..maxRetransmits = 30;

    _dataChannel = await _peerConnection!.createDataChannel('chat', chanInit);
    _dataChannel!.onMessage = (data) {
      print(data);
    };
  }

On Answer side I do:

  _subscribeDataChanel() {
    _peerConnection!.onDataChannel = (channel) {
      _dataChannel = channel;
      _dataChannel!.onMessage = (data) {
        print(data);
      };
    };
  }

And nothing happens. It will never send any events to onDataChannel. May be I do something wrong?

UPD: I made some experiments and figure how to solve.

Solution: We should firstly create DataChannel and then create Offer or Answer. So in code it will be something like:

Offer side:

createOffer(Connection connection) async {
    await _createDataChanel();

    final offerDesc = await _peerConnection!.createOffer(offerSdpConstraints);
    await _peerConnection!.setLocalDescription(offerDesc);
    // send to signaling server and so on...
}

Answer side:

createAnswer(Connection connection) async {
    _subscribeDataChanel();
    // get offer from signaling server and so on ...
}


问:
Changing theme with system in children components
I have a website using React with functioning dark theme changing and system detection, but am having trouble getting the Land and Nav component images to change on system change. They detect the system theme and successfully switch with the themeChange() function, but do not change when I change the theme in my system. Everything else does change on system theme change.

Home.jsx:

```<code>function Home() {
    const [darkTheme, setDarkTheme] = useState()
    const prefersDarkScheme = window.matchMedia('(prefers-color-scheme: dark)').matches;

    useEffect(() => {
        if(prefersDarkScheme) {
            document.body.classList.toggle("light-theme");
            setDarkTheme(prefersDarkScheme)
        } else {
            document.body.classList.toggle("dark-theme");
            setDarkTheme(prefersDarkScheme)
        }
    }, [])

    function themeChange() {
        if(prefersDarkScheme) {
            document.body.classList.toggle("light-theme");
            setDarkTheme(!darkTheme)
        } else {
            document.body.classList.toggle("dark-theme");
            setDarkTheme(!darkTheme)
        }
    };

    return(
        <div className="Home fade" id="home">
            <Navbar themeChange={themeChange} darkTheme={darkTheme} />
            <Landing darkTheme={darkTheme} />
            <About />
            <Skills />
            <Projects />
            <Contact />
            <Footer />
        </div>
    )
}
</code>```

Here is the Landing, same as the Navbar, logic:

```<code>function Landing(props) {
  const prefersDarkScheme = window.matchMedia('(prefers-color-scheme: dark)').matches;
  const [darkNav, setDarkNav] = useState(props.darkTheme)
  useEffect(() => {
    if(props.darkTheme === true){
        setDarkNav(true)
    } else if (props.darkTheme === false) {
        setDarkNav(false)
    } else {
        setDarkNav(prefersDarkScheme)
    }
}, [props.darkTheme])

    return(
        <div className='Landing-Page'>
            <div className='Landing-box'>
                <div className='Landing-Text'>
                    <h1>Bridger Brown</h1>
                    <h2>Front-End Web Developer + Designer</h2>
                </div>
                <div className='landpages'>
                    {
                        !darkLand ?
                        <img src='./src/assets/wave-dark.jpg' className="fade" id='land-bg'/>
                        :
                        <img src='./src/assets/wave-light.jpg' className="fade" id='land-bg2'/>
                    }

                </div>
            </div>
        </div>
    )
}
</code>```

Body:
I have a website using React with functioning dark theme changing and system detection, but am having trouble getting the Land and Nav component images to change on system change. They detect the system theme and successfully switch with the themeChange() function, but do not change when I change the theme in my system. Everything else does change on system theme change.

Home.jsx:

function Home() {
    const [darkTheme, setDarkTheme] = useState()
    const prefersDarkScheme = window.matchMedia('(prefers-color-scheme: dark)').matches;

    useEffect(() => {
        if(prefersDarkScheme) {
            document.body.classList.toggle("light-theme");
            setDarkTheme(prefersDarkScheme)
        } else {
            document.body.classList.toggle("dark-theme");
            setDarkTheme(prefersDarkScheme)
        }
    }, [])

    function themeChange() {
        if(prefersDarkScheme) {
            document.body.classList.toggle("light-theme");
            setDarkTheme(!darkTheme)
        } else {
            document.body.classList.toggle("dark-theme");
            setDarkTheme(!darkTheme)
        }
    };

    return(

            <Navbar themeChange={themeChange} darkTheme={darkTheme} />
            <Landing darkTheme={darkTheme} />
            <About />
            <Skills />
            <Projects />
            <Contact />

    )
}

Here is the Landing, same as the Navbar, logic:

function Landing(props) {
  const prefersDarkScheme = window.matchMedia('(prefers-color-scheme: dark)').matches;
  const [darkNav, setDarkNav] = useState(props.darkTheme)
  useEffect(() => {
    if(props.darkTheme === true){
        setDarkNav(true)
    } else if (props.darkTheme === false) {
        setDarkNav(false)
    } else {
        setDarkNav(prefersDarkScheme)
    }
}, [props.darkTheme])

    return(

Bridger Brown

Front-End Web Developer + Designer

                    {
                        !darkLand ?

                        :

                    }

    )
}


问:
Why is my program only printing part of what I need?
I have this function below that essentially will print out a schedule on a week by week basis. This is what I have so far.

```<code>void Date::increaseWeek()
{
    int increaseWeek = (day + 7);
    int increaseDay = (day + 1);
    int increasedDay = (day + 1);
    int increaseMonth = (month + 1);
    int increaseYear = (year + 1);

    if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10)
    {
        if (day < 31)
        {
            std::cout << " " << month << '/' << day << '/' << year
                << " - ";

            if (increaseWeek > 31)
            {
                int subDate = increaseWeek - 32;
                day = 1 + subDate;
                std::cout << increaseMonth << '/' << day << '/' << year;
                month++;
                day++;
            }
            else
            {
                std::cout << month << '/' << increaseWeek << '/' << year;
                int addDay = increaseWeek + 1;
                day = addDay;
            }
        }
        else if (day == 31)
        {
            std::cout << " " << month << '/' << day << '/' << year
                << " - ";
            int subDate = increaseWeek - 32;
            day = 1 + subDate;
            std::cout << increaseMonth << '/' << day << '/' << year;
            int increaseDayAgain = day + 1;
            day = increaseDayAgain;
            month++;
        }
    }
    else if (month == 4 || month == 6 || month == 9 || month == 11)
    {
        if (day < 30)
        {
            std::cout << " " << month << '/' << day << '/' << year
                << " - ";

            if (increaseWeek > 30)
            {
                int subDate = increaseWeek - 31;
                day = 1 + subDate;
                std::cout << increaseMonth << '/' << day << '/' << year;
                month++;
            }
            else
            {
                std::cout << month << '/' << increaseWeek << '/' << year;
                int addDay = increaseWeek + 1;
                day = addDay;
            }
        }
        else if (day == 30)
        {
            std::cout << " " << month << '/' << day << '/' << year
                << " - ";
            int subDate = increaseWeek - 31;
            day = 1 + subDate;
            std::cout << increaseMonth << '/' << day << '/' << year;
            int increaseDayAgain = day + 1;
            day = increaseDayAgain;
            month++;
        }
    }
    else if (month == 2)
    {
        if (day < 28)
        {
            std::cout << " " << month << '/' << day << '/' << year
                << " - ";

            if (increaseWeek > 28)
            {
                int subDate = increaseWeek - 29;
                day = 1 + subDate;
                std::cout << increaseMonth << '/' << day << '/' << year;
                month++;
            }
            else
            {
                std::cout << month << '/' << increaseWeek << '/' << year;
                int addDay = increaseWeek + 1;
                day = addDay;
            }
        }
        else if (day == 28)
        {
            std::cout << " " << month << '/' << day << '/' << year
                << " - ";
            int subDate = increaseWeek - 29;
            day = 1 + subDate;
            month = 1;
            std::cout << increaseMonth << '/' << day << '/' << year;
            int increaseDayAgain = day + 1;
            day = increaseDayAgain;
            month++;

            //int addDay = rangeDay + 1;
            //day = addDay;
        }
    }
     else if (month == 12)
    {
    if (day < 31)
    {
        std::cout << " " << month << '/' << day << '/' << year
            << " - ";

        if (increaseWeek > 31)
        {
            int subDate = increaseWeek - 32;
            day = 1 + subDate;
            month = 1;
            std::cout << month << '/' << day << '/' << increaseYear;
            day++;
            year++;
        }
        else
        {
            std::cout << month << '/' << increaseWeek << '/' << year;
            int addDay = increaseWeek + 1;
            day = addDay;
        }
    }
    else if (day == 31)
    {
        month = 1;
        std::cout << " " << month << '/' << day << '/' << year
            << " - ";
        int subDate = increaseWeek - 32;
        day = 1 + subDate;
        std::cout << month << '/' << day << '/' << increaseYear;
        int increaseDayAgain = day + 1;
        day = increaseDayAgain;
        year++;
    }
    }
}
</code>```

The function above seems to work until the I use it on a much larger scale. The code below is going to print a schedule for apple over the course of _____ weeks.

```<code>std::string fruitChoice = "Apple";
            int courseOfLife = (rand() % 350) + 349;
            int weeksOfLife = (courseOfLife / 7);

            std::cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << std::endl;
            std::cout << "        SCHEDULE FOR APPLE        " << std::endl;
            std::cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << std::endl;

            printInstructionsFruit();

            Fruit appleObj = Fruit("Apple", 1, 1, 1, 1, "yes", 1, 1);
            appleObj.whenToWater();
            appleObj.light();
            appleObj.whenToFertilize();

            std::cout << courseOfLife;
            for (int i = 1; i <= weeksOfLife; i++)
            {
                std::cout << "Week: " << i;
                while (i < courseOfLife)
                {
                    userdate.increaseWeek();
                    break;
                }

                std::cout << "\n----------------------------------------------------" << std::endl;
            }

        }
</code>```

This is the output that I get from running the code. The user enters a date, and a schedule is printed week by week from the first day that the user enters. However there are some problems. The week is not implemented the whole way through. The second problem is the line from above
int courseOfLife = (rand() % 350) + 349; is printing out that the courseOfLife is 390 which doesn't make sense considering the rand I have set up only allows a range of choices from 349 - 350
What I want to know is how do I make the schedule keep printing through the whole courseOfLife on a weeksOfLife Basis?

```<code>Week: 1 12/20/2022 - 12/27/2022
----------------------------------------------------
Week: 2 12/28/2022 - 1/4/2023
----------------------------------------------------
Week: 3 1/5/2023 - 1/12/2023
----------------------------------------------------
Week: 4 1/13/2023 - 1/20/2023
----------------------------------------------------
Week: 5 1/21/2023 - 1/28/2023
----------------------------------------------------
Week: 6 1/29/2023 - 2/5/2023
----------------------------------------------------
Week: 7 2/6/2023 - 2/13/2023
----------------------------------------------------
Week: 8 2/14/2023 - 2/21/2023
----------------------------------------------------
Week: 9 2/22/2023 - 3/1/2023
----------------------------------------------------
Week: 10 3/1/2023 - 3/8/2023
----------------------------------------------------
Week: 11 3/9/2023 - 3/16/2023
----------------------------------------------------
Week: 12 3/17/2023 - 3/24/2023
----------------------------------------------------
Week: 13 3/25/2023 - 4/1/2023
----------------------------------------------------
Week: 14 4/2/2023 - 4/9/2023
----------------------------------------------------
Week: 15 4/10/2023 - 4/17/2023
----------------------------------------------------
Week: 16 4/18/2023 - 4/25/2023
----------------------------------------------------
Week: 17 4/26/2023 - 5/3/2023
----------------------------------------------------
Week: 18 5/3/2023 - 5/10/2023
----------------------------------------------------
Week: 19 5/11/2023 - 5/18/2023
----------------------------------------------------
Week: 20 5/19/2023 - 5/26/2023
----------------------------------------------------
Week: 21 5/27/2023 - 6/3/2023
----------------------------------------------------
Week: 22 6/4/2023 - 6/11/2023
----------------------------------------------------
Week: 23 6/12/2023 - 6/19/2023
----------------------------------------------------
Week: 24 6/20/2023 - 6/27/2023
----------------------------------------------------
Week: 25 6/28/2023 - 7/5/2023
----------------------------------------------------
Week: 26 7/5/2023 - 7/12/2023
----------------------------------------------------
Week: 27 7/13/2023 - 7/20/2023
----------------------------------------------------
Week: 28 7/21/2023 - 7/28/2023
----------------------------------------------------
Week: 29 7/29/2023 - 8/5/2023
----------------------------------------------------
Week: 30 8/6/2023 - 8/13/2023
----------------------------------------------------
Week: 31 8/14/2023 - 8/21/2023
----------------------------------------------------
Week: 32 8/22/2023 - 8/29/2023
----------------------------------------------------
Week: 33 8/30/2023 - 9/6/2023
----------------------------------------------------
Week: 34 9/7/2023 - 9/14/2023
----------------------------------------------------
Week: 35 9/15/2023 - 9/22/2023
----------------------------------------------------
Week: 36 9/23/2023 - 9/30/2023
----------------------------------------------------
Week: 37
----------------------------------------------------
Week: 38
----------------------------------------------------
Week: 39
----------------------------------------------------
Week: 40
----------------------------------------------------
Week: 41
----------------------------------------------------
Week: 42
----------------------------------------------------
Week: 43
----------------------------------------------------
Week: 44
----------------------------------------------------
Week: 45
----------------------------------------------------
Week: 46
----------------------------------------------------
Week: 47
----------------------------------------------------
Week: 48
----------------------------------------------------
Week: 49
----------------------------------------------------
Week: 50
----------------------------------------------------
Week: 51
----------------------------------------------------
Week: 52
----------------------------------------------------
Week: 53
----------------------------------------------------
Week: 54
----------------------------------------------------
Week: 55
----------------------------------------------------
</code>```

I am currently not sure what to try at the given moment. I have only tried making additional changes to my function by splitting up the months in to separate else if statements so there wouldn't be so many arguments on one line, but other than that I have not tried anything else, and that is why I am here now. Thank you for any help.

Body:
I have this function below that essentially will print out a schedule on a week by week basis. This is what I have so far.

void Date::increaseWeek()
{
    int increaseWeek = (day + 7);
    int increaseDay = (day + 1);
    int increasedDay = (day + 1);
    int increaseMonth = (month + 1);
    int increaseYear = (year + 1);

    if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10)
    {
        if (day < 31)
        {
            std::cout << " " << month << '/' << day << '/' << year
                << " - ";

            if (increaseWeek > 31)
            {
                int subDate = increaseWeek - 32;
                day = 1 + subDate;
                std::cout << increaseMonth << '/' << day << '/' << year;
                month++;
                day++;
            }
            else
            {
                std::cout << month << '/' << increaseWeek << '/' << year;
                int addDay = increaseWeek + 1;
                day = addDay;
            }
        }
        else if (day == 31)
        {
            std::cout << " " << month << '/' << day << '/' << year
                << " - ";
            int subDate = increaseWeek - 32;
            day = 1 + subDate;
            std::cout << increaseMonth << '/' << day << '/' << year;
            int increaseDayAgain = day + 1;
            day = increaseDayAgain;
            month++;
        }
    }
    else if (month == 4 || month == 6 || month == 9 || month == 11)
    {
        if (day < 30)
        {
            std::cout << " " << month << '/' << day << '/' << year
                << " - ";

            if (increaseWeek > 30)
            {
                int subDate = increaseWeek - 31;
                day = 1 + subDate;
                std::cout << increaseMonth << '/' << day << '/' << year;
                month++;
            }
            else
            {
                std::cout << month << '/' << increaseWeek << '/' << year;
                int addDay = increaseWeek + 1;
                day = addDay;
            }
        }
        else if (day == 30)
        {
            std::cout << " " << month << '/' << day << '/' << year
                << " - ";
            int subDate = increaseWeek - 31;
            day = 1 + subDate;
            std::cout << increaseMonth << '/' << day << '/' << year;
            int increaseDayAgain = day + 1;
            day = increaseDayAgain;
            month++;
        }
    }
    else if (month == 2)
    {
        if (day < 28)
        {
            std::cout << " " << month << '/' << day << '/' << year
                << " - ";

            if (increaseWeek > 28)
            {
                int subDate = increaseWeek - 29;
                day = 1 + subDate;
                std::cout << increaseMonth << '/' << day << '/' << year;
                month++;
            }
            else
            {
                std::cout << month << '/' << increaseWeek << '/' << year;
                int addDay = increaseWeek + 1;
                day = addDay;
            }
        }
        else if (day == 28)
        {
            std::cout << " " << month << '/' << day << '/' << year
                << " - ";
            int subDate = increaseWeek - 29;
            day = 1 + subDate;
            month = 1;
            std::cout << increaseMonth << '/' << day << '/' << year;
            int increaseDayAgain = day + 1;
            day = increaseDayAgain;
            month++;

            //int addDay = rangeDay + 1;
            //day = addDay;
        }
    }
     else if (month == 12)
    {
    if (day < 31)
    {
        std::cout << " " << month << '/' << day << '/' << year
            << " - ";

        if (increaseWeek > 31)
        {
            int subDate = increaseWeek - 32;
            day = 1 + subDate;
            month = 1;
            std::cout << month << '/' << day << '/' << increaseYear;
            day++;
            year++;
        }
        else
        {
            std::cout << month << '/' << increaseWeek << '/' << year;
            int addDay = increaseWeek + 1;
            day = addDay;
        }
    }
    else if (day == 31)
    {
        month = 1;
        std::cout << " " << month << '/' << day << '/' << year
            << " - ";
        int subDate = increaseWeek - 32;
        day = 1 + subDate;
        std::cout << month << '/' << day << '/' << increaseYear;
        int increaseDayAgain = day + 1;
        day = increaseDayAgain;
        year++;
    }
    }
}

The function above seems to work until the I use it on a much larger scale. The code below is going to print a schedule for apple over the course of _____ weeks.

std::string fruitChoice = "Apple";
            int courseOfLife = (rand() % 350) + 349;
            int weeksOfLife = (courseOfLife / 7);

            std::cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << std::endl;
            std::cout << "        SCHEDULE FOR APPLE        " << std::endl;
            std::cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << std::endl;

            printInstructionsFruit();

            Fruit appleObj = Fruit("Apple", 1, 1, 1, 1, "yes", 1, 1);
            appleObj.whenToWater();
            appleObj.light();
            appleObj.whenToFertilize();

            std::cout << courseOfLife;
            for (int i = 1; i <= weeksOfLife; i++)
            {
                std::cout << "Week: " << i;
                while (i < courseOfLife)
                {
                    userdate.increaseWeek();
                    break;
                }

                std::cout << "\n----------------------------------------------------" << std::endl;
            }

        }

This is the output that I get from running the code. The user enters a date, and a schedule is printed week by week from the first day that the user enters. However there are some problems. The week is not implemented the whole way through. The second problem is the line from above
int courseOfLife = (rand() % 350) + 349; is printing out that the courseOfLife is 390 which doesn't make sense considering the rand I have set up only allows a range of choices from 349 - 350
What I want to know is how do I make the schedule keep printing through the whole courseOfLife on a weeksOfLife Basis?

Week: 1 12/20/2022 - 12/27/2022
----------------------------------------------------
Week: 2 12/28/2022 - 1/4/2023
----------------------------------------------------
Week: 3 1/5/2023 - 1/12/2023
----------------------------------------------------
Week: 4 1/13/2023 - 1/20/2023
----------------------------------------------------
Week: 5 1/21/2023 - 1/28/2023
----------------------------------------------------
Week: 6 1/29/2023 - 2/5/2023
----------------------------------------------------
Week: 7 2/6/2023 - 2/13/2023
----------------------------------------------------
Week: 8 2/14/2023 - 2/21/2023
----------------------------------------------------
Week: 9 2/22/2023 - 3/1/2023
----------------------------------------------------
Week: 10 3/1/2023 - 3/8/2023
----------------------------------------------------
Week: 11 3/9/2023 - 3/16/2023
----------------------------------------------------
Week: 12 3/17/2023 - 3/24/2023
----------------------------------------------------
Week: 13 3/25/2023 - 4/1/2023
----------------------------------------------------
Week: 14 4/2/2023 - 4/9/2023
----------------------------------------------------
Week: 15 4/10/2023 - 4/17/2023
----------------------------------------------------
Week: 16 4/18/2023 - 4/25/2023
----------------------------------------------------
Week: 17 4/26/2023 - 5/3/2023
----------------------------------------------------
Week: 18 5/3/2023 - 5/10/2023
----------------------------------------------------
Week: 19 5/11/2023 - 5/18/2023
----------------------------------------------------
Week: 20 5/19/2023 - 5/26/2023
----------------------------------------------------
Week: 21 5/27/2023 - 6/3/2023
----------------------------------------------------
Week: 22 6/4/2023 - 6/11/2023
----------------------------------------------------
Week: 23 6/12/2023 - 6/19/2023
----------------------------------------------------
Week: 24 6/20/2023 - 6/27/2023
----------------------------------------------------
Week: 25 6/28/2023 - 7/5/2023
----------------------------------------------------
Week: 26 7/5/2023 - 7/12/2023
----------------------------------------------------
Week: 27 7/13/2023 - 7/20/2023
----------------------------------------------------
Week: 28 7/21/2023 - 7/28/2023
----------------------------------------------------
Week: 29 7/29/2023 - 8/5/2023
----------------------------------------------------
Week: 30 8/6/2023 - 8/13/2023
----------------------------------------------------
Week: 31 8/14/2023 - 8/21/2023
----------------------------------------------------
Week: 32 8/22/2023 - 8/29/2023
----------------------------------------------------
Week: 33 8/30/2023 - 9/6/2023
----------------------------------------------------
Week: 34 9/7/2023 - 9/14/2023
----------------------------------------------------
Week: 35 9/15/2023 - 9/22/2023
----------------------------------------------------
Week: 36 9/23/2023 - 9/30/2023
----------------------------------------------------
Week: 37
----------------------------------------------------
Week: 38
----------------------------------------------------
Week: 39
----------------------------------------------------
Week: 40
----------------------------------------------------
Week: 41
----------------------------------------------------
Week: 42
----------------------------------------------------
Week: 43
----------------------------------------------------
Week: 44
----------------------------------------------------
Week: 45
----------------------------------------------------
Week: 46
----------------------------------------------------
Week: 47
----------------------------------------------------
Week: 48
----------------------------------------------------
Week: 49
----------------------------------------------------
Week: 50
----------------------------------------------------
Week: 51
----------------------------------------------------
Week: 52
----------------------------------------------------
Week: 53
----------------------------------------------------
Week: 54
----------------------------------------------------
Week: 55
----------------------------------------------------

I am currently not sure what to try at the given moment. I have only tried making additional changes to my function by splitting up the months in to separate else if statements so there wouldn't be so many arguments on one line, but other than that I have not tried anything else, and that is why I am here now. Thank you for any help.


问:
UWP Application Crashed after launching when build created by Windows-2019 Agent pool
Have a UWP application that runs fine when the build was created by VS2017 Agent pool in DevOps. But on using windows-2019 Agent pool, the build runs successful. On running the exe created with the windows-2019 agent, the application crashed immediately.
Below are the
Event log 1(Application Error):
Faulting module name: CoreCLR.dll, version: 4.6.27902.3, time stamp: 0x5d1bcbcd
Faulting module path: C:\Program Files\WindowsApps\Microsoft.NET.CoreRuntime.2.2_2.2.27902.3_x64__8wekyb3d8bbwe\CoreCLR.dll

Event Log(.NET Runtime):
CoreCLR Version: 4.6.27902.3
Description: The process was terminated due to an internal error in the .NET Runtime at IP 00007FFD19AE5AF3 (00007FFD19940000) with exit code c0000005.

How to solve this issue?


问:
Jackson @JsonFormat date without double quotes
I have this POJO :

```<code>@JsonIgnoreProperties(ignoreUnknown = true)
public class Test {
    @JsonFormat(pattern = "yyyyMMdd")
    private Date date;
}
</code>```

and I got json like this:

```<code>{"date": 20221201}
</code>```

the date value should be an string. but i can not change anything, it's passed from other service.

it can't be parsed. the date property is always 1970-01-01.

how do i parse a date string without quotes?? is there any way to solve this? Thanks.

Body:
I have this POJO :

@JsonIgnoreProperties(ignoreUnknown = true)
public class Test {
    @JsonFormat(pattern = "yyyyMMdd")
    private Date date;
}

and I got json like this:

{"date": 20221201}

the date value should be an string. but i can not change anything, it's passed from other service.

it can't be parsed. the date property is always 1970-01-01.

how do i parse a date string without quotes?? is there any way to solve this? Thanks.


问:
Make the OpenCV libraries that the binary program really needs available to the customer
I have installed the OpenCV package in Ubuntu22.04 by sudo apt-get.

And the said OpenCV is one of the dependencies for my project.

The problem is that the target computer does not have installed OpenCV and it's impossible to use sudo permission.

How to make the OpenCV that I am using portable by the install command of Cmake? I intend to copy the OpenCV libraries when make install is invoked.

What I have tried is seen below.

Here is a portion of the CMakeLists.txt:

```<code>find_package( OpenCV REQUIRED )

message("OpenCV_LIBS:")
foreach(lib  ${OpenCV_LIBS})
message("${lib}")
endforeach()

install(FILES ${OpenCV_LIBS} TYPE LIB)
</code>```

Here is the output when cmake .. is invoked:

```<code>OpenCV_LIBS:
opencv_calib3d
opencv_core
opencv_dnn
opencv_features2d
opencv_flann
opencv_highgui
//omits some similar output
</code>```

Here is the error message when make install is called:

```<code>CMake Error at cmake_install.cmake:130 (file):
  file INSTALL cannot find "/home/john/myproject/opencv_calib3d":
  No such file or directory.
</code>```

And what's more, how to only make the libraries that the binary program really needs available to the customer other than sending all the libraries of OpenCV to the customer?

Tips: the customer uses the same OS.

Body:
I have installed the OpenCV package in Ubuntu22.04 by sudo apt-get.

And the said OpenCV is one of the dependencies for my project.

The problem is that the target computer does not have installed OpenCV and it's impossible to use sudo permission.

How to make the OpenCV that I am using portable by the install command of Cmake? I intend to copy the OpenCV libraries when make install is invoked.

What I have tried is seen below.

Here is a portion of the CMakeLists.txt:

find_package( OpenCV REQUIRED )

message("OpenCV_LIBS:")
foreach(lib  ${OpenCV_LIBS})
message("${lib}")
endforeach()

install(FILES ${OpenCV_LIBS} TYPE LIB)

Here is the output when cmake .. is invoked:

OpenCV_LIBS:
opencv_calib3d
opencv_core
opencv_dnn
opencv_features2d
opencv_flann
opencv_highgui
//omits some similar output

Here is the error message when make install is called:

CMake Error at cmake_install.cmake:130 (file):
  file INSTALL cannot find "/home/john/myproject/opencv_calib3d":
  No such file or directory.

And what's more, how to only make the libraries that the binary program really needs available to the customer other than sending all the libraries of OpenCV to the customer?

Tips: the customer uses the same OS.


问:
The Git process exit code 138 (interrupted by signal 10: SIGBUS)
Every time, when I commit or push, this comment shows up.

I'm using company network for project folder(with co-workers), and we push project on gitlab.
Someone(including me) use m1(mac), others use windows(Not sure is this related o
r not ^^:)

My os: Mac m1(Sliicon)

Those 3 are what I tried to solve.

sudo sysctl -w kern.maxfilesperproc=524288

sudo sysctl -p

git config --global core.autocrlf true input

Please help me T.T

I appreciate who can tell me how to solve this problem.


问:
Running Python file uses the wrong directory? "No such file or directory" as a result
Brand new to Python, and I wrote a simple script to print some data from an Excel sheet using Pandas. I installed Pandas via Anaconda.

Weirdly when I run my .py file, ~1/4 times when I hit "Run Python File" in VSCode it gives me an error that it can't find the current .py file. The terminal shows:

```<code>... ~/Desktop/PSI Work/Python Data Work VSCode Project
$ Desktop/PSI Work/Python Data Work VSCode Project/dC:/Users/soup/anaconda3/python.exe "c:/Users/soup/ataWork.py"
bash: Desktop/PSI: No such file or directory
(base)
</code>```

The filename is "dataWork.py", but for some reason it sometimes inserts the "d" in "dataWork" before the "C:" portion of the directory, breaking the path

.../dC:/Users/soup/anaconda3/python.exe
"c:/Users/soup/ataWork.py"

Running it again usually does the trick... but I'm a bit puzzled.

Body:
Brand new to Python, and I wrote a simple script to print some data from an Excel sheet using Pandas. I installed Pandas via Anaconda.

Weirdly when I run my .py file, ~1/4 times when I hit "Run Python File" in VSCode it gives me an error that it can't find the current .py file. The terminal shows:

... ~/Desktop/PSI Work/Python Data Work VSCode Project
$ Desktop/PSI Work/Python Data Work VSCode Project/dC:/Users/soup/anaconda3/python.exe "c:/Users/soup/ataWork.py"
bash: Desktop/PSI: No such file or directory
(base)

The filename is "dataWork.py", but for some reason it sometimes inserts the "d" in "dataWork" before the "C:" portion of the directory, breaking the path

.../dC:/Users/soup/anaconda3/python.exe
"c:/Users/soup/ataWork.py"

Running it again usually does the trick... but I'm a bit puzzled.


问:
Android Oboe Library size
We are trying to integrate Oboe and the library size seems to be big.We dont need any processing like resampling ,format conversion .This we do in app and would like to know if its possible to significantly reduce library size with our only requirement using Oboe being for Audio IO.

The source to configuring streams with flow graphs where lot of processing code seems to exist.Is there any easy way to take this processing code and use only Audio IO part.

Title: Android Oboe Library size


问:
SVG security validation using safe-svg jar
Svg files are validated based on the set of SVG_ELEMENTS,SVG_ATTRIBUTES defined by safe-svg validator jar. So when the svg is implemented by the tags which are not part of SVG_ELEMENTS,SVG_ATTRIBUTES then we are getting violations. So here, in which basis SVG_ELEMENTS,SVG_ATTRIBUTES are defined.
Ex of unsupported tags and attributes by safe-svg jar : missing-glyph,font-face-src,xmlns:xodm,horiz-adv-x

How the SVG_ELEMENTS and SVG_ATTRIBUTES are meant to be valid tag or invalid tags ?
Also do we have any other security validator to validate svg files other than safe-svg jar ?


问:
How to solve this GITHUB error in Eclipse?
I wrote a JAVA class in Eclipse:

```<code>package sample123;

public class sample2 {

}
</code>```

Same way, I created a file in my GITHUB repository:

```<code>package sample123;

public class sample2 {

}
</code>```

When I commit that JAVA class from eclipse to GITHUB:

How to solve this error in Eclipse?

Body:
I wrote a JAVA class in Eclipse:

package sample123;

public class sample2 {

}

Same way, I created a file in my GITHUB repository:

package sample123;

public class sample2 {

}

When I commit that JAVA class from eclipse to GITHUB:

How to solve this error in Eclipse?


问:
passing two arrays in foreach
passing ajax posting values in php laravel controller only one selected dropdown options array values are inserted  so required two arrays of two selected drop list values to be inserted
get array of values

'$.ajax({
dataType: 'json',
url: "/getCity/"+id,
type: "GET",
success: function (data) {
console.log(data);

```<code>            $('select[name="GLNO[]"]').empty();
                $.each(data, function(key,data){
                  $('select[name="GLNO[]"]').append('<option value="'+ data.GLNO +'">'+ data.GLNO +'</option>');

            });
            $('select[name="NAME[]"]').empty();
                $.each(data, function(key,data){
                  $('select[name="NAME[]"]').append('<option value="'+ data.NAME +'">'+ data.NAME +'</option>');

            });
</code>```

``
post array of values

```<code> $('#ProductForm').submit(function(e) {
            e.preventDefault();
            var formData = new FormData(this);
            $.ajax({
                type: 'POST',
                url: "{{ url('store-product') }}",
                data: formData,

                cache: false,
                contentType: false,
                processData: false,
                success: (data) => {
                    $("#product-modal").modal('hide');
                    var oTable = $('#products').dataTable();

                    oTable.fnDraw(false);
                    $("#btn-save").html('Submit');
                    $("#btn-save").attr("disabled", false);

                },
                error: function(data) {
                    console.log(data);
                }
            });
        });

form of multiple selected dropdown

                        <div class="form-group">
                            <label for="name" class="col-sm-2 control-label">GLNO</label>

                            <div class="col-sm-12">

                            <select  name="GLNO[]" multiple  id="glno"   class="form-control" >

<option value=""></option>
                        </select>

                            </div>
                        </div>

                        <div class="form-group">
                            <label for="name" class="col-sm-2 control-label">GLNO</label>

                            <div class="col-sm-12">

                            <select  name="NAME[]" multiple  id="name"   class="form-control" >
<option value=""></option>
                        </select>

                            </div>
                        </div>
</code>```

controller of store

```<code>
    public function store(Request $request)
    {

         $productId = $request->id;

        $request->validate([

            'fmcode',
            'fmcodes',
            'area',
            'naoffm','glno','frmdate',
            'todate'
        ]);
        $input = $request->all();
     $products=$request->GLNO;

     foreach ((array)$products as $product1) {

        $product = Product::updateOrCreate(
            [
              'id'=> $productId ,
                'fmcode' => $request->FMCODE,
                'fmcodes' => $request->FMCODES,
                'area' => $request->AREA,

                'naoffm' => $request->NAOFFM,
                'frmdate' => $request->frmdate,
                'todate' => $request->todate,
                'glno'=>$product1
            ]
        );

     }
        return Response()->json($product);

    }'

inserting two array multiple selected dropdown list values its showing error of inserting values so how we can pass values in for each loop for two request of values
</code>```

Title: passing two arrays in foreach

Body:
passing ajax posting values in php laravel controller only one selected dropdown options array values are inserted  so required two arrays of two selected drop list values to be inserted
get array of values

'$.ajax({
dataType: 'json',
url: "/getCity/"+id,
type: "GET",
success: function (data) {
console.log(data);

            $('select[name="GLNO[]"]').empty();
                $.each(data, function(key,data){
                  $('select[name="GLNO[]"]').append('<option value="'+ data.GLNO +'">'+ data.GLNO +'</option>');

            });
            $('select[name="NAME[]"]').empty();
                $.each(data, function(key,data){
                  $('select[name="NAME[]"]').append('<option value="'+ data.NAME +'">'+ data.NAME +'</option>');

            });

``
post array of values

 $('#ProductForm').submit(function(e) {
            e.preventDefault();
            var formData = new FormData(this);
            $.ajax({
                type: 'POST',
                url: "{{ url('store-product') }}",
                data: formData,

                cache: false,
                contentType: false,
                processData: false,
                success: (data) => {
                    $("#product-modal").modal('hide');
                    var oTable = $('#products').dataTable();

                    oTable.fnDraw(false);
                    $("#btn-save").html('Submit');
                    $("#btn-save").attr("disabled", false);

                },
                error: function(data) {
                    console.log(data);
                }
            });
        });

form of multiple selected dropdown

                            GLNO

                            <select  name="GLNO[]" multiple  id="glno"   class="form-control" >

<option value=""></option>
                        </select>

                            GLNO

                            <select  name="NAME[]" multiple  id="name"   class="form-control" >
<option value=""></option>
                        </select>

controller of store

    public function store(Request $request)
    {

         $productId = $request->id;

        $request->validate([

            'fmcode',
            'fmcodes',
            'area',
            'naoffm','glno','frmdate',
            'todate'
        ]);
        $input = $request->all();
     $products=$request->GLNO;

     foreach ((array)$products as $product1) {

        $product = Product::updateOrCreate(
            [
              'id'=> $productId ,
                'fmcode' => $request->FMCODE,
                'fmcodes' => $request->FMCODES,
                'area' => $request->AREA,

                'naoffm' => $request->NAOFFM,
                'frmdate' => $request->frmdate,
                'todate' => $request->todate,
                'glno'=>$product1
            ]
        );

     }
        return Response()->json($product);

    }'

inserting two array multiple selected dropdown list values its showing error of inserting values so how we can pass values in for each loop for two request of values


问:
Is it possible to detect users click emoji on specific channel for specific server?
I think I need some answer from discord api experts.
I'm wondering if someone can detect using bots below logics.
If we enter the server, we will have initial channel. (for example Welcome)
There some rules will be described and we will have emojis like check / symbols for the server.
And after user click, bot can detect the user id and can send direct message to him/her.
Is it possible for the outside guy of the server? (I mean without any discord related api key)
Thanks

Since I don't have exp with this just went through the discord docs, but didn't find proper resources.


问:
Unable to debug project with the Debugger Atmel-ICE and CPU ATtiny13a
I am currently facing an issue where I have connect the debugger via USB to my laptop, power on its Atmel-ICE debugger with the CPU ATtiny13a. After clean and build project successfully, I didn't managed to debug it.

It resulted in the error: Failed to enable DW: Failed to enter programming mode. ispEnterProgMode: Error status received: Got 0xc0, expected 0x00 (Command has failed to execute on the tool)

I have tried to troubleshoot by checking the wiring connection. It shows connection to my laptop as the debugger lights up with green LED when i powered it up with 12V, and red LED lights up to show debugger has been connected.

Could it be the connection issue or failure in the chip or debugger board having issue?

Would like to have some advice on what I can do. Thank you so much!


问:
Does MongoDB have set for data structure?
I have a list of user ids stored in a field of MongoDB collection. Each of the user ids is an UUID. The field is an array. For example,

```<code>["59cc7562-751b-11ed-a1eb-0242ac120002", "66e6f240-751b-11ed-a1eb-0242ac120002",
"742df8ea-751b-11ed-a1eb-0242ac120002", ............,"6cf6e398-751b-11ed-a1eb-0242ac120002"]
</code>```

Now, if I want to check whether a user id is in the array, i need to do loop through the array until I find the user id or reach the end of the array. This is slow. I wonder if I can use a set to store the user ids instead of an array.

I am using Next.Js in the backend. If I convert the array to a set, that would be even slower than just looping through the array since the conversion takes o(n).

Body:
I have a list of user ids stored in a field of MongoDB collection. Each of the user ids is an UUID. The field is an array. For example,

["59cc7562-751b-11ed-a1eb-0242ac120002", "66e6f240-751b-11ed-a1eb-0242ac120002",
"742df8ea-751b-11ed-a1eb-0242ac120002", ............,"6cf6e398-751b-11ed-a1eb-0242ac120002"]

Now, if I want to check whether a user id is in the array, i need to do loop through the array until I find the user id or reach the end of the array. This is slow. I wonder if I can use a set to store the user ids instead of an array.

I am using Next.Js in the backend. If I convert the array to a set, that would be even slower than just looping through the array since the conversion takes o(n).


问:
I am not able to understand why parent reference variable value of all recursive calls changes as soon as parent=n is done?
```<code>    Node parent;
    private int size;

    public void addNodes() {
        if (size == 0) {
            Node n = new Node(sc.nextInt());
            parent = n;
            root = n;
            size++;
        }

        System.out.println("Does " + parent.data + " have a left node");

        if (sc.nextBoolean()) {
            Node n = new Node(sc.nextInt());
            parent.left = n;
            parent = n;
            addNodes();
        }

        System.out.println("Does " + parent.data + " have a right node?");

        if (sc.nextBoolean()) {
            Node n = new Node(sc.nextInt());
            parent.right = n;
            parent = n;
            addNodes();
        }
    }
</code>```

I cannot understand why the parent reference variable value of all recursive calls changes as soon as parent = n is done.

If there is any doubt in question, just run the program. I have tried to create a binary tree and initialize it using recursion.

Body:
    Node parent;
    private int size;

    public void addNodes() {
        if (size == 0) {
            Node n = new Node(sc.nextInt());
            parent = n;
            root = n;
            size++;
        }

        System.out.println("Does " + parent.data + " have a left node");

        if (sc.nextBoolean()) {
            Node n = new Node(sc.nextInt());
            parent.left = n;
            parent = n;
            addNodes();
        }

        System.out.println("Does " + parent.data + " have a right node?");

        if (sc.nextBoolean()) {
            Node n = new Node(sc.nextInt());
            parent.right = n;
            parent = n;
            addNodes();
        }
    }

I cannot understand why the parent reference variable value of all recursive calls changes as soon as parent = n is done.

If there is any doubt in question, just run the program. I have tried to create a binary tree and initialize it using recursion.


问:
How to omit properties from functions
How would one omit a property from a function:

type OmitError = Omit<{
    <T>(result: T): void
    (...results: any[]): void;
    error(...errors: any[]): void;
},'error'>
// returns {} but should return
// {
//   <T>(result: T): void
//   (...results: any[]): void;
// }
```

Title: How to omit properties from functions


问:
What format is the data in the clipt parameter?
I am trying to programatically generate YouTube embed URLs using standard YouTube URLs. I'm having trouble generating embed URLs for Clips. The clipt parameter is not listed in Google's documentation of YouTube embedded player parameters

https://www.youtube.com/embed/qVqV5T45QB0?clip=Ugkx97OCpf318BJnwKLlPj48mCBSes4MBD3w&clipt=EAAYiCc

The part after /embed/ is the ID of the original video. clip is the ID of the clip. clipt appears to be the start time and end time of the clip, however, I do not know what format this number is in. The embed URL above has a start and end time of 0:00.0 - 0:05.0.

EAAY7Cc is the value for a start and end time of 0:00.0 - 0:05.1.

EAAY0Cg is 0:00.0 - 0:05.2

EAAYtCk is 0:00.0 - 0:05.3

EAAYmCo is 0:00.0 - 0:05.4

EAAY8C4 is 0:00.0 - 0:06.0

EAAY2DY is 0:00.0 - 0:07.0

EGQY8C4 is 0:00.1 - 0:06.0

EMgBGPAu is 0:00.2 - 0:06.0

EKwCGPAu is 0:00.3 - 0:06.0

EOgHGPAu is 0:01.0 - 0:06.0

I have attempted to decode these numbers as base64, base58, base32, and base16; none of the outputs looked correct.

An explanation of the format for video IDs is available here. Even while using this document, I was unable to solve how to convert "0:00.0 - 0:05.0" to EAAYiCc


问:
find if all elements of a list exists in a file and create new list
Team,
issue is that it is still appending those lines to needed_list that match the pattern defined in skip_list. Not sure if there is space or why it is not skipping them, ex: // or }

I have two files and I need to see if a string from each line in fileA is referred in file2.

For this, I am looping over all strings just before : in fileA and check against all lines in file2 and printing them and skipping those lines from being printed that are not used in file2.

But I am observing that some strings from skip_list are still being printed.
Please ignore what sort of files these are because these are manually created sample files to test code.

file1

```<code>package deploy
application: sonarqube: helm: values: {
    sonarqube: {
        namespace:      "sonarqube"
        deploymentType: "StatefulSet"
        role:       "server"
        // There should not be more than 1 sonarqube instance connected to the same database. Please set this value to 1 or 0 (in case you need to scale down programmatically).
</code>```

file2

```<code>metadata:
  name: {{ .scanjob }}
  namespace: {{ .Values.namespace }}
  command: ls
  deploy: deploymentType
  type: role: server
</code>```

code

```<code>class SearchIn():

    skip_list = ['{','}','/','[]','[',']','//','#']
    needed_list = []
    def charts_files(self, args):
        chart_name = args
        self.local_path = Path(environ.get("HOME"))/chart_name/"templates"
        self.files_list=listdir(local_path)
        return self.files_list

    def values(self, args):
        self.charts_files(chart_name)
        values = "values.cue"
        with open(self.local_path/values, 'r') as v:
            for aline in v:
                trimmed_line=aline.strip().split(":",1)[0]
                print(trimmed_line)
                for aptrn in self.skip_list:
                    if aptrn in trimmed_line or aptrn is trimmed_line:
                        continue
                    else:
                        print("no pattern found")
                        print(trimmed_line)
                        if trimmed_line not in self.needed_list:
                            self.needed_list.append(trimmed_line)
        print(self.needed_list)
co = SearchIn()
chart_name = input(r'Enter chart name:')
co.values(chart_name)
</code>```

Output: some snip

```<code>}
no pattern found
}
['package deploy', 'application', 'sonarqube', 'namespace', 'deploymentType', 'role', '// There should not.....
..
..

</code>```

expected output
needed_list should not contain any element from skip_list

```<code>}
['package deploy', 'application', 'sonarqube', 'namespace', 'deploymentType','role'....]

</code>```

Body:
Team,
issue is that it is still appending those lines to needed_list that match the pattern defined in skip_list. Not sure if there is space or why it is not skipping them, ex: // or }

I have two files and I need to see if a string from each line in fileA is referred in file2.

For this, I am looping over all strings just before : in fileA and check against all lines in file2 and printing them and skipping those lines from being printed that are not used in file2.

But I am observing that some strings from skip_list are still being printed.
Please ignore what sort of files these are because these are manually created sample files to test code.

file1

package deploy
application: sonarqube: helm: values: {
    sonarqube: {
        namespace:      "sonarqube"
        deploymentType: "StatefulSet"
        role:       "server"
        // There should not be more than 1 sonarqube instance connected to the same database. Please set this value to 1 or 0 (in case you need to scale down programmatically).

file2

metadata:
  name: {{ .scanjob }}
  namespace: {{ .Values.namespace }}
  command: ls
  deploy: deploymentType
  type: role: server

code

class SearchIn():

    skip_list = ['{','}','/','[]','[',']','//','#']
    needed_list = []
    def charts_files(self, args):
        chart_name = args
        self.local_path = Path(environ.get("HOME"))/chart_name/"templates"
        self.files_list=listdir(local_path)
        return self.files_list

    def values(self, args):
        self.charts_files(chart_name)
        values = "values.cue"
        with open(self.local_path/values, 'r') as v:
            for aline in v:
                trimmed_line=aline.strip().split(":",1)[0]
                print(trimmed_line)
                for aptrn in self.skip_list:
                    if aptrn in trimmed_line or aptrn is trimmed_line:
                        continue
                    else:
                        print("no pattern found")
                        print(trimmed_line)
                        if trimmed_line not in self.needed_list:
                            self.needed_list.append(trimmed_line)
        print(self.needed_list)
co = SearchIn()
chart_name = input(r'Enter chart name:')
co.values(chart_name)

Output: some snip

}
no pattern found
}
['package deploy', 'application', 'sonarqube', 'namespace', 'deploymentType', 'role', '// There should not.....
..
..

expected output
needed_list should not contain any element from skip_list

}
['package deploy', 'application', 'sonarqube', 'namespace', 'deploymentType','role'....]


问:
move_uploaded_file - Failed to open stream: Invalid argument PHP
```<code>my web directory is at ip 192.168.120.3 , when I upload an image, I want the image to be stored in a different folder from my web directory, for example saved at ip 192.168.120.4, how do I do that?
</code>```

This is my code :

```<code>$newname = $getFileName."-".date('YmdHis',time()).mt_rand().'.jpg';
$target =  '\\\\192.168.164.5\\Common Pict\\'.$newname;
$tmp = $val['tmp_name'];

move_uploaded_file($tmp, $target);
</code>```

Error :

move_uploaded_file(\192.168.164.5\Common Pict\m-20221206105651907307421.jpg): failed to open stream: Invalid argument

Code working if i upload an image to web directory:

```<code>$newname = $getFileName."-".date('YmdHis',time()).mt_rand().'.jpg';
$target =  '\\\\192.168.120.3\\Common Pict\\'.$newname;
$tmp = $val['tmp_name'];

move_uploaded_file($tmp, $target);
</code>```

Body:
my web directory is at ip 192.168.120.3 , when I upload an image, I want the image to be stored in a different folder from my web directory, for example saved at ip 192.168.120.4, how do I do that?

This is my code :

$newname = $getFileName."-".date('YmdHis',time()).mt_rand().'.jpg';
$target =  '\\\\192.168.164.5\\Common Pict\\'.$newname;
$tmp = $val['tmp_name'];

move_uploaded_file($tmp, $target);

Error :

move_uploaded_file(\192.168.164.5\Common Pict\m-20221206105651907307421.jpg): failed to open stream: Invalid argument

Code working if i upload an image to web directory:

$newname = $getFileName."-".date('YmdHis',time()).mt_rand().'.jpg';
$target =  '\\\\192.168.120.3\\Common Pict\\'.$newname;
$tmp = $val['tmp_name'];

move_uploaded_file($tmp, $target);


问:
Angular 12: ngx-charts-line-chart x axis plotting date data and ordering issue
I am using  ngx-charts-line-chart  of "@swimlane/ngx-charts": "^16.0.0" . I have following config.data that will render on line chart.

```<code>[
      {
        "name": "North East Region",
        "series": [
          {
            "name": "2022-06-01",
            "value": 2.6296,
            "extra": {
              "hidden": false
            }
          },
          {
            "name": "2022-07-01",
            "value": 3.0741,
            "extra": {
              "hidden": false
            }
          },
          {
            "name": "2022-11-01",
            "value": 1.8958,
            "extra": {
              "hidden": false
            }
          }
        ],
        "extra": {
          "hidden": false
        }
      },
      {
        "name": "North West Region",
        "series": [
          {
            "name": "2022-06-01",
            "value": 2.8889,
            "extra": {
              "hidden": false
            }
          },
          {
            "name": "2022-10-01",
            "value": 2.4074,
            "extra": {
              "hidden": false
            }
          }
        ],
        "extra": {
          "hidden": false
        }
      },
      {
        "name": "Pharmacy",
        "series": [
          {
            "name": "2022-07-01",
            "value": 2.7907,
            "extra": {
              "hidden": false
            }
          },
          {
            "name": "2022-09-01",
            "value": 2.4074,
            "extra": {
              "hidden": false
            }
          },
          {
            "name": "2022-10-01",
            "value": 2.1071,
            "extra": {
              "hidden": false
            }
          }
        ],
        "extra": {
          "hidden": false
        }
      }
    ]
</code>```

HTML

```<code><ngx-charts-line-chart *ngIf="config && config.data"
                                   [autoScale]="true"
                                   [legend]="config.size !== 'small'"
                                   [legendPosition]="'below'"
                                   [results]="config.data"
                                   [roundDomains]="true"
                                   [scheme]="colors"
                                   [showGridLines]="config.size !== 'small'"
                                   [showXAxisLabel]="config.size !== 'small'"
                                   [showYAxisLabel]="config.size !== 'small'"
                                   [timeline]="config.size !== 'small'"
                                   [view]="getView()"
                                   [xAxis]="config.size !== 'small'"
                                   [xAxisLabel]="(config.xAxisLabel||'')|translate"
                                   [xAxisTickFormatting]="dateTickFormatting"
                                   [yAxis]="config.size !== 'small'"
                                   [yAxisLabel]="(config.yAxisLabel||'')|translate"
                                   [yScaleMax]="config.yScaleMax||4"
                                   [yScaleMin]="config.yScaleMin||1"
            >
            </ngx-charts-line-chart>
</code>```

Ts

```<code>public dateTickFormatting(val: Date | any): string {
        try {
            return moment(val).format('MMM-DD-YY');
        } catch (exception) {
            console.error(exception);
            return val;
        }
    }
</code>```

With above code, I was getting chart like below, where its taking 5 dates and not sorted/ not in order.

I need those dates in sort or in order so I searched and found like if I have data in numbers then those dates on X-axis will be in order so I got below data and frontend code

```<code>[
      {
        "name": "North East Region",
        "series": [
          {
            "name": 1654041600,
            "value": 2.6296,
            "extra": {
              "hidden": false
            }
          },
          {
            "name": 1656633600,
            "value": 3.0741,
            "extra": {
              "hidden": false
            }
          },
          {
            "name": 1667260800,
            "value": 1.8958,
            "extra": {
              "hidden": false
            }
          }
        ],
        "extra": {
          "hidden": false
        }
      },
      {
        "name": "North West Region",
        "series": [
          {
            "name": 1654041600,
            "value": 2.8889,
            "extra": {
              "hidden": false
            }
          },
          {
            "name": 1664582400,
            "value": 2.4074,
            "extra": {
              "hidden": false
            }
          }
        ],
        "extra": {
          "hidden": false
        }
      },
      {
        "name": "Pharmacy",
        "series": [
          {
            "name": 1656633600,
            "value": 2.7907,
            "extra": {
              "hidden": false
            }
          },
          {
            "name": 1661990400,
            "value": 2.4074,
            "extra": {
              "hidden": false
            }
          },
          {
            "name": 1664582400,
            "value": 2.1071,
            "extra": {
              "hidden": false
            }
          }
        ],
        "extra": {
          "hidden": false
        }
      }
    ]
</code>```

Ts

```<code>public dateTickFormatting(val: Date | any): string {
        try {
            let formatdt = new Date(1000*val);
            let formatdtString = formatDate(formatdt, 'MMM y', 'en-US');
            //return moment(formatdt).format('M/yy');
            return formatdtString;
        } catch (exception) {
            console.error(exception);
            return val;
        }
    }
</code>```

Now chart I am getting is like below, where it shows 8 values (different that earlier) and now its in order but Sep is getting repeated

Question

I am not getting why this is happening. How that chart is taking/rendering those X-axis values ?
On x axis, it should show like  Jun-22 Jul-22 Sep-22 Oct-22 Nov-22. How can I get this on that graph? Do I need to make changes in my Data format, in HTML etc?

Please guide and help. Thanks.

Body:
I am using  ngx-charts-line-chart  of "@swimlane/ngx-charts": "^16.0.0" . I have following config.data that will render on line chart.

[
      {
        "name": "North East Region",
        "series": [
          {
            "name": "2022-06-01",
            "value": 2.6296,
            "extra": {
              "hidden": false
            }
          },
          {
            "name": "2022-07-01",
            "value": 3.0741,
            "extra": {
              "hidden": false
            }
          },
          {
            "name": "2022-11-01",
            "value": 1.8958,
            "extra": {
              "hidden": false
            }
          }
        ],
        "extra": {
          "hidden": false
        }
      },
      {
        "name": "North West Region",
        "series": [
          {
            "name": "2022-06-01",
            "value": 2.8889,
            "extra": {
              "hidden": false
            }
          },
          {
            "name": "2022-10-01",
            "value": 2.4074,
            "extra": {
              "hidden": false
            }
          }
        ],
        "extra": {
          "hidden": false
        }
      },
      {
        "name": "Pharmacy",
        "series": [
          {
            "name": "2022-07-01",
            "value": 2.7907,
            "extra": {
              "hidden": false
            }
          },
          {
            "name": "2022-09-01",
            "value": 2.4074,
            "extra": {
              "hidden": false
            }
          },
          {
            "name": "2022-10-01",
            "value": 2.1071,
            "extra": {
              "hidden": false
            }
          }
        ],
        "extra": {
          "hidden": false
        }
      }
    ]

HTML

<ngx-charts-line-chart *ngIf="config && config.data"
                                   [autoScale]="true"
                                   [legend]="config.size !== 'small'"
                                   [legendPosition]="'below'"
                                   [results]="config.data"
                                   [roundDomains]="true"
                                   [scheme]="colors"
                                   [showGridLines]="config.size !== 'small'"
                                   [showXAxisLabel]="config.size !== 'small'"
                                   [showYAxisLabel]="config.size !== 'small'"
                                   [timeline]="config.size !== 'small'"
                                   [view]="getView()"
                                   [xAxis]="config.size !== 'small'"
                                   [xAxisLabel]="(config.xAxisLabel||'')|translate"
                                   [xAxisTickFormatting]="dateTickFormatting"
                                   [yAxis]="config.size !== 'small'"
                                   [yAxisLabel]="(config.yAxisLabel||'')|translate"
                                   [yScaleMax]="config.yScaleMax||4"
                                   [yScaleMin]="config.yScaleMin||1"
            >
            </ngx-charts-line-chart>

Ts

public dateTickFormatting(val: Date | any): string {
        try {
            return moment(val).format('MMM-DD-YY');
        } catch (exception) {
            console.error(exception);
            return val;
        }
    }

With above code, I was getting chart like below, where its taking 5 dates and not sorted/ not in order.

I need those dates in sort or in order so I searched and found like if I have data in numbers then those dates on X-axis will be in order so I got below data and frontend code

[
      {
        "name": "North East Region",
        "series": [
          {
            "name": 1654041600,
            "value": 2.6296,
            "extra": {
              "hidden": false
            }
          },
          {
            "name": 1656633600,
            "value": 3.0741,
            "extra": {
              "hidden": false
            }
          },
          {
            "name": 1667260800,
            "value": 1.8958,
            "extra": {
              "hidden": false
            }
          }
        ],
        "extra": {
          "hidden": false
        }
      },
      {
        "name": "North West Region",
        "series": [
          {
            "name": 1654041600,
            "value": 2.8889,
            "extra": {
              "hidden": false
            }
          },
          {
            "name": 1664582400,
            "value": 2.4074,
            "extra": {
              "hidden": false
            }
          }
        ],
        "extra": {
          "hidden": false
        }
      },
      {
        "name": "Pharmacy",
        "series": [
          {
            "name": 1656633600,
            "value": 2.7907,
            "extra": {
              "hidden": false
            }
          },
          {
            "name": 1661990400,
            "value": 2.4074,
            "extra": {
              "hidden": false
            }
          },
          {
            "name": 1664582400,
            "value": 2.1071,
            "extra": {
              "hidden": false
            }
          }
        ],
        "extra": {
          "hidden": false
        }
      }
    ]

Ts

public dateTickFormatting(val: Date | any): string {
        try {
            let formatdt = new Date(1000*val);
            let formatdtString = formatDate(formatdt, 'MMM y', 'en-US');
            //return moment(formatdt).format('M/yy');
            return formatdtString;
        } catch (exception) {
            console.error(exception);
            return val;
        }
    }

Now chart I am getting is like below, where it shows 8 values (different that earlier) and now its in order but Sep is getting repeated

Question

I am not getting why this is happening. How that chart is taking/rendering those X-axis values ?
On x axis, it should show like  Jun-22 Jul-22 Sep-22 Oct-22 Nov-22. How can I get this on that graph? Do I need to make changes in my Data format, in HTML etc?

Please guide and help. Thanks.


问:
How to fix pandas callback error in Jupyter notebook or lab
I keep getting a AttributeError  in my code when trying to open a large dataset in jupyter notebook and in Jupyter lab with pandas. I have tried many ways but I am trying to use pandas only.

I have uninstalled all Jupiter modules, all python packages, and I updated all of my anaconda packages.

Here is my code:

import pandas as pd

df = pd.read_excel('CalEnviroScreenSailor.xls')
print(df)

Here is the error message:

```<code>---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/var/folders/y5/m3s9mlh90hj78cpkj8ytxzkc0000gn/T/ipykernel_21302/2008694909.py in <module>
----> 1 df = pd.read_excel('CalEnviroScreenSailor.xls')
      2 print(df)

AttributeError: module 'pandas' has no attribute 'read_excel'
</code>```

Body:
I keep getting a AttributeError  in my code when trying to open a large dataset in jupyter notebook and in Jupyter lab with pandas. I have tried many ways but I am trying to use pandas only.

I have uninstalled all Jupiter modules, all python packages, and I updated all of my anaconda packages.

Here is my code:

import pandas as pd

df = pd.read_excel('CalEnviroScreenSailor.xls')
print(df)

Here is the error message:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/var/folders/y5/m3s9mlh90hj78cpkj8ytxzkc0000gn/T/ipykernel_21302/2008694909.py in <module>
----> 1 df = pd.read_excel('CalEnviroScreenSailor.xls')
      2 print(df)

AttributeError: module 'pandas' has no attribute 'read_excel'


问:
Unsupported or unrecognized SSL message?
I've created a Maven project in Eclipse. I got the below error in pom.xml.

Failure to transfer commons-lang:commons-lang:pom:2.1 from
https://repo.maven.apache.org/maven2 was cached in the local
repository, resolution   will not be reattempted until the update
interval of central has elapsed or updates are forced. Original error:
Could not transfer artifact commons-  lang:commons-lang:pom:2.1
from/to central (https://repo.maven.apache.org/maven2): Unsupported or
unrecognized SSL message

Java version: 1.8.0_291
Maven version: 3.8.6


问:
Is there any limit of running spiders in a parallel?
```<code>import scrapy
from scrapy.crawler import CrawlerProcess

class MySpider1(scrapy.Spider):
    # Your first spider definition
    ...

class MySpider2(scrapy.Spider):
    # Your second spider definition
    ...

process = CrawlerProcess()
process.crawl(MySpider1)
process.crawl(MySpider2)
process.start()
</code>```

As here we are running our Spider in 2 parallel.
So is there any number of limit of running the parallel job in scrapy. As when I have run with 10 process, in some result i don't get any record.

As I have run with different number of process, but not sure what is the limit number for running the parallel and if there any example of running the parallel process, please share.

Body:
import scrapy
from scrapy.crawler import CrawlerProcess

class MySpider1(scrapy.Spider):
    # Your first spider definition
    ...

class MySpider2(scrapy.Spider):
    # Your second spider definition
    ...

process = CrawlerProcess()
process.crawl(MySpider1)
process.crawl(MySpider2)
process.start()

As here we are running our Spider in 2 parallel.
So is there any number of limit of running the parallel job in scrapy. As when I have run with 10 process, in some result i don't get any record.

As I have run with different number of process, but not sure what is the limit number for running the parallel and if there any example of running the parallel process, please share.


问:
Skipping of inputs if user types fast
I am trying to create otp view where each item is individually editable, problem arises when user types fast, the input is skipped. I believe there is some delay in focus manager. Below is the code, let me know if there is any issues in the snippet itself</p>
```<code>@Composable
@Preview
fun OtpLayout(modifier: Modifier = Modifier, otpLength: Int = 6) {
    Row(horizontalArrangement = Arrangement.SpaceBetween, modifier = modifier.fillMaxWidth()) {
        val focusManager = LocalFocusManager.current
        val list = remember {
            List(6) {
                mutableStateOf(TextFieldValue(text = "", selection = TextRange(0)))
            }
        }
        repeat(otpLength) { index ->
            key(index) {
                BasicTextField(
                    modifier = Modifier.onKeyEvent {
                        if (it.key == Key.Backspace && index > 0 && list[index].value.text.isEmpty()) {
                            focusManager.moveFocus(FocusDirection.Left)
                        }
                        true
                    },
                    maxLines = 1,
                    value = list[index].value,
                    textStyle = TextStyle(color = Color.White, fontSize = 16.sp),
                    keyboardOptions = KeyboardOptions.Default.copy(keyboardType = KeyboardType.Number),
                    onValueChange = { value ->
                        Log.e("OnValue Changed called", value.text)
                        if (value.text.length <= 1 && value.text.isDigitsOnly()) {
                            list[index].value = value
                            if (value.text != "" && index < otpLength - 1) {
                                focusManager.moveFocus(FocusDirection.Right)
                            } else if (value.text == "" && index > 0) {
                                focusManager.moveFocus(FocusDirection.Left)
                            }
                        } else if (list[index].value.text.length == 1 && index < otpLength - 1) {
                            list[index + 1].value = value.copy(text = value.text.last().toString())
                            focusManager.moveFocus(FocusDirection.Right)
                        }
                    },
                    decorationBox = { innerTextField ->
                        Box(contentAlignment = Alignment.Center,
                            modifier = Modifier
                                .size(width = 42.dp, height = 52.dp)
                                .border(width = 1.dp,
                                    color = PrimaryColor,
                                    shape = RoundedCornerShape(6.dp))
                                .background(color = Gray, shape = RoundedCornerShape(6.dp))) {
                            innerTextField()
                        }
                    }
                )
            }
        }
    }
}

</code>```

Title: Skipping of inputs if user types fast

Body:
I am trying to create otp view where each item is individually editable, problem arises when user types fast, the input is skipped. I believe there is some delay in focus manager. Below is the code, let me know if there is any issues in the snippet itself

@Composable
@Preview
fun OtpLayout(modifier: Modifier = Modifier, otpLength: Int = 6) {
    Row(horizontalArrangement = Arrangement.SpaceBetween, modifier = modifier.fillMaxWidth()) {
        val focusManager = LocalFocusManager.current
        val list = remember {
            List(6) {
                mutableStateOf(TextFieldValue(text = "", selection = TextRange(0)))
            }
        }
        repeat(otpLength) { index ->
            key(index) {
                BasicTextField(
                    modifier = Modifier.onKeyEvent {
                        if (it.key == Key.Backspace && index > 0 && list[index].value.text.isEmpty()) {
                            focusManager.moveFocus(FocusDirection.Left)
                        }
                        true
                    },
                    maxLines = 1,
                    value = list[index].value,
                    textStyle = TextStyle(color = Color.White, fontSize = 16.sp),
                    keyboardOptions = KeyboardOptions.Default.copy(keyboardType = KeyboardType.Number),
                    onValueChange = { value ->
                        Log.e("OnValue Changed called", value.text)
                        if (value.text.length <= 1 && value.text.isDigitsOnly()) {
                            list[index].value = value
                            if (value.text != "" && index < otpLength - 1) {
                                focusManager.moveFocus(FocusDirection.Right)
                            } else if (value.text == "" && index > 0) {
                                focusManager.moveFocus(FocusDirection.Left)
                            }
                        } else if (list[index].value.text.length == 1 && index < otpLength - 1) {
                            list[index + 1].value = value.copy(text = value.text.last().toString())
                            focusManager.moveFocus(FocusDirection.Right)
                        }
                    },
                    decorationBox = { innerTextField ->
                        Box(contentAlignment = Alignment.Center,
                            modifier = Modifier
                                .size(width = 42.dp, height = 52.dp)
                                .border(width = 1.dp,
                                    color = PrimaryColor,
                                    shape = RoundedCornerShape(6.dp))
                                .background(color = Gray, shape = RoundedCornerShape(6.dp))) {
                            innerTextField()
                        }
                    }
                )
            }
        }
    }
}