问:
Margins' is from 'package:flutter_html/src/style/margin.dart' Flutter build failed how to solve it?
Building with sound null safety

Warning: unexpected element (uri:"", local:"extension-level"). Expected elements are <{}codename>,<{}layoutlib>,<{}api-level>
Warning: unexpected element (uri:"", local:"base-extension"). Expected elements are <{}codename>,<{}layoutlib>,<{}api-level>
lib/service/messaging.dart:25:70: Error: Too many positional arguments: 2 allowed, but 3 found.
Try removing the extra positional arguments.
const AndroidNotificationChannel channel = AndroidNotificationChannel(
^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_local_notifications-12.0.4/lib/src/platform_specifics/android/notification_channel.dart:10:9: Context: Found this candidate, but the
arguments don't match.
const AndroidNotificationChannel(
^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/service/messaging.dart:218:48: Error: Too many positional arguments: 2 allowed, but 3 found.
Try removing the extra positional arguments.
android: AndroidNotificationDetails(
^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_local_notifications-12.0.4/lib/src/platform_specifics/android/notification_details.dart:102:9: Context: Found this candidate, but the
arguments don't match.
const AndroidNotificationDetails(
^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/service/messaging.dart:202:9: Error: No named parameter with the name 'onSelectNotification'.
onSelectNotification: onSelectNotification,
^^^^^^^^^^^^^^^^^^^^
lib/mixins/product_mixin.dart:153:34: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
margin: EdgeInsets.zero,
^
lib/mixins/product_mixin.dart:157:34: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
margin: EdgeInsets.zero,
^
lib/mixins/product_mixin.dart:171:32: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
margin: EdgeInsets.zero,
^
lib/mixins/product_mixin.dart:175:32: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
margin: EdgeInsets.zero,
^
lib/mixins/review_mixin.dart:111:51: Error: The argument type 'double?' can't be assigned to the parameter type 'double' because 'double?' is nullable and 'double' isn't.
fontSize: FontSize(theme.textTheme.caption!.fontSize),
^
lib/mixins/review_mixin.dart:109:26: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
margin: EdgeInsets.zero,
^
lib/mixins/review_mixin.dart:121:30: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
margin: EdgeInsets.zero,
^
lib/mixins/review_mixin.dart:124:30: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
margin: EdgeInsets.zero,
^
lib/mixins/review_mixin.dart:127:25: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
margin: const EdgeInsets.only(left: itemPaddingMedium),
^
lib/mixins/review_mixin.dart:129:40: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
'h1': Style(margin: EdgeInsets.zero),
^
lib/mixins/review_mixin.dart:130:40: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
'h2': Style(margin: EdgeInsets.zero),
^
lib/mixins/review_mixin.dart:131:40: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
'h3': Style(margin: EdgeInsets.zero),
^
lib/mixins/review_mixin.dart:132:40: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
'h4': Style(margin: EdgeInsets.zero),
^
lib/mixins/review_mixin.dart:133:40: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
'h5': Style(margin: EdgeInsets.zero),
^
lib/mixins/review_mixin.dart:134:40: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
'h6': Style(margin: EdgeInsets.zero),
^
lib/widgets/cirilla_html.dart:31:27: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
Try using a constructor or factory that is 'const'.
fontSize: const FontSize(16),
^^^^^^^^
lib/widgets/cirilla_html.dart:35:27: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
Try using a constructor or factory that is 'const'.
fontSize: const FontSize(16),
^^^^^^^^
lib/widgets/builder/post_comment/post_comment.dart:165:66: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
Try using a constructor or factory that is 'const'.
"div": Style(fontSize: const FontSize(12)),
^^^^^^^^
lib/widgets/builder/post_comment/post_comment.dart:166:70: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
"body": Style(margin: EdgeInsets.zero),
^
lib/widgets/builder/post_comment/post_comment.dart:167:67: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
"p": Style(margin: EdgeInsets.zero),
^
lib/screens/post/blocks/core_paragraph.dart:14:26: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
margin: EdgeInsets.zero,
^
lib/screens/post/blocks/core_paragraph.dart:18:26: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
margin: EdgeInsets.zero,
^
lib/screens/post/blocks/core_paragraph.dart:30:26: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
margin: EdgeInsets.zero,
^
lib/screens/post/blocks/rehub_wc_box.dart:158:32: Error: The argument type 'double?' can't be assigned to the parameter type 'double' because 'double?' is nullable and 'double' isn't.
fontSize: FontSize(fontSize),
^
lib/screens/post/blocks/rehub_wc_box.dart:159:32: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
margin: EdgeInsets.zero,
^
lib/screens/post/blocks/rehub_wc_box.dart:170:54: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
'p': styleTag.copyWith(margin: const EdgeInsets.only(left: secondItemPaddingSmall)),
^
lib/screens/post/blocks/rehub_wc_box.dart:182:38: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
margin: EdgeInsets.zero,
^
lib/screens/post/blocks/html_text.dart:34:26: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
margin: EdgeInsets.zero,
^
lib/screens/post/blocks/html_text.dart:48:30: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
margin: EdgeInsets.zero,
^
lib/screens/post/blocks/html_text.dart:51:30: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
margin: EdgeInsets.zero,
^
lib/screens/post/blocks/html_text.dart:54:25: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
margin: const EdgeInsets.only(left: itemPaddingMedium),
^
lib/screens/post/blocks/html_text.dart:56:40: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
'h1': Style(margin: EdgeInsets.zero),
^
lib/screens/post/blocks/html_text.dart:57:40: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
'h2': Style(margin: EdgeInsets.zero),
^
lib/screens/post/blocks/html_text.dart:58:40: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
'h3': Style(margin: EdgeInsets.zero),
^
lib/screens/post/blocks/html_text.dart:59:40: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
'h4': Style(margin: EdgeInsets.zero),
^
lib/screens/post/blocks/html_text.dart:60:40: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
'h5': Style(margin: EdgeInsets.zero),
^
lib/screens/post/blocks/html_text.dart:61:40: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
'h6': Style(margin: EdgeInsets.zero),
^
lib/screens/post/comments.dart:266:42: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
"body": Style(margin: EdgeInsets.zero),
^
lib/screens/post/comments.dart:267:34: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.

'EdgeInsets' is from 'package:flutter/src/painting/edge_insets.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/edge_insets.dart').

'Margins' is from 'package:flutter_html/src/style/margin.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_html-3.0.0-alpha.6/lib/src/style/margin.dart').
"p": Style(margin: const EdgeInsets.only(top: 11, bottom: itemPaddingMedium)),
^

FAILURE: Build failed with an exception.

* Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1159

* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
\> Process 'command 'C:\src\flutter\bin\flutter.bat'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

BUILD FAILED in 2m 4s
Running Gradle task 'assembleRelease'...                          126.1s
Gradle task assembleRelease failed with exit code 1

I have changes flutter html downgrade for solving tha same but its not i am not able to solve it please help me to solve this issue. lib/screens/post/comments.dart:266:42: Error: The argument type 'EdgeInsets' can't be assigned to the parameter type 'Margins?'.


来源: stackexchange

问:
Pass text to a Python script and return the result using R JSON
I have a string in R that I would like to pass to python in order to compute something and return the result back into R.

I have the following which "works" but not as I would like.

The below passes a string from R, to a Python file, uses openAI to collect the text data and then load it back into R.

```<code>library(reticulate)
computePythonFunction <- "
def print_openai_response():
  import openai
  openai.api_key = 'ej-powurjf___OpenAI_API_KEY___HGAJjswe'      # you will need an API key
  prompt = 'write me a poem about the sea'
  response = openai.Completion.create(engine = 'text-davinci-003', prompt = prompt, max_tokens=1000)
  #response['choices'][0]['text']
  print(response)
"

py_run_string(computePythonFunction)
py$print_openai_response()

library("rjson")
fromJSON(as.character(py$print_openai_response()))
</code>```

I would like to store the results in R objects - i.e. Here is one output from the python script.

```<code>{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "logprobs": null,
      "text": "\n\nThe sea glitters like stars in the night \nWith hues, vibrant and bright\nThe waves flow gentle, serene, and divine \nLike the sun's most gentle shine\n\nAs the sea reaches, so wide, so vast \nAn adventure awaits, and a pleasure, not passed\nWhite sands, with seaweed green \nForms a kingdom of the sea\n\nConnecting different land and tide \nThe sea churns, dancing with the sun's pride\nAs a tempest forms, raging and wild \nThe sea turns, its colors so mild\n\nA raging storm, so wild and deep \nProtecting the creatures that no one can see \nThe sea is a living breathing soul \nA true and untouchable goal \n\nThe sea is a beauty that no one can describe \nAnd it's power, no one can deny \nAn ever-lasting bond, timeless and free \nThe love of the sea, is a love, to keep"
    }
  ],
  "created": 1670525403,
  "id": "cmpl-6LGG3hDNzeTZ5VFbkyjwfkHH7rDkE",
  "model": "text-davinci-003",
  "object": "text_completion",
  "usage": {
    "completion_tokens": 210,
    "prompt_tokens": 7,
    "total_tokens": 217
  }
}
</code>```

I am interested in the text generated but I am also interested in the completion_tokens, promt_tokens and total_tokens.

I thought about save the Python code as a script, then pass the argument to it such as:

myPythin.py arg1.

How can I return the JSON output from the model to an R object? The only input which changes/varies in the python code is the prompt variable.

ContentLicense: CC BY-SA 4.0

Body:
I have a string in R that I would like to pass to python in order to compute something and return the result back into R.

I have the following which "works" but not as I would like.

The below passes a string from R, to a Python file, uses openAI to collect the text data and then load it back into R.

library(reticulate)
computePythonFunction <- "
def print_openai_response():
  import openai
  openai.api_key = 'ej-powurjf___OpenAI_API_KEY___HGAJjswe'      # you will need an API key
  prompt = 'write me a poem about the sea'
  response = openai.Completion.create(engine = 'text-davinci-003', prompt = prompt, max_tokens=1000)
  #response['choices'][0]['text']
  print(response)
"

py_run_string(computePythonFunction)
py$print_openai_response()

library("rjson")
fromJSON(as.character(py$print_openai_response()))

I would like to store the results in R objects - i.e. Here is one output from the python script.

{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "logprobs": null,
      "text": "\n\nThe sea glitters like stars in the night \nWith hues, vibrant and bright\nThe waves flow gentle, serene, and divine \nLike the sun's most gentle shine\n\nAs the sea reaches, so wide, so vast \nAn adventure awaits, and a pleasure, not passed\nWhite sands, with seaweed green \nForms a kingdom of the sea\n\nConnecting different land and tide \nThe sea churns, dancing with the sun's pride\nAs a tempest forms, raging and wild \nThe sea turns, its colors so mild\n\nA raging storm, so wild and deep \nProtecting the creatures that no one can see \nThe sea is a living breathing soul \nA true and untouchable goal \n\nThe sea is a beauty that no one can describe \nAnd it's power, no one can deny \nAn ever-lasting bond, timeless and free \nThe love of the sea, is a love, to keep"
    }
  ],
  "created": 1670525403,
  "id": "cmpl-6LGG3hDNzeTZ5VFbkyjwfkHH7rDkE",
  "model": "text-davinci-003",
  "object": "text_completion",
  "usage": {
    "completion_tokens": 210,
    "prompt_tokens": 7,
    "total_tokens": 217
  }
}

