问:
How to ignore a fitting iteration when there is NaN - lmfit
I ran into the problem of NaNs in one of the function evaluation during the fit and cannot complete fitting. I know that the source of NaNs come from evaluating xlogy() with a negative input. However, this happens because the fitting routine suddenly estimates parameter values that are very different from those of an iteration before. I am not sure how I can specify the min or max to the parameters because the negative value is produced as a result of two parameters in the linear background function (ax+b) and therefore the min and max are dependent on each other for the two parameters.

This is how I do the fitting:

```<code>Model = GaussianModel() + LinearModel()

mu = 20
sigma = 4
counts = 10
A = 10  # background value at mu
B = 9.5   # background value at mu+sigma
slope = (B-A)/sigma
b = A-slope*mu
x = np.arange(0, 40, step=0.5)

def poisson_loss(fit_param, datax, data, predict_model):
    print(f'fit param ==={fit_param.valuesdict()}')
    fit_model = predict_model.eval(
        x=datax, params=fit_param
    )

    #confirming the NaN output here
    if (np.array(fit_model<0)).sum()>0:
        print(f'HEREEEE---{xlogy(data, fit_model)}')
        plt.plot(datax,data,drawstyle="steps-mid")
        plt.plot(datax,fit_model)
    r = fit_model - xlogy(data, fit_model)
    return r

prms = Parameters()
prms.update(Model.make_params())
prms["slope"].set(value=slope, max=0)
prms["intercept"].set(value=b, min=0)  # ,max=b*3)
prms["amplitude"].set(value=counts, min=0)
prms["center"].set(value=mu, vary=False)
prms["sigma"].set(value=sigma, min=0)  # ,max=sigma*5)

mini_poisson = Minimizer(
    poisson_loss,
    prms,
    fcn_args=(x,),
    fcn_kws={"data": sample_spectra, "predict_model": Model},
)
result_poisson = mini_poisson.minimize()
</code>```

The plotting part of poisson_loss() produces this plot:

The print out from poisson_loss() and the error message is this:

You can see that the parameters when NaNs show up are very different from the previous evaluations.
I think I might be able to avoid this by skipping the function iteration when there is an NaN value, but I need help how to do this (if this is a good idea). Or, if there is any way that I can fix my code so that the fitting would not produce such huge difference in estimating of parameters suddenly, that might work, too. If anyone has an idea of how I can work around this to get the fit, I would appreciate it a lot! Thank you.

Body:
I ran into the problem of NaNs in one of the function evaluation during the fit and cannot complete fitting. I know that the source of NaNs come from evaluating xlogy() with a negative input. However, this happens because the fitting routine suddenly estimates parameter values that are very different from those of an iteration before. I am not sure how I can specify the min or max to the parameters because the negative value is produced as a result of two parameters in the linear background function (ax+b) and therefore the min and max are dependent on each other for the two parameters.

This is how I do the fitting:

Model = GaussianModel() + LinearModel()

mu = 20
sigma = 4
counts = 10
A = 10  # background value at mu
B = 9.5   # background value at mu+sigma
slope = (B-A)/sigma
b = A-slope*mu
x = np.arange(0, 40, step=0.5)

def poisson_loss(fit_param, datax, data, predict_model):
    print(f'fit param ==={fit_param.valuesdict()}')
    fit_model = predict_model.eval(
        x=datax, params=fit_param
    )

    #confirming the NaN output here
    if (np.array(fit_model<0)).sum()>0:
        print(f'HEREEEE---{xlogy(data, fit_model)}')
        plt.plot(datax,data,drawstyle="steps-mid")
        plt.plot(datax,fit_model)
    r = fit_model - xlogy(data, fit_model)
    return r

prms = Parameters()
prms.update(Model.make_params())
prms["slope"].set(value=slope, max=0)
prms["intercept"].set(value=b, min=0)  # ,max=b*3)
prms["amplitude"].set(value=counts, min=0)
prms["center"].set(value=mu, vary=False)
prms["sigma"].set(value=sigma, min=0)  # ,max=sigma*5)

mini_poisson = Minimizer(
    poisson_loss,
    prms,
    fcn_args=(x,),
    fcn_kws={"data": sample_spectra, "predict_model": Model},
)
result_poisson = mini_poisson.minimize()

The plotting part of poisson_loss() produces this plot:

The print out from poisson_loss() and the error message is this:

You can see that the parameters when NaNs show up are very different from the previous evaluations.
I think I might be able to avoid this by skipping the function iteration when there is an NaN value, but I need help how to do this (if this is a good idea). Or, if there is any way that I can fix my code so that the fitting would not produce such huge difference in estimating of parameters suddenly, that might work, too. If anyone has an idea of how I can work around this to get the fit, I would appreciate it a lot! Thank you.


来源: stackexchange

问:
Change the static text caption of a CMFCRibbonEdit dynamically using MFC (Microsoft Foundation Class) and C++
I'm having trouble trying to update the caption (text element) of an Edit box in MFC.

Below. is what I currently tried. I know I am grabbing the correct element because I can see that the tooltip has changed. The caption text next to the edit box just changes to blank

*Update: After further collaboration with a senior programmer, we've found this is most likely an MFC bug. I'd love to be proven wrong though because the work-around involves splitting the edit box into a label and a box, which is less than ideal due to alignment issues.

```<code>CMFCRibbonBaseElement* pEditBox = (CMFCRibbonBaseElement*)m_wndRibbon.FindByID(EDIT_BOX_ID);
pEditBox->SetText(_T("new Text"));
pEditBox->SetToolTipText(_T("tool tip text"));
</code>```

I can also see using the debugger that m_strText, which in this case is the caption, is being changed. Am I missing a step where I need to re-render the text for it to show up? The only thing I could think of was calling pEditBox->Redraw(); after setting the text, but this did nothing.

The other approach I tried below was to use SetText in an update function, but this just changes the text in the box, not the title. I thought this might work because I was able to change the text next to a checkbox using this approach.

```<code>ON_UPDATE_COMMAND_UI(EDIT_BOX_ID, &CMyDoc::OnUpdateEditBoxText);

void CMyDoc::OnUpdateEditBoxText(CCmdUI *pCmdUI)
{
 if (//my condition)
    pCmdUI->SetText(_T("new Text"));
}
</code>```

Another approach I could take is just having the box disappear but pEditBox->SetVisible(FALSE); doesn't work for this edit box either.

ContentLicense: CC BY-SA 4.0

Body:
I'm having trouble trying to update the caption (text element) of an Edit box in MFC.

Below. is what I currently tried. I know I am grabbing the correct element because I can see that the tooltip has changed. The caption text next to the edit box just changes to blank

*Update: After further collaboration with a senior programmer, we've found this is most likely an MFC bug. I'd love to be proven wrong though because the work-around involves splitting the edit box into a label and a box, which is less than ideal due to alignment issues.

CMFCRibbonBaseElement* pEditBox = (CMFCRibbonBaseElement*)m_wndRibbon.FindByID(EDIT_BOX_ID);
pEditBox->SetText(_T("new Text"));
pEditBox->SetToolTipText(_T("tool tip text"));

I can also see using the debugger that m_strText, which in this case is the caption, is being changed. Am I missing a step where I need to re-render the text for it to show up? The only thing I could think of was calling pEditBox->Redraw(); after setting the text, but this did nothing.

The other approach I tried below was to use SetText in an update function, but this just changes the text in the box, not the title. I thought this might work because I was able to change the text next to a checkbox using this approach.

ON_UPDATE_COMMAND_UI(EDIT_BOX_ID, &CMyDoc::OnUpdateEditBoxText);

