问:
"java.util.ArrayList cannot be cast to java.util.Map"
```<code>PUT my-index-000001
{
  "mappings": {
    "dynamic_templates": [
      {
        "strings_as_keywords": {
          "match_mapping_type": "string",
          "mapping`enter code here`": {
            "type": "text",
            "norms": false,
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
        }
      }
    ]
  }
}
</code>```

I would expect that this should create and index. If you can    help me I would highly appreciate it.

Body:
PUT my-index-000001
{
  "mappings": {
    "dynamic_templates": [
      {
        "strings_as_keywords": {
          "match_mapping_type": "string",
          "mapping`enter code here`": {
            "type": "text",
            "norms": false,
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
        }
      }
    ]
  }
}

I would expect that this should create and index. If you can    help me I would highly appreciate it.


来源: stackexchange

问:
How to calculate distance or error line in an image?
I have a black line and red line. I want to calculate the distance or error value between red pixel points (error line) in the image and the black line (target line) in the most efficient and fastest way. How can I do it? Is there any opencv-python function?

this is the example of the image:

ContentLicense: CC BY-SA 4.0


问:
How to maintain the portrait position of the mobile web browser address bar even in landscape mode
I am developing a mobile first web application and I have this certain scenario.

The default behaviour of screen orientation changing from portrait to landscape is as follows:

What I want to happen is whenever I switch to to landscape mode, the address bar should remain the same as if it was still in portrait mode, like in the following image.

Is this possible to achieve?


问:
Imbalanced Dataset in R - ROSE package
I'm working in 'German Credit Risk' dataset, and noticed that target variable is imbalanced.
I tried to use the package ROSE, though it changed the predictors variables.

```<code>ds<- data.frame(read.csv("credit.csv",header =TRUE, stringsAsFactors = TRUE))
View(ds)
library(ROSE)
ds1 <- ROSE(CreditStatus ~ ., data = ds, seed = 1)$data
dim(ds1)
View(ds1)
</code>```

I'd like to know how to fix it.

I tried to find another package, but I didn't manage

Title: Imbalanced Dataset in R - ROSE package

Body:
I'm working in 'German Credit Risk' dataset, and noticed that target variable is imbalanced.
I tried to use the package ROSE, though it changed the predictors variables.

ds<- data.frame(read.csv("credit.csv",header =TRUE, stringsAsFactors = TRUE))
View(ds)
library(ROSE)
ds1 <- ROSE(CreditStatus ~ ., data = ds, seed = 1)$data
dim(ds1)
View(ds1)

I'd like to know how to fix it.

I tried to find another package, but I didn't manage


问:
How to refresh the FlatFeedCore widget after a comment is added?
Im implementing getstream io in my app. So when ever a new comment is added im calling the setstate method,to view the added comment. but eventhough the widget is geting rebuilt, its not returning the latest comment.
How do i get to see my latest comment soon when its added


问:
Change Source Control front Commit & Sync button
With a new VSCode update they changed the source control button from "commit" to "commit & sync". Personally I dislike this change and want to reverse it, so the main button will be "commit" again (I know that there are multiple options which you can select with the dropdown).

I already tried to add the following settings

```<code>     "git.showActionButton": {
        "publish": false,
        "sync": false
    }
</code>```

which didn't work, but if I say

```<code>"git.showActionButton": {
        "commit": false,
    }
</code>```

it just hides the button entirely.

Is there any possible way to change this?

#Edit 1
I found out that if I switch the project I also see the "commit" button as the main button, but if I switch back to the project of my company the "commit & sync" button appears again as the main button. Is there some kind of setting per project that can cause this?

#Edit 2
I checked a GitHub project and DevOps project. With GitHub I get the Commit button and with DevOps I get the Commit & Sync button. I hope this is helpful.

Body:
With a new VSCode update they changed the source control button from "commit" to "commit & sync". Personally I dislike this change and want to reverse it, so the main button will be "commit" again (I know that there are multiple options which you can select with the dropdown).

I already tried to add the following settings

     "git.showActionButton": {
        "publish": false,
        "sync": false
    }

which didn't work, but if I say

"git.showActionButton": {
        "commit": false,
    }

it just hides the button entirely.

Is there any possible way to change this?

#Edit 1
I found out that if I switch the project I also see the "commit" button as the main button, but if I switch back to the project of my company the "commit & sync" button appears again as the main button. Is there some kind of setting per project that can cause this?

#Edit 2
I checked a GitHub project and DevOps project. With GitHub I get the Commit button and with DevOps I get the Commit & Sync button. I hope this is helpful.


问:
Apple Watch Prevent from being inActive when User wrist down
I want the specific behaviour from my apple watch, i am developing a Fitness app in apple watch.

Problem:

When user will be on some specific screen (e.g. Download ODRs from firebase). user faces issue that when user slightly down their wrist and Screen goes deem and Refresh rate goes to 1 FPS. Client has special requirement that Screen should not go to Sleep When that particular downloading process is running.

References(Example):

I tried to find solution everywhere and found some questions also over StackOverflow about this but there also saying not possible so i still haven't found anything related to this but i have found one example that is doing this behaviour is Apple watch app Mindfulness. When user runs this app and start the session as much time user will be on that screen watch will not go to inactive state no matter user raise the hand or lower down the hand.

i want to implement that same behaviour in my app. Client wants no mater what ever it takes make it work. (No issues with battery life also or Computation). i may need to implement this kind of behaviour in other screens as well.

I have tried one solution that is to Turn on auto Rotate so that when user slightly turns their wrist it will rotate instead of going to Sleep or inactive state, but it isn't the solution and looks like something weird behaviour

I have also tried TimelineView() but it will be useful once watch goes to inactive state and also it is useful when doing computations but if i have to update UI it will only do it at 1FPS in inactive state no matter how frequent your data is updating.

Thanks in advance :)


问:
The code signature version is no longer supported. iOS 16.2
I run my App to my device and get this error.

This is my device version.

```<code>macOS Version 12.6.1 (Build 21G217)
Xcode 14.1 (21534.1) (Build 14B47b)
iPadOS 16.2
</code>```

I also try to add --generate-entitlement-der in Other Code Signin Flags.

And not work for me.

Is my MacOS version or Xcode version too low?

Body:
I run my App to my device and get this error.

This is my device version.

macOS Version 12.6.1 (Build 21G217)
Xcode 14.1 (21534.1) (Build 14B47b)
iPadOS 16.2

I also try to add --generate-entitlement-der in Other Code Signin Flags.

And not work for me.

Is my MacOS version or Xcode version too low?


问:
Android Alarm Manager with Kivy not working
I am trying to run a service, declared in buildozer.spec with Alarm Manager, but unfortunately it throws an error. I need Alarm Manager in order to schedule my service to run every day.

Let me just get to the point. I have this simple service in Buildozer that just makes few requests to my api:

```<code>    from time import sleep

    url = "some/url"

    while True:
        requests.get(url)
        sleep(30)
</code>```

And a simple Kivy app that runs this service in the 'on_start' function:

```<code>    from kivymd.app import MDApp

    class MainApp(MDApp):
        def on_start(self):
            if platform == "android":
                self.service_start()
        def service_start(self):
            from jnius import autoclass
            service = autoclass("org.my.app.ServiceMyservice")
            mActivity = autoclass("org.kivy.android.PythonActivity").mActivity
            service.start(mActivity, "")
            return service
</code>```

Obviously I have 'build' function and everything else set up so the app runs and with it, the service.

Now I would like to run the service forever or at least once a day, so I increase the 'sleep', but Android stops it after one loop. Therefore, I am trying to use Android Alarm Manager to schedule the service each day, but am failing to do so. I tried it like so:

```<code>    def on_start(self):
            from jnius import autoclass
            service = autoclass("org.my.app.ServiceMyservice")
            #get activtiy
            activity = autoclass('org.kivy.android.PythonActivity').mActivity
            #get manager
            AlarmManager = autoclass('android.app.AlarmManager')
            alarm_manager = activity.getSystemService(activity.ALARM_SERVICE)

            PendingIntent = autoclass('android.app.PendingIntent')
            Intent = autoclass('android.content.Intent')

            interval = 86400 * 1000 #   1day
            request_code = 0
            intent = Intent(activity, service)
            pending_intent = PendingIntent.getService(activity, request_code, intent, 0)
            alarm_manager.setRepeating(AlarmManager.RTC, 0, interval, pending_intent)
            return alarm_manager
</code>```

And I've changed my service from a while loop to a function, but it throws the following java error:

```<code>java.lang.RuntimeException: Unable to start service org.my.app.ServiceMyservice@7c59518 with Intent { flg=0x4 cmp=org.my.app/.ServiceMyservice (has extras) }: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
</code>```

Here is the relevant part of my log. It starts the main loop and the service, but it immediately crashes. The GUI is unaffected, it just says the service has stopped running on android device.

