问:
Apple AWT Internal Exception: NSWindow drag regions should only be invalidated on the Main Thread
I am trying to run a PApplet class. I am running it on Eclipse, in MacOS. All the necessary Library files are included in the application and using Java 1.8 to compile and run the class.
Mac OS Version is Catalina, 10.15.6 (19G2021). I am getting the following error:

```<code>    2020-10-13 13:23:51.528 java[20420:1238853] Apple AWT Internal Exception: NSWindow drag regions should only be invalidated on the Main Thread!
    2020-10-13 13:23:51.528 java[20420:1238853] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow drag regions should only be invalidated on the Main Thread!'
    *** First throw call stack:
    (
    0   CoreFoundation                      0x00007fff338dbb57 __exceptionPreprocess + 250
    1   libobjc.A.dylib                     0x00007fff6c7245bf objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff3390434c -[NSException raise] + 9
    3   AppKit                              0x00007fff30afe5ec -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 310
    4   AppKit                              0x00007fff30ae6052 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1416
    5   AppKit                              0x00007fff30ae5ac3 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 42
    6   libnativewindow_macosx.jnilib       0x000000015e4d8f9e Java_jogamp_nativewindow_macosx_OSXUtil_CreateNSWindow0 + 398
    7   ???                                 0x0000000112dad407 0x0 + 4611298311
    )
    libc++abi.dylib: terminating with uncaught exception of type NSException
</code>```

Reference Code that I have written.

```<code>package module1;
import processing.core.PApplet;
import de.fhpotsdam.unfolding.UnfoldingMap;
import de.fhpotsdam.unfolding.geo.Location;
import de.fhpotsdam.unfolding.providers.AbstractMapProvider;
import de.fhpotsdam.unfolding.providers.Google;
import de.fhpotsdam.unfolding.providers.MBTilesMapProvider;
import de.fhpotsdam.unfolding.utils.MapUtils;

    public class HelloWorld extends PApplet
    {
        /** Your goal: add code to display second map, zoom in, and customize the background.
         * Feel free to copy and use this code, adding to it, modifying it, etc.
         * Don't forget the import lines above. */

        // You can ignore this.  It's to keep eclipse from reporting a warning
        private static final long serialVersionUID = 1L;

        /** This is where to find the local tiles, for working without an Internet connection */
        public static String mbTilesString = "blankLight-1-3.mbtiles";

        // IF YOU ARE WORKING OFFLINE: Change the value of this variable to true
        private static final boolean offline = false;

        /** The map we use to display our home town: La Jolla, CA */
        UnfoldingMap map1;

        /** The map you will use to display your home town */
        UnfoldingMap map2;

        public void setup() {
            size(800, 600, P2D);  // Set up the Applet window to be 800x600
                                  // The OPENGL argument indicates to use the
                                  // Processing library's 2D drawing
                                  // You'll learn more about processing in Module 3

            // This sets the background color for the Applet.
            // Play around with these numbers and see what happens!
            this.background(200, 200, 200);

            // Select a map provider
            AbstractMapProvider provider = new Google.GoogleTerrainProvider();
            // Set a zoom level
            int zoomLevel = 10;

            if (offline) {
                // If you are working offline, you need to use this provider
                // to work with the maps that are local on your computer.
                provider = new MBTilesMapProvider(mbTilesString);
                // 3 is the maximum zoom level for working offline
                zoomLevel = 3;
            }

            // Create a new UnfoldingMap to be displayed in this window.
            // The 2nd-5th arguments give the map's x, y, width and height
            // When you create your map we want you to play around with these
            // arguments to get your second map in the right place.
            // The 6th argument specifies the map provider.
            // There are several providers built-in.
            // Note if you are working offline you must use the MBTilesMapProvider
            map1 = new UnfoldingMap(this, 50, 50, 350, 500, provider);
            map2 = new UnfoldingMap(this, 450, 450, 350, 500, provider);

            // The next line zooms in and centers the map at
            // 32.9 (latitude) and -117.2 (longitude)
            map1.zoomAndPanTo(zoomLevel, new Location(32.9f, -117.2f));
            map2.zoomAndPanTo(zoomLevel, new Location(32.9f, -117.2f));

            // This line makes the map interactive
            MapUtils.createDefaultEventDispatcher(this, map1);
            MapUtils.createDefaultEventDispatcher(this, map2);

            // TODO: Add code here that creates map2
            // Then you'll modify draw() below

        }

        /** Draw the Applet window.  */
        public void draw() {
            // So far we only draw map1...
            // TODO: Add code so that both maps are displayed
            map1.draw();
            map2.draw();
        }

    }
</code>```

答:
You have to use jdk8u242-b08 for jre.
download from here</p>

Body:
I am trying to run a PApplet class. I am running it on Eclipse, in MacOS. All the necessary Library files are included in the application and using Java 1.8 to compile and run the class.
Mac OS Version is Catalina, 10.15.6 (19G2021). I am getting the following error:

    2020-10-13 13:23:51.528 java[20420:1238853] Apple AWT Internal Exception: NSWindow drag regions should only be invalidated on the Main Thread!
    2020-10-13 13:23:51.528 java[20420:1238853] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow drag regions should only be invalidated on the Main Thread!'
    *** First throw call stack:
    (
    0   CoreFoundation                      0x00007fff338dbb57 __exceptionPreprocess + 250
    1   libobjc.A.dylib                     0x00007fff6c7245bf objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff3390434c -[NSException raise] + 9
    3   AppKit                              0x00007fff30afe5ec -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 310
    4   AppKit                              0x00007fff30ae6052 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1416
    5   AppKit                              0x00007fff30ae5ac3 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 42
    6   libnativewindow_macosx.jnilib       0x000000015e4d8f9e Java_jogamp_nativewindow_macosx_OSXUtil_CreateNSWindow0 + 398
    7   ???                                 0x0000000112dad407 0x0 + 4611298311
    )
    libc++abi.dylib: terminating with uncaught exception of type NSException

Reference Code that I have written.

package module1;
import processing.core.PApplet;
import de.fhpotsdam.unfolding.UnfoldingMap;
import de.fhpotsdam.unfolding.geo.Location;
import de.fhpotsdam.unfolding.providers.AbstractMapProvider;
import de.fhpotsdam.unfolding.providers.Google;
import de.fhpotsdam.unfolding.providers.MBTilesMapProvider;
import de.fhpotsdam.unfolding.utils.MapUtils;

    public class HelloWorld extends PApplet
    {
        /** Your goal: add code to display second map, zoom in, and customize the background.
         * Feel free to copy and use this code, adding to it, modifying it, etc.
         * Don't forget the import lines above. */

        // You can ignore this.  It's to keep eclipse from reporting a warning
        private static final long serialVersionUID = 1L;

        /** This is where to find the local tiles, for working without an Internet connection */
        public static String mbTilesString = "blankLight-1-3.mbtiles";

        // IF YOU ARE WORKING OFFLINE: Change the value of this variable to true
        private static final boolean offline = false;

        /** The map we use to display our home town: La Jolla, CA */
        UnfoldingMap map1;

        /** The map you will use to display your home town */
        UnfoldingMap map2;

        public void setup() {
            size(800, 600, P2D);  // Set up the Applet window to be 800x600
                                  // The OPENGL argument indicates to use the
                                  // Processing library's 2D drawing
                                  // You'll learn more about processing in Module 3

            // This sets the background color for the Applet.
            // Play around with these numbers and see what happens!
            this.background(200, 200, 200);

            // Select a map provider
            AbstractMapProvider provider = new Google.GoogleTerrainProvider();
            // Set a zoom level
            int zoomLevel = 10;

            if (offline) {
                // If you are working offline, you need to use this provider
                // to work with the maps that are local on your computer.
                provider = new MBTilesMapProvider(mbTilesString);
                // 3 is the maximum zoom level for working offline
                zoomLevel = 3;
            }

            // Create a new UnfoldingMap to be displayed in this window.
            // The 2nd-5th arguments give the map's x, y, width and height
            // When you create your map we want you to play around with these
            // arguments to get your second map in the right place.
            // The 6th argument specifies the map provider.
            // There are several providers built-in.
            // Note if you are working offline you must use the MBTilesMapProvider
            map1 = new UnfoldingMap(this, 50, 50, 350, 500, provider);
            map2 = new UnfoldingMap(this, 450, 450, 350, 500, provider);

            // The next line zooms in and centers the map at
            // 32.9 (latitude) and -117.2 (longitude)
            map1.zoomAndPanTo(zoomLevel, new Location(32.9f, -117.2f));
            map2.zoomAndPanTo(zoomLevel, new Location(32.9f, -117.2f));

            // This line makes the map interactive
            MapUtils.createDefaultEventDispatcher(this, map1);
            MapUtils.createDefaultEventDispatcher(this, map2);

            // TODO: Add code here that creates map2
            // Then you'll modify draw() below

        }

        /** Draw the Applet window.  */
        public void draw() {
            // So far we only draw map1...
            // TODO: Add code so that both maps are displayed
            map1.draw();
            map2.draw();
        }

    }


来源: stackexchange

问:
adding mean line and data label to a pandas' plot
I plotted a series of subplots of a Dataframe's columns, and I cannot find a way to add data labels and a mean line to the plots.