void CMyDoc::OnUpdateEditBoxText(CCmdUI *pCmdUI)
{
 if (//my condition)
    pCmdUI->SetText(_T("new Text"));
}

Another approach I could take is just having the box disappear but pEditBox->SetVisible(FALSE); doesn't work for this edit box either.


问:
Why in codeignitor 3 mysqli update query taking more then 20 seconds
while debugging when I reach on this point it took some time more then minute.

```<code>$this->db->where('userid', $userid);
        $this->db->update('tbluser', ['activity' => date('Y-m-d H:i:s')]);
</code>```

I have executed same update query string in phpmyadmin and it took 0.0005 seconds. Don't know why it is like that, anyone help will be greatly appreciated

Body:
while debugging when I reach on this point it took some time more then minute.

$this->db->where('userid', $userid);
        $this->db->update('tbluser', ['activity' => date('Y-m-d H:i:s')]);

I have executed same update query string in phpmyadmin and it took 0.0005 seconds. Don't know why it is like that, anyone help will be greatly appreciated


问:
running .dll from Python yields error: please enable loadFromRemoteSources switch
I have installed the pythonnet package using pip install pythonnet for the purposes of capturing the output from a .dll file I have been provided. The .dll makes an API call. To run the .dll through python, I have this code:

```<code>import clr
clr.AddReference('myfile')
</code>```

Running this yields the error:

System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.

I am unsure of how to proceed, as I am unfamiliar with C# and .dll files. I am also provided with myfile.deps.json, myfile.runtimeconfig.json, myfile.exe and myfile.pdb

How can I run this in Python?

Body:
I have installed the pythonnet package using pip install pythonnet for the purposes of capturing the output from a .dll file I have been provided. The .dll makes an API call. To run the .dll through python, I have this code:

import clr
clr.AddReference('myfile')

Running this yields the error:

System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.

I am unsure of how to proceed, as I am unfamiliar with C# and .dll files. I am also provided with myfile.deps.json, myfile.runtimeconfig.json, myfile.exe and myfile.pdb

How can I run this in Python?


问:
How to display my custom status bar in android?
Recently I came across an android application nameed StatusBar+ from the market. It is a custom status bar which remains on top even in case of full screen apps.

I want to know how can we show the status bar even in full screen apps.

ContentLicense: CC BY-SA 3.0


问:
Drawing the solution to the Hanoi Tower problem using a recursive code
I've got an assignment to make a program (in which you can type the amount of discs) that solves the Towers of Hanoi and draws(prints) every step of the solution.

what i've tried is using a basic recursive code:

```<code>def hanoi(n, pocz:list, dopol:list, fin:list):
    if n > 0:
        hanoi(n-1, pocz, fin, dopol)
        fin.insert(0, pocz.pop(0))
        print(f'{pier},{drug},{trz}')
        hanoi(n-1, dopol, pocz, fin)
pier=[1,2,3,4]
drug=[]
trz=[]
print(f'{pier},{drug},{trz}')
hanoi(t,pier,drug,trz)
</code>```

which gives me the solution steps in numbers:

```<code>[1, 2, 3, 4],[],[]
[2, 3, 4],[1],[]
[3, 4],[1],[2]
[3, 4],[],[1, 2]
. . .
[2],[1],[3, 4]
[],[1],[2, 3, 4]
[],[],[1, 2, 3, 4]
</code>```

what I need is for the program to output
something like this:

what i've tried doing is inserting different algorithms into the middle of the recursion to either make additional lists and work with them later, or using the amount and the number of disks do the printing in the function itself, but they would either mess up the function itself, or get overwritten later on.

Body:
I've got an assignment to make a program (in which you can type the amount of discs) that solves the Towers of Hanoi and draws(prints) every step of the solution.

what i've tried is using a basic recursive code:

def hanoi(n, pocz:list, dopol:list, fin:list):
    if n > 0:
        hanoi(n-1, pocz, fin, dopol)
        fin.insert(0, pocz.pop(0))
        print(f'{pier},{drug},{trz}')
        hanoi(n-1, dopol, pocz, fin)
pier=[1,2,3,4]
drug=[]
trz=[]
print(f'{pier},{drug},{trz}')
hanoi(t,pier,drug,trz)

which gives me the solution steps in numbers:

[1, 2, 3, 4],[],[]
[2, 3, 4],[1],[]
[3, 4],[1],[2]
[3, 4],[],[1, 2]
. . .
[2],[1],[3, 4]
[],[1],[2, 3, 4]
[],[],[1, 2, 3, 4]

what I need is for the program to output
something like this:

what i've tried doing is inserting different algorithms into the middle of the recursion to either make additional lists and work with them later, or using the amount and the number of disks do the printing in the function itself, but they would either mess up the function itself, or get overwritten later on.


问:
pip not working on a windows 11 home computer
I'm using python 3.10.9 and the pip is not working it gives me a error saying

```<code>C:\Users\udayv>pip
Fatal error in launcher: Unable to create process using '"c:\users\udayv\appdata\local\programs\python\python37\python.exe"  "C:\Users\udayv\AppData\Local\Programs\Python\Python37\Scripts\pip.exe" ': The system cannot find the file specified.
</code>```

Please help.

I was trying to install python packages put no pip command would work.
I tried reinstalling python and it still did not work sadly.

Body:
I'm using python 3.10.9 and the pip is not working it gives me a error saying

C:\Users\udayv>pip
Fatal error in launcher: Unable to create process using '"c:\users\udayv\appdata\local\programs\python\python37\python.exe"  "C:\Users\udayv\AppData\Local\Programs\Python\Python37\Scripts\pip.exe" ': The system cannot find the file specified.

Please help.

I was trying to install python packages put no pip command would work.
I tried reinstalling python and it still did not work sadly.


问:
How to add a local project as a dependency to another project in Intellij IDEA
I have two projects that I am developing using Intellij IDEA and Gradle. Project A depends on project B, but I cannot get the dependency working.

After I add project B as a module of project A, Intellij tells me to add project B as a dependency, so I do that, but when I build it, it throws a circular dependency error.

How can I get project A to depend on project B?


问:
How do I add extra functions to a mock and have it pass typescript?
I have a mock for @react-native-community/netinfo but I want to expand it so that I have an extra function that I can call to update the mock data.  e.g. setConnectionState but if I do the following

```<code>import NetInfo, {
  NetInfoState,
  NetInfoStateType,
  setConnectionState,
} from '@react-native-community/netinfo';
</code>```

it fails typescript.

How would I code it so that the mock will allow additional functionality that is not present in the original type?

The mock

The test

I know I can add the following to make it pass TypeScript but I want the scope of usage to only be on Jest

```<code>declare module '@react-native-community/netinfo' {
  export function resetConnectionState(): void;
  export function setConnectionState(next: NetInfoState): void;
}
</code>```

Body:
I have a mock for @react-native-community/netinfo but I want to expand it so that I have an extra function that I can call to update the mock data.  e.g. setConnectionState but if I do the following

import NetInfo, {
  NetInfoState,
  NetInfoStateType,
  setConnectionState,
} from '@react-native-community/netinfo';

it fails typescript.

How would I code it so that the mock will allow additional functionality that is not present in the original type?

The mock

The test

I know I can add the following to make it pass TypeScript but I want the scope of usage to only be on Jest

declare module '@react-native-community/netinfo' {
  export function resetConnectionState(): void;
  export function setConnectionState(next: NetInfoState): void;
}


问:
Ball sprite won't bounce off rectangles. Need to know how to make rectangles disappear
I have a ball sprite that is generated via generateSprite(); and also a platform sprite that is generated the same way. I need to make the ball bounce off the platform. This is a breakout style game so I have rectangles that are NOT sprites that the ball needs to hit, bounce off of and make them disappear. How would I do this?

To make the ball bounce off the platform this is what I tried:

```<code> ballvx = 2;
    ballvy = 2;
    ballx += ballvx;
    bally += ballvy;
   if (ballx > platformx && ballx < platformx + 200 && bally > platformy) {
    if (bally < platformy + 20) {
      ballvy *= -1;
    } else {
      ballvx *= -1;
    }
  }
    if (ballx < 0 || ballx > width) {
      ballvx *= -1;
    }
    if (bally < 0 || bally > height) {
      state=LOSE;
    }
</code>```

The problem here is that the ball simply goes straight through the platform instead of bouncing off of it.

For the rectangles I have no idea how to make them both disappear and have the ball bounce off them at the same time. Here is the code for the rectangles:

```<code>fill(r, g, b);
    rect(width*.01, height/28, w, h);
    fill(r, g, b);
    rect(width*.128, height/28, w, h);
    fill(r, g, b);
    rect(width*.25, height/28, w, h);
    fill(r, g, b);
    rect(width*.35, height/28, w, h);
    fill(r, g, b);
    rect(width*.45, height/28, w, h);
    fill(r, g, b);
    rect(width*.55, height/28, w, h);
    fill(r, g, b);
    rect(width*.65, height/28, w, h);
    fill(r, g, b);
    rect(width*.75, height/28, w, h);
    fill(r, g, b);
    rect(width*.85, height/28, w, h);
    fill(r, g, b);
    rect(width*.95, height/28, w, h);
    fill(r, g, b);
    rect(width*.01, height/4, w, h);
    fill(r, g, b);
    rect(width*.128, height/4, w, h);
    fill(r, g, b);
    rect(width*.25, height/4, w, h);
    fill(r, g, b);
    rect(width*.35, height/4, w, h);
    fill(r, g, b);
    rect(width*.45, height/4, w, h);
    fill(r, g, b);
    rect(width*.55, height/4, w, h);
    fill(r, g, b);
    rect(width*.65, height/4, w, h);
    fill(r, g, b);
    rect(width*.75, height/4, w, h);
    fill(r, g, b);
    rect(width*.85, height/4, w, h);
    fill(r, g, b);
    rect(width*.95, height/4, w, h);
</code>```

Body:
I have a ball sprite that is generated via generateSprite(); and also a platform sprite that is generated the same way. I need to make the ball bounce off the platform. This is a breakout style game so I have rectangles that are NOT sprites that the ball needs to hit, bounce off of and make them disappear. How would I do this?

To make the ball bounce off the platform this is what I tried:

 ballvx = 2;
    ballvy = 2;
    ballx += ballvx;
    bally += ballvy;
   if (ballx > platformx && ballx < platformx + 200 && bally > platformy) {
    if (bally < platformy + 20) {
      ballvy *= -1;
    } else {
      ballvx *= -1;
    }
  }
    if (ballx < 0 || ballx > width) {
      ballvx *= -1;
    }
    if (bally < 0 || bally > height) {
      state=LOSE;
    }

The problem here is that the ball simply goes straight through the platform instead of bouncing off of it.

For the rectangles I have no idea how to make them both disappear and have the ball bounce off them at the same time. Here is the code for the rectangles:

fill(r, g, b);
    rect(width*.01, height/28, w, h);
    fill(r, g, b);
    rect(width*.128, height/28, w, h);
    fill(r, g, b);
    rect(width*.25, height/28, w, h);
    fill(r, g, b);
    rect(width*.35, height/28, w, h);
    fill(r, g, b);
    rect(width*.45, height/28, w, h);
    fill(r, g, b);
    rect(width*.55, height/28, w, h);
    fill(r, g, b);
    rect(width*.65, height/28, w, h);
    fill(r, g, b);
    rect(width*.75, height/28, w, h);
    fill(r, g, b);
    rect(width*.85, height/28, w, h);
    fill(r, g, b);
    rect(width*.95, height/28, w, h);
    fill(r, g, b);
    rect(width*.01, height/4, w, h);
    fill(r, g, b);
    rect(width*.128, height/4, w, h);
    fill(r, g, b);
    rect(width*.25, height/4, w, h);
    fill(r, g, b);
    rect(width*.35, height/4, w, h);
    fill(r, g, b);
    rect(width*.45, height/4, w, h);
    fill(r, g, b);
    rect(width*.55, height/4, w, h);
    fill(r, g, b);
    rect(width*.65, height/4, w, h);
    fill(r, g, b);
    rect(width*.75, height/4, w, h);
    fill(r, g, b);
    rect(width*.85, height/4, w, h);
    fill(r, g, b);
    rect(width*.95, height/4, w, h);


问:
Why event is not added to Android Calendar?
I am developing an app that allows users to add events to their calendar. However, I am experiencing an issue where the events are not being added as expected. When I try to add an event, the app seems to freeze and the event is not added to the calendar. I have tried several different approaches to fix this issue, but none of them seem to be working. Can someone please help me understand what might be causing this issue and how I can fix it?"

In this example, you have provided a brief overview of the problem you are experiencing and some of the steps you have already taken to try and fix it. By including details like the specific actions you are taking and the results you are seeing, you can help others understand the problem and potentially offer suggestions for a solution.

I have taken permission.

Here is my code snippet

```<code>private fun addEventAndReminder(calendar: Calendar) {
    try {
        val calID: Long = 3
        val startMillis: Long = Calendar.getInstance().run {
            set(
                calendar.get(Calendar.YEAR),
                calendar.get(Calendar.MONTH),
                calendar.get(Calendar.DAY_OF_MONTH),
                8,
                0
            )
            timeInMillis
        }
        val endMillis: Long = Calendar.getInstance().run {
            set(
                calendar.get(Calendar.YEAR),
                calendar.get(Calendar.MONTH),
                calendar.get(Calendar.DAY_OF_MONTH),
                9,
                0
            )
            timeInMillis
        }

        Log.d(
            TAG,
            "addEventAndReminder: ${startMillis.convertLongToTime("dd/MM/yyyy hh:mm a")}"
        )
        Log.d(TAG, "addEventAndReminder: ${endMillis.convertLongToTime("dd/MM/yyyy hh:mm a")}")

        val values = ContentValues().apply {
            put(CalendarContract.Events.DTSTART, startMillis)
            put(CalendarContract.Events.DTEND, endMillis)
            put(CalendarContract.Events.TITLE, "BOok Reminder")
            put(CalendarContract.Events.DESCRIPTION, "Reminder for book")
            put(CalendarContract.Events.CALENDAR_ID, calID)
            put(CalendarContract.Events.EVENT_TIMEZONE, TimeZone.getDefault().id)
            put(CalendarContract.Events.ALL_DAY, false)
            put(CalendarContract.Events.HAS_ALARM, true)
            put(CalendarContract.Events.CUSTOM_APP_PACKAGE, requireContext().packageName)

        }
        val uri: Uri? =
            requireContext().contentResolver.insert(CalendarContract.Events.CONTENT_URI, values)
        val eventID: Long = uri?.lastPathSegment?.toLong() ?: -1
        // check event is added or not
        if (eventID > 0) {
            Log.d(TAG, "addEventAndReminder: Event added")
        } else {
            Log.d(TAG, "addEventAndReminder: Event not added")
        }

        val reminderValues = ContentValues().apply {
            put(CalendarContract.Reminders.EVENT_ID, eventID)
            put(CalendarContract.Reminders.METHOD, CalendarContract.Reminders.METHOD_ALERT)
            put(CalendarContract.Reminders.MINUTES, 5)
        }
        val remainder: Uri? = requireContext().contentResolver.insert(
            CalendarContract.Reminders.CONTENT_URI,
            reminderValues
        )

        Log.d(TAG, "addEventAndReminder: $eventID $remainder ")

    } catch (e: Exception) {
        Log.e(TAG, "addEventAndReminder: $e")
    }
}
</code>```

Getting solution of about code snippets

Body:
I am developing an app that allows users to add events to their calendar. However, I am experiencing an issue where the events are not being added as expected. When I try to add an event, the app seems to freeze and the event is not added to the calendar. I have tried several different approaches to fix this issue, but none of them seem to be working. Can someone please help me understand what might be causing this issue and how I can fix it?"

In this example, you have provided a brief overview of the problem you are experiencing and some of the steps you have already taken to try and fix it. By including details like the specific actions you are taking and the results you are seeing, you can help others understand the problem and potentially offer suggestions for a solution.

I have taken permission.

Here is my code snippet

private fun addEventAndReminder(calendar: Calendar) {
    try {
        val calID: Long = 3
        val startMillis: Long = Calendar.getInstance().run {
            set(
                calendar.get(Calendar.YEAR),
                calendar.get(Calendar.MONTH),
                calendar.get(Calendar.DAY_OF_MONTH),
                8,
                0
            )
            timeInMillis
        }
        val endMillis: Long = Calendar.getInstance().run {
            set(
                calendar.get(Calendar.YEAR),
                calendar.get(Calendar.MONTH),
                calendar.get(Calendar.DAY_OF_MONTH),
                9,
                0
            )
            timeInMillis
        }

        Log.d(
            TAG,
            "addEventAndReminder: ${startMillis.convertLongToTime("dd/MM/yyyy hh:mm a")}"
        )
        Log.d(TAG, "addEventAndReminder: ${endMillis.convertLongToTime("dd/MM/yyyy hh:mm a")}")

        val values = ContentValues().apply {
            put(CalendarContract.Events.DTSTART, startMillis)
            put(CalendarContract.Events.DTEND, endMillis)
            put(CalendarContract.Events.TITLE, "BOok Reminder")
            put(CalendarContract.Events.DESCRIPTION, "Reminder for book")
            put(CalendarContract.Events.CALENDAR_ID, calID)
            put(CalendarContract.Events.EVENT_TIMEZONE, TimeZone.getDefault().id)
            put(CalendarContract.Events.ALL_DAY, false)
            put(CalendarContract.Events.HAS_ALARM, true)
            put(CalendarContract.Events.CUSTOM_APP_PACKAGE, requireContext().packageName)

        }
        val uri: Uri? =
            requireContext().contentResolver.insert(CalendarContract.Events.CONTENT_URI, values)
        val eventID: Long = uri?.lastPathSegment?.toLong() ?: -1
        // check event is added or not
        if (eventID > 0) {
            Log.d(TAG, "addEventAndReminder: Event added")
        } else {
            Log.d(TAG, "addEventAndReminder: Event not added")
        }

        val reminderValues = ContentValues().apply {
            put(CalendarContract.Reminders.EVENT_ID, eventID)
            put(CalendarContract.Reminders.METHOD, CalendarContract.Reminders.METHOD_ALERT)
            put(CalendarContract.Reminders.MINUTES, 5)
        }
        val remainder: Uri? = requireContext().contentResolver.insert(
            CalendarContract.Reminders.CONTENT_URI,
            reminderValues
        )

        Log.d(TAG, "addEventAndReminder: $eventID $remainder ")

    } catch (e: Exception) {
        Log.e(TAG, "addEventAndReminder: $e")
    }
}

Getting solution of about code snippets


问:
how to add React ToolKit Query to existing app?
I have a website that is using react redux toolkit, but now I want to migrate it to RTK query, because it has some options like caching, etc, so, I have this endpoint:
/products, that is returning this:

```<code>[
  {
    "id": "1",
    "name": "T-shirt z",
    "price": 15.09,
    "description": "",
    "imageURL": "https://live.staticflickr.com/7013/6612824761_3f66a93c71_b.jpg"
  },
  {
    "id": "2",
    "name": "T-shirt x",
    "price": 25.99,
    "description": "",
    "imageURL": "https://cdn.shopify.com/s/files/1/0386/0293/2356/products/image_2c5617fb-89a7-4d04-9bfb-f0c0dcd28f6d_590x.jpg?v=1612476249"
  },
  ...
  ....
]
</code>```

api/products.ts

```<code>import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";
import type { Product } from "../app/api";

export interface ProductsState {
  products: { [id: string]: Product };
}

///and also I don't know how to set the initial state
const initialState: ProductsState = {
  products: {},
};

// Define a service using a base URL and expected endpoints
export const productsApi = createApi({
  reducerPath: "productsApi",
  baseQuery: fetchBaseQuery({ baseUrl: "/" }),
  endpoints: (builder) => ({
    getProducts: builder.query<Product[], string>({
      query: () => "/products",
      transformResponse: (response: Product[]) : ProductsState => // here is an error
        {
          return {
            products: response.reduce((acc, curr) => {
              acc[curr.id] = curr; // here is an error
              return acc;
            }, {});
          }
        }
    }),
  }),
});
</code>```

app/api.ts

```<code>export interface Product {
  id: string;
  name: string;
  price: number;
  description: string;
  imageURL: string;
}

....
...
</code>```

I want to transform the result of the api, to this:

```<code> {
    products:{
    "1": {
        "id": "1",
        "name": "T-shirt z",
        "price": 15.09,
        "description": "",
        "imageURL": "https://live.staticflickr.com/7013/6612824761_3f66a93c71_b.jpg"
      },
    "2":{
        "id": "2",
        "name": "T-shirt x",
        "price": 25.99,
        "description": "",
        "imageURL": "https://cdn.shopify.com/s/files/1/0386/0293/2356/products/image_2c5617fb-89a7-4d04-9bfb-f0c0dcd28f6d_590x.jpg?v=1612476249"
      }
    }
    }
</code>```

In the transformResponse method I get this typescript error:

```<code>Type '(response: Product[]) => ProductsState' is not assignable to type '(baseQueryReturnValue: unknown, meta: FetchBaseQueryMeta |
</code>```

undefined, arg: string) => Product[] | Promise<Product[]>'.
Type 'ProductsState' is not assignable to type 'Product[] | Promise<Product[]>'.ts(2322)
endpointDefinitions.d.ts(41, 5): The expected type comes from property 'transformResponse' which is declared here on type
'Omit<EndpointDefinitionWithQuery<string, BaseQueryFn<string |
FetchArgs, unknown, FetchBaseQueryError, {}, FetchBaseQueryMeta>,
Product[]> & { ...; } & { ...; } & QueryExtraOptions<...>, "type"> |
Omit<...>'

