问:
Dynamic Rule validation of a Java class
I have a usecase where I need some validations at the entity level based on value of some attribute of the entity. For eg:

```<code>    Class User {
        int id;
        String job;
        String phone;
        String city;
        String state;
        String country;
    }
</code>```

Lets say for different type of jobs, I am trying to do different validations before putting in the DB.

```<code>1.**Job == Manager**
{
    city => required,
    state => optional,
    phone => optional,
    country => optional
}

2. **Job == Teacher**
{
    city => optional,
    state => required,
    phone => optional,
    country => optional
}

3. **Job == Clerk**
{
    city => should not be preset (throw exception if present),
    state => required,
    phone => optional,
    country => required
}

4. **Job == Sportsman**
{
    city => required,
    state => required,
    phone => [some regex only],
    country => required
}
</code>```

I know we can hardcode these validations before inserting the record into DB, but I want these rules to be dynamic enough, so that before insertion based on the Job type the rules will be evaluated and if confirms then only proceed to DB. The advantage of this approach will be that the application code will be decoupled from the rules. So, in future some new rule comes, I will just update the rules and it should work smoothly.

I am sure there must be some library (rule-engine) already implemented for rule validation in java. Please let me know what should I refer to implement this.

Title: Dynamic Rule validation of a Java class

Body:
I have a usecase where I need some validations at the entity level based on value of some attribute of the entity. For eg:

    Class User {
        int id;
        String job;
        String phone;
        String city;
        String state;
        String country;
    }

Lets say for different type of jobs, I am trying to do different validations before putting in the DB.

1.**Job == Manager**
{
    city => required,
    state => optional,
    phone => optional,
    country => optional
}

2. **Job == Teacher**
{
    city => optional,
    state => required,
    phone => optional,
    country => optional
}

3. **Job == Clerk**
{
    city => should not be preset (throw exception if present),
    state => required,
    phone => optional,
    country => required
}

4. **Job == Sportsman**
{
    city => required,
    state => required,
    phone => [some regex only],
    country => required
}

I know we can hardcode these validations before inserting the record into DB, but I want these rules to be dynamic enough, so that before insertion based on the Job type the rules will be evaluated and if confirms then only proceed to DB. The advantage of this approach will be that the application code will be decoupled from the rules. So, in future some new rule comes, I will just update the rules and it should work smoothly.

I am sure there must be some library (rule-engine) already implemented for rule validation in java. Please let me know what should I refer to implement this.


来源: stackexchange

问:
TinyMCE 6 - How remove selected text from TinyMCE editor
Goal: Get selected element into another element and remove selected text from existing element then place the new element where the text previously existed but as a new element.

Get the selected text:

```<code>selectedText = tinymce.activeEditor.selection.getContent()
</code>```

Create new element with selected text:

```<code>newTextNode = tinymce.activeEditor.dom.create('span', {class: value}, selectedText);
</code>```

Now i need to remove the selected text from the element and place it as the new element exactly where it was before.

How do i do that?

ContentLicense: CC BY-SA 4.0

Body:
Goal: Get selected element into another element and remove selected text from existing element then place the new element where the text previously existed but as a new element.

Get the selected text:

selectedText = tinymce.activeEditor.selection.getContent()

Create new element with selected text:

newTextNode = tinymce.activeEditor.dom.create('span', {class: value}, selectedText);

Now i need to remove the selected text from the element and place it as the new element exactly where it was before.

How do i do that?


问:
Cannot Install Crypto.Cipher Module Python (Windows)
I am having trouble installing the Crypto.Cipher module. I ran pip install Crypto and pip install Crypto.Cipher commands which state the package was successfully installed. However, when I try to execute a python file with the importation, it states that "ModuleNotFoundError: No module named 'Crypto'"


问:
Flutter check if string make 2 lines
I'm trying to fetch data from my firestore and use that data to show a description text in my widget. The problem is I want the container to have fix size, If the desc text exceed 1 line it will have certain height and if its more then 1 line it will have different height.

Can I check if that text create multiline or not in my container ? How can I achieve it ?

Title: Flutter check if string make 2 lines


问:
Determine the generic type of promise
I have a javascript function that I want to convert to typescript.
My function returns a promise, but I don't know what type I should put inside the generic promise.

My function:

async function getData(pageNum): Promise<"Here">{
    response = await ((await fetch(`https://reqres.in/api/users?page=${pageNum}`)).json());
    response = response.data;
    return response.map(user => user);
}```

Title: Determine the generic type of promise


问:
Website's images got scale in iphone's screen but in android screen it look perfect
I need help for fixing images scale issues in my project. On iPhone, screen images got scaled, but on Android phones, all images look perfect. I share some images please check and help.

Link of my project please check it inspiration page in Android and iPhone:

http://64.227.178.9/inspiration/

Does anyone know how to fix it? Please help. thanks

I tried to apply media queries to different ways but it look perfect in Android but in iPhone images got scaled.


问:
Page break in Quarto markdown
I have recently started using Quarto markdown.
Unfortunately following their documentation to generate a page break within my document with {{< pagebreak >}} does not work.
Thanks for any suggestions!

Title: Page break in Quarto markdown


问:
Can I use EF Core connection string for ADO.NET SqlConnection object in .NET 5?
```<code>SqlConnection conn = new(_dbContext.Database.GetConnectionString())
</code>```

Is this a correct way to get the connection string from DbContext, instead of getting from IConfiguration? Or it will have any other issue?

Body:
SqlConnection conn = new(_dbContext.Database.GetConnectionString())

Is this a correct way to get the connection string from DbContext, instead of getting from IConfiguration? Or it will have any other issue?


问:
Step to a specific address in angr
I'm trying to use angr to explore possible execution states from a point in a program that I know will be reached. My program takes an optional text input file as an argument, which I am providing. I can't get the simulation manager to the known point.

Here's the technique I'm attempting to use: I wrote a function that returns true if the zeroth state in the active stash has an address equal to the address of my desired basic block. I'm providing that function in the until parameter of SimulationManager.step.

sim.step(until=at_continue)
```

From the docs: https://api.angr.io/angr#angr.sim_manager.SimulationManager.step

until – (DEPRECATED) If provided, should be a function that takes a SimulationManager and returns True or False. Stepping will terminate when it is True.

My angr script runs for awhile (this basic block should be hit almost instantly), then eventually runs out of active states. I expected it to hit the block and stop. I've already verified by stepping through in radare2 that the block is hit in normal execution.

So there are two parts to my question:

Why isn't my code working?

Since until is deprecated, what's the new correct way to get this functionality?

Here's my minimum reproducible example: https://github.com/aerobinsonIV/angr-stepping-question

It's contrived, I know. My real application is pretty complicated, and I want to make this question generally applicable and easy to understand.

Thanks for your time reading this. Please let me know if there's anything I can add to make the question clearer. I might not have articulated it great because I'm not super experienced with angr.

Title: Step to a specific address in angr

Body:
I'm trying to use angr to explore possible execution states from a point in a program that I know will be reached. My program takes an optional text input file as an argument, which I am providing. I can't get the simulation manager to the known point.

Here's the technique I'm attempting to use: I wrote a function that returns true if the zeroth state in the active stash has an address equal to the address of my desired basic block. I'm providing that function in the until parameter of SimulationManager.step.

sim.step(until=at_continue)

From the docs: https://api.angr.io/angr#angr.sim_manager.SimulationManager.step

until – (DEPRECATED) If provided, should be a function that takes a SimulationManager and returns True or False. Stepping will terminate when it is True.

My angr script runs for awhile (this basic block should be hit almost instantly), then eventually runs out of active states. I expected it to hit the block and stop. I've already verified by stepping through in radare2 that the block is hit in normal execution.

So there are two parts to my question:

Why isn't my code working?

Since until is deprecated, what's the new correct way to get this functionality?

Here's my minimum reproducible example: https://github.com/aerobinsonIV/angr-stepping-question

It's contrived, I know. My real application is pretty complicated, and I want to make this question generally applicable and easy to understand.

Thanks for your time reading this. Please let me know if there's anything I can add to make the question clearer. I might not have articulated it great because I'm not super experienced with angr.


问:
Not able to access the Django APIs with WSGI
We are currently hosting the application in Google App Engine, which is powered by Python 2.7 and Django 1.1.

I tried to upgrade the application to the Python 3.x version. We included all required imports and dependencies.
It is compiled successfully, without any errors.

While launching the application, APIs are not getting invoked, and it returns with a 500 Internal Server Error code without any errors and exceptions..
We have added the WSGI handlers to the Django setup.

```<code>from django.core.wsgi import get_wsgi_application
from google.appengine.api import wrap_wsgi_app

application = get_wsgi_application()
app = wrap_wsgi_app(application)
</code>```

Follow the below Google Docs:
https://cloud.google.com/appengine/docs/standard/python3/services/access#django

Could someone help me with this ? Thanks in advance

Django APIs should be access without any issues.

Body:
We are currently hosting the application in Google App Engine, which is powered by Python 2.7 and Django 1.1.

I tried to upgrade the application to the Python 3.x version. We included all required imports and dependencies.
It is compiled successfully, without any errors.

While launching the application, APIs are not getting invoked, and it returns with a 500 Internal Server Error code without any errors and exceptions..
We have added the WSGI handlers to the Django setup.

from django.core.wsgi import get_wsgi_application
from google.appengine.api import wrap_wsgi_app

application = get_wsgi_application()
app = wrap_wsgi_app(application)

Follow the below Google Docs:
https://cloud.google.com/appengine/docs/standard/python3/services/access#django

Could someone help me with this ? Thanks in advance

Django APIs should be access without any issues.


问:
Copy to clipboard getdata function not working with modern browsers
We are facing issue with copy to clipboard function, which is working fine with IE browser while copying       data from Excel to grid on browser,but not working with modern browsers.

Our code is using GWT and through java native method call its calling Javascript code.
We have tool button- with name "Paste from excel"  on click of it below code gets called

I was trying to use event.clipboardData.getData("text/plain") but in my case I am not aware how to get event in getClipboardData(). Please comment if any one has resolved similar issue, considering the code how I can get event(paste event) in getClipboardData() or any alternative way to get solution.

```<code>

protected Function pasteFromExcelFunction =new Function(){
    public void execute(){
     if(readOnly){
     return;
     }// its false
    try{
         if(pasteFromExcelHelper.pasteDataIntoGrid(BaseEditorGridPanel.this, getRecordDef()));
           doAfterPaste();
   }
    }
  }
    public boolean pasteDataIntoGrid(BaseEditorGridPanel grid, BaseGridRecordDef recordDef)
    {
      boolean pasteSuccessful=true;
      String pastedText= readFromClipboard();
     }
     private String readFromClipboard (){
    return JavaScriptUtils.getClipboardData();
   }

public static native String getClipboardData()/*-{
    if($wnd.clipboardData && clipboardData.setData){
    return $wnd.clipboardData.getData('Text');
}-*/;

</code>```

