问:
Python Selenium, using twitter api to access direct messages
```<code>s = Service('C:/Users/joeykatz/Desktop/chromedriver1/chromedriver')
driver = webdriver.Chrome(service=s)
# Selenium opens up webpage
driver.get("https://twitter.com/i/flow/login?input_flow_data=%7B%22requested_variant%22%3A%22eyJoaWRlX21lc3NhZ2UiOiJ0cnVlIiwicmVkaXJlY3RfYWZ0ZXJfbG9naW4iOiJodHRwczovL3R3aXR0ZXIuY29tL2kvb2F1dGgyL2F1dGhvcml6ZT9zdGF0ZT12RkpVMVdDVmYxTDNlVlpqQUU0Z1ZWT1hmNmZHSkEmcmVzcG9uc2VfdHlwZT1jb2RlJnJlZGlyZWN0X3VyaT1odHRwcyUzQSUyRiUyRnd3dy5zcG9ydHNkYXRhbm93LmNvbSUyRiZzY29wZT1kbS5yZWFkJTIwdHdlZXQucmVhZCUyMHVzZXJzLnJlYWQlMjBvZmZsaW5lLmFjY2VzcyZjbGllbnRfaWQ9YUVGMVdYWnZhVzB5WlVKTFV6STFTMFV4VGt3Nk1UcGphUSZjb2RlX2NoYWxsZW5nZV9tZXRob2Q9UzI1NiZjb2RlX2NoYWxsZW5nZT1MOW9xTGsySnhWQTU2TG85Z3d2T1JMWWJ4cWVMNks0QkZYTW4weXhnNmxFIn0%3D%22%7D")

time.sleep(10)
username_input = driver.find_element(By.NAME, "text")
username_input.send_keys('username')
time.sleep(2)
next = driver.find_element(By.XPATH, "//span[text()='Next']")
next.click()
time.sleep(3)
if driver.find_element(By.NAME, "text"):
    phone = driver.find_element(By.NAME, "text")
    phone.send_keys('xxx-xxx-xxxx')
    next = driver.find_element(By.XPATH, "//span[text()='Next']")
    next.click()
    time.sleep(3)

passward_input = driver.find_element(By.NAME, "password")
passward_input.send_keys('password')
time.sleep(1)
log_in = driver.find_element(By.XPATH, "//span[text()='Log in']")
log_in.click()
time.sleep(5)
authorize_app = driver.find_element(By.XPATH, "//span[text()='Authorize app']")
authorize_app.click()
time.sleep(5)
authorization_response = "https://www.sportsdatanow.com/?state=vFJU1WCVf1L3eVZjAE4gVVOXf6fGJA&code=RWdBZkx2dnd4UHl0V0w4VUtQNzFSa3h1NDBYREJLZUhuRDhBSE81R2xQRE5hOjE2NzI5MzI4OTcyMTA6MToxOmFjOjE"

# Fetches access token.
token_url = "https://api.twitter.com/2/oauth2/token"

# The following line of code will only work if you are using a type of App that is a public client.
auth = False

token = oauth.fetch_token(
    token_url=token_url,
    authorization_response=authorization_response,
    auth=auth,
    client_id=client_id,
    include_client_id=True,
    code_verifier=code_verifier,
)

# The access token.
access = token["access_token"]

return access
</code>```

def get_user_conversation_events():

```<code>access = handle_oauth()

headers = {
    "Authorization": "Bearer {}".format(access),
    "Content-Type": "application/json",
    "User-Agent": "TwitterDevSampleCode",
    "X-TFE-Experiment-environment": "staging1",
    "Dtab-Local": "/s/gizmoduck/test-users-temporary => /s/gizmoduck/gizmoduck"
}

request_url = GET_DM_EVENTS_URL

response = requests.request("GET", request_url, headers=headers)

if response.status_code != 200:
    print("Request returned an error: {} {}".format(response.status_code, response.text))
else:
    print(f"Response code: {response.status_code}")
    return response
</code>```

I am trying to use selenium to log in to twitter and authorize my app. However with this code I get this error oauthlib.oauth2.rfc6749.errors.MismatchingStateError: (mismatching_state) CSRF Warning! State not equal in request and response. Any help would be much appreciated.

Body:
s = Service('C:/Users/joeykatz/Desktop/chromedriver1/chromedriver')
driver = webdriver.Chrome(service=s)
# Selenium opens up webpage
driver.get("https://twitter.com/i/flow/login?input_flow_data=%7B%22requested_variant%22%3A%22eyJoaWRlX21lc3NhZ2UiOiJ0cnVlIiwicmVkaXJlY3RfYWZ0ZXJfbG9naW4iOiJodHRwczovL3R3aXR0ZXIuY29tL2kvb2F1dGgyL2F1dGhvcml6ZT9zdGF0ZT12RkpVMVdDVmYxTDNlVlpqQUU0Z1ZWT1hmNmZHSkEmcmVzcG9uc2VfdHlwZT1jb2RlJnJlZGlyZWN0X3VyaT1odHRwcyUzQSUyRiUyRnd3dy5zcG9ydHNkYXRhbm93LmNvbSUyRiZzY29wZT1kbS5yZWFkJTIwdHdlZXQucmVhZCUyMHVzZXJzLnJlYWQlMjBvZmZsaW5lLmFjY2VzcyZjbGllbnRfaWQ9YUVGMVdYWnZhVzB5WlVKTFV6STFTMFV4VGt3Nk1UcGphUSZjb2RlX2NoYWxsZW5nZV9tZXRob2Q9UzI1NiZjb2RlX2NoYWxsZW5nZT1MOW9xTGsySnhWQTU2TG85Z3d2T1JMWWJ4cWVMNks0QkZYTW4weXhnNmxFIn0%3D%22%7D")

time.sleep(10)
username_input = driver.find_element(By.NAME, "text")
username_input.send_keys('username')
time.sleep(2)
next = driver.find_element(By.XPATH, "//span[text()='Next']")
next.click()
time.sleep(3)
if driver.find_element(By.NAME, "text"):
    phone = driver.find_element(By.NAME, "text")
    phone.send_keys('xxx-xxx-xxxx')
    next = driver.find_element(By.XPATH, "//span[text()='Next']")
    next.click()
    time.sleep(3)

passward_input = driver.find_element(By.NAME, "password")
passward_input.send_keys('password')
time.sleep(1)
log_in = driver.find_element(By.XPATH, "//span[text()='Log in']")
log_in.click()
time.sleep(5)
authorize_app = driver.find_element(By.XPATH, "//span[text()='Authorize app']")
authorize_app.click()
time.sleep(5)
authorization_response = "https://www.sportsdatanow.com/?state=vFJU1WCVf1L3eVZjAE4gVVOXf6fGJA&code=RWdBZkx2dnd4UHl0V0w4VUtQNzFSa3h1NDBYREJLZUhuRDhBSE81R2xQRE5hOjE2NzI5MzI4OTcyMTA6MToxOmFjOjE"

# Fetches access token.
token_url = "https://api.twitter.com/2/oauth2/token"

# The following line of code will only work if you are using a type of App that is a public client.
auth = False

token = oauth.fetch_token(
    token_url=token_url,
    authorization_response=authorization_response,
    auth=auth,
    client_id=client_id,
    include_client_id=True,
    code_verifier=code_verifier,
)

# The access token.
access = token["access_token"]

return access

def get_user_conversation_events():

access = handle_oauth()

headers = {
    "Authorization": "Bearer {}".format(access),
    "Content-Type": "application/json",
    "User-Agent": "TwitterDevSampleCode",
    "X-TFE-Experiment-environment": "staging1",
    "Dtab-Local": "/s/gizmoduck/test-users-temporary => /s/gizmoduck/gizmoduck"
}

request_url = GET_DM_EVENTS_URL

response = requests.request("GET", request_url, headers=headers)

if response.status_code != 200:
    print("Request returned an error: {} {}".format(response.status_code, response.text))
else:
    print(f"Response code: {response.status_code}")
    return response

I am trying to use selenium to log in to twitter and authorize my app. However with this code I get this error oauthlib.oauth2.rfc6749.errors.MismatchingStateError: (mismatching_state) CSRF Warning! State not equal in request and response. Any help would be much appreciated.


来源: stackexchange

问:
Elastic search pod giving following error "./run: line 62: ulimit: max locked memory: cannot modify limit: Operation not permitted"
I have a pod which is trying to connect to Elastic search pod but it is failing. So, when I checked Elastic search pod logs, I am getting the following error.

*** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
*** Running /etc/my_init.d/10_syslog-ng.init...
Jan  5 20:20:02 elasticsearch-0 syslog-ng[12]: syslog-ng starting up; version='3.5.6'
Jan  5 20:20:03 elasticsearch-0 syslog-ng[12]: EOF on control channel, closing connection;
*** Running /etc/rc.local...
*** Booting runit daemon...
*** Runit started as PID 18
Jan  5 20:20:03 elasticsearch-0 cron[23]: (CRON) INFO (pidfile fd = 3)
Jan  5 20:20:03 elasticsearch-0 cron[23]: (CRON) INFO (Running @reboot jobs)
./run: line 62: ulimit: max locked memory: cannot modify limit: Operation not permitted
curl: (7) Failed to connect to elasticsearch-tekstack-0 port 9200: Connection refused
```

I have checked whether Elastic search service, endpoints are created or not. All those have been created. I am not sure why this error popping out.

ContentLicense: CC BY-SA 4.0

Body:
I have a pod which is trying to connect to Elastic search pod but it is failing. So, when I checked Elastic search pod logs, I am getting the following error.

*** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
*** Running /etc/my_init.d/10_syslog-ng.init...
Jan  5 20:20:02 elasticsearch-0 syslog-ng[12]: syslog-ng starting up; version='3.5.6'
Jan  5 20:20:03 elasticsearch-0 syslog-ng[12]: EOF on control channel, closing connection;
*** Running /etc/rc.local...
*** Booting runit daemon...
*** Runit started as PID 18
Jan  5 20:20:03 elasticsearch-0 cron[23]: (CRON) INFO (pidfile fd = 3)
Jan  5 20:20:03 elasticsearch-0 cron[23]: (CRON) INFO (Running @reboot jobs)
./run: line 62: ulimit: max locked memory: cannot modify limit: Operation not permitted
curl: (7) Failed to connect to elasticsearch-tekstack-0 port 9200: Connection refused

I have checked whether Elastic search service, endpoints are created or not. All those have been created. I am not sure why this error popping out.


问:
On Chromebook getConnectionOwnerUid() return -1 (Process.INVALID_UID) on chrome app
I have a VPN service that uses the [getConnectionOwnerUid()]1 function to get the user ID (UID) of the owner of a network connection. On Android, this function works well for all apps. However, when I try to use it on a Chromebook with the Chrome app, it returns -1 (Process.INVALID_UID).

Why is this happening and how can I fix it? Is there a different way to get the UID of the owner of a network connection on a Chromebook?

My Chromebook’s details are:

```<code>ACER CB314
Model N19Q2
ARC: 9375475
</code>```

Body:
I have a VPN service that uses the [getConnectionOwnerUid()]1 function to get the user ID (UID) of the owner of a network connection. On Android, this function works well for all apps. However, when I try to use it on a Chromebook with the Chrome app, it returns -1 (Process.INVALID_UID).

Why is this happening and how can I fix it? Is there a different way to get the UID of the owner of a network connection on a Chromebook?

My Chromebook’s details are:

ACER CB314
Model N19Q2
ARC: 9375475


问:
CFileDialog::OnFolderChange() doesn't work as expected (Windows C++/MFC)
C++/MFC, Windows 11. Visual Studio 2022 17.4.3.

I'm using CFileDialog to allow user to chose a file. I want to be notified whenever the user changes directories (folders), but I can't get OnFolderChange to work. I expect OnFolderChange() to be called every time user selects a folder, but it is not called.

What do I need to do to get the notification when user switches folders?

Here is sample code.

Header:

```<code>// Browsing_test.h