and here acc[curr.id] , I get this typescript error:

(parameter) curr: Product Element implicitly has an 'any' type because
expression of type 'string' can't be used to index type '{}'.   No
index signature with a parameter of type 'string' was found on type

What can I do? thank you.

Body:
I have a website that is using react redux toolkit, but now I want to migrate it to RTK query, because it has some options like caching, etc, so, I have this endpoint:
/products, that is returning this:

[
  {
    "id": "1",
    "name": "T-shirt z",
    "price": 15.09,
    "description": "",
    "imageURL": "https://live.staticflickr.com/7013/6612824761_3f66a93c71_b.jpg"
  },
  {
    "id": "2",
    "name": "T-shirt x",
    "price": 25.99,
    "description": "",
    "imageURL": "https://cdn.shopify.com/s/files/1/0386/0293/2356/products/image_2c5617fb-89a7-4d04-9bfb-f0c0dcd28f6d_590x.jpg?v=1612476249"
  },
  ...
  ....
]

api/products.ts

import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";
import type { Product } from "../app/api";

export interface ProductsState {
  products: { [id: string]: Product };
}

///and also I don't know how to set the initial state
const initialState: ProductsState = {
  products: {},
};

// Define a service using a base URL and expected endpoints
export const productsApi = createApi({
  reducerPath: "productsApi",
  baseQuery: fetchBaseQuery({ baseUrl: "/" }),
  endpoints: (builder) => ({
    getProducts: builder.query<Product[], string>({
      query: () => "/products",
      transformResponse: (response: Product[]) : ProductsState => // here is an error
        {
          return {
            products: response.reduce((acc, curr) => {
              acc[curr.id] = curr; // here is an error
              return acc;
            }, {});
          }
        }
    }),
  }),
});

app/api.ts

export interface Product {
  id: string;
  name: string;
  price: number;
  description: string;
  imageURL: string;
}

....
...

I want to transform the result of the api, to this:

 {
    products:{
    "1": {
        "id": "1",
        "name": "T-shirt z",
        "price": 15.09,
        "description": "",
        "imageURL": "https://live.staticflickr.com/7013/6612824761_3f66a93c71_b.jpg"
      },
    "2":{
        "id": "2",
        "name": "T-shirt x",
        "price": 25.99,
        "description": "",
        "imageURL": "https://cdn.shopify.com/s/files/1/0386/0293/2356/products/image_2c5617fb-89a7-4d04-9bfb-f0c0dcd28f6d_590x.jpg?v=1612476249"
      }
    }
    }

In the transformResponse method I get this typescript error:

Type '(response: Product[]) => ProductsState' is not assignable to type '(baseQueryReturnValue: unknown, meta: FetchBaseQueryMeta |

undefined, arg: string) => Product[] | Promise<Product[]>'.
Type 'ProductsState' is not assignable to type 'Product[] | Promise<Product[]>'.ts(2322)
endpointDefinitions.d.ts(41, 5): The expected type comes from property 'transformResponse' which is declared here on type
'Omit<EndpointDefinitionWithQuery<string, BaseQueryFn<string |
FetchArgs, unknown, FetchBaseQueryError, {}, FetchBaseQueryMeta>,
Product[]> & { ...; } & { ...; } & QueryExtraOptions<...>, "type"> |
Omit<...>'

and here acc[curr.id] , I get this typescript error:

(parameter) curr: Product Element implicitly has an 'any' type because
expression of type 'string' can't be used to index type '{}'.   No
index signature with a parameter of type 'string' was found on type

What can I do? thank you.


问:
JNDI lookup failed for the resource: Name: SaosData, Lookup: SaosData, Type: javax.sql.DataSource
I have a backend project (this is added as dependency of others) in which the persistence.xml has several PersistenceUnit defined, I just added a new one for a new project but when I try to deploy it this error is throw, the deployment is stopped after this:

```<code>SEVERE:   JNDI lookup failed for the resource: Name: ObraSocialPU, Lookup: SaosData, Type: javax.sql.DataSource.
SEVERE:   JNDI lookup failed for the resource: Name: [ObraSocialPU], Lookup: [SaosData], Type: [javax.sql.DataSource] -- Lookup failed for 'SaosData' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
</code>```

I don't why or when in the deployment the code is trying to prematurely create/check the existence of this JDBC Resource, because it is not even the one that I am going to use.
The front-end is in a very early state so, I am not even using the backend yet, just was added as dependency

Body:
I have a backend project (this is added as dependency of others) in which the persistence.xml has several PersistenceUnit defined, I just added a new one for a new project but when I try to deploy it this error is throw, the deployment is stopped after this:

SEVERE:   JNDI lookup failed for the resource: Name: ObraSocialPU, Lookup: SaosData, Type: javax.sql.DataSource.
SEVERE:   JNDI lookup failed for the resource: Name: [ObraSocialPU], Lookup: [SaosData], Type: [javax.sql.DataSource] -- Lookup failed for 'SaosData' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}

I don't why or when in the deployment the code is trying to prematurely create/check the existence of this JDBC Resource, because it is not even the one that I am going to use.
The front-end is in a very early state so, I am not even using the backend yet, just was added as dependency


问:
does React-native-maps support windows, if not, which library can I use for using maps in my windows app by using React-Native
I am searching if I can use React-Native to build a windows application, where I want to use a map(I prefer Google Maps) to display some information.

I checked the React-Native-Maps library, and it only supports IOS and Android.

Does anyone know if it supports windows app? if not, are there other options?

Thanks


问:
Is it possible to force the debugger to show the structure fields in its own way?
I keep a linked list in memory:

struct list {
  int value;
  list *nxt;
};
```
<p>In the debugger, for example, Clion, I see its pointer to the next element as a structure and can view it:</p>
<p><img src="https://i.stack.imgur.com/MoQfR.png" alt="list in debugger" /></p>
<p>Now I want to serialize this list into a file, and make the pointers an offset in the file. The structure being written to the file is now as follows:</p>
<pre class="lang-cpp prettyprint-override"><code>typedef int64_t my_offset_t;
struct file_list {
  int value;
  my_offset_t nxt;
};
</code>```

And now I obviously can't move on to the next element.

I can declare a method that will return the structure I need, but then I will have to write something like a->GetNext()->GetNext()->... in the debugger. But I want it to look like an ordinary field in the structure, which I can see as in the first image.

Is it possible in Clion/VS Code/... make me interpret such a field as a pointer, but so that I can describe the logic of its dereference myself?
Maybe some special classes, annotations, magic methods,...?

Body:
I keep a linked list in memory:

struct list {
  int value;
  list *nxt;
};

In the debugger, for example, Clion, I see its pointer to the next element as a structure and can view it:

Now I want to serialize this list into a file, and make the pointers an offset in the file. The structure being written to the file is now as follows:

typedef int64_t my_offset_t;
struct file_list {
  int value;
  my_offset_t nxt;
};

And now I obviously can't move on to the next element.

I can declare a method that will return the structure I need, but then I will have to write something like a->GetNext()->GetNext()->... in the debugger. But I want it to look like an ordinary field in the structure, which I can see as in the first image.

Is it possible in Clion/VS Code/... make me interpret such a field as a pointer, but so that I can describe the logic of its dereference myself?
Maybe some special classes, annotations, magic methods,...?


问:
How to click on a minimized window
I want to click on a minimized(or not foregrounded) window without using my cursor. simply when I'm playing games or doing homeworks etc. my codes automatically click on my coordinates and I don't want to see this window every reply is welcome thanks for helps from now...

```<code>win32api
win32con
win32gui
win32ui
def main():
    window_name = "Chrome"
    hwnd = win32gui.FindWindow(None, window_name)
    hwnd = get_inner_windows(hwnd)['Edit']
    win32ui.CreateWindowFromHandle(hwnd)

</code>```

I have tried with these but every source i searched using "SetForegroundWindow" and i don't want to see this window on top

Title: How to click on a minimized window

Body:
I want to click on a minimized(or not foregrounded) window without using my cursor. simply when I'm playing games or doing homeworks etc. my codes automatically click on my coordinates and I don't want to see this window every reply is welcome thanks for helps from now...

win32api
win32con
win32gui
win32ui
def main():
    window_name = "Chrome"
    hwnd = win32gui.FindWindow(None, window_name)
    hwnd = get_inner_windows(hwnd)['Edit']
    win32ui.CreateWindowFromHandle(hwnd)

I have tried with these but every source i searched using "SetForegroundWindow" and i don't want to see this window on top


问:
Selenium Python: Hidden Input Field Not Interactable
I'm working on selenium python (modifying zap auth repo) trying to pass login page that has hidden field for the password. So the login flow would be, Insert Email > Click Button "Continue" > (password field comes up) Insert Password > Click Button "Login". Each button has different button id and this flow working on the same page.

I've tried using actionchain, find_element and execute_script to fill the field as well, but seems not found any solutions.

here's my part of code

```<code>if self.config.auth_password:
            try:
                # ActionChains(self.driver).click("Continue").perform()
                self.fill_password()
            except Exception:
                logging.warning(
                    'Did not find the password field - clicking Next button and trying again')
                button = self.driver.find_element_by_id("Continue")
                button.click()
                # if the password field was not found, we probably need to submit to go to the password page
                # login flow: username -> next -> password -> submit
                self.fill_password()
</code>```

This code always returning selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable, seems like ignoring the button click before.

This code returning

```<code>2022-12-16 18:42:21,099 Found element password by name
Traceback (most recent call last):
  File "/zap/zap_auth.py", line 203, in login
    self.fill_password()
  File "/zap/zap_auth.py", line 262, in fill_password
    return self.find_and_fill_element(self.config.auth_password,
  File "/zap/zap_auth.py", line 280, in find_and_fill_element
    element.clear()
  File "/usr/local/lib/python3.9/dist-packages/selenium/webdriver/remote/webelement.py", line 95, in clear
    self._execute(Command.CLEAR_ELEMENT)
  File "/usr/local/lib/python3.9/dist-packages/selenium/webdriver/remote/webelement.py", line 633, in _execute
    return self._parent.execute(command, params)
  File "/usr/local/lib/python3.9/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.9/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
  (Session info: headless chrome=108.0.5359.98)
</code>```

Any suggestions about this case? once again my login page flow,  Insert Email > Click Button "Continue" > (password field comes up) Insert Password > Click Button "Login"

UPDATE

Sadly I can't afford the url due to private working website. But I hope this inspect element on this page would help. This is before continue button clicked...

After I clicked the Continue button, the field will be unhide and button id change to login. In this link zap is the source code and handler the login flow.

Body:
I'm working on selenium python (modifying zap auth repo) trying to pass login page that has hidden field for the password. So the login flow would be, Insert Email > Click Button "Continue" > (password field comes up) Insert Password > Click Button "Login". Each button has different button id and this flow working on the same page.

I've tried using actionchain, find_element and execute_script to fill the field as well, but seems not found any solutions.

here's my part of code

if self.config.auth_password:
            try:
                # ActionChains(self.driver).click("Continue").perform()
                self.fill_password()
            except Exception:
                logging.warning(
                    'Did not find the password field - clicking Next button and trying again')
                button = self.driver.find_element_by_id("Continue")
                button.click()
                # if the password field was not found, we probably need to submit to go to the password page
                # login flow: username -> next -> password -> submit
                self.fill_password()

This code always returning selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable, seems like ignoring the button click before.

This code returning

2022-12-16 18:42:21,099 Found element password by name
Traceback (most recent call last):
  File "/zap/zap_auth.py", line 203, in login
    self.fill_password()
  File "/zap/zap_auth.py", line 262, in fill_password
    return self.find_and_fill_element(self.config.auth_password,
  File "/zap/zap_auth.py", line 280, in find_and_fill_element
    element.clear()
  File "/usr/local/lib/python3.9/dist-packages/selenium/webdriver/remote/webelement.py", line 95, in clear
    self._execute(Command.CLEAR_ELEMENT)
  File "/usr/local/lib/python3.9/dist-packages/selenium/webdriver/remote/webelement.py", line 633, in _execute
    return self._parent.execute(command, params)
  File "/usr/local/lib/python3.9/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.9/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
  (Session info: headless chrome=108.0.5359.98)

Any suggestions about this case? once again my login page flow,  Insert Email > Click Button "Continue" > (password field comes up) Insert Password > Click Button "Login"

UPDATE

Sadly I can't afford the url due to private working website. But I hope this inspect element on this page would help. This is before continue button clicked...

After I clicked the Continue button, the field will be unhide and button id change to login. In this link zap is the source code and handler the login flow.


问:
How to test API with POST requests to the database
I need to test an API with POST requests. Testing with supertest and chai. The problem is that the test is one-time, that is, it actually enters data into the database and the next time the test will not work, since the object has already been created, how can I get around this?</p>
```<code>const request = require('supertest')('http://localhost:5000');
const assert = require('chai').assert;

it('POST /api/book/create', () => {
    const data = {
        "id" : "3",
        "title" : "Testt",
        "author" : "He",
        "vendorCode" : "1321",
        "year" : "10.10.2022",
        "numberOfCopies" : "100"
    };
    return request
        .post('/api/book/create')
        .send(data)
        .then((res) => {
            assert.equal(res.body.book.title, 'Testt');
            assert.equal(res.body.book.author, 'He')
        });
});
</code>```

Body:
I need to test an API with POST requests. Testing with supertest and chai. The problem is that the test is one-time, that is, it actually enters data into the database and the next time the test will not work, since the object has already been created, how can I get around this?

const request = require('supertest')('http://localhost:5000');
const assert = require('chai').assert;

it('POST /api/book/create', () => {
    const data = {
        "id" : "3",
        "title" : "Testt",
        "author" : "He",
        "vendorCode" : "1321",
        "year" : "10.10.2022",
        "numberOfCopies" : "100"
    };
    return request
        .post('/api/book/create')
        .send(data)
        .then((res) => {
            assert.equal(res.body.book.title, 'Testt');
            assert.equal(res.body.book.author, 'He')
        });
});


问: Convert

Title: Convert <script> to <script setup lang="ts">

Body: I use the composition api with


问:
TF2 Sourcebans++ Won't connect with TCP
I've spent the entirety of my day for this.. but UDP connection works yet TCP connection doesn't

happens when I interact with a player

the debug thingy

I expected it to work, tried multiple things and my TCP and UDP port 3307 (yes not 3306 i know i set php to be 3307) and they are forwarded.

Title: TF2 Sourcebans++ Won't connect with TCP


问:
How to pass id with getserverside props in Reactjs
I am working on Reactjs and using "nextjs" framework,Right now i tyring to use "dynamic routes with serverside props",For this i used following code for dynamic routes

```<code> <Link href={`/blog/${todoList.id}`}>Edit</Link> //passing id
</code>```

And now i want to use "serverside props",I tried with following code,is this right way ? And for pass id (todoList.id) what should i do  ?

```<code>export const getServerSideProps = async ({ params }) => {
 const { data } = await axios.get(`https://xxxxxxxxxxx/`); // want to pass my id(todolist.id) here
  const post = data;

console.log(data);

  return {

    props: {
      post,
    },
  };
};
</code>```

Body:
I am working on Reactjs and using "nextjs" framework,Right now i tyring to use "dynamic routes with serverside props",For this i used following code for dynamic routes

 <Link href={`/blog/${todoList.id}`}>Edit</Link> //passing id

And now i want to use "serverside props",I tried with following code,is this right way ? And for pass id (todoList.id) what should i do  ?

export const getServerSideProps = async ({ params }) => {
 const { data } = await axios.get(`https://xxxxxxxxxxx/`); // want to pass my id(todolist.id) here
  const post = data;

