问:
multiple swiper.js sliders with thumbnail navigation on same page
If I have multiple swiper.js sliders on a page then only the first slider works.
I used this slider as a guideline: https://swiperjs.com/demos#thumbs-gallery-loop
I have a lot of pages with multiple sliders, so a solution where you don't have to add classes or copy a lot of javascript would be good.

I think my JavaScript code is wrong.

I have found a solution how to run multiple sliders without thumbnail navigation on one page. The code: https://codepen.io/johannes-bichlmayr/pen/JjZVqqR

With thumbnail navigation it is very difficult. My current code: https://codepen.io/johannes-bichlmayr/pen/KKeYjgP
It does not work very well.

This was my first JavaScript code that works very well with one slider per page:

```<code>var swiper = new Swiper(".mySwiper", {
  loop: false,
  spaceBetween: 10,
  slidesPerView: document.getElementsByClassName('swiper-slide').length / 2,
  freeMode: true,
  watchSlidesProgress: true,
});
var swiper2 = new Swiper(".mySwiper2", {
  loop: false,
  spaceBetween: 10,
  navigation: {
    nextEl: ".swiper-button-next",
    prevEl: ".swiper-button-prev",
  },
  thumbs: {
    swiper: swiper,
  },
});
</code>```

With the code you can run two sliders without thumbnail navigation on one page:

```<code>  // declare Swiper.js .classes
const myCustomSlider = document.querySelectorAll('.swiper-container');

// declare navigation arrows classes
const mySliderPrev = document.querySelectorAll('.swiper-button-prev');
const mySliderNext = document.querySelectorAll('.swiper-button-next');

for( i=0; i< myCustomSlider.length; i++ ) {
// add special class with number to each Swiper.js slider and its nabigation arrows
  myCustomSlider[i].classList.add('swiper-container-' + i);
  mySliderPrev[i].classList.add('swiper-button-prev-' + i);
  mySliderNext[i].classList.add('swiper-button-next-' + i);

     var slider = new Swiper ('.swiper-container', {
    effect: 'slide',

    pagination: {
      el: '.swiper-pagination',
    },

    navigation: {
      nextEl: '.swiper-button-next',
      prevEl: '.swiper-button-prev',
    },

    scrollbar: {
      el: '.swiper-scrollbar',
    },
});
  }
</code>```

I am working on the code right now:

```<code>  // declare Swiper.js .classes
const myCustomSlider = document.querySelectorAll('.mySwiper2');

// declare navigation arrows classes
const mySliderPrev = document.querySelectorAll('.swiper-button-prev');
const mySliderNext = document.querySelectorAll('.swiper-button-next');

for( i=0; i< myCustomSlider.length; i++ ) {
// add special class with number to each Swiper.js slider and its nabigation arrows
  myCustomSlider[i].classList.add('mySwiper2-' + i);
  mySliderPrev[i].classList.add('swiper-button-prev-' + i);
  mySliderNext[i].classList.add('swiper-button-next-' + i);

var swiper2 = new Swiper(".mySwiper2", {
  loop: false,
  spaceBetween: 10,
  navigation: {
    nextEl: ".swiper-button-next",
    prevEl: ".swiper-button-prev",
  },
  thumbs: {
    swiper: swiper,
  },
});
  }

  // declare Swiper.js .classes
const myCustomSliderThumbs = document.querySelectorAll('.mySwiper');

for( i=0; i< myCustomSliderThumbs.length; i++ ) {
// add special class with number to each Swiper.js slider and its nabigation arrows
  myCustomSliderThumbs[i].classList.add('mySwiper-' + i);

var swiper = new Swiper(".mySwiper", {
  loop: false,
  spaceBetween: 10,
  slidesPerView: document.getElementsByClassName('swiper-slide').length / 2,
  freeMode: true,
  watchSlidesProgress: true,
});
  }
</code>```

Body:
If I have multiple swiper.js sliders on a page then only the first slider works.
I used this slider as a guideline: https://swiperjs.com/demos#thumbs-gallery-loop
I have a lot of pages with multiple sliders, so a solution where you don't have to add classes or copy a lot of javascript would be good.

I think my JavaScript code is wrong.

I have found a solution how to run multiple sliders without thumbnail navigation on one page. The code: https://codepen.io/johannes-bichlmayr/pen/JjZVqqR

With thumbnail navigation it is very difficult. My current code: https://codepen.io/johannes-bichlmayr/pen/KKeYjgP
It does not work very well.

This was my first JavaScript code that works very well with one slider per page:

var swiper = new Swiper(".mySwiper", {
  loop: false,
  spaceBetween: 10,
  slidesPerView: document.getElementsByClassName('swiper-slide').length / 2,
  freeMode: true,
  watchSlidesProgress: true,
});
var swiper2 = new Swiper(".mySwiper2", {
  loop: false,
  spaceBetween: 10,
  navigation: {
    nextEl: ".swiper-button-next",
    prevEl: ".swiper-button-prev",
  },
  thumbs: {
    swiper: swiper,
  },
});

With the code you can run two sliders without thumbnail navigation on one page:

  // declare Swiper.js .classes
const myCustomSlider = document.querySelectorAll('.swiper-container');

// declare navigation arrows classes
const mySliderPrev = document.querySelectorAll('.swiper-button-prev');
const mySliderNext = document.querySelectorAll('.swiper-button-next');

for( i=0; i< myCustomSlider.length; i++ ) {
// add special class with number to each Swiper.js slider and its nabigation arrows
  myCustomSlider[i].classList.add('swiper-container-' + i);
  mySliderPrev[i].classList.add('swiper-button-prev-' + i);
  mySliderNext[i].classList.add('swiper-button-next-' + i);

     var slider = new Swiper ('.swiper-container', {
    effect: 'slide',

    pagination: {
      el: '.swiper-pagination',
    },

    navigation: {
      nextEl: '.swiper-button-next',
      prevEl: '.swiper-button-prev',
    },

    scrollbar: {
      el: '.swiper-scrollbar',
    },
});
  }

I am working on the code right now:

  // declare Swiper.js .classes
const myCustomSlider = document.querySelectorAll('.mySwiper2');

// declare navigation arrows classes
const mySliderPrev = document.querySelectorAll('.swiper-button-prev');
const mySliderNext = document.querySelectorAll('.swiper-button-next');

for( i=0; i< myCustomSlider.length; i++ ) {
// add special class with number to each Swiper.js slider and its nabigation arrows
  myCustomSlider[i].classList.add('mySwiper2-' + i);
  mySliderPrev[i].classList.add('swiper-button-prev-' + i);
  mySliderNext[i].classList.add('swiper-button-next-' + i);

var swiper2 = new Swiper(".mySwiper2", {
  loop: false,
  spaceBetween: 10,
  navigation: {
    nextEl: ".swiper-button-next",
    prevEl: ".swiper-button-prev",
  },
  thumbs: {
    swiper: swiper,
  },
});
  }

  // declare Swiper.js .classes
const myCustomSliderThumbs = document.querySelectorAll('.mySwiper');

for( i=0; i< myCustomSliderThumbs.length; i++ ) {
// add special class with number to each Swiper.js slider and its nabigation arrows
  myCustomSliderThumbs[i].classList.add('mySwiper-' + i);

var swiper = new Swiper(".mySwiper", {
  loop: false,
  spaceBetween: 10,
  slidesPerView: document.getElementsByClassName('swiper-slide').length / 2,
  freeMode: true,
  watchSlidesProgress: true,
});
  }


来源: stackexchange

问:
Hibernate @Where clause does not work on a joined relationship. (Hibernate)
Currently I have two entities, Hoa and Activity respectively. They share the following relationship

HOA:

@Data
@Entity
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Hoa {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @NotNull
    @Builder.Default
    @OneToMany(mappedBy = "hoa", orphanRemoval = true)
    @Cascade(CascadeType.ALL)
    @Where(clause = " time > now() ")
    private List<Activity> activityDashboard = new ArrayList<>();
```
<p>Activity:</p>
<pre class="lang-java prettyprint-override"><code>@Data
@Builder
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Where(clause = "time > now()")
public class Activity  {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @NotNull
    @Builder.Default
    private LocalDateTime time = LocalDateTime.now();

    @NotNull
    @ManyToOne
    @JoinColumn(name = "HOA_ID")
    @JsonIgnore
    @ToString.Exclude
    private Hoa hoa;
}

</code>```

The use of @Where here suggests two things:
1.) When I try to get the associated activity entity from the repository directly it should not return anything.
2.) When I get the HOA entity from the repository, it should also not have the associated activity object within the list.

With this being said, The last assertion in the following test is failing.