class P
{
public:
    int BrowseTest(void);
    virtual void OnFolderChange();
};
</code>```
```<code>#include "Browsing_test.h"

int P::BrowseTest(void)
{
    DWORD flags = OFN_CREATEPROMPT | OFN_HIDEREADONLY | OFN_ENABLESIZING;
    CFileDialog dlg(TRUE, NULL/*defaultExt*/, NULL/*defaultFiles*/, flags, NULL/*fileTypes*/, nullptr/* pParentWnd*/, 0/*dwSize*/, TRUE/*bVistaStyle*/);
    int resultDebug = (int)dlg.DoModal();
    return resultDebug;
}

void P::OnFolderChange()
{
    bool stopHere = true; // NEVER GETS HERE
}
</code>```

Body:
C++/MFC, Windows 11. Visual Studio 2022 17.4.3.

I'm using CFileDialog to allow user to chose a file. I want to be notified whenever the user changes directories (folders), but I can't get OnFolderChange to work. I expect OnFolderChange() to be called every time user selects a folder, but it is not called.

What do I need to do to get the notification when user switches folders?

Here is sample code.

Header:

// Browsing_test.h

class P
{
public:
    int BrowseTest(void);
    virtual void OnFolderChange();
};

#include "Browsing_test.h"

int P::BrowseTest(void)
{
    DWORD flags = OFN_CREATEPROMPT | OFN_HIDEREADONLY | OFN_ENABLESIZING;
    CFileDialog dlg(TRUE, NULL/*defaultExt*/, NULL/*defaultFiles*/, flags, NULL/*fileTypes*/, nullptr/* pParentWnd*/, 0/*dwSize*/, TRUE/*bVistaStyle*/);
    int resultDebug = (int)dlg.DoModal();
    return resultDebug;
}

void P::OnFolderChange()
{
    bool stopHere = true; // NEVER GETS HERE
}


问:
Postgres JsonB data deep level searching
```<code>-- PostgreSQL 11.17

CREATE TABLE products(
id SERIAL PRIMARY KEY,
json_data JSONB NOT null
);

insert into products(json_data) values('{"metadata":{"prompts":[{"id":"ITEMS","children":[{"id":"Level1","name":"Dairy","children":[{"id":"Level2","name":"Yogurt","children":[{"id":"Level3","name":"Sweetened","children":[{"id":"Level4","name":"Probiotic"}]}]}]}]}]}}');
insert into products(json_data) values('{"metadata":{"prompts":[{"id":"ITEMS","children":[{"id":"Level1","name":"Dairy","children":[{"id":"Level2","name":"Yogurt","children":[{"id":"Level3","name":"Probiotic","children":[{"id":"Level4","name":"VitaminD"}]}]}]}]}]}}');

select * from products;
</code>```

I would like to get the product id whose item is Probiotic irrespective of any level. Am expecting my query to return product id 1 and 2. But So I come up with the query like this.

```<code>SELECT id
FROM products,
  JSONB_ARRAY_ELEMENTS(json_data->'metadata' -> 'prompts') AS prompts,
  JSONB_ARRAY_ELEMENTS(prompts->'children') AS level1,
  JSONB_ARRAY_ELEMENTS(level1->'children') AS level2,
  JSONB_ARRAY_ELEMENTS(level2->'children') AS level3,
  JSONB_ARRAY_ELEMENTS(level3->'children') AS level4
WHERE level3 ->> 'name' = 'Probiotic'
or level4 ->> 'name' = 'Probiotic';
</code>```

In this case, I need to dig into all the levels and find out the name is Probiotic or not. In other words, i need to know the level where the name is Probiotic.

How to come up with the query, where query itself dig into all levels and find out where its Probiotic or not.

I tried something like below and is not returning any result

```<code>--NOT working
SELECT products.id
FROM products
WHERE EXISTS (SELECT TRUE
       FROM jsonb_array_elements(json_data->'metadata' -> 'prompts') prompts
       WHERE prompts @> ANY(ARRAY[
           JSONB '{ "name":"Probiotic" }'
              ]
       )
);
</code>```

SQL Fiddle link:
http://sqlfiddle.com/#!17/9eecb/100580

Thanks.

Body:
-- PostgreSQL 11.17

CREATE TABLE products(
id SERIAL PRIMARY KEY,
json_data JSONB NOT null
);

insert into products(json_data) values('{"metadata":{"prompts":[{"id":"ITEMS","children":[{"id":"Level1","name":"Dairy","children":[{"id":"Level2","name":"Yogurt","children":[{"id":"Level3","name":"Sweetened","children":[{"id":"Level4","name":"Probiotic"}]}]}]}]}]}}');
insert into products(json_data) values('{"metadata":{"prompts":[{"id":"ITEMS","children":[{"id":"Level1","name":"Dairy","children":[{"id":"Level2","name":"Yogurt","children":[{"id":"Level3","name":"Probiotic","children":[{"id":"Level4","name":"VitaminD"}]}]}]}]}]}}');

select * from products;

I would like to get the product id whose item is Probiotic irrespective of any level. Am expecting my query to return product id 1 and 2. But So I come up with the query like this.

SELECT id
FROM products,
  JSONB_ARRAY_ELEMENTS(json_data->'metadata' -> 'prompts') AS prompts,
  JSONB_ARRAY_ELEMENTS(prompts->'children') AS level1,
  JSONB_ARRAY_ELEMENTS(level1->'children') AS level2,
  JSONB_ARRAY_ELEMENTS(level2->'children') AS level3,
  JSONB_ARRAY_ELEMENTS(level3->'children') AS level4
WHERE level3 ->> 'name' = 'Probiotic'
or level4 ->> 'name' = 'Probiotic';

In this case, I need to dig into all the levels and find out the name is Probiotic or not. In other words, i need to know the level where the name is Probiotic.

How to come up with the query, where query itself dig into all levels and find out where its Probiotic or not.

I tried something like below and is not returning any result

--NOT working
SELECT products.id
FROM products
WHERE EXISTS (SELECT TRUE
       FROM jsonb_array_elements(json_data->'metadata' -> 'prompts') prompts
       WHERE prompts @> ANY(ARRAY[
           JSONB '{ "name":"Probiotic" }'
              ]
       )
);

SQL Fiddle link:
http://sqlfiddle.com/#!17/9eecb/100580

Thanks.


问:
How Can I Conditionally Select Data using a HTTP POST request while getting Data from Server?
So I am using a RestAPI where it is specified in the document that I have to :

log in using the username and password with the POST method. The response of which is a token. Raw JSON to be used.

use that token and make a Bearer POST request with headers as "date_end" and "date_begin" to retrieve data in JSON format. The same Raw JSON to be used.

Now the final retrieved data has 25 keys which does not include the "date_end" and "date_begin" keys. Out of which one column is the STATEX. Of all, there's is a "XXXXX" value. Now I want to query only these "XXXXX" values from the server. How do I do it without downloading the entire dataset and filtering? I want the request to query like we have 'parameters' in GET request. This RestAPI does not allow GET requests.

I did get the token value successfully. Now for retrieving the data,
I have tried:

json_data = {"date_end" : ... , "date_begin" : ...}

requests.post(url=url, headers={Authentication: 'Bearer '+token}, json=json_data)

Which produces a JSON response contining 25 Keys. I only want data of key "STATEX" which has value "XXXXX"

I don't want to download all data and filter because the rest of it is not needed.


问:
What does PBT_POWERSETTINGSCHANGE (32787) with lParam = 206730400 mean?
I am using trying to track when the monitor goes off due to user inactivity.

To do that, I process PBT_POWERSETTINGCHANGE like this:

```<code>    Select Case wParam
        Case PBT_APMPOWERSTATUSCHANGE
            'DebugPrint "PBT_APMPOWERSTATUSCHANGE"
        Case PBT_APMRESUMEAUTOMATIC
           ' DebugPrint "PBT_APMRESUMEAUTOMATIC"
        Case PBT_APMRESUMESUSPEND
            'DebugPrint "PBT_APMRESUMESUSPEND"
        Case PBT_APMSUSPEND
            'DebugPrint "PBT_APMSUSPEND"
        Case PBT_POWERSETTINGCHANGE
            CopyMemory pbs, ByVal lParam, Len(pbs)
            'DebugPrint "PBT_POWERSETTINGCHANGE " & GuidToString(pbs.PowerSetting)
            Select Case GuidToString(pbs.PowerSetting)
                Case GUID_POWERSCHEME_PERSONALITY
                    CopyMemory g, ByVal lParam + Len(pbs), 16
                    'DebugPrint "New power scheme: " & GuidToString(g)
                Case GUID_SESSION_DISPLAY_STATUS
                    CopyMemory l, ByVal lParam + Len(pbs), 4
                    'DebugPrint "Display status: " & L
                Case GUID_MONITOR_POWER_ON
                    CopyMemory l, ByVal lParam + Len(pbs), 4
                    'DebugPrint "Primary Monitor state: " & L & " ON!!!"
                Case GUID_CONSOLE_DISPLAY_STATE
                    CopyMemory l, ByVal lParam + Len(pbs), 4
                    'DebugPrint "Console Display state: " & L
            End Select

            If l = 0 Then
                  Debug.Assert False'monitor went off