console.log(data);

  return {

    props: {
      post,
    },
  };
};


问:
ie9 border disappears when zoomed out
I have a 1px border around some images. Ive only seen this issue in IE9 but when you zoom out some sides of the border disappear. Is this a bug or just how IE9 zooms out? Using the developer toolbar it doesn't seem to happen on IE8 and 7. Thanks </p>

Title: ie9 border disappears when zoomed out


问:
Solve multiple SAT problem at the same time
I want to solve multiple SAT problem at the same time, how can I apply this in C++ (with the SOTA SAT solver like minisat, CMS etc.)

I found there is a likely implementation in this github issue. However, I want to apply this in C++, any suggestion? I am thinking about using multithreading, OpenMP or something else, but I am wondering why people like to use multi-threading to solve a very complicated SAT problem, but rarely found some implementation to use multiple solvers to solve multiple CNF problems at the same time?


问:
Map function returning a empty value list
I am trying to map my firebase data and add it to a usestate hook in order for it to have a list of data. But I am getting empty list. I have used display hook to store objects
example of one object

```<code>
type:"others"
dayNumber:348
sum:130
id:"QDstSFIDgn72vrcsqcrP"

it has a list of these objects. Here is my code.
function BarChart(){
  const moneyCollectionRef = collection(db,"dailyData")
  const [display,setDisplay] = useState([]);
  let a ={
    labels:display.map(d=> ( d.dayNumber)),
    datasets:[{
      label:"Daily Expense",
      data: display.map(d=> ( d.sum)),
    }],
  }
  const [userData,setUserData] = useState({
    labels: [],
    datasets:[{
      label:"",
      data: [],
    }],
  });
  setUserData(a);

  useEffect(()=>{
    getUsers()

  },[]);

  const getUsers = async () =>{
    const data = await getDocs(moneyCollectionRef);
    setDisplay(data.docs.map((d)=>(
      {
      ...d.data(),id:d.id
    })));
  };

  // console.log(display)
  return <Bar data={userData} />;

}

export default BarChart;

</code>```

I am getting a empty list. Kindly help. how can I get a full list with all daynumbers from display hook.

Body:
I am trying to map my firebase data and add it to a usestate hook in order for it to have a list of data. But I am getting empty list. I have used display hook to store objects
example of one object

type:"others"
dayNumber:348
sum:130
id:"QDstSFIDgn72vrcsqcrP"

it has a list of these objects. Here is my code.
function BarChart(){
  const moneyCollectionRef = collection(db,"dailyData")
  const [display,setDisplay] = useState([]);
  let a ={
    labels:display.map(d=> ( d.dayNumber)),
    datasets:[{
      label:"Daily Expense",
      data: display.map(d=> ( d.sum)),
    }],
  }
  const [userData,setUserData] = useState({
    labels: [],
    datasets:[{
      label:"",
      data: [],
    }],
  });
  setUserData(a);

  useEffect(()=>{
    getUsers()

  },[]);

  const getUsers = async () =>{
    const data = await getDocs(moneyCollectionRef);
    setDisplay(data.docs.map((d)=>(
      {
      ...d.data(),id:d.id
    })));
  };

  // console.log(display)
  return <Bar data={userData} />;

}

export default BarChart;

I am getting a empty list. Kindly help. how can I get a full list with all daynumbers from display hook.


问:
How to add third-party plugins or libraries in android studio 2021.3.1 (Dolphin)
I am facing a problem in adding an third-party plugins or library of liquid swipe https://github.com/Cuberto/liquid-swipe-android in Top-level build.gradle file in android studio 2021.3.1 (Dolphin). since I am not seeing "allprojects" function where I should place the code of step 3 of the above mentioned link. I am unable to continue because I am stuck with the program.

```<code>//My build.gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.3.1' apply false
    id 'com.android.library' version '7.3.1' apply false
}
</code>```

what should I do to add this plugin/library.

Body:
I am facing a problem in adding an third-party plugins or library of liquid swipe https://github.com/Cuberto/liquid-swipe-android in Top-level build.gradle file in android studio 2021.3.1 (Dolphin). since I am not seeing "allprojects" function where I should place the code of step 3 of the above mentioned link. I am unable to continue because I am stuck with the program.

//My build.gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.3.1' apply false
    id 'com.android.library' version '7.3.1' apply false
}

what should I do to add this plugin/library.


问:
NextJS imports everything when trying to use dynamic imports with `react-icons`
I need to use an Icon from the react-icons package.

Whenever I use it with an import statement, this is the bundle size I get:

Route (pages)                              Size     First Load JS
┌ ● /                                      7.41 kB        87.1 kB
├   /_app                                  0 B              77 kB
├ ○ /404                                   181 B          77.2 kB
├ ○ /auth                                  2.19 kB        79.2 kB
├ ○ /create (483 ms)                       3.72 kB        83.4 kB
├ λ /post/[name]                           78.8 kB         158 kB
├ λ /post/author/[name]                    3.24 kB        82.9 kB
├ ○ /settings                              3.6 kB         83.3 kB
├ λ /users                                 3.09 kB        82.8 kB
└ λ /users/[name]                          3.2 kB         82.9 kB
+ First Load JS shared by all              81.1 kB
  ├ chunks/framework-3b5a00d5d7e8d93b.js   45.4 kB
  ├ chunks/main-b5f8370d8042886c.js        27.4 kB
  ├ chunks/pages/_app-db3210ce0bd19d50.js  1.92 kB
```
<p>users/index.tsx</p>
```import { BsFillPeopleFill } from "react-icons/bs";
```
<p>Basically, the <strong>First Load JS</strong> is always consistent between 70 - 83kb (Although <code>/post/[name]</code> route has 158kb)</p>
<p>But whenever I am trying to dynamically import the icon component with <code>dynamic</code>, this is what I get:</p>
<pre class="lang-bash prettyprint-override"><code>Route (pages)                              Size     First Load JS
┌ ● /                                      7.42 kB         266 kB
├   /_app                                  0 B              77 kB
├ ○ /404                                   181 B          77.2 kB
├ ○ /auth                                  2.19 kB        79.2 kB
├ ○ /create                                3.73 kB         262 kB
├ λ /post/[name]                           78.8 kB         337 kB
├ λ /post/author/[name]                    3.25 kB         262 kB
├ ○ /settings                              3.61 kB         262 kB
├ λ /users                                 3.12 kB         262 kB
└ λ /users/[name]                          3.21 kB         262 kB
+ First Load JS shared by all              81.1 kB
  ├ chunks/framework-3b5a00d5d7e8d93b.js   45.4 kB
  ├ chunks/main-b5f8370d8042886c.js        27.4 kB
  ├ chunks/pages/_app-db3210ce0bd19d50.js  1.92 kB
  ├ chunks/webpack-e486fd67877a5f73.js     2.25 kB
  └ css/a905066d5b28cc23.css               4.07 kB
</code>```

users/index.tsx

```<code>const BsFillPeopleFill = dynamic(() => import("react-icons/bs").then(bootstrapIcons => bootstrapIcons.BsFillPeopleFill));
</code>```

As you can see, it just spiked up to 200kb in routes that use an icon. I don't really why it is importing the entire react-icons/bs part instead of just importing the one icon and splitting it into one bundle.

Can anyone help with this issue?

Body:
I need to use an Icon from the react-icons package.

Whenever I use it with an import statement, this is the bundle size I get:

Route (pages)                              Size     First Load JS
┌ ● /                                      7.41 kB        87.1 kB
├   /_app                                  0 B              77 kB
├ ○ /404                                   181 B          77.2 kB
├ ○ /auth                                  2.19 kB        79.2 kB
├ ○ /create (483 ms)                       3.72 kB        83.4 kB
├ λ /post/[name]                           78.8 kB         158 kB
├ λ /post/author/[name]                    3.24 kB        82.9 kB
├ ○ /settings                              3.6 kB         83.3 kB
├ λ /users                                 3.09 kB        82.8 kB
└ λ /users/[name]                          3.2 kB         82.9 kB
+ First Load JS shared by all              81.1 kB
  ├ chunks/framework-3b5a00d5d7e8d93b.js   45.4 kB
  ├ chunks/main-b5f8370d8042886c.js        27.4 kB
  ├ chunks/pages/_app-db3210ce0bd19d50.js  1.92 kB

users/index.tsx

import { BsFillPeopleFill } from "react-icons/bs";

Basically, the First Load JS is always consistent between 70 - 83kb (Although /post/[name] route has 158kb)

But whenever I am trying to dynamically import the icon component with dynamic, this is what I get:

Route (pages)                              Size     First Load JS
┌ ● /                                      7.42 kB         266 kB
├   /_app                                  0 B              77 kB
├ ○ /404                                   181 B          77.2 kB
├ ○ /auth                                  2.19 kB        79.2 kB
├ ○ /create                                3.73 kB         262 kB
├ λ /post/[name]                           78.8 kB         337 kB
├ λ /post/author/[name]                    3.25 kB         262 kB
├ ○ /settings                              3.61 kB         262 kB
├ λ /users                                 3.12 kB         262 kB
└ λ /users/[name]                          3.21 kB         262 kB
+ First Load JS shared by all              81.1 kB
  ├ chunks/framework-3b5a00d5d7e8d93b.js   45.4 kB
  ├ chunks/main-b5f8370d8042886c.js        27.4 kB
  ├ chunks/pages/_app-db3210ce0bd19d50.js  1.92 kB
  ├ chunks/webpack-e486fd67877a5f73.js     2.25 kB
  └ css/a905066d5b28cc23.css               4.07 kB

users/index.tsx

const BsFillPeopleFill = dynamic(() => import("react-icons/bs").then(bootstrapIcons => bootstrapIcons.BsFillPeopleFill));

As you can see, it just spiked up to 200kb in routes that use an icon. I don't really why it is importing the entire react-icons/bs part instead of just importing the one icon and splitting it into one bundle.

Can anyone help with this issue?


问:
how to get windows URL every time page is loaded in electron app?
I am using electron-forge to create an app with node.js.

