问:
(AT&T Syntax Assembly) VGA mode 13 line algorithm not looping correctly
I'm trying to implement a version of Bresenham's line-drawing algorithm in 16-bit assembly by passing the coordinates through registers (deliberately not using the stack or writing to video memory right now). It plots the very first pixel correctly (x1 and y1), but nothing else happens.

The following is how the coordinates of the line is defined:

```<code>real_start:
    movw    $boot_message, %si  # Display our boot message
    call    cons_writeline

    # Switch to VGA mode 13
    movb $0, %ah
    movb $0x13, %al
    int $0x10

    # lines are defined in the registers from this point

    movw $5, %cx # x coordinate
    movw $10, %dx # y coordinate
    movw $100, %bx # x2 coordinate
    movw $100, %ax # y2 coordinate
    movb $2, %bl # colour green
    call bresenham_start
</code>```

And this is the main code

```<code>draw_pixel:
    movb (colour), %al # move colour to al

    movb $0x0c, %ah
    movb $0, %bh
    int $0x10
    jmp bresenham_main

bresenham_start:
    movw %cx, (x1)
    movw %dx, (y1)
    movw %bx, (x2)
    movw %ax, (y2)
    movb %bl, (colour)

    sub %cx, %bx # delta x = x2 - x1
    movw %bx, (delta_x) # store result in delta_x

    sub %dx, %ax # delta y = y2 - y1
    movw %ax, (delta_y) # store result in delta_y

    sub %ax, %bx # err = delta x - delta y
    movw %bx, (err)

    movw (x1), %cx #
    movw (x2), %dx # Reset the coordinates to their original registers

    movw (x1), %cx
    movw (x2), %dx
    movw $1, (sx)
    cmp %dx, %cx
    jl sx_end # if x1 is less than x2, it jumps to sx_end and keeps sx as 1
    movw $-1, (sx) # if x1 is more than x2, it sets sx to -1 and plods along
    sx_end:

    movw (y1), %cx
    movw (y2), %dx
    movw $1, (sx)
    cmp %dx, %cx
    jl sy_end # if y1 is less than y2, it jumps to sy_end and keeps sy as 1
    movw $-1, (sx) # if y1 is more than y2, it sets sy to -1 and plods along
    sy_end:
    jmp bresenham

bresenham:
    movw (x1), %cx #
    movw (x2), %bx # Reset the coordinates to their original registers
    movw (y1), %dx # ^^
    movw (y2), %ax #

    # jump to draw_pixel
    jmp draw_pixel

bresenham_main:
    # check if x1 = x2 and y1 = y2
    cmp %cx, %bx # Check if x1 is less than x2
    jne carry_on # Condition in pseudocode uses and, meaning we don't break from the loop if x1 is not equal to x2
    cmp %dx, %ax # Check if y1 equals y2
    je break # break from the loop if y1 = y2, since to reach this part of the code, x1 is equal to x2
    carry_on: # Else:

    # calculate e2
    movw (err), %ax # move err into ax
    movw $2, %dx # set bx to 2
    mul %dx # when operand is a word: (DX AX) = AX * operand
    movw %ax, (e2) # put the result into e2

    # Check if e2 = -dy
    # e2 is already in ax
    movw (delta_y), %bx
    neg %bx # flip delta_y to negative
    cmp (e2), %bx
    jg carry_on_two # skips this block of code if e2 > -dy
    movw (err), %cx # move err into cx
    add %bx, %cx # add -dy to err, which is same as err - dy
    movw (x1), %dx # move x1 to dx
    add (sx), %dx # add sx to x1 and store it in dx

    carry_on_two: # code resumes here from the if statement
    # e2 is currently in ax
    movw (delta_x), %bx # move delta_x to bx
    cmp %ax, %bx
    jne inc_y # add delta_x to err and increment y1 by sy, then continue loop
    jmp bresenham # continue the loop
    inc_y: # if e2 < dx
    movw (y1), %ax # move y1 to ax
    movw (sy), %bx # move sy to bx
    add %ax, %bx # add y1 to sy and store it in bx
    movw %bx, (y1) # set y1 to the new result
    jmp bresenham # jump back to beginning of loop

break:
    ret
</code>```

This is the data portion:

```<code>x1: .word 0 # x1 coordinate, i.e. the starting coordinate of x
x2: .word 0 # x2 coodinate, i.e. the ending coordinate of x
y1: .word 0 # y1 coordinate, i.e. the starting coordinate of y
y2: .word 0 # y2 coordinate, i.e. the ending coordinate of y
sx: .word 0
sy: .word 0
delta_x: .word 0 # Delta x variable
delta_y: .word 0 # Delta y variable
err: .word 0 # error variable
e2: .word 0
colour: .byte 0
</code>```

pixel on screen

I've read and reread the code, but as there are no errors, I cannot find where I've messed up. I followed the implementation of this pseudocode line by line, and it seems to check out.

```<code> function drawline(x1, y1, x2, y2, colour)
 dx := abs(x2 - x1)
 dy := abs(y2 - y1)
 if x1 < x2 then sx := 1 else sx := -1
 if y1 < y2 then sy := 1 else sy := -1
 err := dx - dy
 loop
 setPixel(x1, y1, colour)
 if x1 = x2 and y1 = y2 exit loop
 e2 := 2 * err
 if e2 > -dy then
 err := err - dy
 x1 := x1 + sx
 end if
 if e2 < dx then
 err := err + dx
 y1 := y1 + sy
 end if
 end loop
</code>```

Body:
I'm trying to implement a version of Bresenham's line-drawing algorithm in 16-bit assembly by passing the coordinates through registers (deliberately not using the stack or writing to video memory right now). It plots the very first pixel correctly (x1 and y1), but nothing else happens.

The following is how the coordinates of the line is defined:

real_start:
    movw    $boot_message, %si  # Display our boot message
    call    cons_writeline

    # Switch to VGA mode 13
    movb $0, %ah
    movb $0x13, %al
    int $0x10

    # lines are defined in the registers from this point

    movw $5, %cx # x coordinate
    movw $10, %dx # y coordinate
    movw $100, %bx # x2 coordinate
    movw $100, %ax # y2 coordinate
    movb $2, %bl # colour green
    call bresenham_start

And this is the main code

draw_pixel:
    movb (colour), %al # move colour to al

    movb $0x0c, %ah
    movb $0, %bh
    int $0x10
    jmp bresenham_main

bresenham_start:
    movw %cx, (x1)
    movw %dx, (y1)
    movw %bx, (x2)
    movw %ax, (y2)
    movb %bl, (colour)

    sub %cx, %bx # delta x = x2 - x1
    movw %bx, (delta_x) # store result in delta_x

    sub %dx, %ax # delta y = y2 - y1
    movw %ax, (delta_y) # store result in delta_y

    sub %ax, %bx # err = delta x - delta y
    movw %bx, (err)

    movw (x1), %cx #
    movw (x2), %dx # Reset the coordinates to their original registers

    movw (x1), %cx
    movw (x2), %dx
    movw $1, (sx)
    cmp %dx, %cx
    jl sx_end # if x1 is less than x2, it jumps to sx_end and keeps sx as 1
    movw $-1, (sx) # if x1 is more than x2, it sets sx to -1 and plods along
    sx_end:

    movw (y1), %cx
    movw (y2), %dx
    movw $1, (sx)
    cmp %dx, %cx
    jl sy_end # if y1 is less than y2, it jumps to sy_end and keeps sy as 1
    movw $-1, (sx) # if y1 is more than y2, it sets sy to -1 and plods along
    sy_end:
    jmp bresenham

bresenham:
    movw (x1), %cx #
    movw (x2), %bx # Reset the coordinates to their original registers
    movw (y1), %dx # ^^
    movw (y2), %ax #

    # jump to draw_pixel
    jmp draw_pixel

bresenham_main:
    # check if x1 = x2 and y1 = y2
    cmp %cx, %bx # Check if x1 is less than x2
    jne carry_on # Condition in pseudocode uses and, meaning we don't break from the loop if x1 is not equal to x2
    cmp %dx, %ax # Check if y1 equals y2
    je break # break from the loop if y1 = y2, since to reach this part of the code, x1 is equal to x2
    carry_on: # Else:

    # calculate e2
    movw (err), %ax # move err into ax
    movw $2, %dx # set bx to 2
    mul %dx # when operand is a word: (DX AX) = AX * operand
    movw %ax, (e2) # put the result into e2

    # Check if e2 = -dy
    # e2 is already in ax
    movw (delta_y), %bx
    neg %bx # flip delta_y to negative
    cmp (e2), %bx
    jg carry_on_two # skips this block of code if e2 > -dy
    movw (err), %cx # move err into cx
    add %bx, %cx # add -dy to err, which is same as err - dy
    movw (x1), %dx # move x1 to dx
    add (sx), %dx # add sx to x1 and store it in dx

    carry_on_two: # code resumes here from the if statement
    # e2 is currently in ax
    movw (delta_x), %bx # move delta_x to bx
    cmp %ax, %bx
    jne inc_y # add delta_x to err and increment y1 by sy, then continue loop
    jmp bresenham # continue the loop
    inc_y: # if e2 < dx
    movw (y1), %ax # move y1 to ax
    movw (sy), %bx # move sy to bx
    add %ax, %bx # add y1 to sy and store it in bx
    movw %bx, (y1) # set y1 to the new result
    jmp bresenham # jump back to beginning of loop

break:
    ret

This is the data portion:

x1: .word 0 # x1 coordinate, i.e. the starting coordinate of x
x2: .word 0 # x2 coodinate, i.e. the ending coordinate of x
y1: .word 0 # y1 coordinate, i.e. the starting coordinate of y
y2: .word 0 # y2 coordinate, i.e. the ending coordinate of y
sx: .word 0
sy: .word 0
delta_x: .word 0 # Delta x variable
delta_y: .word 0 # Delta y variable
err: .word 0 # error variable
e2: .word 0
colour: .byte 0

pixel on screen

I've read and reread the code, but as there are no errors, I cannot find where I've messed up. I followed the implementation of this pseudocode line by line, and it seems to check out.

 function drawline(x1, y1, x2, y2, colour)
 dx := abs(x2 - x1)
 dy := abs(y2 - y1)
 if x1 < x2 then sx := 1 else sx := -1
 if y1 < y2 then sy := 1 else sy := -1
 err := dx - dy
 loop
 setPixel(x1, y1, colour)
 if x1 = x2 and y1 = y2 exit loop
 e2 := 2 * err
 if e2 > -dy then
 err := err - dy
 x1 := x1 + sx
 end if
 if e2 < dx then
 err := err + dx
 y1 := y1 + sy
 end if
 end loop


来源: stackexchange

问:
How to create prototype for collection using different entries types
I am trying to create a form tu manage sliders. I this form, I need to add slides. Each slide can be a video or an image.

To do that, I created a parent class which has communs attributes (position, active ...) and two others classes with specifics attributes.

<?php

namespace App\Entity\Slider;