</code>```

To my surprise, I experience "GUID_POWERSCHEME_PERSONALITY" and "l = 0" me even though I am just starting my app.

Where do I go wrong, or what should I track in order to be notified when the screen goes off due to inactivity?

Body:
I am using trying to track when the monitor goes off due to user inactivity.

To do that, I process PBT_POWERSETTINGCHANGE like this:

    Select Case wParam
        Case PBT_APMPOWERSTATUSCHANGE
            'DebugPrint "PBT_APMPOWERSTATUSCHANGE"
        Case PBT_APMRESUMEAUTOMATIC
           ' DebugPrint "PBT_APMRESUMEAUTOMATIC"
        Case PBT_APMRESUMESUSPEND
            'DebugPrint "PBT_APMRESUMESUSPEND"
        Case PBT_APMSUSPEND
            'DebugPrint "PBT_APMSUSPEND"
        Case PBT_POWERSETTINGCHANGE
            CopyMemory pbs, ByVal lParam, Len(pbs)
            'DebugPrint "PBT_POWERSETTINGCHANGE " & GuidToString(pbs.PowerSetting)
            Select Case GuidToString(pbs.PowerSetting)
                Case GUID_POWERSCHEME_PERSONALITY
                    CopyMemory g, ByVal lParam + Len(pbs), 16
                    'DebugPrint "New power scheme: " & GuidToString(g)
                Case GUID_SESSION_DISPLAY_STATUS
                    CopyMemory l, ByVal lParam + Len(pbs), 4
                    'DebugPrint "Display status: " & L
                Case GUID_MONITOR_POWER_ON
                    CopyMemory l, ByVal lParam + Len(pbs), 4
                    'DebugPrint "Primary Monitor state: " & L & " ON!!!"
                Case GUID_CONSOLE_DISPLAY_STATE
                    CopyMemory l, ByVal lParam + Len(pbs), 4
                    'DebugPrint "Console Display state: " & L
            End Select

            If l = 0 Then
                  Debug.Assert False'monitor went off

To my surprise, I experience "GUID_POWERSCHEME_PERSONALITY" and "l = 0" me even though I am just starting my app.

Where do I go wrong, or what should I track in order to be notified when the screen goes off due to inactivity?


问:
Matplotlib+Jupyter stops rendering animation when run inside a function
After getting a matplotlib animation to run successfully inside a Vscode Juypter notebook cell, I decided to refactor the matplotlib animation code into a function but this causes the matplotlib figure to stop showing and display a warning

UserWarning: Animation was deleted without rendering anything. This is most likely not intended. To prevent deletion, assign the Animation to a variable, e.g. anim, that exists until you output the Animation using plt.show() or anim.save().

Initial working code:

import matplotlib.pyplot as plt
import matplotlib.animation
import numpy as np

plt.rcParams["animation.html"] = "jshtml"
plt.rcParams["figure.dpi"] = 100
plt.ioff()

def animate(frame_num):
    x = np.linspace(0, 2*np.pi, 100)
    y = np.sin(x + 2*np.pi * frame_num/100)
    line.set_data((x, y))
    return line

fig, ax = plt.subplots()
line, = ax.plot([])
ax.set_xlim(0, 2*np.pi)
ax.set_ylim(-1.1, 1.1)

matplotlib.animation.FuncAnimation(
    fig, animate, frames=10, blit=True
)
```
<p><img src="https://i.stack.imgur.com/39Qia.png" alt="enter image description here" /></p>
<p><strong>Non-working refactored code:</strong></p>
<pre class="lang-py prettyprint-override"><code>import matplotlib.pyplot as plt
import matplotlib.animation
import numpy as np

plt.rcParams["animation.html"] = "jshtml"
plt.rcParams["figure.dpi"] = 100
plt.ioff()

def animate(frame_num):
    x = np.linspace(0, 2*np.pi, 100)
    y = np.sin(x + 2*np.pi * frame_num/100)
    line.set_data((x, y))
    return line

def generate_animation():
    fig, ax = plt.subplots()
    line, = ax.plot([])
    ax.set_xlim(0, 2*np.pi)
    ax.set_ylim(-1.1, 1.1)

    anim = matplotlib.animation.FuncAnimation(
        fig, animate, frames=10, blit=True
    )

    plt.show()

    return anim

anim = generate_animation()
</code>```

Also tried adding %matplotlib notebook or %matplotlib widget to the start of the Jupyter notebook cell, but the same error occurs.

Is there a way to get the matplotlib.animation.FuncAnimation working when its running from inside a function?

Body:
After getting a matplotlib animation to run successfully inside a Vscode Juypter notebook cell, I decided to refactor the matplotlib animation code into a function but this causes the matplotlib figure to stop showing and display a warning

UserWarning: Animation was deleted without rendering anything. This is most likely not intended. To prevent deletion, assign the Animation to a variable, e.g. anim, that exists until you output the Animation using plt.show() or anim.save().

Initial working code:

import matplotlib.pyplot as plt
import matplotlib.animation
import numpy as np

plt.rcParams["animation.html"] = "jshtml"
plt.rcParams["figure.dpi"] = 100
plt.ioff()

def animate(frame_num):
    x = np.linspace(0, 2*np.pi, 100)
    y = np.sin(x + 2*np.pi * frame_num/100)
    line.set_data((x, y))
    return line

fig, ax = plt.subplots()
line, = ax.plot([])
ax.set_xlim(0, 2*np.pi)
ax.set_ylim(-1.1, 1.1)

matplotlib.animation.FuncAnimation(
    fig, animate, frames=10, blit=True
)

Non-working refactored code:

import matplotlib.pyplot as plt
import matplotlib.animation
import numpy as np

plt.rcParams["animation.html"] = "jshtml"
plt.rcParams["figure.dpi"] = 100
plt.ioff()

def animate(frame_num):
    x = np.linspace(0, 2*np.pi, 100)
    y = np.sin(x + 2*np.pi * frame_num/100)
    line.set_data((x, y))
    return line

def generate_animation():
    fig, ax = plt.subplots()
    line, = ax.plot([])
    ax.set_xlim(0, 2*np.pi)
    ax.set_ylim(-1.1, 1.1)

    anim = matplotlib.animation.FuncAnimation(
        fig, animate, frames=10, blit=True
    )

    plt.show()

    return anim

anim = generate_animation()

Also tried adding %matplotlib notebook or %matplotlib widget to the start of the Jupyter notebook cell, but the same error occurs.

Is there a way to get the matplotlib.animation.FuncAnimation working when its running from inside a function?


问:
React testing the Google sign-in button
How to go about testing the Google sign-in button from Google identity services?

Currently the button is not being found when I run a findBy query. Do I need to mock the API call to Google?

The function that returns the button:

```<code>export const initialiseGoogle = (callbackResponse, google) => {
 /* global google */
 google.accounts.id.initialize({
   client_id: process.env.REACT_APP_ID,
   callback: callbackResponse,
 });
 window.google.accounts.id.renderButton(
   document.getElementsByClassName("buttonSignIn")[0],
  {
    shape: "circle",
    size: "medium",
    type: "standard",
  }
 );
};
</code>```

The useEffect that calls the function:

```<code>  useEffect(() => {
// Initializes the google sign-in button

  if (google && divRef.current) {
    console.log(google);
    initialiseGoogle(handleCallbackResponse, google);
  }
 }, [google, divRef.current]);
</code>```

The div that takes the button:

```<code> <section>
   <div
     ref={divRef}
     className={`buttonSignIn ${signInButtonClass}`}
     hidden={!isSignedIn ? false : true}
   ></div>
 </section>
</code>```

The test and the console during test:

```<code> const user = userEvent.setup();

 test("The Google sign-in should be visible within 3sec of page load", async () => {
   const { debug, getByPlaceholderText, getByRole, findByTitle } = customRender(
     Wrapper,
     <App />
     );

   const button = await findByTitle("Sign in with Google Button");

   debug();
  });
</code>```

Test fail:

```<code>FAIL src/components/__tests__/Header.test.js
 × The Google sign-in should be visible within 3sec of page load (1060 ms)

 ● The Google sign-in should be visible within 3sec of page load

  Unable to find an element with the title: Sign in with Google Button.

Ignored nodes: comments, script, style
<body>
  <div>
    <header>
      <div
        class="w-100 divider-1"
      />
      <div
        class="header-container border-ani container-fluid"
      >
        <div
          class="d-flex full-logo flex-row justify-content-center"
        >
          <i
            class="check square logo-icon outline icon mb-2 "
          />
        </div>
        <div
          class="signIn-div d-flex justify-content-center"
        >
          <section
            class="w-100 d-flex justify-content-center"
          >
            <div
              class="buttonSignIn"
            />
       </header>
      </div>
    </body>