```<code>01-05 22:53:11.159  1663    1878    system_server   I   ActivityManager Start proc 13900:org.dasadweb.eamenu:service_Meni/u0a404 for service {org.dasadweb.eamenu/org.dasadweb.eamenu.ServiceMeni}
01-05 22:53:11.164  1362    1412    adbd    I   adbd    jdwp connection from 13899
01-05 22:53:11.164  13900   13900   No info available   I   libc    SetHeapTaggingLevel: tag level set to 0
01-05 22:53:11.164  13899   13899   No info available   D   ProcessState    Binder ioctl to enable oneway spam detection failed: Invalid argument
01-05 22:53:11.169  1663    12867   system_server   D   CompatibilityChangeReporter Compat change id reported: 168419799; UID 10291; state: DISABLED
01-05 22:53:11.170  13900   13900   No info available   I   nu:service_Men  Late-enabling -Xcheck:jni
01-05 22:53:11.174  13899   13899   No info available   D   CompatibilityChangeReporter Compat change id reported: 171979766; UID 10291; state: DISABLED
01-05 22:53:11.181  13899   13899   No info available   D   ApplicationLoaders  Returning zygote-cached class loader: /system/framework/android.test.base.jar
01-05 22:53:11.204  1362    1412    adbd    I   adbd    jdwp connection from 13900
01-05 22:53:11.206  13900   13900   No info available   D   ProcessState    Binder ioctl to enable oneway spam detection failed: Invalid argument
01-05 22:53:11.234  13900   13900   No info available   D   CompatibilityChangeReporter Compat change id reported: 171979766; UID 10404; state: DISABLED
01-05 22:53:11.239  13899   13899   No info available   V   GraphicsEnvironment ANGLE Developer option for 'com.google.android.apps.authenticator2' set to: 'default'
01-05 22:53:11.240  13899   13899   No info available   V   GraphicsEnvironment ANGLE GameManagerService for com.google.android.apps.authenticator2: false
01-05 22:53:11.241  13899   13899   No info available   V   GraphicsEnvironment Neither updatable production driver nor prerelease driver is supported.
01-05 22:53:11.242  13900   13900   No info available   D   ApplicationLoaders  Returning zygote-cached class loader: /system/framework/android.test.base.jar
01-05 22:53:11.242  13899   13899   No info available   D   NetworkSecurityConfig   No Network Security Config specified, using platform default
01-05 22:53:11.243  13899   13899   No info available   D   NetworkSecurityConfig   No Network Security Config specified, using platform default
01-05 22:53:11.245  13899   13899   No info available   I   MultiDex    VM with version 2.1.0 has multidex support
01-05 22:53:11.245  13899   13899   No info available   I   MultiDex    install
01-05 22:53:11.245  13899   13899   No info available   I   MultiDex    VM has multidex support, MultiDex support library is disabled.
01-05 22:53:11.259  13900   13900   No info available   V   GraphicsEnvironment ANGLE Developer option for 'org.dasadweb.eamenu' set to: 'default'
01-05 22:53:11.259  13900   13900   No info available   V   GraphicsEnvironment ANGLE GameManagerService for org.dasadweb.eamenu: false
01-05 22:53:11.260  13900   13900   No info available   V   GraphicsEnvironment Neither updatable production driver nor prerelease driver is supported.
01-05 22:53:11.262  13900   13900   No info available   D   NetworkSecurityConfig   No Network Security Config specified, using platform default
01-05 22:53:11.263  13900   13900   No info available   D   NetworkSecurityConfig   No Network Security Config specified, using platform default
01-05 22:53:11.267  13900   13900   No info available   D   AndroidRuntime  Shutting down VM
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime  FATAL EXCEPTION: main
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime  Process: org.dasadweb.eamenu:service_Meni, PID: 13900
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime  java.lang.RuntimeException: Unable to start service org.dasadweb.eamenu.ServiceMeni@7c59518 with Intent { flg=0x4 cmp=org.dasadweb.eamenu/.ServiceMeni (has extras) }: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime      at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4724)
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime      at android.app.ActivityThread.access$2000(ActivityThread.java:256)
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2129)
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime      at android.os.Handler.dispatchMessage(Handler.java:106)
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime      at android.os.Looper.loopOnce(Looper.java:201)
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime      at android.os.Looper.loop(Looper.java:288)
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime      at android.app.ActivityThread.main(ActivityThread.java:7870)
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime      at java.lang.reflect.Method.invoke(Native Method)
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime  Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime      at org.kivy.android.PythonService.onStartCommand(PythonService.java:82)
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime      at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4706)
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime      ... 9 more
01-05 22:53:11.271  1663    13934   system_server   I   DropBoxManagerService   add tag=data_app_crash isTagEnabled=true flags=0x2
01-05 22:53:11.273  13900   13900   No info available   I   Process Sending signal. PID: 13900 SIG: 9
01-05 22:53:11.279  1663    1882    system_server   I   libprocessgroup Successfully killed process cgroup uid 10404 pid 13900 in 0ms
01-05 22:53:11.279  1663    12867   system_server   I   ActivityManager Process org.dasadweb.eamenu:service_Meni (pid 13900) has died: fg  SVC
01-05 22:53:11.280  1011    1011    zygote64    I   Zygote  Process 13900 exited due to signal 9 (Killed)
01-05 22:53:11.280  1663    12867   system_server   W   ActivityManager Scheduling restart of crashed service org.dasadweb.eamenu/.ServiceMeni in 1000ms for start-requested
01-05 22:53:11.281  29928   12525   com.google.android.gms  D   GmsServicesProvider query caller=com.google.android.apps.authenticator2 name=primes:shutdown_primes value=false
01-05 22:53:11.350  29928   29928   com.google.android.gms  D   ClearcutLoggerService   onBind: Intent { act=com.google.android.gms.clearcut.service.START pkg=com.google.android.gms }
01-05 22:53:11.354  29928   9504    com.google.android.gms  D   ClearcutLoggerService   bound by: GetServiceRequest{serviceId=CLEARCUT_LOGGER, gmsVersion=201802000, packageName='com.google.android.apps.authenticator2', extras=Bundle[{}]}
01-05 22:53:12.284  1663    1877    system_server   D   CompatibilityChangeReporter Compat change id reported: 135634846; UID 10404; state: DISABLED
01-05 22:53:12.285  1663    1877    system_server   D   CompatibilityChangeReporter Compat change id reported: 177438394; UID 10404; state: DISABLED
01-05 22:53:12.285  1663    1877    system_server   D   CompatibilityChangeReporter Compat change id reported: 135772972; UID 10404; state: DISABLED
01-05 22:53:12.285  1663    1877    system_server   D   CompatibilityChangeReporter Compat change id reported: 135754954; UID 10404; state: DISABLED
01-05 22:53:12.286  1663    1878    system_server   D   CompatibilityChangeReporter Compat change id reported: 143937733; UID 10404; state: DISABLED
01-05 22:53:12.298  1011    1011    zygote64    D   Zygote  Forked child process 13941
01-05 22:53:12.299  1663    1878    system_server   I   ActivityManager Start proc 13941:org.dasadweb.eamenu:service_Meni/u0a404 for service {org.dasadweb.eamenu/org.dasadweb.eamenu.ServiceMeni}
01-05 22:53:12.304  13941   13941   No info available   I   libc    SetHeapTaggingLevel: tag level set to 0
01-05 22:53:12.307  13941   13941   No info available   I   nu:service_Men  Late-enabling -Xcheck:jni
01-05 22:53:12.329  1362    1412    adbd    I   adbd    jdwp connection from 13941
01-05 22:53:12.331  13941   13941   No info available   D   ProcessState    Binder ioctl to enable oneway spam detection failed: Invalid argument
01-05 22:53:12.361  13941   13941   No info available   D   CompatibilityChangeReporter Compat change id reported: 171979766; UID 10404; state: DISABLED
01-05 22:53:12.378  13941   13941   No info available   D   ApplicationLoaders  Returning zygote-cached class loader: /system/framework/android.test.base.jar
01-05 22:53:12.420  13941   13941   No info available   V   GraphicsEnvironment ANGLE Developer option for 'org.dasadweb.eamenu' set to: 'default'
01-05 22:53:12.421  13941   13941   No info available   V   GraphicsEnvironment ANGLE GameManagerService for org.dasadweb.eamenu: false
01-05 22:53:12.421  13941   13941   org.dasadweb.eamenu:service_Meni    V   GraphicsEnvironment Neither updatable production driver nor prerelease driver is supported.
01-05 22:53:12.427  13941   13941   org.dasadweb.eamenu:service_Meni    D   NetworkSecurityConfig   No Network Security Config specified, using platform default
01-05 22:53:12.429  13941   13941   org.dasadweb.eamenu:service_Meni    D   NetworkSecurityConfig   No Network Security Config specified, using platform default
01-05 22:53:12.441  13941   13941   org.dasadweb.eamenu:service_Meni    D   AndroidRuntime  Shutting down VM
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime  FATAL EXCEPTION: main
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime  Process: org.dasadweb.eamenu:service_Meni, PID: 13941
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime  java.lang.RuntimeException: Unable to start service org.dasadweb.eamenu.ServiceMeni@7c59518 with Intent { flg=0x4 cmp=org.dasadweb.eamenu/.ServiceMeni (has extras) }: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime      at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4724)
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime      at android.app.ActivityThread.access$2000(ActivityThread.java:256)
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2129)
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime      at android.os.Handler.dispatchMessage(Handler.java:106)
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime      at android.os.Looper.loopOnce(Looper.java:201)
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime      at android.os.Looper.loop(Looper.java:288)
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime      at android.app.ActivityThread.main(ActivityThread.java:7870)
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime      at java.lang.reflect.Method.invoke(Native Method)
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime  Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime      at org.kivy.android.PythonService.onStartCommand(PythonService.java:82)
01-05 22:53:12.444  13941   13941   org.dasadweb.eamenu:service_Meni    E   AndroidRuntime      at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4706)
01-05 22:53:12.444  13941   13941   org.dasadweb.eamenu:service_Meni    E   AndroidRuntime      ... 9 more
01-05 22:53:12.450  1663    13961   system_server   I   DropBoxManagerService   add tag=data_app_crash isTagEnabled=true flags=0x2
01-05 22:53:12.511  13474   13474   org.dasadweb.eamenu V   SDL onWindowFocusChanged(): false
01-05 22:53:12.511  13474   13474   org.dasadweb.eamenu V   SDL nativePause()
</code>```

Am I doing something wrong, or is there another way of doing it? Every answer is appreciated :)

Thank you!

Body:
I am trying to run a service, declared in buildozer.spec with Alarm Manager, but unfortunately it throws an error. I need Alarm Manager in order to schedule my service to run every day.

Let me just get to the point. I have this simple service in Buildozer that just makes few requests to my api:

    from time import sleep

    url = "some/url"

    while True:
        requests.get(url)
        sleep(30)

And a simple Kivy app that runs this service in the 'on_start' function:

    from kivymd.app import MDApp

    class MainApp(MDApp):
        def on_start(self):
            if platform == "android":
                self.service_start()
        def service_start(self):
            from jnius import autoclass
            service = autoclass("org.my.app.ServiceMyservice")
            mActivity = autoclass("org.kivy.android.PythonActivity").mActivity
            service.start(mActivity, "")
            return service

Obviously I have 'build' function and everything else set up so the app runs and with it, the service.

Now I would like to run the service forever or at least once a day, so I increase the 'sleep', but Android stops it after one loop. Therefore, I am trying to use Android Alarm Manager to schedule the service each day, but am failing to do so. I tried it like so:

    def on_start(self):
            from jnius import autoclass
            service = autoclass("org.my.app.ServiceMyservice")
            #get activtiy
            activity = autoclass('org.kivy.android.PythonActivity').mActivity
            #get manager
            AlarmManager = autoclass('android.app.AlarmManager')
            alarm_manager = activity.getSystemService(activity.ALARM_SERVICE)

            PendingIntent = autoclass('android.app.PendingIntent')
            Intent = autoclass('android.content.Intent')

            interval = 86400 * 1000 #   1day
            request_code = 0
            intent = Intent(activity, service)
            pending_intent = PendingIntent.getService(activity, request_code, intent, 0)
            alarm_manager.setRepeating(AlarmManager.RTC, 0, interval, pending_intent)
            return alarm_manager

And I've changed my service from a while loop to a function, but it throws the following java error:

java.lang.RuntimeException: Unable to start service org.my.app.ServiceMyservice@7c59518 with Intent { flg=0x4 cmp=org.my.app/.ServiceMyservice (has extras) }: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference

Here is the relevant part of my log. It starts the main loop and the service, but it immediately crashes. The GUI is unaffected, it just says the service has stopped running on android device.