my code now looks something like this (I'm simplifying the data here):

```<code>categorized = pd.DataFrame(data={"food":[50, 60, 23, 80],
                                 "books":[10, 18, 3, 12],
                                 "cloths":[30, 50, 23, 80]},
                           index=["jan", "feb", "mar", "apr"])
a = categorized.plot(kind='bar', subplots=True, legend=False, figsize=(25, 105), sharex=False, layout=(4, 1))
plt.subplots_adjust(hspace=0.55)
</code>```

I found two ways to handle this but I can't use any of them:

to use matplotlib, which has the option of mean and data labels - but I didn't see an option for multiple subplots (one per column)

pandas' above example - with subplots - but I couldn't find how to add data labels and mean line

Is there another way that combines the benefits of both options?
Thanks!

答:
I'm not sure what you're trying to do as far as subplots, data labels, and the mean line go, but here is a script that produces a result similar to the result of the pandas command. In particular, it produces a plot with the three bar graphs as subplots, stacked on top of each other. Unlike the pandas command, the bars here are a bit wider and the colors are the same.

```<code>categorized = pd.DataFrame(data={"food":[50, 60, 23, 80],
                                 "books":[10, 18, 3, 12],
                                 "cloths":[30, 50, 23, 80]},
                           index=["jan", "feb", "mar", "apr"])
fig,axs = plt.subplots(3,sharex = False, figsize=(10, 42))

for k,c in enumerate(categorized.columns):
    axs[k].bar(categorized.index,categorized.loc[:,c])
    axs[k].set_title(c)
</code>```

Result:

Pandas result for comparison:

ContentLicense: CC BY-SA 4.0

Body:
I plotted a series of subplots of a Dataframe's columns, and I cannot find a way to add data labels and a mean line to the plots.

my code now looks something like this (I'm simplifying the data here):

categorized = pd.DataFrame(data={"food":[50, 60, 23, 80],
                                 "books":[10, 18, 3, 12],
                                 "cloths":[30, 50, 23, 80]},
                           index=["jan", "feb", "mar", "apr"])
a = categorized.plot(kind='bar', subplots=True, legend=False, figsize=(25, 105), sharex=False, layout=(4, 1))
plt.subplots_adjust(hspace=0.55)

I found two ways to handle this but I can't use any of them:

to use matplotlib, which has the option of mean and data labels - but I didn't see an option for multiple subplots (one per column)

pandas' above example - with subplots - but I couldn't find how to add data labels and mean line

Is there another way that combines the benefits of both options?
Thanks!

Body:
I'm not sure what you're trying to do as far as subplots, data labels, and the mean line go, but here is a script that produces a result similar to the result of the pandas command. In particular, it produces a plot with the three bar graphs as subplots, stacked on top of each other. Unlike the pandas command, the bars here are a bit wider and the colors are the same.

categorized = pd.DataFrame(data={"food":[50, 60, 23, 80],
                                 "books":[10, 18, 3, 12],
                                 "cloths":[30, 50, 23, 80]},
                           index=["jan", "feb", "mar", "apr"])
fig,axs = plt.subplots(3,sharex = False, figsize=(10, 42))

for k,c in enumerate(categorized.columns):
    axs[k].bar(categorized.index,categorized.loc[:,c])
    axs[k].set_title(c)

Result:

Pandas result for comparison:


问:
How do I make my custom data type an instance of Functor?
I have this data type:

```<code>data F a b = F (a -> b)
</code>```

My task is to make this type an instance of the Functor class.
I understand how to do this with the usual examples. i.e. Maybe.

Usually, the given function is applied to the value which is extracted from the wrapper. Then the result is replaced in the same wrapper type. The wrapper in the case of the Maybe type being Just.

However, my data type represents a function of type a -> b. I don't understand how to transfer this concept to use a wrapped function. The reason to create this data type as well as the way to implement this idea are both lost on me.

I'm assuming I'm not fully understanding the concept behind functors or just missing the intention behind the given task where I must specifically define and use the custom data type above...

Please help me to correct the following...

instance Functor (F a) where

答:
I think the other answers address how to write an instance once you know what instance you want to write, but don't give a very good intuition for working out what instance you should want to write in the first place. In this answer, I'll attempt to do that.

I'm going to start very simple. The simplest thing that could possibly be: a functor that doesn't even have any values in it is really, really easy to fmap over.

```<code>data F0 a = F0
instance Functor F0 where fmap f F0 = F0
</code>```

Okay, let's step up our game slightly. What if we've got one value? Well, we just apply our function to that value. Sensible.

```<code>data F1 a = F1 a
instance Functor F1 where fmap f (F1 a0) = F1 (f a0)
</code>```

Once we get to two values, it may not be blindingly obvious what should happen. But I'm going to claim that the most natural thing is to apply the incoming function to both values:

```<code>data F2 a = F2 a a
instance Functor F2 where fmap f (F2 a0 a1) = F2 (f a0) (f a1)
</code>```

With three, we want to apply f to all the values:

```<code>data F3 a = F3 a a a
instance Functor F3 where fmap f (F3 a0 a1 a2) = F3 (f a0) (f a1) (f a2)
</code>```

The pattern continues like this: no matter how many as one of these types contain, the right thing for fmap to do is to apply f to all of them.

In fact, the pattern is so regular, that I think we can abstract it. Let's write types that have zero, one, two, three, and so on values (rather than fields). So:

```<code>data N0
data N1 = N1_0
data N2 = N2_0 | N2_1
data N3 = N3_0 | N3_1 | N3_2
</code>```

These types aren't parameterized at all. Rather than being the collection of values, like F3 a was, an N3 is just an index. In fact, if we wanted, we could write an indexing function:

```<code>index3 :: F3 a -> N3 -> a
index3 (F3 a0 a1 a2) n = case n of
    N3_0 -> a0
    N3_1 -> a1
    N3_2 -> a2
</code>```

This is kind of frustrating, though. We need a new indexing function for each size. It would be nice if things were a bit more uniform -- once we have a type for indices, we'd like to automatically get a container with those values as indices. How can we do that? Well, one way is to just store the indexing function itself; a pre-applied version of index3, for example. So, for our new type F, we'll have

```<code>F N3 a ~= N3 -> a
</code>```

and our new size-independent indexing will just return that function. As a quick example, where before we might have written x = F3 5 16 (-92), now we'll write something like this:

```<code>x ~= \n -> case n of
   N3_0 -> 5
   N3_1 -> 16
   N3_2 -> (-92)
</code>```

You can see how this might be thought of as a pre-applied index. Thinking about fmap quickly, we can use our definition from above: fmap f (F3 a0 a1 a2) = F3 (f a0) (f a1) (f a2). So:

```<code>fmap f x ~= \n -> case n of
    N3_0 -> f 5
    N3_1 -> f 16
    N3_2 -> f (-92)
</code>```

You might want to pause here and think about how you might write a function that did this transformation on x for some specific f like \v -> v+1 or so. So it would have a type like foo :: (N3 -> Int) -> (N3 -> Int). Note that foo shouldn't have to do any pattern matching; x, which we are going to pass in to foo as its first argument, already has the pattern match of interest in it, so foo should be able to use x as its "pattern matcher".

Let's write down our new type:

```<code>data F n a = F (n -> a)
</code>```

Okay. Now I've led you down the garden path, and we can have a grounded thought about what the functor instance should do. It should apply the incoming function to all the values, no matter their index!

With that intuition, I suspect the instance itself will come quite naturally (though perhaps not easily! it can be hard to figure out what the natural choice is).

```<code>instance Functor (F n) where
    fmap f (F index) = F (\n -> {- ... -})
</code>```

Body:
I have this data type:

data F a b = F (a -> b)

My task is to make this type an instance of the Functor class.
I understand how to do this with the usual examples. i.e. Maybe.

Usually, the given function is applied to the value which is extracted from the wrapper. Then the result is replaced in the same wrapper type. The wrapper in the case of the Maybe type being Just.

However, my data type represents a function of type a -> b. I don't understand how to transfer this concept to use a wrapped function. The reason to create this data type as well as the way to implement this idea are both lost on me.

I'm assuming I'm not fully understanding the concept behind functors or just missing the intention behind the given task where I must specifically define and use the custom data type above...

Please help me to correct the following...

instance Functor (F a) where

Body:
I think the other answers address how to write an instance once you know what instance you want to write, but don't give a very good intuition for working out what instance you should want to write in the first place. In this answer, I'll attempt to do that.

I'm going to start very simple. The simplest thing that could possibly be: a functor that doesn't even have any values in it is really, really easy to fmap over.

data F0 a = F0
instance Functor F0 where fmap f F0 = F0

Okay, let's step up our game slightly. What if we've got one value? Well, we just apply our function to that value. Sensible.

data F1 a = F1 a
instance Functor F1 where fmap f (F1 a0) = F1 (f a0)

Once we get to two values, it may not be blindingly obvious what should happen. But I'm going to claim that the most natural thing is to apply the incoming function to both values:

data F2 a = F2 a a
instance Functor F2 where fmap f (F2 a0 a1) = F2 (f a0) (f a1)

With three, we want to apply f to all the values:

data F3 a = F3 a a a
instance Functor F3 where fmap f (F3 a0 a1 a2) = F3 (f a0) (f a1) (f a2)

The pattern continues like this: no matter how many as one of these types contain, the right thing for fmap to do is to apply f to all of them.

In fact, the pattern is so regular, that I think we can abstract it. Let's write types that have zero, one, two, three, and so on values (rather than fields). So:

data N0
data N1 = N1_0
data N2 = N2_0 | N2_1
data N3 = N3_0 | N3_1 | N3_2

These types aren't parameterized at all. Rather than being the collection of values, like F3 a was, an N3 is just an index. In fact, if we wanted, we could write an indexing function:

index3 :: F3 a -> N3 -> a
index3 (F3 a0 a1 a2) n = case n of
    N3_0 -> a0
    N3_1 -> a1
    N3_2 -> a2

This is kind of frustrating, though. We need a new indexing function for each size. It would be nice if things were a bit more uniform -- once we have a type for indices, we'd like to automatically get a container with those values as indices. How can we do that? Well, one way is to just store the indexing function itself; a pre-applied version of index3, for example. So, for our new type F, we'll have

F N3 a ~= N3 -> a

and our new size-independent indexing will just return that function. As a quick example, where before we might have written x = F3 5 16 (-92), now we'll write something like this:

x ~= \n -> case n of
   N3_0 -> 5
   N3_1 -> 16
   N3_2 -> (-92)

You can see how this might be thought of as a pre-applied index. Thinking about fmap quickly, we can use our definition from above: fmap f (F3 a0 a1 a2) = F3 (f a0) (f a1) (f a2). So:

fmap f x ~= \n -> case n of
    N3_0 -> f 5
    N3_1 -> f 16
    N3_2 -> f (-92)

You might want to pause here and think about how you might write a function that did this transformation on x for some specific f like \v -> v+1 or so. So it would have a type like foo :: (N3 -> Int) -> (N3 -> Int). Note that foo shouldn't have to do any pattern matching; x, which we are going to pass in to foo as its first argument, already has the pattern match of interest in it, so foo should be able to use x as its "pattern matcher".

Let's write down our new type:

data F n a = F (n -> a)

Okay. Now I've led you down the garden path, and we can have a grounded thought about what the functor instance should do. It should apply the incoming function to all the values, no matter their index!

With that intuition, I suspect the instance itself will come quite naturally (though perhaps not easily! it can be hard to figure out what the natural choice is).

instance Functor (F n) where
    fmap f (F index) = F (\n -> {- ... -})


问:
HTTP Error 500.31 - ANCM Failed to Find Native Dependencies in IIS
I try to run a Blazor application.

```<code>Web.Server runs .NET Core 3.0
Web.Client runs .NET Standard 2.0
Web.Shared runs .NET Standard 2.0
</code>```

After publishing and uploading the application to IIS i get this error:

```<code>HTTP Error 500.31 - ANCM Failed to Find Native Dependencies
Common solutions to this issue:
The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found.
</code>```

Event Viewer contains this error message:

```<code>HTTP Error 500.31 - ANCM Failed to Find Native Dependencies
</code>```

When I run dotnet --info I can see that I both Microsoft.NetCore.App and Microsoft.AspNetCore.App contains version 3:
    PS C:\Users\FooBar> dotnet --info
    .NET Core SDK (reflecting any global.json):
     Version:   3.0.100-preview6-012264
     Commit:    be3f0c1a03

```<code>Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17763
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100-preview6-012264\

Host (useful for support):
  Version: 3.0.0-preview6-27804-01
  Commit:  fdf81c6faf

.NET Core SDKs installed:
  1.0.4 [C:\Program Files\dotnet\sdk]
  2.0.0 [C:\Program Files\dotnet\sdk]
  2.1.101 [C:\Program Files\dotnet\sdk]
  3.0.100-preview6-012264 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview6.19307.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview6-27804-01 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0-preview6-27804-01 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download
</code>```

ASP.NET Core Diagnostics:

```<code>IMPORTANT: This report might contain confidential information. Mask such before sharing to others.
-----
System Time: 6/18/2019 12:50:58 AM
Processor Architecture: AMD64
OS: Microsoft Windows NT 10.0.17763.0
Server Type: IIS

Scan 31 installed module(s).
ASP.NET Core module version 2 is installed for .NET Core 2.2 and above: C:\Program Files\IIS\Asp.Net Core Module\V2\aspnetcorev2.dll (13.0.19158.0).

Scan 86 registered handler(s).
* Found a valid ASP.NET Core handler as { Name: aspNetCore, Path: *, State: Enabled, Module: AspNetCoreModuleV2, Entry Type: Local }.
  Visual C++ runtime is detected (expected: 14.0, detected: 14.14.26405.0 built by: VCTOOLSREL): C:\WINDOWS\system32\msvcp140.dll.
Scan aspNetCore section.
    "processPath": dotnet.
    "arguments": .\Web.Server.dll.
    "hostingModel": inprocess.
"runtimeTarget": .NETCoreApp,Version=v3.0.
Please refer to pages such as https://dotnet.microsoft.com/download/dotnet-core/2.2 to verify that ASP.NET Core version 13.0.19158.0 matches the runtime of the web app.
</code>```

Why is IIS throwing this error on my server?

Note: It works from Visual Studio 2019.

答: I had this error publishing to an Azure AppService today.  In my case, a previous site already existed in the AppService and when I published the new site into it I got the 500.31 error.  In my case, I updated the publish profile to delete the existing files on the site first, re-published and that fixed the issue (I assume there was something hanging out there in conflict).</p>

Body:
I try to run a Blazor application.

Web.Server runs .NET Core 3.0
Web.Client runs .NET Standard 2.0
Web.Shared runs .NET Standard 2.0

After publishing and uploading the application to IIS i get this error:

HTTP Error 500.31 - ANCM Failed to Find Native Dependencies
Common solutions to this issue:
The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found.

Event Viewer contains this error message:

HTTP Error 500.31 - ANCM Failed to Find Native Dependencies

When I run dotnet --info I can see that I both Microsoft.NetCore.App and Microsoft.AspNetCore.App contains version 3:
    PS C:\Users\FooBar> dotnet --info
    .NET Core SDK (reflecting any global.json):
     Version:   3.0.100-preview6-012264
     Commit:    be3f0c1a03

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17763
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100-preview6-012264\

Host (useful for support):
  Version: 3.0.0-preview6-27804-01
  Commit:  fdf81c6faf

.NET Core SDKs installed:
  1.0.4 [C:\Program Files\dotnet\sdk]
  2.0.0 [C:\Program Files\dotnet\sdk]
  2.1.101 [C:\Program Files\dotnet\sdk]
  3.0.100-preview6-012264 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview6.19307.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview6-27804-01 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0-preview6-27804-01 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

ASP.NET Core Diagnostics:

IMPORTANT: This report might contain confidential information. Mask such before sharing to others.
-----
System Time: 6/18/2019 12:50:58 AM
Processor Architecture: AMD64
OS: Microsoft Windows NT 10.0.17763.0
Server Type: IIS

Scan 31 installed module(s).
ASP.NET Core module version 2 is installed for .NET Core 2.2 and above: C:\Program Files\IIS\Asp.Net Core Module\V2\aspnetcorev2.dll (13.0.19158.0).

Scan 86 registered handler(s).
* Found a valid ASP.NET Core handler as { Name: aspNetCore, Path: *, State: Enabled, Module: AspNetCoreModuleV2, Entry Type: Local }.
  Visual C++ runtime is detected (expected: 14.0, detected: 14.14.26405.0 built by: VCTOOLSREL): C:\WINDOWS\system32\msvcp140.dll.
Scan aspNetCore section.
    "processPath": dotnet.
    "arguments": .\Web.Server.dll.
    "hostingModel": inprocess.
"runtimeTarget": .NETCoreApp,Version=v3.0.
Please refer to pages such as https://dotnet.microsoft.com/download/dotnet-core/2.2 to verify that ASP.NET Core version 13.0.19158.0 matches the runtime of the web app.

Why is IIS throwing this error on my server?

Note: It works from Visual Studio 2019.


问:
Terminology for a deterministic function with no side-effects?
I need the proper terminology for a specific type of function.

Suppose you write a function in your SQL database, whose inputs and outputs are contained within the scope of a database transaction.

That is, if you call this function in the scope of a database transaction, all the data used by the function is available within the same scope.  It can query a database table, but it can't read a file from the filesystem, or ping a web site, etc.  If you call the function twice within a single transaction with REPEATABLE READ isolation, you should get the same result, even if other clients are making changes in the database.

Likewise, the function has no side-effects, except within the same transaction scope.  Changes in state outside the scope of the database transaction are not allowed.  The function shouldn't send emails, nor write to the filesystem, nor store a value in memcached, etc.  If the function changes data within the database, that's okay because if the calling transaction is rolled back, then the effects of the function are too.

The arguments of the function are okay, since they're basically used as constants.

What would be the proper term for a function of this type?  "Deterministic" doesn't really seem to be specific enough.  How would you describe this class of function?

Thanks for your answers, but none of them is exactly what I had in mind.  Idempotent gets closest, so I marked that as the accepted answer.  But each of you got an upvote from me regardless.

Pure functions have no side-effects, and their result is based solely on their arguments.  The result given the same arguments is always identical.  This doesn't work because the database functions I have in mind can be based on the state of data, and the function can also affect the state of data.

Idempotent functions can return a result based on the state of data, and given the same state of data, the result is always identical.  But this doesn't work for what I have in mind exactly; the effects of an idempotent functions must result in an unchanging result no matter how many times the function is called.  But there's no distinction between changes made within transaction isolation and changes made external to that scope.

答: Are you asking about idempotent?</p>

OwnerDisplayName: Bill Karwin

ContentLicense: CC BY-SA 2.5

LastEditorDisplayName: chaos

Body: Are you asking about idempotent?


问:
access java object in javascript
I am using spring framework. I am passing java bean object as model attribute to JSP. On JSP I am calling a javascript function passing this java bean object. I need to access memebers of this object inside the javascript. below is the code snippet

```<code>Test.jsp
..
..
<form:radiobutton id="showdialog" path="nextAction" value="showdialog" label="show dialog"
    onclick="javascript: showDiseaseGroupDialog('${dataRequestFormDTO}');"/></span></div>
..
..

Common.js
function showDiseaseGroupDialog(dataRequestFormDTO){

    alert("DG:"+dataRequestFormDTO.selectedDiseaseGroup);
    for(var diseaseGroupDTO in dataRequestFormDTO.availableDiseaseGroups.values){
        alert(diseaseGroupDTO.name);
    }
}

DataRequestFormDTO.java
public class DataRequestFormDTO{
    private String selectedDiseaseGroup;
    private Map<String, DiseaseGroupDTO> availableDiseaseGroups;

    public String getSelectedDiseaseGroup() {
        return selectedDiseaseGroups;
    }

    public void setSelectedDiseaseGroup(String selectedDiseaseGroup) {
        this.selectedDiseaseGroup = selectedDiseaseGroup;
    }

    public Map<String, DiseaseGroupDTO> getAvailableDiseaseGroups() {
        return availableDiseaseGroups;
    }

    public void setAvailableDiseaseGroups(
            Map<String, DiseaseGroupDTO> availableDiseaseGroups) {
        this.availableDiseaseGroups = availableDiseaseGroups;
    }
}

public class DiseaseGroupDTO {

    private String id;
    private String name;

    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

}
</code>```

Problem is I am getting error in showDiseaseGroupDialog function. First alert displays "DG:undefined" and javascript error "availableDiseaseGroups is undefined".

I want to understand

Why java bean members are not accessible in javascript? Though in jsp I can print the same values.

how hashmap/arraylist can access in javascript?

答: You cannot pass a java object directly into javascript, because the java object is only meaningful with Java Virtual Machine while the javascript can only be interpreted by the JS engine in browser. But you can transform the java bean into a JSON format or other plain text format. </p>

ContentLicense: CC BY-SA 3.0

Title: access java object in javascript

Body:
I am using spring framework. I am passing java bean object as model attribute to JSP. On JSP I am calling a javascript function passing this java bean object. I need to access memebers of this object inside the javascript. below is the code snippet

Test.jsp
..
..
<form:radiobutton id="showdialog" path="nextAction" value="showdialog" label="show dialog"
    onclick="javascript: showDiseaseGroupDialog('${dataRequestFormDTO}');"/>

..
..

Common.js
function showDiseaseGroupDialog(dataRequestFormDTO){

    alert("DG:"+dataRequestFormDTO.selectedDiseaseGroup);
    for(var diseaseGroupDTO in dataRequestFormDTO.availableDiseaseGroups.values){
        alert(diseaseGroupDTO.name);
    }
}

DataRequestFormDTO.java
public class DataRequestFormDTO{
    private String selectedDiseaseGroup;
    private Map<String, DiseaseGroupDTO> availableDiseaseGroups;

    public String getSelectedDiseaseGroup() {
        return selectedDiseaseGroups;
    }

    public void setSelectedDiseaseGroup(String selectedDiseaseGroup) {
        this.selectedDiseaseGroup = selectedDiseaseGroup;
    }

    public Map<String, DiseaseGroupDTO> getAvailableDiseaseGroups() {
        return availableDiseaseGroups;
    }

    public void setAvailableDiseaseGroups(
            Map<String, DiseaseGroupDTO> availableDiseaseGroups) {
        this.availableDiseaseGroups = availableDiseaseGroups;
    }
}

public class DiseaseGroupDTO {

    private String id;
    private String name;

    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

}

Problem is I am getting error in showDiseaseGroupDialog function. First alert displays "DG:undefined" and javascript error "availableDiseaseGroups is undefined".

I want to understand

Why java bean members are not accessible in javascript? Though in jsp I can print the same values.

how hashmap/arraylist can access in javascript?


问:
Process Maker 4.2 Script output
I am working on process maker 4.2, and it is running on “localhost:8080”.
I created one script named as "practice1" , where I am returning a simple output i.e, return {"Hello": "Tryig by Devesh"};

How can I get the script output when I will call that endpoint using postman.
As of now I am using "http://localhost:8080/api/1.0/scripts/2" and my response code is 200 and the output which I am getting here is:-

How can I get my script output ("Hello": "Tryig by Devesh") here instead of getting all the data ?

答:
You should be use the POST method in order to execute the script. The endpoint should be return a key; with this key, you can get the response of the script execution, using this another endpoint:

```<code>GET http://localhost:8080/api/1.0/scripts/execution/{key}
</code>```

Title: Process Maker 4.2 Script output

Body:
You should be use the POST method in order to execute the script. The endpoint should be return a key; with this key, you can get the response of the script execution, using this another endpoint:

GET http://localhost:8080/api/1.0/scripts/execution/{key}


问:
Laravel Sanctum Token API Authentication Not Working in Postman
I am trying to utilize Sanctum for an API only application. I am not using it for a SPA. I have a single end point set up and protected by the Sanctum middleware. I am creating a user and a token for said user through the tinker cli tool. I then paste the token into Postman under the bearer token selection within the authorization tab. However, when I submit the request I get an unauthenticated error. Not quite sure what I am doing incorrect here. Followed the documentation provided very closely as well as the sparse videos I could find. Here are some code snippets. I appreciate the insight here.

API.php

```<code>Route::middleware('auth:sanctum')->apiResource('/documents','DocumentHandlerController');
</code>```

Middleware/Authenticate.php

```<code>class Authenticate extends Middleware
{
    /**
     * Return 401 when not authorized
     *
     * @param  \Illuminate\Http\Request  $request
     * @return string|null
     */
    public function handle($request)
    {
        return response()->json(
            ['message'=>'Unauthorized']
            ,Response::HTTP_UNAUTHORIZED
        );
    }
}
</code>```

Function from my controller

```<code>    public function index()
    {
        return response()->json(['Success'],Response::HTTP_OK);
    }
</code>```

答:
I killed full day when trying to solve this problem. In my case, the problem was in the Apache config. I hope this helps you.</p>
```<code>RewriteCond %{HTTP:Authorization} ^(.+)$
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</code>```

Body:
I am trying to utilize Sanctum for an API only application. I am not using it for a SPA. I have a single end point set up and protected by the Sanctum middleware. I am creating a user and a token for said user through the tinker cli tool. I then paste the token into Postman under the bearer token selection within the authorization tab. However, when I submit the request I get an unauthenticated error. Not quite sure what I am doing incorrect here. Followed the documentation provided very closely as well as the sparse videos I could find. Here are some code snippets. I appreciate the insight here.

API.php

Route::middleware('auth:sanctum')->apiResource('/documents','DocumentHandlerController');

Middleware/Authenticate.php

class Authenticate extends Middleware
{
    /**
     * Return 401 when not authorized
     *
     * @param  \Illuminate\Http\Request  $request
     * @return string|null
     */
    public function handle($request)
    {
        return response()->json(
            ['message'=>'Unauthorized']
            ,Response::HTTP_UNAUTHORIZED
        );
    }
}

Function from my controller

    public function index()
    {
        return response()->json(['Success'],Response::HTTP_OK);
    }

Body:
I killed full day when trying to solve this problem. In my case, the problem was in the Apache config. I hope this helps you.

RewriteCond %{HTTP:Authorization} ^(.+)$
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]


问:
NWJS app crashing because of website console errors
I've a NW.JS desktop app keeps crashing because of webpage errors.
I'm trying to open this webpage inside my app - URL

As soon as the pages get loaded my app starts to crash with the following error:

```<code>[3491:775:0210/215448.347299:FATAL:native_extension_bindings_system.cc(214)] Check failed: schema. arcAppsPrivate
0   nwjs Framework                      0x000000011243a239 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 14936185
1   nwjs Framework                      0x000000011239a8f3 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 14282547
2   nwjs Framework                      0x00000001123ad73f v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 14359935
3   nwjs Framework                      0x00000001123ae5ee v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 14363694
4   nwjs Framework                      0x0000000111ad1838 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 5070456
5   nwjs Framework                      0x0000000111a9900a v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 4838986
6   nwjs Framework                      0x0000000111a98f7d v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 4838845
7   nwjs Framework                      0x0000000111ad4de8 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 5084200
8   nwjs Framework                      0x0000000111ad48b3 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 5082867
9   nwjs Framework                      0x0000000111ad4253 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 5081235
10  nwjs Framework                      0x0000000111ad447f v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 5081791
11  nwjs Framework                      0x0000000110f02f73 v8::internal::FixedArray::SetAndGrow(v8::internal::Isolate*, v8::internal::Handle<v8::internal::FixedArray>, int, v8::internal::Handle<v8::internal::Object>) + 1763
12  nwjs Framework                      0x0000000110f02321 v8::internal::Object::GetProperty(v8::internal::LookupIterator*, bool) + 3041
13  nwjs Framework                      0x0000000110f01814 v8::internal::Object::GetProperty(v8::internal::LookupIterator*, bool) + 212
14  nwjs Framework                      0x0000000111048bf5 v8::internal::Runtime::GetObjectProperty(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, bool*) + 181
15  nwjs Framework                      0x000000011104f103 v8::internal::Runtime::DefineObjectOwnProperty(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::StoreOrigin, v8::Maybe<v8::internal::ShouldThrow>) + 13571
16  ???                                 0x0000003707f0a8f8 0x0 + 236356413688
17  ???                                 0x0000003707fa17b6 0x0 + 236357031862
18  ???                                 0x0000003707e8c862 0x0 + 236355897442
Task trace:
    0   nwjs Framework                      0x0000000115920992 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 70406098
1   nwjs Framework                      0x00000001125fe106 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 16787270
IPC message handler context: 0x95373B38
Crash keys:
    "discardable-memory-free" = "2715648"
"discardable-memory-allocated" = "4194304"
"view-count" = "3"
"extension-1" = "jhedmmohalmhagooekjmhcjkphpnfmfa"
"num-extensions" = "1"
"blink_scheduler_async_stack" = "0x115920992 0x1125FE106"
"v8_code_space_firstpage_address" = "0x3700000000"
"v8_map_space_firstpage_address" = "0x3708180000"
"v8_ro_space_firstpage_address" = "0x3708000000"
"v8_isolate_address" = "0x7ff2f8c44000"
"variations" = "f475deb0-f475deb0,313957be-3ef44cd2,7e184ca7-2ec1a7e,60c843ad-3f4a17df,3fa8d059-3fa8d059,3c98d047-3f4a17df,8950ab95-3f4a17df,6cbcf5b7-3f4a17df,4701a278-3f4a17df,4749874c-a300a3e6,65570806-377be55a,6aa15a86-9d8c1aae,8e3b682d-3f4a17df,722b8030-3f4a17df,3042ad4b-ad2fa222,e4a357e9-3f4a17df,3fd33f16-fa281276,5252c71-3f4a17df,e79de56c-dee0823,8bccc03b-3f4a17df,178e8b37-3f4a17df,facdb7bf-3f4a17df,69d4ebd5-3f4a17df,9e5c75f1-30e1b12b,255dfea8-cf12f279,a083757a-d6a08b38,e4cbd6c7-3f4a17df,f7a3ec9-bd336006,3487aa71-84708353,23a898eb-fc93cf74,d3566fbd-c6f74b94,4ea303a6-3f4a17df,7048821f-7b0f7072,ef4764d7-c9f4d4ef,931c5f72-3f4a17df,ade3efeb-e1cc0f14,32d6b1fe-3f4a17df,ae82076d-3f4a17df,17b84626-3f4a17df,8d7344de-3f4a17df,1bb6a450-3f4a17df,3e7d7783-f38a9353,90a7075b-725c8fbe,1d606bb5-8d14c5d8,a0da97d6-3f4a17df,3b96a1d-3f4a17df,248e3a0-3f4a17df,dba92675-f23d1dea,5306c29b-9cbf73ff,f8a7f5e4-d6a08b38,e87da360-3f4a17df,39ec51c3-572726d7,77e44b8e-3f4a17df,6c5f69af-3f4a17df,bef5c006-3f4a17df,fc7e4d22-3f4a17df,7638c831-857014ec,a112f012-3f4a17df,6e08fc3e-3f4a17df,8470b833-3f4a17df,6be2e990-3f4a17df,47d92407-5b5edf5b,4b9a5bc0-efbbc50a,49a20295-49a20295,f2cb61f-3f4a17df,8c8d8faf-3f4a17df,727723f1-40193c20,b012722b-3f4a17df,d8692482-fe3984ae,29c62d4-3f4a17df,7760b5b2-3f4a17df,ad4acdda-3f4a17df,234de0a0-ace4e138,b1ceb06f-3f4a17df,ca5a2953-ff983c32,4e3ec83a-e4938e2c,7f655da7-3f4a17df,248c3fbd-3f4a17df,6cb5e962-3f4a17df,bf4029fe-1776d9e,6a5f15b-3f4a17df,61a655b5-3f4a17df,54410569-3f4a17df,6aa685f2-dcaf2061,f48c01d3-6eb2bd2b,89a16501-3f4a17df,"
"num-experiments" = "86"
"switch-21" = "--user-data-dir=/path/temp/userdatadir/profile2"
"switch-20" = "--user-data-dir=/path/temp/userdatadir/profile2"
"switch-19" = "--disable-gpu"
"switch-18" = "--field-trial-handle=1718379636,962445429152936292,7087525159415"
"switch-17" = "--shared-files"
"switch-16" = "--launch-time-ticks=8302334130"
"switch-15" = "--renderer-client-id=6"
"switch-14" = "--enable-main-frame-before-activation"
"switch-13" = "--enable-gpu-memory-buffer-compositor-resources"
"switch-12" = "--enable-zero-copy"
"switch-11" = "--num-raster-threads=4"
"switch-10" = "--lang=en-GB"
"switch-9" = "--disable-gpu-compositing"
"switch-8" = "--no-zygote"
"switch-7" = "--file-url-path-alias=/gen=/path/software/nwjs-sdk-"
"switch-6" = "--no-sandbox"
"switch-5" = "--display-capture-permissions-policy-allowed"
"switch-4" = "--extension-process"
"switch-3" = "--nwjs"
"switch-2" = "--nwapp-path=/path/projects/soft-v2/nw"
"switch-1" = "--user-data-dir=/path/temp/userdatadir/profile2"
"num-switches" = "24"
"osarch" = "x86_64"
"pid" = "3491"
"ptype" = "renderer"

    [0210/215448.351355:WARNING:process_memory_mac.cc(93)] mach_vm_read(0x7ffeebe70000, 0x2000): (os/kern) invalid address (1)
    [3486:12803:0210/215448.434605:ERROR:ssl_client_socket_impl.cc(995)] handshake failed; returned -1, SSL error code 1, net_error -200
    [3486:18691:0210/215448.806969:WARNING:sqlite_persistent_store_backend_base.cc(171)] Failed to post task from FlushAndNotifyInBackground@net/extras/sqlite/sqlite_persistent_store_backend_base.cc:219 to client_task_runner_.
    [3486:18691:0210/215448.807044:WARNING:sqlite_persistent_store_backend_base.cc(171)] Failed to post task from FlushAndNotifyInBackground@net/extras/sqlite/sqlite_persistent_store_backend_base.cc:219 to client_task_runner_.
    [3475:775:0210/215448.857362:WARNING:pref_notifier_impl.cc(40)] Pref observer for media_router.cast_allow_all_ips found at shutdown.
</code>```

There's a similar issue already open - URL

I tried upgrading/downgrading NWJS version.

Tried passing the
flags suggested in one of the comments of the github issue

Tried
adding try catch to window open like below:

try {
nw.Window.open(url);
}
catch(err) {
log.info("Got error")
}

Tried different OS (Mac & Windows)

It crashes with both 32 Bit NWJS and 64 Bit. Tried both of them.

But nothing is working.

However, another page link of the same website is working, which does not have console errors and much content. URL

Need help in understanding the problem and fixing it.

Also, I'm surprised as well, since a webpage can cause the NWJS desktop app to crash.

答:
I could be wrong, but I think the feature you're looking for is:

nw.Shell.openExternal('https://seller.flipkart.com/sell-online');
```

That page just looks like a normal website, not a desktop app that would need access to Node.js. So you can just use nw.Shell.openExternal to open the page in the user's default browser. For security reasons, it's best to avoid using node-remote unless you are running a local webserver and pointing it to "http://localhost:8000" (or whatever port).

Body:
I've a NW.JS desktop app keeps crashing because of webpage errors.
I'm trying to open this webpage inside my app - URL

As soon as the pages get loaded my app starts to crash with the following error:

[3491:775:0210/215448.347299:FATAL:native_extension_bindings_system.cc(214)] Check failed: schema. arcAppsPrivate
0   nwjs Framework                      0x000000011243a239 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 14936185
1   nwjs Framework                      0x000000011239a8f3 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 14282547
2   nwjs Framework                      0x00000001123ad73f v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 14359935
3   nwjs Framework                      0x00000001123ae5ee v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 14363694
4   nwjs Framework                      0x0000000111ad1838 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 5070456
5   nwjs Framework                      0x0000000111a9900a v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 4838986
6   nwjs Framework                      0x0000000111a98f7d v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 4838845
7   nwjs Framework                      0x0000000111ad4de8 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 5084200
8   nwjs Framework                      0x0000000111ad48b3 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 5082867
9   nwjs Framework                      0x0000000111ad4253 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 5081235
10  nwjs Framework                      0x0000000111ad447f v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 5081791
11  nwjs Framework                      0x0000000110f02f73 v8::internal::FixedArray::SetAndGrow(v8::internal::Isolate*, v8::internal::Handle<v8::internal::FixedArray>, int, v8::internal::Handle<v8::internal::Object>) + 1763
12  nwjs Framework                      0x0000000110f02321 v8::internal::Object::GetProperty(v8::internal::LookupIterator*, bool) + 3041
13  nwjs Framework                      0x0000000110f01814 v8::internal::Object::GetProperty(v8::internal::LookupIterator*, bool) + 212
14  nwjs Framework                      0x0000000111048bf5 v8::internal::Runtime::GetObjectProperty(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, bool*) + 181
15  nwjs Framework                      0x000000011104f103 v8::internal::Runtime::DefineObjectOwnProperty(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::StoreOrigin, v8::Maybe<v8::internal::ShouldThrow>) + 13571
16  ???                                 0x0000003707f0a8f8 0x0 + 236356413688
17  ???                                 0x0000003707fa17b6 0x0 + 236357031862
18  ???                                 0x0000003707e8c862 0x0 + 236355897442
Task trace:
    0   nwjs Framework                      0x0000000115920992 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 70406098
1   nwjs Framework                      0x00000001125fe106 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 16787270
IPC message handler context: 0x95373B38
Crash keys:
    "discardable-memory-free" = "2715648"
"discardable-memory-allocated" = "4194304"
"view-count" = "3"
"extension-1" = "jhedmmohalmhagooekjmhcjkphpnfmfa"
"num-extensions" = "1"
"blink_scheduler_async_stack" = "0x115920992 0x1125FE106"
"v8_code_space_firstpage_address" = "0x3700000000"
"v8_map_space_firstpage_address" = "0x3708180000"
"v8_ro_space_firstpage_address" = "0x3708000000"
"v8_isolate_address" = "0x7ff2f8c44000"
"variations" = "f475deb0-f475deb0,313957be-3ef44cd2,7e184ca7-2ec1a7e,60c843ad-3f4a17df,3fa8d059-3fa8d059,3c98d047-3f4a17df,8950ab95-3f4a17df,6cbcf5b7-3f4a17df,4701a278-3f4a17df,4749874c-a300a3e6,65570806-377be55a,6aa15a86-9d8c1aae,8e3b682d-3f4a17df,722b8030-3f4a17df,3042ad4b-ad2fa222,e4a357e9-3f4a17df,3fd33f16-fa281276,5252c71-3f4a17df,e79de56c-dee0823,8bccc03b-3f4a17df,178e8b37-3f4a17df,facdb7bf-3f4a17df,69d4ebd5-3f4a17df,9e5c75f1-30e1b12b,255dfea8-cf12f279,a083757a-d6a08b38,e4cbd6c7-3f4a17df,f7a3ec9-bd336006,3487aa71-84708353,23a898eb-fc93cf74,d3566fbd-c6f74b94,4ea303a6-3f4a17df,7048821f-7b0f7072,ef4764d7-c9f4d4ef,931c5f72-3f4a17df,ade3efeb-e1cc0f14,32d6b1fe-3f4a17df,ae82076d-3f4a17df,17b84626-3f4a17df,8d7344de-3f4a17df,1bb6a450-3f4a17df,3e7d7783-f38a9353,90a7075b-725c8fbe,1d606bb5-8d14c5d8,a0da97d6-3f4a17df,3b96a1d-3f4a17df,248e3a0-3f4a17df,dba92675-f23d1dea,5306c29b-9cbf73ff,f8a7f5e4-d6a08b38,e87da360-3f4a17df,39ec51c3-572726d7,77e44b8e-3f4a17df,6c5f69af-3f4a17df,bef5c006-3f4a17df,fc7e4d22-3f4a17df,7638c831-857014ec,a112f012-3f4a17df,6e08fc3e-3f4a17df,8470b833-3f4a17df,6be2e990-3f4a17df,47d92407-5b5edf5b,4b9a5bc0-efbbc50a,49a20295-49a20295,f2cb61f-3f4a17df,8c8d8faf-3f4a17df,727723f1-40193c20,b012722b-3f4a17df,d8692482-fe3984ae,29c62d4-3f4a17df,7760b5b2-3f4a17df,ad4acdda-3f4a17df,234de0a0-ace4e138,b1ceb06f-3f4a17df,ca5a2953-ff983c32,4e3ec83a-e4938e2c,7f655da7-3f4a17df,248c3fbd-3f4a17df,6cb5e962-3f4a17df,bf4029fe-1776d9e,6a5f15b-3f4a17df,61a655b5-3f4a17df,54410569-3f4a17df,6aa685f2-dcaf2061,f48c01d3-6eb2bd2b,89a16501-3f4a17df,"
"num-experiments" = "86"
"switch-21" = "--user-data-dir=/path/temp/userdatadir/profile2"
"switch-20" = "--user-data-dir=/path/temp/userdatadir/profile2"
"switch-19" = "--disable-gpu"
"switch-18" = "--field-trial-handle=1718379636,962445429152936292,7087525159415"
"switch-17" = "--shared-files"
"switch-16" = "--launch-time-ticks=8302334130"
"switch-15" = "--renderer-client-id=6"
"switch-14" = "--enable-main-frame-before-activation"
"switch-13" = "--enable-gpu-memory-buffer-compositor-resources"
"switch-12" = "--enable-zero-copy"
"switch-11" = "--num-raster-threads=4"
"switch-10" = "--lang=en-GB"
"switch-9" = "--disable-gpu-compositing"
"switch-8" = "--no-zygote"
"switch-7" = "--file-url-path-alias=/gen=/path/software/nwjs-sdk-"
"switch-6" = "--no-sandbox"
"switch-5" = "--display-capture-permissions-policy-allowed"
"switch-4" = "--extension-process"
"switch-3" = "--nwjs"
"switch-2" = "--nwapp-path=/path/projects/soft-v2/nw"
"switch-1" = "--user-data-dir=/path/temp/userdatadir/profile2"
"num-switches" = "24"
"osarch" = "x86_64"
"pid" = "3491"
"ptype" = "renderer"

    [0210/215448.351355:WARNING:process_memory_mac.cc(93)] mach_vm_read(0x7ffeebe70000, 0x2000): (os/kern) invalid address (1)
    [3486:12803:0210/215448.434605:ERROR:ssl_client_socket_impl.cc(995)] handshake failed; returned -1, SSL error code 1, net_error -200
    [3486:18691:0210/215448.806969:WARNING:sqlite_persistent_store_backend_base.cc(171)] Failed to post task from FlushAndNotifyInBackground@net/extras/sqlite/sqlite_persistent_store_backend_base.cc:219 to client_task_runner_.
    [3486:18691:0210/215448.807044:WARNING:sqlite_persistent_store_backend_base.cc(171)] Failed to post task from FlushAndNotifyInBackground@net/extras/sqlite/sqlite_persistent_store_backend_base.cc:219 to client_task_runner_.
    [3475:775:0210/215448.857362:WARNING:pref_notifier_impl.cc(40)] Pref observer for media_router.cast_allow_all_ips found at shutdown.

There's a similar issue already open - URL

I tried upgrading/downgrading NWJS version.

Tried passing the
flags suggested in one of the comments of the github issue

Tried
adding try catch to window open like below:

try {
nw.Window.open(url);
}
catch(err) {
log.info("Got error")
}

Tried different OS (Mac & Windows)

It crashes with both 32 Bit NWJS and 64 Bit. Tried both of them.

But nothing is working.

However, another page link of the same website is working, which does not have console errors and much content. URL

Need help in understanding the problem and fixing it.

Also, I'm surprised as well, since a webpage can cause the NWJS desktop app to crash.

Body:
I could be wrong, but I think the feature you're looking for is:

nw.Shell.openExternal('https://seller.flipkart.com/sell-online');

That page just looks like a normal website, not a desktop app that would need access to Node.js. So you can just use nw.Shell.openExternal to open the page in the user's default browser. For security reasons, it's best to avoid using node-remote unless you are running a local webserver and pointing it to "http://localhost:8000" (or whatever port).


问:
How to convert Cassandra UDT to Optional type
I have a User table and its corresponding POJO

```<code>@Table
public class User{
  @Column(name = "id")
  private String id;

  // lots of fields

  @Column(name = "address")
  @Frozen
  private Optional<Address> address;

  // getters and setters
}

@UDT
public class Address {
  @Field(name = "id")
  private String id;

  @Field(name = "country")
  private String country;

  @Field(name = "state")
  private String state;

  @Field(name = "district")
  private String district;

  @Field(name = "street")
  private String street;

  @Field(name = "city")
  private String city;

  @Field(name = "zip_code")
  private String zipCode;

  // getters and setters
}
</code>```

I wanna convert UDT "address" to Optional.
Because I use "cassandra-driver-mapping:3.0.0-rc1" and "cassandra-driver-extras:3.0.0-rc1", there are lots of codec I can use them.

For example: OptionalCodec

I wanna register it to CodecRegistry and pass TypeCodec to OptionalCodec's constructor.

But TypeCodec is a abstract class, I can't initiate it.

Someone have any idea how to initiate OptionalCodec?

Thank you, @Olivier Michallat. Your solution is OK!

But I'm a little confused to set OptionalCodec to CodecRegistry.
You must initial a session at first.
Then pass session to MappingManager, get correct TypeCodec and register codecs.

It's a little weird that you must initial session at first, in order to get TypeCodec !?

```<code>Cluster cluster = Cluster.builder()
                         .addContactPoints("127.0.0.1")
                         .build();
Session session = cluster.connect(...);
cluster.getConfiguration()
       .getCodecRegistry()
       .register(new OptionalCodec(new MappingManager(session).udtCodec(Address.class)))
       .register(...);
// use session to operate DB
</code>```

答:
Not really an answer but hope it helps. I  couldn't make the Optional work with UDT in scala. However List and Array are working fine:

Here is a scala solution for driver version 4.x:

val reg = session.getContext.getCodecRegistry
val yourTypeUdt: UserDefinedType = session.getMetadata.getKeyspace(keyspace).flatMap(_.getUserDefinedType("YOUR_TYPE")).get
val yourTypeCodec: TypeCodec[UserDefinedType] = reg.codecFor(yourTypeUdt)
reg.asInstanceOf[MutableCodecRegistry].register(TypeCodecs.listOf(yourTypeCodec))
```

Don't forget to use java.util.* instead of your normal scala types.

Body:
I have a User table and its corresponding POJO

@Table
public class User{
  @Column(name = "id")
  private String id;

  // lots of fields

  @Column(name = "address")
  @Frozen
  private Optional<Address> address;

  // getters and setters
}

@UDT
public class Address {
  @Field(name = "id")
  private String id;

  @Field(name = "country")
  private String country;

  @Field(name = "state")
  private String state;

  @Field(name = "district")
  private String district;

  @Field(name = "street")
  private String street;

  @Field(name = "city")
  private String city;

  @Field(name = "zip_code")
  private String zipCode;

  // getters and setters
}

I wanna convert UDT "address" to Optional.
Because I use "cassandra-driver-mapping:3.0.0-rc1" and "cassandra-driver-extras:3.0.0-rc1", there are lots of codec I can use them.

For example: OptionalCodec

I wanna register it to CodecRegistry and pass TypeCodec to OptionalCodec's constructor.

But TypeCodec is a abstract class, I can't initiate it.

Someone have any idea how to initiate OptionalCodec?

Thank you, @Olivier Michallat. Your solution is OK!

But I'm a little confused to set OptionalCodec to CodecRegistry.
You must initial a session at first.
Then pass session to MappingManager, get correct TypeCodec and register codecs.

It's a little weird that you must initial session at first, in order to get TypeCodec !?

Cluster cluster = Cluster.builder()
                         .addContactPoints("127.0.0.1")
                         .build();
Session session = cluster.connect(...);
cluster.getConfiguration()
       .getCodecRegistry()
       .register(new OptionalCodec(new MappingManager(session).udtCodec(Address.class)))
       .register(...);
// use session to operate DB

Body:
Not really an answer but hope it helps. I  couldn't make the Optional work with UDT in scala. However List and Array are working fine:

Here is a scala solution for driver version 4.x:

val reg = session.getContext.getCodecRegistry
val yourTypeUdt: UserDefinedType = session.getMetadata.getKeyspace(keyspace).flatMap(_.getUserDefinedType("YOUR_TYPE")).get
val yourTypeCodec: TypeCodec[UserDefinedType] = reg.codecFor(yourTypeUdt)
reg.asInstanceOf[MutableCodecRegistry].register(TypeCodecs.listOf(yourTypeCodec))

Don't forget to use java.util.* instead of your normal scala types.


问:
Get route path '/blog/{slug}' of current request in Symfony
For some logging/monitoring i would like to get the current route path including placeholders.

If my route is /blog/{slug} and the request is to http://localhost/blog/foobar what i need is "/blog/{slug}"

In request listeners this value seem to not be inside the request object. I only find the resolved path which i am not interested in.

In Compiler passes I have the issue that any Router related service I try to get from the ContainerBuilder returns an exception. If i had the

What is a clean way to obtain this?

答:
You can obtain the Router and RouteCollection, that holds all the routes in your app:

```<code>// src/Listener/RouteLoggerListener.php -- namespace and use ommited
class RouteLoggerListener implements EventSubscriberInterface
{
    /**
     * @var LoggerInterface
     */
    private $logger;
    /**
     * @var RouterInterface
     */
    private $router;

    public function __construct(LoggerInterface $logger, RouterInterface $router)
    {
        $this->logger = $logger;
        $this->router = $router;
    }

    public static function getSubscribedEvents()
    {
        // Trigger after the RouterListener
        return [KernelEvents::REQUEST => ['onKernelRequest', 50]];
    }

    public function onKernelRequest(RequestEvent $event)
    {
        // This is for sf53 and up, for previous versions, use isMasterRequest()
        if (!$event->isMainRequest()) {
            return;
        }

        $request = $event->getRequest();

        if (null == $request) {
            return;
        }

        $matchedRoute = $request->attributes->get('_route');

        if (null == $matchedRoute) {
            // Bail gracefully
            return;
        }

        $routeCollection = $this->router->getRouteCollection();
        $route = $routeCollection->get($matchedRoute);
        $this->logger->debug('Request route: '.$route->getPath());
    }
}
</code>```

Note: Using RouteCollection at runtime is highly discouraged because it triggers a recompile. As indicated in this GitHub comment, the proper way to do it would be to use ConfigCache while cache warming.

Body:
You can obtain the Router and RouteCollection, that holds all the routes in your app:

// src/Listener/RouteLoggerListener.php -- namespace and use ommited
class RouteLoggerListener implements EventSubscriberInterface
{
    /**
     * @var LoggerInterface
     */
    private $logger;
    /**
     * @var RouterInterface
     */
    private $router;

    public function __construct(LoggerInterface $logger, RouterInterface $router)
    {
        $this->logger = $logger;
        $this->router = $router;
    }

    public static function getSubscribedEvents()
    {
        // Trigger after the RouterListener
        return [KernelEvents::REQUEST => ['onKernelRequest', 50]];
    }

    public function onKernelRequest(RequestEvent $event)
    {
        // This is for sf53 and up, for previous versions, use isMasterRequest()
        if (!$event->isMainRequest()) {
            return;
        }

        $request = $event->getRequest();

        if (null == $request) {
            return;
        }

        $matchedRoute = $request->attributes->get('_route');

        if (null == $matchedRoute) {
            // Bail gracefully
            return;
        }

        $routeCollection = $this->router->getRouteCollection();
        $route = $routeCollection->get($matchedRoute);
        $this->logger->debug('Request route: '.$route->getPath());
    }
}

Note: Using RouteCollection at runtime is highly discouraged because it triggers a recompile. As indicated in this GitHub comment, the proper way to do it would be to use ConfigCache while cache warming.


问:
BeautifulSoup - find the element following an already found element
I am trying to find the ul element under the h2 element.

I find the h2 element with:

```<code>tmpSpan = soupDetail.find_all("a", {"class": "external"})
tmpParent = tmpSpan.parent
</code>```

I have tried several methods to get the following ul element (descendants, next_sibling, next-element, etc. ) but the result is always the span element in the h1.

How can I do this?

答:
```<code>tmpSpan = soupDetail.find_all("a", {"class": "external"})
tmpParent = tmpSpan.parent
</code>```

Above code from your question will lead to an AttributeError, cause ResultSet object has no attribute parent.

Select your tags more specific for example with css selectors - An build it based on tag or id, cause they are mor static then classes.

Get the
 based on its content:

```<code>soup.select_one('h2:has(span#External_links)')
</code>```

Get the next sibling
 of such these
:

```<code>soup.select_one('h2:has(span#External_links) + ul')
</code>```

or

```<code>soup.select_one('h2:has(span#External_links)').find_next('ul')
</code>```

Example

```<code>from bs4 import BeautifulSoup
html='''
<h2>
    <span id="External_links"></span>
    <span>
        <a class="external"></a>
    </span>
</h2>
<ul></ul>
'''

soup = BeautifulSoup(html, 'lxml')

print(soup.select_one('h2:has(span#External_links) + ul'))

##output
<ul></ul>
</code>```

Body:
I am trying to find the ul element under the h2 element.

I find the h2 element with:

tmpSpan = soupDetail.find_all("a", {"class": "external"})
tmpParent = tmpSpan.parent

I have tried several methods to get the following ul element (descendants, next_sibling, next-element, etc. ) but the result is always the span element in the h1.

How can I do this?

Body:
tmpSpan = soupDetail.find_all("a", {"class": "external"})
tmpParent = tmpSpan.parent

Above code from your question will lead to an AttributeError, cause ResultSet object has no attribute parent.

Select your tags more specific for example with css selectors - An build it based on tag or id, cause they are mor static then classes.

Get the <h2> based on its content:

soup.select_one('h2:has(span#External_links)')

Get the next sibling <ul> of such these <h2>:

soup.select_one('h2:has(span#External_links) + ul')

or

soup.select_one('h2:has(span#External_links)').find_next('ul')

Example

from bs4 import BeautifulSoup
html='''
<h2>
    <span id="External_links"></span>
    <span>
        <a class="external"></a>
    </span>
</h2>
<ul></ul>
'''

soup = BeautifulSoup(html, 'lxml')

print(soup.select_one('h2:has(span#External_links) + ul'))

##output
<ul></ul>


问:
Peculiar Maven Repository Resolution Problem
I am facing a strange phenomena related to Maven repository resolution (Maven version: 3.8.4) which I am unable to explain. The matter is as follows:

We have a internal Nexus proxy setup for Central Repository. The URL is http://[companyDomain]:8081/repository/maven-central

I am declaring a repository in the pom.xml as follows:

```<code>     <repository>
        <id>nexus-maven-central</id>
        <name>Maven Central Repository Internal Proxy</name>
        <url>http://[companyDomain]:8081/repository/maven-central</url>
        <layout>default</layout>
        <snapshots><enabled>true</enabled></snapshots>
        <releases><enabled>true</enabled></releases>
    </repository>
</code>```

The effective pom is showing the above repository as the first in the list of repositories and default Maven Central repository (id:central) after that as it should be.

However, when I build the pom, Maven is directly going to the Maven Central repository, not considering the above repository.

Now, when I start a Nexus instance in my local host and change the above URL to:

```<code>http://localhost:8081/repository/maven-central
</code>```

Maven resolves the repository and downloads from the localhost.

Further, when I use the http://[companyDomain]:8081/repository/maven-central again in the pom and this time configure a mirror in the global setting.xml (I am not using user specific settings)

```<code><mirror>
  <id>nexus-maven-central-mirror</id>
  <name>Mirror for Maven Central Repository</name>
  <url>http://[companyDomain]:8081/repository/maven-central</url>
  <mirrorOf>central</mirrorOf>
</mirror>
</code>```

Maven perfectly resolves the internal proxy repository and downloads artifacts.

As for the environment, I am connecting to the corporate network through a VPN. IP of the internal Nexus server is resolvable when I am connected to the VPN; there are no VPN outages when I am trying the above.

I was expecting Maven to at least try the internal proxy repo when configured with the 'downloading from ...' message, nothing of that nature shows up in the console. It goes directly to Central Repository.

I further tested with the following URLs:

http://repo1.maven.org/maven2/ ---> Does Not Work

https://repo1.maven.org/maven2/ ---> Works

While I am aware that Maven does not prefer to download from 'http' and Maven Central explicitly states that it will send error if accessed over http, then the question is why is it downloading from localhost on http and not remote; does Maven have this behaviour of ignoring remote http.

Or are the 'localhost' and remote repos treated differently by Maven. Or are there some other matter I am missing.

I, unfortunately could not unearth much documentation on the above; any help would be appreciated.

答:
The first thing is: I am declaring a repository in the pom.xml as follows:
If you use a repository manager always define the repositories via the settings.xml like this:

```<code>  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:8081/nexus/content/groups/public</url>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <id>nexus</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <repositories>
        <repository>
          <id>central</id>
          <url>https://central</url>
          <releases>
            <enabled>true</enabled>
            <checksumPolicy>fail</checksumPolicy>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <checksumPolicy>fail</checksumPolicy>
          </snapshots>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>https://central</url>
          <releases>
            <enabled>true</enabled>
            <checksumPolicy>fail</checksumPolicy>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <checksumPolicy>fail</checksumPolicy>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
</code>```

Remove all repository entries from your pom files...

Body:
I am facing a strange phenomena related to Maven repository resolution (Maven version: 3.8.4) which I am unable to explain. The matter is as follows:

We have a internal Nexus proxy setup for Central Repository. The URL is http://[companyDomain]:8081/repository/maven-central

I am declaring a repository in the pom.xml as follows:

     <repository>
        <id>nexus-maven-central</id>
        <name>Maven Central Repository Internal Proxy</name>
        <url>http://[companyDomain]:8081/repository/maven-central</url>
        <layout>default</layout>
        <snapshots><enabled>true</enabled></snapshots>
        <releases><enabled>true</enabled></releases>
    </repository>

The effective pom is showing the above repository as the first in the list of repositories and default Maven Central repository (id:central) after that as it should be.

However, when I build the pom, Maven is directly going to the Maven Central repository, not considering the above repository.

Now, when I start a Nexus instance in my local host and change the above URL to:

http://localhost:8081/repository/maven-central

Maven resolves the repository and downloads from the localhost.

Further, when I use the http://[companyDomain]:8081/repository/maven-central again in the pom and this time configure a mirror in the global setting.xml (I am not using user specific settings)

<mirror>
  <id>nexus-maven-central-mirror</id>
  <name>Mirror for Maven Central Repository</name>
  <url>http://[companyDomain]:8081/repository/maven-central</url>
  <mirrorOf>central</mirrorOf>
</mirror>

Maven perfectly resolves the internal proxy repository and downloads artifacts.

As for the environment, I am connecting to the corporate network through a VPN. IP of the internal Nexus server is resolvable when I am connected to the VPN; there are no VPN outages when I am trying the above.

I was expecting Maven to at least try the internal proxy repo when configured with the 'downloading from ...' message, nothing of that nature shows up in the console. It goes directly to Central Repository.

I further tested with the following URLs:

http://repo1.maven.org/maven2/ ---> Does Not Work

https://repo1.maven.org/maven2/ ---> Works

While I am aware that Maven does not prefer to download from 'http' and Maven Central explicitly states that it will send error if accessed over http, then the question is why is it downloading from localhost on http and not remote; does Maven have this behaviour of ignoring remote http.

Or are the 'localhost' and remote repos treated differently by Maven. Or are there some other matter I am missing.

I, unfortunately could not unearth much documentation on the above; any help would be appreciated.

Body:
The first thing is: I am declaring a repository in the pom.xml as follows:
If you use a repository manager always define the repositories via the settings.xml like this:

  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:8081/nexus/content/groups/public</url>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <id>nexus</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <repositories>
        <repository>
          <id>central</id>
          <url>https://central</url>
          <releases>
            <enabled>true</enabled>
            <checksumPolicy>fail</checksumPolicy>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <checksumPolicy>fail</checksumPolicy>
          </snapshots>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>https://central</url>
          <releases>
            <enabled>true</enabled>
            <checksumPolicy>fail</checksumPolicy>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <checksumPolicy>fail</checksumPolicy>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
  </activeProfiles>

Remove all repository entries from your pom files...


问:
Powershell - capture all non-blank lines between key words
I have a script that was put together with the community help and it works great.  I'm trying to alter it to work for my new requirements.
I have data (See below) that needs to be captured from 10K+ files.
Inside each file could be multiple iterations of the data I need to capture.  The script I'm using captured only the file name and not the data I need.  Can someone see where I'm off (Code wise) and offer another option.

Here is my Raw Data.  There could be four or five places in a text member with this data and I need to capture it all.
The words in Bold (Select and From) are the words I'm keying on.  I need to capture those lines as well as all the lines between them.

```<code>    SELECT   FIL_ID_NUM,                                             00481002
             LAU_CRE_DTS,                                            00482002
             LAU_CD,                                                 00483002
             LAU_EFF_DT,                                             00484002
             LAU_EFF_TIM,                                            00485002
             LAU_EXP_DT,                                             00486002
             LAU_EXP_TIM,                                            00487002
             LAU_SERV_REAS1_CD,                                      00488002
             LAU_SERV_REAS2_CD,                                      00489002
             LAU_SERV_REAS3_CD,                                      00489102
             LAU_CARE_IND,                                           00489202
             SEG_UPDT_LOCK_NUM,                                      00489302
             LAU_AGRMT_PER_NAM,                                      00489402
             LAU_AGRMT_DSGT_NAM,                                     00489502
             LAU_AGRMT_DIR_TXT,                                      00489602
             LAU_TERMS_TXT                                           00489702
                                                                     00520002
        FROM TLEGAL
</code>```

Here is my script....

```<code># create a List object to collect the 'flowerbox' strings in
$Flowerbox = [System.Collections.Generic.List[string]]::new()
$treat = $false

# get a list of the .pl1m files and loop through. Collect all output in variable $result
$CBLFileList = Get-ChildItem -Path 'C:\src' -Filter '*.pl1m' -File -Recurse
$result = foreach ($CBLFile in $CBLFileList) {
    Write-Host "Processing ... $($CBLFile.Name)" -ForegroundColor Green

    $Flowerbox.Clear()  # empty the list for the next run
    $treat = $false
    switch -Regex -File $CBLFile.FullName {
        'SELECT' {
        Write-Host "Found Select" -ForegroundColor DarkYellow
            # start collecting lines from here
            $treat = $true
        }
        'FROM ' {
        Write-Host "Found From" -ForegroundColor DarkRed
           if ($treat) {

            # stop colecting Flowerbox lines and output what we already have
            # output an object with the two properties you need
            [PsCustomObject]@{
                Program     = $CBLFile.Name  # or $CBLFile.FullName
                Description = $Flowerbox -join [environment]::NewLine
            }
            }
            $Flowerbox.Clear()  # empty the list for the next run
            $treat = $false
        }
        default {
                # Add captures data here
                if ($treat -and ($_ -match '/[^\s\\]/')) {
                $Flowerbox.Add($Matches[1])
            }
        }
    }
}

# now you have everything in an array of PSObjects so you can save that as Csv
$result | Export-Csv -Path 'C:\src\SQL_Desc.csv' -UseCulture -NoTypeInformation
</code>```

答:
You could try using this function to find all those files that contain those fragments starting on SELECT and ending on FROM, the function would output objects with the captured fragment (Value), Index, Path and Length. The regex is likely to be improved, but this worked for me with some test files.

NOTE: this answer requires that the files fit in memory, as the functions reads the files as a whole string.

```<code>using namespace System.IO

function Find-String {
param(
    [parameter(ValueFromPipeline, Mandatory)]
    [Alias('PSPath')]
    [FileInfo]$Path,
    [parameter(Mandatory, Position = 0)]
    [regex]$Pattern,
    [switch]$AllMatches
)

    process {
        $content = [File]::ReadAllText($Path)
        $match = if($AllMatches.IsPresent) {
            $Pattern.Matches($content)
        }
        else {
            $Pattern.Match($content)
        }

        if($match.Success -notcontains $true) {
            return
        }

        foreach($m in $match) {
            [pscustomobject]@{
                Path   = $path.FullName
                Value  = $m.Value
                Index  = $m.Index
                Length = $m.Length
            }
        }
    }
}

Get-ChildItem -Path 'C:\src' -Filter '*.pl1m' -Recurse |
    Find-String -Pattern '(?msi)SELECT.*?FROM.*?$' -AllMatches |
    Export-Csv path\to\export.csv -NoTypeInformation
</code>```

Output with one particular file looks like this:

```<code>Path   : /home/user/Documents/test.txt
Value  : SELECT  FIL_ID_NUM,             00481002
         ...
         ...
         ...
         FROM SOMETABLE
Index  : 11
Length : 449

Path   : /home/user/Documents/test.txt
Value  : SELECT  FIL_ID_NUM,             00481002
         ...
         ...
         ...
         FROM SOMEOTHERTABLE
Index  : 501
Length : 522
</code>```

Body:
I have a script that was put together with the community help and it works great.  I'm trying to alter it to work for my new requirements.
I have data (See below) that needs to be captured from 10K+ files.
Inside each file could be multiple iterations of the data I need to capture.  The script I'm using captured only the file name and not the data I need.  Can someone see where I'm off (Code wise) and offer another option.

Here is my Raw Data.  There could be four or five places in a text member with this data and I need to capture it all.
The words in Bold (Select and From) are the words I'm keying on.  I need to capture those lines as well as all the lines between them.

    SELECT   FIL_ID_NUM,                                             00481002
             LAU_CRE_DTS,                                            00482002
             LAU_CD,                                                 00483002
             LAU_EFF_DT,                                             00484002
             LAU_EFF_TIM,                                            00485002
             LAU_EXP_DT,                                             00486002
             LAU_EXP_TIM,                                            00487002
             LAU_SERV_REAS1_CD,                                      00488002
             LAU_SERV_REAS2_CD,                                      00489002
             LAU_SERV_REAS3_CD,                                      00489102
             LAU_CARE_IND,                                           00489202
             SEG_UPDT_LOCK_NUM,                                      00489302
             LAU_AGRMT_PER_NAM,                                      00489402
             LAU_AGRMT_DSGT_NAM,                                     00489502
             LAU_AGRMT_DIR_TXT,                                      00489602
             LAU_TERMS_TXT                                           00489702
                                                                     00520002
        FROM TLEGAL

Here is my script....

# create a List object to collect the 'flowerbox' strings in
$Flowerbox = [System.Collections.Generic.List[string]]::new()
$treat = $false

# get a list of the .pl1m files and loop through. Collect all output in variable $result
$CBLFileList = Get-ChildItem -Path 'C:\src' -Filter '*.pl1m' -File -Recurse
$result = foreach ($CBLFile in $CBLFileList) {
    Write-Host "Processing ... $($CBLFile.Name)" -ForegroundColor Green

    $Flowerbox.Clear()  # empty the list for the next run
    $treat = $false
    switch -Regex -File $CBLFile.FullName {
        'SELECT' {
        Write-Host "Found Select" -ForegroundColor DarkYellow
            # start collecting lines from here
            $treat = $true
        }
        'FROM ' {
        Write-Host "Found From" -ForegroundColor DarkRed
           if ($treat) {

            # stop colecting Flowerbox lines and output what we already have
            # output an object with the two properties you need
            [PsCustomObject]@{
                Program     = $CBLFile.Name  # or $CBLFile.FullName
                Description = $Flowerbox -join [environment]::NewLine
            }
            }
            $Flowerbox.Clear()  # empty the list for the next run
            $treat = $false
        }
        default {
                # Add captures data here
                if ($treat -and ($_ -match '/[^\s\\]/')) {
                $Flowerbox.Add($Matches[1])
            }
        }
    }
}

# now you have everything in an array of PSObjects so you can save that as Csv
$result | Export-Csv -Path 'C:\src\SQL_Desc.csv' -UseCulture -NoTypeInformation

Body:
You could try using this function to find all those files that contain those fragments starting on SELECT and ending on FROM, the function would output objects with the captured fragment (Value), Index, Path and Length. The regex is likely to be improved, but this worked for me with some test files.

NOTE: this answer requires that the files fit in memory, as the functions reads the files as a whole string.

using namespace System.IO

function Find-String {
param(
    [parameter(ValueFromPipeline, Mandatory)]
    [Alias('PSPath')]
    [FileInfo]$Path,
    [parameter(Mandatory, Position = 0)]
    [regex]$Pattern,
    [switch]$AllMatches
)

    process {
        $content = [File]::ReadAllText($Path)
        $match = if($AllMatches.IsPresent) {
            $Pattern.Matches($content)
        }
        else {
            $Pattern.Match($content)
        }

        if($match.Success -notcontains $true) {
            return
        }

        foreach($m in $match) {
            [pscustomobject]@{
                Path   = $path.FullName
                Value  = $m.Value
                Index  = $m.Index
                Length = $m.Length
            }
        }
    }
}

Get-ChildItem -Path 'C:\src' -Filter '*.pl1m' -Recurse |
    Find-String -Pattern '(?msi)SELECT.*?FROM.*?$' -AllMatches |
    Export-Csv path\to\export.csv -NoTypeInformation

Output with one particular file looks like this:

Path   : /home/user/Documents/test.txt
Value  : SELECT  FIL_ID_NUM,             00481002
         ...
         ...
         ...
         FROM SOMETABLE
Index  : 11
Length : 449

Path   : /home/user/Documents/test.txt
Value  : SELECT  FIL_ID_NUM,             00481002
         ...
         ...
         ...
         FROM SOMEOTHERTABLE
Index  : 501
Length : 522