</code>```

Title: React testing the Google sign-in button

Body:
How to go about testing the Google sign-in button from Google identity services?

Currently the button is not being found when I run a findBy query. Do I need to mock the API call to Google?

The function that returns the button:

export const initialiseGoogle = (callbackResponse, google) => {
 /* global google */
 google.accounts.id.initialize({
   client_id: process.env.REACT_APP_ID,
   callback: callbackResponse,
 });
 window.google.accounts.id.renderButton(
   document.getElementsByClassName("buttonSignIn")[0],
  {
    shape: "circle",
    size: "medium",
    type: "standard",
  }
 );
};

The useEffect that calls the function:

  useEffect(() => {
// Initializes the google sign-in button

  if (google && divRef.current) {
    console.log(google);
    initialiseGoogle(handleCallbackResponse, google);
  }
 }, [google, divRef.current]);

The div that takes the button:

   <div
     ref={divRef}
     className={`buttonSignIn ${signInButtonClass}`}
     hidden={!isSignedIn ? false : true}
   >

The test and the console during test:

 const user = userEvent.setup();

 test("The Google sign-in should be visible within 3sec of page load", async () => {
   const { debug, getByPlaceholderText, getByRole, findByTitle } = customRender(
     Wrapper,
     <App />
     );

   const button = await findByTitle("Sign in with Google Button");

   debug();
  });

Test fail:

FAIL src/components/__tests__/Header.test.js
 × The Google sign-in should be visible within 3sec of page load (1060 ms)

 ● The Google sign-in should be visible within 3sec of page load

  Unable to find an element with the title: Sign in with Google Button.

Ignored nodes: comments, script, style


问:
Having trouble understanding Deeplinking
I'm trying to implement the Coinbase Android Wallet SDK

In their tutorial on github

https://github.com/coinbase/wallet-mobile-sdk/tree/master/android

It tells me to use

```<code>CoinbaseWalletSDK(
    appContext = applicationContext,
    domain = Uri.parse("https://www.myappxyz.com"),
    openIntent = { intent -> launcher.launch(intent) }
)
</code>```

Is the url inside Uri.parse() a server I would have to host myself?

I also checked coinbase's website and they provide users with a Universal Link

https://docs.cloud.coinbase.com/wallet-sdk/docs/deep-link-into-dapp-browser

From the docs:

```<code>Universal Link

https://go.cb-w.com/dapp?cb_url=[YOUR_URL]

YOUR_URL should be encoded with percent-encoding.
</code>```

I'm confused because they provide us with a "Universal Link". Does that mean we just use their url or do we still have to host our own server?

Body:
I'm trying to implement the Coinbase Android Wallet SDK

In their tutorial on github

https://github.com/coinbase/wallet-mobile-sdk/tree/master/android

It tells me to use

CoinbaseWalletSDK(
    appContext = applicationContext,
    domain = Uri.parse("https://www.myappxyz.com"),
    openIntent = { intent -> launcher.launch(intent) }
)

Is the url inside Uri.parse() a server I would have to host myself?

I also checked coinbase's website and they provide users with a Universal Link

https://docs.cloud.coinbase.com/wallet-sdk/docs/deep-link-into-dapp-browser

From the docs:

Universal Link

https://go.cb-w.com/dapp?cb_url=[YOUR_URL]

YOUR_URL should be encoded with percent-encoding.

I'm confused because they provide us with a "Universal Link". Does that mean we just use their url or do we still have to host our own server?


问:
How to create a repository using Probot?
I want to build an app that can perform automatically create a new repo in GitHub.
I followed https://probot.github.io/docs/http/:

```<code>import { Probot, ApplicationFunctionOptions, Context } from 'probot'

export = (app: Probot, { getRouter }: ApplicationFunctionOptions) => {
  const router = getRouter("/my-app");
  router.get("/hello-world", (req, res) => {
    // I want to create a new repo from here,
    // after getRouter(path).get('/') is called
    res.send("Hello World");
  });

  app.on('issues.opened', (context: Context) => {
    // Not from here
  })
}
</code>```

How to do that? Thank you!

I tried:

```<code>import { Probot, ApplicationFunctionOptions, Context, ProbotOctokit } from 'probot'

export = (app: Probot, { getRouter }: ApplicationFunctionOptions) => {
  const router = getRouter("/my-app");
  router.get("/hello-world", (req, res) => {

    const appOctokit = new ProbotOctokit({
      authStrategy: createAppAuth,
      auth: {
        appId: process.env.APP_ID || 0,
        privateKey: process.env.PRIVATE_KEY || '',
        clientId: process.env.GITHUB_CLIENT_ID || '',
        clientSecret: process.env.GITHUB_CLIENT_SECRET || '',
        installationId: process.env.INSTALLATION_ID
      }
    })

    await appOctokit.request('POST /user/repos', {
      name: body.name,
      auto_init: body.auto_init
    })

    res.send("Hello World");
  });
}
</code>```

But I got a response like this:

```<code>data: {
  message: 'Resource not accessible by integration',
  documentation_url: 'https://docs.github.com/rest/reference/repos#create-a-repository-for-the-authenticated-user'
}
</code>```

Body:
I want to build an app that can perform automatically create a new repo in GitHub.
I followed https://probot.github.io/docs/http/:

import { Probot, ApplicationFunctionOptions, Context } from 'probot'

export = (app: Probot, { getRouter }: ApplicationFunctionOptions) => {
  const router = getRouter("/my-app");
  router.get("/hello-world", (req, res) => {
    // I want to create a new repo from here,
    // after getRouter(path).get('/') is called
    res.send("Hello World");
  });

  app.on('issues.opened', (context: Context) => {
    // Not from here
  })
}

How to do that? Thank you!

I tried:

import { Probot, ApplicationFunctionOptions, Context, ProbotOctokit } from 'probot'

export = (app: Probot, { getRouter }: ApplicationFunctionOptions) => {
  const router = getRouter("/my-app");
  router.get("/hello-world", (req, res) => {

    const appOctokit = new ProbotOctokit({
      authStrategy: createAppAuth,
      auth: {
        appId: process.env.APP_ID || 0,
        privateKey: process.env.PRIVATE_KEY || '',
        clientId: process.env.GITHUB_CLIENT_ID || '',
        clientSecret: process.env.GITHUB_CLIENT_SECRET || '',
        installationId: process.env.INSTALLATION_ID
      }
    })

    await appOctokit.request('POST /user/repos', {
      name: body.name,
      auto_init: body.auto_init
    })

    res.send("Hello World");
  });
}

But I got a response like this:

data: {
  message: 'Resource not accessible by integration',
  documentation_url: 'https://docs.github.com/rest/reference/repos#create-a-repository-for-the-authenticated-user'
}


问:
Google Scripts - Retaining formatting & hyperlinks when copying body text from Google Sheets into an email
I have the below code, which currently sends a templated email via gmail to contacts whose details are listed in an active google sheet, drawing the subject line and body from a google doc.

Currently, all formatting is removed when the email is sent. I would like to have all formatting & hyperlinks preserved from the original document, as if I had copy/pasted directly.

```<code>function sendEmail() {
  // Access the Google Sheet and open the Google Doc by its ID
  var sheet = SpreadsheetApp.getActiveSheet();
  var doc = DocumentApp.openById("YOUR_DOC_ID");

  // Get the subject line and body text from the Google Doc
  var subject = doc.getHeader().getText();
  var body = doc.getBody().getText();

  // Find the column indices for the name and email
  var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0];
  var nameIndex = headers.indexOf("name");
  var emailIndex = headers.indexOf("email");

  // Set the indices to 0 if the columns are not found
  if (nameIndex == -1) nameIndex = 0;
  if (emailIndex == -1) emailIndex = 0;

  // Start on the second row
  var startRow = 2;
  var numRows = sheet.getLastRow();

  // Loop through the rows
  for (var row = startRow; row <= numRows; row++) {
    var name = sheet.getRange(row, nameIndex + 1).getValue();
    var email = sheet.getRange(row, emailIndex + 1).getValue();

    // Skip the contact if no email is provided or if the email is invalid
    if (email == "" || !email.includes("@")) continue;

    // Send the email
    MailApp.sendEmail(email, subject, "Hi " + name + ",\n\n" + body + "\n\nBest regards,");
  }
}

</code>```

Any workaround or addition to the code to ensure the formatting & hyperlinks are preserved would be a great help.

Body:
I have the below code, which currently sends a templated email via gmail to contacts whose details are listed in an active google sheet, drawing the subject line and body from a google doc.

Currently, all formatting is removed when the email is sent. I would like to have all formatting & hyperlinks preserved from the original document, as if I had copy/pasted directly.

function sendEmail() {
  // Access the Google Sheet and open the Google Doc by its ID
  var sheet = SpreadsheetApp.getActiveSheet();
  var doc = DocumentApp.openById("YOUR_DOC_ID");

  // Get the subject line and body text from the Google Doc
  var subject = doc.getHeader().getText();
  var body = doc.getBody().getText();

  // Find the column indices for the name and email
  var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0];
  var nameIndex = headers.indexOf("name");
  var emailIndex = headers.indexOf("email");

  // Set the indices to 0 if the columns are not found
  if (nameIndex == -1) nameIndex = 0;
  if (emailIndex == -1) emailIndex = 0;

  // Start on the second row
  var startRow = 2;
  var numRows = sheet.getLastRow();

  // Loop through the rows
  for (var row = startRow; row <= numRows; row++) {
    var name = sheet.getRange(row, nameIndex + 1).getValue();
    var email = sheet.getRange(row, emailIndex + 1).getValue();

    // Skip the contact if no email is provided or if the email is invalid
    if (email == "" || !email.includes("@")) continue;

    // Send the email
    MailApp.sendEmail(email, subject, "Hi " + name + ",\n\n" + body + "\n\nBest regards,");
  }
}

Any workaround or addition to the code to ensure the formatting & hyperlinks are preserved would be a great help.


问:
Sign Up Users in Bulk - Parse Platform
I'm creating an app in iOS using Parse where a district administrator would bulk create accounts for all students in the district using their student information system data.

I'm wondering if any method exists where a bulk number of accounts can be created? I'm aware that I can setup a for-in statement to make them all one-by-one using signUpInBackground(), but this method causes the current user to be logged out and the newly created user to be logged in... thus losing the district administrator session.

Title: Sign Up Users in Bulk - Parse Platform


问:
reportLab showPage() doesn't work on landscape layout
I'm trying create a pdf with many pages, it work 100% with portrait ones, but if i try create a portrait pdf, the showPage() function doesn't create a new page.

It's my code with landscape layout:

```<code>from reportlab.lib.pagesizes import A4, landscape
from reportlab.pdfgen import canvas