01-05 22:53:11.159  1663    1878    system_server   I   ActivityManager Start proc 13900:org.dasadweb.eamenu:service_Meni/u0a404 for service {org.dasadweb.eamenu/org.dasadweb.eamenu.ServiceMeni}
01-05 22:53:11.164  1362    1412    adbd    I   adbd    jdwp connection from 13899
01-05 22:53:11.164  13900   13900   No info available   I   libc    SetHeapTaggingLevel: tag level set to 0
01-05 22:53:11.164  13899   13899   No info available   D   ProcessState    Binder ioctl to enable oneway spam detection failed: Invalid argument
01-05 22:53:11.169  1663    12867   system_server   D   CompatibilityChangeReporter Compat change id reported: 168419799; UID 10291; state: DISABLED
01-05 22:53:11.170  13900   13900   No info available   I   nu:service_Men  Late-enabling -Xcheck:jni
01-05 22:53:11.174  13899   13899   No info available   D   CompatibilityChangeReporter Compat change id reported: 171979766; UID 10291; state: DISABLED
01-05 22:53:11.181  13899   13899   No info available   D   ApplicationLoaders  Returning zygote-cached class loader: /system/framework/android.test.base.jar
01-05 22:53:11.204  1362    1412    adbd    I   adbd    jdwp connection from 13900
01-05 22:53:11.206  13900   13900   No info available   D   ProcessState    Binder ioctl to enable oneway spam detection failed: Invalid argument
01-05 22:53:11.234  13900   13900   No info available   D   CompatibilityChangeReporter Compat change id reported: 171979766; UID 10404; state: DISABLED
01-05 22:53:11.239  13899   13899   No info available   V   GraphicsEnvironment ANGLE Developer option for 'com.google.android.apps.authenticator2' set to: 'default'
01-05 22:53:11.240  13899   13899   No info available   V   GraphicsEnvironment ANGLE GameManagerService for com.google.android.apps.authenticator2: false
01-05 22:53:11.241  13899   13899   No info available   V   GraphicsEnvironment Neither updatable production driver nor prerelease driver is supported.
01-05 22:53:11.242  13900   13900   No info available   D   ApplicationLoaders  Returning zygote-cached class loader: /system/framework/android.test.base.jar
01-05 22:53:11.242  13899   13899   No info available   D   NetworkSecurityConfig   No Network Security Config specified, using platform default
01-05 22:53:11.243  13899   13899   No info available   D   NetworkSecurityConfig   No Network Security Config specified, using platform default
01-05 22:53:11.245  13899   13899   No info available   I   MultiDex    VM with version 2.1.0 has multidex support
01-05 22:53:11.245  13899   13899   No info available   I   MultiDex    install
01-05 22:53:11.245  13899   13899   No info available   I   MultiDex    VM has multidex support, MultiDex support library is disabled.
01-05 22:53:11.259  13900   13900   No info available   V   GraphicsEnvironment ANGLE Developer option for 'org.dasadweb.eamenu' set to: 'default'
01-05 22:53:11.259  13900   13900   No info available   V   GraphicsEnvironment ANGLE GameManagerService for org.dasadweb.eamenu: false
01-05 22:53:11.260  13900   13900   No info available   V   GraphicsEnvironment Neither updatable production driver nor prerelease driver is supported.
01-05 22:53:11.262  13900   13900   No info available   D   NetworkSecurityConfig   No Network Security Config specified, using platform default
01-05 22:53:11.263  13900   13900   No info available   D   NetworkSecurityConfig   No Network Security Config specified, using platform default
01-05 22:53:11.267  13900   13900   No info available   D   AndroidRuntime  Shutting down VM
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime  FATAL EXCEPTION: main
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime  Process: org.dasadweb.eamenu:service_Meni, PID: 13900
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime  java.lang.RuntimeException: Unable to start service org.dasadweb.eamenu.ServiceMeni@7c59518 with Intent { flg=0x4 cmp=org.dasadweb.eamenu/.ServiceMeni (has extras) }: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime      at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4724)
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime      at android.app.ActivityThread.access$2000(ActivityThread.java:256)
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2129)
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime      at android.os.Handler.dispatchMessage(Handler.java:106)
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime      at android.os.Looper.loopOnce(Looper.java:201)
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime      at android.os.Looper.loop(Looper.java:288)
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime      at android.app.ActivityThread.main(ActivityThread.java:7870)
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime      at java.lang.reflect.Method.invoke(Native Method)
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime  Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime      at org.kivy.android.PythonService.onStartCommand(PythonService.java:82)
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime      at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4706)
01-05 22:53:11.268  13900   13900   No info available   E   AndroidRuntime      ... 9 more
01-05 22:53:11.271  1663    13934   system_server   I   DropBoxManagerService   add tag=data_app_crash isTagEnabled=true flags=0x2
01-05 22:53:11.273  13900   13900   No info available   I   Process Sending signal. PID: 13900 SIG: 9
01-05 22:53:11.279  1663    1882    system_server   I   libprocessgroup Successfully killed process cgroup uid 10404 pid 13900 in 0ms
01-05 22:53:11.279  1663    12867   system_server   I   ActivityManager Process org.dasadweb.eamenu:service_Meni (pid 13900) has died: fg  SVC
01-05 22:53:11.280  1011    1011    zygote64    I   Zygote  Process 13900 exited due to signal 9 (Killed)
01-05 22:53:11.280  1663    12867   system_server   W   ActivityManager Scheduling restart of crashed service org.dasadweb.eamenu/.ServiceMeni in 1000ms for start-requested
01-05 22:53:11.281  29928   12525   com.google.android.gms  D   GmsServicesProvider query caller=com.google.android.apps.authenticator2 name=primes:shutdown_primes value=false
01-05 22:53:11.350  29928   29928   com.google.android.gms  D   ClearcutLoggerService   onBind: Intent { act=com.google.android.gms.clearcut.service.START pkg=com.google.android.gms }
01-05 22:53:11.354  29928   9504    com.google.android.gms  D   ClearcutLoggerService   bound by: GetServiceRequest{serviceId=CLEARCUT_LOGGER, gmsVersion=201802000, packageName='com.google.android.apps.authenticator2', extras=Bundle[{}]}
01-05 22:53:12.284  1663    1877    system_server   D   CompatibilityChangeReporter Compat change id reported: 135634846; UID 10404; state: DISABLED
01-05 22:53:12.285  1663    1877    system_server   D   CompatibilityChangeReporter Compat change id reported: 177438394; UID 10404; state: DISABLED
01-05 22:53:12.285  1663    1877    system_server   D   CompatibilityChangeReporter Compat change id reported: 135772972; UID 10404; state: DISABLED
01-05 22:53:12.285  1663    1877    system_server   D   CompatibilityChangeReporter Compat change id reported: 135754954; UID 10404; state: DISABLED
01-05 22:53:12.286  1663    1878    system_server   D   CompatibilityChangeReporter Compat change id reported: 143937733; UID 10404; state: DISABLED
01-05 22:53:12.298  1011    1011    zygote64    D   Zygote  Forked child process 13941
01-05 22:53:12.299  1663    1878    system_server   I   ActivityManager Start proc 13941:org.dasadweb.eamenu:service_Meni/u0a404 for service {org.dasadweb.eamenu/org.dasadweb.eamenu.ServiceMeni}
01-05 22:53:12.304  13941   13941   No info available   I   libc    SetHeapTaggingLevel: tag level set to 0
01-05 22:53:12.307  13941   13941   No info available   I   nu:service_Men  Late-enabling -Xcheck:jni
01-05 22:53:12.329  1362    1412    adbd    I   adbd    jdwp connection from 13941
01-05 22:53:12.331  13941   13941   No info available   D   ProcessState    Binder ioctl to enable oneway spam detection failed: Invalid argument
01-05 22:53:12.361  13941   13941   No info available   D   CompatibilityChangeReporter Compat change id reported: 171979766; UID 10404; state: DISABLED
01-05 22:53:12.378  13941   13941   No info available   D   ApplicationLoaders  Returning zygote-cached class loader: /system/framework/android.test.base.jar
01-05 22:53:12.420  13941   13941   No info available   V   GraphicsEnvironment ANGLE Developer option for 'org.dasadweb.eamenu' set to: 'default'
01-05 22:53:12.421  13941   13941   No info available   V   GraphicsEnvironment ANGLE GameManagerService for org.dasadweb.eamenu: false
01-05 22:53:12.421  13941   13941   org.dasadweb.eamenu:service_Meni    V   GraphicsEnvironment Neither updatable production driver nor prerelease driver is supported.
01-05 22:53:12.427  13941   13941   org.dasadweb.eamenu:service_Meni    D   NetworkSecurityConfig   No Network Security Config specified, using platform default
01-05 22:53:12.429  13941   13941   org.dasadweb.eamenu:service_Meni    D   NetworkSecurityConfig   No Network Security Config specified, using platform default
01-05 22:53:12.441  13941   13941   org.dasadweb.eamenu:service_Meni    D   AndroidRuntime  Shutting down VM
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime  FATAL EXCEPTION: main
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime  Process: org.dasadweb.eamenu:service_Meni, PID: 13941
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime  java.lang.RuntimeException: Unable to start service org.dasadweb.eamenu.ServiceMeni@7c59518 with Intent { flg=0x4 cmp=org.dasadweb.eamenu/.ServiceMeni (has extras) }: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime      at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4724)
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime      at android.app.ActivityThread.access$2000(ActivityThread.java:256)
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2129)
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime      at android.os.Handler.dispatchMessage(Handler.java:106)
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime      at android.os.Looper.loopOnce(Looper.java:201)
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime      at android.os.Looper.loop(Looper.java:288)
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime      at android.app.ActivityThread.main(ActivityThread.java:7870)
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime      at java.lang.reflect.Method.invoke(Native Method)
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime  Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
01-05 22:53:12.444  13941   13941   No info available   E   AndroidRuntime      at org.kivy.android.PythonService.onStartCommand(PythonService.java:82)
01-05 22:53:12.444  13941   13941   org.dasadweb.eamenu:service_Meni    E   AndroidRuntime      at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4706)
01-05 22:53:12.444  13941   13941   org.dasadweb.eamenu:service_Meni    E   AndroidRuntime      ... 9 more
01-05 22:53:12.450  1663    13961   system_server   I   DropBoxManagerService   add tag=data_app_crash isTagEnabled=true flags=0x2
01-05 22:53:12.511  13474   13474   org.dasadweb.eamenu V   SDL onWindowFocusChanged(): false
01-05 22:53:12.511  13474   13474   org.dasadweb.eamenu V   SDL nativePause()

Am I doing something wrong, or is there another way of doing it? Every answer is appreciated :)

Thank you!


问:
How to maintain states for multiple tabs having same panel Components
How to maintain states for multiple tabs having same panel Components. For example, on tab1 it shows user1 details, on tab2 it shows user2 details. But when I click on tab2 details or inner components it also happen on tab1 because of same redux state. How to manage different state? Maybe on basis of tab index? Or whatever you could suggest.