```<code>
function createWindow () {
  // Create the browser window.
  const mainWindow = new BrowserWindow({
    width: 1030,
    height: 800,
    webPreferences: {
      preload: path.join(__dirname, 'preload.js')
    }
  })

  // and load the index.html of the app.
  //mainWindow.loadFile('index.html');
  mainWindow.loadURL('http://localhost:3000');
  mainWindow.setMenuBarVisibility(false);
 /// mainWindow.webContents.openDevTools();

  // Open the DevTools.
  // mainWindow.webContents.openDevTools()
}

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.whenReady().then(() => {
  createWindow()

  app.on('activate', function () {
    // On macOS it's common to re-create a window in the app when the
    // dock icon is clicked and there are no other windows open.
    if (BrowserWindow.getAllWindows().length === 0) createWindow()
  })
})

// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
app.on('window-all-closed', function () {
  if (process.platform !== 'darwin') app.quit()
})
</code>```

How can I detect the URL changed and find out the URL with the electron? let's say:

if the URL is www.google.com, I want to pop up a modal saying "Please search here" with some message in the Electron app.

Please help! Thanks in advance and happy holidays to you guys!

Body:
I am using electron-forge to create an app with node.js.

function createWindow () {
  // Create the browser window.
  const mainWindow = new BrowserWindow({
    width: 1030,
    height: 800,
    webPreferences: {
      preload: path.join(__dirname, 'preload.js')
    }
  })

  // and load the index.html of the app.
  //mainWindow.loadFile('index.html');
  mainWindow.loadURL('http://localhost:3000');
  mainWindow.setMenuBarVisibility(false);
 /// mainWindow.webContents.openDevTools();

  // Open the DevTools.
  // mainWindow.webContents.openDevTools()
}

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.whenReady().then(() => {
  createWindow()

  app.on('activate', function () {
    // On macOS it's common to re-create a window in the app when the
    // dock icon is clicked and there are no other windows open.
    if (BrowserWindow.getAllWindows().length === 0) createWindow()
  })
})

// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
app.on('window-all-closed', function () {
  if (process.platform !== 'darwin') app.quit()
})

How can I detect the URL changed and find out the URL with the electron? let's say:

if the URL is www.google.com, I want to pop up a modal saying "Please search here" with some message in the Electron app.

Please help! Thanks in advance and happy holidays to you guys!


问:
Versioning via Git Tag in Jetbrains Space Automation
I am currently trying to solve a versioning problem in my application: I want to use the git tag as a version number inside a JetBrains Space automation script.

My .space.kts is based on a template from the official docs and contains the following relevant job:

```<code>job("Deploy") {
    container("Run deploy script", image = "gradle:7.1-jre11") {
        kotlinScript { api ->
            // ...

            api.space().projects.automation.deployments.schedule(
                project = api.projectIdentifier(),
                targetIdentifier = TargetIdentifier.Key("production-server"),
                version = "1.0.0" // Here, I need the git tag
            )
        }
    }
}
</code>```

I have not been able to find a good solution. And I am wondering why that is:

Did I not manage to research correctly?

Is my approach not sensible?

If so, what would be considered best-practices for setting a version? Are there resources I can use to learn?

Most example I saw, used the build execution number or some other env variable to compose a version number. But I cannot really make sense of that approach, since I want to adhere to semver, have git tags to organize VCS and automate this process.

Thanks for your help in clarifying the issue.

Body:
I am currently trying to solve a versioning problem in my application: I want to use the git tag as a version number inside a JetBrains Space automation script.

My .space.kts is based on a template from the official docs and contains the following relevant job:

job("Deploy") {
    container("Run deploy script", image = "gradle:7.1-jre11") {
        kotlinScript { api ->
            // ...

            api.space().projects.automation.deployments.schedule(
                project = api.projectIdentifier(),
                targetIdentifier = TargetIdentifier.Key("production-server"),
                version = "1.0.0" // Here, I need the git tag
            )
        }
    }
}

I have not been able to find a good solution. And I am wondering why that is:

Did I not manage to research correctly?

Is my approach not sensible?

If so, what would be considered best-practices for setting a version? Are there resources I can use to learn?

Most example I saw, used the build execution number or some other env variable to compose a version number. But I cannot really make sense of that approach, since I want to adhere to semver, have git tags to organize VCS and automate this process.

Thanks for your help in clarifying the issue.


问:
Python type checking: cannot assign to a dict
I get the following error message in my Python code when assigning something to a dict:

```<code>Argument of type "dict[Unknown, Unknown]" cannot be assigned to parameter "__value" of type "str" in function "__setitem__"
  "dict[Unknown, Unknown]" is incompatible with "str"
</code>```

The code:

async def notify(self, method: str, params: Optional[dict] = None):
    reqDict = {"jsonrpc": "2.0", "method": method}
    if params is not None:
        reqDict["params"] = params
        # ^^^^^^^^^^^^^^^ error
```
<p>I don't understand why that is. The following code works fine:</p>
<pre class="lang-py prettyprint-override"><code>async def notify(self, method: str, params: Optional[dict] = None):
    id = 1
    reqDict = {"jsonrpc": "2.0", "id": id, "method": method}
    if params is not None:
        reqDict["params"] = params
</code>```

Not much difference, just the extra "id" key in the dict.

What is wrong here? My code or the type checker? How can I fix this?

This appears in VSCode 1.74.1 on Windows 10 with the Python extension and Python 3.9.6.

Body:
I get the following error message in my Python code when assigning something to a dict:

Argument of type "dict[Unknown, Unknown]" cannot be assigned to parameter "__value" of type "str" in function "__setitem__"
  "dict[Unknown, Unknown]" is incompatible with "str"

The code:

async def notify(self, method: str, params: Optional[dict] = None):
    reqDict = {"jsonrpc": "2.0", "method": method}
    if params is not None:
        reqDict["params"] = params
        # ^^^^^^^^^^^^^^^ error

I don't understand why that is. The following code works fine:

async def notify(self, method: str, params: Optional[dict] = None):
    id = 1
    reqDict = {"jsonrpc": "2.0", "id": id, "method": method}
    if params is not None:
        reqDict["params"] = params

Not much difference, just the extra "id" key in the dict.

What is wrong here? My code or the type checker? How can I fix this?

This appears in VSCode 1.74.1 on Windows 10 with the Python extension and Python 3.9.6.


问:
DBContext Update actually Adds if ID = 0
I have a DBContext with the following Update Function:

```<code>`        public async Task<T> UpdateAsync(T entity)
        {
            _appDbContext.Set<T>().Update(entity);
            await _appDbContext.SaveChangesAsync();
            return entity;
        }`
</code>```

The ID is autogenerating upon insertion.
When I am updating an entity with an ID = 0, it actually adds the entity instead of updating it.
Is this correct behavior? I was expecting it to break or something, but instead, it adds a new entity with a newly incremented Id value.

Just want to know if this is indeed the normal behavior for the dbcontext update function...

I tried checking if it exists first, with a getbyId function. And then deciding whether to update or add, but I was running into issues with that way. If the function is indeed just adding an new entity with newly created ID, if the ID = 0, then that is great. But is that the correct behavior?

Body:
I have a DBContext with the following Update Function:

`        public async Task<T> UpdateAsync(T entity)
        {
            _appDbContext.Set<T>().Update(entity);
            await _appDbContext.SaveChangesAsync();
            return entity;
        }`

The ID is autogenerating upon insertion.
When I am updating an entity with an ID = 0, it actually adds the entity instead of updating it.
Is this correct behavior? I was expecting it to break or something, but instead, it adds a new entity with a newly incremented Id value.

Just want to know if this is indeed the normal behavior for the dbcontext update function...

I tried checking if it exists first, with a getbyId function. And then deciding whether to update or add, but I was running into issues with that way. If the function is indeed just adding an new entity with newly created ID, if the ID = 0, then that is great. But is that the correct behavior?


问:
iOS Shortcut icon not showing up when shared to watch
I'm finishing up an app extension that provides shortcut support. Shortcuts are working great, and the app's icon shows up in the shortcut on the iPhone.

The problem is that the icon doesn't bubble up to the watch. I get the generic developer icon instead.

Assets file created with name "Assets-Shortcuts" Assets file has an
icon group called "AppIcon-Extension"

Project settings has
"AppIcon-Extension" set for the extension's icon.

After I set up the
assets file, Xcode then started showing the icon in the target list
for the extension, so Xcode seems to think I did it right.

Build
Phases shows the assets file under "Copy Bundle Resources".

When you create the shortcut, the app's extension icon is properly displayed in the shortcut.
After sharing it to the watch, the shortcut is shared properly, but has a generic developer icon.

I'm stumped as to what to do. Any ideas? I even tried Apple Watch icons in both the app's assets file and the extension's assets file with no luck.


问:
How to add VM arguments to ECS container definition in Terraform?
I have this application that depends on two types of profiles, when I pass a VM arguments as "-Dspring.profiles.active="test"", it loads some specific beans, and when I load the application with "-Dspring.profiles.active="test2", it loads the application with other beans. I'm loading a docker with this application's image inside an ECS using terraform. Here's the container definition:

```<code>  {
    "essential": true,
    "image": "docker-image",
    "name": "app",
    "environment": [
      {
        "name": "spring.profiles.active",
        "value": "test1"
      },
     ]"
}
</code>```

I've tried passing the spring profile inside the environent value, but without any success. Is there something I can do? Thanks!

Body:
I have this application that depends on two types of profiles, when I pass a VM arguments as "-Dspring.profiles.active="test"", it loads some specific beans, and when I load the application with "-Dspring.profiles.active="test2", it loads the application with other beans. I'm loading a docker with this application's image inside an ECS using terraform. Here's the container definition:

  {
    "essential": true,
    "image": "docker-image",
    "name": "app",
    "environment": [
      {
        "name": "spring.profiles.active",
        "value": "test1"
      },
     ]"
}

I've tried passing the spring profile inside the environent value, but without any success. Is there something I can do? Thanks!


问:
I'm trying to run npm install and I'm getting these errors. Can you help me with what to do next?
I'm trying to run npm install and I'm getting these errors. Can you help me with what to do next?