c = canvas.Canvas("C:/Report.pdf",pagesize=Landscape(A4)

for i in range(5):
    c.drawString(100,750,'test')
    c.showPage()
c.save()

</code>```

And here is my code in portrait layout:

```<code>from reportlab.lib.pagesizes import A4
from reportlab.pdfgen import canvas

c = canvas.Canvas("C:/Report.pdf",pagesize=A4

for i in range(5):
    c.drawString(100,750,'test')
    c.showPage()
c.save()

</code>```

Body:
I'm trying create a pdf with many pages, it work 100% with portrait ones, but if i try create a portrait pdf, the showPage() function doesn't create a new page.

It's my code with landscape layout:

from reportlab.lib.pagesizes import A4, landscape
from reportlab.pdfgen import canvas

c = canvas.Canvas("C:/Report.pdf",pagesize=Landscape(A4)

for i in range(5):
    c.drawString(100,750,'test')
    c.showPage()
c.save()

And here is my code in portrait layout:

from reportlab.lib.pagesizes import A4
from reportlab.pdfgen import canvas

c = canvas.Canvas("C:/Report.pdf",pagesize=A4

for i in range(5):
    c.drawString(100,750,'test')
    c.showPage()
c.save()


问:
Actix and Inventory crate
I'm trying to make it possible to register an actix route automatically. To do so I found the crate Inventory which seems to answer my need.

I have the following code:

```<code>#[get("/hello2/{name}")]
async fn greet2(req: HttpRequest) -> String {
    let name = req.match_info().get("name").unwrap_or("World");
    let a = format!("Hello2 {}!", &name);
    a
}

pub struct TestStruct {
    test: fn(HttpRequest) -> dyn Future<Output = String>
}

inventory::collect!(TestStruct);

inventory::submit! {
    let mut a = TestStruct {
        test: <greet2 as HttpServiceFactory>::register
    };
    a.test.push(greet2::register::greet2);
    a
}

#[actix_web::main]
async fn main() -> std::io::Result<()> {
    HttpServer::new(move || {
        let mut app = App::new();
        for route in inventory::iter::<AutomaticHttpService> {
            app = app.service(route);
        }
        app
    })
        .bind(("127.0.0.1", 8080))?
        .workers(2)
        .run()
        .await
}
</code>```

My code does not compile as I cannot access the requested function pointer and I cannot use the HttpServiceFactory trait as it is not declared in the same file. I also tried to use the std::any::Any type and then cast to HttpServiceFactory (maybe using unsafe) but without success because its size was not known at compile time.
Would you have any clues to unblock my situation?

Title: Actix and Inventory crate

Body:
I'm trying to make it possible to register an actix route automatically. To do so I found the crate Inventory which seems to answer my need.

I have the following code:

#[get("/hello2/{name}")]
async fn greet2(req: HttpRequest) -> String {
    let name = req.match_info().get("name").unwrap_or("World");
    let a = format!("Hello2 {}!", &name);
    a
}

pub struct TestStruct {
    test: fn(HttpRequest) -> dyn Future<Output = String>
}

inventory::collect!(TestStruct);

inventory::submit! {
    let mut a = TestStruct {
        test: <greet2 as HttpServiceFactory>::register
    };
    a.test.push(greet2::register::greet2);
    a
}

#[actix_web::main]
async fn main() -> std::io::Result<()> {
    HttpServer::new(move || {
        let mut app = App::new();
        for route in inventory::iter::<AutomaticHttpService> {
            app = app.service(route);
        }
        app
    })
        .bind(("127.0.0.1", 8080))?
        .workers(2)
        .run()
        .await
}

My code does not compile as I cannot access the requested function pointer and I cannot use the HttpServiceFactory trait as it is not declared in the same file. I also tried to use the std::any::Any type and then cast to HttpServiceFactory (maybe using unsafe) but without success because its size was not known at compile time.
Would you have any clues to unblock my situation?


问:
com.android.bundle.errors.EvalIssueException: The android Grandle plugin only kotlin-android extension Grandle plugin version
We have developed an application with react native expo and when we upload the application to the google store the application freezes and does not run. After some research we tried to run our application with Android studio and we get the following error

“com.android.bundle.errors.EvalIssueException: The android Grandle plugin only kotlin-android extension Grandle plugin version. The following dependencies do not satisfy the required verssion:

Project ‘:expo’ -> org.jetbrain.kotlin:kotlin-grandle-plugin:1.6.10
”

The error is most probably occurred because the application is using expo and does not build react native in a native environment. Does any body know how we can solve this problem. Should we change from react native expo to bare react native?

We uploaded successfully the application to the google store and after we download it to our mobile phone, the application did not load and freezed in a white screen. Also the application does not run with android studio and we can not fix this problem.


问:
Template for Woocommerce Galery Carousel - Flex Control Thumbs
I need to place something right after this element exactly:

```<code><ol class="flex-control-nav flex-control-thumbs"></ol>
</code>```

It's standard Woocommerce product gallery carousel on single product page, under main thumbnail. I was trying to find this is product-image.php and product-thumbnails.php but it's not there, I tried in different places. I need to add custom action under it.

Body:
I need to place something right after this element exactly:

It's standard Woocommerce product gallery carousel on single product page, under main thumbnail. I was trying to find this is product-image.php and product-thumbnails.php but it's not there, I tried in different places. I need to add custom action under it.


问:
How to force display reference levels in glmer / plot_model?
I am using glmer to create a hierarchical mixed model, and plot_model to display the results as a forest plot.

```<code>hmdl <- glmer(asww ~ bwo + dx_year + psadx + agedec + (1 | practiceid/npi),
              data = mdata, family = binomial(link = "logit"), control = glmerControl(optimizer = "Nelder_Mead"))

plot_model(hmdl, title = "Predictors of active surveillance", axis.labels=labels,
           group.terms = c(1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 4, 4, 4, 4),
           axis.lim = c(0.7,4), colors="Set1")
</code>```

It all works fine, but reviewers of the paper have asked that the reference levels for the model be displayed on the plot. These of course are have OR 1.0, but I can't figure out a way to force these into the glmer output or into plot_model. Is this possible?

(Here's an example of the same question using the mtcars data, in which I would want to include the reference lines for OR=1.0 for cyl=4, gear=3, and carb=1:

```<code>carmodel <- glm(am ~ as.factor(cyl) + as.factor(gear) + as.factor(carb), data = mtcars)

plot_model(carmodel)
</code>```

Body:
I am using glmer to create a hierarchical mixed model, and plot_model to display the results as a forest plot.

hmdl <- glmer(asww ~ bwo + dx_year + psadx + agedec + (1 | practiceid/npi),
              data = mdata, family = binomial(link = "logit"), control = glmerControl(optimizer = "Nelder_Mead"))

plot_model(hmdl, title = "Predictors of active surveillance", axis.labels=labels,
           group.terms = c(1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 4, 4, 4, 4),
           axis.lim = c(0.7,4), colors="Set1")

It all works fine, but reviewers of the paper have asked that the reference levels for the model be displayed on the plot. These of course are have OR 1.0, but I can't figure out a way to force these into the glmer output or into plot_model. Is this possible?

(Here's an example of the same question using the mtcars data, in which I would want to include the reference lines for OR=1.0 for cyl=4, gear=3, and carb=1:

carmodel <- glm(am ~ as.factor(cyl) + as.factor(gear) + as.factor(carb), data = mtcars)

plot_model(carmodel)


问:
How can I stop Python from finishing while running a C# DLL program (API) with user input?
I've been browsing and couldn't find an answer to my question. Hopefully it's not too complicated because it might be multilayered... and I'm not an expert in Python(beginner) or C#(beginner-intermediate)!

What I'm trying to do is to use python and use a C# DLL which is an API that run another program. However, there are events in the DLL that asks for user input in the terminal. When I type something in the terminal, python ends because the python script finishes and the API calls gets interrupted and stops.

Here is a breakdown of what steps I took:

Use a C# DLL in my Python script via pythonnet and clr

```<code>import pythonnet
import clr
clr.AddReference("C:\path\to\dll\test.dll")
</code>```

Call a function from the DLL in Python

```<code>from Namespace1 import Class1
my_obj = FunctionFromTestDLL()
</code>```

C# DLL calls and runs an external program - and this is an API call

```<code>void FunctionFromTestDLL(out string userData)
{
    MyAPI_ = new MyAPI.CompanyAPI();
}
</code>```

Python script finishes and the C# call was disrupted. I fixed this by adding an input at the end of the script:

```<code>input("Don't close this until Program finishes running!\n")
</code>```

However, one of the DLL functions have an event handler, and that triggers a few times. However this event needs user input.

```<code>void UserInputEvent(out string userData)
{
    System.Console.WriteLine("What is your data? \n");
    userData = System.Console.ReadLine();
}
</code>```

I type my user input "cake" and the python script finishes and the C# call was disrupted again.

I want to be able to send user inputs back to C# because the external program will take those inputs for further processing.

I tried to look into importing subprocess but it doesn't seem like the right answer.

Edit: Thanks for the link. I'm not familiar with MCVE so hopefully this edit is better @CristiFati

Body:
I've been browsing and couldn't find an answer to my question. Hopefully it's not too complicated because it might be multilayered... and I'm not an expert in Python(beginner) or C#(beginner-intermediate)!

What I'm trying to do is to use python and use a C# DLL which is an API that run another program. However, there are events in the DLL that asks for user input in the terminal. When I type something in the terminal, python ends because the python script finishes and the API calls gets interrupted and stops.

Here is a breakdown of what steps I took:

Use a C# DLL in my Python script via pythonnet and clr

import pythonnet
import clr
clr.AddReference("C:\path\to\dll\test.dll")

Call a function from the DLL in Python

from Namespace1 import Class1
my_obj = FunctionFromTestDLL()

C# DLL calls and runs an external program - and this is an API call

void FunctionFromTestDLL(out string userData)
{
    MyAPI_ = new MyAPI.CompanyAPI();
}

Python script finishes and the C# call was disrupted. I fixed this by adding an input at the end of the script:

input("Don't close this until Program finishes running!\n")

However, one of the DLL functions have an event handler, and that triggers a few times. However this event needs user input.

void UserInputEvent(out string userData)
{
    System.Console.WriteLine("What is your data? \n");
    userData = System.Console.ReadLine();
}

I type my user input "cake" and the python script finishes and the C# call was disrupted again.

I want to be able to send user inputs back to C# because the external program will take those inputs for further processing.

I tried to look into importing subprocess but it doesn't seem like the right answer.

Edit: Thanks for the link. I'm not familiar with MCVE so hopefully this edit is better @CristiFati


问:
Firebase function not works on production, from IOS
I do a call to Firebase function from ios/swift.

```<code>let functions = Functions.functions()
func callWrapper(funcName: String, data: Any? = nil) async ->  [String: Any]? {
    do {
        let result = try await functions.httpsCallable(funcName).call(data)
        return result.data as? [String : Any]
    } catch {
        if let error = error as NSError? {
            if error.domain == FunctionsErrorDomain {
                let code = FunctionsErrorCode(rawValue: error.code)
                let message = error.localizedDescription
                let details = error.userInfo[FunctionsErrorDetailsKey]
            }
            //todo handle
            print(error)
        }
        return nil
    }
}
</code>```

I got next error.

2023-01-05 22:29:48.821609+0200 wallpapers[41492:641302] Task
<50374BAD-C312-450E-9770-B8300BE8FDB9>.<1> finished with error [-1007]
Error Domain=NSURLErrorDomain Code=-1007 "too many HTTP redirects"
UserInfo={NSLocalizedDescription=too many HTTP redirects,
NSErrorFailingURLStringKey=https://accounts.google.com/v3/signin/rejected?continue=https://uc.appengine.google.com/_ah/conflogin?state%3D~AJKiYcH_jc-hcv6OubZGrM13BmNN37rWX4x6rmTm7rZ4-Lqnr9Kk2C00oVNYR97TOiJ8lcR7vP91c9rv6o89HuwIlj85hxjrj63gbmu1jzGKzkU6S_kvHXv7yGdtaOWJnImTm02c6w9igKt3PbbWcawMsOafXEizRAd8jrT0jSe704DhXZ51m8IgAKv0kXxnblLuu3-DFmm-Uvi30sCPXIRGr_XG2DrMenI-zYGRjTiXf2uBVzIom7nVmKoCxIS7dGTvQozrDisq&dsh=S-1861899242:1672950586288679&flowEntry=ServiceLogin&flowName=WebLiteSignIn&ifkv=AeAAQh7QjO_naDvlYC2CVX-wduN9ft7CbGKMTlrMDHmAba7cHNPiDVDd4AQJzvAJgPnBpbS7sCeK0w&rhlk=no&rrk=32,
NSErrorFailingURLKey=https://accounts.google.com/v3/signin/rejected?continue=https://uc.appengine.google.com/_ah/conflogin?state%3D~AJKiYcH_jc-hcv6OubZGrM13BmNN37rWX4x6rmTm7rZ4-Lqnr9Kk2C00oVNYR97TOiJ8lcR7vP91c9rv6o89HuwIlj85hxjrj63gbmu1jzGKzkU6S_kvHXv7yGdtaOWJnImTm02c6w9igKt3PbbWcawMsOafXEizRAd8jrT0jSe704DhXZ51m8IgAKv0kXxnblLuu3-DFmm-Uvi30sCPXIRGr_XG2DrMenI-zYGRjTiXf2uBVzIom7nVmKoCxIS7dGTvQozrDisq&dsh=S-1861899242:1672950586288679&flowEntry=ServiceLogin&flowName=WebLiteSignIn&ifkv=AeAAQh7QjO_naDvlYC2CVX-wduN9ft7CbGKMTlrMDHmAba7cHNPiDVDd4AQJzvAJgPnBpbS7sCeK0w&rhlk=no&rrk=32,
_NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <50374BAD-C312-450E-9770-B8300BE8FDB9>.<1>" ), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <50374BAD-C312-450E-9770-B8300BE8FDB9>.<1>,
NSUnderlyingError=0x6000005f7c00 {Error Domain=kCFErrorDomainCFNetwork
Code=-1007 "(null)"}}.

If i run on local firebase simulator, it works fine

```<code>functions.useEmulator(withHost: "localhost", port: 5001)
</code>```

i assume, i call function anonymously, and this might be a problem hovewer i want to do it as anonymous unauthorized user. Is it possible somehow to allow function to be called from unauthorized user? Or how to fix this problem? Thanks

Body:
I do a call to Firebase function from ios/swift.

let functions = Functions.functions()
func callWrapper(funcName: String, data: Any? = nil) async ->  [String: Any]? {
    do {
        let result = try await functions.httpsCallable(funcName).call(data)
        return result.data as? [String : Any]
    } catch {
        if let error = error as NSError? {
            if error.domain == FunctionsErrorDomain {
                let code = FunctionsErrorCode(rawValue: error.code)
                let message = error.localizedDescription
                let details = error.userInfo[FunctionsErrorDetailsKey]
            }
            //todo handle
            print(error)
        }
        return nil
    }
}

I got next error.

2023-01-05 22:29:48.821609+0200 wallpapers[41492:641302] Task
<50374BAD-C312-450E-9770-B8300BE8FDB9>.<1> finished with error [-1007]
Error Domain=NSURLErrorDomain Code=-1007 "too many HTTP redirects"
UserInfo={NSLocalizedDescription=too many HTTP redirects,
NSErrorFailingURLStringKey=https://accounts.google.com/v3/signin/rejected?continue=https://uc.appengine.google.com/_ah/conflogin?state%3D~AJKiYcH_jc-hcv6OubZGrM13BmNN37rWX4x6rmTm7rZ4-Lqnr9Kk2C00oVNYR97TOiJ8lcR7vP91c9rv6o89HuwIlj85hxjrj63gbmu1jzGKzkU6S_kvHXv7yGdtaOWJnImTm02c6w9igKt3PbbWcawMsOafXEizRAd8jrT0jSe704DhXZ51m8IgAKv0kXxnblLuu3-DFmm-Uvi30sCPXIRGr_XG2DrMenI-zYGRjTiXf2uBVzIom7nVmKoCxIS7dGTvQozrDisq&dsh=S-1861899242:1672950586288679&flowEntry=ServiceLogin&flowName=WebLiteSignIn&ifkv=AeAAQh7QjO_naDvlYC2CVX-wduN9ft7CbGKMTlrMDHmAba7cHNPiDVDd4AQJzvAJgPnBpbS7sCeK0w&rhlk=no&rrk=32,
NSErrorFailingURLKey=https://accounts.google.com/v3/signin/rejected?continue=https://uc.appengine.google.com/_ah/conflogin?state%3D~AJKiYcH_jc-hcv6OubZGrM13BmNN37rWX4x6rmTm7rZ4-Lqnr9Kk2C00oVNYR97TOiJ8lcR7vP91c9rv6o89HuwIlj85hxjrj63gbmu1jzGKzkU6S_kvHXv7yGdtaOWJnImTm02c6w9igKt3PbbWcawMsOafXEizRAd8jrT0jSe704DhXZ51m8IgAKv0kXxnblLuu3-DFmm-Uvi30sCPXIRGr_XG2DrMenI-zYGRjTiXf2uBVzIom7nVmKoCxIS7dGTvQozrDisq&dsh=S-1861899242:1672950586288679&flowEntry=ServiceLogin&flowName=WebLiteSignIn&ifkv=AeAAQh7QjO_naDvlYC2CVX-wduN9ft7CbGKMTlrMDHmAba7cHNPiDVDd4AQJzvAJgPnBpbS7sCeK0w&rhlk=no&rrk=32,
_NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <50374BAD-C312-450E-9770-B8300BE8FDB9>.<1>" ), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <50374BAD-C312-450E-9770-B8300BE8FDB9>.<1>,
NSUnderlyingError=0x6000005f7c00 {Error Domain=kCFErrorDomainCFNetwork
Code=-1007 "(null)"}}.

If i run on local firebase simulator, it works fine

functions.useEmulator(withHost: "localhost", port: 5001)

i assume, i call function anonymously, and this might be a problem hovewer i want to do it as anonymous unauthorized user. Is it possible somehow to allow function to be called from unauthorized user? Or how to fix this problem? Thanks


问:
JIRA DC Scriptrunner - change the name of a custom field context
JIRA Data Center v9.x

using Scriptrunner, I can get the context name of a custom field

```<code>CustomField cField = customFieldManager.getCustomFieldObject(customFieldId)
List<FieldConfigScheme> contexts = cField.getConfigurationSchemes()
if ( contexts.size() == 1 ){
    FieldConfigScheme tmpContext = contexts[0]
    log.warn("tmpContext :: ${tmpContext.name}")
}
</code>```

I need to be able to change the context name!
The FieldConfigScheme class does not have a set...

I have looked through all the related classes I can find, and done Google searches, all to no avail.

is there a way to change the custom field context name using Scriptrunner?

That did the trick
This is what I got working!

```<code>def allCFIDs = customFieldManager.getCustomFieldObjects().collect({return it.getId()})
    allCFIDs.each { customFieldId ->
        CustomField cField =
            customFieldManager.getCustomFieldObject(customFieldId)
        List<FieldConfigScheme> contexts = cField.getConfigurationSchemes()
        FieldConfigScheme tmpContext = contexts[0]
        if ( tmpContext.name.contains("Fred") ){
            def newname = tmpContext.name + " Flintstone"
            log.warn("Rename Context:: ${tmpContext.name}    to ::  ${newname}")
            def schemeData = new SchemeBuilder( tmpContext )
            schemeData.setName( newname )
            def updatedScheme = schemeData.toFieldConfigScheme()
            fieldConfigSchemeManager.updateFieldConfigScheme( updatedScheme )
    }
}
</code>```

Body:
JIRA Data Center v9.x

using Scriptrunner, I can get the context name of a custom field

CustomField cField = customFieldManager.getCustomFieldObject(customFieldId)
List<FieldConfigScheme> contexts = cField.getConfigurationSchemes()
if ( contexts.size() == 1 ){
    FieldConfigScheme tmpContext = contexts[0]
    log.warn("tmpContext :: ${tmpContext.name}")
}

I need to be able to change the context name!
The FieldConfigScheme class does not have a set...

I have looked through all the related classes I can find, and done Google searches, all to no avail.

is there a way to change the custom field context name using Scriptrunner?

That did the trick
This is what I got working!

def allCFIDs = customFieldManager.getCustomFieldObjects().collect({return it.getId()})
    allCFIDs.each { customFieldId ->
        CustomField cField =
            customFieldManager.getCustomFieldObject(customFieldId)
        List<FieldConfigScheme> contexts = cField.getConfigurationSchemes()
        FieldConfigScheme tmpContext = contexts[0]
        if ( tmpContext.name.contains("Fred") ){
            def newname = tmpContext.name + " Flintstone"
            log.warn("Rename Context:: ${tmpContext.name}    to ::  ${newname}")
            def schemeData = new SchemeBuilder( tmpContext )
            schemeData.setName( newname )
            def updatedScheme = schemeData.toFieldConfigScheme()
            fieldConfigSchemeManager.updateFieldConfigScheme( updatedScheme )
    }
}


问:
upgrade gradle version with android studio
I have a old android studio project, the gradle version is 4.10.1. Today when I try to open it with androidstudio, I got below error:

```<code>cvc-complex-type.2.4.a: Invalid content was found starting with element 'base-extension'. One of '{layoutlib}' is expected.
</code>```

I am thinking the gradle 4.10.1 is tool old but how can I upgrade it to latest one?

Body:
I have a old android studio project, the gradle version is 4.10.1. Today when I try to open it with androidstudio, I got below error:

cvc-complex-type.2.4.a: Invalid content was found starting with element 'base-extension'. One of '{layoutlib}' is expected.

I am thinking the gradle 4.10.1 is tool old but how can I upgrade it to latest one?


问:
How do I run a command in a makefile to test all files and folders inside a folder?
I have such a project structure:

```<code>Makefile
server/
 -cmd
   -main
 -folder1
 -folder2
 ...
config
...
</code>```

If I go in the server folder and do:

```<code>go test ./... -cover
</code>```

then all folders and files are tested normally.

Now I don't understand how to write this command for Makefile.
I tried different combinations go test ./server/... -cover , go test ./server./... -cover

it all give out errors. Can you suggest the right command to put it in the Makefile to test the folder?

Body:
I have such a project structure:

Makefile
server/
 -cmd
   -main
 -folder1
 -folder2
 ...
config
...

If I go in the server folder and do:

go test ./... -cover

then all folders and files are tested normally.

Now I don't understand how to write this command for Makefile.
I tried different combinations go test ./server/... -cover , go test ./server./... -cover

it all give out errors. Can you suggest the right command to put it in the Makefile to test the folder?


问:
OpenCV VideoCapture.read() same frame has different values per pixel if running on different machines
I have a C++ project running on an old windows PC, I am trying to convert it to
Python and run it on an Ubuntu machine (a Jetson Nano). I started by
simply reading a frame from a grayscale video and writing it into a text file, and I expect the result to be identical, however for some reason  it's not. specifically on the Nano, some of the pixel values
are larger than on the Windows PC.

How is this possible? can this be because of the OpenCV version, or maybe the decoder VideoCapture.read() is using is different (is there a way to check that)? or am I missing something in the code?

Here is the C++ code:

```<code>#include <opencv2/opencv.hpp>
#include <stdio.h>
#include <fstream>

std::ofstream imagetest("image_test_cpp.txt");
int main(){
    cv::Mat img;
    cv::VideoCapture m_VideoCapture;
    m_VideoCapture.open("video.avi");
    m_VideoCapture.read(img);
    imagetest << img;
    return 0;
}
</code>```

Output:

```<code>[ 12,  15,  13,  12,  15,  13,  12,  15,  13,  14, ...
  12,  15,  13,  12,  15,  13,  13,  16,  14,  15, ...
  14,  17,  15,  14,  17,  15,  13,  16,  14,  14, ...
  ... ]
</code>```

And here is the Python code (maybe the way I write it to the file is wrong?):

```<code>import cv2
import numpy as np

image_test = open('image_test_py.txt', 'w')
cap = cv2.VideoCapture('video.avi')

img = cap.read()
np.savetxt('image_test_py.txt', img.reshape(img.shape[0], -1),fmt="%d")
</code>```

Output:

```<code>[ 12, 16, 12, 12, 16, 12, 12, 16, 12, 15, ... ]
</code>```

(The rows in the output files didn't match so I only put the start of the first one, but I think it's enough
to see the difference)

The frame I'm reading is this:
grayscale frame

Any help would be appreciated.

Body:
I have a C++ project running on an old windows PC, I am trying to convert it to
Python and run it on an Ubuntu machine (a Jetson Nano). I started by
simply reading a frame from a grayscale video and writing it into a text file, and I expect the result to be identical, however for some reason  it's not. specifically on the Nano, some of the pixel values
are larger than on the Windows PC.

How is this possible? can this be because of the OpenCV version, or maybe the decoder VideoCapture.read() is using is different (is there a way to check that)? or am I missing something in the code?

Here is the C++ code:

#include <opencv2/opencv.hpp>
#include <stdio.h>
#include <fstream>

std::ofstream imagetest("image_test_cpp.txt");
int main(){
    cv::Mat img;
    cv::VideoCapture m_VideoCapture;
    m_VideoCapture.open("video.avi");
    m_VideoCapture.read(img);
    imagetest << img;
    return 0;
}

Output:

[ 12,  15,  13,  12,  15,  13,  12,  15,  13,  14, ...
  12,  15,  13,  12,  15,  13,  13,  16,  14,  15, ...
  14,  17,  15,  14,  17,  15,  13,  16,  14,  14, ...
  ... ]

And here is the Python code (maybe the way I write it to the file is wrong?):

import cv2
import numpy as np

image_test = open('image_test_py.txt', 'w')
cap = cv2.VideoCapture('video.avi')

img = cap.read()
np.savetxt('image_test_py.txt', img.reshape(img.shape[0], -1),fmt="%d")

Output:

[ 12, 16, 12, 12, 16, 12, 12, 16, 12, 15, ... ]

(The rows in the output files didn't match so I only put the start of the first one, but I think it's enough
to see the difference)

The frame I'm reading is this:
grayscale frame

Any help would be appreciated.


问:
incompatible versions of the classes org.hibernate.cfg.AnnotationBinder and javax.persistence.JoinColumn
I have a maven springboot 2.7.3 project which I use with javax.persistence classes, spring data jpa and other dependencies. I'm getting an exception java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey;  which requires the action Correct the classpath of your application so that it contains compatible versions of the classes org.hibernate.cfg.AnnotationBinder and javax.persistence.JoinColumn

So what versions I should be using?

console output:

```<code>============================
CONDITIONS EVALUATION REPORT
============================

Positive matches:
-----------------

   AopAutoConfiguration matched:
      - @ConditionalOnProperty (spring.aop.auto=true) matched (OnPropertyCondition)

   AopAutoConfiguration.AspectJAutoProxyingConfiguration matched:
      - @ConditionalOnClass found required class 'org.aspectj.weaver.Advice' (OnClassCondition)

   AopAutoConfiguration.AspectJAutoProxyingConfiguration.CglibAutoProxyConfiguration matched:
      - @ConditionalOnProperty (spring.aop.proxy-target-class=true) matched (OnPropertyCondition)

   DataSourceAutoConfiguration matched:
      - @ConditionalOnClass found required classes 'javax.sql.DataSource', 'org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType' (OnClassCondition)
      - @ConditionalOnMissingBean (types: io.r2dbc.spi.ConnectionFactory; SearchStrategy: all) did not find any beans (OnBeanCondition)

   DataSourceAutoConfiguration.PooledDataSourceConfiguration matched:
      - AnyNestedCondition 1 matched 1 did not; NestedCondition on DataSourceAutoConfiguration.PooledDataSourceCondition.PooledDataSourceAvailable PooledDataSource found supported DataSource; NestedCondition on DataSourceAutoConfiguration.PooledDataSourceCondition.ExplicitType @ConditionalOnProperty (spring.datasource.type) did not find property 'type' (DataSourceAutoConfiguration.PooledDataSourceCondition)
      - @ConditionalOnMissingBean (types: javax.sql.DataSource,javax.sql.XADataSource; SearchStrategy: all) did not find any beans (OnBeanCondition)

2023-01-05 12:54:08.695 DEBUG 3716 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : Application failed to start due to an exception

java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey;
    at org.hibernate.cfg.AnnotationBinder.bindForeignKeyNameAndDefinition(AnnotationBinder.java:3505) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
    at org.hibernate.cfg.AnnotationBinder.bindManyToOne(AnnotationBinder.java:3115) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
    at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1822) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
    at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:968) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
    at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:793) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
    at org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl.processEntityHierarchies(AnnotationMetadataSourceProcessorImpl.java:225) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess$1.processEntityHierarchies(MetadataBuildingProcess.java:239) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:282) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1460) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1494) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58) ~[spring-orm-5.3.22.jar:5.3.22]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.3.22.jar:5.3.22]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[spring-orm-5.3.22.jar:5.3.22]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[spring-orm-5.3.22.jar:5.3.22]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) ~[spring-orm-5.3.22.jar:5.3.22]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.22.jar:5.3.22]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.22.jar:5.3.22]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.22.jar:5.3.22]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.22.jar:5.3.22]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.22.jar:5.3.22]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.22.jar:5.3.22]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.22.jar:5.3.22]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.22.jar:5.3.22]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) ~[spring-context-5.3.22.jar:5.3.22]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908) ~[spring-context-5.3.22.jar:5.3.22]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.22.jar:5.3.22]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.3.jar:2.7.3]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-2.7.3.jar:2.7.3]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.3.jar:2.7.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.7.3.jar:2.7.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-2.7.3.jar:2.7.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-2.7.3.jar:2.7.3]
    at com.example.partshop.PartShopApplication.main(PartShopApplication.java:9) ~[classes/:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.7.3.jar:2.7.3]