```<code><Tabs
  onChange={handleCurrentPatient}
  value={currentPatient}
  variant="scrollable"
  scrollButtons="auto"
  textColor="primary"
  indicatorColor="primary"
>
  <Tab label="Patients" />
  {dynTabs.map((patient, ind) => (
    <Tab
      label={patient.patientName}
      onClick={() => {
        dispatch(SetCurrentPatient(patient.emrId));
      }}
      value={patient.emrId}
      key={ind}
      icon={
        patient.closeIcon ? (
          <Box onClick={(e) => e.stopPropagation()}>
            <CloseIcon
              // fontSize="small"
              style={{ fontSize: "16px" }}
            />
          </Box>
        ) : (
          ""
        )
      }
      iconPosition="end"
    />
  ))}
</Tabs>;
{
  dynTabs.map((item2, index) =>
    item2.emrId == currentPatient ? (
      PatientList.map((item1, key2) =>
        currentPatient == item1.emrId ? ( // tab body of current active tab
          <TabPanel key={key2} value={index} index={index}>
            <PatientInfo data={item1}></PatientInfo>
            <Divider sx={{ borderTop: 1, borderTopColor: "#186ad1" }} />
            <PatientRecordTabs />
          </TabPanel>
        ) : (
          <></>
        )
      )
    ) : (
      <>{dynTabs.length == 0 ? setCurrentPatient("000") : <></>}</>
    )
  );
}
</code>```

I want different states for same tab panel components on basis of tab id or index whatever. Any suggestions?

Body:
How to maintain states for multiple tabs having same panel Components. For example, on tab1 it shows user1 details, on tab2 it shows user2 details. But when I click on tab2 details or inner components it also happen on tab1 because of same redux state. How to manage different state? Maybe on basis of tab index? Or whatever you could suggest.

<Tabs
  onChange={handleCurrentPatient}
  value={currentPatient}
  variant="scrollable"
  scrollButtons="auto"
  textColor="primary"
  indicatorColor="primary"
>
  <Tab label="Patients" />
  {dynTabs.map((patient, ind) => (
    <Tab
      label={patient.patientName}
      onClick={() => {
        dispatch(SetCurrentPatient(patient.emrId));
      }}
      value={patient.emrId}
      key={ind}
      icon={
        patient.closeIcon ? (
          <Box onClick={(e) => e.stopPropagation()}>
            <CloseIcon
              // fontSize="small"
              style={{ fontSize: "16px" }}
            />
          </Box>
        ) : (
          ""
        )
      }
      iconPosition="end"
    />
  ))}
</Tabs>;
{
  dynTabs.map((item2, index) =>
    item2.emrId == currentPatient ? (
      PatientList.map((item1, key2) =>
        currentPatient == item1.emrId ? ( // tab body of current active tab
          <TabPanel key={key2} value={index} index={index}>
            <PatientInfo data={item1}></PatientInfo>
            <Divider sx={{ borderTop: 1, borderTopColor: "#186ad1" }} />
            <PatientRecordTabs />
          </TabPanel>
        ) : (
          <></>
        )
      )
    ) : (
      <>{dynTabs.length == 0 ? setCurrentPatient("000") : <></>}</>
    )
  );
}

I want different states for same tab panel components on basis of tab id or index whatever. Any suggestions?


问:
How to get grpc.ServiceDesc info in golang
I need to fetch custom options from proto and for that I need serviceDescriptor in golang. I am not using 'protoc-gen-go-grpc' to compile protos since it's an existing project and can't enforce everyone to use protoc-gen-go-grpc now. In existing generated .pb file, it is in an unexported format. Please help me with the way to get grpc.ServiceDesc value.</p>


问:
getting the following error when splitting test and train data in colab
Test_train split and please provide an explanation

I tried to change the test_split from 0.2 to 0.4, but I do not know what singleton is.

enter image description here


问:
UE5 How to set output pin values in customized AnimNode?
I have a customized AnimNode, I overrided CreateOutputPins func:

```<code>virtual void CreateOutputPins() override
    {
        const UAnimationGraphSchema* Schema = GetDefault<UAnimationGraphSchema>();
        CreatePin(EGPD_Output, Schema->PC_Struct, TEXT("HeadPose"), TBaseStructure<FVector>::Get(), /*bIsArray=*/ false,
                  /*bIsReference=*/ false, TEXT("HeadPose"));
        CreatePin(EGPD_Output, Schema->PC_Struct, TEXT("EyePose"), TBaseStructure<FVector>::Get(), /*bIsArray=*/ false,
                  /*bIsReference=*/ false, TEXT("EyePose"));
        Super::CreateOutputPins();
    }
</code>```

Then I can get a node like this:

Which gives me out Vector output.

Question is: How Can I set the output values calculated from my Node?

Body:
I have a customized AnimNode, I overrided CreateOutputPins func:

virtual void CreateOutputPins() override
    {
        const UAnimationGraphSchema* Schema = GetDefault<UAnimationGraphSchema>();
        CreatePin(EGPD_Output, Schema->PC_Struct, TEXT("HeadPose"), TBaseStructure<FVector>::Get(), /*bIsArray=*/ false,
                  /*bIsReference=*/ false, TEXT("HeadPose"));
        CreatePin(EGPD_Output, Schema->PC_Struct, TEXT("EyePose"), TBaseStructure<FVector>::Get(), /*bIsArray=*/ false,
                  /*bIsReference=*/ false, TEXT("EyePose"));
        Super::CreateOutputPins();
    }

Then I can get a node like this:

Which gives me out Vector output.

Question is: How Can I set the output values calculated from my Node?


问:
Drake matrix indexing issue
This code errors in Drake:

```<code>forces_matrix = np.zeros((T - 1, O, O, D))
tril_indices = np.tril_indices(O, m=O, k=-1)
forces_matrix[:, tril_indices[0], tril_indices[1]] = f_oo
</code>```

But it works in PyTorch / Numpy.

The LHS and RHS are both 9, 1, 1 shape numpy tensors.

Is this type of operation not supported in Drake?

EDIT: No more syntax error if the initial forces_matrix is OBJECT type. However, I am not sure if the computation graph is being built correctly connecting f_oo and forces_matrix. Is this type of operation supported?

Title: Drake matrix indexing issue

Body:
This code errors in Drake:

forces_matrix = np.zeros((T - 1, O, O, D))
tril_indices = np.tril_indices(O, m=O, k=-1)
forces_matrix[:, tril_indices[0], tril_indices[1]] = f_oo

But it works in PyTorch / Numpy.

The LHS and RHS are both 9, 1, 1 shape numpy tensors.

Is this type of operation not supported in Drake?

EDIT: No more syntax error if the initial forces_matrix is OBJECT type. However, I am not sure if the computation graph is being built correctly connecting f_oo and forces_matrix. Is this type of operation supported?


问:
How to filter entities dynamically on Spring boot where clauses will be defined by frontend
I have an entity with the following properties

```<code>public class DistributorMasterData  implements Serializable {
    @Id
    @Column(updatable = false, nullable = false)
    private Long id;
    private String distributorName;
    private String distributorCode;
    private String ownerName;
    private String address;

}
</code>```

I can write specification to filter data. But the filtering conditions are defined by me in the above way

```<code> @Override
    public Predicate toPredicate(Root<DistributorMasterData> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) {
        return codeSpec()
                .and(idSpec())
                .toPredicate(root, query, criteriaBuilder);
    }

    private Specification<DistributorMasterData> idSpec() {
        return ((root, query, criteriaBuilder) -> Objects.isNull(criteria.getDistributorIds()) ?
                null : root.get(DistributorMasterData_.ID).in(criteria.getDistributorIds())
        );
    }

    private Specification<DistributorMasterData> codeSpec() {
          return Objects.nonNull(criteria.getDistributorCode()) ? buildStringSpecification(criteria.getDistributorCode(), DistributorMasterData_.distributorCode) : null;
    }
</code>```

But what I want to achieve is total dynamic control where user will decide if the want to find data which are greater than the value the have selected or less than or equal. How can I achieve that?

Body:
I have an entity with the following properties

public class DistributorMasterData  implements Serializable {
    @Id
    @Column(updatable = false, nullable = false)
    private Long id;
    private String distributorName;
    private String distributorCode;
    private String ownerName;
    private String address;

}

I can write specification to filter data. But the filtering conditions are defined by me in the above way

 @Override
    public Predicate toPredicate(Root<DistributorMasterData> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) {
        return codeSpec()
                .and(idSpec())
                .toPredicate(root, query, criteriaBuilder);
    }

    private Specification<DistributorMasterData> idSpec() {
        return ((root, query, criteriaBuilder) -> Objects.isNull(criteria.getDistributorIds()) ?
                null : root.get(DistributorMasterData_.ID).in(criteria.getDistributorIds())
        );
    }

    private Specification<DistributorMasterData> codeSpec() {
          return Objects.nonNull(criteria.getDistributorCode()) ? buildStringSpecification(criteria.getDistributorCode(), DistributorMasterData_.distributorCode) : null;
    }

But what I want to achieve is total dynamic control where user will decide if the want to find data which are greater than the value the have selected or less than or equal. How can I achieve that?


问:
How to pass HttpServletResponse in org.apache.catalina.valve invoke(Request,Response) method
I have below Java code to prevent X-FRAME-OPTIONS header being set for specific product responses

public class ResponseHeaderValve extends ValveBase {
    private static final Logger LOGGER = Logger.getLogger(ResponseHeaderValve.class.getName());
    private static final String PRODUCT_NAME = "PRODUCT_NAME";