Body:
We are facing issue with copy to clipboard function, which is working fine with IE browser while copying       data from Excel to grid on browser,but not working with modern browsers.

Our code is using GWT and through java native method call its calling Javascript code.
We have tool button- with name "Paste from excel"  on click of it below code gets called

I was trying to use event.clipboardData.getData("text/plain") but in my case I am not aware how to get event in getClipboardData(). Please comment if any one has resolved similar issue, considering the code how I can get event(paste event) in getClipboardData() or any alternative way to get solution.

protected Function pasteFromExcelFunction =new Function(){
    public void execute(){
     if(readOnly){
     return;
     }// its false
    try{
         if(pasteFromExcelHelper.pasteDataIntoGrid(BaseEditorGridPanel.this, getRecordDef()));
           doAfterPaste();
   }
    }
  }
    public boolean pasteDataIntoGrid(BaseEditorGridPanel grid, BaseGridRecordDef recordDef)
    {
      boolean pasteSuccessful=true;
      String pastedText= readFromClipboard();
     }
     private String readFromClipboard (){
    return JavaScriptUtils.getClipboardData();
   }

public static native String getClipboardData()/*-{
    if($wnd.clipboardData && clipboardData.setData){
    return $wnd.clipboardData.getData('Text');
}-*/;


问:
How can I solve this problem which looks like it's lagged?
I'm trying to make a dodge ball game, so I made a value called status and made "play" and "controller explanation" screen depending on the number of status. But whenever I run it the events
in the play section is so slow as if it the clock.ticK() was set to 1 or it was lagged.

The whole code:

import pygame
import random
import math
import time

#1.초기화
pygame.init()

#2.기본 설정
#2-1 색상
BLACK=(0,0,0)
WHITE=(255,255,255)
size=[700,1000]

#2-2 화면 크기
screen = pygame.display.set_mode(size)

#2-3 게임 이름
pygame.display.set_caption("1946")

#2-4 시계 생성
clock=pygame.time.Clock()

#2-5 이미지 불러오기
status = 0
background_image = pygame.image.load("C:/Temp/a.png")
background_image = pygame.transform.scale(background_image,(700,1000))
player = pygame.image.load("C:/Temp/b.png")
player = pygame.transform.scale(player, (50,50))
enemy = pygame.image.load("C:/Temp/c.png")
enemy = pygame.transform.scale(enemy, (50,50))
enemy1 = pygame.image.load("C:/Temp/c.png")
enemy1= pygame.transform.scale(enemy,(50,50))
level_count = 1
size_player_width = player.get_rect()[0]
size_player_height = player.get_rect()[1]
mod = 0

#2-6 오브젝트 좌표
x_pos = -300
y_pos = -300
to_x=0
to_y=0
player_speed_x = 5
player_speed_y = 5
wx = 2000
wy = 2000
bx1=100
by1=100
by2=100
by3=100

#2-6(1) 적 속도
enemy_speed_x = 4
enemy_speed_y = 4
enemy1_speed_x = 4
enemy1_speed_y = 4

#2-6(2) 변수 랜덤 값
enemy_x = -300
enemy_y = -300
enemey1_x = -300
enemy1_y = -300
e=0
f=0

#2-6(3) 적 좌표(랜덤)

#2-8 글상자
font1 = pygame.font.SysFont("airal",100,True,True)
font2 = pygame.font.SysFont("airal",50,True,True)
font3 = pygame.font.SysFont("airal",100, True, True)
text1 = font1.render("Game",True, 0)
text2 = font2.render("start",True, 0)
text3 = font2.render("control",True, 0)
text4 = font2.render("setting",True, 0)
text5 = font2.render("w = up", True, 0)
text6 = font2.render("a = left", True, 0)
text7 = font2.render("s = right", True, 0)
text8 = font2.render("d = down", True, 0)
text9 = font2.render("ctrl = speed up", True, 0)
text10 = font2.render("exit", True, 0)
text11 = font3.render("Warning!!", True,255)

#3 주요 내용
play = True
while play:
    #3-1 fps
    clock.tick(60)

    #3-2 이벤트
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            play = False

        if status ==0:
            bx1=500
            by1=400
            by2=600
            by3=800
            if event.type == pygame.MOUSEBUTTONDOWN:
                e = event.pos[0]
                f = event.pos[1]
            if 400 < e < 500:
                if 400<f<600:
                    status = 1
                if 600<f<800:
                    status = 2
                if 800<f<1000:
                    status = 3
                player_speed_x = 0
                player_speed_y = 0
                enemy_speed_x = 0
                enemy_speed_y = 0
                enemy1_speed_x = 0
                enemy1_speed_y = 0

        if status == 1:
            time.sleep(1)

            player_speed_x = 5
            player_speed_y = 5
            enemy_speed_x = 4
            enemy_speed_y = 4
            enemy1_speed_x = 4
            enemy1_speed_y = 4
            x_pos = screen.get_size()[0]//2
            y_pos = screen.get_size()[1]//2
            enemy_x=random.randint(0,250)
            enemy_y=random.randint(0,400)
            enemy1_x=random.randint(100,300)+random.randint(100,300)
            enemy1_y=random.randint(200,500)+random.randint(200,500)

            bx1=-300
            by1=-300
            by2=-300
            by3=-300

            #플레이어 이동
            if level_count <=30:
                if event.type == pygame.KEYDOWN:
                    if event.key == 1073742048:
                        mod = 1
                    if event.key == 119:
                        to_y=-player_speed_y
                    elif event.key == 115:
                        to_y=player_speed_y
                    elif event.key == 97:
                        to_x=-player_speed_y
                    elif event.key == 100:
                        to_x=player_speed_x
                    elif event.key == 32:
                        player_speed_x = 10
                        player_speed_y = 10
                if event.type == pygame.KEYUP:
                    if event.key == 119:
                        to_y=0.1
                    elif event.key == 115:
                        to_y=0.1
                    elif event.key == 97:
                        to_x=0.1
                    elif event.key == 100:
                        to_x=0.1
                    elif event.key == 32:
                        player_speed_x = 5
                        player_speed_y = 5

            #경고문
            if level_count == 25:
                wx=500
                wy=500

            #이동키 좌우반전
            if level_count > 30:
                if level_count >= 35:
                    wx=2000
                    wy=2000
                if event.type == pygame.KEYDOWN:
                    if event.key == 119:
                        to_y=player_speed_y
                    elif event.key == 115:
                        to_y=-player_speed_y
                    elif event.key == 97:
                        to_x=player_speed_y
                    elif event.key == 100:
                        to_x=-player_speed_x
                    elif event.key == 32:
                        player_speed_x = -10
                        player_speed_y = -10
                if event.type == pygame.KEYUP:
                    if event.key == 119:
                        to_y=0.1
                    elif event.key == 115:
                        to_y=0.1
                    elif event.key == 97:
                        to_x=0.1
                    elif event.key == 100:
                        to_x=0.1
            x_pos += to_x
            y_pos += to_y

            if enemy_x<=0:
                enemy_x=0
                enemy_speed_x = -enemy_speed_x
                level_count += 1

            elif enemy_x>=690:
                enemy_x=690
                enemy_speed_x = -enemy_speed_x
                level_count += 1

            if enemy_y<=30:
                enemy_y=30
                enemy_speed_y = -enemy_speed_y
                level_count += 1

            if enemy_y>=870:
                enemy_y=870
                enemy_speed_y = -enemy_speed_y
                level_count += 1

            if enemy1_x<=0:
                enemy1_x=0
                enemy1_speed_x = -enemy1_speed_x
                level_count += 1

            elif enemy1_x>=690:
                enemy1_x=690
                enemy1_speed_x = -enemy1_speed_x
                level_count += 1

            if enemy1_y<=30:
                enemy1_y=30
                enemy1_speed_y = -enemy1_speed_y
                level_count += 1

            if enemy1_y>=870:
                enemy1_y=870
                enemy1_speed_y = -enemy1_speed_y
                level_count += 1

            #적 속도 누적
            enemy_x += enemy_speed_x
            enemy_y += enemy_speed_y
            enemy1_x += enemy1_speed_x
            enemy1_y += enemy1_speed_y

            #레벨 기록, 추가
            if level_count >0:
                if level_count<=40:
                    if level_count%3==0:
                        level_count += 1

                        if enemy_speed_x >= 0:
                            if enemy_speed_y >= 0:
                                enemy_speed_x += 0.5
                                enemy_speed_y += 0.5

                            elif enemy_speed_y < 0:
                                enemy_speed_x += 1
                                enemy_speed_y -= 1

                        elif enemy_speed_x < 0:
                            if enemy_speed_y >= 0:
                                enemy_speed_x -= 0.5
                                enemy_speed_y -= 0.5

                            elif enemy_speed_y < 0:
                                enemy_speed_x -= 0.5
                                enemy_speed_y -= 0.5

                        if enemy1_speed_x >= 0:
                            if enemy1_speed_y >= 0:
                                enemy1_speed_x += 0.5
                                enemy1_speed_y += 0.5

                            elif enemy1_speed_y < 0:
                                enemy1_speed_x += 0.5
                                enemy1_speed_y -= 0.5

                        elif enemy1_speed_x < 0:
                            if enemy1_speed_y >= 0:
                                enemy1_speed_x -= 0.5
                                enemy1_speed_y -= 0.5

                            elif enemy1_speed_y < 0:
                                enemy1_speed_x -= 0.5
                                enemy1_speed_y -= 0.5

            if 27<level_count<30:
                screen.blit(text11, (400,500))

            if x_pos <= 0:
                x_pos = 0
            if x_pos >= 650:
                x_pos = 650
            if y_pos <= 50:
                y_pos = 50
            if y_pos >= 850:
                y_pos = 850

            point = level_count*50
            mx_pos = x_pos + 25
            my_pos = y_pos + 25
            mex_pos = enemy_x + 60
            mey_pos = enemy_y + 150
            mex1_pos = enemy1_x + 60
            mey1_pos = enemy1_y + 150

            if -20 < mx_pos-mex_pos < 20:
                if -20 < my_pos-mey_pos < 20:
                    pause = 1
                    print(point)
                    time.sleep(1)
                    play = False

            if -20 < mx_pos-mex1_pos < 20:
                if -20 < my_pos-mey1_pos < 20:
                    pause = 1
                    print(point)
                    time.sleep(1)
                    play = False

        if status == 2:
            if event.type == pygame.MOUSEBUTTONDOWN:
                e = event.pos[0]
                f = event.pos[1]

            if 500 < e < 600:
                if 800<f<900:
                    status = 0

    #3-3 화면
    screen.blit(background_image, (0, 0))

    if status == 1:
        screen.blit(player, (x_pos, y_pos))
        screen.blit(enemy, (enemy_x, enemy_y))
        screen.blit(enemy1, (enemy1_x,enemy1_y))

    if status == 0:
        screen.blit(text1, (200, 100))
        screen.blit(text2, (400,400))
        screen.blit(text3, (400,600))
        screen.blit(text4, (400,800))

    if status == 2:
        screen.blit(text5, (250,200))
        screen.blit(text6, (250,300))
        screen.blit(text7, (250,400))
        screen.blit(text8, (250,500))
        screen.blit(text9, (250,600))
        screen.blit(text10, (500,800))

    #3-4 업데이트
    pygame.display.flip()