2023-01-05 12:54:08.696 ERROR 3716 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   :

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.hibernate.cfg.AnnotationBinder.bindForeignKeyNameAndDefinition(AnnotationBinder.java:3505)

The following method did not exist:

    javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey;

The calling method's class, org.hibernate.cfg.AnnotationBinder, was loaded from the following location:

    jar:file:/C:/Users/jzv0zq/.m2/repository/org/hibernate/hibernate-core/5.6.10.Final/hibernate-core-5.6.10.Final.jar!/org/hibernate/cfg/AnnotationBinder.class

The called method's class, javax.persistence.JoinColumn, is available from the following locations:

    jar:file:/C:/Users/jzv0zq/AppData/demo2/PartShop/lib/javax.persistence.jar!/javax/persistence/JoinColumn.class
    jar:file:/C:/Users/jzv0zq/.m2/repository/jakarta/persistence/jakarta.persistence-api/2.2.3/jakarta.persistence-api-2.2.3.jar!/javax/persistence/JoinColumn.class

The called method's class hierarchy was loaded from the following locations:

    javax.persistence.JoinColumn: file:/C:/Users/jzv0zq/AppData/demo2/PartShop/lib/javax.persistence.jar

Action:

Correct the classpath of your application so that it contains compatible versions of the classes org.hibernate.cfg.AnnotationBinder and javax.persistence.JoinColumn