I am interested in the text generated but I am also interested in the completion_tokens, promt_tokens and total_tokens.

I thought about save the Python code as a script, then pass the argument to it such as:

myPythin.py arg1.

How can I return the JSON output from the model to an R object? The only input which changes/varies in the python code is the prompt variable.


问:
Is it possible to show a website in english if the browser's language is set in a non supported language?
I am currently developing an angular application that will be served in spanish and in english. The application is hosted in firebase hosting.

The intial configuration works well if the user's browser is in spanish (or one of it's variants) and in english (or variant). But it fails if the browser is set in a non supported language like german. I would like to serve the english version in those case.

I've checked the firebase configuration and it support it if I place the fallback version of the application in the root. For instance, let's say that I have three version of the  index.html file: one in english, one in spanish, and the third in english also (the fallback one). If I place them like that:

```<code>+- index.html    <-- this is my fallback page, when the language is not supported
|
+--en
|   +- index.html <-- this is the "index" that will be served when the browser is in english
|
+--es
    +- index.html <-- this is the "index" that will be served when the browser is in spanish
</code>```

Works pretty well. So, the question is: How can I achieve that in Angular? How
to make that angular build deploys the localized versions in such a way?? Or
can be firebase be configured to have a fallback language???

Body:
I am currently developing an angular application that will be served in spanish and in english. The application is hosted in firebase hosting.

The intial configuration works well if the user's browser is in spanish (or one of it's variants) and in english (or variant). But it fails if the browser is set in a non supported language like german. I would like to serve the english version in those case.

I've checked the firebase configuration and it support it if I place the fallback version of the application in the root. For instance, let's say that I have three version of the  index.html file: one in english, one in spanish, and the third in english also (the fallback one). If I place them like that:

+- index.html    <-- this is my fallback page, when the language is not supported
|
+--en
|   +- index.html <-- this is the "index" that will be served when the browser is in english
|
+--es
    +- index.html <-- this is the "index" that will be served when the browser is in spanish

Works pretty well. So, the question is: How can I achieve that in Angular? How
to make that angular build deploys the localized versions in such a way?? Or
can be firebase be configured to have a fallback language???


问:
How to use inspect element for selection tab in selenium
I have written a code than logins to a webpage and tries to download a file. but after login and before downloading it requires to select a particular field from drop down and then select a particular tab to download the file, can anyone pls assist what could be done here ?

```<code>from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
options = Options()
options.add_argument("start-maximized")

webdriver_service = Service('C:\webdrivers\chromedriver.exe')
driver = webdriver.Chrome(service=webdriver_service, options=options)

wait = WebDriverWait(driver, 20)

url = "products.markit.com/home/login.jsp"
driver.get(url)

wait.until(EC.element_to_be_clickable((By.NAME, "username"))).send_keys("Admin")
wait.until(EC.element_to_be_clickable((By.NAME, "password"))).send_keys("admin123")
wait.until(EC.element_to_be_clickable((By.TAG_NAME, "button"))).click()
</code>```

Inspect element for first selection (Pricing Data - Loan)

Inspect element for Past Loan Market

Inspect element for Download tab