@Test
void lateActivitiesShouldNotBeDisplayed() {
    Activity sut = activityService.createActivity(activityInThePast,1L);
    assertThat(activityRepository.findAll()).isEmpty();
    Hoa sutHoa = hoaRepository.findById(sut.getHoa().getId()).get();
    assertThat(sutHoa.getActivityDashboard()).isEmpty();

}
```

The sutHoa object has the associated activity within the activityDashboard list. Why could this be happening?

ContentLicense: CC BY-SA 4.0

Body:
Currently I have two entities, Hoa and Activity respectively. They share the following relationship

HOA:

@Data
@Entity
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Hoa {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @NotNull
    @Builder.Default
    @OneToMany(mappedBy = "hoa", orphanRemoval = true)
    @Cascade(CascadeType.ALL)
    @Where(clause = " time > now() ")
    private List<Activity> activityDashboard = new ArrayList<>();

Activity:

@Data
@Builder
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Where(clause = "time > now()")
public class Activity  {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @NotNull
    @Builder.Default
    private LocalDateTime time = LocalDateTime.now();

    @NotNull
    @ManyToOne
    @JoinColumn(name = "HOA_ID")
    @JsonIgnore
    @ToString.Exclude
    private Hoa hoa;
}

The use of @Where here suggests two things:
1.) When I try to get the associated activity entity from the repository directly it should not return anything.
2.) When I get the HOA entity from the repository, it should also not have the associated activity object within the list.

With this being said, The last assertion in the following test is failing.

@Test
void lateActivitiesShouldNotBeDisplayed() {
    Activity sut = activityService.createActivity(activityInThePast,1L);
    assertThat(activityRepository.findAll()).isEmpty();
    Hoa sutHoa = hoaRepository.findById(sut.getHoa().getId()).get();
    assertThat(sutHoa.getActivityDashboard()).isEmpty();

}

The sutHoa object has the associated activity within the activityDashboard list. Why could this be happening?


问:
usematerial3: true doesnt apply my background color
I am trying to use material 3 design and when i try to make my scaffold and navigation bar background color to the same, navigation bar bg color is not same as my code. But when I use usematerial3: false it's fixing but I want to use material 3 design. For better explanation see the below:

This is when usematerial3: true

This is when usematerial3: false

What I am trying to do is when I use material 3 true, app needs to have same background and navigation bar color. But it changes when usematerial3 is true. (codes are the same, only material3 affects)


问:
wp_query using set() for meta_query doesn't work in elementor/query/{query_id} hook
I was attempting to set the following code in the elementor/query/{query_id} hook. The meta fields were created using ACF.

```<code>$meta_query = (array) $query->get( 'meta_query' );
$date_now   = date( 'Y-m-d H:i:s' );

$meta_query[] = array(
    'key'     => 'event_startdate',
    'compare' => '>=',
    'value'   => $date_now,
    'type'    => 'DATETIME',
);

$query->set( 'meta_query', $meta_query );
</code>```

I tried both placing this code in the following function, with and without the code that sets the sorting (which works as expected)

```<code>add_action(
    'elementor/query/sorted_by_date',
    function( $query ) {
        $query->set( 'meta_key', 'event_startdate' );
        $query->set( 'orderby', 'meta_value_num' );
        $query->set( 'order', 'ASC' );
    }
);
</code>```

yet it does nothing. When I tried placing the same code inside the pre_get_posts hook it works just fine, and as expected.

I would love to understand what I'm not getting. As I see no reason it won't work in the elementor hook.

and also, where can I read about this set() function? I tried in the documentation, but I didn't find any explanation for the odd behavior where, you first set the key of context, and only after that - the value itself. how does that work? (just like in the last piece of code)

many thanks

Body:
I was attempting to set the following code in the elementor/query/{query_id} hook. The meta fields were created using ACF.

$meta_query = (array) $query->get( 'meta_query' );
$date_now   = date( 'Y-m-d H:i:s' );

$meta_query[] = array(
    'key'     => 'event_startdate',
    'compare' => '>=',
    'value'   => $date_now,
    'type'    => 'DATETIME',
);

$query->set( 'meta_query', $meta_query );

I tried both placing this code in the following function, with and without the code that sets the sorting (which works as expected)

add_action(
    'elementor/query/sorted_by_date',
    function( $query ) {
        $query->set( 'meta_key', 'event_startdate' );
        $query->set( 'orderby', 'meta_value_num' );
        $query->set( 'order', 'ASC' );
    }
);

yet it does nothing. When I tried placing the same code inside the pre_get_posts hook it works just fine, and as expected.

I would love to understand what I'm not getting. As I see no reason it won't work in the elementor hook.

and also, where can I read about this set() function? I tried in the documentation, but I didn't find any explanation for the odd behavior where, you first set the key of context, and only after that - the value itself. how does that work? (just like in the last piece of code)

many thanks


问:
Jupyter notebook cannot connect to the kernel
Jupyter notebook cannot connect to the kernel. I tried all the methods. I also reinstalled the computer system, reset the c drive, reinstalled anaconda, etc., but the same error was reported. I also changed the file path to Chinese, but Still fails, why? How to deal with it? The error is as follows: (the front part is the startup part, you can start to see it from the end, and the startup fails at the end)</p>
```<code>[W 2022-12-11 19:23:10.102 LabApp] 'notebook_dir' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2022-12-11 19:23:10.102 LabApp] 'notebook_dir' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[I 2022-12-11 19:23:10.111 LabApp] JupyterLab extension loaded from C:\ProgramData\Anaconda3\lib\site-packages\jupyterlab
[I 2022-12-11 19:23:10.111 LabApp] JupyterLab application directory is C:\ProgramData\Anaconda3\share\jupyter\lab
[I 19:23:10.117 NotebookApp] Serving notebooks from local directory: C:\Users\dilim
[I 19:23:10.117 NotebookApp] Jupyter Notebook 6.4.12 is running at:
[I 19:23:10.117 NotebookApp] http://localhost:8888/?token=a2380da4760b3519ffd6c9e8bc15220404126807c6c4f538
[I 19:23:10.117 NotebookApp]  or http://127.0.0.1:8888/?token=a2380da4760b3519ffd6c9e8bc15220404126807c6c4f538
[I 19:23:10.117 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 19:23:10.149 NotebookApp]

    To access the notebook, open this file in a browser:
        file:///C:/Users/dilim/AppData/Roaming/jupyter/runtime/nbserver-7544-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=a2380da4760b3519ffd6c9e8bc15220404126807c6c4f538
     or http://127.0.0.1:8888/?token=a2380da4760b3519ffd6c9e8bc15220404126807c6c4f538