Process finished with exit code 0

</code>```

My pom file

```<code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.3</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.partshop</groupId>
    <artifactId>PartShopApplication</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>PartShopApplication</name>
    <description>PartShopApplication</description>
    <properties>
        <java.version>11</java.version>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>
    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- spring mvc, rest -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!--
                <!– spring security –>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-security</artifactId>
                    <version>2.7.2</version>
                </dependency>

                <!– spring security test –>
                <dependency>
                    <groupId>org.springframework.security</groupId>
                    <artifactId>spring-security-test</artifactId>
                    <scope>test</scope>
                </dependency>
        -->

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

</code>```

Body:
I have a maven springboot 2.7.3 project which I use with javax.persistence classes, spring data jpa and other dependencies. I'm getting an exception java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey;  which requires the action Correct the classpath of your application so that it contains compatible versions of the classes org.hibernate.cfg.AnnotationBinder and javax.persistence.JoinColumn

So what versions I should be using?

console output:

============================
CONDITIONS EVALUATION REPORT
============================

Positive matches:
-----------------

   AopAutoConfiguration matched:
      - @ConditionalOnProperty (spring.aop.auto=true) matched (OnPropertyCondition)

   AopAutoConfiguration.AspectJAutoProxyingConfiguration matched:
      - @ConditionalOnClass found required class 'org.aspectj.weaver.Advice' (OnClassCondition)

   AopAutoConfiguration.AspectJAutoProxyingConfiguration.CglibAutoProxyConfiguration matched:
      - @ConditionalOnProperty (spring.aop.proxy-target-class=true) matched (OnPropertyCondition)

   DataSourceAutoConfiguration matched:
      - @ConditionalOnClass found required classes 'javax.sql.DataSource', 'org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType' (OnClassCondition)
      - @ConditionalOnMissingBean (types: io.r2dbc.spi.ConnectionFactory; SearchStrategy: all) did not find any beans (OnBeanCondition)

   DataSourceAutoConfiguration.PooledDataSourceConfiguration matched:
      - AnyNestedCondition 1 matched 1 did not; NestedCondition on DataSourceAutoConfiguration.PooledDataSourceCondition.PooledDataSourceAvailable PooledDataSource found supported DataSource; NestedCondition on DataSourceAutoConfiguration.PooledDataSourceCondition.ExplicitType @ConditionalOnProperty (spring.datasource.type) did not find property 'type' (DataSourceAutoConfiguration.PooledDataSourceCondition)
      - @ConditionalOnMissingBean (types: javax.sql.DataSource,javax.sql.XADataSource; SearchStrategy: all) did not find any beans (OnBeanCondition)

2023-01-05 12:54:08.695 DEBUG 3716 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : Application failed to start due to an exception

java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey;
    at org.hibernate.cfg.AnnotationBinder.bindForeignKeyNameAndDefinition(AnnotationBinder.java:3505) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
    at org.hibernate.cfg.AnnotationBinder.bindManyToOne(AnnotationBinder.java:3115) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
    at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1822) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
    at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:968) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
    at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:793) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
    at org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl.processEntityHierarchies(AnnotationMetadataSourceProcessorImpl.java:225) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess$1.processEntityHierarchies(MetadataBuildingProcess.java:239) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:282) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1460) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1494) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58) ~[spring-orm-5.3.22.jar:5.3.22]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.3.22.jar:5.3.22]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[spring-orm-5.3.22.jar:5.3.22]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[spring-orm-5.3.22.jar:5.3.22]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) ~[spring-orm-5.3.22.jar:5.3.22]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.22.jar:5.3.22]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.22.jar:5.3.22]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.22.jar:5.3.22]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.22.jar:5.3.22]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.22.jar:5.3.22]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.22.jar:5.3.22]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.22.jar:5.3.22]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.22.jar:5.3.22]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) ~[spring-context-5.3.22.jar:5.3.22]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908) ~[spring-context-5.3.22.jar:5.3.22]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.22.jar:5.3.22]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.3.jar:2.7.3]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-2.7.3.jar:2.7.3]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.3.jar:2.7.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.7.3.jar:2.7.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-2.7.3.jar:2.7.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-2.7.3.jar:2.7.3]
    at com.example.partshop.PartShopApplication.main(PartShopApplication.java:9) ~[classes/:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.7.3.jar:2.7.3]

2023-01-05 12:54:08.696 ERROR 3716 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   :

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.hibernate.cfg.AnnotationBinder.bindForeignKeyNameAndDefinition(AnnotationBinder.java:3505)

The following method did not exist:

    javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey;

The calling method's class, org.hibernate.cfg.AnnotationBinder, was loaded from the following location:

    jar:file:/C:/Users/jzv0zq/.m2/repository/org/hibernate/hibernate-core/5.6.10.Final/hibernate-core-5.6.10.Final.jar!/org/hibernate/cfg/AnnotationBinder.class

The called method's class, javax.persistence.JoinColumn, is available from the following locations:

    jar:file:/C:/Users/jzv0zq/AppData/demo2/PartShop/lib/javax.persistence.jar!/javax/persistence/JoinColumn.class
    jar:file:/C:/Users/jzv0zq/.m2/repository/jakarta/persistence/jakarta.persistence-api/2.2.3/jakarta.persistence-api-2.2.3.jar!/javax/persistence/JoinColumn.class

The called method's class hierarchy was loaded from the following locations:

    javax.persistence.JoinColumn: file:/C:/Users/jzv0zq/AppData/demo2/PartShop/lib/javax.persistence.jar

Action:

Correct the classpath of your application so that it contains compatible versions of the classes org.hibernate.cfg.AnnotationBinder and javax.persistence.JoinColumn

Process finished with exit code 0

My pom file

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.3</version>
        <relativePath/>
    </parent>
    <groupId>com.partshop</groupId>
    <artifactId>PartShopApplication</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>PartShopApplication</name>
    <description>PartShopApplication</description>
    <properties>
        <java.version>11</java.version>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>
    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>


问:
Conditional formatting based on date from cell
I'm trying to setup a conditional format that will highlight items based on a date within the packnumber range.

For example in the table below after within the packnumber range in Column A and after WM in column C anything after the date 2/3 (based on WM) I would like to highlight via conditional formatting.

EDIT:
Figured it out. I Created a second conditional format using the formula =AND(ISNUMBER(Q1),Q1<Q2) which is highlighting properly.

I was trying a formula like this but it's highlighting everything and I want it to only highligh the SF and TX items in the RetOne column. Any help would be greatly appreciated!

```<code>=COUNTIFS(A:A,A2)<>COUNTIFS(A:A,A2,AE:AE,0) & AND(ISNUMBER(Q2),Q2>Q3)
</code>```

Body:
I'm trying to setup a conditional format that will highlight items based on a date within the packnumber range.

For example in the table below after within the packnumber range in Column A and after WM in column C anything after the date 2/3 (based on WM) I would like to highlight via conditional formatting.

EDIT:
Figured it out. I Created a second conditional format using the formula =AND(ISNUMBER(Q1),Q1<Q2) which is highlighting properly.

I was trying a formula like this but it's highlighting everything and I want it to only highligh the SF and TX items in the RetOne column. Any help would be greatly appreciated!

=COUNTIFS(A:A,A2)<>COUNTIFS(A:A,A2,AE:AE,0) & AND(ISNUMBER(Q2),Q2>Q3)


问:
vectorising images using matrix multiplication
I want to apply the homography matrix (3x3) to an image in order to convert it in the frame of reference of another image. so to create a panorama effect. Currently I have a working code that involves a nested for loop which iterates over all the pixel array and applies the transform the the vector of 3x1 pixels.  I would like speed up the code and replace the nested for loop with a matrix multiplication so that multiply all the position indices  by the homography matrix in one go.

This is my current code:

```<code>
H = calcBestHomography(pts1b , pts3)