    @Override
    public void invoke(Request request, Response response) throws ServletException, IOException {
        try {
            HttpSession session = request.getSession();
            String productName = (String) session.getAttribute(PRODUCT_NAME);
            if (productName == null && request.getParameterMap().containsKey(PRODUCT_NAME)) {
                productName = request.getParameter(PRODUCT_NAME);
            }

            if (productName != null && productName.equalsIgnoreCase("product1")) {
                HttpServletResponse httpServletResponse = new HttpServletResponseWrapper(response.getResponse()) {
                    public void addHeader(String name, String value) {
                        if (!name.equalsIgnoreCase("X-FRAME-OPTIONS")) {
                            super.setHeader(name, value);
                        }
                    }
                    public void setHeader(String name, String value) {
                        if (!name.equalsIgnoreCase("X-FRAME-OPTIONS")) {
                            super.setHeader(name, value);
                        }
                    }
                };
                this.getNext().invoke(request,httpServletResponse);
            } else {
                this.getNext().invoke(request, response);

            }
        }
        catch(Exception e){
            LOGGER.log(Level.INFO, "Exception in ResponseHeaderValve: invoke():", e);
        }
    }
}
```

For cases productName equals "product1" using HttpServletResponseWrapper I tried to prevent header being set.

I have to pass request, httpServletResponse to the next valve using invoke method, but org.apache.catalina.valve invoke(Request,Response) method does not allow passing httpServletResponse. I have tried casting (Response)httpServletResponse, it did not work throws ClassCastException. How can I proceed?

Body:
I have below Java code to prevent X-FRAME-OPTIONS header being set for specific product responses

public class ResponseHeaderValve extends ValveBase {
    private static final Logger LOGGER = Logger.getLogger(ResponseHeaderValve.class.getName());
    private static final String PRODUCT_NAME = "PRODUCT_NAME";

    @Override
    public void invoke(Request request, Response response) throws ServletException, IOException {
        try {
            HttpSession session = request.getSession();
            String productName = (String) session.getAttribute(PRODUCT_NAME);
            if (productName == null && request.getParameterMap().containsKey(PRODUCT_NAME)) {
                productName = request.getParameter(PRODUCT_NAME);
            }

            if (productName != null && productName.equalsIgnoreCase("product1")) {
                HttpServletResponse httpServletResponse = new HttpServletResponseWrapper(response.getResponse()) {
                    public void addHeader(String name, String value) {
                        if (!name.equalsIgnoreCase("X-FRAME-OPTIONS")) {
                            super.setHeader(name, value);
                        }
                    }
                    public void setHeader(String name, String value) {
                        if (!name.equalsIgnoreCase("X-FRAME-OPTIONS")) {
                            super.setHeader(name, value);
                        }
                    }
                };
                this.getNext().invoke(request,httpServletResponse);
            } else {
                this.getNext().invoke(request, response);

            }
        }
        catch(Exception e){
            LOGGER.log(Level.INFO, "Exception in ResponseHeaderValve: invoke():", e);
        }
    }
}

For cases productName equals "product1" using HttpServletResponseWrapper I tried to prevent header being set.

I have to pass request, httpServletResponse to the next valve using invoke method, but org.apache.catalina.valve invoke(Request,Response) method does not allow passing httpServletResponse. I have tried casting (Response)httpServletResponse, it did not work throws ClassCastException. How can I proceed?


问:
Android - Get mobile number from user
I'm developing an android application. And I need user phone number or paypal address to give reward to the user. I don't know how to get it. Is there anyway to achieve it by using firebase or something else?</p>

Title: Android - Get mobile number from user


问:
How to proxy pass to another port (multiple)
I want to proxy pass based on the path to another port (multiple) using NginX.

Example:
/ -> :3000
/test -> :3001

I already config my nginx.conf like this:

```<code>    server {
        listen       443 ssl http2;
        listen       [::]:443 ssl http2;
        server_name  www.xxx.domain.com;

        gzip off;
        proxy_max_temp_file_size 0;
        ssl_certificate /etc/nginx/ssl/xxx.co.id.pem;
        ssl_certificate_key /etc/nginx/ssl/xxx.co.id.pem;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        ssl_ciphers XXX
        proxy_http_version 1.1;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection keep-alive;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;
        proxy_redirect off;

        location / {
                proxy_pass http://10.184.0.4:3000;
        }

        location = /test {
                proxy_pass http://10.184.0.4:3001;
        }

       }
</code>```

It's success for the /, but for the /test route it's get redirected to port :3000 to the Not Found Page.

Any suggestion to success the proxy pass?

Body:
I want to proxy pass based on the path to another port (multiple) using NginX.

Example:
/ -> :3000
/test -> :3001

I already config my nginx.conf like this:

    server {
        listen       443 ssl http2;
        listen       [::]:443 ssl http2;
        server_name  www.xxx.domain.com;

        gzip off;
        proxy_max_temp_file_size 0;
        ssl_certificate /etc/nginx/ssl/xxx.co.id.pem;
        ssl_certificate_key /etc/nginx/ssl/xxx.co.id.pem;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        ssl_ciphers XXX
        proxy_http_version 1.1;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection keep-alive;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;
        proxy_redirect off;

        location / {
                proxy_pass http://10.184.0.4:3000;
        }

        location = /test {
                proxy_pass http://10.184.0.4:3001;
        }

       }

It's success for the /, but for the /test route it's get redirected to port :3000 to the Not Found Page.

Any suggestion to success the proxy pass?


问:
Chrome developer tools truncates long network response
Is there a similar fix for chrome as the one proposed by jon in this post 4 years ago :

Firefox developer tools truncates long network response, Chrome does not show

thank you

tried this fix for firefox : Firefox developer tools truncates long network response, Chrome does not show

worked but  trying to find the same for chrome


问:
Is there a solution to propagate request scoped cdi bean to a consumer with calling EventBus request?
I'm trying to use quarkus-rest-client-reactive to call a rest api, and the rest-client calling is in  a @ConsumeEvent method.

But, now it doesn't work because the authorization header on the request message is not set, and I noticed that when I call the consume event with using a EventBus request, a request scoped cdi bean is not properly propagated.

I'm refering the example https://ja.quarkus.io/guides/reactive-event-bus.

It is said then 'You can inject an executor if you use the Context Propagation extension'.
Please tell me how to propagate request scoped bean when I'm using EventBus request.

```<code>@Priority(10)
@Decorator
abstract public class Repository_Event implements Repository {

    @Inject
    @Any
    @Delegate
    Repository _delegate;

    @Inject
        EventBus _bus;

    @Inject
    JsonWebToken _accessToken;

    @Inject
    Token _token;

    @Override
    public Uni<File> findById(FileId id) {
        _token.setToken(_accessToken.getRawToken());
        return _delegate.findById(id)
                .onItem().transformToUni(file -> _bus.<File>request("find", file))
                .onItem().transform(Message::body);
    }
}
</code>```
```<code>@ApplicationScoped
public class EventFileFileName {

    @RestClient
    ServiceFileFileName _service;

    @Inject
    Logger _log;

    @Inject
    Token _token;

    @Inject
    ManagedExecutor managedExecutor;

    @ConsumeEvent("find")
    public Uni<File> find(File file) {
         _log.info(".find " + file.getId().getFileId() + ",token:" + _token.getToken()); // token: null
        return Uni.createFrom().nullItem()
                .emitOn(managedExecutor)
                .onItem().transformToUni(item -> _service.name(file.getId()))
                .invoke(name -> file.setName(name))
                .onItem().transform(name -> file);
    }
}
</code>```
```<code>@RequestScoped
public class Token {
    private String _token;
    public String getToken() {
        return _token;
    }
    public void setToken(String token) {
        _token = token;
    }
}
</code>```

■ application.properties

```<code> org.eclipse.microprofile.rest.client.propagateHeaders=Authorization
</code>```

■ pom.xml

```<code>  <properties>
    <compiler-plugin.version>3.8.1</compiler-plugin.version>
    <maven.compiler.parameters>true</maven.compiler.parameters>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
    <quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
    <quarkus.platform.version>2.15.0.Final</quarkus.platform.version>
    <surefire-plugin.version>2.22.1</surefire-plugin.version>
  </properties>
  <dependencies>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-oidc</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-keycloak-authorization</artifactId>
    </dependency>
    <dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-vertx</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-resteasy-reactive-jackson</artifactId>
    </dependency>
    <dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-hibernate-reactive</artifactId>
    </dependency>
    <dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-reactive-pg-client</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-rest-client-reactive-jackson</artifactId>
    </dependency>
    <dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-smallrye-context-propagation</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-jdbc-postgresql</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-kubernetes</artifactId>
    </dependency>
    <dependency>
        <groupId>org.jboss.logmanager</groupId>
        <artifactId>log4j2-jboss-logmanager</artifactId>
    </dependency>

  </dependencies>
</code>```

It worked when I use event.fireAsync and @ObservesAsync, but I couldn't get a return value so I can't use this means.

```<code>@Priority(10)
@Decorator
abstract public class Repository_Event implements Repository {

    @Inject
    @Any
    @Delegate
    Repository _delegate;

    @Inject
    @Find
    Event<File> _eventFind;

    @Inject
    Token _token;

    @Inject
    ManagedExecutor managedExecutor;

    @Override
    public Uni<File> findById(FileId id) {
        _token.setToken(_accessToken.getRawToken());
        return _delegate.findById(id)
                .onItem().transformToUni(file ->
                        Uni.createFrom()
                                .completionStage(() -> _eventFind.fireAsync(file, NotificationOptions.ofExecutor(managedExecutor))));
    }

}
</code>```
```<code>@ApplicationScoped
public class EventFileFileName {

    @Inject
    Token _token;

    @RestClient
    ServiceFileFileName _service;

    public void find2(@ObservesAsync @Find File file) {
         _log.info(".find " + file.getId().getFileId() + ",token:" + _token.getToken()); // token is not null
        _service.name(file.getId())
                .onItem().invoke(name -> file.setName(name))
                .onItem().transform(name -> file)
                .subscribeAsCompletionStage();
    }
}
</code>```

And I tried to add an emitOn() with a ManagedExecutor before EventBus.request calling, but it doesn't work.

```<code>@Priority(10)
@Decorator
abstract public class Repository_Event implements Repository {

    @Inject
    @Any
    @Delegate
    Repository _delegate;

    @Inject
        EventBus _bus;

    @Inject
    JsonWebToken _accessToken;

    @Inject
    Token _token;

    @Inject
    ManagedExecutor managedExecutor;