[I 19:23:17.357 NotebookApp] Kernel started: 1474a909-0184-4cc9-995e-713135cea29f, name: python3
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\ProgramData\Anaconda3\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\ProgramData\Anaconda3\lib\site-packages\ipykernel_launcher.py", line 15, in <module>
    from ipykernel import kernelapp as app
  File "C:\ProgramData\Anaconda3\lib\site-packages\ipykernel\__init__.py", line 5, in <module>
    from .connect import *  # noqa
  File "C:\ProgramData\Anaconda3\lib\site-packages\ipykernel\connect.py", line 11, in <module>
    import jupyter_client
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\__init__.py", line 8, in <module>
    from .asynchronous import AsyncKernelClient  # noqa
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\asynchronous\__init__.py", line 1, in <module>
    from .client import AsyncKernelClient  # noqa
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\asynchronous\client.py", line 6, in <module>
    from jupyter_client.channels import HBChannel
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\channels.py", line 4, in <module>
    import asyncio
  File "C:\ProgramData\Anaconda3\lib\asyncio\__init__.py", line 8, in <module>
    from .base_events import *
  File "C:\ProgramData\Anaconda3\lib\asyncio\base_events.py", line 23, in <module>
    import socket
  File "C:\ProgramData\Anaconda3\lib\socket.py", line 54, in <module>
    import os, sys, io, selectors
  File "C:\ProgramData\Anaconda3\lib\selectors.py", line 12, in <module>
    import select
  File "C:\Users\dilim\Desktop\chooseexce\select.py", line 3, in <module>
    X = data=np.loadtxt("1.xlsx",delimiter=',',unpack=False)
  File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\npyio.py", line 1338, in loadtxt
    arr = _read(fname, dtype=dtype, comment=comment, delimiter=delimiter,
  File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\npyio.py", line 999, in _read
    arr = _load_from_filelike(
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa2 in position 50: illegal multibyte sequence
[I 19:23:20.341 NotebookApp] KernelRestarter: restarting kernel (1/5), new random ports
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\ProgramData\Anaconda3\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\ProgramData\Anaconda3\lib\site-packages\ipykernel_launcher.py", line 15, in <module>
    from ipykernel import kernelapp as app
  File "C:\ProgramData\Anaconda3\lib\site-packages\ipykernel\__init__.py", line 5, in <module>
    from .connect import *  # noqa
  File "C:\ProgramData\Anaconda3\lib\site-packages\ipykernel\connect.py", line 11, in <module>
    import jupyter_client
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\__init__.py", line 8, in <module>
    from .asynchronous import AsyncKernelClient  # noqa
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\asynchronous\__init__.py", line 1, in <module>
    from .client import AsyncKernelClient  # noqa
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\asynchronous\client.py", line 6, in <module>
    from jupyter_client.channels import HBChannel
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\channels.py", line 4, in <module>
    import asyncio
  File "C:\ProgramData\Anaconda3\lib\asyncio\__init__.py", line 8, in <module>
    from .base_events import *
  File "C:\ProgramData\Anaconda3\lib\asyncio\base_events.py", line 23, in <module>
    import socket
  File "C:\ProgramData\Anaconda3\lib\socket.py", line 54, in <module>
    import os, sys, io, selectors
  File "C:\ProgramData\Anaconda3\lib\selectors.py", line 12, in <module>
    import select
  File "C:\Users\dilim\Desktop\chooseexce\select.py", line 3, in <module>
    X = data=np.loadtxt("1.xlsx",delimiter=',',unpack=False)
  File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\npyio.py", line 1338, in loadtxt
    arr = _read(fname, dtype=dtype, comment=comment, delimiter=delimiter,
  File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\npyio.py", line 999, in _read
    arr = _load_from_filelike(
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa2 in position 50: illegal multibyte sequence

</code>```

Body:
Jupyter notebook cannot connect to the kernel. I tried all the methods. I also reinstalled the computer system, reset the c drive, reinstalled anaconda, etc., but the same error was reported. I also changed the file path to Chinese, but Still fails, why? How to deal with it? The error is as follows: (the front part is the startup part, you can start to see it from the end, and the startup fails at the end)

[W 2022-12-11 19:23:10.102 LabApp] 'notebook_dir' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2022-12-11 19:23:10.102 LabApp] 'notebook_dir' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[I 2022-12-11 19:23:10.111 LabApp] JupyterLab extension loaded from C:\ProgramData\Anaconda3\lib\site-packages\jupyterlab
[I 2022-12-11 19:23:10.111 LabApp] JupyterLab application directory is C:\ProgramData\Anaconda3\share\jupyter\lab
[I 19:23:10.117 NotebookApp] Serving notebooks from local directory: C:\Users\dilim
[I 19:23:10.117 NotebookApp] Jupyter Notebook 6.4.12 is running at:
[I 19:23:10.117 NotebookApp] http://localhost:8888/?token=a2380da4760b3519ffd6c9e8bc15220404126807c6c4f538
[I 19:23:10.117 NotebookApp]  or http://127.0.0.1:8888/?token=a2380da4760b3519ffd6c9e8bc15220404126807c6c4f538
[I 19:23:10.117 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 19:23:10.149 NotebookApp]

    To access the notebook, open this file in a browser:
        file:///C:/Users/dilim/AppData/Roaming/jupyter/runtime/nbserver-7544-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=a2380da4760b3519ffd6c9e8bc15220404126807c6c4f538
     or http://127.0.0.1:8888/?token=a2380da4760b3519ffd6c9e8bc15220404126807c6c4f538
[I 19:23:17.357 NotebookApp] Kernel started: 1474a909-0184-4cc9-995e-713135cea29f, name: python3
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\ProgramData\Anaconda3\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\ProgramData\Anaconda3\lib\site-packages\ipykernel_launcher.py", line 15, in <module>
    from ipykernel import kernelapp as app
  File "C:\ProgramData\Anaconda3\lib\site-packages\ipykernel\__init__.py", line 5, in <module>
    from .connect import *  # noqa
  File "C:\ProgramData\Anaconda3\lib\site-packages\ipykernel\connect.py", line 11, in <module>
    import jupyter_client
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\__init__.py", line 8, in <module>
    from .asynchronous import AsyncKernelClient  # noqa
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\asynchronous\__init__.py", line 1, in <module>
    from .client import AsyncKernelClient  # noqa
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\asynchronous\client.py", line 6, in <module>
    from jupyter_client.channels import HBChannel
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\channels.py", line 4, in <module>
    import asyncio
  File "C:\ProgramData\Anaconda3\lib\asyncio\__init__.py", line 8, in <module>
    from .base_events import *
  File "C:\ProgramData\Anaconda3\lib\asyncio\base_events.py", line 23, in <module>
    import socket
  File "C:\ProgramData\Anaconda3\lib\socket.py", line 54, in <module>
    import os, sys, io, selectors
  File "C:\ProgramData\Anaconda3\lib\selectors.py", line 12, in <module>
    import select
  File "C:\Users\dilim\Desktop\chooseexce\select.py", line 3, in <module>
    X = data=np.loadtxt("1.xlsx",delimiter=',',unpack=False)
  File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\npyio.py", line 1338, in loadtxt
    arr = _read(fname, dtype=dtype, comment=comment, delimiter=delimiter,
  File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\npyio.py", line 999, in _read
    arr = _load_from_filelike(
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa2 in position 50: illegal multibyte sequence
[I 19:23:20.341 NotebookApp] KernelRestarter: restarting kernel (1/5), new random ports
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\ProgramData\Anaconda3\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\ProgramData\Anaconda3\lib\site-packages\ipykernel_launcher.py", line 15, in <module>
    from ipykernel import kernelapp as app
  File "C:\ProgramData\Anaconda3\lib\site-packages\ipykernel\__init__.py", line 5, in <module>
    from .connect import *  # noqa
  File "C:\ProgramData\Anaconda3\lib\site-packages\ipykernel\connect.py", line 11, in <module>
    import jupyter_client
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\__init__.py", line 8, in <module>
    from .asynchronous import AsyncKernelClient  # noqa
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\asynchronous\__init__.py", line 1, in <module>
    from .client import AsyncKernelClient  # noqa
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\asynchronous\client.py", line 6, in <module>
    from jupyter_client.channels import HBChannel
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\channels.py", line 4, in <module>
    import asyncio
  File "C:\ProgramData\Anaconda3\lib\asyncio\__init__.py", line 8, in <module>
    from .base_events import *
  File "C:\ProgramData\Anaconda3\lib\asyncio\base_events.py", line 23, in <module>
    import socket
  File "C:\ProgramData\Anaconda3\lib\socket.py", line 54, in <module>
    import os, sys, io, selectors
  File "C:\ProgramData\Anaconda3\lib\selectors.py", line 12, in <module>
    import select
  File "C:\Users\dilim\Desktop\chooseexce\select.py", line 3, in <module>
    X = data=np.loadtxt("1.xlsx",delimiter=',',unpack=False)
  File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\npyio.py", line 1338, in loadtxt
    arr = _read(fname, dtype=dtype, comment=comment, delimiter=delimiter,
  File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\npyio.py", line 999, in _read
    arr = _load_from_filelike(
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa2 in position 50: illegal multibyte sequence


问:
Get the SendPort of a named ReceivePort without direct access to the ReceivePort for testing?
I am unit testing and trying to mock a class calling C functions through ffi.
A pair of functions is responsible for starting and stopping a thread in C.
The start function passes a nativePort to C to communicate with the thread.
The stop function is signaling the thread to wrap up.
The thread will then use the nativePort handle to tell the listener running in the startFunction that it finished.

DartFunc1() --ReceivePort.SendPort.nativePort--> native library in C stores port handle globally and starts processing in a thread.
DartFunc2() -> calls native C function that uses global port handle to tell dart processing ended.

In the unit test I am trying to imitate this behavior by mocking the start and stop call to C.
However, I have no idea how to get the dart sendPort to tell the listener in the other function we are done.

I spend literally all day on Google searching for similar problems (maybe hidden solutions?), looking through the documentation of mockito, flutter, the ffi package.

Somewhere I saw IsolateNameServer.lookupPortByName => SendPort? and that I can create ReceivePort with a name argument (at least for debugging), so I did that.

The code looks something like this:

```<code>test("run", () {
  when(() => clib.start).thenReturn((invocation) => (_) {});
  when(() => clib.stop).thenReturn(() => () {
    SendPort? port = IsolateNameServer.lookupPortByName("PortA");
    port?.send(1);
  });
  expect(sut.isRunning, false); sut.start(); // will call clib.start internally
  expect(sut.isRunning, true); sut.stop(); // will call clib.stop internally
  expect(sut.isRunning, false); // <= this always fails
});
</code>```

Body:
I am unit testing and trying to mock a class calling C functions through ffi.
A pair of functions is responsible for starting and stopping a thread in C.
The start function passes a nativePort to C to communicate with the thread.
The stop function is signaling the thread to wrap up.
The thread will then use the nativePort handle to tell the listener running in the startFunction that it finished.

DartFunc1() --ReceivePort.SendPort.nativePort--> native library in C stores port handle globally and starts processing in a thread.
DartFunc2() -> calls native C function that uses global port handle to tell dart processing ended.

In the unit test I am trying to imitate this behavior by mocking the start and stop call to C.
However, I have no idea how to get the dart sendPort to tell the listener in the other function we are done.

I spend literally all day on Google searching for similar problems (maybe hidden solutions?), looking through the documentation of mockito, flutter, the ffi package.

Somewhere I saw IsolateNameServer.lookupPortByName => SendPort? and that I can create ReceivePort with a name argument (at least for debugging), so I did that.

The code looks something like this:

test("run", () {
  when(() => clib.start).thenReturn((invocation) => (_) {});
  when(() => clib.stop).thenReturn(() => () {
    SendPort? port = IsolateNameServer.lookupPortByName("PortA");
    port?.send(1);
  });
  expect(sut.isRunning, false); sut.start(); // will call clib.start internally
  expect(sut.isRunning, true); sut.stop(); // will call clib.stop internally
  expect(sut.isRunning, false); // <= this always fails
});


问:
Add object to an array and update the object based on the key, mongoDB and NodeJs
I am trying to add a certain object to an array and update the object based on the key, in mongoDB - NodeJs.

```<code>const addDailie = async (req, res) => {
  const data = req.body;

  PostSchema.findOneAndUpdate(
    { email: data.email },
    {
      "challenges": {
        "dailies": [
          [data.date]: {
            [data.key]: data.points
          }
        ]
      }
    },
    (err, user) => {
      if (err) {
        res.sendStatus(404);
      } else {
        res.status(200).json(user);
      }
    }
  );
};
</code>```

This is throwing Errors and any other versions I've tried, give me a wrong structure in MongoDB.If path not setted it should be set, and if setted it should just update the data.points.

Appreciate any help.

Thank you.

Body:
I am trying to add a certain object to an array and update the object based on the key, in mongoDB - NodeJs.

const addDailie = async (req, res) => {
  const data = req.body;

  PostSchema.findOneAndUpdate(
    { email: data.email },
    {
      "challenges": {
        "dailies": [
          [data.date]: {
            [data.key]: data.points
          }
        ]
      }
    },
    (err, user) => {
      if (err) {
        res.sendStatus(404);
      } else {
        res.status(200).json(user);
      }
    }
  );
};

This is throwing Errors and any other versions I've tried, give me a wrong structure in MongoDB.If path not setted it should be set, and if setted it should just update the data.points.

Appreciate any help.

Thank you.


问:
How to implement a Google Cloud Platform (GCP) Authorization call via HTTP call in postman
I want to implement an HTTP call to Google Cloud Platform (GCP) to generate the Authorization token.
Cant find a the correct GCP documentation for the same as well.

Using the reference from below URL, I was able to generate a Authorizaton token from Postman, using postmans Authorization UI and not the HTTP call UI.
https://www.vulongtran.com/how-to-use-postman-with-google-cloud-platform-apis
And the call to GCP API are working using the token generated from above process.

I tried implementing the same call via HTTP POST request, but not getting expected result.

HTTP POST

URL - https://accounts.google.com/o/oauth2/token

Query param-

grant_type:authorization_code
redirect_uri:https://www.getpostman.com/oauth2/callback

Authorization -
Basic Auth
username -
password -

Headers -

scope:https://www.googleapis.com/auth/cloud-platform
redirect_uri:https://www.google.com

And the response that I get is
400 bad request
{ "error": "invalid_request", "error_description": "Missing required parameter: code" }

2nd Try-
Also tried sending the  in the request BODY, like below, but the result was same.
{
grant_type:'authorization_code',
redirect_uri:'https://www.getpostman.com/oauth2/callback'
}

Response
{
"error": "invalid_request",
"error_description": "Missing required parameter: code"
}

I saw another page, where 'code' is used in the call. Dont know what language the code on that page is for.
But I am unable to figure out the correct HTTP call to get the token from there as well.
Google OAuth2: Required parameter is missing: grant_type


问:
win32 setcursorpos raised sometime exception error
i need a easy set cursor def i tryed this one

```<code>#Clicks location at x,y
def click(x,y):
    win32api.SetCursorPos((x,y))
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
    time.sleep(0.1) #This pauses the script for 0.1 seconds
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)
</code>```

sometimes i get exeppction erroor
Exepttion (0, SetCursorPos, no error message is avaible)

is there a better way maybe is pyautogui better for this ???

Body:
i need a easy set cursor def i tryed this one

#Clicks location at x,y
def click(x,y):
    win32api.SetCursorPos((x,y))
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
    time.sleep(0.1) #This pauses the script for 0.1 seconds
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)

sometimes i get exeppction erroor
Exepttion (0, SetCursorPos, no error message is avaible)

is there a better way maybe is pyautogui better for this ???


问:
I get duplicate claims from IdentityServer in ASP.NET Core
Any ideas how this is possible? I really can't figure this out.
I've been trying to solve it, but I ended with no results.. I expected only to have a single role 'admin'..


问:
Omit/Skip images on export - TexturePacker
I'm an animator by trade, so this is new ground for me. Hope someone can help ;-)

I am using an app called TexturePacker to pack an image sequence of about 100 pngs into a texture sheet to be used in a game. I want to try optimising the texture sheet by omitting some images during the export to save space. For example, only export every 3rd frame.

TexturePacker uses XML code and there is a way of manually setting the export to ignore certain files but my code knowledge is too amateur to expand on it.

This example ignores all files called "test":

```<code><key>ignoreFileList</key>
<array>
    <string>*/test/*</string>
</array>
</code>```

I was wondering if there's some additional code I can append to "<string>*/test/*</string>" that will allow me to specify images to skip?
Any help will be greatly appreciated. Cheers!

Here is a link to the app i'm using for context - https://www.codeandweb.com/texturepacker

Body:
I'm an animator by trade, so this is new ground for me. Hope someone can help ;-)

I am using an app called TexturePacker to pack an image sequence of about 100 pngs into a texture sheet to be used in a game. I want to try optimising the texture sheet by omitting some images during the export to save space. For example, only export every 3rd frame.

TexturePacker uses XML code and there is a way of manually setting the export to ignore certain files but my code knowledge is too amateur to expand on it.

This example ignores all files called "test":

<key>ignoreFileList</key>
<array>
    <string>*/test/*</string>
</array>

I was wondering if there's some additional code I can append to "<string>*/test/*</string>" that will allow me to specify images to skip?
Any help will be greatly appreciated. Cheers!

Here is a link to the app i'm using for context - https://www.codeandweb.com/texturepacker


问:
How to choose a category in food ordering app which opens that particular section?
I'm making a food ordering application on java using Android Studio IDE. I have designed my application in a way that it has a section called categories in which I have implemented a recyclerView to show the different categories.
I have also figured out to open a fragment with the specific item image and name on which the user has clicked. Now comes the main problem.

I want to display a recyclerView whenever any of the category is opened and that recyclerView should show the data of that specific category. Means, if user is entering into Pizza category so that recyclerView should show him all the pizzas that I have listed on my firebase database. And when the user click on Burger category, that recyclerView should show all the burgers there.

Please help me in this, as I have taken this project and now I'm stucked with this situation.

I'm attaching some images below to help understanding easily.

The image showing the categories.

The image showing the fragment opening after clicked on Pizza category.

The image showing the code of RecyclerView.

If anything else is required related to the code, I will be happy to share it.

I have tried using switch case but then I figured out that I can not update the code each time a new category is added to add a new case for each category. Also, I got failed while implementing that too!


问:
Need to figure out where to put this line of code
I am new to javascript and writing a program that is supposed to be like a simon game. I have created an array that is used to store the user's inputs and I need to reset it everytime the loop runs. But I cannot figure out where to place this line of code.

The code that I want to add :

```<code>inputArray = [];
</code>```

The whole program is :

```<code>var selectedColorsRNG = [];
var inputArray = [];
start();

function start() {
  var randomNumber = RNG();
  var colors = ["green", "red", "yellow", "blue"];
  var randomChosenColor = colors[randomNumber];
  selectedColorsRNG.push(randomChosenColor);
  // test
  console.log(selectedColorsRNG + " >randomly generated array");
  // test
  for (var j = 0; j <= selectedColorsRNG.length; j++) {
    $("." + selectedColorsRNG[j])
      .fadeOut(100)
      .fadeIn(100)
      .fadeOut(100)
      .fadeIn(100);
  }
}

function RNG() {
  var randomNumber = Math.floor(Math.random() * 4);
  return randomNumber;
}

$("button").click(function () {
  while (inputArray.length != selectedColorsRNG.length) {
    console.log(inputArray);
    inputArray.push(this.className);
  }
  if (inputArray.toString() == selectedColorsRNG.toString()) {
    $("h1").html("Very Nice!");
    start();
  } else {
    $("h1").html("Oops :(");
  }
});

</code>```

I am very new to javascript so please help me.

Body:
I am new to javascript and writing a program that is supposed to be like a simon game. I have created an array that is used to store the user's inputs and I need to reset it everytime the loop runs. But I cannot figure out where to place this line of code.

The code that I want to add :

inputArray = [];

The whole program is :

var selectedColorsRNG = [];
var inputArray = [];
start();

function start() {
  var randomNumber = RNG();
  var colors = ["green", "red", "yellow", "blue"];
  var randomChosenColor = colors[randomNumber];
  selectedColorsRNG.push(randomChosenColor);
  // test
  console.log(selectedColorsRNG + " >randomly generated array");
  // test
  for (var j = 0; j <= selectedColorsRNG.length; j++) {
    $("." + selectedColorsRNG[j])
      .fadeOut(100)
      .fadeIn(100)
      .fadeOut(100)
      .fadeIn(100);
  }
}

function RNG() {
  var randomNumber = Math.floor(Math.random() * 4);
  return randomNumber;
}

$("button").click(function () {
  while (inputArray.length != selectedColorsRNG.length) {
    console.log(inputArray);
    inputArray.push(this.className);
  }
  if (inputArray.toString() == selectedColorsRNG.toString()) {
    $("h1").html("Very Nice!");
    start();
  } else {
    $("h1").html("Oops :(");
  }
});

I am very new to javascript so please help me.


问:
Attaching paragraph to the top of nested list highlights level change
I'm working on a simple office-js Word app, built with the Yeoman Generator. I have a very basic document with the following structure:

```<code>1. This is heading one
   1.1 This is subheading 1
   1.2 This is subheading 2

Some random text here...

Paragraph I want to attach to the list from the beginning of my doc
</code>```

When I try to attach this last paragraph to my list though, I'm getting the following output:

Word document's screenshot:

It looks as though it's first trying to insert it to the level=1 of that list (thus the initial 3) and then actually inserts it to the root list's position (thus the secondary 2).

The code I'm running looks as follows:

```<code>const insertHeading = async (event: Office.AddinCommands.Event) => {
  try {
    await Word.run(async (context) => {
      const selection = context.document.getSelection();
      selection.load("paragraphs");
      await context.sync();

      const lists = context.document.body.lists;
      const list = lists.getFirst();
      const paragraph = selection.paragraphs.getFirst();
      list.load("id");
      await context.sync();

      paragraph.attachToList(list.id, 0);
      await context.sync();
    })
  } catch (error) {
    console.info("Error occurred", error.debugInfo);
  } finally {
    event.completed();
  }
}
</code>```

I'd expect this paragraph to be added as 2nd item of the root level (with 2.) and without this turquoise strike, shown in the image above.

Any help would be much appreciated!

Body:
I'm working on a simple office-js Word app, built with the Yeoman Generator. I have a very basic document with the following structure:

1. This is heading one
   1.1 This is subheading 1
   1.2 This is subheading 2

Some random text here...

Paragraph I want to attach to the list from the beginning of my doc

When I try to attach this last paragraph to my list though, I'm getting the following output:

Word document's screenshot:

It looks as though it's first trying to insert it to the level=1 of that list (thus the initial 3) and then actually inserts it to the root list's position (thus the secondary 2).

The code I'm running looks as follows:

const insertHeading = async (event: Office.AddinCommands.Event) => {
  try {
    await Word.run(async (context) => {
      const selection = context.document.getSelection();
      selection.load("paragraphs");
      await context.sync();

      const lists = context.document.body.lists;
      const list = lists.getFirst();
      const paragraph = selection.paragraphs.getFirst();
      list.load("id");
      await context.sync();

      paragraph.attachToList(list.id, 0);
      await context.sync();
    })
  } catch (error) {
    console.info("Error occurred", error.debugInfo);
  } finally {
    event.completed();
  }
}

I'd expect this paragraph to be added as 2nd item of the root level (with 2.) and without this turquoise strike, shown in the image above.

Any help would be much appreciated!


问:
Win32 API - error: assigning to 'LPCSTR' from incompatible type 'const wchar_t[]'
I have the following code,

#include <windows.h>

LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    // Register the window class.

    WNDCLASS wc = { };

    wc.lpfnWndProc = WindowProc;
    wc.hInstance = hInstance;
    wc.lpszClassName = "Sample Window Class";
    wc.hbrBackground = (HBRUSH)COLOR_WINDOW;

    RegisterClass(&wc);

    // Create the window.

    HWND hwnd = CreateWindowEx(
        0,                              // Optional window styles.
        wc.lpszClassName,               // Window class
        "Learn to Program Windows",    // Window text
        WS_OVERLAPPEDWINDOW,            // Window style

        // Size and position
        CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,

        NULL,       // Parent window
        NULL,       // Menu
        hInstance,  // Instance handle
        NULL        // Additional application data
    );

    if (hwnd == NULL)
    {
        return 0;
    }

    ShowWindow(hwnd, nCmdShow);

    // Run the message loop.

    MSG msg = { };
    while (GetMessage(&msg, NULL, 0, 0) > 0)
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    return 0;
}

LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg)
    {
    case WM_DESTROY:
        PostQuitMessage(0);
        return 0;
    }
    return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
```
<p>The error occurs when I try to assign a value of the wrong type <code>'const char [20]'</code> to <code>'LPCWSTR'</code> like so:</p>
```    wc.lpszClassName = "Sample Window Class";

                       ^~~~~~~~~~~~~~~~~~~~~~
```
<p>If I prefix a string with <code>L""</code>, the <code>Visual C++ compiler</code> will no longer complain.</p>
<p>On the other hand, if I try to compile the same code with <code>gcc</code> or <code>clang</code>, it works just fine,
but after I add the prefix it gives me the following error:</p>
```error: assigning to 'LPCSTR' (aka 'const char *') from incompatible type 'const wchar_t[20]'
```

I wonder what causes this strange behaviour, and how could I make one code compatible for all compilers?

Body:
I have the following code,

#include <windows.h>

LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    // Register the window class.

    WNDCLASS wc = { };

    wc.lpfnWndProc = WindowProc;
    wc.hInstance = hInstance;
    wc.lpszClassName = "Sample Window Class";
    wc.hbrBackground = (HBRUSH)COLOR_WINDOW;

    RegisterClass(&wc);

    // Create the window.

    HWND hwnd = CreateWindowEx(
        0,                              // Optional window styles.
        wc.lpszClassName,               // Window class
        "Learn to Program Windows",    // Window text
        WS_OVERLAPPEDWINDOW,            // Window style

        // Size and position
        CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,

        NULL,       // Parent window
        NULL,       // Menu
        hInstance,  // Instance handle
        NULL        // Additional application data
    );

    if (hwnd == NULL)
    {
        return 0;
    }

    ShowWindow(hwnd, nCmdShow);

    // Run the message loop.

    MSG msg = { };
    while (GetMessage(&msg, NULL, 0, 0) > 0)
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    return 0;
}

LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg)
    {
    case WM_DESTROY:
        PostQuitMessage(0);
        return 0;
    }
    return DefWindowProc(hwnd, uMsg, wParam, lParam);
}

The error occurs when I try to assign a value of the wrong type 'const char [20]' to 'LPCWSTR' like so:

    wc.lpszClassName = "Sample Window Class";

                       ^~~~~~~~~~~~~~~~~~~~~~

If I prefix a string with L"", the Visual C++ compiler will no longer complain.

On the other hand, if I try to compile the same code with gcc or clang, it works just fine,
but after I add the prefix it gives me the following error:

error: assigning to 'LPCSTR' (aka 'const char *') from incompatible type 'const wchar_t[20]'

I wonder what causes this strange behaviour, and how could I make one code compatible for all compilers?


问:
Is it possible to use two JsonClassDiscriminators in the same class hierarchy; or emulate the function of such?
I'm trying to de-serialize the following class hierarchy:

@Serializable
@JsonClassDiscriminator("op")
@OptIn(ExperimentalSerializationApi::class)
sealed class Event(val opcode: Int) {
    @Serializable @SerialName("0")
    class EXAMPLE1 private constructor(val data: Int): Event(0) // should have data, opcode
    @Serializable @SerialName("1")
    class EXAMPLE2 private constructor(val data: String): Event(1) // should have data, opcode

    @Serializable @SerialName("2") @JsonClassDiscriminator("eventName")
    // fails: Argument values for inheritable serial info annotation 'JsonClassDiscriminator' must be the same as the values in parent type 'Event'
    sealed class EXAMPLE3 private constructor(val eventName: String): Event(2) { // should have AT LEAST opcode, eventName
        @Serializable @SerialName("0")
        sealed class DEEPEXAMPLE1 private constructor(val data: Int): EXAMPLE3("first") // should have opcode, eventName, data (Int)
        @Serializable @SerialName("1")
        sealed class DEEPEXAMPLE2 private constructor(val data: String): EXAMPLE3("second") // should have opcode, eventName, data (String)
    }
}
```

The first two succeed:

{"op":0, "data": 5} -> Event(op:0,data:5)

{"op":1, "data": "hello"} -> Event(op:1,data:"hello")

However, the second two, do not, and instead gives the error upon compilation: Argument values for inheritable serial info annotation 'JsonClassDiscriminator' must be the same as the values in parent type 'Event'

{"op":2, "eventName": "event1", "data": 3940} -> Event(op:0,eventName:"event1",data:3940)

{"op":2, "eventName": "event2", "data": "hello"} -> Event(op:0,eventName:"event2",data:"hello")

Is there anyway to produce the desired results, other than JsonClassDiscriminator?

Body:
I'm trying to de-serialize the following class hierarchy:

@Serializable
@JsonClassDiscriminator("op")
@OptIn(ExperimentalSerializationApi::class)
sealed class Event(val opcode: Int) {
    @Serializable @SerialName("0")
    class EXAMPLE1 private constructor(val data: Int): Event(0) // should have data, opcode
    @Serializable @SerialName("1")
    class EXAMPLE2 private constructor(val data: String): Event(1) // should have data, opcode

    @Serializable @SerialName("2") @JsonClassDiscriminator("eventName")
    // fails: Argument values for inheritable serial info annotation 'JsonClassDiscriminator' must be the same as the values in parent type 'Event'
    sealed class EXAMPLE3 private constructor(val eventName: String): Event(2) { // should have AT LEAST opcode, eventName
        @Serializable @SerialName("0")
        sealed class DEEPEXAMPLE1 private constructor(val data: Int): EXAMPLE3("first") // should have opcode, eventName, data (Int)
        @Serializable @SerialName("1")
        sealed class DEEPEXAMPLE2 private constructor(val data: String): EXAMPLE3("second") // should have opcode, eventName, data (String)
    }
}

The first two succeed:

{"op":0, "data": 5} -> Event(op:0,data:5)

{"op":1, "data": "hello"} -> Event(op:1,data:"hello")

However, the second two, do not, and instead gives the error upon compilation: Argument values for inheritable serial info annotation 'JsonClassDiscriminator' must be the same as the values in parent type 'Event'

{"op":2, "eventName": "event1", "data": 3940} -> Event(op:0,eventName:"event1",data:3940)

{"op":2, "eventName": "event2", "data": "hello"} -> Event(op:0,eventName:"event2",data:"hello")

Is there anyway to produce the desired results, other than JsonClassDiscriminator?


问:
ACF Image Upload - Strange Glyps
Got a really strange issue with ACF labels showing strange glyphs, we have ACF & WPML setup on the site and this field is set to copy.

This is what it looks like within the Gutenberg editor:

Here is how the field is setup with in ACF.

Has anyone had this issue before?

I've tried disabling WPML too.

Title: ACF Image Upload - Strange Glyps


问:
How to remove this auto generated grey text in jupyter notebook
That code in grey randomly comes up on its own and whenever I click on the cell it disappears. If I click on the right arrow the grey code turns black.

I have also tried uninstalling and reinstalling Anaconda. Please help.

Example of what's happening


问:
Can I get the color picker from Monet Engine in the browser?
I'm wondering if it seems possible at the moment to get the color palette of an android device in a browser. I found only a module for react native, which does not quite suit me.

The module for react native is not quite suitable for me, since my application is embedded on the device according to the manifest file.


问:
Node-schedule doesnt run when I pass in a date and time and runs when I only pass the minute / also date gets formatted to a different date -why?
node-schedule doesnt work when I pass in a date and time when the job should be executed. When I pass in instead of time such as every time its 42 minutes for example it works fine.

No matter what date I pas in it doesnt get executed

The date is being changed very strange. The time gets changed which is I assume because its in UTC and Im CET but also the date gets changed. for example 2022.11.15 becomes 2023.12.15.
I use the date just like explained so what am I doing wrong?

What is happening here?!

```<code>    async remind (userId) {
        const date = new Date(2022, 12, 11, 12, 55, 0); //doesnt work
        //this works: '42 * * * *'
         schedule.scheduleJob(date, () => {
            console.log('The answer to life, the universe, and everything!');
        });
    },
</code>```

Body:
node-schedule doesnt work when I pass in a date and time when the job should be executed. When I pass in instead of time such as every time its 42 minutes for example it works fine.

No matter what date I pas in it doesnt get executed

The date is being changed very strange. The time gets changed which is I assume because its in UTC and Im CET but also the date gets changed. for example 2022.11.15 becomes 2023.12.15.
I use the date just like explained so what am I doing wrong?

What is happening here?!

    async remind (userId) {
        const date = new Date(2022, 12, 11, 12, 55, 0); //doesnt work
        //this works: '42 * * * *'
         schedule.scheduleJob(date, () => {
            console.log('The answer to life, the universe, and everything!');
        });
    },


问:
Why level set to 1000 'calculateLevel' problem
my problem is that with the function 'calculateLevel' the level jumps to 1000 from the XP content 54592352.

```<code>const calculateLevel = (xp) => {
    let next = 500;
    let level = 0;
    for (let i = 1; next <= xp && level < 1000; i++) {
        next += parseInt(next * (0.235) * (1.00 - (0.0095 * level)));
        level++;
    }
    return {level, next};
};
</code>```
```<code>console.log(calculateLevel(54592351)); // Output { level: 106, next: 54592352 }
console.log(calculateLevel(54592352)); // Output { level: 1000, next: 0 }
</code>```

I guess the problem lies in the calculation of the level.

```<code>next += parseInt(next * (0.235) * (1.00 - (0.0095 * level)));
</code>```

Body:
my problem is that with the function 'calculateLevel' the level jumps to 1000 from the XP content 54592352.

const calculateLevel = (xp) => {
    let next = 500;
    let level = 0;
    for (let i = 1; next <= xp && level < 1000; i++) {
        next += parseInt(next * (0.235) * (1.00 - (0.0095 * level)));
        level++;
    }
    return {level, next};
};

console.log(calculateLevel(54592351)); // Output { level: 106, next: 54592352 }
console.log(calculateLevel(54592352)); // Output { level: 1000, next: 0 }

I guess the problem lies in the calculation of the level.

next += parseInt(next * (0.235) * (1.00 - (0.0095 * level)));


问:
I have a problemusing badget in navigation bar kotlin
I'm tyring to use a badget with Materials but I have several custom styles and when I use it, my custom button's style dissapear

I know that it works If I replace in my manifest

```<code>android:theme="@style/Theme.AppCompat.NoActionBar"
</code>```

with

```<code>android:theme="@style/Theme.MaterialComponents.DayNight.NoActionBar"
</code>```

Here is my full manifest

```<code>  <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.AppCompat.NoActionBar"
        android:windowSoftInputMode="adjustPan"
        tools:targetApi="31">
</code>```

But I have a custom xml to modify my buttons which I attach using the backgroudn property of buttons and when I change the manifest I lose my effects

```<code><?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <gradient
        android:type="radial"
        android:centerX="50%"
        android:centerY="50%"
        android:startColor="#6859C1"
        android:endColor="#34278C"
        android:gradientRadius="100%"
        />

    <stroke android:width="1dp"
        android:color="#FFFFFF"/>

    <padding android:left="1dp"
        android:top="1dp"
        android:right="1dp"
        android:bottom="1dp"/>

    <corners android:radius="30px"/>
</shape>
</code>```

What am I doing wrongly?

Thanks in advance!

Body:
I'm tyring to use a badget with Materials but I have several custom styles and when I use it, my custom button's style dissapear

I know that it works If I replace in my manifest

android:theme="@style/Theme.AppCompat.NoActionBar"

with

android:theme="@style/Theme.MaterialComponents.DayNight.NoActionBar"

Here is my full manifest

  <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.AppCompat.NoActionBar"
        android:windowSoftInputMode="adjustPan"
        tools:targetApi="31">

But I have a custom xml to modify my buttons which I attach using the backgroudn property of buttons and when I change the manifest I lose my effects

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <gradient
        android:type="radial"
        android:centerX="50%"
        android:centerY="50%"
        android:startColor="#6859C1"
        android:endColor="#34278C"
        android:gradientRadius="100%"
        />

    <stroke android:width="1dp"
        android:color="#FFFFFF"/>

    <padding android:left="1dp"
        android:top="1dp"
        android:right="1dp"
        android:bottom="1dp"/>

    <corners android:radius="30px"/>
</shape>

What am I doing wrongly?

Thanks in advance!


问:
VS Code typing when change app and come back to code in MacOS App
I got stuck in VS Code, whenever i code and change app in MacOS, once i come back to code in VS Code every button i click doesn type any letter, any help?

I've tried to click on any button but every button does weird things like deleting parts or move the cursor, only way is to reboot VS Code app


问:
Devise permitted parameters submission vs handling
This is a pattern often referred to

```<code>class ApplicationController < ActionController::Base
  before_action :configure_permitted_parameters, if: :devise_controller?

  protected

  def configure_permitted_parameters
    devise_parameter_sanitizer.permit(:sign_up, keys: [:username])
  end
end
</code>```

However, the practical application is missing context.  The example of the reaction of a rails app with devise installed:

```<code>Unpermitted parameters: :municipal_id, :regionminor_id, :regionmajor_id, :login_name, :kee, :virtual_qr_code.

Context: { controller: Users::RegistrationsController, action: create, request: #<ActionDispatch::Request:0x0000000110c0ca40>,
params: {"authenticity_token"=>"[FILTERED]", "user"=>{
"email"=>"kk@nie.mi", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "name_first"=>"k",
"name_last"=>"k",
"public_persona"=>"",
"nation_id"=>"19",
"idiom_id"=>"14",
"municipal_other"=>"Comabbio",
"sex_id"=>"85",
"date_of_birth"=>"",
"conditions_accepted"=>"0"}, "commit"=>"Sign up", "controller"=>"users/registrations", "action"=>"create"} }
</code>```

Note that NONE of the parameters that are deemed 'unpermitted' are being submitted by the form.  And the role of strong parameters is to avoid injection by outside parties of unwanted parameters.

The above "unpermitted" parameters are object attirbutes, but processed by the application.  Is there a way to specify this - in the pure sense of the strong parameter - other than resort to an after_commit action?

Body:
This is a pattern often referred to

class ApplicationController < ActionController::Base
  before_action :configure_permitted_parameters, if: :devise_controller?

  protected

  def configure_permitted_parameters
    devise_parameter_sanitizer.permit(:sign_up, keys: [:username])
  end
end

However, the practical application is missing context.  The example of the reaction of a rails app with devise installed:

Unpermitted parameters: :municipal_id, :regionminor_id, :regionmajor_id, :login_name, :kee, :virtual_qr_code.

Context: { controller: Users::RegistrationsController, action: create, request: #<ActionDispatch::Request:0x0000000110c0ca40>,
params: {"authenticity_token"=>"[FILTERED]", "user"=>{
"email"=>"kk@nie.mi", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "name_first"=>"k",
"name_last"=>"k",
"public_persona"=>"",
"nation_id"=>"19",
"idiom_id"=>"14",
"municipal_other"=>"Comabbio",
"sex_id"=>"85",
"date_of_birth"=>"",
"conditions_accepted"=>"0"}, "commit"=>"Sign up", "controller"=>"users/registrations", "action"=>"create"} }

Note that NONE of the parameters that are deemed 'unpermitted' are being submitted by the form.  And the role of strong parameters is to avoid injection by outside parties of unwanted parameters.

The above "unpermitted" parameters are object attirbutes, but processed by the application.  Is there a way to specify this - in the pure sense of the strong parameter - other than resort to an after_commit action?


问:
New state is same as the previous one, nonetheless React re-renders the component
I am currently experimenting around with React and can't understand one thing.

As you can see in the demo code below, when the third button is clicked, it changes the state dummy to true and thus causes a re-render of the Demo component. Now I've read in React docs, that if the new state value is the same as the previous one, no re-render is done.

```<code>function Demo()
{
   console.log('rendering')
   const [dummy, setDummy] = useState(false);

   return (
      <form onSubmit={(e) => {e.preventDefault();console.log('submitting')}}>
         <button>type="submit"</button>
         <button type="button">type="button"</button>
         <button type="submit" onClick={(e) => {setDummy(true)}}>type="submit" with state change</button>
         {dummy ? 'on' : 'off'}
      </form>
   )
}
</code>```

After the first state update, I do expect the log 'rendering' since the dummy state changes from false to true and thus causes Demo to re-render. But when I click the button the second time, I don't expect a re-render since the state dummy is changed from true to true (which isn't a change).

Nonetheless, somehow surprisingly, React re-renders the component this second time as well.

It's only from the third click, and beyond, that React doesn't re-render the Demo component.

Here's a live demo:

Live demo

Why is this behavior there?

Body:
I am currently experimenting around with React and can't understand one thing.

As you can see in the demo code below, when the third button is clicked, it changes the state dummy to true and thus causes a re-render of the Demo component. Now I've read in React docs, that if the new state value is the same as the previous one, no re-render is done.

function Demo()
{
   console.log('rendering')
   const [dummy, setDummy] = useState(false);

   return (
      <form onSubmit={(e) => {e.preventDefault();console.log('submitting')}}>
         <button>type="submit"</button>
         <button type="button">type="button"</button>
         <button type="submit" onClick={(e) => {setDummy(true)}}>type="submit" with state change</button>
         {dummy ? 'on' : 'off'}
      </form>
   )
}

After the first state update, I do expect the log 'rendering' since the dummy state changes from false to true and thus causes Demo to re-render. But when I click the button the second time, I don't expect a re-render since the state dummy is changed from true to true (which isn't a change).

Nonetheless, somehow surprisingly, React re-renders the component this second time as well.

It's only from the third click, and beyond, that React doesn't re-render the Demo component.

Here's a live demo:

Live demo

Why is this behavior there?


问:
Exception when calling ExecuteNonQuery with 0 argument(s): "The multi-part identifier "System.Data.DataRow.id" could not be bound."
I am trying with this script to query and collect data from a Postgres server and then load this data in a table DatenBankTable. After that i want to insert this collected information in a table in a SQL Server this is the table in the SQL Server. So it's basically data migration from Postgres to SQL Server.

```<code>#### connection to the Postgres server######
$MyServer = "H01POSxxx"
$MyPort  = "5xx"
$MyDB = "daxx"
$MyUid = "akxx"
$MyPass = "xxxx"

$PgConnectionString = "Driver={PostgreSQL Unicode(x64)};Server=$MyServer;Port=$MyPort;Database=$MyDB;Uid=$MyUid;Pwd=$MyPass;"
$PgConn = New-Object System.Data.Odbc.OdbcConnection;
$PgConn.ConnectionString = $PgConnectionString;
$PgConn.Open();

#######connection to the SQL Server#########

$SqlConnecting = "Server=h01sqlxx\insxx;Database=KPIs_DBInxxx;Integrated Security= True;Connect Timeout=30";
$SqlConn = new-object System.DATA.Sqlclient.sqlconnection;
$SqlConn.ConnectionString = $SqlConnecting;
$SqlCommand = $SqlConn.CreateCommand();
$SqlConn.open();

#############query the data from the Postrgres server############

$DatenBankQuery = $PgConn.CreateCommand();
$DatenBankQuery.CommandText = "

SELECT pg_database.oid AS ID,
pg_database.datname AS Datenbank,
(pg_stat_file('base/'||pg_database.oid ||'/PG_VERSION')).modification AS Erstellt,
pg_size_pretty(pg_database_size(datname)) AS Datenbankgröße,
pg_database.datcollate AS Collation,
pg_shdescription.description AS Beschreibung,
joblog.jlgstart AS Backup
from pg_database LEFT JOIN pg_shdescription
ON pg_database.oid = pg_shdescription.objoid,
pgagent.pga_job jobs
LEFT JOIN pgagent.pga_joblog joblog
ON jobs.jobid = joblog.jlgjobid
WHERE jobs.jobname LIKE '%BACKUP%'
AND joblog.jlgstatus = 's'
AND joblog.jlgstart = (SELECT MAX(jlgstart) from pgagent.pga_joblog) "

######Execute the queries and load the data in the table "DatenBankTable"#########

$DatenBankAdapter = New-Object System.Data.Odbc.OdbcDataAdapter($DatenBankQuery)
$DatenBankTable = New-Object System.Data.DataTable
$null = $DatenBankAdapter.Fill($DatenBankTable)

##### insert the data in the table "postgres.DATABASE_TABLE" on the SQL Server########

foreach($tab in $DatnBankTable) {

    $SqlCommand.CommandText = @"

insert into postgres.DATABASE_TABLE (ID, Datenbank, Erstellt, Datenbankgröße, Collation, Beschreibung, Backups)

VALUES ($tab.id, '$tab.datenbank', '$tab.erstellt', '$tab.datenbankgröße', '$tab.collation', '$tab.beschreibung', '$tab.backup');

"@;
}

$null = $SqlCommand.ExecuteNonQuery();
</code>```

The queries are working and the data is stored in the table DatenBankTable.

```<code>PS C:\WINDOWS\system32> $DatenBankTable

id             : 13012
datenbank      : postgres
erstellt       : 05.10.2020 13:47:37
datenbankgröße : 32 MB
collation      : German_Germany.1252
beschreibung   : default administrative connection database
backup         : 11.12.2022 00:00:03

id             : 83481
datenbank      : lrsql_db
erstellt       : 11.03.2022 13:57:31
datenbankgröße : 9549 kB
collation      : German_Germany.1252
beschreibung   :
backup         : 11.12.2022 00:00:03

id             : 1
datenbank      : template1
erstellt       : 05.10.2020 13:47:22
datenbankgröße : 7661 kB
collation      : German_Germany.1252
beschreibung   : default template for new databases
backup         : 11.12.2022 00:00:03

id             : 13011
datenbank      : template0
erstellt       : 05.10.2020 13:47:37
datenbankgröße : 7513 kB
collation      : German_Germany.1252
beschreibung   : unmodifiable empty database
backup         : 11.12.2022 00:00:03

id             : 53356
datenbank      : CrosscapEnterprise_Q
erstellt       : 01.12.2020 13:51:20
datenbankgröße : 14 MB
collation      : German_Germany.1252
beschreibung   :
backup         : 11.12.2022 00:00:03

id             : 86458
datenbank      : TNM_Remox_Q
erstellt       : 07.06.2022 11:22:34
datenbankgröße : 7773 kB
collation      : German_Germany.1252
beschreibung   :
backup         : 11.12.2022 00:00:03

id             : 115715
datenbank      : Test_DB_LM
erstellt       : 03.11.2022 15:55:00
datenbankgröße : 7805 kB
collation      : German_Germany.1252
beschreibung   : TEST11
backup         : 11.12.2022 00:00:03
</code>```

However, I get this error when trying to insert this data into SQL Server:

Exception when calling ExecuteNonQuery with 0 argument(s): "The multi-part identifier "System.Data.DataRow.id" could not be bound."

I'm not sure what the exact problem is, but if I had to guess, I would say that the values are not being interpreted, because I have more than one table, as you can see here:

```<code>PS C:\WINDOWS\system32> $SqlCommand

Connection              : System.Data.SqlClient.SqlConnection
NotificationAutoEnlist  : True
Notification            :
Transaction             :
CommandText             :
                          insert into postgres.DATABASE_TABLE (ID, Datenbank, Erstellt, Datenbankgröße, Collation, Beschreibung, Backups)

                          VALUES (System.Data.DataRow.id, 'System.Data.DataRow.datenbank', 'System.Data.DataRow.erstellt', 'System.Data.DataRow.datenbankgröße', 'System.Data.DataRow.collation', 'System.Data.DataRow.beschreibung', 'System.Data.DataRow.backup');

ColumnEncryptionSetting : UseConnectionSetting
CommandTimeout          : 30
CommandType             : Text
DesignTimeVisible       : True
Parameters              : {}
UpdatedRowSource        : Both
</code>```

I tried to solve the problem with parameters but that doesn't work either.

```<code>    $SqlCommand.CommandText = @"

insert into postgres.DATABASE_TABLE (ID, Datenbank, Erstellt, Datenbankgröße, Collation, Beschreibung, Backups)

VALUES ("@id", @da, @qw, @er, @rt, @tz, @zu);

"@;

$SqlCommand.Parameters.Add("@id", $DatenBankTable);
</code>```

and I get this error:

The table type parameter '@id' must have a valid type name

```<code>PS C:\WINDOWS\system32>   $SqlCommand.CommandText = @"

insert into postgres.DATABASE_TABLE (ID, Datenbank, Erstellt, Datenbankgröße, Collation, Beschreibung, Backups)

VALUES ("@id", @da, @qw, @er, @rt, @tz, @zu);

"@;

$SqlCommand.Parameters.Add("@id", $DatenBankTable);

$null = $SqlCommand.ExecuteNonQuery();

CompareInfo                     : None
XmlSchemaCollectionDatabase     :
XmlSchemaCollectionOwningSchema :
XmlSchemaCollectionName         :
ForceColumnEncryption           : False
DbType                          : Object
LocaleId                        : 0
ParameterName                   : @id
Precision                       : 0
Scale                           : 0
SqlDbType                       : Structured
SqlValue                        :
UdtTypeName                     :
TypeName                        :
Value                           : {13012, 83481, 1, 13011...}
Direction                       : Input
IsNullable                      : False
Offset                          : 0
Size                            : 0
SourceColumn                    :
SourceColumnNullMapping         : False
SourceVersion                   : Current

Ausnahme beim Aufrufen von "ExecuteNonQuery" mit 0 Argument(en):  "Der table-Typparameter '@id' muss einen gültigen Typnamen haben."
In Zeile:11 Zeichen:1
+ $null = $SqlCommand.ExecuteNonQuery();
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentException
</code>```

I am really lost and I have been trying to solve this problem for 3 days. Any help is greatly appreciated

Body:
I am trying with this script to query and collect data from a Postgres server and then load this data in a table DatenBankTable. After that i want to insert this collected information in a table in a SQL Server this is the table in the SQL Server. So it's basically data migration from Postgres to SQL Server.

#### connection to the Postgres server######
$MyServer = "H01POSxxx"
$MyPort  = "5xx"
$MyDB = "daxx"
$MyUid = "akxx"
$MyPass = "xxxx"

$PgConnectionString = "Driver={PostgreSQL Unicode(x64)};Server=$MyServer;Port=$MyPort;Database=$MyDB;Uid=$MyUid;Pwd=$MyPass;"
$PgConn = New-Object System.Data.Odbc.OdbcConnection;
$PgConn.ConnectionString = $PgConnectionString;
$PgConn.Open();

#######connection to the SQL Server#########

$SqlConnecting = "Server=h01sqlxx\insxx;Database=KPIs_DBInxxx;Integrated Security= True;Connect Timeout=30";
$SqlConn = new-object System.DATA.Sqlclient.sqlconnection;
$SqlConn.ConnectionString = $SqlConnecting;
$SqlCommand = $SqlConn.CreateCommand();
$SqlConn.open();

#############query the data from the Postrgres server############

$DatenBankQuery = $PgConn.CreateCommand();
$DatenBankQuery.CommandText = "

SELECT pg_database.oid AS ID,
pg_database.datname AS Datenbank,
(pg_stat_file('base/'||pg_database.oid ||'/PG_VERSION')).modification AS Erstellt,
pg_size_pretty(pg_database_size(datname)) AS Datenbankgröße,
pg_database.datcollate AS Collation,
pg_shdescription.description AS Beschreibung,
joblog.jlgstart AS Backup
from pg_database LEFT JOIN pg_shdescription
ON pg_database.oid = pg_shdescription.objoid,
pgagent.pga_job jobs
LEFT JOIN pgagent.pga_joblog joblog
ON jobs.jobid = joblog.jlgjobid
WHERE jobs.jobname LIKE '%BACKUP%'
AND joblog.jlgstatus = 's'
AND joblog.jlgstart = (SELECT MAX(jlgstart) from pgagent.pga_joblog) "

######Execute the queries and load the data in the table "DatenBankTable"#########

$DatenBankAdapter = New-Object System.Data.Odbc.OdbcDataAdapter($DatenBankQuery)
$DatenBankTable = New-Object System.Data.DataTable
$null = $DatenBankAdapter.Fill($DatenBankTable)

##### insert the data in the table "postgres.DATABASE_TABLE" on the SQL Server########

foreach($tab in $DatnBankTable) {

    $SqlCommand.CommandText = @"

insert into postgres.DATABASE_TABLE (ID, Datenbank, Erstellt, Datenbankgröße, Collation, Beschreibung, Backups)

VALUES ($tab.id, '$tab.datenbank', '$tab.erstellt', '$tab.datenbankgröße', '$tab.collation', '$tab.beschreibung', '$tab.backup');

"@;
}

$null = $SqlCommand.ExecuteNonQuery();

The queries are working and the data is stored in the table DatenBankTable.

PS C:\WINDOWS\system32> $DatenBankTable

id             : 13012
datenbank      : postgres
erstellt       : 05.10.2020 13:47:37
datenbankgröße : 32 MB
collation      : German_Germany.1252
beschreibung   : default administrative connection database
backup         : 11.12.2022 00:00:03

id             : 83481
datenbank      : lrsql_db
erstellt       : 11.03.2022 13:57:31
datenbankgröße : 9549 kB
collation      : German_Germany.1252
beschreibung   :
backup         : 11.12.2022 00:00:03

id             : 1
datenbank      : template1
erstellt       : 05.10.2020 13:47:22
datenbankgröße : 7661 kB
collation      : German_Germany.1252
beschreibung   : default template for new databases
backup         : 11.12.2022 00:00:03

id             : 13011
datenbank      : template0
erstellt       : 05.10.2020 13:47:37
datenbankgröße : 7513 kB
collation      : German_Germany.1252
beschreibung   : unmodifiable empty database
backup         : 11.12.2022 00:00:03

id             : 53356
datenbank      : CrosscapEnterprise_Q
erstellt       : 01.12.2020 13:51:20
datenbankgröße : 14 MB
collation      : German_Germany.1252
beschreibung   :
backup         : 11.12.2022 00:00:03

id             : 86458
datenbank      : TNM_Remox_Q
erstellt       : 07.06.2022 11:22:34
datenbankgröße : 7773 kB
collation      : German_Germany.1252
beschreibung   :
backup         : 11.12.2022 00:00:03

id             : 115715
datenbank      : Test_DB_LM
erstellt       : 03.11.2022 15:55:00
datenbankgröße : 7805 kB
collation      : German_Germany.1252
beschreibung   : TEST11
backup         : 11.12.2022 00:00:03

However, I get this error when trying to insert this data into SQL Server:

Exception when calling ExecuteNonQuery with 0 argument(s): "The multi-part identifier "System.Data.DataRow.id" could not be bound."

I'm not sure what the exact problem is, but if I had to guess, I would say that the values are not being interpreted, because I have more than one table, as you can see here:

PS C:\WINDOWS\system32> $SqlCommand

Connection              : System.Data.SqlClient.SqlConnection
NotificationAutoEnlist  : True
Notification            :
Transaction             :
CommandText             :
                          insert into postgres.DATABASE_TABLE (ID, Datenbank, Erstellt, Datenbankgröße, Collation, Beschreibung, Backups)

                          VALUES (System.Data.DataRow.id, 'System.Data.DataRow.datenbank', 'System.Data.DataRow.erstellt', 'System.Data.DataRow.datenbankgröße', 'System.Data.DataRow.collation', 'System.Data.DataRow.beschreibung', 'System.Data.DataRow.backup');

ColumnEncryptionSetting : UseConnectionSetting
CommandTimeout          : 30
CommandType             : Text
DesignTimeVisible       : True
Parameters              : {}
UpdatedRowSource        : Both

I tried to solve the problem with parameters but that doesn't work either.

    $SqlCommand.CommandText = @"

insert into postgres.DATABASE_TABLE (ID, Datenbank, Erstellt, Datenbankgröße, Collation, Beschreibung, Backups)

VALUES ("@id", @da, @qw, @er, @rt, @tz, @zu);

"@;

$SqlCommand.Parameters.Add("@id", $DatenBankTable);

and I get this error:

The table type parameter '@id' must have a valid type name

PS C:\WINDOWS\system32>   $SqlCommand.CommandText = @"

insert into postgres.DATABASE_TABLE (ID, Datenbank, Erstellt, Datenbankgröße, Collation, Beschreibung, Backups)

VALUES ("@id", @da, @qw, @er, @rt, @tz, @zu);

"@;

$SqlCommand.Parameters.Add("@id", $DatenBankTable);

$null = $SqlCommand.ExecuteNonQuery();

CompareInfo                     : None
XmlSchemaCollectionDatabase     :
XmlSchemaCollectionOwningSchema :
XmlSchemaCollectionName         :
ForceColumnEncryption           : False
DbType                          : Object
LocaleId                        : 0
ParameterName                   : @id
Precision                       : 0
Scale                           : 0
SqlDbType                       : Structured
SqlValue                        :
UdtTypeName                     :
TypeName                        :
Value                           : {13012, 83481, 1, 13011...}
Direction                       : Input
IsNullable                      : False
Offset                          : 0
Size                            : 0
SourceColumn                    :
SourceColumnNullMapping         : False
SourceVersion                   : Current

Ausnahme beim Aufrufen von "ExecuteNonQuery" mit 0 Argument(en):  "Der table-Typparameter '@id' muss einen gültigen Typnamen haben."
In Zeile:11 Zeichen:1
+ $null = $SqlCommand.ExecuteNonQuery();
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentException

I am really lost and I have been trying to solve this problem for 3 days. Any help is greatly appreciated