Body:
I have written a code than logins to a webpage and tries to download a file. but after login and before downloading it requires to select a particular field from drop down and then select a particular tab to download the file, can anyone pls assist what could be done here ?

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
options = Options()
options.add_argument("start-maximized")

webdriver_service = Service('C:\webdrivers\chromedriver.exe')
driver = webdriver.Chrome(service=webdriver_service, options=options)

wait = WebDriverWait(driver, 20)

url = "products.markit.com/home/login.jsp"
driver.get(url)

wait.until(EC.element_to_be_clickable((By.NAME, "username"))).send_keys("Admin")
wait.until(EC.element_to_be_clickable((By.NAME, "password"))).send_keys("admin123")
wait.until(EC.element_to_be_clickable((By.TAG_NAME, "button"))).click()

Inspect element for first selection (Pricing Data - Loan)

Inspect element for Past Loan Market

Inspect element for Download tab


问:
replacements for big int in rust
I made a program to calculate the prime numbers of 1 to n in python and rust. Surprisingly python wins with the difference of 0.008 and 0.590. Rust won all other questions with the difference of 0.001 and 0.008.

The only difference here, is that I need to calculate a large number. Python is fine with large numbers, but rust requires a crate knows as num. Without using the num crate, rust wins.

Is there some how that I can avoid using num, without changing my solution?

Here are the rust and python solutions.

from functools import reduce
fact = lambda x: reduce(lambda y, z: y*z, range(1,x+1))
is_prime = lambda x: False if x <= 1 else fact(x-1) % x == x - 1
primes = lambda x, y: tuple(filter(is_prime, range(x,y+1)))

import sys
print(primes(1, int(sys.argv[1])))
```
<pre class="lang-rust prettyprint-override"><code>macro_rules! number {
    (+ $($args:tt),*) => {
        num::BigInt::new(num::bigint::Sign::Plus, vec![$($args),*])
    };
    (- $($args:tt),*) => {
        num::BigInt::new(num::bigint::Sign::Minus, vec![$($args),*])
    };
}

fn fact(x: u32) -> num::BigInt {
    (1..x+1).map(|x| number!(+ x)).reduce(|x, y| x * y).unwrap()
}

fn is_prime(x: u32) -> bool {
    x > 1 && fact(x - 1) % x == number!(+ (x - 1))
}

fn main() {
    let n = &(std::env::args().collect::<Vec<String>>())[1];
    println!("{:#?}", (1..=n.parse::<u32>().unwrap()).filter(|x| is_prime(*x)).collect::<Vec<u32>>());
}
</code>```

Title: replacements for big int in rust

Body:
I made a program to calculate the prime numbers of 1 to n in python and rust. Surprisingly python wins with the difference of 0.008 and 0.590. Rust won all other questions with the difference of 0.001 and 0.008.

The only difference here, is that I need to calculate a large number. Python is fine with large numbers, but rust requires a crate knows as num. Without using the num crate, rust wins.

Is there some how that I can avoid using num, without changing my solution?

Here are the rust and python solutions.

from functools import reduce
fact = lambda x: reduce(lambda y, z: y*z, range(1,x+1))
is_prime = lambda x: False if x <= 1 else fact(x-1) % x == x - 1
primes = lambda x, y: tuple(filter(is_prime, range(x,y+1)))

import sys
print(primes(1, int(sys.argv[1])))

macro_rules! number {
    (+ $($args:tt),*) => {
        num::BigInt::new(num::bigint::Sign::Plus, vec![$($args),*])
    };
    (- $($args:tt),*) => {
        num::BigInt::new(num::bigint::Sign::Minus, vec![$($args),*])
    };
}

fn fact(x: u32) -> num::BigInt {
    (1..x+1).map(|x| number!(+ x)).reduce(|x, y| x * y).unwrap()
}

fn is_prime(x: u32) -> bool {
    x > 1 && fact(x - 1) % x == number!(+ (x - 1))
}

fn main() {
    let n = &(std::env::args().collect::<Vec<String>>())[1];
    println!("{:#?}", (1..=n.parse::<u32>().unwrap()).filter(|x| is_prime(*x)).collect::<Vec<u32>>());
}


问:
Blazor Routing: Access one Page and pass parameter using various links
i have a blazor page where i load table data depending on the data passed from the other page through the link.

the page route is defined as this @Page/approvals{tablename}

from the other page i have the links

```<code>        <li class="nav-item">
            <a href="approvals/customer_visitation" class="nav-link" >
              <i class="far fa-circle nav-icon"></i>
              <p>Customer Visitation</p>
            </a>
          </li>
          <li class="nav-item">
            <a href="approvals/mapping" class="nav-link">
              <i class="far fa-circle nav-icon"></i>
              <p>Mapping</p>
            </a>
          </li>
</code>```

when i run the app and click anyone first it works well. but Navigating to the second one from the first on does not work. it shows an empty page.

my question is how do i use one page and have multiple links to that page with passed parameter?

Body:
i have a blazor page where i load table data depending on the data passed from the other page through the link.

the page route is defined as this @Page/approvals{tablename}

from the other page i have the links

Customer Visitation

Mapping

when i run the app and click anyone first it works well. but Navigating to the second one from the first on does not work. it shows an empty page.

my question is how do i use one page and have multiple links to that page with passed parameter?


问:
How do I use one .env as the source of truth
I am creating a build system for development purposes for the FreeCAD application. Repo is here if you want to get a better scope of what I'm talking about.

Essentially the folder structure is:

```<code>(Main)
  (Linux)
    (Ubuntu)
      ubuntu.sh
      ubuntu.Dockerfile
    (Fedora)
      fedora.sh
      fedora.Dockerfile
  (Windows)
  (Mac)
  .env
</code>```

What I want to do is use the env variables in .env as a central source of truth for all the build scripts in the tree. But I don't want to have to explicitly define the path of the .env inside the files, absolute or relative paths, as I'm still iterating and I don't want to update all the files if I rearrange the tree. Alternatively, I don't want to put independent .env's in all the child dirs for the same reason (unless they auto update somehow)

My question is as follows:

How do I just explicitly define the "local" path of .env in each script, Dockerfile, etc but only have to modify one top level .env file to auto-update an evolving tree. In a cross platform way

Some things I thought through:

Windows uses "hard links" which are equivalent but non compatible with POSIX hardlinks. I thought about creating windows.env and posix.env in each child dir that point to the same main .env. But most config files can only take one .env path argument.

I thought about writing a script that will update all the .env's when run (would rather not have to), or alternatively, I will accept an answer that uses some dotenv tooling to accomplish the same goal as long as it's cross-platform, and runs locally. I'm just not super familiar with those toolings. I would prefer the tooling or script run as a service and not have to be run everytime in order to update the files.

IF I'm using Git AND only referring to shell scripts, then a command at the top of the script such as  . /$(git rev-parse --show-toplevel)/.env works well but has major limitations for use with dockerfiles and other yml based file types.

I currently use a run.sh file at the top level dir that sources the .env and then calls the other files within it. This seems to be the most used pattern I see in other repos. But this means I need to have two files run.sh and run.pwsh which just seems extranuous and hacky to add extras files that are basically one liners.

Body:
I am creating a build system for development purposes for the FreeCAD application. Repo is here if you want to get a better scope of what I'm talking about.

Essentially the folder structure is:

(Main)
  (Linux)
    (Ubuntu)
      ubuntu.sh
      ubuntu.Dockerfile
    (Fedora)
      fedora.sh
      fedora.Dockerfile
  (Windows)
  (Mac)
  .env

What I want to do is use the env variables in .env as a central source of truth for all the build scripts in the tree. But I don't want to have to explicitly define the path of the .env inside the files, absolute or relative paths, as I'm still iterating and I don't want to update all the files if I rearrange the tree. Alternatively, I don't want to put independent .env's in all the child dirs for the same reason (unless they auto update somehow)

My question is as follows:

How do I just explicitly define the "local" path of .env in each script, Dockerfile, etc but only have to modify one top level .env file to auto-update an evolving tree. In a cross platform way

Some things I thought through:

Windows uses "hard links" which are equivalent but non compatible with POSIX hardlinks. I thought about creating windows.env and posix.env in each child dir that point to the same main .env. But most config files can only take one .env path argument.

I thought about writing a script that will update all the .env's when run (would rather not have to), or alternatively, I will accept an answer that uses some dotenv tooling to accomplish the same goal as long as it's cross-platform, and runs locally. I'm just not super familiar with those toolings. I would prefer the tooling or script run as a service and not have to be run everytime in order to update the files.

IF I'm using Git AND only referring to shell scripts, then a command at the top of the script such as  . /$(git rev-parse --show-toplevel)/.env works well but has major limitations for use with dockerfiles and other yml based file types.

I currently use a run.sh file at the top level dir that sources the .env and then calls the other files within it. This seems to be the most used pattern I see in other repos. But this means I need to have two files run.sh and run.pwsh which just seems extranuous and hacky to add extras files that are basically one liners.


问:
Postman collection running normally but Monitor is failing with bad request
I am testing my API using Postman monitor and the request is failing with bad request. When I run it normally using the Collection, all the tests are passing.