    @Override
    public Uni<File> findById(FileId id) {
        _token.setToken(_accessToken.getRawToken());
        return _delegate.findById(id)
                .emitOn(managedExecutor)
                .onItem().transformToUni(file -> _bus.<File>request("find", file))
                .onItem().transform(Message::body);
    }
}
</code>```
```<code>@ConsumeEvent("find")
public Uni<File> find(File file) {
     _log.info(".find " + file.getId().getFileId() + ",token:" + _token.getToken()); // token: null
    return Uni.createFrom().nullItem()
            .emitOn(managedExecutor)
            .onItem().transformToUni(item -> _service.name(file.getId()))
            .invoke(name -> file.setName(name))
            .onItem().transform(name -> file);
}
</code>```

Body:
I'm trying to use quarkus-rest-client-reactive to call a rest api, and the rest-client calling is in  a @ConsumeEvent method.

But, now it doesn't work because the authorization header on the request message is not set, and I noticed that when I call the consume event with using a EventBus request, a request scoped cdi bean is not properly propagated.

I'm refering the example https://ja.quarkus.io/guides/reactive-event-bus.

It is said then 'You can inject an executor if you use the Context Propagation extension'.
Please tell me how to propagate request scoped bean when I'm using EventBus request.

@Priority(10)
@Decorator
abstract public class Repository_Event implements Repository {

    @Inject
    @Any
    @Delegate
    Repository _delegate;

    @Inject
        EventBus _bus;

    @Inject
    JsonWebToken _accessToken;

    @Inject
    Token _token;

    @Override
    public Uni<File> findById(FileId id) {
        _token.setToken(_accessToken.getRawToken());
        return _delegate.findById(id)
                .onItem().transformToUni(file -> _bus.<File>request("find", file))
                .onItem().transform(Message::body);
    }
}

@ApplicationScoped
public class EventFileFileName {

    @RestClient
    ServiceFileFileName _service;

    @Inject
    Logger _log;

    @Inject
    Token _token;

    @Inject
    ManagedExecutor managedExecutor;

    @ConsumeEvent("find")
    public Uni<File> find(File file) {
         _log.info(".find " + file.getId().getFileId() + ",token:" + _token.getToken()); // token: null
        return Uni.createFrom().nullItem()
                .emitOn(managedExecutor)
                .onItem().transformToUni(item -> _service.name(file.getId()))
                .invoke(name -> file.setName(name))
                .onItem().transform(name -> file);
    }
}

@RequestScoped
public class Token {
    private String _token;
    public String getToken() {
        return _token;
    }
    public void setToken(String token) {
        _token = token;
    }
}

■ application.properties

 org.eclipse.microprofile.rest.client.propagateHeaders=Authorization

■ pom.xml

  <properties>
    <compiler-plugin.version>3.8.1</compiler-plugin.version>
    <maven.compiler.parameters>true</maven.compiler.parameters>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
    <quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
    <quarkus.platform.version>2.15.0.Final</quarkus.platform.version>
    <surefire-plugin.version>2.22.1</surefire-plugin.version>
  </properties>
  <dependencies>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-oidc</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-keycloak-authorization</artifactId>
    </dependency>
    <dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-vertx</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-resteasy-reactive-jackson</artifactId>
    </dependency>
    <dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-hibernate-reactive</artifactId>
    </dependency>
    <dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-reactive-pg-client</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-rest-client-reactive-jackson</artifactId>
    </dependency>
    <dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-smallrye-context-propagation</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-jdbc-postgresql</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-kubernetes</artifactId>
    </dependency>
    <dependency>
        <groupId>org.jboss.logmanager</groupId>
        <artifactId>log4j2-jboss-logmanager</artifactId>
    </dependency>

  </dependencies>

It worked when I use event.fireAsync and @ObservesAsync, but I couldn't get a return value so I can't use this means.

@Priority(10)
@Decorator
abstract public class Repository_Event implements Repository {

    @Inject
    @Any
    @Delegate
    Repository _delegate;

    @Inject
    @Find
    Event<File> _eventFind;

    @Inject
    Token _token;

    @Inject
    ManagedExecutor managedExecutor;

    @Override
    public Uni<File> findById(FileId id) {
        _token.setToken(_accessToken.getRawToken());
        return _delegate.findById(id)
                .onItem().transformToUni(file ->
                        Uni.createFrom()
                                .completionStage(() -> _eventFind.fireAsync(file, NotificationOptions.ofExecutor(managedExecutor))));
    }

}

@ApplicationScoped
public class EventFileFileName {

    @Inject
    Token _token;

    @RestClient
    ServiceFileFileName _service;

    public void find2(@ObservesAsync @Find File file) {
         _log.info(".find " + file.getId().getFileId() + ",token:" + _token.getToken()); // token is not null
        _service.name(file.getId())
                .onItem().invoke(name -> file.setName(name))
                .onItem().transform(name -> file)
                .subscribeAsCompletionStage();
    }
}

And I tried to add an emitOn() with a ManagedExecutor before EventBus.request calling, but it doesn't work.

@Priority(10)
@Decorator
abstract public class Repository_Event implements Repository {

    @Inject
    @Any
    @Delegate
    Repository _delegate;

    @Inject
        EventBus _bus;

    @Inject
    JsonWebToken _accessToken;

    @Inject
    Token _token;

    @Inject
    ManagedExecutor managedExecutor;

    @Override
    public Uni<File> findById(FileId id) {
        _token.setToken(_accessToken.getRawToken());
        return _delegate.findById(id)
                .emitOn(managedExecutor)
                .onItem().transformToUni(file -> _bus.<File>request("find", file))
                .onItem().transform(Message::body);
    }
}

@ConsumeEvent("find")
public Uni<File> find(File file) {
     _log.info(".find " + file.getId().getFileId() + ",token:" + _token.getToken()); // token: null
    return Uni.createFrom().nullItem()
            .emitOn(managedExecutor)
            .onItem().transformToUni(item -> _service.name(file.getId()))
            .invoke(name -> file.setName(name))
            .onItem().transform(name -> file);
}


问:
What happens to a reference if the variable it refers to is removed from stack
I want to understand this snipped:

```<code>#include <iostream>

int& GetInt();
void Print(int& valueToPrint);

int main()
{
    int& myValue = GetInt();
    Print(myValue);
}

int& GetInt()
{
    int x = 9;
    return x;
}

void Print(int& valueToPrint)
{
    std::cout << valueToPrint;
}
</code>```

I was expecting this to print out 9, instead I get some high integer value of 32759.
In my understanding, the function GetInt returns a reference to the variable myValue.
I then pass this reference as a reference to the function Print.

My guessing is that this isn't working because x is defined inside the scope of GetInt and removed from stack memory after exiting this function. But why does my reference then get a strange random big integer number?

Body:
I want to understand this snipped:

#include <iostream>

int& GetInt();
void Print(int& valueToPrint);

int main()
{
    int& myValue = GetInt();
    Print(myValue);
}

int& GetInt()
{
    int x = 9;
    return x;
}

void Print(int& valueToPrint)
{
    std::cout << valueToPrint;
}

I was expecting this to print out 9, instead I get some high integer value of 32759.
In my understanding, the function GetInt returns a reference to the variable myValue.
I then pass this reference as a reference to the function Print.

My guessing is that this isn't working because x is defined inside the scope of GetInt and removed from stack memory after exiting this function. But why does my reference then get a strange random big integer number?


问:
Enrollment certificate of user does not have the attribute values assigned to it when registering it using Hyperledger-fabric-sdk-java
I want to use Access Based Control in my blockchain network and am assigning the user with attributes for this purpose. However, the enrollment certificate stored in my wallet does not have the attribute values present in it.

My code snippet for registering and enrolling the user:

```<code>        RegistrationRequest registrationRequest = new RegistrationRequest("appUser1");
        registrationRequest.setAffiliation("org1.department1");
        registrationRequest.setEnrollmentID("appUser1");
        Attribute attr = new Attribute("Type","Approver",true);
        registrationRequest.addAttribute(attr);
        String enrollmentSecret = caClient.register(registrationRequest, admin);
        Enrollment enrollment = caClient.enroll("appUser1", enrollmentSecret);
        Identity user = Identities.newX509Identity("Org1MSP", adminIdentity.getCertificate(), adminIdentity.getPrivateKey());
        wallet.put("appUser1", user);
        System.out.println("Successfully enrolled user \"appUser1\" and imported it into the wallet");
</code>```

Decrypted x509 certificate of the generated certificate:

```<code>Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            70:b2:b9:02:cd:de:14:6b:00:dc:16:b4:e8:95:74:7d:03:52:3e:01
        Signature Algorithm: ecdsa-with-SHA256
        Issuer: C = US, ST = North Carolina, O = Hyperledger, OU = Fabric, CN = fabric-ca-server
        Validity
            Not Before: Jan  5 05:34:00 2023 GMT
            Not After : Jan  5 06:37:00 2024 GMT
        Subject: OU = client, CN = admin
        Subject Public Key Info:
            Public Key Algorithm: id-ecPublicKey
                Public-Key: (256 bit)
                pub:
                    04:9f:03:45:44:0b:b1:4d:78:c9:58:fe:c1:82:d4:
                    34:04:80:a9:a5:fe:7f:27:2d:5a:a4:54:c8:c2:bb:
                    86:61:00:3d:62:33:99:02:0a:65:75:dc:ce:62:44:
                    96:fd:10:88:2f:44:fa:1d:4a:04:3d:79:33:03:ac:
                    b1:cd:82:dc:5c
                ASN1 OID: prime256v1
                NIST CURVE: P-256
        X509v3 extensions:
            X509v3 Key Usage: critical
                Digital Signature, Key Encipherment, Key Agreement
            X509v3 Extended Key Usage:
                TLS Web Server Authentication, TLS Web Client Authentication
            X509v3 Basic Constraints: critical
                CA:FALSE
            X509v3 Subject Key Identifier:
                FF:71:92:2E:B8:24:37:A3:13:78:EC:D1:11:D7:54:B6:BD:D6:43:9E
            X509v3 Authority Key Identifier:
                keyid:D5:DC:30:53:0C:B2:EF:74:76:6C:44:9F:45:B8:A3:46:EB:F0:05:2A

            X509v3 Subject Alternative Name:
                DNS:localhost
    Signature Algorithm: ecdsa-with-SHA256
         30:44:02:20:11:c6:fa:4a:bf:bb:57:89:63:4a:56:c0:bb:cf:
         2d:49:19:9e:74:9b:ac:dc:05:d4:ed:ca:9c:9e:cf:48:be:f0:
         02:20:53:0b:ed:57:88:26:9d:a9:38:c4:70:cd:8d:07:41:cc:
         85:bf:32:dc:3b:15:41:11:fc:27:02:e4:cf:e8:cf:25
-----BEGIN CERTIFICATE-----
MIICITCCAcigAwIBAgIUcLK5As3eFGsA3Ba06JV0fQNSPgEwCgYIKoZIzj0EAwIw
aDELMAkGA1UEBhMCVVMxFzAVBgNVBAgTDk5vcnRoIENhcm9saW5hMRQwEgYDVQQK
EwtIeXBlcmxlZGdlcjEPMA0GA1UECxMGRmFicmljMRkwFwYDVQQDExBmYWJyaWMt
Y2Etc2VydmVyMB4XDTIzMDEwNTA1MzQwMFoXDTI0MDEwNTA2MzcwMFowITEPMA0G
A1UECxMGY2xpZW50MQ4wDAYDVQQDEwVhZG1pbjBZMBMGByqGSM49AgEGCCqGSM49
AwEHA0IABJ8DRUQLsU14yVj+wYLUNASAqaX+fyctWqRUyMK7hmEAPWIzmQIKZXXc
zmJElv0QiC9E+h1KBD15MwOssc2C3FyjgZYwgZMwDgYDVR0PAQH/BAQDAgOoMB0G
A1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAMBgNVHRMBAf8EAjAAMB0GA1Ud
DgQWBBT/cZIuuCQ3oxN47NER11S2vdZDnjAfBgNVHSMEGDAWgBTV3DBTDLLvdHZs
RJ9FuKNG6/AFKjAUBgNVHREEDTALgglsb2NhbGhvc3QwCgYIKoZIzj0EAwIDRwAw
RAIgEcb6Sr+7V4ljSlbAu88tSRmedJus3AXU7cqcns9IvvACIFML7VeIJp2pOMRw
zY0HQcyFvzLcOxVBEfwnAuTP6M8l
-----END CERTIFICATE-----