for i in range(im1.shape[1]):
    for j in range(im1.shape[0]):
        pt1 = np.array([i, j, 1])
        pt3 = H @ pt1.T
        px = int(pt3[0] / pt3[2])
        py = int(pt3[1] / pt3[2])
        if (px > 0 and px < im3.shape[1] and py> 0 and py < im3.shape[0]):
            im1[j , i , : ] = im3[py , px ,:]
</code>```

thank you

this is my current attempt but my main issue is that since the homography matrix is a 3x3 I cannot pass a matrix that has more than 3 columns

```<code>ax0 =  np.linspace(0, im1.shape[0]-1, im1.shape[0])
ax1 =  np.linspace(0, im1.shape[1]-1, im1.shape[1])
ax2 = np.ones((2740 , 880))
ax2_3d = np.expand_dims(ax2, axis=2)
pts1 = np.meshgrid(ax0 , ax1  )
pts1 = np.stack(pts1 , axis=-1)
result = np.concatenate((pts1, ax2_3d), axis=2)
pt3 = (result) @ H
px = (pt3[0] / pt3[2])
py = (pt3[1] / pt3[2])
</code>```

Body:
I want to apply the homography matrix (3x3) to an image in order to convert it in the frame of reference of another image. so to create a panorama effect. Currently I have a working code that involves a nested for loop which iterates over all the pixel array and applies the transform the the vector of 3x1 pixels.  I would like speed up the code and replace the nested for loop with a matrix multiplication so that multiply all the position indices  by the homography matrix in one go.

This is my current code:

H = calcBestHomography(pts1b , pts3)

for i in range(im1.shape[1]):
    for j in range(im1.shape[0]):
        pt1 = np.array([i, j, 1])
        pt3 = H @ pt1.T
        px = int(pt3[0] / pt3[2])
        py = int(pt3[1] / pt3[2])
        if (px > 0 and px < im3.shape[1] and py> 0 and py < im3.shape[0]):
            im1[j , i , : ] = im3[py , px ,:]

thank you

this is my current attempt but my main issue is that since the homography matrix is a 3x3 I cannot pass a matrix that has more than 3 columns

ax0 =  np.linspace(0, im1.shape[0]-1, im1.shape[0])
ax1 =  np.linspace(0, im1.shape[1]-1, im1.shape[1])
ax2 = np.ones((2740 , 880))
ax2_3d = np.expand_dims(ax2, axis=2)
pts1 = np.meshgrid(ax0 , ax1  )
pts1 = np.stack(pts1 , axis=-1)
result = np.concatenate((pts1, ax2_3d), axis=2)
pt3 = (result) @ H
px = (pt3[0] / pt3[2])
py = (pt3[1] / pt3[2])