[


问:
Jackson - Deserialization - Deserialize a valid value for a field of type object that accepts only specific types
I am creating a deserializer for schema.org entities with jackson library.

The schema.org entities are generated, so I can't add Jackson annotation on them.

Some fields accept several types.

An example is the address field (https://schema.org/address) of the Hotel entity (https://schema.org/Hotel) which accepts the PostalAddress and Text types.

The generated class for Hotel is the following (I only put the address field for simplicity):

```<code>@JsonLdTypeName("Hotel")
public class HotelImpl extends com.weedow.schemaorg.commons.model.JsonLdNodeImpl implements Hotel {

    ...

    private Object address;

    @Override
    public <T> T getAddress() {
        return (T) address;
    }

    @Override
    public void setAddress(Text address) {
        this.address = address;
    }

    @Override
    public void setAddress(PostalAddress address) {
        this.address = address;
    }

    ...
}
</code>```

Since the address field accepts 2 different types, the field type is Object.

When I deserialize a JSON, I don't use setters since Jackson doesn't know which one to choose and throws an exception: Conflicting setter definitions for property ...

I use the fields directly by adding the following 2 lines:

```<code>objectMapper.visibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE);
objectMapper.visibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
</code>```

If the JSON is the following, it works fine because the address field is typed ("@type": "PostalAddress") and Jackson is able to construct the PostalAddress object and set the address field.

```<code>{
  "@context" : "https://schema.org",
  "@type" : "Hotel",
  "address" : {
    "@type" : "PostalAddress",
    "addressLocality" : "Lost City",
    "streetAddress" : "21 jump street"
  }
}
</code>```

If the JSON is the following, it doesn't work because there is no type (@type), but just a String that must be deserialized as a Text object.

(I have a TextDeserializer which works well if the field accepts only the Text type and which converts the String into a Text object)

```<code>{
  "@context" : "https://schema.org",
  "@type" : "Hotel",
  "address" : "21 jump street, Lost City"
}
</code>```

The address field being an object, Jackson set the String value directly on the field which is not correct, because it does not respect the accepted types.

I gave this example but the problem is equivalent with all fields that accept several types of which one of them is a DataType (https://schema.org/DataType).

I tried to implement my own AnnotationIntrospector to choose the right setter, but the resolveSetterConflict method is called before having the value.

```<code>public AnnotatedMethod resolveSetterConflict(MapperConfig<?> config, AnnotatedMethod setter1, AnnotatedMethod setter2) {
    // Parsed value not available
}
</code>```

Does Jackson allow a custom deserialization of a data according to
the value retrieved from the JSON, if this one is a scalar data
(String, number, boolean...)?

Does Jackson allow a custom deserialization of a data by calling the
right setter if there are several setters defined for the same field?

Does Jackson allow custom data deserialization if the field type is
Object, and the retrieved value is a scalar data (String, number,
boolean...)?

Body:
I am creating a deserializer for schema.org entities with jackson library.

The schema.org entities are generated, so I can't add Jackson annotation on them.

Some fields accept several types.

An example is the address field (https://schema.org/address) of the Hotel entity (https://schema.org/Hotel) which accepts the PostalAddress and Text types.

The generated class for Hotel is the following (I only put the address field for simplicity):

@JsonLdTypeName("Hotel")
public class HotelImpl extends com.weedow.schemaorg.commons.model.JsonLdNodeImpl implements Hotel {

    ...

    private Object address;

    @Override
    public <T> T getAddress() {
        return (T) address;
    }

    @Override
    public void setAddress(Text address) {
        this.address = address;
    }

    @Override
    public void setAddress(PostalAddress address) {
        this.address = address;
    }

    ...
}

Since the address field accepts 2 different types, the field type is Object.

When I deserialize a JSON, I don't use setters since Jackson doesn't know which one to choose and throws an exception: Conflicting setter definitions for property ...

I use the fields directly by adding the following 2 lines:

objectMapper.visibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE);
objectMapper.visibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);

If the JSON is the following, it works fine because the address field is typed ("@type": "PostalAddress") and Jackson is able to construct the PostalAddress object and set the address field.

{
  "@context" : "https://schema.org",
  "@type" : "Hotel",
  "address" : {
    "@type" : "PostalAddress",
    "addressLocality" : "Lost City",
    "streetAddress" : "21 jump street"
  }
}

If the JSON is the following, it doesn't work because there is no type (@type), but just a String that must be deserialized as a Text object.

(I have a TextDeserializer which works well if the field accepts only the Text type and which converts the String into a Text object)

{
  "@context" : "https://schema.org",
  "@type" : "Hotel",
  "address" : "21 jump street, Lost City"
}

The address field being an object, Jackson set the String value directly on the field which is not correct, because it does not respect the accepted types.

I gave this example but the problem is equivalent with all fields that accept several types of which one of them is a DataType (https://schema.org/DataType).

I tried to implement my own AnnotationIntrospector to choose the right setter, but the resolveSetterConflict method is called before having the value.

public AnnotatedMethod resolveSetterConflict(MapperConfig<?> config, AnnotatedMethod setter1, AnnotatedMethod setter2) {
    // Parsed value not available
}

Does Jackson allow a custom deserialization of a data according to
the value retrieved from the JSON, if this one is a scalar data
(String, number, boolean...)?

Does Jackson allow a custom deserialization of a data by calling the
right setter if there are several setters defined for the same field?

Does Jackson allow custom data deserialization if the field type is
Object, and the retrieved value is a scalar data (String, number,
boolean...)?


问:
Materialized view in Oracle that updates real time or fast - how to?
Suppose I have something like:

```<code>create table tmp_master (
    id int not null primary key,
    pid int not null,
    title varchar(32) not null
);

create table tmp_detail (
    id int not null primary key,
    mid int not null references tmp_master (id),
    category varchar(8) not null,
    intvalue int
);

insert into tmp_master values (1, 99, 'Item 1');
insert into tmp_master values (2, 99, 'Item 2');
insert into tmp_master values (3, 99, 'Item N');

insert into tmp_detail values (1, 1, 'Cat1', 1);
insert into tmp_detail values (2, 1, 'Cat1', 2);
insert into tmp_detail values (3, 1, 'Cat2', 3);
insert into tmp_detail values (4, 1, 'Cat2', 4);
insert into tmp_detail values (5, 1, 'Cat3', 5);
insert into tmp_detail values (6, 1, 'Cat3', 6);

insert into tmp_detail values (7, 2, 'Cat1', 7);
insert into tmp_detail values (8, 2, 'Cat1', 8);
insert into tmp_detail values (9, 2, 'Cat2', 9);
insert into tmp_detail values (10, 2, 'Cat2', 10);
insert into tmp_detail values (11, 2, 'Cat3', 11);
insert into tmp_detail values (12, 2, 'Cat3', 12);

insert into tmp_detail values (13, 3, 'Cat1', 13);
insert into tmp_detail values (14, 3, 'Cat1', 14);
insert into tmp_detail values (15, 3, 'Cat2', 15);
insert into tmp_detail values (16, 3, 'Cat2', 16);
insert into tmp_detail values (17, 3, 'Cat3', 17);
insert into tmp_detail values (18, 3, 'Cat3', 18);
</code>```

I'd like to have a materialized view based on this query (or something giving the same result):

```<code>select id, pid, maxc1, maxc2, maxc3 from (
    select m.id, m.pid, d.category, d.intvalue from tmp_master m, tmp_detail d where d.mid = m.id
) pivot (
    max(intvalue) for category in ('Cat1' maxc1, 'Cat2' maxc2, 'Cat3' maxc3)
);
</code>```

Result being (max values per category in details per master row, looks correct):

```<code>id  pid maxc1 maxc2 maxc3
-------------------------
 2   99     8    10    12
 3   99    14    16    18
 1   99     2     4     6
</code>```

So something like this would be needed:

```<code>create materialized view tmp_max_ints ... as
select id, pid, maxc1, maxc2, maxc3 from (
    select m.id, m.pid, d.category, d.intvalue from tmp_master m, tmp_detail d where d.mid = m.id
) pivot (
    max(intvalue) for category in ('Cat1' maxc1, 'Cat2' maxc2, 'Cat3' maxc3)
);
</code>```

However, it always fails on something depending on the options I give in place of ... above. MV Logs I have tried a couple of ways as well.

What kind of MV Logs and Create MV options should I use to make the MV work and update automatically as base tables change? I'm running out of ideas (nor am I much of a db expert either).

Version is Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0 - Production. Is this even possible with SE? If not, workarounds?

Body:
Suppose I have something like:

create table tmp_master (
    id int not null primary key,
    pid int not null,
    title varchar(32) not null
);

create table tmp_detail (
    id int not null primary key,
    mid int not null references tmp_master (id),
    category varchar(8) not null,
    intvalue int
);

insert into tmp_master values (1, 99, 'Item 1');
insert into tmp_master values (2, 99, 'Item 2');
insert into tmp_master values (3, 99, 'Item N');

insert into tmp_detail values (1, 1, 'Cat1', 1);
insert into tmp_detail values (2, 1, 'Cat1', 2);
insert into tmp_detail values (3, 1, 'Cat2', 3);
insert into tmp_detail values (4, 1, 'Cat2', 4);
insert into tmp_detail values (5, 1, 'Cat3', 5);
insert into tmp_detail values (6, 1, 'Cat3', 6);

insert into tmp_detail values (7, 2, 'Cat1', 7);
insert into tmp_detail values (8, 2, 'Cat1', 8);
insert into tmp_detail values (9, 2, 'Cat2', 9);
insert into tmp_detail values (10, 2, 'Cat2', 10);
insert into tmp_detail values (11, 2, 'Cat3', 11);
insert into tmp_detail values (12, 2, 'Cat3', 12);

insert into tmp_detail values (13, 3, 'Cat1', 13);
insert into tmp_detail values (14, 3, 'Cat1', 14);
insert into tmp_detail values (15, 3, 'Cat2', 15);
insert into tmp_detail values (16, 3, 'Cat2', 16);
insert into tmp_detail values (17, 3, 'Cat3', 17);
insert into tmp_detail values (18, 3, 'Cat3', 18);

I'd like to have a materialized view based on this query (or something giving the same result):

select id, pid, maxc1, maxc2, maxc3 from (
    select m.id, m.pid, d.category, d.intvalue from tmp_master m, tmp_detail d where d.mid = m.id
) pivot (
    max(intvalue) for category in ('Cat1' maxc1, 'Cat2' maxc2, 'Cat3' maxc3)
);

Result being (max values per category in details per master row, looks correct):

id  pid maxc1 maxc2 maxc3
-------------------------
 2   99     8    10    12
 3   99    14    16    18
 1   99     2     4     6

So something like this would be needed:

create materialized view tmp_max_ints ... as
select id, pid, maxc1, maxc2, maxc3 from (
    select m.id, m.pid, d.category, d.intvalue from tmp_master m, tmp_detail d where d.mid = m.id
) pivot (
    max(intvalue) for category in ('Cat1' maxc1, 'Cat2' maxc2, 'Cat3' maxc3)
);

However, it always fails on something depending on the options I give in place of ... above. MV Logs I have tried a couple of ways as well.

What kind of MV Logs and Create MV options should I use to make the MV work and update automatically as base tables change? I'm running out of ideas (nor am I much of a db expert either).

Version is Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0 - Production. Is this even possible with SE? If not, workarounds?


问:
How to setup Disaster recovery for GridDB?
I know the backup and restore process of GridDB which is specified here, however, I would like to know how to setup Disaster Recovery (To a different site) using methods such as log shipping, Distributed Clustering, etc.</p>


问:
rocket application embed migrations not applying
I'm trying to embed Diesel migrations into my rocket applications but whenever I attempt to select the tables they don't exist. The "Migrations successfully completed" message gets printed and rocket starts normally but the migrations don't seem to be applying, I'm really not sure what's happening here.

I tested the PgPool connection when I manually did migrations and it works fine.

my migrations directory:

00000000000000_diesel_initial_setup

down.sql

up.sql

2022-11-13-225713_users

down.sql

up.sql

my dependencies:

diesel = { version = "2.0.2", features = ["postgres", "nightly-error-messages", "r2d2"] }

diesel_migrations = "2.0.0"

rocket = { version = "0.5.0-rc.2", features = ["json"] }

```<code>pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!("migrations");

fn run_migrations(connection: &mut impl MigrationHarness<diesel::pg::Pg>) {
    match connection.run_pending_migrations(MIGRATIONS) {
        Ok(_) => {
            println!("Migrations successfully completed");
        },
        Err(e) => {
            panic!("error running pending migrations {}", e)
        },
    };
}

async fn run_rocket_migrations(rocket: Rocket<Build>) -> Rocket<Build> {
    let mut pool = rocket.state::<PgPool>().expect("managed database").get().unwrap();
    run_migrations(&mut pool);

    rocket
}

#[launch]
fn rocket() -> _ {
    rocket::build()
        .manage(establish_connection())
        .attach(AdHoc::on_ignite("run migrations", run_rocket_migrations))
}
</code>```

Body:
I'm trying to embed Diesel migrations into my rocket applications but whenever I attempt to select the tables they don't exist. The "Migrations successfully completed" message gets printed and rocket starts normally but the migrations don't seem to be applying, I'm really not sure what's happening here.

I tested the PgPool connection when I manually did migrations and it works fine.

my migrations directory:

00000000000000_diesel_initial_setup

down.sql

up.sql

2022-11-13-225713_users

down.sql

up.sql

my dependencies:

diesel = { version = "2.0.2", features = ["postgres", "nightly-error-messages", "r2d2"] }

diesel_migrations = "2.0.0"

rocket = { version = "0.5.0-rc.2", features = ["json"] }

pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!("migrations");

fn run_migrations(connection: &mut impl MigrationHarness<diesel::pg::Pg>) {
    match connection.run_pending_migrations(MIGRATIONS) {
        Ok(_) => {
            println!("Migrations successfully completed");
        },
        Err(e) => {
            panic!("error running pending migrations {}", e)
        },
    };
}

async fn run_rocket_migrations(rocket: Rocket<Build>) -> Rocket<Build> {
    let mut pool = rocket.state::<PgPool>().expect("managed database").get().unwrap();
    run_migrations(&mut pool);

    rocket
}

#[launch]
fn rocket() -> _ {
    rocket::build()
        .manage(establish_connection())
        .attach(AdHoc::on_ignite("run migrations", run_rocket_migrations))
}


问:
redis-cli command not working as expected on windows machine
I am using a redis-cli command to bulk insert data and save response to a file using

```<code>cat file.txt | redis-cli -h 192.168.100.28 --pipe >result.txt
</code>```

on windows

```<code>type file.txt | redis-cli -h 192.168.100.28 --pipe >result.txt
</code>```

Then on Linux  i can see below response in my result.txt file, but when i run the same command from windows machine the result.txt file is always empty, Any help ?

Result.txt on linux machine

```<code>All data transferred. Waiting for the last reply...

Last reply received from server.

errors: 0, replies: 9844***
</code>```

Result.txt on window machine
nothing always empty although running only type file.txt | redis-cli -h 192.168.100.28 --pipe
executes successfully in cmd and i see expected results in console but no data in file.

Body:
I am using a redis-cli command to bulk insert data and save response to a file using

cat file.txt | redis-cli -h 192.168.100.28 --pipe >result.txt

on windows

type file.txt | redis-cli -h 192.168.100.28 --pipe >result.txt

Then on Linux  i can see below response in my result.txt file, but when i run the same command from windows machine the result.txt file is always empty, Any help ?

Result.txt on linux machine

All data transferred. Waiting for the last reply...

Last reply received from server.

errors: 0, replies: 9844***

Result.txt on window machine
nothing always empty although running only type file.txt | redis-cli -h 192.168.100.28 --pipe
executes successfully in cmd and i see expected results in console but no data in file.


问:
Is there an alternative for textFieldLeader in SwiftUI's SecureField?
As the title says, I'm trying to add some leading padding if the user provides a symbol for the icon. This works just fine in the TextField View but a SecureField doesn't have this as an option. Is there an alternative that I'm missing?

struct PasswordInputView: View {

    @Binding var password: String
    let placeholder: String
    let sfSymbol: String?

    var body: some View {

        SecureField(placeholder, text: $password)
            .frame(maxWidth: .infinity,
                   minHeight: 44)
            .padding(.leading, sfSymbol == nil ? textFieldLeader / 2 : textFieldLeader) <---- ERROR: Cannot find textFieldLeader
            .background(

                ZStack {
                    if let systemName = sfSymbol {
                        Image(systemName: systemName)
                            .font(.system(size: 16, weight: .semibold))
                            .padding(.leading, 5)
                            .foregroundColor(Color.gray.opacity(0.5))
                    }

                    RoundedRectangle(cornerRadius: 10, style: .continuous)
                        .stroke(Color.gray.opacity(0.25))
                }

            )
    }
}
```


问:
How to use open() to read any given csv file, not a preset file name in python
Hello for my class assignment, I have to write a script that will import an csv file, then read the words in the file, count the frequency of each word and print out the list of the words with the frequency count. My problem is that I have to be able to open any given csv file. When I submit the assignment, the program will check if my script can open "input1.csv, input2.csv, input3.csv" and etc. I am having a hard time searching the web to figure out how to have open() open any give file and not just one preset file.

actual assignment:
"Write a program that first reads in the name of an input file and then reads the file using the csv.reader() method. The file contains a list of words separated by commas. Your program should output the words and their frequencies (the number of times each word appears in the file) without any duplicates."

```<code># Have to import the file type
import csv

# I have words and new_words set as list
words = []
new_words = []

# Open the file with read
with open('input1.csv, 'r') as csvfile:
    # Then read the file
    reader = csv.reader(csvfile, delimiter = ',')

    # the for loop will check for the words in the row then add them to list
    for row in reader:
        for word in row:
            words.append(word)

        # Next the for loop with check how many times the word is in the list
        for word in words:
            freq = words.count(word)

            # if the word is not in new_word it will append it to word. This allows to not have duplicated words
            if word not in new_words:
                new_words.append(word)
                # Print the word plus the count
                print(word, freq)
</code>```

Body:
Hello for my class assignment, I have to write a script that will import an csv file, then read the words in the file, count the frequency of each word and print out the list of the words with the frequency count. My problem is that I have to be able to open any given csv file. When I submit the assignment, the program will check if my script can open "input1.csv, input2.csv, input3.csv" and etc. I am having a hard time searching the web to figure out how to have open() open any give file and not just one preset file.

actual assignment:
"Write a program that first reads in the name of an input file and then reads the file using the csv.reader() method. The file contains a list of words separated by commas. Your program should output the words and their frequencies (the number of times each word appears in the file) without any duplicates."

# Have to import the file type
import csv

# I have words and new_words set as list
words = []
new_words = []

# Open the file with read
with open('input1.csv, 'r') as csvfile:
    # Then read the file
    reader = csv.reader(csvfile, delimiter = ',')

    # the for loop will check for the words in the row then add them to list
    for row in reader:
        for word in row:
            words.append(word)

        # Next the for loop with check how many times the word is in the list
        for word in words:
            freq = words.count(word)

            # if the word is not in new_word it will append it to word. This allows to not have duplicated words
            if word not in new_words:
                new_words.append(word)
                # Print the word plus the count
                print(word, freq)


问:
How to handle the string separated by a comma in csvwriter processinggroup nifi
I'm having a csv file with two columns for example column A and Columb B. Column B consists of string value like this : I am, doing good. so when I try to insert this data into a database only the string I am is getting inserted. I just want to know what attribute I need to add to the process group so that I am, doing good will get inserted to the database

The attached image consists of the attributes in the current process group


问:
Passing tokens through microservices using oauth2 authentication through GitHub
For this assignment we are to implement oauth2 using OAuth Apps in GitHub. We have two microservices UMS (UserManagmentService) and Messaging service. I am following the tutorial https://spring.io/guides/tutorials/spring-boot-oauth2/, as recommended - and it is working fine. I now have to extract the token and save it to a database with an expiry of 15 minutes in order to pass it to the other microservice (? I believe there is better ways to implement this). I would rather use JWT but do not understand the process to do so after using oauth2 through GitHub. My main questions are:

How to extract the token and store it to a database

How to set an expiry to the token

If possible, how to use a JWT instead and do the above.

I have limited knowledge of this as it is a new concept, any help would be appreciated.

INDEX.HTML

```<code><!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <title>Tweeter</title>
    <meta name="description" content=""/>
    <meta name="viewport" content="width=device-width"/>
    <base href="/"/>
    <link rel="stylesheet" type="text/css" href="/webjars/bootstrap/css/bootstrap.min.css"/>
    <script type="text/javascript" src="/webjars/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="/webjars/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/webjars/js-cookie/js.cookie.js"></script>
</head>
<body>
<h1>Welcome to Tweeter!</h1>

<div class="container unauthenticated">
    <a href="/oauth2/authorization/github">Log In With GitHub</a>
</div>
<div class="container authenticated" style="display:none">
    Logged in as: <span id="user"></span>
</div>

    <div>
        <button onClick="logout()" class="btn btn-primary">Logout</button>
    </div>
</div>

<script type="text/javascript">
    $.get("/user", function(data) {
        $("#user").html(data.name);
        $(".unauthenticated").hide()
        $(".authenticated").show()
    });

    var logout = function() {
        $.post("/logout", function() {
            $("#user").html('');
            $(".unauthenticated").show();
            $(".authenticated").hide();
        })
        return true;
    }

    $.ajaxSetup({
        beforeSend : function(xhr, settings) {
            if (settings.type == 'POST' || settings.type == 'PUT'
                || settings.type == 'DELETE') {
                if (!(/^http:.*/.test(settings.url) || /^https:.*/
                    .test(settings.url))) {
                    // Only send the token to relative URLs i.e. locally.
                    xhr.setRequestHeader("X-XSRF-TOKEN",
                        Cookies.get('XSRF-TOKEN'));
                }
            }
        }
    });
</script>
</body>
</html>
</code>```

WEBSECURITY

```<code>import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.HttpStatusEntryPoint;
import org.springframework.security.web.csrf.CookieCsrfTokenRepository;

@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {

        http
                .authorizeRequests(auth -> auth
                        .antMatchers("/", "/error", "/webjars/**").permitAll()
                        .anyRequest().authenticated()
                )
                .exceptionHandling(exc -> exc
                        .authenticationEntryPoint(new HttpStatusEntryPoint(HttpStatus.UNAUTHORIZED))
                )
                .csrf(c -> c
                        .csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
                )
                .logout(l -> l
                        .logoutSuccessUrl("/").permitAll()
                )
                .oauth2Login()
                ;
    }

}
</code>```

OAUTH2 CONTROLLER

```<code>import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClient;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClientService;
import org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken;
import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.net.http.HttpHeaders;
import java.util.Collections;
import java.util.Map;

@RestController
public class oauth2Controller {

    @Autowired
    private OAuth2AuthorizedClientService authorizedClientService;

    @GetMapping(value="/user")
    public Map<String, Object> username(@AuthenticationPrincipal OAuth2User principal) {
        return Collections.singletonMap("name", principal.getAttribute("name"));
    }

    @GetMapping(value="/getAuthentication", produces="application/json")
    public String getAuthentication(OAuth2AuthenticationToken auth) {
        return  auth.toString();
    }

    @GetMapping(value = "/getToken", produces = "application/json")
    public String getEmails(OAuth2AuthenticationToken authentication) {
        OAuth2AuthorizedClient client = authorizedClientService.loadAuthorizedClient(
                authentication.getAuthorizedClientRegistrationId(),
                authentication.getPrincipal().getName());

       String token = client.getAccessToken().getTokenValue();
      return token;
    }

}
</code>```

APPLICATION.YAML

```<code>## Server
server:
  port: 8080

## MySQL
spring:
  datasource:
    driverClassName: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://0.0.0.0:3306/ums?serverTimezone=UTC&useLegacyDatetimeCode=false
    username: root
    password: passw

#GitHub
  security:
    oauth2:
      client:
        registration:
          github:
            clientId: ***********
            clientSecret: ************
            scope: read:user, user:name
</code>```

POM.XML

```<code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.6</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>org.cst8277.gibbons.caitlyn</groupId>
    <artifactId>ums</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>ums</name>
    <description>ums</description>
    <properties>
        <java.version>17</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-oauth2-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.projectreactor</groupId>
            <artifactId>reactor-test</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- Added after creation-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
            <version>3.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>jquery</artifactId>
            <version>3.4.1</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>bootstrap</artifactId>
            <version>4.3.1</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>webjars-locator-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt-api</artifactId>
            <version>0.11.5</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>js-cookie</artifactId>
            <version>2.1.0</version>
        </dependency>
    </dependencies>

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

</project>
</code>```

Body:
For this assignment we are to implement oauth2 using OAuth Apps in GitHub. We have two microservices UMS (UserManagmentService) and Messaging service. I am following the tutorial https://spring.io/guides/tutorials/spring-boot-oauth2/, as recommended - and it is working fine. I now have to extract the token and save it to a database with an expiry of 15 minutes in order to pass it to the other microservice (? I believe there is better ways to implement this). I would rather use JWT but do not understand the process to do so after using oauth2 through GitHub. My main questions are:

How to extract the token and store it to a database

How to set an expiry to the token

If possible, how to use a JWT instead and do the above.

I have limited knowledge of this as it is a new concept, any help would be appreciated.

INDEX.HTML

<!doctype html>

    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <title>Tweeter</title>
    <meta name="description" content=""/>
    <meta name="viewport" content="width=device-width"/>
    <base href="/"/>
    <link rel="stylesheet" type="text/css" href="/webjars/bootstrap/css/bootstrap.min.css"/>

Welcome to Tweeter!

    Log In With GitHub

    Logged in as:

        <button onClick="logout()" class="btn btn-primary">Logout</button>

WEBSECURITY

import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.HttpStatusEntryPoint;
import org.springframework.security.web.csrf.CookieCsrfTokenRepository;

@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {

        http
                .authorizeRequests(auth -> auth
                        .antMatchers("/", "/error", "/webjars/**").permitAll()
                        .anyRequest().authenticated()
                )
                .exceptionHandling(exc -> exc
                        .authenticationEntryPoint(new HttpStatusEntryPoint(HttpStatus.UNAUTHORIZED))
                )
                .csrf(c -> c
                        .csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
                )
                .logout(l -> l
                        .logoutSuccessUrl("/").permitAll()
                )
                .oauth2Login()
                ;
    }

}

OAUTH2 CONTROLLER

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClient;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClientService;
import org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken;
import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.net.http.HttpHeaders;
import java.util.Collections;
import java.util.Map;

@RestController
public class oauth2Controller {

    @Autowired
    private OAuth2AuthorizedClientService authorizedClientService;

    @GetMapping(value="/user")
    public Map<String, Object> username(@AuthenticationPrincipal OAuth2User principal) {
        return Collections.singletonMap("name", principal.getAttribute("name"));
    }

    @GetMapping(value="/getAuthentication", produces="application/json")
    public String getAuthentication(OAuth2AuthenticationToken auth) {
        return  auth.toString();
    }

    @GetMapping(value = "/getToken", produces = "application/json")
    public String getEmails(OAuth2AuthenticationToken authentication) {
        OAuth2AuthorizedClient client = authorizedClientService.loadAuthorizedClient(
                authentication.getAuthorizedClientRegistrationId(),
                authentication.getPrincipal().getName());

       String token = client.getAccessToken().getTokenValue();
      return token;
    }

}

APPLICATION.YAML

## Server
server:
  port: 8080

## MySQL
spring:
  datasource:
    driverClassName: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://0.0.0.0:3306/ums?serverTimezone=UTC&useLegacyDatetimeCode=false
    username: root
    password: passw

#GitHub
  security:
    oauth2:
      client:
        registration:
          github:
            clientId: ***********
            clientSecret: ************
            scope: read:user, user:name

POM.XML

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.6</version>
        <relativePath/>
    </parent>
    <groupId>org.cst8277.gibbons.caitlyn</groupId>
    <artifactId>ums</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>ums</name>
    <description>ums</description>
    <properties>
        <java.version>17</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-oauth2-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.projectreactor</groupId>
            <artifactId>reactor-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
            <version>3.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>jquery</artifactId>
            <version>3.4.1</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>bootstrap</artifactId>
            <version>4.3.1</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>webjars-locator-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt-api</artifactId>
            <version>0.11.5</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>js-cookie</artifactId>
            <version>2.1.0</version>
        </dependency>
    </dependencies>

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

</project>


问:
Visual Studio Code (Shift + Alt + F) clearing up the code
When I press shift + alt + f in a cpp file in Visual Studio Code, it lines up the code as following below:

```<code>int main()
{
    return 0;
}
</code>```

however, I'd really like it lo line the code as following:

```<code>int main(){
    return 0;
}
</code>```

it's not that of a problem but I really don't want to fix every bracket one by one to line them up like I wish to be. Is there any extension or some sort of way to solve this issue? Thanks!

Body:
When I press shift + alt + f in a cpp file in Visual Studio Code, it lines up the code as following below:

int main()
{
    return 0;
}

however, I'd really like it lo line the code as following:

int main(){
    return 0;
}

it's not that of a problem but I really don't want to fix every bracket one by one to line them up like I wish to be. Is there any extension or some sort of way to solve this issue? Thanks!


问:
word document with strange characters instead of words
My word document has strange characters. Nothing is readable. I tried converting it to english and it was exactly the same. I have no clue how this happend and dont know what to do. it is a important document to me. please help. thank you

I tried converting it to english.


问:
pyqtgraph : how to allow a plot to only increase its range
I have a xy-plot that updates with new data.

At the first iteration, the XAxis range is automatically set to display the data. On the next iteration, new data is generated, with a potentially smaller min value, and a potentialy bigger max value. By default, pyqtgraph will adjust the range to again display the new data.

What I want is to keep the 'biggest' ranges, that is keep the smallest min limit between both data, and the biggest max limit.

Here a simple example inspired by the 'AutoRange' example from the doc :

# from the auto-range example : from pyqtgraph import examples; examples.run()
import time
import numpy as np
import pyqtgraph as pg
from pyqtgraph.Qt import QtCore

app = pg.mkQApp("Plot Auto Range Example")

win = pg.GraphicsLayoutWidget(show=True, title="Plot auto-range examples")
win.resize(800,600)
win.setWindowTitle('pyqtgraph example: PlotAutoRange')

xs = np.random.normal(size=100)
ys = np.random.normal(size=100)

p2 = win.addPlot(title="Auto Pan Only")

# AutoPan is not what I want : p2.setAutoPan(y=True)
# maybe something else here like
# p2.setRangeRule(x='onlyExtend')
# --> so that the x limits will only grow based on
# new data

curve = p2.plot(xs, ys)
t0 = time.time()

def update():
    xs = np.random.normal(size=100)
    ys = np.random.normal(size=100)

    # other possibility : manually check the old and new limits, and keep
    # the min/max I want, and then set it to the axes....
    old_box = p2.viewRect()
    old_xmin = old_box.left()
    old_xmax = old_box.right()

    # update the curve to new data (this is always wanted)
    curve.setData(xs, ys)

    new_box = p2.viewRect()
    new_xmin = new_box.left()
    new_xmax = new_box.right()

    # .... this causes the xlimits to grow indefinetely
    # p2.setRange(xRange=(min(old_xmin, new_xmin), max(old_xmax, new_xmax)))

timer = QtCore.QTimer()
timer.timeout.connect(update)
timer.start(50)

if __name__ == '__main__':
    pg.exec()
```

As you can see I tried manually get/check/set the limits but ended up with endlessly increasing xlimits (way bigger than needed just to display data).
I guess it comes down to a difference between the limits, the range, the viewbox, the rectangles, and so on. To be fair I am not familiar with the QGraphicView framework.

Body:
I have a xy-plot that updates with new data.

At the first iteration, the XAxis range is automatically set to display the data. On the next iteration, new data is generated, with a potentially smaller min value, and a potentialy bigger max value. By default, pyqtgraph will adjust the range to again display the new data.

What I want is to keep the 'biggest' ranges, that is keep the smallest min limit between both data, and the biggest max limit.

Here a simple example inspired by the 'AutoRange' example from the doc :

# from the auto-range example : from pyqtgraph import examples; examples.run()
import time
import numpy as np
import pyqtgraph as pg
from pyqtgraph.Qt import QtCore

app = pg.mkQApp("Plot Auto Range Example")

win = pg.GraphicsLayoutWidget(show=True, title="Plot auto-range examples")
win.resize(800,600)
win.setWindowTitle('pyqtgraph example: PlotAutoRange')

xs = np.random.normal(size=100)
ys = np.random.normal(size=100)

p2 = win.addPlot(title="Auto Pan Only")

# AutoPan is not what I want : p2.setAutoPan(y=True)
# maybe something else here like
# p2.setRangeRule(x='onlyExtend')
# --> so that the x limits will only grow based on
# new data

curve = p2.plot(xs, ys)
t0 = time.time()

def update():
    xs = np.random.normal(size=100)
    ys = np.random.normal(size=100)

    # other possibility : manually check the old and new limits, and keep
    # the min/max I want, and then set it to the axes....
    old_box = p2.viewRect()
    old_xmin = old_box.left()
    old_xmax = old_box.right()

    # update the curve to new data (this is always wanted)
    curve.setData(xs, ys)

    new_box = p2.viewRect()
    new_xmin = new_box.left()
    new_xmax = new_box.right()

    # .... this causes the xlimits to grow indefinetely
    # p2.setRange(xRange=(min(old_xmin, new_xmin), max(old_xmax, new_xmax)))

timer = QtCore.QTimer()
timer.timeout.connect(update)
timer.start(50)

if __name__ == '__main__':
    pg.exec()

As you can see I tried manually get/check/set the limits but ended up with endlessly increasing xlimits (way bigger than needed just to display data).
I guess it comes down to a difference between the limits, the range, the viewbox, the rectangles, and so on. To be fair I am not familiar with the QGraphicView framework.