</code>```

Access Based Control on the chain code requires the attributes to be present in the certificate. Does anybody know what I am doing wrong?

Body:
I want to use Access Based Control in my blockchain network and am assigning the user with attributes for this purpose. However, the enrollment certificate stored in my wallet does not have the attribute values present in it.

My code snippet for registering and enrolling the user:

        RegistrationRequest registrationRequest = new RegistrationRequest("appUser1");
        registrationRequest.setAffiliation("org1.department1");
        registrationRequest.setEnrollmentID("appUser1");
        Attribute attr = new Attribute("Type","Approver",true);
        registrationRequest.addAttribute(attr);
        String enrollmentSecret = caClient.register(registrationRequest, admin);
        Enrollment enrollment = caClient.enroll("appUser1", enrollmentSecret);
        Identity user = Identities.newX509Identity("Org1MSP", adminIdentity.getCertificate(), adminIdentity.getPrivateKey());
        wallet.put("appUser1", user);
        System.out.println("Successfully enrolled user \"appUser1\" and imported it into the wallet");

Decrypted x509 certificate of the generated certificate:

Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            70:b2:b9:02:cd:de:14:6b:00:dc:16:b4:e8:95:74:7d:03:52:3e:01
        Signature Algorithm: ecdsa-with-SHA256
        Issuer: C = US, ST = North Carolina, O = Hyperledger, OU = Fabric, CN = fabric-ca-server
        Validity
            Not Before: Jan  5 05:34:00 2023 GMT
            Not After : Jan  5 06:37:00 2024 GMT
        Subject: OU = client, CN = admin
        Subject Public Key Info:
            Public Key Algorithm: id-ecPublicKey
                Public-Key: (256 bit)
                pub:
                    04:9f:03:45:44:0b:b1:4d:78:c9:58:fe:c1:82:d4:
                    34:04:80:a9:a5:fe:7f:27:2d:5a:a4:54:c8:c2:bb:
                    86:61:00:3d:62:33:99:02:0a:65:75:dc:ce:62:44:
                    96:fd:10:88:2f:44:fa:1d:4a:04:3d:79:33:03:ac:
                    b1:cd:82:dc:5c
                ASN1 OID: prime256v1
                NIST CURVE: P-256
        X509v3 extensions:
            X509v3 Key Usage: critical
                Digital Signature, Key Encipherment, Key Agreement
            X509v3 Extended Key Usage:
                TLS Web Server Authentication, TLS Web Client Authentication
            X509v3 Basic Constraints: critical
                CA:FALSE
            X509v3 Subject Key Identifier:
                FF:71:92:2E:B8:24:37:A3:13:78:EC:D1:11:D7:54:B6:BD:D6:43:9E
            X509v3 Authority Key Identifier:
                keyid:D5:DC:30:53:0C:B2:EF:74:76:6C:44:9F:45:B8:A3:46:EB:F0:05:2A

            X509v3 Subject Alternative Name:
                DNS:localhost
    Signature Algorithm: ecdsa-with-SHA256
         30:44:02:20:11:c6:fa:4a:bf:bb:57:89:63:4a:56:c0:bb:cf:
         2d:49:19:9e:74:9b:ac:dc:05:d4:ed:ca:9c:9e:cf:48:be:f0:
         02:20:53:0b:ed:57:88:26:9d:a9:38:c4:70:cd:8d:07:41:cc:
         85:bf:32:dc:3b:15:41:11:fc:27:02:e4:cf:e8:cf:25
-----BEGIN CERTIFICATE-----
MIICITCCAcigAwIBAgIUcLK5As3eFGsA3Ba06JV0fQNSPgEwCgYIKoZIzj0EAwIw
aDELMAkGA1UEBhMCVVMxFzAVBgNVBAgTDk5vcnRoIENhcm9saW5hMRQwEgYDVQQK
EwtIeXBlcmxlZGdlcjEPMA0GA1UECxMGRmFicmljMRkwFwYDVQQDExBmYWJyaWMt
Y2Etc2VydmVyMB4XDTIzMDEwNTA1MzQwMFoXDTI0MDEwNTA2MzcwMFowITEPMA0G
A1UECxMGY2xpZW50MQ4wDAYDVQQDEwVhZG1pbjBZMBMGByqGSM49AgEGCCqGSM49
AwEHA0IABJ8DRUQLsU14yVj+wYLUNASAqaX+fyctWqRUyMK7hmEAPWIzmQIKZXXc
zmJElv0QiC9E+h1KBD15MwOssc2C3FyjgZYwgZMwDgYDVR0PAQH/BAQDAgOoMB0G
A1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAMBgNVHRMBAf8EAjAAMB0GA1Ud
DgQWBBT/cZIuuCQ3oxN47NER11S2vdZDnjAfBgNVHSMEGDAWgBTV3DBTDLLvdHZs
RJ9FuKNG6/AFKjAUBgNVHREEDTALgglsb2NhbGhvc3QwCgYIKoZIzj0EAwIDRwAw
RAIgEcb6Sr+7V4ljSlbAu88tSRmedJus3AXU7cqcns9IvvACIFML7VeIJp2pOMRw
zY0HQcyFvzLcOxVBEfwnAuTP6M8l
-----END CERTIFICATE-----

Access Based Control on the chain code requires the attributes to be present in the certificate. Does anybody know what I am doing wrong?


问:
how to implement trained nlp spacy model in a front end application
I am new to ML and DS. I have done many projects on Kaggle or Colab but this is my first time doing an NLP project on Resume Parsing using spacy.

I have trained my model using data from 200 resumes and now i have a model best and a model last

i tried this model on the test data and it works almost flawlessly by returning the label from the text.

I want guidance on how i can use this model and create either a web app or a mobile app

I have some level of knowledge on how to make a material app using flutter and also java mobile apps

but i jus dont know how i can proceed from here

my project is just a python notebook on google colab and everytime i wanna use it i have to train the model for 2 hours

The model just returns labelled data like name, college name, degree, companies worked at and so on from the txt data that i extracted using PyMupdf

github repo

Tbh i didnt try much because i just dont know how to approach this


问:
How do I use the WCF-CustomIsolated base64 decoding in BizTalk?
Input
An xml with a root and a base64-encoded xml, like <data>FFEFE#13DD</data>.

Problem
On the Message tab in the WCF-CustomIsolated adapter you can choose a body path expression to point to the postion in the incoming message you want to use as message. You can also set the type, string, xml, hex or base64.

Setting up this, with a tested xpath, using allowed syntax, that points to an Element and base64 as type, and make a SOAP-call from Postman ends up in "System.InvalidOperationException: ReadSubtree() can be called only if the reader is on an element node." To me it sounds like the xpath is not correct, but it is :)

I've looked at Extracting XML with WCF-SQL adapter and believe I do like that. Does anyone have used this functionality and can guide me? I would be most grateful.


问:
CameraX: front camera video recording failed
I try video recording on front camera (selfie). when it comes to implementation, it causes no recording response instead of start recording. When I press change camera button back, video recording does not work.

Please help me review the preview setup:

Below is part of my code in jetpack compose:

```<code>fun StoryCaptureScreen(
    modifier: Modifier,
    photoPath: Uri,
    imageLoader: ImageLoader,
    isAudioPermissionGranted: Boolean,
    isLabelLoaded: Boolean,
    isShowAlbumPermissionScreen: Boolean,
    isDeviceSupportVideo: Boolean,
....

  Surface(
        modifier = modifier,
        color = MaterialTheme.colors.background
    ) {
        val context = LocalContext.current
        val lifecycleOwner = LocalLifecycleOwner.current
        val standardIconSize = 36.dp
        val cameraPermissionState = rememberMultiplePermissionsState(
            permissions = listOf(
                Manifest.permission.CAMERA,
                Manifest.permission.RECORD_AUDIO
            )
        )

        val necessaryCameraPermissionState = rememberMultiplePermissionsState(
            permissions = listOf(
                Manifest.permission.CAMERA,
                Manifest.permission.RECORD_AUDIO
            )
        )

        val tempUploadDir by lazy {
            FileUtil.createFolder(
                FOLDER_TEMP_UPLOAD_FOLDER,
                FileManager.getExternalFilesDir(context).absolutePath
            )
        }

        val configuration = LocalConfiguration.current
        val screenHeight = configuration.screenHeightDp.dp
        val screenWidth = configuration.screenWidthDp.dp

        var second by remember { mutableStateOf(0.toLong()) }
        var currentNanoSecond by remember { mutableStateOf(0.toLong()) }
        val maxSecond by remember { mutableStateOf((1000000000.0 * maximumRecordingSecond).toLong()) } // ktlint-disable max-line-length
        var recording: Recording? = remember { null }
        val recordingStarted: MutableState<Boolean> = remember { mutableStateOf(false) }
        val cameraSelector: MutableState<CameraSelector> = remember {
            mutableStateOf(CameraSelector.DEFAULT_BACK_CAMERA)
        }

        val audioEnabled: MutableState<Boolean> = remember { mutableStateOf(true) }
        val isAudioMenuVisible: MutableState<Boolean> = remember { mutableStateOf(false) }
        val isLoading: MutableState<Boolean> = remember { mutableStateOf(false) }
        val flashEnabled: MutableState<Int> =
            remember { mutableStateOf(0) } // 0 off , 1 on , 2 auto
        val isFlashMenuVisible: MutableState<Boolean> = remember { mutableStateOf(false) }

        val animatedProgress = remember { Animatable(1f) }
        val animatedLoaded = remember { mutableStateOf(isLabelLoaded) }

        LaunchedEffect(Unit) {
            cameraPermissionState.launchMultiplePermissionRequest()
        }

        var preview = Preview.Builder().build()
        val previewView = remember { PreviewView(context) }
        val imageCapture: ImageCapture = remember {
            ImageCapture.Builder()
                .setCaptureMode(ImageCapture.CAPTURE_MODE_ZERO_SHUTTER_LAG)
                .build()
        }

        imageCapture.flashMode = when (flashEnabled.value) {
            0 -> ImageCapture.FLASH_MODE_OFF
            1 -> ImageCapture.FLASH_MODE_ON
            2 -> ImageCapture.FLASH_MODE_AUTO
            else -> ImageCapture.FLASH_MODE_OFF
        }

        val qualitySelector = QualitySelector.from(
            Quality.UHD,
            FallbackStrategy.lowerQualityThan(Quality.UHD)
        )

        val recorder = Recorder.Builder()
            .setExecutor(context.mainExecutor)
            .setQualitySelector(qualitySelector)
            .build()

        val videoCapture = VideoCapture.withOutput(recorder)

        LaunchedEffect(cameraSelector.value) {
            Timber.d("image change camera lens: ${cameraSelector.value}")

            preview = Preview.Builder().build().also {
                it.setSurfaceProvider(previewView.surfaceProvider)
            }
            val cameraProvider = context.getCameraProvider()
            cameraProvider.unbindAll()

            if (isDeviceSupportVideo) {
                cameraProvider.bindToLifecycle(
                    lifecycleOwner,
                    cameraSelector.value,
                    preview,
                    imageCapture,
                    videoCapture
                ).apply {
                    preview.setSurfaceProvider(previewView.surfaceProvider)
                }
            }
            else {
                cameraProvider.bindToLifecycle(
                    lifecycleOwner,
                    cameraSelector.value,
                    preview,
                    imageCapture
                ).apply {
                    preview.setSurfaceProvider(previewView.surfaceProvider)
                }
            }
        }
.......

                // front camera button
                IconButton(
                    onClick = {
                        cameraSelector.value =
                            if (cameraSelector.value == CameraSelector.DEFAULT_BACK_CAMERA) CameraSelector.DEFAULT_FRONT_CAMERA // ktlint-disable max-line-length
                            else CameraSelector.DEFAULT_BACK_CAMERA

                        onTracking(
                            if (cameraSelector.value == CameraSelector.DEFAULT_FRONT_CAMERA) FirstLookTools.FrontCamera else FirstLookTools.BackCamera // ktlint-disable max-line-length
                        )

                        if (cameraSelector.value == CameraSelector.DEFAULT_FRONT_CAMERA) {
                            onLabelLoaded(true)
                        }
                    },
                    modifier = Modifier
                        .align(Alignment.BottomEnd)
                        .padding(bottom = 48.dp, end = 24.dp)
                ) {
                    Image(
                        painter = painterResource(R.drawable.ic_outline_change_source),
                        contentDescription = "",
                        modifier = Modifier.size(64.dp)
                    )
                }
</code>```

Start recording:

```<code>@SuppressLint("MissingPermission")
fun startRecordingVideo(
    context: Context,
    filename: String,
    videoCapture: VideoCapture<Recorder>,
    outputDirectory: File,
    executor: Executor,
    audioEnabled: Boolean,
    consumer: Consumer<VideoRecordEvent>
): Recording {
    val videoFile = File(
        outputDirectory,
        "$filename.mp4"
    )

    val outputOptions = FileOutputOptions.Builder(videoFile).build()

    return videoCapture.output
        .prepareRecording(context, outputOptions)
        .apply { if (audioEnabled) withAudioEnabled() }
        .start(executor, consumer)
}
</code>```

Body:
I try video recording on front camera (selfie). when it comes to implementation, it causes no recording response instead of start recording. When I press change camera button back, video recording does not work.

Please help me review the preview setup:

Below is part of my code in jetpack compose:

fun StoryCaptureScreen(
    modifier: Modifier,
    photoPath: Uri,
    imageLoader: ImageLoader,
    isAudioPermissionGranted: Boolean,
    isLabelLoaded: Boolean,
    isShowAlbumPermissionScreen: Boolean,
    isDeviceSupportVideo: Boolean,
....

  Surface(
        modifier = modifier,
        color = MaterialTheme.colors.background
    ) {
        val context = LocalContext.current
        val lifecycleOwner = LocalLifecycleOwner.current
        val standardIconSize = 36.dp
        val cameraPermissionState = rememberMultiplePermissionsState(
            permissions = listOf(
                Manifest.permission.CAMERA,
                Manifest.permission.RECORD_AUDIO
            )
        )

        val necessaryCameraPermissionState = rememberMultiplePermissionsState(
            permissions = listOf(
                Manifest.permission.CAMERA,
                Manifest.permission.RECORD_AUDIO
            )
        )

        val tempUploadDir by lazy {
            FileUtil.createFolder(
                FOLDER_TEMP_UPLOAD_FOLDER,
                FileManager.getExternalFilesDir(context).absolutePath
            )
        }

        val configuration = LocalConfiguration.current
        val screenHeight = configuration.screenHeightDp.dp
        val screenWidth = configuration.screenWidthDp.dp

        var second by remember { mutableStateOf(0.toLong()) }
        var currentNanoSecond by remember { mutableStateOf(0.toLong()) }
        val maxSecond by remember { mutableStateOf((1000000000.0 * maximumRecordingSecond).toLong()) } // ktlint-disable max-line-length
        var recording: Recording? = remember { null }
        val recordingStarted: MutableState<Boolean> = remember { mutableStateOf(false) }
        val cameraSelector: MutableState<CameraSelector> = remember {
            mutableStateOf(CameraSelector.DEFAULT_BACK_CAMERA)
        }

        val audioEnabled: MutableState<Boolean> = remember { mutableStateOf(true) }
        val isAudioMenuVisible: MutableState<Boolean> = remember { mutableStateOf(false) }
        val isLoading: MutableState<Boolean> = remember { mutableStateOf(false) }
        val flashEnabled: MutableState<Int> =
            remember { mutableStateOf(0) } // 0 off , 1 on , 2 auto
        val isFlashMenuVisible: MutableState<Boolean> = remember { mutableStateOf(false) }

        val animatedProgress = remember { Animatable(1f) }
        val animatedLoaded = remember { mutableStateOf(isLabelLoaded) }

        LaunchedEffect(Unit) {
            cameraPermissionState.launchMultiplePermissionRequest()
        }

        var preview = Preview.Builder().build()
        val previewView = remember { PreviewView(context) }
        val imageCapture: ImageCapture = remember {
            ImageCapture.Builder()
                .setCaptureMode(ImageCapture.CAPTURE_MODE_ZERO_SHUTTER_LAG)
                .build()
        }

        imageCapture.flashMode = when (flashEnabled.value) {
            0 -> ImageCapture.FLASH_MODE_OFF
            1 -> ImageCapture.FLASH_MODE_ON
            2 -> ImageCapture.FLASH_MODE_AUTO
            else -> ImageCapture.FLASH_MODE_OFF
        }

        val qualitySelector = QualitySelector.from(
            Quality.UHD,
            FallbackStrategy.lowerQualityThan(Quality.UHD)
        )

        val recorder = Recorder.Builder()
            .setExecutor(context.mainExecutor)
            .setQualitySelector(qualitySelector)
            .build()

        val videoCapture = VideoCapture.withOutput(recorder)

        LaunchedEffect(cameraSelector.value) {
            Timber.d("image change camera lens: ${cameraSelector.value}")

            preview = Preview.Builder().build().also {
                it.setSurfaceProvider(previewView.surfaceProvider)
            }
            val cameraProvider = context.getCameraProvider()
            cameraProvider.unbindAll()

            if (isDeviceSupportVideo) {
                cameraProvider.bindToLifecycle(
                    lifecycleOwner,
                    cameraSelector.value,
                    preview,
                    imageCapture,
                    videoCapture
                ).apply {
                    preview.setSurfaceProvider(previewView.surfaceProvider)
                }
            }
            else {
                cameraProvider.bindToLifecycle(
                    lifecycleOwner,
                    cameraSelector.value,
                    preview,
                    imageCapture
                ).apply {
                    preview.setSurfaceProvider(previewView.surfaceProvider)
                }
            }
        }
.......

                // front camera button
                IconButton(
                    onClick = {
                        cameraSelector.value =
                            if (cameraSelector.value == CameraSelector.DEFAULT_BACK_CAMERA) CameraSelector.DEFAULT_FRONT_CAMERA // ktlint-disable max-line-length
                            else CameraSelector.DEFAULT_BACK_CAMERA

                        onTracking(
                            if (cameraSelector.value == CameraSelector.DEFAULT_FRONT_CAMERA) FirstLookTools.FrontCamera else FirstLookTools.BackCamera // ktlint-disable max-line-length
                        )

                        if (cameraSelector.value == CameraSelector.DEFAULT_FRONT_CAMERA) {
                            onLabelLoaded(true)
                        }
                    },
                    modifier = Modifier
                        .align(Alignment.BottomEnd)
                        .padding(bottom = 48.dp, end = 24.dp)
                ) {
                    Image(
                        painter = painterResource(R.drawable.ic_outline_change_source),
                        contentDescription = "",
                        modifier = Modifier.size(64.dp)
                    )
                }

Start recording:

@SuppressLint("MissingPermission")
fun startRecordingVideo(
    context: Context,
    filename: String,
    videoCapture: VideoCapture<Recorder>,
    outputDirectory: File,
    executor: Executor,
    audioEnabled: Boolean,
    consumer: Consumer<VideoRecordEvent>
): Recording {
    val videoFile = File(
        outputDirectory,
        "$filename.mp4"
    )

    val outputOptions = FileOutputOptions.Builder(videoFile).build()

    return videoCapture.output
        .prepareRecording(context, outputOptions)
        .apply { if (audioEnabled) withAudioEnabled() }
        .start(executor, consumer)
}


问:
how to configure the toggle method between finger touch and pencil in PencilKit after iOS 14.0?
I use this IBAction below but I get some errors. How can I make it work efficiently?

```<code> @IBAction func fingerOrPencil (_ sender: Any) {
        canvasView.allowsFingerDrawing.toggle()
        pencilButton.title = canvasView.allowsFingerDrawing ? "Finger" : "Pencil"
</code>```

these are the errors

```<code>allowsFingerDrawing' was deprecated in iOS 14.0: Use 'drawingPolicy' property.
</code>```

actually I used drawingPolicy method inside viewDidLoad as

```<code>canvasView.drawingPolicy = .anyInput
</code>```

but how can I use this inside IBAction to be able to toggle?

Body:
I use this IBAction below but I get some errors. How can I make it work efficiently?

 @IBAction func fingerOrPencil (_ sender: Any) {
        canvasView.allowsFingerDrawing.toggle()
        pencilButton.title = canvasView.allowsFingerDrawing ? "Finger" : "Pencil"

these are the errors

allowsFingerDrawing' was deprecated in iOS 14.0: Use 'drawingPolicy' property.

actually I used drawingPolicy method inside viewDidLoad as

canvasView.drawingPolicy = .anyInput

but how can I use this inside IBAction to be able to toggle?


问:
How to add two numpy arrays containing integers and NaNs while preserving integers?
I have two numpy arrays that contains integers (1, 0, -1) or np.nan.

How can I add these arrays while preserving the integer value of one array element if the other array element contains np.nan?

My problem is that when you add an integer to np.nan, the result will be np.nan.

```<code>import numpy as np

array1 = np.array([1, 0, np.nan, 0,  np.nan, 1,      0, -1    ])
array2 = np.array([0, 1, np.nan, -1, 0,      np.nan, 0, np.nan])

result = array1 + array2  # [ 1.  1. nan -1. nan nan  0. nan]

expected_result = np.array([1., 1., np.nan, -1., 0., 1., 0., -1.])

np.testing.assert_equal(result, expected_result)
</code>```

Body:
I have two numpy arrays that contains integers (1, 0, -1) or np.nan.

How can I add these arrays while preserving the integer value of one array element if the other array element contains np.nan?

My problem is that when you add an integer to np.nan, the result will be np.nan.

import numpy as np

array1 = np.array([1, 0, np.nan, 0,  np.nan, 1,      0, -1    ])
array2 = np.array([0, 1, np.nan, -1, 0,      np.nan, 0, np.nan])

result = array1 + array2  # [ 1.  1. nan -1. nan nan  0. nan]

expected_result = np.array([1., 1., np.nan, -1., 0., 1., 0., -1.])

np.testing.assert_equal(result, expected_result)