While resolving: @angular/common@13.3.11
Found: @angular/core@13.3.12
node_modules/@angular/core
  @angular/core@"^13.2.2" from the root project
  peer @angular/core@"13.3.12" from @angular/animations@13.3.12
  node_modules/@angular/animations
    @angular/animations@"^13.2.2" from the root project
    peer @angular/animations@"^13.0.0 || ^14.0.0-0" from @angular/material@13.3.9
    node_modules/@angular/material
      @angular/material@"13.3.9" from the root project
    peerOptional @angular/animations@"13.3.12" from @angular/platform-browser@13.3.12
    node_modules/@angular/platform-browser
      @angular/platform-browser@"^13.2.2" from the root project
      peer @angular/platform-browser@"13.3.12" from @angular/forms@13.3.12
      node_modules/@angular/forms
        @angular/forms@"^13.2.2" from the root project
        peer @angular/forms@"^13.0.0 || ^14.0.0-0" from @angular/material@13.3.9
        node_modules/@angular/material
          @angular/material@"13.3.9" from the root project
        peer @angular/forms@"^13.0.0" from ngx-bootstrap@8.0.0
        node_modules/ngx-bootstrap
          ngx-bootstrap@"^8.0.0" from the root project
      peer @angular/platform-browser@"^13.0.0 || ^14.0.0-0" from @angular/material@13.3.9
      node_modules/@angular/material
        @angular/material@"13.3.9" from the root project
      peer @angular/platform-browser@"13.3.12" from @angular/platform-browser-dynamic@13.3.12
      node_modules/@angular/platform-browser-dynamic
        @angular/platform-browser-dynamic@"^13.2.2" from the root project
      peer @angular/platform-browser@"13.3.12" from @angular/router@13.3.12
      node_modules/@angular/router
        @angular/router@"^13.2.2" from the root project
    peer @angular/animations@"^13.0.0" from ngx-bootstrap@8.0.0
    node_modules/ngx-bootstrap
      ngx-bootstrap@"^8.0.0" from the root project
  peer @angular/core@"^13.0.0 || ^14.0.0-0" from @angular/cdk@13.3.9
  node_modules/@angular/cdk
    @angular/cdk@"^13.2.2" from the root project
    peer @angular/cdk@"13.3.9" from @angular/material@13.3.9
    node_modules/@angular/material
      @angular/material@"13.3.9" from the root project
    @angular/cdk@"^13.2.2" from @de-electron/electron-angular-components@13.2.0
    node_modules/@de-electron/electron-angular-components
      @de-electron/electron-angular-components@"13.2.0" from the root project
  peer @angular/core@"13.3.12" from @angular/forms@13.3.12
  node_modules/@angular/forms
    @angular/forms@"^13.2.2" from the root project
    peer @angular/forms@"^13.0.0 || ^14.0.0-0" from @angular/material@13.3.9
    node_modules/@angular/material
      @angular/material@"13.3.9" from the root project
    peer @angular/forms@"^13.0.0" from ngx-bootstrap@8.0.0
    node_modules/ngx-bootstrap
      ngx-bootstrap@"^8.0.0" from the root project
  peer @angular/core@"^13.0.0 || ^14.0.0-0" from @angular/material@13.3.9
  node_modules/@angular/material
    @angular/material@"13.3.9" from the root project
  peer @angular/core@"13.3.12" from @angular/platform-browser@13.3.12
  node_modules/@angular/platform-browser
    @angular/platform-browser@"^13.2.2" from the root project
    peer @angular/platform-browser@"13.3.12" from @angular/forms@13.3.12
    node_modules/@angular/forms
      @angular/forms@"^13.2.2" from the root project
      peer @angular/forms@"^13.0.0 || ^14.0.0-0" from @angular/material@13.3.9
      node_modules/@angular/material
        @angular/material@"13.3.9" from the root project
      peer @angular/forms@"^13.0.0" from ngx-bootstrap@8.0.0
      node_modules/ngx-bootstrap
        ngx-bootstrap@"^8.0.0" from the root project
    peer @angular/platform-browser@"^13.0.0 || ^14.0.0-0" from @angular/material@13.3.9
    node_modules/@angular/material
      @angular/material@"13.3.9" from the root project
    peer @angular/platform-browser@"13.3.12" from @angular/platform-browser-dynamic@13.3.12
    node_modules/@angular/platform-browser-dynamic
      @angular/platform-browser-dynamic@"^13.2.2" from the root project
    peer @angular/platform-browser@"13.3.12" from @angular/router@13.3.12
    node_modules/@angular/router
      @angular/router@"^13.2.2" from the root project
  peer @angular/core@"13.3.12" from @angular/platform-browser-dynamic@13.3.12
  node_modules/@angular/platform-browser-dynamic
    @angular/platform-browser-dynamic@"^13.2.2" from the root project
  peer @angular/core@"13.3.12" from @angular/router@13.3.12
  node_modules/@angular/router
    @angular/router@"^13.2.2" from the root project
  peer @angular/core@"^13.2.2" from @de-electron/electron-angular-components@13.2.0
  node_modules/@de-electron/electron-angular-components
    @de-electron/electron-angular-components@"13.2.0" from the root project
  peer @angular/core@"^13.0.0" from ngx-bootstrap@8.0.0
  node_modules/ngx-bootstrap
    ngx-bootstrap@"^8.0.0" from the root project
  peer @angular/core@">=13.0.0" from ngx-pagination@6.0.3
  node_modules/ngx-pagination
    ngx-pagination@"^6.0.3" from the root project

Could not resolve dependency:
peer @angular/core@"13.3.11" from @angular/common@13.3.11
node_modules/@angular/common
  @angular/common@"13.3.11" from the root project
  peer @angular/common@"^13.0.0 || ^14.0.0-0" from @angular/cdk@13.3.9
  node_modules/@angular/cdk
    @angular/cdk@"^13.2.2" from the root project
    peer @angular/cdk@"13.3.9" from @angular/material@13.3.9
    node_modules/@angular/material
      @angular/material@"13.3.9" from the root project
    @angular/cdk@"^13.2.2" from @de-electron/electron-angular-components@13.2.0
    node_modules/@de-electron/electron-angular-components
      @de-electron/electron-angular-components@"13.2.0" from the root project
  peer @angular/common@"^13.0.0 || ^14.0.0-0" from @angular/material@13.3.9
  node_modules/@angular/material
    @angular/material@"13.3.9" from the root project
  peer @angular/common@"^13.2.2" from @de-electron/electron-angular-components@13.2.0
  node_modules/@de-electron/electron-angular-components
    @de-electron/electron-angular-components@"13.2.0" from the root project
  peer @angular/common@"^13.0.0" from ngx-bootstrap@8.0.0
  node_modules/ngx-bootstrap
    ngx-bootstrap@"^8.0.0" from the root project
  peer @angular/common@">=13.0.0" from ngx-pagination@6.0.3
  node_modules/ngx-pagination
    ngx-pagination@"^6.0.3" from the root project

Conflicting peer dependency: @angular/core@13.3.11
node_modules/@angular/core
  peer @angular/core@"13.3.11" from @angular/common@13.3.11
  node_modules/@angular/common
    @angular/common@"13.3.11" from the root project
    peer @angular/common@"^13.0.0 || ^14.0.0-0" from @angular/cdk@13.3.9
    node_modules/@angular/cdk
      @angular/cdk@"^13.2.2" from the root project
      peer @angular/cdk@"13.3.9" from @angular/material@13.3.9
      node_modules/@angular/material
        @angular/material@"13.3.9" from the root project
      @angular/cdk@"^13.2.2" from @de-electron/electron-angular-components@13.2.0
      node_modules/@de-electron/electron-angular-components
        @de-electron/electron-angular-components@"13.2.0" from the root project
    peer @angular/common@"^13.0.0 || ^14.0.0-0" from @angular/material@13.3.9
    node_modules/@angular/material
      @angular/material@"13.3.9" from the root project
    peer @angular/common@"^13.2.2" from @de-electron/electron-angular-components@13.2.0
    node_modules/@de-electron/electron-angular-components
      @de-electron/electron-angular-components@"13.2.0" from the root project
    peer @angular/common@"^13.0.0" from ngx-bootstrap@8.0.0
    node_modules/ngx-bootstrap
      ngx-bootstrap@"^8.0.0" from the root project
    peer @angular/common@">=13.0.0" from ngx-pagination@6.0.3
    node_modules/ngx-pagination
      ngx-pagination@"^6.0.3" from the root project