use App\Repository\Slider\SlideRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\InheritanceType('JOINED')]
#[ORM\DiscriminatorColumn(name: 'slide_type', type: Types::STRING)]
#[ORM\DiscriminatorMap([
    'image' => Image::class,
    'video' => Video::class
])]
#[ORM\Entity(repositoryClass: SlideRepository::class)]
#[ORM\Table(name: 'tmp_slide')]
class Slide
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column(type: 'integer')]
    private ?int $id = null;

    #[ORM\Column(type: 'integer', nullable: true)]
    private ?int $position;

    // getters and setters
}
```
<pre class="lang-php prettyprint-override"><code><?php

namespace App\Entity\Slider;

use App\Repository\Slider\VideoRepository;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity(repositoryClass: VideoRepository::class)]
#[ORM\Table(name: 'tmp_slide_video')]
class Video extends Slide
{
    #[ORM\Column(type: 'string', length: 255)]
    private string $source;
}
</code>```

<?php

namespace App\Entity\Slider;

use App\Repository\Slider\ImageRepository;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity(repositoryClass: ImageRepository::class)]
#[ORM\Table(name: 'tmp_slide_image')]
class Image extends Slide
{
    #[ORM\Column(type: 'string', length: 255)]
    private string $meta_alt;
}
```
<p>So I created the form and for the slide collection, I use form events to set the good form following the doc</p>
<pre class="lang-php prettyprint-override"><code>$form->addEventListener(FormEvents::POST_SET_DATA, function (FormEvent $event) {
                /** @var Slide $slide */
                $slide = $event->getData();
                $form = $event->getForm();

                if ($slide) {

                    switch (get_class($slide)) {
                        case Video::class:
                            $form->add('source', TextType::class);
                        break;
                        case Image::class:
                            $form->add('meta_alt', TextType::class);
                        break;
                        default:
                            throw new \Exception('Undefined slide type');
                        break;
                    }
                }
            });
</code>```

That perfectly works for updating but like this I do not found the way to generate the prototype to add a slide with the choice of image or video.

So the question is : How to create two different prototypes for those two types of slide ?

I really hope you will understand the problem
Thank you for help

ContentLicense: CC BY-SA 4.0

Body:
I am trying to create a form tu manage sliders. I this form, I need to add slides. Each slide can be a video or an image.

To do that, I created a parent class which has communs attributes (position, active ...) and two others classes with specifics attributes.

<?php

namespace App\Entity\Slider;

use App\Repository\Slider\SlideRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\InheritanceType('JOINED')]
#[ORM\DiscriminatorColumn(name: 'slide_type', type: Types::STRING)]
#[ORM\DiscriminatorMap([
    'image' => Image::class,
    'video' => Video::class
])]
#[ORM\Entity(repositoryClass: SlideRepository::class)]
#[ORM\Table(name: 'tmp_slide')]
class Slide
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column(type: 'integer')]
    private ?int $id = null;

    #[ORM\Column(type: 'integer', nullable: true)]
    private ?int $position;

    // getters and setters
}

<?php

namespace App\Entity\Slider;

use App\Repository\Slider\VideoRepository;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity(repositoryClass: VideoRepository::class)]
#[ORM\Table(name: 'tmp_slide_video')]
class Video extends Slide
{
    #[ORM\Column(type: 'string', length: 255)]
    private string $source;
}

<?php

namespace App\Entity\Slider;

use App\Repository\Slider\ImageRepository;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity(repositoryClass: ImageRepository::class)]
#[ORM\Table(name: 'tmp_slide_image')]
class Image extends Slide
{
    #[ORM\Column(type: 'string', length: 255)]
    private string $meta_alt;
}

So I created the form and for the slide collection, I use form events to set the good form following the doc

$form->addEventListener(FormEvents::POST_SET_DATA, function (FormEvent $event) {
                /** @var Slide $slide */
                $slide = $event->getData();
                $form = $event->getForm();

                if ($slide) {

                    switch (get_class($slide)) {
                        case Video::class:
                            $form->add('source', TextType::class);
                        break;
                        case Image::class:
                            $form->add('meta_alt', TextType::class);
                        break;
                        default:
                            throw new \Exception('Undefined slide type');
                        break;
                    }
                }
            });

That perfectly works for updating but like this I do not found the way to generate the prototype to add a slide with the choice of image or video.

So the question is : How to create two different prototypes for those two types of slide ?

I really hope you will understand the problem
Thank you for help