pygame.quit()
```

I tried putting functions in each section and changed the time for the play section but it wouldn't work.

Body:
I'm trying to make a dodge ball game, so I made a value called status and made "play" and "controller explanation" screen depending on the number of status. But whenever I run it the events
in the play section is so slow as if it the clock.ticK() was set to 1 or it was lagged.

The whole code:

import pygame
import random
import math
import time

#1.초기화
pygame.init()

#2.기본 설정
#2-1 색상
BLACK=(0,0,0)
WHITE=(255,255,255)
size=[700,1000]

#2-2 화면 크기
screen = pygame.display.set_mode(size)

#2-3 게임 이름
pygame.display.set_caption("1946")

#2-4 시계 생성
clock=pygame.time.Clock()

#2-5 이미지 불러오기
status = 0
background_image = pygame.image.load("C:/Temp/a.png")
background_image = pygame.transform.scale(background_image,(700,1000))
player = pygame.image.load("C:/Temp/b.png")
player = pygame.transform.scale(player, (50,50))
enemy = pygame.image.load("C:/Temp/c.png")
enemy = pygame.transform.scale(enemy, (50,50))
enemy1 = pygame.image.load("C:/Temp/c.png")
enemy1= pygame.transform.scale(enemy,(50,50))
level_count = 1
size_player_width = player.get_rect()[0]
size_player_height = player.get_rect()[1]
mod = 0

#2-6 오브젝트 좌표
x_pos = -300
y_pos = -300
to_x=0
to_y=0
player_speed_x = 5
player_speed_y = 5
wx = 2000
wy = 2000
bx1=100
by1=100
by2=100
by3=100

#2-6(1) 적 속도
enemy_speed_x = 4
enemy_speed_y = 4
enemy1_speed_x = 4
enemy1_speed_y = 4

#2-6(2) 변수 랜덤 값
enemy_x = -300
enemy_y = -300
enemey1_x = -300
enemy1_y = -300
e=0
f=0

#2-6(3) 적 좌표(랜덤)

#2-8 글상자
font1 = pygame.font.SysFont("airal",100,True,True)
font2 = pygame.font.SysFont("airal",50,True,True)
font3 = pygame.font.SysFont("airal",100, True, True)
text1 = font1.render("Game",True, 0)
text2 = font2.render("start",True, 0)
text3 = font2.render("control",True, 0)
text4 = font2.render("setting",True, 0)
text5 = font2.render("w = up", True, 0)
text6 = font2.render("a = left", True, 0)
text7 = font2.render("s = right", True, 0)
text8 = font2.render("d = down", True, 0)
text9 = font2.render("ctrl = speed up", True, 0)
text10 = font2.render("exit", True, 0)
text11 = font3.render("Warning!!", True,255)

#3 주요 내용
play = True
while play:
    #3-1 fps
    clock.tick(60)

    #3-2 이벤트
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            play = False

        if status ==0:
            bx1=500
            by1=400
            by2=600
            by3=800
            if event.type == pygame.MOUSEBUTTONDOWN:
                e = event.pos[0]
                f = event.pos[1]
            if 400 < e < 500:
                if 400<f<600:
                    status = 1
                if 600<f<800:
                    status = 2
                if 800<f<1000:
                    status = 3
                player_speed_x = 0
                player_speed_y = 0
                enemy_speed_x = 0
                enemy_speed_y = 0
                enemy1_speed_x = 0
                enemy1_speed_y = 0

        if status == 1:
            time.sleep(1)

            player_speed_x = 5
            player_speed_y = 5
            enemy_speed_x = 4
            enemy_speed_y = 4
            enemy1_speed_x = 4
            enemy1_speed_y = 4
            x_pos = screen.get_size()[0]//2
            y_pos = screen.get_size()[1]//2
            enemy_x=random.randint(0,250)
            enemy_y=random.randint(0,400)
            enemy1_x=random.randint(100,300)+random.randint(100,300)
            enemy1_y=random.randint(200,500)+random.randint(200,500)

            bx1=-300
            by1=-300
            by2=-300
            by3=-300

            #플레이어 이동
            if level_count <=30:
                if event.type == pygame.KEYDOWN:
                    if event.key == 1073742048:
                        mod = 1
                    if event.key == 119:
                        to_y=-player_speed_y
                    elif event.key == 115:
                        to_y=player_speed_y
                    elif event.key == 97:
                        to_x=-player_speed_y
                    elif event.key == 100:
                        to_x=player_speed_x
                    elif event.key == 32:
                        player_speed_x = 10
                        player_speed_y = 10
                if event.type == pygame.KEYUP:
                    if event.key == 119:
                        to_y=0.1
                    elif event.key == 115:
                        to_y=0.1
                    elif event.key == 97:
                        to_x=0.1
                    elif event.key == 100:
                        to_x=0.1
                    elif event.key == 32:
                        player_speed_x = 5
                        player_speed_y = 5

            #경고문
            if level_count == 25:
                wx=500
                wy=500

            #이동키 좌우반전
            if level_count > 30:
                if level_count >= 35:
                    wx=2000
                    wy=2000
                if event.type == pygame.KEYDOWN:
                    if event.key == 119:
                        to_y=player_speed_y
                    elif event.key == 115:
                        to_y=-player_speed_y
                    elif event.key == 97:
                        to_x=player_speed_y
                    elif event.key == 100:
                        to_x=-player_speed_x
                    elif event.key == 32:
                        player_speed_x = -10
                        player_speed_y = -10
                if event.type == pygame.KEYUP:
                    if event.key == 119:
                        to_y=0.1
                    elif event.key == 115:
                        to_y=0.1
                    elif event.key == 97:
                        to_x=0.1
                    elif event.key == 100:
                        to_x=0.1
            x_pos += to_x
            y_pos += to_y

            if enemy_x<=0:
                enemy_x=0
                enemy_speed_x = -enemy_speed_x
                level_count += 1

            elif enemy_x>=690:
                enemy_x=690
                enemy_speed_x = -enemy_speed_x
                level_count += 1

            if enemy_y<=30:
                enemy_y=30
                enemy_speed_y = -enemy_speed_y
                level_count += 1

            if enemy_y>=870:
                enemy_y=870
                enemy_speed_y = -enemy_speed_y
                level_count += 1

            if enemy1_x<=0:
                enemy1_x=0
                enemy1_speed_x = -enemy1_speed_x
                level_count += 1

            elif enemy1_x>=690:
                enemy1_x=690
                enemy1_speed_x = -enemy1_speed_x
                level_count += 1

            if enemy1_y<=30:
                enemy1_y=30
                enemy1_speed_y = -enemy1_speed_y
                level_count += 1

            if enemy1_y>=870:
                enemy1_y=870
                enemy1_speed_y = -enemy1_speed_y
                level_count += 1

            #적 속도 누적
            enemy_x += enemy_speed_x
            enemy_y += enemy_speed_y
            enemy1_x += enemy1_speed_x
            enemy1_y += enemy1_speed_y

            #레벨 기록, 추가
            if level_count >0:
                if level_count<=40:
                    if level_count%3==0:
                        level_count += 1

                        if enemy_speed_x >= 0:
                            if enemy_speed_y >= 0:
                                enemy_speed_x += 0.5
                                enemy_speed_y += 0.5

                            elif enemy_speed_y < 0:
                                enemy_speed_x += 1
                                enemy_speed_y -= 1

                        elif enemy_speed_x < 0:
                            if enemy_speed_y >= 0:
                                enemy_speed_x -= 0.5
                                enemy_speed_y -= 0.5

                            elif enemy_speed_y < 0:
                                enemy_speed_x -= 0.5
                                enemy_speed_y -= 0.5

                        if enemy1_speed_x >= 0:
                            if enemy1_speed_y >= 0:
                                enemy1_speed_x += 0.5
                                enemy1_speed_y += 0.5

                            elif enemy1_speed_y < 0:
                                enemy1_speed_x += 0.5
                                enemy1_speed_y -= 0.5

                        elif enemy1_speed_x < 0:
                            if enemy1_speed_y >= 0:
                                enemy1_speed_x -= 0.5
                                enemy1_speed_y -= 0.5

                            elif enemy1_speed_y < 0:
                                enemy1_speed_x -= 0.5
                                enemy1_speed_y -= 0.5

            if 27<level_count<30:
                screen.blit(text11, (400,500))

            if x_pos <= 0:
                x_pos = 0
            if x_pos >= 650:
                x_pos = 650
            if y_pos <= 50:
                y_pos = 50
            if y_pos >= 850:
                y_pos = 850

            point = level_count*50
            mx_pos = x_pos + 25
            my_pos = y_pos + 25
            mex_pos = enemy_x + 60
            mey_pos = enemy_y + 150
            mex1_pos = enemy1_x + 60
            mey1_pos = enemy1_y + 150

            if -20 < mx_pos-mex_pos < 20:
                if -20 < my_pos-mey_pos < 20:
                    pause = 1
                    print(point)
                    time.sleep(1)
                    play = False

            if -20 < mx_pos-mex1_pos < 20:
                if -20 < my_pos-mey1_pos < 20:
                    pause = 1
                    print(point)
                    time.sleep(1)
                    play = False

        if status == 2:
            if event.type == pygame.MOUSEBUTTONDOWN:
                e = event.pos[0]
                f = event.pos[1]

            if 500 < e < 600:
                if 800<f<900:
                    status = 0

    #3-3 화면
    screen.blit(background_image, (0, 0))

    if status == 1:
        screen.blit(player, (x_pos, y_pos))
        screen.blit(enemy, (enemy_x, enemy_y))
        screen.blit(enemy1, (enemy1_x,enemy1_y))

    if status == 0:
        screen.blit(text1, (200, 100))
        screen.blit(text2, (400,400))
        screen.blit(text3, (400,600))
        screen.blit(text4, (400,800))

    if status == 2:
        screen.blit(text5, (250,200))
        screen.blit(text6, (250,300))
        screen.blit(text7, (250,400))
        screen.blit(text8, (250,500))
        screen.blit(text9, (250,600))
        screen.blit(text10, (500,800))

    #3-4 업데이트
    pygame.display.flip()
pygame.quit()

I tried putting functions in each section and changed the time for the play section but it wouldn't work.


问:
How can converting an export CSV file to WordPress wp_filesystem
How I can convert an export CSV file to WordPress wp_filesystem function ??

This Is My PHP Code:

$fh = fopen( 'php://output', 'w' );
fprintf( $fh, chr( 0xEF ) . chr( 0xBB ) . chr( 0xBF ) );
header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' );
header( 'Content-Description: File Transfer' );
header( 'Content-type: text/csv' );
header( "Content-Disposition: attachment; filename={$filename}" );
header( 'Expires: 0' );
header( 'Pragma: public' );
fputcsv( $fh, $header_row );

foreach ( $data_rows as $data_row ) {
    fputcsv( $fh, $data_row );
}

fclose( $fh );

ob_end_flush();

die();
```