Fix the upstream dependency conflict, or retry
this command with --force or --legacy-peer-deps
to accept an incorrect (and potentially broken) dependency resolution.
```

I've also tried npm install using --force and -peer-dependency issues. I'm still getting those errors.

Body:
I'm trying to run npm install and I'm getting these errors. Can you help me with what to do next?

While resolving: @angular/common@13.3.11
Found: @angular/core@13.3.12
node_modules/@angular/core
  @angular/core@"^13.2.2" from the root project
  peer @angular/core@"13.3.12" from @angular/animations@13.3.12
  node_modules/@angular/animations
    @angular/animations@"^13.2.2" from the root project
    peer @angular/animations@"^13.0.0 || ^14.0.0-0" from @angular/material@13.3.9
    node_modules/@angular/material
      @angular/material@"13.3.9" from the root project
    peerOptional @angular/animations@"13.3.12" from @angular/platform-browser@13.3.12
    node_modules/@angular/platform-browser
      @angular/platform-browser@"^13.2.2" from the root project
      peer @angular/platform-browser@"13.3.12" from @angular/forms@13.3.12
      node_modules/@angular/forms
        @angular/forms@"^13.2.2" from the root project
        peer @angular/forms@"^13.0.0 || ^14.0.0-0" from @angular/material@13.3.9
        node_modules/@angular/material
          @angular/material@"13.3.9" from the root project
        peer @angular/forms@"^13.0.0" from ngx-bootstrap@8.0.0
        node_modules/ngx-bootstrap
          ngx-bootstrap@"^8.0.0" from the root project
      peer @angular/platform-browser@"^13.0.0 || ^14.0.0-0" from @angular/material@13.3.9
      node_modules/@angular/material
        @angular/material@"13.3.9" from the root project
      peer @angular/platform-browser@"13.3.12" from @angular/platform-browser-dynamic@13.3.12
      node_modules/@angular/platform-browser-dynamic
        @angular/platform-browser-dynamic@"^13.2.2" from the root project
      peer @angular/platform-browser@"13.3.12" from @angular/router@13.3.12
      node_modules/@angular/router
        @angular/router@"^13.2.2" from the root project
    peer @angular/animations@"^13.0.0" from ngx-bootstrap@8.0.0
    node_modules/ngx-bootstrap
      ngx-bootstrap@"^8.0.0" from the root project
  peer @angular/core@"^13.0.0 || ^14.0.0-0" from @angular/cdk@13.3.9
  node_modules/@angular/cdk
    @angular/cdk@"^13.2.2" from the root project
    peer @angular/cdk@"13.3.9" from @angular/material@13.3.9
    node_modules/@angular/material
      @angular/material@"13.3.9" from the root project
    @angular/cdk@"^13.2.2" from @de-electron/electron-angular-components@13.2.0
    node_modules/@de-electron/electron-angular-components
      @de-electron/electron-angular-components@"13.2.0" from the root project
  peer @angular/core@"13.3.12" from @angular/forms@13.3.12
  node_modules/@angular/forms
    @angular/forms@"^13.2.2" from the root project
    peer @angular/forms@"^13.0.0 || ^14.0.0-0" from @angular/material@13.3.9
    node_modules/@angular/material
      @angular/material@"13.3.9" from the root project
    peer @angular/forms@"^13.0.0" from ngx-bootstrap@8.0.0
    node_modules/ngx-bootstrap
      ngx-bootstrap@"^8.0.0" from the root project
  peer @angular/core@"^13.0.0 || ^14.0.0-0" from @angular/material@13.3.9
  node_modules/@angular/material
    @angular/material@"13.3.9" from the root project
  peer @angular/core@"13.3.12" from @angular/platform-browser@13.3.12
  node_modules/@angular/platform-browser
    @angular/platform-browser@"^13.2.2" from the root project
    peer @angular/platform-browser@"13.3.12" from @angular/forms@13.3.12
    node_modules/@angular/forms
      @angular/forms@"^13.2.2" from the root project
      peer @angular/forms@"^13.0.0 || ^14.0.0-0" from @angular/material@13.3.9
      node_modules/@angular/material
        @angular/material@"13.3.9" from the root project
      peer @angular/forms@"^13.0.0" from ngx-bootstrap@8.0.0
      node_modules/ngx-bootstrap
        ngx-bootstrap@"^8.0.0" from the root project
    peer @angular/platform-browser@"^13.0.0 || ^14.0.0-0" from @angular/material@13.3.9
    node_modules/@angular/material
      @angular/material@"13.3.9" from the root project
    peer @angular/platform-browser@"13.3.12" from @angular/platform-browser-dynamic@13.3.12
    node_modules/@angular/platform-browser-dynamic
      @angular/platform-browser-dynamic@"^13.2.2" from the root project
    peer @angular/platform-browser@"13.3.12" from @angular/router@13.3.12
    node_modules/@angular/router
      @angular/router@"^13.2.2" from the root project
  peer @angular/core@"13.3.12" from @angular/platform-browser-dynamic@13.3.12
  node_modules/@angular/platform-browser-dynamic
    @angular/platform-browser-dynamic@"^13.2.2" from the root project
  peer @angular/core@"13.3.12" from @angular/router@13.3.12
  node_modules/@angular/router
    @angular/router@"^13.2.2" from the root project
  peer @angular/core@"^13.2.2" from @de-electron/electron-angular-components@13.2.0
  node_modules/@de-electron/electron-angular-components
    @de-electron/electron-angular-components@"13.2.0" from the root project
  peer @angular/core@"^13.0.0" from ngx-bootstrap@8.0.0
  node_modules/ngx-bootstrap
    ngx-bootstrap@"^8.0.0" from the root project
  peer @angular/core@">=13.0.0" from ngx-pagination@6.0.3
  node_modules/ngx-pagination
    ngx-pagination@"^6.0.3" from the root project

Could not resolve dependency:
peer @angular/core@"13.3.11" from @angular/common@13.3.11
node_modules/@angular/common
  @angular/common@"13.3.11" from the root project
  peer @angular/common@"^13.0.0 || ^14.0.0-0" from @angular/cdk@13.3.9
  node_modules/@angular/cdk
    @angular/cdk@"^13.2.2" from the root project
    peer @angular/cdk@"13.3.9" from @angular/material@13.3.9
    node_modules/@angular/material
      @angular/material@"13.3.9" from the root project
    @angular/cdk@"^13.2.2" from @de-electron/electron-angular-components@13.2.0
    node_modules/@de-electron/electron-angular-components
      @de-electron/electron-angular-components@"13.2.0" from the root project
  peer @angular/common@"^13.0.0 || ^14.0.0-0" from @angular/material@13.3.9
  node_modules/@angular/material
    @angular/material@"13.3.9" from the root project
  peer @angular/common@"^13.2.2" from @de-electron/electron-angular-components@13.2.0
  node_modules/@de-electron/electron-angular-components
    @de-electron/electron-angular-components@"13.2.0" from the root project
  peer @angular/common@"^13.0.0" from ngx-bootstrap@8.0.0
  node_modules/ngx-bootstrap
    ngx-bootstrap@"^8.0.0" from the root project
  peer @angular/common@">=13.0.0" from ngx-pagination@6.0.3
  node_modules/ngx-pagination
    ngx-pagination@"^6.0.3" from the root project

Conflicting peer dependency: @angular/core@13.3.11
node_modules/@angular/core
  peer @angular/core@"13.3.11" from @angular/common@13.3.11
  node_modules/@angular/common
    @angular/common@"13.3.11" from the root project
    peer @angular/common@"^13.0.0 || ^14.0.0-0" from @angular/cdk@13.3.9
    node_modules/@angular/cdk
      @angular/cdk@"^13.2.2" from the root project
      peer @angular/cdk@"13.3.9" from @angular/material@13.3.9
      node_modules/@angular/material
        @angular/material@"13.3.9" from the root project
      @angular/cdk@"^13.2.2" from @de-electron/electron-angular-components@13.2.0
      node_modules/@de-electron/electron-angular-components
        @de-electron/electron-angular-components@"13.2.0" from the root project
    peer @angular/common@"^13.0.0 || ^14.0.0-0" from @angular/material@13.3.9
    node_modules/@angular/material
      @angular/material@"13.3.9" from the root project
    peer @angular/common@"^13.2.2" from @de-electron/electron-angular-components@13.2.0
    node_modules/@de-electron/electron-angular-components
      @de-electron/electron-angular-components@"13.2.0" from the root project
    peer @angular/common@"^13.0.0" from ngx-bootstrap@8.0.0
    node_modules/ngx-bootstrap
      ngx-bootstrap@"^8.0.0" from the root project
    peer @angular/common@">=13.0.0" from ngx-pagination@6.0.3
    node_modules/ngx-pagination
      ngx-pagination@"^6.0.3" from the root project

Fix the upstream dependency conflict, or retry
this command with --force or --legacy-peer-deps
to accept an incorrect (and potentially broken) dependency resolution.

I've also tried npm install using --force and -peer-dependency issues. I'm still getting those errors.


问:
JavaFX Working Except for FXMLLoader Import
When I was searching for a solution I noticed most people's issues was an incorrect installation. I believe my installation is correct as a normal JavaFX project works fine. However, I am not able to import the FXMLLoader or use it in my Java project. All jars have been added to my JavaFX19 user library.

I am using Eclipse 09-2022, Java 19, JavaFX19.

```<code>Error Message on Import: The type javafx.fxml.FXMLLoader is not accessible

package application;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;
import javafx.scene.Group;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;

public class Main extends Application {

    public static void main(String[] args) {
        // Launches stage and goes to start.
        launch(args);
    }

    @Override
    public void start(Stage stage) throws Exception {

        Parent root = FXMLLoader.load(getClass().getResource("FXMLHomeScreen.fxml"));
        Scene homeScreen = new Scene(root, 1000, 700, Color.BLACK);
        stage.setScene(homeScreen);
        stage.show();
    }
}

</code>```

EDIT: Adding module-info.java as requested.

```<code>module ResellingManager {
    requires javafx.controls;
    requires javafx.graphics;

    opens application to javafx.graphics, javafx.fxml;
}
</code>```

Body:
When I was searching for a solution I noticed most people's issues was an incorrect installation. I believe my installation is correct as a normal JavaFX project works fine. However, I am not able to import the FXMLLoader or use it in my Java project. All jars have been added to my JavaFX19 user library.

I am using Eclipse 09-2022, Java 19, JavaFX19.

Error Message on Import: The type javafx.fxml.FXMLLoader is not accessible

package application;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;
import javafx.scene.Group;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;

public class Main extends Application {

    public static void main(String[] args) {
        // Launches stage and goes to start.
        launch(args);
    }

    @Override
    public void start(Stage stage) throws Exception {

        Parent root = FXMLLoader.load(getClass().getResource("FXMLHomeScreen.fxml"));
        Scene homeScreen = new Scene(root, 1000, 700, Color.BLACK);
        stage.setScene(homeScreen);
        stage.show();
    }
}

EDIT: Adding module-info.java as requested.

module ResellingManager {
    requires javafx.controls;
    requires javafx.graphics;

    opens application to javafx.graphics, javafx.fxml;
}


问:
SharePoint Excel Web Part - Auto Refresh
I am trying to add a simple Excel table as a web part that will auto update upon entering into SharePoint.  I understand that it will not update unless the SharePoint page is refreshed (that is ok).  I previously asked a question on the Microsoft SharePoint forum, but was directed to the Microsoft Power Automate forum.

I have an Excel file that is stored on our SharePoint site.  The main tab used is a log for our operators.  I have created another tab called "Dashboard" that takes the most recent data to display in my simple table.  It is this table that I wish to display as a web part on our SharePoint main page.

I would like the web part to update when a change is made in the root "Logbook" tab.  Any ideas?


问:
When kuberentes terminates a pod, it kills any ongoing pyodbc calls, even when the parent python process is handling SIGTERM etc
I have a python docker container running in kuberetes. The code's general workflow is that it receives messages and then kicks off a series of long-running SQL Server statements via pyodbc.

My goal is to increase the kubernetes timeout and intercept the shutdown signal so that we can finish our SQL statements before shutting down the pod.
First, I set terminationGracePeriodSeconds: 1800 in my k8s.yaml file to make sure the pod has time to finish running the queries.

I've set up the code in python:

    def graceful_shutdown(_signo, _stack_frame):
        _logger.info(
            f"Received {_signo}, attempting to let the queries finish gracefully before shutting down."
        )
        # shutdown_event is a threading.Event object
        shutdown_event.set()
```
<p>And then in the main execution loop:</p>
<pre class="lang-py prettyprint-override"><code>    signal.signal(signal.SIGTERM, graceful_shutdown)
    signal.signal(signal.SIGINT, graceful_shutdown)
    signal.signal(signal.SIGHUP, graceful_shutdown)
</code>```

(Tangentially, a good discussion as to why I get SIGHUP and not SIGTERM here: 1)

This works as expected. I get the SIGHUP signal, the Threading.Event shutdown_event object tells my main execution loop to terminate, everything works...

...Except when one of those SQL queries is actually running. In that case, my graceful_shutdown() method doesn't get called. What happens is that the pyodbc connection throws the following error:

pyodbc.OperationalError: ('08S01', '[08S01] [Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: Error code 0x2714 (10004) (SQLExecDirectW)')

This error is a communication link failure caused by Kubernetes telling the pod to terminate.

My question is, can I prevent this error from being raised so that pyodbc can finish running the query?

Body:
I have a python docker container running in kuberetes. The code's general workflow is that it receives messages and then kicks off a series of long-running SQL Server statements via pyodbc.

My goal is to increase the kubernetes timeout and intercept the shutdown signal so that we can finish our SQL statements before shutting down the pod.
First, I set terminationGracePeriodSeconds: 1800 in my k8s.yaml file to make sure the pod has time to finish running the queries.

I've set up the code in python:

    def graceful_shutdown(_signo, _stack_frame):
        _logger.info(
            f"Received {_signo}, attempting to let the queries finish gracefully before shutting down."
        )
        # shutdown_event is a threading.Event object
        shutdown_event.set()

And then in the main execution loop:

    signal.signal(signal.SIGTERM, graceful_shutdown)
    signal.signal(signal.SIGINT, graceful_shutdown)
    signal.signal(signal.SIGHUP, graceful_shutdown)

(Tangentially, a good discussion as to why I get SIGHUP and not SIGTERM here: 1)

This works as expected. I get the SIGHUP signal, the Threading.Event shutdown_event object tells my main execution loop to terminate, everything works...

...Except when one of those SQL queries is actually running. In that case, my graceful_shutdown() method doesn't get called. What happens is that the pyodbc connection throws the following error:

pyodbc.OperationalError: ('08S01', '[08S01] [Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: Error code 0x2714 (10004) (SQLExecDirectW)')

This error is a communication link failure caused by Kubernetes telling the pod to terminate.

My question is, can I prevent this error from being raised so that pyodbc can finish running the query?