问:
Cannot POST / (Express, EJS)
I'm trying to make a calculator for calculating the volume and area of a square.
BUT when I submit the form, I get "Cannot POST /square_volume" or "Cannot POST /square_area"
How to solve it ? (please help me because this is a school group project and i'm the only one who working on this thing)

This is my HTML form for calculating square volume (square_volume.ejs)

```<code><% if (!locals.data) { %>
<form method="post" action="/square_volume">
    <label><p>Square Width : </p></label>
    <input type="number" name="square_width" step="any"></input>
    <label><p>Square Length : </p></label>
    <input type="number" name="square_length" step="any"></input>
    <label><p>Square Height : </p></label>
    <input type="number" name="square_height" step="any"></input>
    <button class="submitButton">Calculate</button>
</form> <br>
<% } else { %>
        <p>Square Width : <p><%= square_width %></p></p>
        <p>Square Length : <p><%= square_length %></p></p>
        <p>Square Height : <p><%= square_height %></p></p>
        <h1>Square Volume : <p><%= square_volume %></p></h1>
        <button onclick="history.back()">Calculate Again</button>
<% } %>
</code>```

And this is my JavaScript server, using Node.js, Express, EJS (app.js)

```<code>// PAGES
app.get('/', (req, res) => {
    res.render('shapes_selection')
})
app.get('/square_selection.ejs', (req, res) => {
    res.render('square_selection')
})
app.get('/square_volume.ejs', (req, res) => {
    res.render('square_volume')
})
app.get('/square_area.ejs', (req, res) => {
    res.render('square_area')
})

//CALCULATIONS
if (typeof square_width != 'undefined') {
    app.all('square_volume', (req, res) => {
        let form = req.body
        let data = {}
        if (form.square_width) {
            data = {
                data: true,
                square_width: form.square_width,
                square_length: form.square_length,
                square_height: form.square_height,
                square_volume: numberWithCommas(parseFloat(form.square_width) * parseFloat(form.square_length) * parseFloat(form.square_height))
            }
        }
        res.render('square_volume', data)
    })
} else if (typeof square_side1 != 'undefined') {
    app.all('square_area', (req, res) => {
        let form = req.body
        let data = {}
        if (form.square_side1) {
            data = {
                data: true,
                square_side1: form.square_side1,
                square_side2: form.square_side2,
                square_area: numberWithCommas(parseFloat(form.square_side1) * parseFloat(form.square_side2))
            }
        }
        res.render('square_area', data)
    })
}
</code>```

If I do something dumb you can blame me.

Title: Cannot POST / (Express, EJS)

Body:
I'm trying to make a calculator for calculating the volume and area of a square.
BUT when I submit the form, I get "Cannot POST /square_volume" or "Cannot POST /square_area"
How to solve it ? (please help me because this is a school group project and i'm the only one who working on this thing)

This is my HTML form for calculating square volume (square_volume.ejs)

<% if (!locals.data) { %>
<form method="post" action="/square_volume">

Square Width :

    <input type="number" name="square_width" step="any"></input>

Square Length :

    <input type="number" name="square_length" step="any"></input>

Square Height :

    <input type="number" name="square_height" step="any"></input>
    <button class="submitButton">Calculate</button>
</form>

<% } else { %>

Square Width :
<%= square_width %>

Square Length :
<%= square_length %>

Square Height :
<%= square_height %>

Square Volume :
<%= square_volume %>

        <button onclick="history.back()">Calculate Again</button>
<% } %>

And this is my JavaScript server, using Node.js, Express, EJS (app.js)

// PAGES
app.get('/', (req, res) => {
    res.render('shapes_selection')
})
app.get('/square_selection.ejs', (req, res) => {
    res.render('square_selection')
})
app.get('/square_volume.ejs', (req, res) => {
    res.render('square_volume')
})
app.get('/square_area.ejs', (req, res) => {
    res.render('square_area')
})

//CALCULATIONS
if (typeof square_width != 'undefined') {
    app.all('square_volume', (req, res) => {
        let form = req.body
        let data = {}
        if (form.square_width) {
            data = {
                data: true,
                square_width: form.square_width,
                square_length: form.square_length,
                square_height: form.square_height,
                square_volume: numberWithCommas(parseFloat(form.square_width) * parseFloat(form.square_length) * parseFloat(form.square_height))
            }
        }
        res.render('square_volume', data)
    })
} else if (typeof square_side1 != 'undefined') {
    app.all('square_area', (req, res) => {
        let form = req.body
        let data = {}
        if (form.square_side1) {
            data = {
                data: true,
                square_side1: form.square_side1,
                square_side2: form.square_side2,
                square_area: numberWithCommas(parseFloat(form.square_side1) * parseFloat(form.square_side2))
            }
        }
        res.render('square_area', data)
    })
}

If I do something dumb you can blame me.


问:
Generic type compiled classes for common handling
I've 10 data transfer objects that i received through a maven dependency. I would like to type these objects with an abstract class or an interface so I can handle them as one type and not separately.

Since the classes are compiled and imported through maven I cannot change the classes itself.

The reason behind this is for me to handle them as one common type so I for example can send each one of them inside the same function.

```<code>public void build(CommonDTO commonDto) {
......
}
</code>```

I need to solve this in Scala. But I can try to translate it to Scala if a Java solution is found.

Body:
I've 10 data transfer objects that i received through a maven dependency. I would like to type these objects with an abstract class or an interface so I can handle them as one type and not separately.

Since the classes are compiled and imported through maven I cannot change the classes itself.

The reason behind this is for me to handle them as one common type so I for example can send each one of them inside the same function.

public void build(CommonDTO commonDto) {
......
}

I need to solve this in Scala. But I can try to translate it to Scala if a Java solution is found.


问:
read txt file and then delete it in a windows service c#
I have made a windows service in C#, what this service does is read a text file and convert it to json, but what I want to know is how can I delete that txt file once converted to json, it doesn't allow me to delete it because I get this log, "The process cannot access the file 'C:\API\inbox\13203530500100000060800712202231100.TXT' because it is being used by another process."

I am using the following to get the txt of the folder:

string[] files = Directory.GetFiles(rutaRaiz, "*.txt");

thanks for the support,

use the File.Delete(item) to delete the txt but it gave me error:
, "The process cannot access the file 'C:\API\inbox\13203530500100000060800712202231100.TXT' because it is being used by another process."


问:
Issues using setData(id, newData) from trpc.useContext() -> typescript not accepting string as input
Currently exerciseId flagged on line with // Typescript Error isn't being accepted, resulting in the following Typescript Error:

Argument of type 'string' is not assignable to parameter of type 'Updater<"" | ExerciseWithFavourited | null | undefined, "" | ExerciseWithFavourited | null | undefined>'.ts(2345)

```<code>  const favouriteMutation = trpc.exercise.favourite.useMutation({
    onMutate: async (exerciseId) => {
      // stop any outgoing refetches (so they don't overwrite our optimistic update)
      await utils.exercise.getById.cancel(exerciseId);

      // get snapshot of current value
      const origExercise = utils.exercise.getById.getData(exerciseId);

      // modify cache to reflect optimistic update
      utils.exercise.getById.setData(exerciseId, { // Typescript Error
        ...origExercise,
        favourited: origExercise && !origExercise?.favourited
      });

    },
    onSuccess: () => {
      utils.exercise.getById.invalidate();
    },
    onError: (err, exerciseId) => {
      utils.exercise.getById.refetch(exerciseId);
    }
  });
</code>```

I'm pretty new to Typescript and tRPC, so could easily be making a silly mistake. Any help greatly appreciated. Thanks!

I've tried:

Passing 'undefined' as the first parameter...

Using a functional approach (orig) => {...orig, favourited: !orig.favourited}

Reading through the tRPC examples (looks the same as what I'm doing)
-> https://github.com/trpc/trpc/blob/main/packages/tests/server/react/setQueryData.test.tsx

Body:
Currently exerciseId flagged on line with // Typescript Error isn't being accepted, resulting in the following Typescript Error:

Argument of type 'string' is not assignable to parameter of type 'Updater<"" | ExerciseWithFavourited | null | undefined, "" | ExerciseWithFavourited | null | undefined>'.ts(2345)

  const favouriteMutation = trpc.exercise.favourite.useMutation({
    onMutate: async (exerciseId) => {
      // stop any outgoing refetches (so they don't overwrite our optimistic update)
      await utils.exercise.getById.cancel(exerciseId);

      // get snapshot of current value
      const origExercise = utils.exercise.getById.getData(exerciseId);

      // modify cache to reflect optimistic update
      utils.exercise.getById.setData(exerciseId, { // Typescript Error
        ...origExercise,
        favourited: origExercise && !origExercise?.favourited
      });

    },
    onSuccess: () => {
      utils.exercise.getById.invalidate();
    },
    onError: (err, exerciseId) => {
      utils.exercise.getById.refetch(exerciseId);
    }
  });

I'm pretty new to Typescript and tRPC, so could easily be making a silly mistake. Any help greatly appreciated. Thanks!

I've tried:

Passing 'undefined' as the first parameter...

Using a functional approach (orig) => {...orig, favourited: !orig.favourited}

Reading through the tRPC examples (looks the same as what I'm doing)
-> https://github.com/trpc/trpc/blob/main/packages/tests/server/react/setQueryData.test.tsx


问:
JavaScript trigger a MouseEvent with istrusted being true
I was wondering if its possible to trigger a click event with isTrusted being true, i found out how to trigger a click event but i couldn't find any answers on how to set isTrusted as true

```<code>
function click(x, y)
{
    var ev = new MouseEvent('click', {
        'view': window,
        'bubbles': true,
        'cancelable': true,
        'screenX': x,
        'screenY': y
    });

    var el = document.elementFromPoint(x, y);
    console.log(el); //print element to console
    el.dispatchEvent(ev);
}
click(255, 600);
</code>```

Here is the code that i used to trigger a normal click with isTrusted being false

Body:
I was wondering if its possible to trigger a click event with isTrusted being true, i found out how to trigger a click event but i couldn't find any answers on how to set isTrusted as true

function click(x, y)
{
    var ev = new MouseEvent('click', {
        'view': window,
        'bubbles': true,
        'cancelable': true,
        'screenX': x,
        'screenY': y
    });

    var el = document.elementFromPoint(x, y);
    console.log(el); //print element to console
    el.dispatchEvent(ev);
}
click(255, 600);

Here is the code that i used to trigger a normal click with isTrusted being false


问:
Web API PUT 400 Bad Request
I have a HttpPut annotated Insert method in a controller and when I want to insert a new dto with it it returns a Bad Request 400 error.

```<code>public class BaseDto
{
    public int Id { get; set; }
    ...
}

public class ModelDto : BaseDto
{
    public string Name { get; set; }
    ...
}

[Produces("application/json")]
[Route("api/[controller]")]
public class ExampleController : MyControlle
{
   ...

   [HttpPut]
    public IActionResult Insert([FromBody] ModelDto model)
    {
        _service.Insert(model, _user);
        return Ok();
    }
}
</code>```

I tried it with an API client in Edge with this URL:
http://localhost:52073/api/Example

with this JSON:

```<code>``
{
    "award_Id":1,
    "nameOfTheAwardee":"zgghjggf",
    "titleOfTheAwardee":"XXX",
    "reasonForAwarding":"zzhfhf",
    "numberOfDecision":"876",
    "yearOfAwarding":"2022"
}
``
</code>```

Title: Web API PUT 400 Bad Request

Body:
I have a HttpPut annotated Insert method in a controller and when I want to insert a new dto with it it returns a Bad Request 400 error.

public class BaseDto
{
    public int Id { get; set; }
    ...
}

public class ModelDto : BaseDto
{
    public string Name { get; set; }
    ...
}

[Produces("application/json")]
[Route("api/[controller]")]
public class ExampleController : MyControlle
{
   ...

   [HttpPut]
    public IActionResult Insert([FromBody] ModelDto model)
    {
        _service.Insert(model, _user);
        return Ok();
    }
}

I tried it with an API client in Edge with this URL:
http://localhost:52073/api/Example

with this JSON:

``
{
    "award_Id":1,
    "nameOfTheAwardee":"zgghjggf",
    "titleOfTheAwardee":"XXX",
    "reasonForAwarding":"zzhfhf",
    "numberOfDecision":"876",
    "yearOfAwarding":"2022"
}
``


问:
Check if item is present in a string array inside of a for statement
I am trying to read a Toml file and check if the sub information is present in an array and if it is pass it or do something.

I have tried this and a few different types of it but nothing is seeming to work

int main{
 string v = {"css", "css_files", "html", "html_files", "js", "js_files", "php", "php_files", "all_files", "time", "user_data", "edit_files", "SQL","run_files","download_files","requests","WIFI","battery"};
   int len = sizeof(v)/sizeof(v[0]);
   int i;
   const auto data = toml::parse("test.toml");
   const auto& perms = toml::find(data, "permissions");
      for(const auto& [k, v] : perms.as_table())
      {
        if (find(v.begin(), v.end(), k) != v.end())
            cout << k << " is present in the array";
        else
            cout << k << " is not present in the array";
      const auto values = toml::find(perms, k);
      cout << k << ": " << values << endl;
      }
      return 0;
}
```


问:
Datadog API URL Endpoint for RUM User Session Data
I want to find out the daily number of sessions there were for a specific application programmatically using Datadog's API. Datadog has a Get a list of RUM events API endpoint where it is possible to query for sessions. But the problem I am having is formulating the correct URL query string in my Python code to retrieve such information correctly. How to I properly format the JSON to have it generate the correct URL endpoint to retrieve the user session data I need?</p>
```<code>import json
import requests
import urllib3
from urllib.parse import urlencode

endpoint = {
  "data": [
    {
      "attributes": {
        "service": "web-app",
        "timestamp": "2022-01-02T09:42:36.320Z"
      },
      "id": "AAAAAWgN8Xwgr1vKDQAAAABBV2dOOFh3ZzZobm1mWXJFYTR0OA",
      "type": "rum"
    }
    ]
  }

url_endpoint = urlencode(endpoint)
URL = ("https://api.datadoghq.com/api/v2/rum/events?" + url_endpoint)

response = requests.request('GET', URL, headers={"Authorization": [BEARER TOKEN], "application_key": "[APP_KEY]"}, verify=False)

obj = json.loads(response.text)
json_formatted_str = json.dumps(obj, indent=0)
print(json_formatted_str)
</code>```

Body:
I want to find out the daily number of sessions there were for a specific application programmatically using Datadog's API. Datadog has a Get a list of RUM events API endpoint where it is possible to query for sessions. But the problem I am having is formulating the correct URL query string in my Python code to retrieve such information correctly. How to I properly format the JSON to have it generate the correct URL endpoint to retrieve the user session data I need?

import json
import requests
import urllib3
from urllib.parse import urlencode

endpoint = {
  "data": [
    {
      "attributes": {
        "service": "web-app",
        "timestamp": "2022-01-02T09:42:36.320Z"
      },
      "id": "AAAAAWgN8Xwgr1vKDQAAAABBV2dOOFh3ZzZobm1mWXJFYTR0OA",
      "type": "rum"
    }
    ]
  }

url_endpoint = urlencode(endpoint)
URL = ("https://api.datadoghq.com/api/v2/rum/events?" + url_endpoint)

response = requests.request('GET', URL, headers={"Authorization": [BEARER TOKEN], "application_key": "[APP_KEY]"}, verify=False)

obj = json.loads(response.text)
json_formatted_str = json.dumps(obj, indent=0)
print(json_formatted_str)


问:
How to retrieve all childnodes from a firebase realtime database?
So I have a Firebase database with these security rules
`

```<code>{
  "rules": {
    "members": {
      "$uid": {
        //Only a user can view/edit their own details or an admin
        ".read": "auth.uid === $uid",
        ".write": "auth !== null && (auth.uid === $uid || auth.token.admin === true)",
        "firstName": {".validate": true},
          },
     },
}
</code>```

`
I want to retrieve all members and tried this:

`

```<code>let usersTest = '';
onValue(ref(getDatabase(), "members/{uid}"), (snapshot) => {
  const data = snapshot.val();
  this.usersTest = data;
  console.log("data: ", data);
});
</code>```

`
I expected to get an array of objects with each object containing a user, accessing "members/" itself is not possible as there is no security rule set for it. I just get null returned with this current implementation.
So the problem is that I want to read all members but cannot set a security rule as that needs to be deeper in the tree.
A solution would be to have a seperate memberList node and make a separate request for each member but I expect there to be a neater way of doing this as that feels inefficient

Body:
So I have a Firebase database with these security rules
`

{
  "rules": {
    "members": {
      "$uid": {
        //Only a user can view/edit their own details or an admin
        ".read": "auth.uid === $uid",
        ".write": "auth !== null && (auth.uid === $uid || auth.token.admin === true)",
        "firstName": {".validate": true},
          },
     },
}

`
I want to retrieve all members and tried this:

`

let usersTest = '';
onValue(ref(getDatabase(), "members/{uid}"), (snapshot) => {
  const data = snapshot.val();
  this.usersTest = data;
  console.log("data: ", data);
});

`
I expected to get an array of objects with each object containing a user, accessing "members/" itself is not possible as there is no security rule set for it. I just get null returned with this current implementation.
So the problem is that I want to read all members but cannot set a security rule as that needs to be deeper in the tree.
A solution would be to have a seperate memberList node and make a separate request for each member but I expect there to be a neater way of doing this as that feels inefficient


问:
Nginx reverse-proxy remove a part of the path
Heres the code:

```<code>        location /api {
            proxy_pass http://37.221.214.125:3000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_cache_bypass $http_upgrade;
        }
</code>```

It send request from this:

```<code>https://new.chatenium.hu
</code>```

to

```<code>http://37.221.214.125:3000/api
</code>```

the thing i want:

```<code>http://37.221.214.125:3000
</code>```

Is there any way to remove the api in the proxy?
Thanks!

Body:
Heres the code:

        location /api {
            proxy_pass http://37.221.214.125:3000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_cache_bypass $http_upgrade;
        }

It send request from this:

https://new.chatenium.hu

to

http://37.221.214.125:3000/api

the thing i want:

http://37.221.214.125:3000

Is there any way to remove the api in the proxy?
Thanks!


问:
Is there a standard function in pandas to interpolate between values in a lookup table?
I want to look up values from a table, also when the values are 'in between' the indices.

Example: here's a table from which I want to look up values. What is the easiest way, perhaps a standard function, to look up the value corresponding to (-2,-38)? It seems to me this is quite a common job to do, so I would expect something like table.lookup(-2,38) to exist. Perhaps I don't know the correct search terms but I can't seem to find it.

Example code:

```<code>import pandas as pd

d = {-7: [3.6,2.6,2.25,2],
     0: [4.3,2.8,2.5,2.2],
     5: [4.8,3.1,2.7,2.4],
     10: [5.5,3.5,3,2.6],
     15: [6.5,4,3.4,2.8]}
table = pd.DataFrame(data=d,index=[35,55,65,75])

table
Out[4]:
      -7    0    5   10   15
35  3.60  4.3  4.8  5.5  6.5
55  2.60  2.8  3.1  3.5  4.0
65  2.25  2.5  2.7  3.0  3.4
75  2.00  2.2  2.4  2.6  2.8
</code>```

I defined the table using the example code, but can't find a standard function to look up values from the table in a straightforward way.

I've checked out these related questions but find it hard to believe that this is the best way to go:
How to get value from Python table that will be interpolate between columns and rows?

Lookup a value in pandas table and if not there then interpolate between values in python

Body:
I want to look up values from a table, also when the values are 'in between' the indices.

Example: here's a table from which I want to look up values. What is the easiest way, perhaps a standard function, to look up the value corresponding to (-2,-38)? It seems to me this is quite a common job to do, so I would expect something like table.lookup(-2,38) to exist. Perhaps I don't know the correct search terms but I can't seem to find it.

Example code:

import pandas as pd

d = {-7: [3.6,2.6,2.25,2],
     0: [4.3,2.8,2.5,2.2],
     5: [4.8,3.1,2.7,2.4],
     10: [5.5,3.5,3,2.6],
     15: [6.5,4,3.4,2.8]}
table = pd.DataFrame(data=d,index=[35,55,65,75])

table
Out[4]:
      -7    0    5   10   15
35  3.60  4.3  4.8  5.5  6.5
55  2.60  2.8  3.1  3.5  4.0
65  2.25  2.5  2.7  3.0  3.4
75  2.00  2.2  2.4  2.6  2.8

I defined the table using the example code, but can't find a standard function to look up values from the table in a straightforward way.

I've checked out these related questions but find it hard to believe that this is the best way to go:
How to get value from Python table that will be interpolate between columns and rows?

Lookup a value in pandas table and if not there then interpolate between values in python


问:
Close MS Access after using JayDeBeApi
I'm coding in Python and using JayDeBeApi to connect to a MS Access database. The problem is I can't seem to find how to close the file, cause when I run a script to compact the database (msaccess %path_to_db% /compact) it says file already in use.

My code look like this

class AccessConnect:
    def __init__(self, p_path_to_db: Path, p_table_name: str)
        self.path_to_db = p_path_to_db
        self.table_name = p_table_name

        self.u_can_access_jars = [
            f"{ref_to_root}/jdbc_access/ucanaccess-5.0.1.jar",
            f"{ref_to_root}/jdbc_access/commons-lang3-3.8.1.jar",
            f"{ref_to_root}/jdbc_access/commons-logging-1.2.jar",
            f"{ref_to_root}/jdbc_access/hsqldb-2.5.0.jar",
            f"{ref_to_root}/jdbc_access/jackcess-3.0.1.jar"
        ]
        self.classpath = ";".join(self.u_can_access_jars)

        try:
            jpype.startJVM(classpath=self.u_can_access_jars)
        except OSError as e:
            if e.args[0] == "JVM is already started":
                pass
            else:
                raise e

    def open_connexion(self) -> jaydebeapi.Connection:
        return jaydebeapi.connect(
            "net.ucanaccess.jdbc.UcanaccessDriver",
            f"jdbc:ucanaccess:///{self.path_to_db}",
            ["", ""],
            self.classpath
        )

    def get_all(self):
        query = f"SELECT * FROM {self.table_name}"
        with self.open_connection() as conn:
            with conn.cursor() as cursor:
                cursor.execute(query)
                ans = cursor.fetchall()
       return ans

```

So I want to be able to close the file to use it after.

Thanks!

Title: Close MS Access after using JayDeBeApi

Body:
I'm coding in Python and using JayDeBeApi to connect to a MS Access database. The problem is I can't seem to find how to close the file, cause when I run a script to compact the database (msaccess %path_to_db% /compact) it says file already in use.

My code look like this

class AccessConnect:
    def __init__(self, p_path_to_db: Path, p_table_name: str)
        self.path_to_db = p_path_to_db
        self.table_name = p_table_name

        self.u_can_access_jars = [
            f"{ref_to_root}/jdbc_access/ucanaccess-5.0.1.jar",
            f"{ref_to_root}/jdbc_access/commons-lang3-3.8.1.jar",
            f"{ref_to_root}/jdbc_access/commons-logging-1.2.jar",
            f"{ref_to_root}/jdbc_access/hsqldb-2.5.0.jar",
            f"{ref_to_root}/jdbc_access/jackcess-3.0.1.jar"
        ]
        self.classpath = ";".join(self.u_can_access_jars)

        try:
            jpype.startJVM(classpath=self.u_can_access_jars)
        except OSError as e:
            if e.args[0] == "JVM is already started":
                pass
            else:
                raise e

    def open_connexion(self) -> jaydebeapi.Connection:
        return jaydebeapi.connect(
            "net.ucanaccess.jdbc.UcanaccessDriver",
            f"jdbc:ucanaccess:///{self.path_to_db}",
            ["", ""],
            self.classpath
        )

    def get_all(self):
        query = f"SELECT * FROM {self.table_name}"
        with self.open_connection() as conn:
            with conn.cursor() as cursor:
                cursor.execute(query)
                ans = cursor.fetchall()
       return ans

So I want to be able to close the file to use it after.

Thanks!


问:
How do I import a SQL dump into pgadmin 4 using postgresql?
I have a SQL dump that I need to import using postgresql into pgadmin4, however when I run the command, the schema gets created but none of the data comes with it, I have the database set up in pgadmin4. This is my first time using postgresql and pgadmin so I know I have to be missing something.
The SQL dump file was sent to me directly, I did not use pg_dump to migrate anything, the file is in my downloads and I need to plug it in to pgadmin.

I need this SQL dump because I need to log into several portals locally for a large project.

On Windows, using postgres version 14, I've tried several ways from other solutions on stack overflow, first using the command line in both bash and powershell
This here is the command I was told to use that should add the tables and data for the app from a coworker, and it worked fine for him.

```<code>C:\Program Files\PostgreSQL\14\bin>psql -h localhost -U postgres -d the_database -f PATH_TO_YOUR_DOWNLOADS\data_dump.sql
</code>```

This command will create the schema in the pgadmin database but no data comes with it. (I know the data is missing because I cant use my dummy logins to get into the project)

Second, I tried using the built in restore and backup methods in pgadmin and both of those end in an error

`Process failed Restoring backup on the server 'PostgreSQL 14 (localhost:5432)

Third I tried using the query tool and link the sql file that way, but when I hit execute I get an error there as well.
Using the query tool, when I link the download file, I can see the data in the Query, but it is not in the database.

ERROR:  syntax error at or near "2"
LINE 3285: 2 Some Test 2020-11-13 07:42:29.356827 2020-11-13 04:32:...
           ^
SQL state: 42601
Character: 87447
```

Any advice?

Do I need the SQL file formatted in any certain way?
I just need the data to be imported into pgadmin4 database WITH my schema.

Body:
I have a SQL dump that I need to import using postgresql into pgadmin4, however when I run the command, the schema gets created but none of the data comes with it, I have the database set up in pgadmin4. This is my first time using postgresql and pgadmin so I know I have to be missing something.
The SQL dump file was sent to me directly, I did not use pg_dump to migrate anything, the file is in my downloads and I need to plug it in to pgadmin.

I need this SQL dump because I need to log into several portals locally for a large project.

On Windows, using postgres version 14, I've tried several ways from other solutions on stack overflow, first using the command line in both bash and powershell
This here is the command I was told to use that should add the tables and data for the app from a coworker, and it worked fine for him.

C:\Program Files\PostgreSQL\14\bin>psql -h localhost -U postgres -d the_database -f PATH_TO_YOUR_DOWNLOADS\data_dump.sql

This command will create the schema in the pgadmin database but no data comes with it. (I know the data is missing because I cant use my dummy logins to get into the project)

Second, I tried using the built in restore and backup methods in pgadmin and both of those end in an error

`Process failed Restoring backup on the server 'PostgreSQL 14 (localhost:5432)

Third I tried using the query tool and link the sql file that way, but when I hit execute I get an error there as well.
Using the query tool, when I link the download file, I can see the data in the Query, but it is not in the database.

ERROR:  syntax error at or near "2"
LINE 3285: 2 Some Test 2020-11-13 07:42:29.356827 2020-11-13 04:32:...
           ^
SQL state: 42601
Character: 87447

Any advice?

Do I need the SQL file formatted in any certain way?
I just need the data to be imported into pgadmin4 database WITH my schema.


问:
net::ERR_UNKNOWN_URL_SCHEME For wordpress site url launching on webview flutter
I have done a webview using flutter to show my WordPress-made website on flutter webview, The app works well but whenever i click the URL reference button that redirects to a third-party application like telegram, TikTok, and Instagram it says net::ERR_UNKNOWN_URL_SCHEME

I have tried to solve the problem by referring to similar problems question on StackOverflow but their problem and my problem are different due to they are launching an internal url button which is coded under the flutter main.dart but I am launching my WordPress social media URLs. I appreciate your coming up with solutions.
Here is where the eror comes from
Here is the eror net::ERR_UNKNOWN_URL_SCHEME
Here is my app link on playstore: You can see the problem when you click on the footer social media icons.

I expected to laucnh third party url that actually in my wordpress website.


问:
Cucumber BDD, call gRPC
I am new to BDD, want to call gRPC.

gRPC is working without BDD by following way

command:

./grpcurl -vv -proto functionsNservices_file_java.proto -plaintext localhost:8080 service_in_proto.func

output: exactly what I need

Where

functionsNservices_file_java.proto is a java file

localhost:8080 is deamon

service_in_proto.func is defined in functionsNservices_file_java.proto file

Problem:

is how can i call gRPC using BDD script. as BDD supports camel and camel supports gRPC.

Title: Cucumber BDD, call gRPC


问:
Why .withSockJs seems to block Stomp over Websocket from connecting client with server
I've struggled to connect the JS client with the Java server with a client using Stomp over WebSocket. The problem was fixed when I got rid of .withSockJs() while configuring stompEndpoints. Can someone explain to me what was the case here and why it happened? My understanding was that this method offers fallback but should not mess up a normal WebSocket connection.

Working alternatives:

@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
    registry.addEndpoint("/chat");
    registry.addEndpoint("/chat").withSockJS();
}

@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
    registry.addEndpoint("/chat");
}
```
<h3>Notworking case:</h3>
<pre class="lang-java prettyprint-override"><code>@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
    registry.addEndpoint("/chat").withSockJS();
}
</code>```

Also: I have noticed that adding .setAllowedOrigins("http://localhost:5050") doesn't have any impact on communication in my case. I was able to connect to the server via a client on port 5050 but also via postman on 5555. Before the problem with withSockJs() I struggled with a different problem related to CORS. The solution was to change the socket configuration on the client from SockJs to WebSocket but before finding this I tried many different approaches on the server side as I thought that my server implementation was the problem. I was working with setAllowedOrigins, but when I was finally able to connect I noticed that this method seems to not work.

One more question: How is the controller of WebSocket endpoints implemented? I want to keep track of active clients username to sessionId mapping. Do I need thread safe static map or all of messaging happen on a single thread? In other words, will there be more than one WebSocket controller instance if multiple clients are connected?

Body:
I've struggled to connect the JS client with the Java server with a client using Stomp over WebSocket. The problem was fixed when I got rid of .withSockJs() while configuring stompEndpoints. Can someone explain to me what was the case here and why it happened? My understanding was that this method offers fallback but should not mess up a normal WebSocket connection.

Working alternatives:

@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
    registry.addEndpoint("/chat");
    registry.addEndpoint("/chat").withSockJS();
}

@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
    registry.addEndpoint("/chat");
}

Notworking case:

@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
    registry.addEndpoint("/chat").withSockJS();
}

Also: I have noticed that adding .setAllowedOrigins("http://localhost:5050") doesn't have any impact on communication in my case. I was able to connect to the server via a client on port 5050 but also via postman on 5555. Before the problem with withSockJs() I struggled with a different problem related to CORS. The solution was to change the socket configuration on the client from SockJs to WebSocket but before finding this I tried many different approaches on the server side as I thought that my server implementation was the problem. I was working with setAllowedOrigins, but when I was finally able to connect I noticed that this method seems to not work.

One more question: How is the controller of WebSocket endpoints implemented? I want to keep track of active clients username to sessionId mapping. Do I need thread safe static map or all of messaging happen on a single thread? In other words, will there be more than one WebSocket controller instance if multiple clients are connected?


问:
How can I use TLS and ECC in a C++ Android application?
I want to write a C++ server which will run on Android. It needs TLS and cryptographic functions including ECC.

Pretty much every solution I can find is Java-oriented, but this has to be C++. And OpenSSL is not a standard library on Android as far as I can tell, nor can I find any similar library available as standard.

The final app will run the C++ server component in as a background service (it should auto-restart in event of a crash) and also a conventional Java/Kotlin UI (running in a separate process) which I intend to develop using Android Studio on Linux.

How can I include TLS and ECC in the server component, in a way which makes sense with Android Studio?


问:
Why does the return data of a function useAsync appear undefined?
We tried to obtain weather data, but tried with the react-async library to determine the return value of this asynchronous function. However, the status is always displayed as pending and no data is defined.
Can you tell me why?

// The parameter was omitted because the required values were obtained through other functions.
const weatherData = async () => {
  let req = await axios.get(getURLs(...getTime()).curr);
  let reqData = current(req);
  // console.log(req);
  // console.log(reqData);
  return reqData;
};

// Component function
const WeatherList = () => {
  const { data, error, isLoading, promise } = useAsync({
    promiseFn: weatherData,
  });
  console.log(data); // undefined << Why are you doing this to me?
// ... more code
}
```

react-async docs : https://docs.react-async.com/guide/async-components

Body:
We tried to obtain weather data, but tried with the react-async library to determine the return value of this asynchronous function. However, the status is always displayed as pending and no data is defined.
Can you tell me why?

// The parameter was omitted because the required values were obtained through other functions.
const weatherData = async () => {
  let req = await axios.get(getURLs(...getTime()).curr);
  let reqData = current(req);
  // console.log(req);
  // console.log(reqData);
  return reqData;
};

// Component function
const WeatherList = () => {
  const { data, error, isLoading, promise } = useAsync({
    promiseFn: weatherData,
  });
  console.log(data); // undefined << Why are you doing this to me?
// ... more code
}

react-async docs : https://docs.react-async.com/guide/async-components


问:
How to position bootstrap button on bottom of page unless user needs to scroll
I have a web page using bootstrap layout.
Currently built with Container>row>col.

I need to position a button at the bottom of every page that will stay at the bottom of the page, unless the user needs to scroll down to view.  At that point the button needs to be at the end of the  content.

I've tried multiple variations of Position: absolute, fixed, sticky, but in most cases, when the content of a page is short, the button will park itself at the bottom of the content, half way up the page.  I need it to remain either at the bottom or buried under the scroll.

(Almost like a "bottom-max" value.)

The screen size is not known, as this is an app built for phones and tablets.


问:
Mysql find element
I have:

```<code>const connection = mysql.createConnection({
   host: process.env.APP_DATABASE_HOST,
   user: process.env.APP_DATABASE_USER,
   password: process.env.APP_DATABASE_PASS,
   database: process.env.APP_DATABASE_NAME,
   port: process.env.APP_DATABASE_PORT
});

const connectDataBase = () => {
    connection.connect(function(error){
        if(error){
           console.log(error);
        }else{
           console.log('Connected');
        }
     });
}

exports.search = async (id) => {
    try {
       connectDataBase();
       await connection.query(`SELECT * from devices where numberserial="${id}"`, function (err, result, fields) {
          if( result ){
             return true;
          }
          return false;
        });
       closeConnectionDataBase();
    } catch (error) {
       console.log(error)
    }
 };

const closeConnectionDataBase = () => {
   connection.end();
}
</code>```

I want that when it gets the element it returns true, but if it doesn't get the element it returns false.

for now if it gets the element it returns true, the problem I'm having is when it doesn't get the element the terminal gets stuck, what am I doing wrong??? what I want is that if the element is not found in the database it returns false

Title: Mysql find element

Body:
I have:

const connection = mysql.createConnection({
   host: process.env.APP_DATABASE_HOST,
   user: process.env.APP_DATABASE_USER,
   password: process.env.APP_DATABASE_PASS,
   database: process.env.APP_DATABASE_NAME,
   port: process.env.APP_DATABASE_PORT
});

const connectDataBase = () => {
    connection.connect(function(error){
        if(error){
           console.log(error);
        }else{
           console.log('Connected');
        }
     });
}

exports.search = async (id) => {
    try {
       connectDataBase();
       await connection.query(`SELECT * from devices where numberserial="${id}"`, function (err, result, fields) {
          if( result ){
             return true;
          }
          return false;
        });
       closeConnectionDataBase();
    } catch (error) {
       console.log(error)
    }
 };

const closeConnectionDataBase = () => {
   connection.end();
}

I want that when it gets the element it returns true, but if it doesn't get the element it returns false.

for now if it gets the element it returns true, the problem I'm having is when it doesn't get the element the terminal gets stuck, what am I doing wrong??? what I want is that if the element is not found in the database it returns false


问:
Python script making OPC DA connection not running on VM Server after RDP disconnects
I am running a Python script on a Windows 2016 Server that uses the OpenOPC module to connect to an OPC DA Server and write values to a couple of tags. I need this script to execute every 15 min so I have set up a task in task scheduler to execute the script with the highest privileges whether the user is logged in or not. If I RDP connect to the server and run the script manually it works perfectly. However, as soon as I disconnect the script no longer works.

I am running other python scripts, that connect to SQL databases and query information and then save the proccessed information to excel spreadsheets, which continue to work even when I disconnect. It seems that the OpenOPC module cannot run when the user disconnects. I can't understand why this would be an issue. Take note that the VM does not log off or restart.

I tried running the script manually in IDLE while connected and putting it on a loop so that I could start it, disconnect and reconnect to see what happened. I was presented with the following error code:

```<code>Traceback (most recent call last):
File "C:\Users\Script.py", line 92, in <module>
main(time, String, opcServer)
File "C:\Users\Script.py", line 34, in main
opc.connect(opcServer)
File "C:\Python27\lib\site-packages\Pyro\core.py", line 381, in __call__
return self.__send(self.__name, args, kwargs)
File "C:\Python27\lib\site-packages\Pyro\core.py", line 456, in _invokePYRO
return self.adapter.remoteInvocation(name, Pyro.constants.RIF_VarargsAndKeywords, vargs, kargs)
File "C:\Python27\lib\site-packages\Pyro\protocol.py", line 497, in remoteInvocation
return self._remoteInvocation(method, flags, *args)
File "C:\Python27\lib\site-packages\Pyro\protocol.py", line 572, in _remoteInvocation
answer.raiseEx()
File "C:\Python27\lib\site-packages\Pyro\errors.py", line 72, in raiseEx
raise self.excObj
OPCError: Connect: The server process could not be started because the configured identity is incorrect. Check the username and password. (The server process could not be started because the configured identity is incorrect. Check the username and password.)
</code>```

Body:
I am running a Python script on a Windows 2016 Server that uses the OpenOPC module to connect to an OPC DA Server and write values to a couple of tags. I need this script to execute every 15 min so I have set up a task in task scheduler to execute the script with the highest privileges whether the user is logged in or not. If I RDP connect to the server and run the script manually it works perfectly. However, as soon as I disconnect the script no longer works.

I am running other python scripts, that connect to SQL databases and query information and then save the proccessed information to excel spreadsheets, which continue to work even when I disconnect. It seems that the OpenOPC module cannot run when the user disconnects. I can't understand why this would be an issue. Take note that the VM does not log off or restart.

I tried running the script manually in IDLE while connected and putting it on a loop so that I could start it, disconnect and reconnect to see what happened. I was presented with the following error code:

Traceback (most recent call last):
File "C:\Users\Script.py", line 92, in <module>
main(time, String, opcServer)
File "C:\Users\Script.py", line 34, in main
opc.connect(opcServer)
File "C:\Python27\lib\site-packages\Pyro\core.py", line 381, in __call__
return self.__send(self.__name, args, kwargs)
File "C:\Python27\lib\site-packages\Pyro\core.py", line 456, in _invokePYRO
return self.adapter.remoteInvocation(name, Pyro.constants.RIF_VarargsAndKeywords, vargs, kargs)
File "C:\Python27\lib\site-packages\Pyro\protocol.py", line 497, in remoteInvocation
return self._remoteInvocation(method, flags, *args)
File "C:\Python27\lib\site-packages\Pyro\protocol.py", line 572, in _remoteInvocation
answer.raiseEx()
File "C:\Python27\lib\site-packages\Pyro\errors.py", line 72, in raiseEx
raise self.excObj
OPCError: Connect: The server process could not be started because the configured identity is incorrect. Check the username and password. (The server process could not be started because the configured identity is incorrect. Check the username and password.)


问:
authenticate against sonatype ossindex with maven plugin
I am using the mvn org.sonatype.ossindex.maven:ossindex-maven-plugin from command line to check the dependencies of a maven project for CVEs. Locally, everything works fine, but in my build pipeline in Azure Devops, I get the following error:

```<code>[DEBUG] Connecting to ossindex.sonatype.org/18.118.116.156:443
[DEBUG] Connecting socket to ossindex.sonatype.org/18.118.116.156:443 with timeout 0
[DEBUG] Enabled protocols: [TLSv1.3, TLSv1.2]
[DEBUG] Enabled cipher suites:[TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_DSS_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384, TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_DSS_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
[DEBUG] Starting handshake
[DEBUG] Secure session established
[DEBUG]  negotiated protocol: TLSv1.2
[DEBUG]  negotiated cipher suite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
[DEBUG]  peer principal: CN=ossindex.sonatype.org
[DEBUG]  peer alternative names: [ossindex.sonatype.org]
[DEBUG]  issuer principal: CN=Amazon, OU=Server CA 1B, O=Amazon, C=US
[DEBUG] Connection established 172.21.1.242:33030<->18.118.116.156:443
[DEBUG] Executing request POST /api/v3/component-report HTTP/1.1
[DEBUG] Proxy auth state: UNCHALLENGED
[DEBUG] http-outgoing-2 >> POST /api/v3/component-report HTTP/1.1
[DEBUG] http-outgoing-2 >> User-Agent: ossindex-client/1.1.1 (Linux; 5.4.0-124-generic; amd64; 11.0.12) Maven/3.8.1 Maven-Plugin/3.1.0
[DEBUG] http-outgoing-2 >> Authorization: Basic {SOME_BASE_64_THAT_TRANSLATES_TO:AzureDevOps:ey...}
[DEBUG] http-outgoing-2 >> Accept: application/vnd.ossindex.component-report.v1+json
[DEBUG] http-outgoing-2 >> Content-Length: 6737
[DEBUG] http-outgoing-2 >> Content-Type: application/vnd.ossindex.component-report-request.v1+json; charset=UTF-8
[DEBUG] http-outgoing-2 >> Host: ossindex.sonatype.org
[DEBUG] http-outgoing-2 >> Connection: Keep-Alive
[DEBUG] http-outgoing-2 >> Accept-Encoding: gzip,deflate
[DEBUG] http-outgoing-2 >> "POST /api/v3/component-report HTTP/1.1[\r][\n]"
[DEBUG] http-outgoing-2 >> "User-Agent: ossindex-client/1.1.1 (Linux; 5.4.0-124-generic; amd64; 11.0.12) Maven/3.8.1 Maven-Plugin/3.1.0[\r][\n]"
[DEBUG] http-outgoing-2 >> "Authorization: Basic {SOME_OTHER_BASE64_NO_IDEA_WHERE_IT_COMES_FROM=[\r][\n]"
[DEBUG] http-outgoing-2 >> "Accept: application/vnd.ossindex.component-report.v1+json[\r][\n]"
[DEBUG] http-outgoing-2 >> "Content-Length: 6737[\r][\n]"
[DEBUG] http-outgoing-2 >> "Content-Type: application/vnd.ossindex.component-report-request.v1+json; charset=UTF-8[\r][\n]"
[DEBUG] http-outgoing-2 >> "Host: ossindex.sonatype.org[\r][\n]"
[DEBUG] http-outgoing-2 >> "Connection: Keep-Alive[\r][\n]"
[DEBUG] http-outgoing-2 >> "Accept-Encoding: gzip,deflate[\r][\n]"
[DEBUG] http-outgoing-2 >> "[\r][\n]"
[DEBUG] http-outgoing-2 >> "{"coordinates":[ A_LIST_OF_128_COORDINATES]
[DEBUG] http-outgoing-2 << "HTTP/1.1 401 Unauthorized[\r][\n]"
[DEBUG] http-outgoing-2 << "Date: Wed, 07 Dec 2022 13:51:42 GMT[\r][\n]"
[DEBUG] http-outgoing-2 << "Content-Length: 0[\r][\n]"
[DEBUG] http-outgoing-2 << "Connection: keep-alive[\r][\n]"
</code>```

so I tried setting the clientConfiguration parameter described here.

it has a dead link but I believe it references this class which has this class as a member.

```<code> mvn org.sonatype.ossindex.maven:ossindex-maven-plugin:3.1.0:audit -f $(Build.SourcesDirectory)/pom.xml -"Dossindex.authId=MY_SERVER" -"Dossindex.clientConfiguration={\"auth\": {\"username\": \"myemail@myorg.com\", \"password\": \"$(OSS_INDEX_API_TOKEN)\"} }"
</code>```

but it didn't change anything.
Is this how one passes this parameter? Why am I getting a 401 in my build pipeline but everything works locally? I tried reading the docs on what requests are allowed/authorized but found them rather lacking...

Body:
I am using the mvn org.sonatype.ossindex.maven:ossindex-maven-plugin from command line to check the dependencies of a maven project for CVEs. Locally, everything works fine, but in my build pipeline in Azure Devops, I get the following error:

[DEBUG] Connecting to ossindex.sonatype.org/18.118.116.156:443
[DEBUG] Connecting socket to ossindex.sonatype.org/18.118.116.156:443 with timeout 0
[DEBUG] Enabled protocols: [TLSv1.3, TLSv1.2]
[DEBUG] Enabled cipher suites:[TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_DSS_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384, TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_DSS_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
[DEBUG] Starting handshake
[DEBUG] Secure session established
[DEBUG]  negotiated protocol: TLSv1.2
[DEBUG]  negotiated cipher suite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
[DEBUG]  peer principal: CN=ossindex.sonatype.org
[DEBUG]  peer alternative names: [ossindex.sonatype.org]
[DEBUG]  issuer principal: CN=Amazon, OU=Server CA 1B, O=Amazon, C=US
[DEBUG] Connection established 172.21.1.242:33030<->18.118.116.156:443
[DEBUG] Executing request POST /api/v3/component-report HTTP/1.1
[DEBUG] Proxy auth state: UNCHALLENGED
[DEBUG] http-outgoing-2 >> POST /api/v3/component-report HTTP/1.1
[DEBUG] http-outgoing-2 >> User-Agent: ossindex-client/1.1.1 (Linux; 5.4.0-124-generic; amd64; 11.0.12) Maven/3.8.1 Maven-Plugin/3.1.0
[DEBUG] http-outgoing-2 >> Authorization: Basic {SOME_BASE_64_THAT_TRANSLATES_TO:AzureDevOps:ey...}
[DEBUG] http-outgoing-2 >> Accept: application/vnd.ossindex.component-report.v1+json
[DEBUG] http-outgoing-2 >> Content-Length: 6737
[DEBUG] http-outgoing-2 >> Content-Type: application/vnd.ossindex.component-report-request.v1+json; charset=UTF-8
[DEBUG] http-outgoing-2 >> Host: ossindex.sonatype.org
[DEBUG] http-outgoing-2 >> Connection: Keep-Alive
[DEBUG] http-outgoing-2 >> Accept-Encoding: gzip,deflate
[DEBUG] http-outgoing-2 >> "POST /api/v3/component-report HTTP/1.1[\r][\n]"
[DEBUG] http-outgoing-2 >> "User-Agent: ossindex-client/1.1.1 (Linux; 5.4.0-124-generic; amd64; 11.0.12) Maven/3.8.1 Maven-Plugin/3.1.0[\r][\n]"
[DEBUG] http-outgoing-2 >> "Authorization: Basic {SOME_OTHER_BASE64_NO_IDEA_WHERE_IT_COMES_FROM=[\r][\n]"
[DEBUG] http-outgoing-2 >> "Accept: application/vnd.ossindex.component-report.v1+json[\r][\n]"
[DEBUG] http-outgoing-2 >> "Content-Length: 6737[\r][\n]"
[DEBUG] http-outgoing-2 >> "Content-Type: application/vnd.ossindex.component-report-request.v1+json; charset=UTF-8[\r][\n]"
[DEBUG] http-outgoing-2 >> "Host: ossindex.sonatype.org[\r][\n]"
[DEBUG] http-outgoing-2 >> "Connection: Keep-Alive[\r][\n]"
[DEBUG] http-outgoing-2 >> "Accept-Encoding: gzip,deflate[\r][\n]"
[DEBUG] http-outgoing-2 >> "[\r][\n]"
[DEBUG] http-outgoing-2 >> "{"coordinates":[ A_LIST_OF_128_COORDINATES]
[DEBUG] http-outgoing-2 << "HTTP/1.1 401 Unauthorized[\r][\n]"
[DEBUG] http-outgoing-2 << "Date: Wed, 07 Dec 2022 13:51:42 GMT[\r][\n]"
[DEBUG] http-outgoing-2 << "Content-Length: 0[\r][\n]"
[DEBUG] http-outgoing-2 << "Connection: keep-alive[\r][\n]"

so I tried setting the clientConfiguration parameter described here.

it has a dead link but I believe it references this class which has this class as a member.

 mvn org.sonatype.ossindex.maven:ossindex-maven-plugin:3.1.0:audit -f $(Build.SourcesDirectory)/pom.xml -"Dossindex.authId=MY_SERVER" -"Dossindex.clientConfiguration={\"auth\": {\"username\": \"myemail@myorg.com\", \"password\": \"$(OSS_INDEX_API_TOKEN)\"} }"

but it didn't change anything.
Is this how one passes this parameter? Why am I getting a 401 in my build pipeline but everything works locally? I tried reading the docs on what requests are allowed/authorized but found them rather lacking...


问:
Firestore Firebase (onShapshot) or Socket.io
One quick question just to figure out how this works under the hood.

I implemented onSnapshot from FireBase, it works exactly as Socket.io,
when you subscribe to something in Data Base , and when you change it , it automatically updates on Front End as well.
Like in any chat-app, you automatically get the latest "message" without manually fetching it.

How does this work?
Why can't i see anything happening in the network tab?
My content changes exactly how i want it to, but i can't track it, nothing shows in the networking tab.
Any insight? Thanks!


问:
Having list of luigi tasks as parameter to be called in requires method of another luigi task
I am using Luigi for a data pipeline I am currently working on.

I have a Task A that calls another Task B in its requires-method. Task B calls a few other tasks (let's call them C) in its requires-method to download data from a server. The data then is merged to a single dataframe in Task B.

Right now, the C tasks are called statically, I am just calling them in the requires-method of Task B.
 My idea was to make the tasks C to call dynamic by having a list of luigi tasks as parameter for Task B.

So instead of doing this:

Task A:

```<code>def requires(self):
    return Task_B(param1=param1, param2=param2, ...)
</code>```

Task B:

```<code>def requires(self):
    return [Task_C1(param1=param1, param2=param2, ...),
            Task_C2(param1=param1, param2=param2, ...),
            ...
           ]
</code>```

I wanna do this:

Task A:

```<code>def requires(self):
    return Task_B(param1=param1, param2=param2,
                  param_C_tasks=[Task_C1(param1=param1, param2=param2, ...),
                                 Task_C2(param1=param1, param2=param2, ...),
                                 ...
                                 ],
                  ...)

</code>```

Task B:

```<code>def requires(self):
    *pseudo code*
    run every task in self.param_C_tasks
</code>```

Is it even possible to achieve the dynamic calling of the `C` tasks as I imagine them being called?

Body:
I am using Luigi for a data pipeline I am currently working on.

I have a Task A that calls another Task B in its requires-method. Task B calls a few other tasks (let's call them C) in its requires-method to download data from a server. The data then is merged to a single dataframe in Task B.

Right now, the C tasks are called statically, I am just calling them in the requires-method of Task B.
 My idea was to make the tasks C to call dynamic by having a list of luigi tasks as parameter for Task B.

So instead of doing this:

Task A:

def requires(self):
    return Task_B(param1=param1, param2=param2, ...)

Task B:

def requires(self):
    return [Task_C1(param1=param1, param2=param2, ...),
            Task_C2(param1=param1, param2=param2, ...),
            ...
           ]

I wanna do this:

Task A:

def requires(self):
    return Task_B(param1=param1, param2=param2,
                  param_C_tasks=[Task_C1(param1=param1, param2=param2, ...),
                                 Task_C2(param1=param1, param2=param2, ...),
                                 ...
                                 ],
                  ...)

Task B:

def requires(self):
    *pseudo code*
    run every task in self.param_C_tasks

Is it even possible to achieve the dynamic calling of the `C` tasks as I imagine them being called?


问:
How do I check for a running process before executing another?
I've found some references to searching for active .exe in the task list but I haven't been able to get any to work.

I'm trying to find a working bat script because I have memory problems and I've been banned twice now for simply forgetting to shut it down.

I have tried the other suggestions on here but they are from 2012 and didn't seem to be working.

I am running Win 10 Home. Any help would be appreciated.

I am not a proficient coder. I can read it and determine what it's supposed to do, but I don't know how to fix it if it doesn't.

For the non-coders looking at this from a google search, this is attempting to create a batch file that simply checks if Cheat engine is running. If it is it pauses and tells me and stops the launcher from loading until Cheat engine isn't in the process tree.

The first bit I found on Reddit by someone who searched through your site to come up with this. It is about 2 years old but doesn't appear to work anymore, as far as I can tell.

tasklist /FI "IMAGENAME eq Cheat engine.exe" 2>NUL | find /N "Cheat engine.exe">NUL

if "%ERRORLEVEL%"=="0" start "" cmd /c "echo [Cheat engine running.]&echo(&pause"

if "%ERRORLEVEL%"=="1" start "" F:\SteamLibrary\steamapps\common\Warframe\Tools\Launcher.exe

That's what I've found. But it never returns an error, even when I run it while intentionally running CE. I never go past the launcher so it shouldn't flag in their system, therefore I should be able to test this as much as necessary.

and

just to see if I could run a kill process for it. This didn't do anything.

```<code>echo off
tasklist /fi "imagename eq cheat engine.exe" |find ":" > nul
if errorlevel 1 taskkill /f /im "cheat engine.exe"
exit
</code>```

Body:
I've found some references to searching for active .exe in the task list but I haven't been able to get any to work.

I'm trying to find a working bat script because I have memory problems and I've been banned twice now for simply forgetting to shut it down.

I have tried the other suggestions on here but they are from 2012 and didn't seem to be working.

I am running Win 10 Home. Any help would be appreciated.

I am not a proficient coder. I can read it and determine what it's supposed to do, but I don't know how to fix it if it doesn't.

For the non-coders looking at this from a google search, this is attempting to create a batch file that simply checks if Cheat engine is running. If it is it pauses and tells me and stops the launcher from loading until Cheat engine isn't in the process tree.

The first bit I found on Reddit by someone who searched through your site to come up with this. It is about 2 years old but doesn't appear to work anymore, as far as I can tell.

tasklist /FI "IMAGENAME eq Cheat engine.exe" 2>NUL | find /N "Cheat engine.exe">NUL

if "%ERRORLEVEL%"=="0" start "" cmd /c "echo [Cheat engine running.]&echo(&pause"

if "%ERRORLEVEL%"=="1" start "" F:\SteamLibrary\steamapps\common\Warframe\Tools\Launcher.exe

That's what I've found. But it never returns an error, even when I run it while intentionally running CE. I never go past the launcher so it shouldn't flag in their system, therefore I should be able to test this as much as necessary.

and

just to see if I could run a kill process for it. This didn't do anything.

echo off
tasklist /fi "imagename eq cheat engine.exe" |find ":" > nul
if errorlevel 1 taskkill /f /im "cheat engine.exe"
exit


问:
Java Record in Valhalla
I have been using record from Java 17 for sometime and I like it.

```<code>record Something(int a, int b){}
</code>```

I also noticed recently that Project Valhalla introduces value type

```<code>value record Something(int a, int b){}
</code>```

Now I am confused. record was supposed to be value classes. Then what is the point of adding the value? What is the problem valhalla trying to solve?

Title: Java Record in Valhalla

Body:
I have been using record from Java 17 for sometime and I like it.

record Something(int a, int b){}

I also noticed recently that Project Valhalla introduces value type

value record Something(int a, int b){}

Now I am confused. record was supposed to be value classes. Then what is the point of adding the value? What is the problem valhalla trying to solve?


问:
Use environment variable as connection with paramiko (Python)
How can I use environment variable to connect with paramiko package.
My parameters currently are hard coded:
client.connect(hostname="",username="",password="")</p>


问:
Printing out Color
```<code>package com.mycompany.advent;
import java.util.Random;
import java.util.Scanner;
import java.util.\*;

public class Advent {
public static final String ANSI_RESET = "\\u001B\[0m";
// Declaring the color
public static final String ANSI_YELLOW = "\\u001B\[33m";

     public static void main(String[] args) {
         Scanner in= new Scanner(System.in);
         Random rand = new Random();

         //game variables
        String[] enemies = {" Snake"," Gorilla"," Warrior"," Assasian"};
        int maxEnemyHealth=75;
        int enemyAttackDamage=25;
        int health=100;
        int attackDamage=50;
        int healthPotions=3;
        int healthPotionHealAmount = 30;
        int healthPotionDropChance = 50;//percentage
        int counter = 0;

        boolean running =true;

        System.out.println("░░░░░██╗██╗░░░██╗███╗░░██╗░██████╗░██╗░░░░░███████╗  ███╗░░░███╗░█████╗░██████╗░███╗░░██╗███████╗░██████╗░██████╗\n" +
                           "░░░░░██║██║░░░██║████╗░██║██╔════╝░██║░░░░░██╔════╝  ████╗░████║██╔══██╗██╔══██╗████╗░██║██╔════╝██╔════╝██╔════╝\n" +
                           "░░░░░██║██║░░░██║██╔██╗██║██║░░██╗░██║░░░░░█████╗░░  ██╔████╔██║███████║██║░░██║██╔██╗██║█████╗░░╚█████╗░╚█████╗░\n" +
                           "██╗░░██║██║░░░██║██║╚████║██║░░╚██╗██║░░░░░██╔══╝░░  ██║╚██╔╝██║██╔══██║██║░░██║██║╚████║██╔══╝░░░╚═══██╗░╚═══██╗\n" +
                           "╚█████╔╝╚██████╔╝██║░╚███║╚██████╔╝███████╗███████╗  ██║░╚═╝░██║██║░░██║██████╔╝██║░╚███║███████╗██████╔╝██████╔╝\n" +
                           "░╚════╝░░╚═════╝░╚═╝░░╚══╝░╚═════╝░╚══════╝╚══════╝  ╚═╝░░░░░╚═╝╚═╝░░╚═╝╚═════╝░╚═╝░░╚══╝╚══════╝╚═════╝░╚═════╝░");

        GAME:
            while(running) {
                System.out.println(ANSI_YELLOW + "╭━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━╮\n" +
                                                         "╰━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━╯" + ANSI_RESET);
</code>```

Im trying to print color in my terminal, but it won't let me, I put it inside the class, but outside of the main method and it doesn't show any errors, but when I do press play, It does not print the color.

Title: Printing out Color

Body:
package com.mycompany.advent;
import java.util.Random;
import java.util.Scanner;
import java.util.\*;

public class Advent {
public static final String ANSI_RESET = "\\u001B\[0m";
// Declaring the color
public static final String ANSI_YELLOW = "\\u001B\[33m";

     public static void main(String[] args) {
         Scanner in= new Scanner(System.in);
         Random rand = new Random();

         //game variables
        String[] enemies = {" Snake"," Gorilla"," Warrior"," Assasian"};
        int maxEnemyHealth=75;
        int enemyAttackDamage=25;
        int health=100;
        int attackDamage=50;
        int healthPotions=3;
        int healthPotionHealAmount = 30;
        int healthPotionDropChance = 50;//percentage
        int counter = 0;

        boolean running =true;

        System.out.println("░░░░░██╗██╗░░░██╗███╗░░██╗░██████╗░██╗░░░░░███████╗  ███╗░░░███╗░█████╗░██████╗░███╗░░██╗███████╗░██████╗░██████╗\n" +
                           "░░░░░██║██║░░░██║████╗░██║██╔════╝░██║░░░░░██╔════╝  ████╗░████║██╔══██╗██╔══██╗████╗░██║██╔════╝██╔════╝██╔════╝\n" +
                           "░░░░░██║██║░░░██║██╔██╗██║██║░░██╗░██║░░░░░█████╗░░  ██╔████╔██║███████║██║░░██║██╔██╗██║█████╗░░╚█████╗░╚█████╗░\n" +
                           "██╗░░██║██║░░░██║██║╚████║██║░░╚██╗██║░░░░░██╔══╝░░  ██║╚██╔╝██║██╔══██║██║░░██║██║╚████║██╔══╝░░░╚═══██╗░╚═══██╗\n" +
                           "╚█████╔╝╚██████╔╝██║░╚███║╚██████╔╝███████╗███████╗  ██║░╚═╝░██║██║░░██║██████╔╝██║░╚███║███████╗██████╔╝██████╔╝\n" +
                           "░╚════╝░░╚═════╝░╚═╝░░╚══╝░╚═════╝░╚══════╝╚══════╝  ╚═╝░░░░░╚═╝╚═╝░░╚═╝╚═════╝░╚═╝░░╚══╝╚══════╝╚═════╝░╚═════╝░");

        GAME:
            while(running) {
                System.out.println(ANSI_YELLOW + "╭━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━╮\n" +
                                                         "╰━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━╯" + ANSI_RESET);

Im trying to print color in my terminal, but it won't let me, I put it inside the class, but outside of the main method and it doesn't show any errors, but when I do press play, It does not print the color.


问:
SurveyJS: Problem while installing the dependencies
I have several problems while installing SurveyJS locally and all it's dependencies.
I am installing them with npm i but still got several problems with the dependencies.
My OS version is Ubuntu 20.04.5 LTS.
Node -v v19.2.0
NPM -v 8.19.3

Here are the dependencies:

```<code>{
    "@angular-devkit/build-angular": "^13.3.10",
    "@angular/cdk": "~13.0.0",
    "@angular/cli": "~13.0.0",
    "@angular/common": "~13.0.0",
    "@angular/compiler": "~13.0.0",
    "@angular/compiler-cli": "~13.0.0",
    "@angular/core": "~13.0.0",
    "@angular/forms": "~13.0.0",
    "@angular/platform-browser": "~13.0.0",
    "@angular/platform-browser-dynamic": "~13.0.0",
    "@types/ace": "0.0.32",
    "@types/angular": "^1.6.2",
    "@types/babel__traverse": "7.18.2",
    "@types/jest": "23.3.3",
    "@types/jquery": "^2.0.39",
    "@types/lodash": "4.14.186",
    "@types/node": "*",
    "@types/papaparse": "^5.0.4",
    "@types/qunit": "2.0.31",
    "@types/react": "17.0.1",
    "@types/react-dom": "17.0.1",
    "@types/signature_pad": "^2.3.0",
    "@typescript-eslint/eslint-plugin": "^4.29.0",
    "@typescript-eslint/parser": "^4.29.0",
    "ace-builds": "1.2.2",
    "ajv": "^8.11.2",
    "babel-loader": "8.2.5",
    "colors": "1.4.0",
    "concurrently": "^5.2.0",
    "copy-webpack-plugin": "^11.0.0",
    "css-loader": "^3.6.0",
    "devextreme-screenshot-comparer": "^2.0.11",
    "dotenv": "4.0.0",
    "eslint": "^7.32.0",
    "eslint-cli": "^1.1.1",
    "eslint-plugin-react": "7.30.1",
    "eslint-plugin-surveyjs": "file:eslint-surveyjs",
    "eslint-plugin-vue": "^7.16.0",
    "file-loader": "^0.10.1",
    "generate-json-webpack-plugin": "^1.0.0",
    "github-api": "^3.3.0",
    "html-loader": "^0.4.5",
    "http-server": "^14.1.1",
    "husky": "^7.0.0",
    "jest": "^26.1.0",
    "jest-canvas-mock": "^2.2.0",
    "jquery": "^3.5.1",
    "karma": "^6.1.1",
    "karma-chrome-launcher": "^3.1.0",
    "karma-junit-reporter": "2.0.1",
    "karma-qunit": "4.1.2",
    "karma-sourcemap-loader": "0.3.8",
    "karma-webpack": "5.0.0",
    "knockout": "^3.5.0",
    "live-server": "^1.1.0",
    "madge": "^4.0.2",
    "mini-css-extract-plugin": "^0.9.0",
    "minimist": "^1.2.5",
    "ng-packagr": "^13.0.0",
    "node-uuid": "^1.4.8",
    "postcss": "^8.4.0",
    "puppeteer": "^1.19.0",
    "qunit": "2.14.0",
    "react": "17.0.1",
    "react-dom": "17.0.1",
    "replace-in-file": "^3.4.3",
    "rimraf": "2.5.4",
    "rxjs": "~6.6.0",
    "sass": "^1",
    "sass-loader": "^8.0.2",
    "standard-version": "^9.5.0",
    "style-loader": "^1.2.1",
    "surveyjs-doc-generator": "git+https://github.com/surveyjs/surveyjs-doc-generator.git",
    "svg-inline-loader": "^0.8.2",
    "testcafe": "1.16.1",
    "testcafe-hammerhead": "24.5.4",
    "testcafe-reporter-dashboard": "^0.2.4-rc.1",
    "ts-jest": "^26.1.1",
    "ts-loader": "^8.0.15",
    "ts-node": "3.3.0",
    "tsconfig-paths-webpack-plugin": "^3.3.0",
    "typescript": "^4.2.2",
    "url-loader": "^4.1.1",
    "val-loader": "^0.5.1",
    "vue": "2.6.14",
    "vue-class-component": "7.2.6",
    "vue-class-decorator": "7.6.3",
    "vue-loader": "15.9.8",
    "vue-property-decorator": "9.1.2",
    "vue-template-compiler": "2.6.14",
    "vue-tsc": "^1.0.8",
    "webpack": "^4.43.0",
    "webpack-cli": "^3.3.12",
    "webpack-dev-server": "^4.11.1",
    "webpack-fix-style-only-entries": "^0.6.1",
    "webpack-merge": "^5.7.3",
    "webpack-svgstore-plugin": "^3.0.5",
    "zone.js": "~0.11.4"
</code>```

I tried to force the execution with npm i --force still have a issues there.
My OS version is Ubuntu 20.04.5 LTS.
Node -v v19.2.0
NPM -v 8.19.3

I don't know if it's my OS version or if it's related to the dependencies.

For further details, I can add terminal output.

Here is what I got after doing:

rm -rf node_modules

npm config set legacy-peer-deps true

npm install

Body:
I have several problems while installing SurveyJS locally and all it's dependencies.
I am installing them with npm i but still got several problems with the dependencies.
My OS version is Ubuntu 20.04.5 LTS.
Node -v v19.2.0
NPM -v 8.19.3

Here are the dependencies:

{
    "@angular-devkit/build-angular": "^13.3.10",
    "@angular/cdk": "~13.0.0",
    "@angular/cli": "~13.0.0",
    "@angular/common": "~13.0.0",
    "@angular/compiler": "~13.0.0",
    "@angular/compiler-cli": "~13.0.0",
    "@angular/core": "~13.0.0",
    "@angular/forms": "~13.0.0",
    "@angular/platform-browser": "~13.0.0",
    "@angular/platform-browser-dynamic": "~13.0.0",
    "@types/ace": "0.0.32",
    "@types/angular": "^1.6.2",
    "@types/babel__traverse": "7.18.2",
    "@types/jest": "23.3.3",
    "@types/jquery": "^2.0.39",
    "@types/lodash": "4.14.186",
    "@types/node": "*",
    "@types/papaparse": "^5.0.4",
    "@types/qunit": "2.0.31",
    "@types/react": "17.0.1",
    "@types/react-dom": "17.0.1",
    "@types/signature_pad": "^2.3.0",
    "@typescript-eslint/eslint-plugin": "^4.29.0",
    "@typescript-eslint/parser": "^4.29.0",
    "ace-builds": "1.2.2",
    "ajv": "^8.11.2",
    "babel-loader": "8.2.5",
    "colors": "1.4.0",
    "concurrently": "^5.2.0",
    "copy-webpack-plugin": "^11.0.0",
    "css-loader": "^3.6.0",
    "devextreme-screenshot-comparer": "^2.0.11",
    "dotenv": "4.0.0",
    "eslint": "^7.32.0",
    "eslint-cli": "^1.1.1",
    "eslint-plugin-react": "7.30.1",
    "eslint-plugin-surveyjs": "file:eslint-surveyjs",
    "eslint-plugin-vue": "^7.16.0",
    "file-loader": "^0.10.1",
    "generate-json-webpack-plugin": "^1.0.0",
    "github-api": "^3.3.0",
    "html-loader": "^0.4.5",
    "http-server": "^14.1.1",
    "husky": "^7.0.0",
    "jest": "^26.1.0",
    "jest-canvas-mock": "^2.2.0",
    "jquery": "^3.5.1",
    "karma": "^6.1.1",
    "karma-chrome-launcher": "^3.1.0",
    "karma-junit-reporter": "2.0.1",
    "karma-qunit": "4.1.2",
    "karma-sourcemap-loader": "0.3.8",
    "karma-webpack": "5.0.0",
    "knockout": "^3.5.0",
    "live-server": "^1.1.0",
    "madge": "^4.0.2",
    "mini-css-extract-plugin": "^0.9.0",
    "minimist": "^1.2.5",
    "ng-packagr": "^13.0.0",
    "node-uuid": "^1.4.8",
    "postcss": "^8.4.0",
    "puppeteer": "^1.19.0",
    "qunit": "2.14.0",
    "react": "17.0.1",
    "react-dom": "17.0.1",
    "replace-in-file": "^3.4.3",
    "rimraf": "2.5.4",
    "rxjs": "~6.6.0",
    "sass": "^1",
    "sass-loader": "^8.0.2",
    "standard-version": "^9.5.0",
    "style-loader": "^1.2.1",
    "surveyjs-doc-generator": "git+https://github.com/surveyjs/surveyjs-doc-generator.git",
    "svg-inline-loader": "^0.8.2",
    "testcafe": "1.16.1",
    "testcafe-hammerhead": "24.5.4",
    "testcafe-reporter-dashboard": "^0.2.4-rc.1",
    "ts-jest": "^26.1.1",
    "ts-loader": "^8.0.15",
    "ts-node": "3.3.0",
    "tsconfig-paths-webpack-plugin": "^3.3.0",
    "typescript": "^4.2.2",
    "url-loader": "^4.1.1",
    "val-loader": "^0.5.1",
    "vue": "2.6.14",
    "vue-class-component": "7.2.6",
    "vue-class-decorator": "7.6.3",
    "vue-loader": "15.9.8",
    "vue-property-decorator": "9.1.2",
    "vue-template-compiler": "2.6.14",
    "vue-tsc": "^1.0.8",
    "webpack": "^4.43.0",
    "webpack-cli": "^3.3.12",
    "webpack-dev-server": "^4.11.1",
    "webpack-fix-style-only-entries": "^0.6.1",
    "webpack-merge": "^5.7.3",
    "webpack-svgstore-plugin": "^3.0.5",
    "zone.js": "~0.11.4"

I tried to force the execution with npm i --force still have a issues there.
My OS version is Ubuntu 20.04.5 LTS.
Node -v v19.2.0
NPM -v 8.19.3

I don't know if it's my OS version or if it's related to the dependencies.

For further details, I can add terminal output.

Here is what I got after doing:

rm -rf node_modules

npm config set legacy-peer-deps true

npm install


问:
Spring reactive - backoff breaks chain in retryWhen
code 1 - with max(3)

```<code>        Mono.just("abc")
                .map(s -> s.charAt(4))
                .retryWhen(Retry
                    .max(3)
                    .doBeforeRetry(rs -> System.out.println("doBeforeRetry"))
                )
                .onErrorResume(e -> {
                    System.out.println("onErrorResume()");
                    return Mono.just('?');
                })
                .subscribe(System.out::println);
</code>```

Output:

doBeforeRetry()

doBeforeRetry()

doBeforeRetry()

onErrorResume()

?

code 2 - with backoff(3, Duration.ofMillis(100)

```<code>        Mono.just("abc")
                .map(s -> s.charAt(4))
                .retryWhen(Retry
                    .backoff(3, Duration.ofMillis(100))
                    .doBeforeRetry(rs -> System.out.println("doBeforeRetry()"))
                )
                .onErrorResume(e -> {
                    System.out.println("onErrorResume()");
                    return Mono.just('?');
                })
                .subscribe(System.out::println);
</code>```

Output:

doBeforeRetry()

Looks like backoff breaks a chain completely... The question is why output differs?

Body:
code 1 - with max(3)

        Mono.just("abc")
                .map(s -> s.charAt(4))
                .retryWhen(Retry
                    .max(3)
                    .doBeforeRetry(rs -> System.out.println("doBeforeRetry"))
                )
                .onErrorResume(e -> {
                    System.out.println("onErrorResume()");
                    return Mono.just('?');
                })
                .subscribe(System.out::println);

Output:

doBeforeRetry()

doBeforeRetry()

doBeforeRetry()

onErrorResume()

?

code 2 - with backoff(3, Duration.ofMillis(100)

        Mono.just("abc")
                .map(s -> s.charAt(4))
                .retryWhen(Retry
                    .backoff(3, Duration.ofMillis(100))
                    .doBeforeRetry(rs -> System.out.println("doBeforeRetry()"))
                )
                .onErrorResume(e -> {
                    System.out.println("onErrorResume()");
                    return Mono.just('?');
                })
                .subscribe(System.out::println);

Output:

doBeforeRetry()

Looks like backoff breaks a chain completely... The question is why output differs?


问:
In a .NET web app, how do I get functions to work with RDLC?
I have a web application that uses RDLC to format reports in both Excel and PDF. The values appear fine when I insert them directly from a DataSet, but when I use any sort of function other than First(), the value shows "#Error" in PDF and "#VALUE!" in Excel. This includes using & to concentate two strings.

For example, my DataSet has fields named LastName and FirstName. Using either field name by itself works, but something like LastName & ", " & FirstName, or Trim(LastName), returns the error value.

Short of rewriting every report to do all of the formatting/calculations in the back-end C# code and passing the results into the data set, is there a way to fix this?