问:
Using Mutagen ID3 Tags to Update Cover Art in Spotify's Local Files
I was building my first project that edited the metadata of an mp3 file so that the upload process to Spotify's local files can be a lot easier.

Using the mutagen python library, my program edits the TIT2 (song name), TPE1 (artist name), and APIC (cover art) of an mp3 file. Thus far, the updates in the song name and artist name translate to the local files on Spotify but the cover art remains blank.

One way to solve this is to manually add artwork through apple music but I am trying to automate as much as possible while having as little interference as possible.

Is there any way I can get the cover art to load on my local files on Spotify through python? I.e - any libraries that might work?

EDIT: Fixed through using eyed3 instead of mutagen.


问:
Unable To Get Frame Count Using ffmpeg To Stich To Beginning
I am using Python to make a script with ffmpeg where the script exports the middle frame into a jpg file and then stitches it back into beginning of the video. This is my script

```<code>video_filename = "test_video.webm"
import ffmpeg

# Open the input video file
input_video = ffmpeg.input(video_filename)

# Get the video stream from the input video
video_stream = next(s for s in input_video.streams if s.type == 'video')

# Get the total number of frames in the stream
num_frames = video_stream.frame_count

# Calculate the middle frame number
middle_frame = num_frames // 2

# Extract the middle frame from the input video
middle_frame_extract = input_video.trim(start_frame=middle_frame, end_frame=middle_frame+1).setpts('PTS-STARTPTS')

# Save the extracted frame to an image file
ffmpeg.output(middle_frame_extract, 'middle_frame.jpg').run()

# Open the image file
middle_frame_image = ffmpeg.input('middle_frame.jpg')

# Concatenate the image file with the rest of the video
output_video = ffmpeg.concat(middle_frame_image, input_video, v=1, a=0).setpts('PTS+STARTPTS')

# Save the output video to a file
ffmpeg.output(output_video, 'output.mp4').run()
</code>```

I get this error though

```<code>AttributeError                            Traceback (most recent call last)

<ipython-input-8-7bfc1bdca9c8> in <module>
      6
      7 # Get the video stream from the input video
----> 8 video_stream = next(s for s in input_video.streams if s.type == 'video')
      9
     10 # Get the total number of frames in the stream

AttributeError: 'FilterableStream' object has no attribute 'streams'

</code>```

The issue is that there is little documentation to do this and I only found this snippet of code online. How do I modify it to make it work for my use case?

Body:
I am using Python to make a script with ffmpeg where the script exports the middle frame into a jpg file and then stitches it back into beginning of the video. This is my script

video_filename = "test_video.webm"
import ffmpeg

# Open the input video file
input_video = ffmpeg.input(video_filename)

# Get the video stream from the input video
video_stream = next(s for s in input_video.streams if s.type == 'video')

# Get the total number of frames in the stream
num_frames = video_stream.frame_count

# Calculate the middle frame number
middle_frame = num_frames // 2

# Extract the middle frame from the input video
middle_frame_extract = input_video.trim(start_frame=middle_frame, end_frame=middle_frame+1).setpts('PTS-STARTPTS')

# Save the extracted frame to an image file
ffmpeg.output(middle_frame_extract, 'middle_frame.jpg').run()

# Open the image file
middle_frame_image = ffmpeg.input('middle_frame.jpg')

# Concatenate the image file with the rest of the video
output_video = ffmpeg.concat(middle_frame_image, input_video, v=1, a=0).setpts('PTS+STARTPTS')

# Save the output video to a file
ffmpeg.output(output_video, 'output.mp4').run()

I get this error though

AttributeError                            Traceback (most recent call last)

<ipython-input-8-7bfc1bdca9c8> in <module>
      6
      7 # Get the video stream from the input video
----> 8 video_stream = next(s for s in input_video.streams if s.type == 'video')
      9
     10 # Get the total number of frames in the stream

AttributeError: 'FilterableStream' object has no attribute 'streams'

The issue is that there is little documentation to do this and I only found this snippet of code online. How do I modify it to make it work for my use case?


问:
Xcode 14.2 - Annoying source control shadow changes
Hi All not sure if anyone is having this but when making changes it adds the blue box on the left-hand side which is fine as before this was just showing what had changed. Now though, it's added this discard change and gives you a kind of before and after within your code. It's really really annoying and difficult to make changes. I've added a screenshot here where I was just removing so spacing. The code doesn't appear to do anything until you commit. Turning off Source Control completely doesn't even get rid of it.

Does anyone have any solutions for just turning this silly feature off completely? I've always used git fine with no issues within Xcode,  I don't need to see the old change just what I'm actually updating the code to be.


问:
Cannot run npm run build due to error ".next/status/media/IMG" does not exist
I'm trying to deploy a static react website (nextjs) and I cannot due to the npm run build command not being able to run. I have an image in my public folder and it's saying it doesn't exist. I've never done this before and don't understand the error I'm getting. The github repository is https://github.com/mattmoon00/portfolio-website . I have tried using vercel and netlify and they both gave me the same error. I also cannot run "npm run build" in the terminal on my machine either. Thanks in advance.</p>


问:
Machine Learning - Designing Domain Suggestion Application
I am creating a machine learning tool in Python Keras to suggest domain name from random alphabets.

The idea is that if I input the network ['o','g','g','l','e'], it should suggest me 'google'.

The data set available is worlds top domains. I have almost 500,000 of them.

The design is like this. Input is None, 50, 26. Up to 50 alphabets as input. Each alphabet one hot encoded to have 26 size list.

Middle layer I have tried both LSTM / Dense layer with None, 50, 200 and other configurations.

Output is None, 50, 26. Output is hot encoded values of rearranged alphabets.

The accuracy never goes above 0.1 I tried various configurations. Even multi layered ones. I am new to machine learning. What am I doing wrong?

Code that I've tried:

```<code>X_train, X_test, y_train, y_test = train_test_split(
    inputArray, outputArray, test_size=0.2, random_state=0
)

def lstm_model(num_alphabets=27, name_length=50, embedding_dim=128):
    model = Sequential()
    layer_1 = Dense((26), activation="relu")
    model.add(layer_1)
    layer_2 = Dense(units=200, activation="relu")
    model.add(layer_2)
    outputLayer = Dense(units=26, activation="sigmoid")
    model.add(outputLayer)

    model.compile(
        loss="categorical_crossentropy",
        optimizer=Adam(learning_rate=0.001),
        metrics=["accuracy"],
    )
    input_shape = (None, 50, 26)
    model.build(input_shape)

    return model
</code>```

Training output

My idea is that I will generate random alphabets and feed it into this neural network to get meaningful words that sound like Google, Facebook etc.

Body:
I am creating a machine learning tool in Python Keras to suggest domain name from random alphabets.

The idea is that if I input the network ['o','g','g','l','e'], it should suggest me 'google'.

The data set available is worlds top domains. I have almost 500,000 of them.

The design is like this. Input is None, 50, 26. Up to 50 alphabets as input. Each alphabet one hot encoded to have 26 size list.

Middle layer I have tried both LSTM / Dense layer with None, 50, 200 and other configurations.

Output is None, 50, 26. Output is hot encoded values of rearranged alphabets.

The accuracy never goes above 0.1 I tried various configurations. Even multi layered ones. I am new to machine learning. What am I doing wrong?

Code that I've tried:

X_train, X_test, y_train, y_test = train_test_split(
    inputArray, outputArray, test_size=0.2, random_state=0
)

def lstm_model(num_alphabets=27, name_length=50, embedding_dim=128):
    model = Sequential()
    layer_1 = Dense((26), activation="relu")
    model.add(layer_1)
    layer_2 = Dense(units=200, activation="relu")
    model.add(layer_2)
    outputLayer = Dense(units=26, activation="sigmoid")
    model.add(outputLayer)

    model.compile(
        loss="categorical_crossentropy",
        optimizer=Adam(learning_rate=0.001),
        metrics=["accuracy"],
    )
    input_shape = (None, 50, 26)
    model.build(input_shape)

    return model

Training output

My idea is that I will generate random alphabets and feed it into this neural network to get meaningful words that sound like Google, Facebook etc.


问:
HelloSign PHP SDK - Class "HelloSignSDK\Configuration" not found
I tried with the below code to get the Account details, it's working fine.

```<code>require_once __DIR__ . "/vendor/autoload.php";
$apikey = "<API KEY FROM HELLOSIGN>";
$client = new HelloSign\Client($apikey);
$account = $client->getAccount();
</code>```

But when I try with the below code to get an Account using SDK, reference link: https://developers.hellosign.com/api/reference/operation/accountGet/:

```<code>require_once __DIR__ . "/vendor/autoload.php";
$config = HelloSignSDK\Configuration::getDefaultConfiguration();
// Configure HTTP basic authorization: api_key
$config->setUsername("YOUR_API_KEY");
// or, configure Bearer (JWT) authorization: oauth2
// $config->setAccessToken("YOUR_ACCESS_TOKEN");
$api = new HelloSignSDK\Api\AccountApi($config);
try {
    $result = $api->accountGet(null, 'jack@example.com');
    print_r($result);
} catch (HelloSignSDK\ApiException $e) {
    $error = $e->getResponseObject();
    echo "Exception when calling HelloSign API: "
        . print_r($error->getError());
}
</code>```

It throws an error: Fatal error: Uncaught Error: Class "HelloSignSDK\Configuration" not found

Added autoload, why is this issue if using SDK? Kindly help!

Body:
I tried with the below code to get the Account details, it's working fine.

require_once __DIR__ . "/vendor/autoload.php";
$apikey = "<API KEY FROM HELLOSIGN>";
$client = new HelloSign\Client($apikey);
$account = $client->getAccount();

But when I try with the below code to get an Account using SDK, reference link: https://developers.hellosign.com/api/reference/operation/accountGet/:

require_once __DIR__ . "/vendor/autoload.php";
$config = HelloSignSDK\Configuration::getDefaultConfiguration();
// Configure HTTP basic authorization: api_key
$config->setUsername("YOUR_API_KEY");
// or, configure Bearer (JWT) authorization: oauth2
// $config->setAccessToken("YOUR_ACCESS_TOKEN");
$api = new HelloSignSDK\Api\AccountApi($config);
try {
    $result = $api->accountGet(null, 'jack@example.com');
    print_r($result);
} catch (HelloSignSDK\ApiException $e) {
    $error = $e->getResponseObject();
    echo "Exception when calling HelloSign API: "
        . print_r($error->getError());
}

It throws an error: Fatal error: Uncaught Error: Class "HelloSignSDK\Configuration" not found

Added autoload, why is this issue if using SDK? Kindly help!


问:
How to use GCC extension to tell if overloaded method is overridden
It is explained here that gcc gives an extension thats takes a pointer to object and a pointer to virtual method and resolves the dynamic dispatch giving a free function pointer. It is unclear to me how to best do this when the virtual function is overloaded. I have some example code below.

coliru

```<code>#include <memory>
#include<iostream>
using namespace std;

struct B{
    virtual void f(){cout<<"b\n";}
    virtual void f() const {}//this makes things more interesting, can no longer use (F)&B::f, would need extra cast (F)(PTM)&B::f
    bool overridesf(){
        constexpr void (B::*ptm)()=&B::f;
        using PTM = decltype(ptm);
        using F = void (*)(B*);
        auto thisF = (F)(this->*ptm);
        auto notBaseF = (F)(PTM)&B::f;
        auto baseF = (F)(B().*ptm);//can simply use (F)&B::f when no overload is present
        B b;
        //below, all print b when `this` is a B
        thisF(this);//c when `this` is a C
        thisF(&b);//c when `this` is a C
        baseF(this);//b when `this` is a C
        baseF(&b);//b when `this` is a C
        notBaseF(this);//c when `this` is a C
        notBaseF(&b);//c when `this` is a C
        //return thisF!=notBaseF; //wrong: is false when this is a c
        return thisF!=baseF; //works correctly: true when this is a c
    }
};
struct C:B{
    void f()override{cout<<"c\n";}
};

int main() {
    auto b=make_unique<B>();
    cout<<b->overridesf()<<endl;
    b=make_unique<C>();
    cout<<b->overridesf();
}
</code>```

I am interested in seeing if a object has overridden the first nonconst f, and I have created a function overridesf to do this. The idea is to do the dynamic dispatch on this to get a function pointer (thisF) and compare this function pointer to what we get if we do dynamic dispatch with an object that is known not to override f (baseF).

In fact, if f is not overloaded, then we can get the baseF function pointer simply with the expression (F)&B::f. However, if f is overloaded, this expression becomes ambiguous and we would have to do (F)(PTM)&B::f, where the PTM cast resolves the overload ambiguity. But (I think) the expression (F)(PTM)&B::f isn't a direct cast of a PMF constant (because of the intermediate cast), so the part about the direct conversion at the end of the linked page doesn't apply and you need an object (in my case B()).

I have two questions. First is there a better way to get baseF? If the interface has many pure virtual functions then it would be annoying to create a derived class which overrides all the pure virtuals (but of course not f) in order to construct an object to get baseF.

Another question is what is going on with notBaseF which is defined by the expression (F)(PTM)&B::f. Presumably this is undefined behavior, but is there an explanation for why the behavior of notBaseF(&b) is determined by the dynamic type of this?

Body:
It is explained here that gcc gives an extension thats takes a pointer to object and a pointer to virtual method and resolves the dynamic dispatch giving a free function pointer. It is unclear to me how to best do this when the virtual function is overloaded. I have some example code below.

coliru

#include <memory>
#include<iostream>
using namespace std;

struct B{
    virtual void f(){cout<<"b\n";}
    virtual void f() const {}//this makes things more interesting, can no longer use (F)&B::f, would need extra cast (F)(PTM)&B::f
    bool overridesf(){
        constexpr void (B::*ptm)()=&B::f;
        using PTM = decltype(ptm);
        using F = void (*)(B*);
        auto thisF = (F)(this->*ptm);
        auto notBaseF = (F)(PTM)&B::f;
        auto baseF = (F)(B().*ptm);//can simply use (F)&B::f when no overload is present
        B b;
        //below, all print b when `this` is a B
        thisF(this);//c when `this` is a C
        thisF(&b);//c when `this` is a C
        baseF(this);//b when `this` is a C
        baseF(&b);//b when `this` is a C
        notBaseF(this);//c when `this` is a C
        notBaseF(&b);//c when `this` is a C
        //return thisF!=notBaseF; //wrong: is false when this is a c
        return thisF!=baseF; //works correctly: true when this is a c
    }
};
struct C:B{
    void f()override{cout<<"c\n";}
};

int main() {
    auto b=make_unique();
    cout<overridesf()<<endl;
    b=make_unique<C>();
    cout<overridesf();
}

I am interested in seeing if a object has overridden the first nonconst f, and I have created a function overridesf to do this. The idea is to do the dynamic dispatch on this to get a function pointer (thisF) and compare this function pointer to what we get if we do dynamic dispatch with an object that is known not to override f (baseF).

In fact, if f is not overloaded, then we can get the baseF function pointer simply with the expression (F)&B::f. However, if f is overloaded, this expression becomes ambiguous and we would have to do (F)(PTM)&B::f, where the PTM cast resolves the overload ambiguity. But (I think) the expression (F)(PTM)&B::f isn't a direct cast of a PMF constant (because of the intermediate cast), so the part about the direct conversion at the end of the linked page doesn't apply and you need an object (in my case B()).

I have two questions. First is there a better way to get baseF? If the interface has many pure virtual functions then it would be annoying to create a derived class which overrides all the pure virtuals (but of course not f) in order to construct an object to get baseF.

Another question is what is going on with notBaseF which is defined by the expression (F)(PTM)&B::f. Presumably this is undefined behavior, but is there an explanation for why the behavior of notBaseF(&b) is determined by the dynamic type of this?


问:
How to capture all submitted data on my website form n download the data neatly placed in a pdf template by click of a button?
We are on Odoo 15. So on the website i need a way users can (after clicking submit) click on a button and download the information the just submitted on a template with more fields. See we are trying to offer needy kids scholarships and we need a way they can download a pdf with the same information they submit on the website plus extra fields e.g

header with two columns, one for our logo and location info other for QR image

footer with two columns again. One for a local authority figure from their area to sign and affirm the individual's identity, the ohter column for the same local authority figure to stamp so we are sure it's the legitimate officer.
I have the Forms module by Nova Code installed and am trying to figure out how to do this?
How is this module integrated with odoo? // how do i capture posted data? // How do i print out this posted data // How do i prepare this template that users will be downloading?

I tried having two buttons, one hidden the other with some JS code logic to download a file first from a URL (

```<code><a href="./abcf32x.pdf" download="How-to-download-file.pdf">
    <button>Download File</button>
</a>
</code>```

) and simultaneously trigger the click of our initial (now hidden button) and submit our form. The download part worked it downloaded a file i pointed to with url but the form never submitted (Plus what i need is a way to print out data that user posted...not just a pdf file that they have to fill out all over again)

Am not sure what am missing? Or doing Wrong?

Thanks guys ur all my Heros :)

Body:
We are on Odoo 15. So on the website i need a way users can (after clicking submit) click on a button and download the information the just submitted on a template with more fields. See we are trying to offer needy kids scholarships and we need a way they can download a pdf with the same information they submit on the website plus extra fields e.g

header with two columns, one for our logo and location info other for QR image

footer with two columns again. One for a local authority figure from their area to sign and affirm the individual's identity, the ohter column for the same local authority figure to stamp so we are sure it's the legitimate officer.
I have the Forms module by Nova Code installed and am trying to figure out how to do this?
How is this module integrated with odoo? // how do i capture posted data? // How do i print out this posted data // How do i prepare this template that users will be downloading?

I tried having two buttons, one hidden the other with some JS code logic to download a file first from a URL (

    <button>Download File</button>

) and simultaneously trigger the click of our initial (now hidden button) and submit our form. The download part worked it downloaded a file i pointed to with url but the form never submitted (Plus what i need is a way to print out data that user posted...not just a pdf file that they have to fill out all over again)

Am not sure what am missing? Or doing Wrong?

Thanks guys ur all my Heros :)


问:
Format money number_format PHP
C:\xampp\htdocs\ksucatalog\application\helpers\nokencode_helper.php
Line: 118
Function: number_format

Message: number_format(): Passing null to parameter #1 ($num) of type float is deprecated

code:

```<code>if (!function_exists('money')) {
    function money($str)
    {
        return number_format($str, 2, '.', ',');
    }
}
</code>```

Title: Format money number_format PHP

Body:
C:\xampp\htdocs\ksucatalog\application\helpers\nokencode_helper.php
Line: 118
Function: number_format

Message: number_format(): Passing null to parameter #1 ($num) of type float is deprecated

code:

if (!function_exists('money')) {
    function money($str)
    {
        return number_format($str, 2, '.', ',');
    }
}


问:
Bootstrap table option format
I am a beginner in web application. When I tried to use Bootstrap to modify the table, I do not understand why it will take around half second to change to the format I want.
When the page was loaded, the options look like:
(https://i.stack.imgur.com/lAiYh.png)
But after less than 1 second, it will change back to the look I want:
(https://i.stack.imgur.com/9MEnf.png)

May I know how can I improve this situation so that I can get the format I want directly?
Thanks in advance.

I tried to download the script files and css files required and loaded it locally, but the problem is still existed. I want to know how can I skip that 1 second waiting time.

```<code><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
</code>```

```<code><link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/css/bootstrap-multiselect.css"/>

<script>
        $(document).ready(function()
        {
             $('#multiple-checkboxes').multiselect({
          includeSelectAllOption: true,
        });

            var multipleCancelButton = new Choices('#class_duties', {
            removeItemButton: true,
            searchEnabled: true,
            searchChoices: true,
            searchFloor: 1,
            noResultsText: 'No results found',
            noChoicesText: 'No choices to choose from',
            itemSelectText: 'Press to select',
            selectAll: true,
            });

        });

    </script>

</head>
<body>

<div class="container">
    <div class="col-md-10">
        <link rel="stylesheet" href="https://res.cloudinary.com/dxfq3iotg/raw/upload/v1569006288/BBBootstrap/choices.min.css?version=7.0.0">
        <script src="https://res.cloudinary.com/dxfq3iotg/raw/upload/v1569006273/BBBootstrap/choices.min.js?version=7.0.0"></script>

     <select id="class_duties"  name="class_duties[]" placeholder="Select the Position" multiple>

                <option>Option A</option>
                <option>Option B</option>
        </select>
     </div>
    </div>

</body>
</html>
</code>```

Video:
https://streamable.com/5hju8q

Title: Bootstrap table option format

Body:
I am a beginner in web application. When I tried to use Bootstrap to modify the table, I do not understand why it will take around half second to change to the format I want.
When the page was loaded, the options look like:
(https://i.stack.imgur.com/lAiYh.png)
But after less than 1 second, it will change back to the look I want:
(https://i.stack.imgur.com/9MEnf.png)

May I know how can I improve this situation so that I can get the format I want directly?
Thanks in advance.

I tried to download the script files and css files required and loaded it locally, but the problem is still existed. I want to know how can I skip that 1 second waiting time.

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/css/bootstrap-multiselect.css"/>

        <link rel="stylesheet" href="https://res.cloudinary.com/dxfq3iotg/raw/upload/v1569006288/BBBootstrap/choices.min.css?version=7.0.0">

     <select id="class_duties"  name="class_duties[]" placeholder="Select the Position" multiple>

                <option>Option A</option>
                <option>Option B</option>
        </select>

Video:
https://streamable.com/5hju8q


问:
How to add flags in Github CLI
I'm trying to search the net and I've found this documentation regarding issues. But I don't know how to add flags in the command.

Can someone enlighten me about this?

This is the command that I'm trying to run.

This is the link of the parameters: Click me

I've tried adding them as - or -- to the end of the command to no avail.

Title: How to add flags in Github CLI


问:
how do i add timeout to the function which is continuously running
this is a part code of sample blockchain I made in nodejs

```<code>  calculateHash(difficulty) {
    const pow = require('proof-of-work');
    const solver = new pow.Solver();
    var nonce = solver.solve(difficulty);
    return "0x"+sha256(sha256(nonce)).toString();
  }
</code>```

I need to add some new feature "GRACE BLOCKS" that's i call

When the miners aren't able to calculate hash within 10 seconds a block hash with lower difficulty will be calculated.

I tried many combinations of code

one of them is

```<code>
  async calculateHash(difficulty, timeLimit) {
    const pow = require('proof-of-work');
    const solver = new pow.Solver();
    let nonce;

    const timeout = new Promise((_, reject) => setTimeout(() => reject(new Error("Timed out")), timeLimit));

    const solvePromise = new Promise((resolve, reject) => {
      const result = solver.solve(difficulty);
      if (result) {
        resolve(result);
      } else {
        reject(new Error("No solution found"));
      }
    });

    try {
      nonce = await Promise.race([solvePromise, timeout]);
      console.log(`Trying to solve hash with difficulty ${difficulty}: ${nonce}`);

      if (nonce) {
        console.log(`Solved hash with difficulty ${difficulty}`);
        return "0x" + sha256(sha256(nonce.toString()).toString()).toString();
      } else {
        // Reduce the difficulty and try again
        return this.calculateHash(difficulty / 2, timeLimit);
      }
    } catch (error) {
      console.log(error.message);
      return error.message;
    }
  }
</code>```

Body:
this is a part code of sample blockchain I made in nodejs

  calculateHash(difficulty) {
    const pow = require('proof-of-work');
    const solver = new pow.Solver();
    var nonce = solver.solve(difficulty);
    return "0x"+sha256(sha256(nonce)).toString();
  }

I need to add some new feature "GRACE BLOCKS" that's i call

When the miners aren't able to calculate hash within 10 seconds a block hash with lower difficulty will be calculated.

I tried many combinations of code

one of them is

  async calculateHash(difficulty, timeLimit) {
    const pow = require('proof-of-work');
    const solver = new pow.Solver();
    let nonce;

    const timeout = new Promise((_, reject) => setTimeout(() => reject(new Error("Timed out")), timeLimit));

    const solvePromise = new Promise((resolve, reject) => {
      const result = solver.solve(difficulty);
      if (result) {
        resolve(result);
      } else {
        reject(new Error("No solution found"));
      }
    });

    try {
      nonce = await Promise.race([solvePromise, timeout]);
      console.log(`Trying to solve hash with difficulty ${difficulty}: ${nonce}`);

      if (nonce) {
        console.log(`Solved hash with difficulty ${difficulty}`);
        return "0x" + sha256(sha256(nonce.toString()).toString()).toString();
      } else {
        // Reduce the difficulty and try again
        return this.calculateHash(difficulty / 2, timeLimit);
      }
    } catch (error) {
      console.log(error.message);
      return error.message;
    }
  }


问:
browscap.xml not working with msnbot and amazonaws bot
I have used browscap.xml file but its not working with below crawler.

```<code>   Ip address           Host name
1) 35.81.238.115    ec2-35-81-238-115.us-west-2.compute.amazonaws.com
2) 40.77.167.19     msnbot-40-77-167-19.search.msn.com
</code>```

Can you please help me? How to add this additional name into browscap.xml file.
https://browscap.org/#google_vignette

Body:
I have used browscap.xml file but its not working with below crawler.

   Ip address           Host name
1) 35.81.238.115    ec2-35-81-238-115.us-west-2.compute.amazonaws.com
2) 40.77.167.19     msnbot-40-77-167-19.search.msn.com

Can you please help me? How to add this additional name into browscap.xml file.
https://browscap.org/#google_vignette


问:
Set mitmdump proving multi domain
You need to set up map-remote on multiple phone URLs in autotest, but how do you do it via the command line?

launch example:

```<code>case ANDROID -> {
    String[] command = {"mitmdump",
            "--listen-port", String.valueOf(port),
            "--set", "confdir=" + Objects.requireNonNull(Proxy.class.getClassLoader().getResource("mitmproxy")).toURI().getPath() + "/mitmproxy-certs",
            "--map-remote", "|" + mapRemotePattern + "|http://localhost:" + String.valueOf(mockPort),
            "--modify-headers", "/~hq localhost/Host/" + hostHeader,
            "--save-stream-file", fileNameNetworkLog};
    startMitmdump(command);
}
</code>```

I can't find the answer in the documentation

when trying to add 1 more map-remote field with different url, then it doesn't work

If you try to write mapRemote by regular expression OR, to 2 url , then it doesn't work either.

Title: Set mitmdump proving multi domain

Body:
You need to set up map-remote on multiple phone URLs in autotest, but how do you do it via the command line?

launch example:

case ANDROID -> {
    String[] command = {"mitmdump",
            "--listen-port", String.valueOf(port),
            "--set", "confdir=" + Objects.requireNonNull(Proxy.class.getClassLoader().getResource("mitmproxy")).toURI().getPath() + "/mitmproxy-certs",
            "--map-remote", "|" + mapRemotePattern + "|http://localhost:" + String.valueOf(mockPort),
            "--modify-headers", "/~hq localhost/Host/" + hostHeader,
            "--save-stream-file", fileNameNetworkLog};
    startMitmdump(command);
}

I can't find the answer in the documentation

when trying to add 1 more map-remote field with different url, then it doesn't work

If you try to write mapRemote by regular expression OR, to 2 url , then it doesn't work either.


问:
How to show border only value existing row in PaginatedDataTable2
I've created flutter with PaginatedDataTable2 as below source code

```<code>Expanded(
    child: Theme(
        data: Theme.of(context).copyWith(
            cardColor: backgroundEndColor, dividerColor: Colors.white),
        child: PaginatedDataTable2(
          controller: paginatorController,
          hidePaginator: true,
          headingRowColor: MaterialStateColor.resolveWith(
            (states) {
              return Colors.white;
            },
          ),
          source: dataTable,
          header: const ListHeader(),
          columns: tableColumns,
          columnSpacing: 0,
          horizontalMargin: 10,
          rowsPerPage: projectPartProgressController.rowsPerPage.value,
          showCheckboxColumn: false,
        )),
  )
</code>```

But the last page result is showing with horizontal border that no value inside as below

Is there any way to remove the border for those no value row?

Body:
I've created flutter with PaginatedDataTable2 as below source code

Expanded(
    child: Theme(
        data: Theme.of(context).copyWith(
            cardColor: backgroundEndColor, dividerColor: Colors.white),
        child: PaginatedDataTable2(
          controller: paginatorController,
          hidePaginator: true,
          headingRowColor: MaterialStateColor.resolveWith(
            (states) {
              return Colors.white;
            },
          ),
          source: dataTable,
          header: const ListHeader(),
          columns: tableColumns,
          columnSpacing: 0,
          horizontalMargin: 10,
          rowsPerPage: projectPartProgressController.rowsPerPage.value,
          showCheckboxColumn: false,
        )),
  )

But the last page result is showing with horizontal border that no value inside as below

Is there any way to remove the border for those no value row?


问:
Master page not loading on my web application. After login I redirect the default page,
```<code><%@ Page Title="" Language="C#" MasterPageFile="~/Include/Master/Master.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<br /><br /><br /><br /><br /><br />
<div style="text-align:center; color:Red; font-size:medium;" id="dvMsg" runat="server"></div>
</asp:Content>
</code>```

After login I redirect the default page
as

Response.Redirect("default.aspx", false);
```

The application is in Visual studio 2017. The same code works on another computer.

Body:
<%@ Page Title="" Language="C#" MasterPageFile="~/Include/Master/Master.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

</asp:Content>

After login I redirect the default page
as

Response.Redirect("default.aspx", false);

The application is in Visual studio 2017. The same code works on another computer.


问:
"RFC5424 is not a valid syslog facility string" unable to configure RFC5424 syslog format in logback and sprinboot
I have configured syslog appender in my logback.xml

When I run my spring-boot application, I get the error "RFC5424 is not a valid syslog facility string"

below is my logback.xml

```<code><?xml version="1.0" encoding="UTF-8"?>
<configuration  debug="true">
<property name="DEV_HOME" value="logs"></property>

<!--console appender-->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
        <pattern>[%d{yyyy-MM-dd HH:mm:ss}] - %msg%n</pattern>
    </encoder>
</appender>

<!--all logs-->
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
    <file>${DEV_HOME}/debug.log</file>
    <encoder>
        <pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n</pattern>
    </encoder>
</appender>

<!--only controller class logs-->
<appender name="SPECIFIC_CLASS" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${DEV_HOME}/sizeTimeOutputlogFile.log</file>
    <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
        <pattern>[%d{yyyy-MM-dd HH:mm:ss}] %p %c{1.} [%t]- %m%n</pattern>
    </encoder>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <fileNamePattern>${DEV_HOME}/archived/sizeTimeOutputlogFile.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
        <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
            <!--Max Size of file to start Archive -->
            <maxFileSize>10KB</maxFileSize>
        </timeBasedFileNamingAndTriggeringPolicy>

        <!-- Days till log history to keep -->
        <maxHistory>3</maxHistory>
    </rollingPolicy>
</appender>

<!--syslog appender-->
<appender name="SYSLOG" class="ch.qos.logback.classic.net.SyslogAppender">
    <syslogHost>127.0.0.1</syslogHost>
    <facility>LOCAL0</facility>
    <port>514</port>
    <throwableExcluded>true</throwableExcluded>
    <suffixPattern>%syslogStart{RFC5424}%n</suffixPattern>
</appender>

<!-- Setup the root category, add the appenders and set the default level -->
<root level="ERROR">
    <appender-ref ref="FILE"/>
    <appender-ref ref="STDOUT"/>
</root>
<!-- Specify the level specific to controller -->
<logger name="sysLogger" level="DEBUG" additivity="false">
    <appender-ref ref="SYSLOG" />
</logger>
<logger name="com.syslogspringboot.syslog.poc" level="ERROR" additivity="false">
    <appender-ref ref="STDOUT" />
    <appender-ref ref="SPECIFIC_CLASS" />
</logger>
</code>```

with a different suffix pattern it works fine.
Can someone help

Body:
I have configured syslog appender in my logback.xml

When I run my spring-boot application, I get the error "RFC5424 is not a valid syslog facility string"

below is my logback.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration  debug="true">
<property name="DEV_HOME" value="logs"></property>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
        <pattern>[%d{yyyy-MM-dd HH:mm:ss}] - %msg%n</pattern>
    </encoder>
</appender>

<appender name="FILE" class="ch.qos.logback.core.FileAppender">
    <file>${DEV_HOME}/debug.log</file>
    <encoder>
        <pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n</pattern>
    </encoder>
</appender>

<appender name="SPECIFIC_CLASS" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${DEV_HOME}/sizeTimeOutputlogFile.log</file>
    <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
        <pattern>[%d{yyyy-MM-dd HH:mm:ss}] %p %c{1.} [%t]- %m%n</pattern>
    </encoder>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <fileNamePattern>${DEV_HOME}/archived/sizeTimeOutputlogFile.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
        <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">

            <maxFileSize>10KB</maxFileSize>
        </timeBasedFileNamingAndTriggeringPolicy>

        <maxHistory>3</maxHistory>
    </rollingPolicy>
</appender>

<appender name="SYSLOG" class="ch.qos.logback.classic.net.SyslogAppender">
    <syslogHost>127.0.0.1</syslogHost>
    <facility>LOCAL0</facility>
    <port>514</port>
    <throwableExcluded>true</throwableExcluded>
    <suffixPattern>%syslogStart{RFC5424}%n</suffixPattern>
</appender>

<root level="ERROR">
    <appender-ref ref="FILE"/>
    <appender-ref ref="STDOUT"/>
</root>

<logger name="sysLogger" level="DEBUG" additivity="false">
    <appender-ref ref="SYSLOG" />
</logger>
<logger name="com.syslogspringboot.syslog.poc" level="ERROR" additivity="false">
    <appender-ref ref="STDOUT" />
    <appender-ref ref="SPECIFIC_CLASS" />
</logger>

with a different suffix pattern it works fine.
Can someone help


问:
trying to extract pdf data into json format with headers and paragraphs as nested child
I am trying to extract pdf data to json format like below using in adobe pdf extract api,
this is the json I am getting

I want it to be something like this

Tried lots of solution with nested approach but can't figure out a proper way.

I have tried a nested approach but it didn't give proper solution
here is code
`

```<code>const fs = require("fs");

// Read the JSON file
const jsonString = fs.readFileSync("structuredData.json", "utf8");

// Parse the JSON string into an object
const data = JSON.parse(jsonString);

// Initialize the output object
const output = {};

// Loop through each line in the data
data.elements.forEach((line) => {
  // Get the path and text values

  const path = line.Path;
  const text = line.Text;

  // Split the path into an array
  const pathParts = path.split("/");

  // Initialize the current object to be the output object
  let current = output;
  let prev = null;
  // Loop through each part of the path
  pathParts.forEach((part, index) => {
    // If this is the last part of the path, set the text as the value
    if (index === pathParts.length - 1) {
      if (Object.keys(current)[0]) {
        prevdata = current[Object.keys(current)[0]];
        current[Object.keys(current)[0]] = { ...prevdata, [text]: {} };
      } else [(current[text] = {})];
    } else {
      // If the current object doesn't have a property with this path part, create it
      if (!current[part]) {
        current[part] = {};
      }

      // Set the current object to be the nested object
      current = current[part];
    }
  });
});

// Convert the output object to a JSON string and write it to a file
fs.writeFileSync("output.json", JSON.stringify(output));

</code>```

`

Body:
I am trying to extract pdf data to json format like below using in adobe pdf extract api,
this is the json I am getting

I want it to be something like this

Tried lots of solution with nested approach but can't figure out a proper way.

I have tried a nested approach but it didn't give proper solution
here is code
`

const fs = require("fs");

// Read the JSON file
const jsonString = fs.readFileSync("structuredData.json", "utf8");

// Parse the JSON string into an object
const data = JSON.parse(jsonString);

// Initialize the output object
const output = {};

// Loop through each line in the data
data.elements.forEach((line) => {
  // Get the path and text values

  const path = line.Path;
  const text = line.Text;

  // Split the path into an array
  const pathParts = path.split("/");

  // Initialize the current object to be the output object
  let current = output;
  let prev = null;
  // Loop through each part of the path
  pathParts.forEach((part, index) => {
    // If this is the last part of the path, set the text as the value
    if (index === pathParts.length - 1) {
      if (Object.keys(current)[0]) {
        prevdata = current[Object.keys(current)[0]];
        current[Object.keys(current)[0]] = { ...prevdata, [text]: {} };
      } else [(current[text] = {})];
    } else {
      // If the current object doesn't have a property with this path part, create it
      if (!current[part]) {
        current[part] = {};
      }

      // Set the current object to be the nested object
      current = current[part];
    }
  });
});

// Convert the output object to a JSON string and write it to a file
fs.writeFileSync("output.json", JSON.stringify(output));

`


问:
How to not duplicate when adding data in JTable
How to not duplicate when adding data in JTable because when I am adding in JTable it always duplicate the same data.

public void buyproduct() {
    String name = code_cart1.getText();
    try {
        con = Connector.getConnection();
        PreparedStatement pst = con.prepareStatement("SELECT `Code`, `Category`, `ProductName`, `Size`, `Quantity`, `Price`, `Sub-Total` FROM `product_table` WHERE Code = ?");
        pst.setString(1, name);
        rs = pst.executeQuery();
        while (rs.next()) {
            int currentqty = rs.getInt("Quantity");
            int pricenew = Integer.parseInt(price_cart1.getText());
            int qtynew = Integer.parseInt(quantity_cart1.getText());
            int tot = pricenew * qtynew;
            if (qtynew > currentqty || qtynew == 0) {
                JOptionPane.showMessageDialog(this, "Out of Stock!");
            } else {
                DefaultTableModel model = (DefaultTableModel) cart_Display.getModel();
                model.addRow(new Object[]{code_cart1.getText(),
                                          category_cart1.getText(),
                                          productname_cart1.getText(),
                                          size_cart1.getText(),
                                          quantity_cart1.getText(),
                                          price_cart1.getText(),
                                          tot});
                int sum = 0;
                for (int i = 0; i < cart_Display.getRowCount(); i++) {
                    sum = sum + Integer.parseInt(cart_Display.getValueAt(i, 6).toString());
                }
                SubTotal_Cart_text.setText(Integer.toString(sum));
                SubTotal_Cart_text1.setText(Integer.toString(sum));
                code_cart1.setText("");
                category_cart1.setText("");
                productname_cart1.setText("");
                size_cart1.setText("");
                quantity_cart1.setText("");
                price_cart1.setText("");
            }
        }
    } catch(Exception ex) {
    }
}
```


问:
Unhandled Rejection reason Error: PUT_STATE failed:
I was performing Private datacollection for organization1 and I am getting an error like this,

and the below is the configfile which is created

```<code>[
{
        "name": "collectionMarbles",
        "policy": "OR('Org1MSP.member')",
        "requiredPeerCount": 1,
        "maxPeerCount": 10,
        "blockToLive": 1000,
        "memberOnlyRead": true,
        "memberOnlyWrite": true,
        "endorsementPolicy": {
            "signaturePolicy": "OR('Org1MSP.member')"
        }
    }
,
    {
        "name": "collectionMarblesorg2",
        "policy": "OR('Org2MSP.member')",
        "requiredPeerCount": 1,
        "maxPeerCount": 10,
        "blockToLive": 1000,
        "memberOnlyRead": true,
        "memberOnlyWrite": true,
        "endorsementPolicy": {
            "signaturePolicy": "OR('Org2MSP.member')"
        }
    }

]
</code>```

Performed invoke function after deployment of the chaincode and it was not saving to the Couch database.

Body:
I was performing Private datacollection for organization1 and I am getting an error like this,

and the below is the configfile which is created

[
{
        "name": "collectionMarbles",
        "policy": "OR('Org1MSP.member')",
        "requiredPeerCount": 1,
        "maxPeerCount": 10,
        "blockToLive": 1000,
        "memberOnlyRead": true,
        "memberOnlyWrite": true,
        "endorsementPolicy": {
            "signaturePolicy": "OR('Org1MSP.member')"
        }
    }
,
    {
        "name": "collectionMarblesorg2",
        "policy": "OR('Org2MSP.member')",
        "requiredPeerCount": 1,
        "maxPeerCount": 10,
        "blockToLive": 1000,
        "memberOnlyRead": true,
        "memberOnlyWrite": true,
        "endorsementPolicy": {
            "signaturePolicy": "OR('Org2MSP.member')"
        }
    }

]

Performed invoke function after deployment of the chaincode and it was not saving to the Couch database.


问:
I want to show the antd datepicker in a drawer from datepicker field that is outside the drawer and will show inline is there a way
I am following Sastaticket you can also check from there in different screen sizes I need to show the datepicker according to screen size if on a desktop window the datepicker will show normally that is already showing but when on a mobile screen i need to open a drawer and then the datepicker should show inside the drawer with inline style i have created the datepicker field outside the drawer .is there a way to do this i am using antd datepicker

I have tried to create the custom drawer and when on mobile screen only the drawer is showing and not the datepicker because i do not know how to call the respective datepicker in a onclick function like in the jquery we have .datepicker() for custom styling and other stuff

```<code><DatePicker placeholder='EndDate'onClick={ShowWithPopOver} onChange={onChange} name='EndDatePicker' id='EndDatePicker' style={{ border: "transparent", boxShadow: "none" }} />
</code>```

and here is my function code

```<code>  function ShowWithPopOver()
  {
    if(window.innerWidth>700)
    {

    }
    else
    {
        debugger
        const el = document.getElementById('MobileDatePickerOverlay');
        el.classList.add('mlk-drawer-open');

    }

  }
</code>```

if mobile view then add class to this view MobileDatePickerOverly to show the view and after that the datepicker will show in that view as inline

Body:
I am following Sastaticket you can also check from there in different screen sizes I need to show the datepicker according to screen size if on a desktop window the datepicker will show normally that is already showing but when on a mobile screen i need to open a drawer and then the datepicker should show inside the drawer with inline style i have created the datepicker field outside the drawer .is there a way to do this i am using antd datepicker

I have tried to create the custom drawer and when on mobile screen only the drawer is showing and not the datepicker because i do not know how to call the respective datepicker in a onclick function like in the jquery we have .datepicker() for custom styling and other stuff

<DatePicker placeholder='EndDate'onClick={ShowWithPopOver} onChange={onChange} name='EndDatePicker' id='EndDatePicker' style={{ border: "transparent", boxShadow: "none" }} />

and here is my function code

  function ShowWithPopOver()
  {
    if(window.innerWidth>700)
    {

    }
    else
    {
        debugger
        const el = document.getElementById('MobileDatePickerOverlay');
        el.classList.add('mlk-drawer-open');

    }

  }

if mobile view then add class to this view MobileDatePickerOverly to show the view and after that the datepicker will show in that view as inline


问:
Output binary tree (inorder traversal iterative) doesn't work
I need to output tree. But this output is incorrect.
My tree is:
`

```<code> public class ElTree
    {
        public int L;
        public string inf;
        public bool PR;
        public ElTree(string inf)
        {
            this.inf = inf;
            this.PR = false;
            this.L = -1;
        }
    }
</code>```

`

Class Tree is (Here other methods that I do with Tree, the method that output Tree in in the end. I`ve also tried to do output with recursion and it work correctly, so method Add() works correctly. But I have a task to do output in iterative way). For example, when I add tree lake "k"-root, "r"-right elem, "l"-left elem then my recursive method output "lkr" but iterative method output just "ll":

`

```<code>public class Tree
    {
        public ElTree[] T;
        public int Coun { get { return _count; } }
        private int _count;
        public Tree(string inf)
        {
            ElTree temp = new ElTree(inf);
            T = new ElTree[1];
            T[T.Length-1] = temp;
        }
        public int Find(int V, string inf)
        {
            if (V == T.Length) return -1;
            if (V != -1)
            {
                if (T[V].inf == inf) return V;
                int temp = Find(T[V].L, inf);
                if (temp != -1)
                    return temp;
                return temp = Find(V + 1, inf);
            }
            return -1;
        }
        public bool Empty()
        {
            if (Coun == 0)
            {
                return true;
            }
            else
                return false;
        }
 public bool Add(int i, string inf, char s)
        {
            ElTree temp = new ElTree(inf);
            switch (s)
            {
                case 'L':
                    if (T[i].L == -1)
                    {
                        Array.Resize(ref T, T.Length + 1);
                        T[T.Length - 1] = temp;
                        T[i].L = T.Length - 1;
                        _count++;
                        return true;
                    }
                    else return false;
                case 'R':
                    if (!T[i].PR)
                    {
                        Array.Resize(ref T, T.Length + 1);
                        T[T.Length - 1] = temp;
                        T[i].PR = true;
                        _count++;
                        return true;
                    }
                    else return false;
            }
            return false;
        }
        public void TreeInStringit(int i, ref string s)//iterative output
        {
            Stack<int> stack = new Stack<int>();
            //int i = 0;
            stack.Push(i);
            do
            {
                while (T[i].L != -1 && i < T.Length)
                {
                    i = T[i].L;
                    stack.Push(i);
                }
                s += T[i].inf;
                while (T[i].PR && i < T.Length)
                {
                    i++;
                    stack.Push(i);
                }
                if (stack.Count != 0) stack.Pop();
            } while (stack.Count != 0);
        }
 public void String(int V, ref string s)//recursive output
        {
            ElTree temp = T[V];
            if (temp.L != -1)
                String(temp.L, ref s);
            s += temp.inf;
            if (temp.PR)
                String(V+1, ref s);
        }
</code>```

`

When I add tree like root with two elements (one on left side and one on right) it output left side of tree 2 times. But I need output all tree.

Body:
I need to output tree. But this output is incorrect.
My tree is:
`

 public class ElTree
    {
        public int L;
        public string inf;
        public bool PR;
        public ElTree(string inf)
        {
            this.inf = inf;
            this.PR = false;
            this.L = -1;
        }
    }

`

Class Tree is (Here other methods that I do with Tree, the method that output Tree in in the end. I`ve also tried to do output with recursion and it work correctly, so method Add() works correctly. But I have a task to do output in iterative way). For example, when I add tree lake "k"-root, "r"-right elem, "l"-left elem then my recursive method output "lkr" but iterative method output just "ll":

`

public class Tree
    {
        public ElTree[] T;
        public int Coun { get { return _count; } }
        private int _count;
        public Tree(string inf)
        {
            ElTree temp = new ElTree(inf);
            T = new ElTree[1];
            T[T.Length-1] = temp;
        }
        public int Find(int V, string inf)
        {
            if (V == T.Length) return -1;
            if (V != -1)
            {
                if (T[V].inf == inf) return V;
                int temp = Find(T[V].L, inf);
                if (temp != -1)
                    return temp;
                return temp = Find(V + 1, inf);
            }
            return -1;
        }
        public bool Empty()
        {
            if (Coun == 0)
            {
                return true;
            }
            else
                return false;
        }
 public bool Add(int i, string inf, char s)
        {
            ElTree temp = new ElTree(inf);
            switch (s)
            {
                case 'L':
                    if (T[i].L == -1)
                    {
                        Array.Resize(ref T, T.Length + 1);
                        T[T.Length - 1] = temp;
                        T[i].L = T.Length - 1;
                        _count++;
                        return true;
                    }
                    else return false;
                case 'R':
                    if (!T[i].PR)
                    {
                        Array.Resize(ref T, T.Length + 1);
                        T[T.Length - 1] = temp;
                        T[i].PR = true;
                        _count++;
                        return true;
                    }
                    else return false;
            }
            return false;
        }
        public void TreeInStringit(int i, ref string s)//iterative output
        {
            Stack<int> stack = new Stack<int>();
            //int i = 0;
            stack.Push(i);
            do
            {
                while (T[i].L != -1 && i < T.Length)
                {
                    i = T[i].L;
                    stack.Push(i);
                }
                s += T[i].inf;
                while (T[i].PR && i < T.Length)
                {
                    i++;
                    stack.Push(i);
                }
                if (stack.Count != 0) stack.Pop();
            } while (stack.Count != 0);
        }
 public void String(int V, ref string s)//recursive output
        {
            ElTree temp = T[V];
            if (temp.L != -1)
                String(temp.L, ref s);
            s += temp.inf;
            if (temp.PR)
                String(V+1, ref s);
        }

`

When I add tree like root with two elements (one on left side and one on right) it output left side of tree 2 times. But I need output all tree.


问:
How to use selectionSet in graphql field resolver
I'm writing code that needs to use the extend schema.

But I can't use stitch because I'm using federation.

So I am implementing a field resolver with one local graphql schema, but I want the server to add the fields needed by the field resolver.

How can I do this?


问:
Combining log of a python program running multiple times in parallel
I’ve a Python program which connects to an API and gets data from a webpage.
This program is parametrized to get data from different end points and write into files based on the end points.
This program is called in parallel pointing to different end points in a scheduler which runs in unix.
Some of the endpoints can take minutes or hours to get the data.

I want to run a program once in 20 minutes and see how many active sessions are running the program and what are the current status
e.g.

```<code>| end_point  | current_status | available_rows   | rows_extracted_so_far | start_time |
|------------|----------------|-----------------|-----------------------|------------|
| EP1        | running        | 10000           | 100                   | 09:00 AM   |
| EP2        | completed      | 10000           | 10000                 | 09:00 AM   |
| EP3        | failed         | 10000           | 100                   | 09:01 AM   |
</code>```

I’m creating each row in their respective log when I run the program.
All I need is a way to combine the logs and track status in a single place when I run a program to get the status every now and then .
I cannot run a server in the production system to write the common log using socket.
Is there any other way to do this without installing any new packages or running a server for constantly tracking logs.

Body:
I’ve a Python program which connects to an API and gets data from a webpage.
This program is parametrized to get data from different end points and write into files based on the end points.
This program is called in parallel pointing to different end points in a scheduler which runs in unix.
Some of the endpoints can take minutes or hours to get the data.

I want to run a program once in 20 minutes and see how many active sessions are running the program and what are the current status
e.g.

| end_point  | current_status | available_rows   | rows_extracted_so_far | start_time |
|------------|----------------|-----------------|-----------------------|------------|
| EP1        | running        | 10000           | 100                   | 09:00 AM   |
| EP2        | completed      | 10000           | 10000                 | 09:00 AM   |
| EP3        | failed         | 10000           | 100                   | 09:01 AM   |

I’m creating each row in their respective log when I run the program.
All I need is a way to combine the logs and track status in a single place when I run a program to get the status every now and then .
I cannot run a server in the production system to write the common log using socket.
Is there any other way to do this without installing any new packages or running a server for constantly tracking logs.


问:
How to increase vcores per container in tez task?
I am trying to configure vcores per container for tez task. I have edited the property tez.task.resource.cpu.vcores but tez is not taking the value, it always allocates one vcore per requested container.

How to increase vcores per container in tez?


问:
Yarn v3 migration error: cannot find script grpc_node_tools_protoc
We are trying to migrate Hyperledger Cactus from yarn v1 to yarn v3 (3.3.0). During migration using these steps here, we encountered issues.
Node version used: 16.14.2

issues encountered:
see screenshot

Ways to replicate issue:
After building cactus project and updating the yarn version we updated some scripts:
Updated the script "codegen" on the cactus/packages/cactus-core-api/package.json to "codegen": "yarn run codegen:openapi && yarn run codegen:proto", and updated the cactus/package.json configure command with "configure": "yarn install --immutable && yarn run build:dev:backend".

We run the command yarn run configure to replicate the errors


问:
Run yapf on list of files from git-diff output
I want to add a pre-commit hook to run yapf on changed changed in a commit. I use

```<code>git diff --name-only --line-prefix=`git rev-parse --show-toplevel`
</code>```

to get the list of full file names modified in a commit.

I am not sure on how to run yapf on the list of files produced by the above command as part of git pre-commit hook. I tried executing in bash

```<code>git diff --name-only --line-prefix=`git rev-parse --show-toplevel` | yapf -i
</code>```

but it says yapf: error: cannot use --in-place or --diff flags when reading from stdin. My question here is there a way to run yapf on a list of changed files?

Body:
I want to add a pre-commit hook to run yapf on changed changed in a commit. I use

git diff --name-only --line-prefix=`git rev-parse --show-toplevel`

to get the list of full file names modified in a commit.

I am not sure on how to run yapf on the list of files produced by the above command as part of git pre-commit hook. I tried executing in bash

git diff --name-only --line-prefix=`git rev-parse --show-toplevel` | yapf -i

but it says yapf: error: cannot use --in-place or --diff flags when reading from stdin. My question here is there a way to run yapf on a list of changed files?