问:
How to make a copy of a database in SQL Server
I can't seem to find any SQL that will clone one database in SQL Server within the same server.

Let's say I have a database called MyDB. I simply want to make a copy of MyDB to MyDb2. I thought that this would work:

```<code>BACKUP DATABASE MyDB TO MyDB2;
</code>```

But I get this error when I try to execute it:

Backup device 'DbTestBack' does not exist. To view existing backup devices, use the sys.backup_devices catalog view. To create a new backup device use either sp_addumpdevice or SQL Server Management Studio.

Does anyone know what the best way to do this is? I want an exact duplicate of the original including security permissions.

答:
DBAtools is your friend here.

Use Copy-DbaDatabase

ie.

```<code>Copy-DbaDatabase -Source SRV1 -Destination SRV1 -Database myDB -BackupRestore -SharedPath \\<<your temporary server location such as c:\temp>>
</code>```

Body:
I can't seem to find any SQL that will clone one database in SQL Server within the same server.

Let's say I have a database called MyDB. I simply want to make a copy of MyDB to MyDb2. I thought that this would work:

BACKUP DATABASE MyDB TO MyDB2;

But I get this error when I try to execute it:

Backup device 'DbTestBack' does not exist. To view existing backup devices, use the sys.backup_devices catalog view. To create a new backup device use either sp_addumpdevice or SQL Server Management Studio.

Does anyone know what the best way to do this is? I want an exact duplicate of the original including security permissions.

Body:
DBAtools is your friend here.

Use Copy-DbaDatabase

ie.

Copy-DbaDatabase -Source SRV1 -Destination SRV1 -Database myDB -BackupRestore -SharedPath \\<<your temporary server location such as c:\temp>>


来源: stackexchange

问:
Falling factorial JAVA
So basically I need to write a method that calculates a falling factorial. "The falling power 10 5 would equal 10 * 9 * 8 * 7 * 6 = 30240"

so here is my 1st try:

```<code>public static long fallingPower(int n, int k) {
    long holder = n;
    int counter;

    if (n > 0) {
        counter = 1;
        for (int i = k - 1; i > 0; i--) {
            holder = holder * (n - counter);
            counter++;
        }
    }

    if (n < 0) {
        counter = -1;
        for (int i = k - 1; i > 0; i--) {
            holder = holder * (n + counter);
            counter--;
            //System.out.println(holder);
        }
    }

    return holder;
}
</code>```

It works with tests like (10, 5) (-4, 5) and (8, 3) given in the problem context but it fails the actual test.

After a long session of wolfram alfa readings and a bit of googling this passes the test:

```<code>public static long fallingPower(int n, int k) {

    long count, holder;

    holder = 1;

    for (count = 0; count <= k - 1; count = count + 1) {
        holder = holder * (n - count);
    }

    return holder;
}
</code>```

My question is, what exactly did I do wrong in the first case that led to the correct sample test but would result in incorrect output given larger input.

Thank you very much.

答: One thing that immediately caught my attention was that your code doesn't really handle the case where n is 0. Basically both of your if statements are skipped, so you return 0. However this seems wrong to me, since 0! = 1. Notice in the code you found online, this is accounted for. So with your code fallingFactorial(0, 1) is 0, and with the online code fallingFactorial(0, 1) is 1.

ContentLicense: CC BY-SA 4.0

Title: Falling factorial JAVA

Body:
So basically I need to write a method that calculates a falling factorial. "The falling power 10 5 would equal 10 * 9 * 8 * 7 * 6 = 30240"

so here is my 1st try:

public static long fallingPower(int n, int k) {
    long holder = n;
    int counter;

    if (n > 0) {
        counter = 1;
        for (int i = k - 1; i > 0; i--) {
            holder = holder * (n - counter);
            counter++;
        }
    }

    if (n < 0) {
        counter = -1;
        for (int i = k - 1; i > 0; i--) {
            holder = holder * (n + counter);
            counter--;
            //System.out.println(holder);
        }
    }

    return holder;
}

It works with tests like (10, 5) (-4, 5) and (8, 3) given in the problem context but it fails the actual test.

After a long session of wolfram alfa readings and a bit of googling this passes the test:

public static long fallingPower(int n, int k) {

    long count, holder;

    holder = 1;

    for (count = 0; count <= k - 1; count = count + 1) {
        holder = holder * (n - count);
    }

    return holder;
}

My question is, what exactly did I do wrong in the first case that led to the correct sample test but would result in incorrect output given larger input.

Thank you very much.


问:
why 'Generating DAG in progress' and 'Looking for peers' keep showing forever when I try to use geth to build up a private chain on my local computer?
I just try to learn etherum, geth and so forth. Now i am doing:

```<code>feng@DESKTOP-PNE7LPV:~/myChain$ ../go-ethereum/build/bin/geth --datadir . --networkid 312 console
</code>```

I use this way to start a private chain and open the console. It all looks fine. But there is a problem:

This kind of information keeps jumping forever. Could anyone tell me why this happens and how to avoid this?

答: I have got it. build up a log file then all the updates will only show there.</p>

Body:
I just try to learn etherum, geth and so forth. Now i am doing:

feng@DESKTOP-PNE7LPV:~/myChain$ ../go-ethereum/build/bin/geth --datadir . --networkid 312 console

I use this way to start a private chain and open the console. It all looks fine. But there is a problem:

This kind of information keeps jumping forever. Could anyone tell me why this happens and how to avoid this?


问:
Conditional Preprocessor macro expansion in C
I have a macro, SOME_MACRO. It takes an argument.

Definition of SOME_MACRO:

#define SOME_MACRO(arg)  __SOME_MACRO(arg)

Further I want __SOME_MACRO(arg) to expand to "ABC" if arg is 0. And if arg is not zero, __SOME_MACRO(arg) should expand to "DEF"

Suppose I call with argument 0, that is: SOME_MACRO(0)
I need to test at preprocessing time, whether the argument is zero or not.

```<code>#if <argument is zero>     // line 1
#define __SOME_MACRO(arg) "ABC"
#elif
#define __SOME_MACRO(arg) "DEF"
#endif
</code>```

My question is: What should be at line 1?

Taking an example:

SOME_MACRO(2) should expand to "DEF"

SOME_MACRO(0) should expand to "ABC"

答:
Here is a solution for the requested behavior. Do not use it, it is bad practice, and you should not be attempting this.</p>

```<code>/*  Define __SOME_MACRO:

        Defer is used so that its arguments will be macro-replaced before
        Kludge is processed.

        "Kludge" is pasted to arg.  If this makes "Kludge0", it will be
        replaced by two arguments (an empty argument, a comma, and the argument
        "abc").  Otherwise, if it forms a single token, that is one argument.
        (If the pasting does not form a proper token, the behavior is
        undefined.  Most likely, the compiler will report an error.)

        The resulting argument(s) are then passed to Kludge, followed by "DEF".

        Kludge is replaced by its second argument.  If __SOME_MACRO's argument
        was "0", this second argument is "ABC".  Otherwise, it is "DEF".
*/
#define Kludge0             , "ABC"
#define Kludge(x, y,...)    y
#define Defer(x, ...)       Kludge(x, __VA_ARGS__)
#define __SOME_MACRO(arg)   Defer(Kludge##arg, "DEF",)

__SOME_MACRO(0)
__SOME_MACRO(2)
</code>```

Body:
I have a macro, SOME_MACRO. It takes an argument.

Definition of SOME_MACRO:

#define SOME_MACRO(arg)  __SOME_MACRO(arg)

Further I want __SOME_MACRO(arg) to expand to "ABC" if arg is 0. And if arg is not zero, __SOME_MACRO(arg) should expand to "DEF"

Suppose I call with argument 0, that is: SOME_MACRO(0)
I need to test at preprocessing time, whether the argument is zero or not.

#if <argument is zero>     // line 1
#define __SOME_MACRO(arg) "ABC"
#elif
#define __SOME_MACRO(arg) "DEF"
#endif

My question is: What should be at line 1?

Taking an example:

SOME_MACRO(2) should expand to "DEF"

SOME_MACRO(0) should expand to "ABC"

Body:
Here is a solution for the requested behavior. Do not use it, it is bad practice, and you should not be attempting this.

/*  Define __SOME_MACRO:

        Defer is used so that its arguments will be macro-replaced before
        Kludge is processed.

        "Kludge" is pasted to arg.  If this makes "Kludge0", it will be
        replaced by two arguments (an empty argument, a comma, and the argument
        "abc").  Otherwise, if it forms a single token, that is one argument.
        (If the pasting does not form a proper token, the behavior is
        undefined.  Most likely, the compiler will report an error.)

        The resulting argument(s) are then passed to Kludge, followed by "DEF".

        Kludge is replaced by its second argument.  If __SOME_MACRO's argument
        was "0", this second argument is "ABC".  Otherwise, it is "DEF".
*/
#define Kludge0             , "ABC"
#define Kludge(x, y,...)    y
#define Defer(x, ...)       Kludge(x, __VA_ARGS__)
#define __SOME_MACRO(arg)   Defer(Kludge##arg, "DEF",)

__SOME_MACRO(0)
__SOME_MACRO(2)


问:
JavaScript - Time Logout, click reset Time Logout
I have a code that gives the time of 20min and then disconnects the user. It's working normal. However, I need that if the user is working on the page, the team returns to the initial value, as I use a lot of ajax and the page ends up not updating as it should to return to the initial one.

HTML

```<code><h2 id="theTime" style="font-weight: bold;font-size: 16px; color:#FFF;">20:00 </h2>
</code>```

JavaScript

```<code>$("#index-body").click(function() {
    var newTime = "s";
    sivamtime(newTime);
});
</code>```

JavaScript - timeLogout

```<code>min=20;
sec=0;
var now = new Date();
var expire_time = new Date(now.getTime() + (min * 60000));
var timer_ticket = null;

function sivamtime(newTime) {
    var progressive_time = new Date();
    if((expire_time - progressive_time) < 1 || (min == 0 && sec == 0)){
        //$(document).ready(function() {
        $('#myModal').modal('show');
        $("#modal-body-info").html('<b>Por segurança</b>,<br> Tempo esgotado, não utilizou o site no prazo de 20 minutos');
        $('.logout').click(function() {
          window.location='login.php';
        });
        //});
    } else{
        min = "20";
        sec = "00";
        var countdown = (expire_time - progressive_time) / 1000;
        min = Math.ceil(countdown / 60) - 1;
        sec = Math.ceil(countdown % 60) - 1;
        if (min<=9 ) { min="0"+min; }
        if (min==0) {min="00";}
        if (sec<=9) { sec="0"+sec; }

        time = min + ":" + sec + " " ;

        if (document.getElementById) { document.getElementById('theTime').innerHTML = time; }
        else if (document.layers) {
            document.layers.theTime.document.write(time);
            document.layers.theTime.document.close();
        }
            timer_ticket = setTimeout("sivamtime()", 1000);
        }
    }

    $(document).ready(function() {
        sivamtime();
});
</code>```

答:
I did it that way and it's not zeroing.
Although the console log is showing "Hello"</p>

```<code>min=20;
sec=0;
var now = new Date();
var expireTime = new Date(now.getTime() + (min * 60000));
var timerTicket = null;

function logoutTimer(newTimer) {
    var progressiveTime = new Date();
    if((expireTime - progressiveTime) < 1 || (min == 0 && sec == 0)){
        //$(document).ready(function() {
        $('#myModal').modal('show');
        $("#modal-body-info").html('<b>Por segurança</b>,<br> Tempo esgotado, não utilizou o site no prazo de 20 minutos');
        $('.logout').click(function() {
          window.location='login.php';
        });
        //});
    } else{
        min = "20";
        sec = "00";
        var countdown = (expireTime - progressiveTime) / 1000;
        min = Math.ceil(countdown / 60) - 1;
        sec = Math.ceil(countdown % 60) - 1;
        if (min<=9 ) { min="0"+min; }
        if (min==0) { min="00"; }
        if (sec<=9) { sec="0"+sec; }

        time = min + ":" + sec + " " ;

        document.getElementById('theTimer').innerHTML = time;

        timerTicket = setTimeout("logoutTimer()", 1000);

        if(newTimer){ clearTimeout(timerTicket); console.log("Ola"); }

    }
}
$(document).ready(function() {

    $("#index-body").click(function(){
        var newTimer = true;
        logoutTimer(newTimer);
    });
    logoutTimer();
});
</code>```

Body:
I have a code that gives the time of 20min and then disconnects the user. It's working normal. However, I need that if the user is working on the page, the team returns to the initial value, as I use a lot of ajax and the page ends up not updating as it should to return to the initial one.

HTML

20:00

JavaScript

$("#index-body").click(function() {
    var newTime = "s";
    sivamtime(newTime);
});

JavaScript - timeLogout

min=20;
sec=0;
var now = new Date();
var expire_time = new Date(now.getTime() + (min * 60000));
var timer_ticket = null;

function sivamtime(newTime) {
    var progressive_time = new Date();
    if((expire_time - progressive_time) < 1 || (min == 0 && sec == 0)){
        //$(document).ready(function() {
        $('#myModal').modal('show');
        $("#modal-body-info").html('Por segurança,
 Tempo esgotado, não utilizou o site no prazo de 20 minutos');
        $('.logout').click(function() {
          window.location='login.php';
        });
        //});
    } else{
        min = "20";
        sec = "00";
        var countdown = (expire_time - progressive_time) / 1000;
        min = Math.ceil(countdown / 60) - 1;
        sec = Math.ceil(countdown % 60) - 1;
        if (min<=9 ) { min="0"+min; }
        if (min==0) {min="00";}
        if (sec<=9) { sec="0"+sec; }

        time = min + ":" + sec + " " ;

        if (document.getElementById) { document.getElementById('theTime').innerHTML = time; }
        else if (document.layers) {
            document.layers.theTime.document.write(time);
            document.layers.theTime.document.close();
        }
            timer_ticket = setTimeout("sivamtime()", 1000);
        }
    }

    $(document).ready(function() {
        sivamtime();
});

Body:
I did it that way and it's not zeroing.
Although the console log is showing "Hello"

min=20;
sec=0;
var now = new Date();
var expireTime = new Date(now.getTime() + (min * 60000));
var timerTicket = null;

function logoutTimer(newTimer) {
    var progressiveTime = new Date();
    if((expireTime - progressiveTime) < 1 || (min == 0 && sec == 0)){
        //$(document).ready(function() {
        $('#myModal').modal('show');
        $("#modal-body-info").html('<b>Por segurança</b>,<br> Tempo esgotado, não utilizou o site no prazo de 20 minutos');
        $('.logout').click(function() {
          window.location='login.php';
        });
        //});
    } else{
        min = "20";
        sec = "00";
        var countdown = (expireTime - progressiveTime) / 1000;
        min = Math.ceil(countdown / 60) - 1;
        sec = Math.ceil(countdown % 60) - 1;
        if (min<=9 ) { min="0"+min; }
        if (min==0) { min="00"; }
        if (sec<=9) { sec="0"+sec; }

        time = min + ":" + sec + " " ;

        document.getElementById('theTimer').innerHTML = time;

        timerTicket = setTimeout("logoutTimer()", 1000);

        if(newTimer){ clearTimeout(timerTicket); console.log("Ola"); }

    }
}
$(document).ready(function() {

    $("#index-body").click(function(){
        var newTimer = true;
        logoutTimer(newTimer);
    });
    logoutTimer();
});


问:
Encription with chances
I am new to Python so help. I want it to minus the chance if the password is wrong. Its stuck on 2 if I enter a wrong password</p>

```<code>while True:
    password = input("Password for activation ")
    chance = 3

    if password == "LUN":
            print("access granted")
            break

    if password != "LUN":
        wrong = chance - 1
        print("Try again. your chance is {0}".format(wrong))

    if chance == 0:
        break
</code>```

答:
You set chance = 3 the loop. This resets chance at each iteration, regardless of what else you may do.

Then, if the user guesses wrong, you set wrong = chance - 1. This does not change chance at all.

The simplest fix would be to move the initialization outside the loop, and update the correct variable:

```<code>chance = 3
while True:
    password = input("Password for activation ")

    if password == "LUN":
        print("access granted")
        break

    chance -= 1
    print("Try again. your chance is {0}".format(chance))

    if chance == 0:
        break
</code>```

I also took the liberty of removing the unnecessary if statement.

This may be a good time to learn about for loops. These loops let you iterate through a collection, like a range of fixed size. They have another special feature, which is that they support an else clause that triggers whenever the loop completes normally, without a break:

```<code>for chance in range(3, -1, -1):
    password = input("Password for activation ")

    if password == "LUN":
        print("Access Granted")
        break
    print(f"Try again. You have {chance} chances left")
else:
    print("You Failed")
</code>```

Title: Encription with chances

Body:
I am new to Python so help. I want it to minus the chance if the password is wrong. Its stuck on 2 if I enter a wrong password

while True:
    password = input("Password for activation ")
    chance = 3

    if password == "LUN":
            print("access granted")
            break

    if password != "LUN":
        wrong = chance - 1
        print("Try again. your chance is {0}".format(wrong))

    if chance == 0:
        break

Body:
You set chance = 3 the loop. This resets chance at each iteration, regardless of what else you may do.

Then, if the user guesses wrong, you set wrong = chance - 1. This does not change chance at all.

The simplest fix would be to move the initialization outside the loop, and update the correct variable:

chance = 3
while True:
    password = input("Password for activation ")

    if password == "LUN":
        print("access granted")
        break

    chance -= 1
    print("Try again. your chance is {0}".format(chance))

    if chance == 0:
        break

I also took the liberty of removing the unnecessary if statement.

This may be a good time to learn about for loops. These loops let you iterate through a collection, like a range of fixed size. They have another special feature, which is that they support an else clause that triggers whenever the loop completes normally, without a break:

for chance in range(3, -1, -1):
    password = input("Password for activation ")

    if password == "LUN":
        print("Access Granted")
        break
    print(f"Try again. You have {chance} chances left")
else:
    print("You Failed")


问:
insert html tag in join method at angular 2+ not working
Is there any reason this is not working?

The
 or any html tags is not interpreted.

in HTML:

```<code>{{data.prContent.join(' <br> ')}}
</code>```

in Json file:

```<code> "prContent": [
              "Banana",
              "Orange",
              "Apple",
              "Mango"
            ],
</code>```

How can I work around this?

答:
If the parent element contains only that interpolation, you can set the content with [innerHTML]:

```<code><div [innerHTML]="data.prContent.join('<br/>')"></div>
</code>```

Otherwise, you can combine the array items with multiple interpolations, using an *ngFor loop:

```<code><ng-container *ngFor="let item of data.prContent; let isLast = last">
  {{item}} <br *ngIf="!isLast" />
</ng-container>
</code>```

See this stackblitz for a demo.

Body:
Is there any reason this is not working?

The
 or any html tags is not interpreted.

in HTML:

{{data.prContent.join('
 ')}}

in Json file:

 "prContent": [
              "Banana",
              "Orange",
              "Apple",
              "Mango"
            ],

How can I work around this?

Body:
If the parent element contains only that interpolation, you can set the content with [innerHTML]:

<div [innerHTML]="data.prContent.join('<br/>')"></div>

Otherwise, you can combine the array items with multiple interpolations, using an *ngFor loop:

<ng-container *ngFor="let item of data.prContent; let isLast = last">
  {{item}} <br *ngIf="!isLast" />
</ng-container>

See this stackblitz for a demo.


问:
How do I center properly in AbsoluteLayout?
I have element a and element b and I want b to overlap a. While I accomplished this with an AbsoluteLayout, it seems like element b isnt properly centered anymore.

Here is a screenshot of how it looks:

The orange image above is centered out of the AbsoluteLayout as a reference, the label in the background is element a and the red box is element b.

```<code><StackLayout Orientation="Vertical">
        <StackLayout  HeightRequest="150"  Orientation="Horizontal" HorizontalOptions="Center">
            <Image x:Name="logo" Aspect="AspectFit"  HorizontalOptions="FillAndExpand"  Source="percentageLOGOsmall2.png"></Image>
        </StackLayout>
        <AbsoluteLayout HorizontalOptions="Center">

            <Label x:Name="l_trinkeinladung" Text="Lorem ipsum test text" WidthRequest="300" FontSize="Title"
             AbsoluteLayout.LayoutBounds="0,0.5,-1,-1"
             AbsoluteLayout.LayoutFlags="PositionProportional"
             HorizontalOptions="Center"
             TextColor="White"
             HorizontalTextAlignment="Center"
                   />
             <ListView HorizontalOptions="Center" ItemsSource="{Binding players}" HeightRequest="270" WidthRequest="200" x:Name="listview1" RowHeight="50" BackgroundColor="Red">
                <ListView.ItemTemplate >
                    <DataTemplate>
                        <ViewCell >
                       /*Stack for properites*/
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </AbsoluteLayout>
    </StackLayout>
</code>```

Why is the red listview not centered?

答:
According to your code, you add ListView in AbsoluteLayout, if you want to set ListView as center in AbsoluteLayout, you can use  AbsoluteLayout.LayoutBounds and AbsoluteLayout.LayoutFlags to set ListView position.

Please take a look the following code:

```<code><StackLayout Orientation="Vertical">
        <StackLayout
            HeightRequest="150"
            HorizontalOptions="Center"
            Orientation="Horizontal">
            <Image
                x:Name="logo"
                Aspect="AspectFit"
                HorizontalOptions="FillAndExpand"
                Source="a11.jpg" />
        </StackLayout>
        <AbsoluteLayout HorizontalOptions="Center">

            <Label
                x:Name="l_trinkeinladung"
                AbsoluteLayout.LayoutBounds="0,0.5,-1,-1"
                AbsoluteLayout.LayoutFlags="PositionProportional"
                FontSize="Title"
                Text="Lorem ipsum test text, this is test aaaaaaaaaaaaa"
                TextColor="Black"
                WidthRequest="300" />
            <ListView
                x:Name="listview1"
                AbsoluteLayout.LayoutBounds=".5,.5,200,270"
                AbsoluteLayout.LayoutFlags="PositionProportional"
                BackgroundColor="Red"
                HorizontalOptions="Center"
                ItemsSource="{Binding players}"
                RowHeight="50">

                <!--<ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            /*Stack for properites*/
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>-->

            </ListView>
        </AbsoluteLayout>
    </StackLayout>
</code>```

The Screenshot like this:

AbsoluteLayoutFlags specifies how values will be interpreted and has the
following predefined options:

None – interprets all values as absolute. This is the default value if no layout flags are specified.

All – interprets all values as proportional.

WidthProportional – interprets the Width value as proportional and all other values as absolute.

HeightProportional – interprets only the height value as proportional with all other values absolute.

XProportional – interprets the X value as proportional, while treating all other values as absolute.

YProportional – interprets the Y value as proportional, while treating all other values as absolute.

PositionProportional – interprets the X and Y values as proportional, while the size values are interpreted as absolute.

SizeProportional – interprets the Width and Height values as proportional while the position values are absolute.

About using Xamarin.Forms AbsoluteLayout, please take a look the detailed info:

https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/layouts/absolute-layout

Body:
I have element a and element b and I want b to overlap a. While I accomplished this with an AbsoluteLayout, it seems like element b isnt properly centered anymore.

Here is a screenshot of how it looks:

The orange image above is centered out of the AbsoluteLayout as a reference, the label in the background is element a and the red box is element b.

<StackLayout Orientation="Vertical">
        <StackLayout  HeightRequest="150"  Orientation="Horizontal" HorizontalOptions="Center">
            <Image x:Name="logo" Aspect="AspectFit"  HorizontalOptions="FillAndExpand"  Source="percentageLOGOsmall2.png"></Image>
        </StackLayout>
        <AbsoluteLayout HorizontalOptions="Center">

             <ListView HorizontalOptions="Center" ItemsSource="{Binding players}" HeightRequest="270" WidthRequest="200" x:Name="listview1" RowHeight="50" BackgroundColor="Red">
                <ListView.ItemTemplate >
                    <DataTemplate>
                        <ViewCell >
                       /*Stack for properites*/
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </AbsoluteLayout>
    </StackLayout>

Why is the red listview not centered?

Body:
According to your code, you add ListView in AbsoluteLayout, if you want to set ListView as center in AbsoluteLayout, you can use  AbsoluteLayout.LayoutBounds and AbsoluteLayout.LayoutFlags to set ListView position.

Please take a look the following code:

<StackLayout Orientation="Vertical">
        <StackLayout
            HeightRequest="150"
            HorizontalOptions="Center"
            Orientation="Horizontal">
            <Image
                x:Name="logo"
                Aspect="AspectFit"
                HorizontalOptions="FillAndExpand"
                Source="a11.jpg" />
        </StackLayout>
        <AbsoluteLayout HorizontalOptions="Center">

            <Label
                x:Name="l_trinkeinladung"
                AbsoluteLayout.LayoutBounds="0,0.5,-1,-1"
                AbsoluteLayout.LayoutFlags="PositionProportional"
                FontSize="Title"
                Text="Lorem ipsum test text, this is test aaaaaaaaaaaaa"
                TextColor="Black"
                WidthRequest="300" />
            <ListView
                x:Name="listview1"
                AbsoluteLayout.LayoutBounds=".5,.5,200,270"
                AbsoluteLayout.LayoutFlags="PositionProportional"
                BackgroundColor="Red"
                HorizontalOptions="Center"
                ItemsSource="{Binding players}"
                RowHeight="50">

                <!--<ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            /*Stack for properites*/
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>-->

            </ListView>
        </AbsoluteLayout>
    </StackLayout>

The Screenshot like this:

AbsoluteLayoutFlags specifies how values will be interpreted and has the
following predefined options:

None – interprets all values as absolute. This is the default value if no layout flags are specified.

All – interprets all values as proportional.

WidthProportional – interprets the Width value as proportional and all other values as absolute.

HeightProportional – interprets only the height value as proportional with all other values absolute.

XProportional – interprets the X value as proportional, while treating all other values as absolute.

YProportional – interprets the Y value as proportional, while treating all other values as absolute.

PositionProportional – interprets the X and Y values as proportional, while the size values are interpreted as absolute.

SizeProportional – interprets the Width and Height values as proportional while the position values are absolute.

About using Xamarin.Forms AbsoluteLayout, please take a look the detailed info:

https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/layouts/absolute-layout


问:
Is there a Preview Handler VCL for Windows 7?
This article

http://msdn.microsoft.com/en-gb/library/bb776867.aspx

describes preview handlers in Windows as

Preview handlers are called when an
  item is selected to show a
  lightweight, rich, read-only preview
  of the file's contents in the view's
  reading pane. This is done without
  launching the file's associated
  application.

and ...

A preview handler is a hosted
  application. Hosts include the
  Microsoft Windows Explorer in Windows
  Vista or Microsoft Outlook 2007.

Is there some Delphi VCL code which can be used as a startingpoint for such a handler?

答:
I have made this unit to handle all the preview handler stuff:

```<code>unit PreviewHandler;

{$WARN SYMBOL_PLATFORM OFF}
{.$DEFINE USE_CODESITE}

interface

uses
  Classes, Controls, ComObj;

type
  TPreviewHandler = class abstract
  public
    { Create all controls needed for the preview and connect them to the
      parent given. The parent follows the size, color and font of the preview
      pane. The parent will stay valid until this instance is destroyed, so if
      you make the parent also the owner of the controls you don't need to free
      them in Destroy. }
    constructor Create(AParent: TWinControl); virtual;
    class function GetComClass: TComClass; virtual; abstract;
    class procedure Register(const AClassID: TGUID; const AName, ADescription, AFileExtension: string);
    {$REGION 'Clear Content'}
    /// <summary>Clear Content</summary>
    /// <remarks>This method is called when the preview should be cleared because
    /// either another item was selected or the PreviewHandler will be
    /// closed.</remarks>
    {$ENDREGION}
    procedure Unload; virtual;
  end;

  TStreamPreviewHandler = class abstract(TPreviewHandler)
  public
    {$REGION 'Render the preview from the stream data'}
    /// <summary>Render the preview from the stream data</summary>
    /// <remarks>Here you should render the data from the stream in whatever
    /// fashion you want.</remarks>
    {$ENDREGION}
    procedure DoPreview(Stream: TStream); virtual; abstract;
    class function GetComClass: TComClass; override; final;
  end;

  TFilePreviewHandler = class abstract(TPreviewHandler)
  public
    {$REGION 'Render the preview from the file path'}
    /// <summary>Render the preview from the file path</summary>
    /// <remarks>Here you should render the data from the file path in whatever
    /// fashion you want.</remarks>
    {$ENDREGION}
    procedure DoPreview(const FilePath: String); virtual; abstract;
    class function GetComClass: TComClass; override; final;
  end;

implementation

uses
{$IFDEF USE_CODESITE}
  CodeSiteLogging,
{$ENDIF}
  Windows, ActiveX, ComServ, ShlObj, PropSys, Types, SysUtils, Graphics, ExtCtrls;

type
  TPreviewHandlerClass = class of TPreviewHandler;
  TComPreviewHandler = class(TComObject, IPreviewHandler, IPreviewHandlerVisuals, IObjectWithSite, IOleWindow)
  strict private
    function IPreviewHandler.DoPreview = IPreviewHandler_DoPreview;
    function ContextSensitiveHelp(fEnterMode: LongBool): HRESULT; stdcall;
    function GetSite(const riid: TGUID; out site: IInterface): HRESULT; stdcall;
    function GetWindow(out wnd: HWND): HRESULT; stdcall;
    function IPreviewHandler_DoPreview: HRESULT; stdcall;
    function QueryFocus(var phwnd: HWND): HRESULT; stdcall;
    function SetBackgroundColor(color: Cardinal): HRESULT; stdcall;
    function SetFocus: HRESULT; stdcall;
    function SetFont(const plf: tagLOGFONTW): HRESULT; stdcall;
    function SetRect(var prc: TRect): HRESULT; stdcall;
    function SetSite(const pUnkSite: IInterface): HRESULT; stdcall;
    function SetTextColor(color: Cardinal): HRESULT; stdcall;
    function SetWindow(hwnd: HWND; var prc: TRect): HRESULT; stdcall;
    function TranslateAccelerator(var pmsg: tagMSG): HRESULT; stdcall;
    function Unload: HRESULT; stdcall;
  private
    FBackgroundColor: Cardinal;
    FBounds: TRect;
    FContainer: TWinControl;
    FLogFont: tagLOGFONTW;
    FParentWindow: HWND;
    FPreviewHandler: TPreviewHandler;
    FPreviewHandlerClass: TPreviewHandlerClass;
    FPreviewHandlerFrame: IPreviewHandlerFrame;
    FSite: IInterface;
    FTextColor: Cardinal;
  protected
    procedure CheckContainer;
    procedure CheckPreviewHandler;
    procedure InternalUnload; virtual; abstract;
    procedure InternalDoPreview; virtual; abstract;
    property Container: TWinControl read FContainer;
    property PreviewHandler: TPreviewHandler read FPreviewHandler;
  public
    destructor Destroy; override;
    property PreviewHandlerClass: TPreviewHandlerClass read FPreviewHandlerClass write FPreviewHandlerClass;
  end;

  TComStreamPreviewHandler = class(TComPreviewHandler, IInitializeWithStream)
  strict private
    function IInitializeWithStream.Initialize = IInitializeWithStream_Initialize;
    function IInitializeWithStream_Initialize(const pstream: IStream; grfMode: Cardinal): HRESULT; stdcall;
  private
    FIStream: IStream;
    FMode: Cardinal;
    function GetPreviewHandler: TStreamPreviewHandler;
  protected
    procedure InternalUnload; override;
    procedure InternalDoPreview; override;
    property PreviewHandler: TStreamPreviewHandler read GetPreviewHandler;
  end;

  TComFilePreviewHandler = class(TComPreviewHandler, IInitializeWithFile)
  strict private
    function IInitializeWithFile.Initialize = IInitializeWithFile_Initialize;
    function IInitializeWithFile_Initialize(pszFilePath: LPCWSTR; grfMode: DWORD): HRESULT; stdcall;
  private
    FFilePath: string;
    FMode: DWORD;
    function GetPreviewHandler: TFilePreviewHandler;
  protected
    procedure InternalDoPreview; override;
    procedure InternalUnload; override;
    property PreviewHandler: TFilePreviewHandler read GetPreviewHandler;
  end;

  TComPreviewHandlerFactory = class(TComObjectFactory)
  private
    FFileExtension: string;
    FPreviewHandlerClass: TPreviewHandlerClass;
    class procedure DeleteRegValue(const Key, ValueName: string; RootKey: DWord);
    class function IsRunningOnWOW64: Boolean;
  protected
    property FileExtension: string read FFileExtension;
  public
    constructor Create(APreviewHandlerClass: TPreviewHandlerClass; const AClassID: TGUID; const AName, ADescription, AFileExtension: string);
    function CreateComObject(const Controller: IUnknown): TComObject; override;
    procedure UpdateRegistry(Register: Boolean); override;
    property PreviewHandlerClass: TPreviewHandlerClass read FPreviewHandlerClass;
  end;

  TWinControlHelper = class helper for TWinControl
  public
    procedure SetFocusTabFirst;
    procedure SetFocusTabLast;
    procedure SetBackgroundColor(AColor: Cardinal);
    procedure SetBoundsRect(const ARect: TRect);
    procedure SetTextColor(AColor: Cardinal);
    procedure SetTextFont(const Source: tagLOGFONTW);
  end;

  TIStreamAdapter = class(TStream)
  private
    FTarget: IStream;
  protected
    function GetSize: Int64; override;
    procedure SetSize(NewSize: Longint); override;
    procedure SetSize(const NewSize: Int64); override;
  public
    constructor Create(ATarget: IStream);
    function Read(var Buffer; Count: Longint): Longint; override;
    function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; overload; override;
    function Write(const Buffer; Count: Longint): Longint; override;
    property Target: IStream read FTarget;
  end;

procedure TWinControlHelper.SetFocusTabFirst;
begin
  SelectNext(nil, true, true);
end;

procedure TWinControlHelper.SetFocusTabLast;
begin
  SelectNext(nil, false, true);
end;

procedure TWinControlHelper.SetBackgroundColor(AColor: Cardinal);
begin
  Color := AColor;
end;

procedure TWinControlHelper.SetBoundsRect(const ARect: TRect);
begin
  SetBounds(ARect.Left, ARect.Top, ARect.Right - ARect.Left, ARect.Bottom - ARect.Top);
end;

procedure TWinControlHelper.SetTextColor(AColor: Cardinal);
begin
  Font.Color := AColor;
end;

procedure TWinControlHelper.SetTextFont(const Source: tagLOGFONTW);
var
  fontStyle: TFontStyles;
begin
  Font.Height := Source.lfHeight;
  fontStyle := Font.Style;
  if Source.lfWeight >= FW_BOLD then
    Include(fontStyle, fsBold);
  if Source.lfItalic = 1 then
    Include(fontStyle, fsItalic);
  if Source.lfUnderline = 1 then
    Include(fontStyle, fsUnderline);
  if Source.lfStrikeOut = 1 then
    Include(fontStyle, fsStrikeOut);
  Font.Style := fontStyle;
  Font.Charset := TFontCharset(Source.lfCharSet);
  Font.Name := Source.lfFaceName;
  case Source.lfPitchAndFamily and $F of
    VARIABLE_PITCH: Font.Pitch := fpVariable;
    FIXED_PITCH: Font.Pitch := fpFixed;
  else
    Font.Pitch := fpDefault;
  end;
  Font.Orientation := Source.lfOrientation;
end;

constructor TComPreviewHandlerFactory.Create(APreviewHandlerClass: TPreviewHandlerClass; const AClassID: TGUID; const
    AName, ADescription, AFileExtension: string);
begin
  inherited Create(ComServ.ComServer, APreviewHandlerClass.GetComClass, AClassID, AName, ADescription, ciMultiInstance, tmApartment);
  FPreviewHandlerClass := APreviewHandlerClass;
  FFileExtension := AFileExtension;
end;

function TComPreviewHandlerFactory.CreateComObject(const Controller: IUnknown): TComObject;
begin
  result := inherited CreateComObject(Controller);
  TComPreviewHandler(result).PreviewHandlerClass := PreviewHandlerClass;
end;

class procedure TComPreviewHandlerFactory.DeleteRegValue(const Key, ValueName: string; RootKey: DWord);
var
  RegKey: HKEY;
begin
  if RegOpenKeyEx(RootKey, PChar(Key), 0, KEY_ALL_ACCESS, regKey) = ERROR_SUCCESS then begin
    try
      RegDeleteValue(regKey, PChar(ValueName));
    finally
      RegCloseKey(regKey)
    end;
  end;
end;

class function TComPreviewHandlerFactory.IsRunningOnWOW64: Boolean;
{ code taken from www.delphidabbler.com "IsWow64" }
type
  // Type of IsWow64Process API fn
  TIsWow64Process = function(Handle: Windows.THandle; var Res: Windows.BOOL): Windows.BOOL; stdcall;
var
  IsWow64Result: Windows.BOOL; // Result from IsWow64Process
  IsWow64Process: TIsWow64Process; // IsWow64Process fn reference
begin
{$IF defined(CPUX64)}
  // compiled for 64-bit: can't be running on Wow64
  result := false;
{$ELSE}
  // Try to load required function from kernel32
  IsWow64Process := Windows.GetProcAddress(Windows.GetModuleHandle('kernel32'), 'IsWow64Process');
  if Assigned(IsWow64Process) then begin
    // Function is implemented: call it
    if not IsWow64Process(Windows.GetCurrentProcess, IsWow64Result) then
      raise SysUtils.Exception.Create('IsWindows64: bad process handle');
    // Return result of function
    Result := IsWow64Result;
  end
  else
    // Function not implemented: can't be running on Wow64
    Result := False;
{$IFEND}
end;

procedure TComPreviewHandlerFactory.UpdateRegistry(Register: Boolean);
var
  plainFileName: string;
  sAppID, sClassID, ProgID, ServerKeyName, RegPrefix: string;
  RootKey: HKEY;
  RootKey2: HKEY;
begin
  if Instancing = ciInternal then
    Exit;

  ComServer.GetRegRootAndPrefix(RootKey, RegPrefix);
  if ComServer.PerUserRegistration then
    RootKey2 := HKEY_CURRENT_USER
  else
    RootKey2 := HKEY_LOCAL_MACHINE;
  sClassID := GUIDToString(ClassID);
  ProgID := GetProgID;
  ServerKeyName := RegPrefix + 'CLSID\' + sClassID + '\' + ComServer.ServerKey;
  if IsRunningOnWOW64 then
    sAppID := '{534A1E02-D58F-44f0-B58B-36CBED287C7C}' // for Win32 shell extension running on Win64
  else
    sAppID := '{6d2b5079-2f0b-48dd-ab7f-97cec514d30b}';

  if Register then begin
    inherited;
    plainFileName := ExtractFileName(ComServer.ServerFileName);
    CreateRegKey(RegPrefix + 'CLSID\' + sClassID, 'AppID', sAppID, RootKey);
    if ProgID <> '' then begin
      CreateRegKey(ServerKeyName, 'ProgID', ProgID, RootKey);
      CreateRegKey(ServerKeyName, 'VersionIndependentProgID', ProgID, RootKey);
      CreateRegKey(RegPrefix + ProgID + '\shellex\' + SID_IPreviewHandler, '', sClassID, RootKey);
      CreateRegKey(RegPrefix + FileExtension, '', ProgID, RootKey);
      CreateRegKey('SOFTWARE\Microsoft\Windows\CurrentVersion\PreviewHandlers', sClassID, Description, RootKey2);
    end;
  end
  else begin
    if ProgID <> '' then begin
      DeleteRegValue('SOFTWARE\Microsoft\Windows\CurrentVersion\PreviewHandlers', sClassID, RootKey2);
      DeleteRegKey(RegPrefix + FileExtension, RootKey);
      DeleteRegKey(RegPrefix + ProgID + '\shellex', RootKey);
    end;
    inherited;
  end;
end;

destructor TComPreviewHandler.Destroy;
begin
  FPreviewHandler.Free;
  FContainer.Free;
  inherited Destroy;
end;

procedure TComPreviewHandler.CheckContainer;
begin
  if FContainer = nil then begin
    { I sprang for a TPanel here, because it makes things so much simpler. }
    FContainer := TPanel.Create(nil);
    TPanel(FContainer).BevelOuter := bvNone;
    FContainer.SetBackgroundColor(FBackgroundColor);
    FContainer.SetTextFont(FLogFont);
    FContainer.SetTextColor(FTextColor);
    FContainer.SetBoundsRect(FBounds);
    FContainer.ParentWindow := FParentWindow;
  end;
end;

procedure TComPreviewHandler.CheckPreviewHandler;
begin
  if FPreviewHandler = nil then begin
    CheckContainer;
    FPreviewHandler := PreviewHandlerClass.Create(Container);
  end;
end;

function TComPreviewHandler.ContextSensitiveHelp(fEnterMode: LongBool): HRESULT;
begin
  result := E_NOTIMPL;
end;

function TComPreviewHandler.GetSite(const riid: TGUID; out site: IInterface): HRESULT;
begin
  site := nil;
  if FSite = nil then
    result := E_FAIL
  else if Supports(FSite, riid, site) then
    result := S_OK
  else
    result := E_NOINTERFACE;
end;

function TComPreviewHandler.GetWindow(out wnd: HWND): HRESULT;
begin
  if Container = nil then begin
    result := E_FAIL;
  end
  else begin
    wnd := Container.Handle;
    result := S_OK;
  end;
end;

function TComPreviewHandler.IPreviewHandler_DoPreview: HRESULT;
begin
  try
    CheckPreviewHandler;
    InternalDoPreview;
  except
    on E: Exception do begin
    {$IFDEF USE_CODESITE}
      CodeSite.SendException(E);
    {$ENDIF}
    end;
  end;
  result := S_OK;
end;

function TComPreviewHandler.QueryFocus(var phwnd: HWND): HRESULT;
begin
  phwnd := GetFocus;
  result := S_OK;
end;

function TComPreviewHandler.SetBackgroundColor(color: Cardinal): HRESULT;
begin
  FBackgroundColor := color;
  if Container <> nil then
    Container.SetBackgroundColor(FBackgroundColor);
  result := S_OK;
end;

function TComPreviewHandler.SetFocus: HRESULT;
begin
  if Container <> nil then begin
    if GetKeyState(VK_SHIFT) < 0 then
      Container.SetFocusTabLast
    else
      Container.SetFocusTabFirst;
  end;
  result := S_OK;
end;

function TComPreviewHandler.SetFont(const plf: tagLOGFONTW): HRESULT;
begin
  FLogFont := plf;
  if Container <> nil then
    Container.SetTextFont(FLogFont);
  result := S_OK;
end;

function TComPreviewHandler.SetRect(var prc: TRect): HRESULT;
begin
  FBounds := prc;
  if Container <> nil then
    Container.SetBoundsRect(FBounds);
  result := S_OK;
end;

function TComPreviewHandler.SetSite(const pUnkSite: IInterface): HRESULT;
begin
  FSite := PUnkSite;
  FPreviewHandlerFrame := FSite as IPreviewHandlerFrame;
  result := S_OK;
end;

function TComPreviewHandler.SetTextColor(color: Cardinal): HRESULT;
begin
  FTextColor := color;
  if Container <> nil then
    Container.SetTextColor(FTextColor);
  result := S_OK;
end;

function TComPreviewHandler.SetWindow(hwnd: HWND; var prc: TRect): HRESULT;
begin
  FParentWindow := hwnd;
  FBounds := prc;
  if Container <> nil then begin
    Container.ParentWindow := FParentWindow;
    Container.SetBoundsRect(FBounds);
  end;
  result := S_OK;
end;

function TComPreviewHandler.TranslateAccelerator(var pmsg: tagMSG): HRESULT;
begin
  if FPreviewHandlerFrame = nil then
    result := S_FALSE
  else
    result := FPreviewHandlerFrame.TranslateAccelerator(pmsg);
end;

function TComPreviewHandler.Unload: HRESULT;
begin
  if PreviewHandler <> nil then
    PreviewHandler.Unload;
  InternalUnload;
  result := S_OK;
end;

constructor TPreviewHandler.Create(AParent: TWinControl);
begin
  inherited Create;
end;

class procedure TPreviewHandler.Register(const AClassID: TGUID; const AName, ADescription, AFileExtension: string);
begin
  TComPreviewHandlerFactory.Create(Self, AClassID, AName, ADescription, AFileExtension);
end;

procedure TPreviewHandler.Unload;
begin
end;

constructor TIStreamAdapter.Create(ATarget: IStream);
begin
  inherited Create;
  FTarget := ATarget;
end;

function TIStreamAdapter.GetSize: Int64;
var
  statStg: TStatStg;
begin
  if Target.Stat(statStg, STATFLAG_NONAME) = S_OK then
    result := statStg.cbSize
  else
    result := -1;
end;

function TIStreamAdapter.Read(var Buffer; Count: Longint): Longint;
begin
  Target.Read(@Buffer, Count, @result);
end;

function TIStreamAdapter.Seek(const Offset: Int64; Origin: TSeekOrigin): Int64;
begin
  Target.Seek(Offset, Ord(Origin), result);
end;

procedure TIStreamAdapter.SetSize(const NewSize: Int64);
begin
  raise ENotImplemented.Create('SetSize not implemented');
//  Target.SetSize(NewSize);
end;

procedure TIStreamAdapter.SetSize(NewSize: Longint);
begin
  SetSize(Int64(NewSize));
end;

function TIStreamAdapter.Write(const Buffer; Count: Longint): Longint;
begin
  raise ENotImplemented.Create('Write not implemented');
//  Target.Write(@Buffer, Count, @result);
end;

function TComStreamPreviewHandler.GetPreviewHandler: TStreamPreviewHandler;
begin
  Result := inherited PreviewHandler as TStreamPreviewHandler;
end;

function TComStreamPreviewHandler.IInitializeWithStream_Initialize(const pstream: IStream; grfMode: Cardinal): HRESULT;
begin
  FIStream := pStream;
  FMode := grfMode;
  result := S_OK;
end;

procedure TComStreamPreviewHandler.InternalUnload;
begin
  FIStream := nil;
end;

procedure TComStreamPreviewHandler.InternalDoPreview;
var
  stream: TIStreamAdapter;
begin
  stream := TIStreamAdapter.Create(FIStream);
  try
    PreviewHandler.DoPreview(stream);
  finally
    stream.Free;
  end;
end;

function TComFilePreviewHandler.GetPreviewHandler: TFilePreviewHandler;
begin
  Result := inherited PreviewHandler as TFilePreviewHandler;
end;

function TComFilePreviewHandler.IInitializeWithFile_Initialize(pszFilePath: LPCWSTR; grfMode: DWORD): HRESULT;
begin
  FFilePath := pszFilePath;
  FMode := grfMode;
  result := S_OK;
end;

procedure TComFilePreviewHandler.InternalDoPreview;
begin
  PreviewHandler.DoPreview(FFilePath);
end;

procedure TComFilePreviewHandler.InternalUnload;
begin
  FFilePath := '';
end;

class function TFilePreviewHandler.GetComClass: TComClass;
begin
  result := TComFilePreviewHandler;
end;

class function TStreamPreviewHandler.GetComClass: TComClass;
begin
  result := TComStreamPreviewHandler;
end;

initialization
{$IFDEF USE_CODESITE}
  CodeSiteManager.ConnectUsingTcp;
{$ENDIF}
end.
</code>```

A sample preview handler based on this unit is shown here:

```<code>unit MyPreviewHandler;

interface

uses
  PreviewHandler, Classes, Controls, StdCtrls;

const
  {$REGION 'Unique ClassID of your PreviewHandler'}
  ///   <summary>Unique ClassID of your PreviewHandler</summary>
  ///   <remarks>Don't forget to create a new one. Best use Ctrl-G.</remarks>
  {$ENDREGION}
  CLASS_MyPreviewHandler: TGUID = '{64644512-C345-469F-B5FB-EB351E20129D}';

type
  {$REGION 'Sample PreviewHandler'}
  ///   <summary>Sample PreviewHandler</summary>
  ///   <remarks>A sample PreviewHandler. You only have to derive from
  ///   TFilePreviewHandler or TStreamPreviewHandler and override some methods.</remarks>
  {$ENDREGION}
  TMyPreviewHandler = class(TFilePreviewHandler)
  private
    FTextLabel: TLabel;
  protected
  public
    constructor Create(AParent: TWinControl); override;
    procedure Unload; override;
    procedure DoPreview(const FilePath: string); override;
    property TextLabel: TLabel read FTextLabel;
  end;

implementation

uses
  SysUtils;

constructor TMyPreviewHandler.Create(AParent: TWinControl);
begin
  inherited;
  FTextLabel := TLabel.Create(AParent);
  FTextLabel.Parent := AParent;
  FTextLabel.AutoSize := false;
  FTextLabel.Align := alClient;
  FTextLabel.Alignment := taCenter;
  FTextLabel.Layout := tlCenter;
  FTextLabel.WordWrap := true;
end;

procedure TMyPreviewHandler.DoPreview(const FilePath: string);
begin
  TextLabel.Caption := GetPackageDescription(PWideChar(FilePath));
end;

procedure TMyPreviewHandler.Unload;
begin
  TextLabel.Caption := '';
  inherited;
end;

initialization
  { Register your PreviewHandler with the ClassID, name, descripton and file extension }
  TMyPreviewHandler.Register(CLASS_MyPreviewHandler, 'bplfile', 'BPL Binary Preview Handler', '.bpl');
end.

library MyPreviewHandlerLib;

uses
  ComServ,
  PreviewHandler in 'PreviewHandler.pas' {PreviewHandler: CoClass},
  MyPreviewHandler in 'MyPreviewHandler.pas';

exports
  DllGetClassObject,
  DllCanUnloadNow,
  DllRegisterServer,
  DllUnregisterServer,
  DllInstall;

{$R *.RES}

begin
end.
</code>```

You may be interested in this article in my blog describing some more details on that framework.

ContentLicense: CC BY-SA 2.5

Body:
I have made this unit to handle all the preview handler stuff:

unit PreviewHandler;

{$WARN SYMBOL_PLATFORM OFF}
{.$DEFINE USE_CODESITE}

interface

uses
  Classes, Controls, ComObj;

type
  TPreviewHandler = class abstract
  public
    { Create all controls needed for the preview and connect them to the
      parent given. The parent follows the size, color and font of the preview
      pane. The parent will stay valid until this instance is destroyed, so if
      you make the parent also the owner of the controls you don't need to free
      them in Destroy. }
    constructor Create(AParent: TWinControl); virtual;
    class function GetComClass: TComClass; virtual; abstract;
    class procedure Register(const AClassID: TGUID; const AName, ADescription, AFileExtension: string);
    {$REGION 'Clear Content'}
    /// <summary>Clear Content</summary>
    /// <remarks>This method is called when the preview should be cleared because
    /// either another item was selected or the PreviewHandler will be
    /// closed.</remarks>
    {$ENDREGION}
    procedure Unload; virtual;
  end;

  TStreamPreviewHandler = class abstract(TPreviewHandler)
  public
    {$REGION 'Render the preview from the stream data'}
    /// <summary>Render the preview from the stream data</summary>
    /// <remarks>Here you should render the data from the stream in whatever
    /// fashion you want.</remarks>
    {$ENDREGION}
    procedure DoPreview(Stream: TStream); virtual; abstract;
    class function GetComClass: TComClass; override; final;
  end;

  TFilePreviewHandler = class abstract(TPreviewHandler)
  public
    {$REGION 'Render the preview from the file path'}
    /// <summary>Render the preview from the file path</summary>
    /// <remarks>Here you should render the data from the file path in whatever
    /// fashion you want.</remarks>
    {$ENDREGION}
    procedure DoPreview(const FilePath: String); virtual; abstract;
    class function GetComClass: TComClass; override; final;
  end;

implementation

uses
{$IFDEF USE_CODESITE}
  CodeSiteLogging,
{$ENDIF}
  Windows, ActiveX, ComServ, ShlObj, PropSys, Types, SysUtils, Graphics, ExtCtrls;

type
  TPreviewHandlerClass = class of TPreviewHandler;
  TComPreviewHandler = class(TComObject, IPreviewHandler, IPreviewHandlerVisuals, IObjectWithSite, IOleWindow)
  strict private
    function IPreviewHandler.DoPreview = IPreviewHandler_DoPreview;
    function ContextSensitiveHelp(fEnterMode: LongBool): HRESULT; stdcall;
    function GetSite(const riid: TGUID; out site: IInterface): HRESULT; stdcall;
    function GetWindow(out wnd: HWND): HRESULT; stdcall;
    function IPreviewHandler_DoPreview: HRESULT; stdcall;
    function QueryFocus(var phwnd: HWND): HRESULT; stdcall;
    function SetBackgroundColor(color: Cardinal): HRESULT; stdcall;
    function SetFocus: HRESULT; stdcall;
    function SetFont(const plf: tagLOGFONTW): HRESULT; stdcall;
    function SetRect(var prc: TRect): HRESULT; stdcall;
    function SetSite(const pUnkSite: IInterface): HRESULT; stdcall;
    function SetTextColor(color: Cardinal): HRESULT; stdcall;
    function SetWindow(hwnd: HWND; var prc: TRect): HRESULT; stdcall;
    function TranslateAccelerator(var pmsg: tagMSG): HRESULT; stdcall;
    function Unload: HRESULT; stdcall;
  private
    FBackgroundColor: Cardinal;
    FBounds: TRect;
    FContainer: TWinControl;
    FLogFont: tagLOGFONTW;
    FParentWindow: HWND;
    FPreviewHandler: TPreviewHandler;
    FPreviewHandlerClass: TPreviewHandlerClass;
    FPreviewHandlerFrame: IPreviewHandlerFrame;
    FSite: IInterface;
    FTextColor: Cardinal;
  protected
    procedure CheckContainer;
    procedure CheckPreviewHandler;
    procedure InternalUnload; virtual; abstract;
    procedure InternalDoPreview; virtual; abstract;
    property Container: TWinControl read FContainer;
    property PreviewHandler: TPreviewHandler read FPreviewHandler;
  public
    destructor Destroy; override;
    property PreviewHandlerClass: TPreviewHandlerClass read FPreviewHandlerClass write FPreviewHandlerClass;
  end;

  TComStreamPreviewHandler = class(TComPreviewHandler, IInitializeWithStream)
  strict private
    function IInitializeWithStream.Initialize = IInitializeWithStream_Initialize;
    function IInitializeWithStream_Initialize(const pstream: IStream; grfMode: Cardinal): HRESULT; stdcall;
  private
    FIStream: IStream;
    FMode: Cardinal;
    function GetPreviewHandler: TStreamPreviewHandler;
  protected
    procedure InternalUnload; override;
    procedure InternalDoPreview; override;
    property PreviewHandler: TStreamPreviewHandler read GetPreviewHandler;
  end;

  TComFilePreviewHandler = class(TComPreviewHandler, IInitializeWithFile)
  strict private
    function IInitializeWithFile.Initialize = IInitializeWithFile_Initialize;
    function IInitializeWithFile_Initialize(pszFilePath: LPCWSTR; grfMode: DWORD): HRESULT; stdcall;
  private
    FFilePath: string;
    FMode: DWORD;
    function GetPreviewHandler: TFilePreviewHandler;
  protected
    procedure InternalDoPreview; override;
    procedure InternalUnload; override;
    property PreviewHandler: TFilePreviewHandler read GetPreviewHandler;
  end;

  TComPreviewHandlerFactory = class(TComObjectFactory)
  private
    FFileExtension: string;
    FPreviewHandlerClass: TPreviewHandlerClass;
    class procedure DeleteRegValue(const Key, ValueName: string; RootKey: DWord);
    class function IsRunningOnWOW64: Boolean;
  protected
    property FileExtension: string read FFileExtension;
  public
    constructor Create(APreviewHandlerClass: TPreviewHandlerClass; const AClassID: TGUID; const AName, ADescription, AFileExtension: string);
    function CreateComObject(const Controller: IUnknown): TComObject; override;
    procedure UpdateRegistry(Register: Boolean); override;
    property PreviewHandlerClass: TPreviewHandlerClass read FPreviewHandlerClass;
  end;

  TWinControlHelper = class helper for TWinControl
  public
    procedure SetFocusTabFirst;
    procedure SetFocusTabLast;
    procedure SetBackgroundColor(AColor: Cardinal);
    procedure SetBoundsRect(const ARect: TRect);
    procedure SetTextColor(AColor: Cardinal);
    procedure SetTextFont(const Source: tagLOGFONTW);
  end;

  TIStreamAdapter = class(TStream)
  private
    FTarget: IStream;
  protected
    function GetSize: Int64; override;
    procedure SetSize(NewSize: Longint); override;
    procedure SetSize(const NewSize: Int64); override;
  public
    constructor Create(ATarget: IStream);
    function Read(var Buffer; Count: Longint): Longint; override;
    function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; overload; override;
    function Write(const Buffer; Count: Longint): Longint; override;
    property Target: IStream read FTarget;
  end;

procedure TWinControlHelper.SetFocusTabFirst;
begin
  SelectNext(nil, true, true);
end;

procedure TWinControlHelper.SetFocusTabLast;
begin
  SelectNext(nil, false, true);
end;

procedure TWinControlHelper.SetBackgroundColor(AColor: Cardinal);
begin
  Color := AColor;
end;

procedure TWinControlHelper.SetBoundsRect(const ARect: TRect);
begin
  SetBounds(ARect.Left, ARect.Top, ARect.Right - ARect.Left, ARect.Bottom - ARect.Top);
end;

procedure TWinControlHelper.SetTextColor(AColor: Cardinal);
begin
  Font.Color := AColor;
end;

procedure TWinControlHelper.SetTextFont(const Source: tagLOGFONTW);
var
  fontStyle: TFontStyles;
begin
  Font.Height := Source.lfHeight;
  fontStyle := Font.Style;
  if Source.lfWeight >= FW_BOLD then
    Include(fontStyle, fsBold);
  if Source.lfItalic = 1 then
    Include(fontStyle, fsItalic);
  if Source.lfUnderline = 1 then
    Include(fontStyle, fsUnderline);
  if Source.lfStrikeOut = 1 then
    Include(fontStyle, fsStrikeOut);
  Font.Style := fontStyle;
  Font.Charset := TFontCharset(Source.lfCharSet);
  Font.Name := Source.lfFaceName;
  case Source.lfPitchAndFamily and $F of
    VARIABLE_PITCH: Font.Pitch := fpVariable;
    FIXED_PITCH: Font.Pitch := fpFixed;
  else
    Font.Pitch := fpDefault;
  end;
  Font.Orientation := Source.lfOrientation;
end;

constructor TComPreviewHandlerFactory.Create(APreviewHandlerClass: TPreviewHandlerClass; const AClassID: TGUID; const
    AName, ADescription, AFileExtension: string);
begin
  inherited Create(ComServ.ComServer, APreviewHandlerClass.GetComClass, AClassID, AName, ADescription, ciMultiInstance, tmApartment);
  FPreviewHandlerClass := APreviewHandlerClass;
  FFileExtension := AFileExtension;
end;

function TComPreviewHandlerFactory.CreateComObject(const Controller: IUnknown): TComObject;
begin
  result := inherited CreateComObject(Controller);
  TComPreviewHandler(result).PreviewHandlerClass := PreviewHandlerClass;
end;

class procedure TComPreviewHandlerFactory.DeleteRegValue(const Key, ValueName: string; RootKey: DWord);
var
  RegKey: HKEY;
begin
  if RegOpenKeyEx(RootKey, PChar(Key), 0, KEY_ALL_ACCESS, regKey) = ERROR_SUCCESS then begin
    try
      RegDeleteValue(regKey, PChar(ValueName));
    finally
      RegCloseKey(regKey)
    end;
  end;
end;

class function TComPreviewHandlerFactory.IsRunningOnWOW64: Boolean;
{ code taken from www.delphidabbler.com "IsWow64" }
type
  // Type of IsWow64Process API fn
  TIsWow64Process = function(Handle: Windows.THandle; var Res: Windows.BOOL): Windows.BOOL; stdcall;
var
  IsWow64Result: Windows.BOOL; // Result from IsWow64Process
  IsWow64Process: TIsWow64Process; // IsWow64Process fn reference
begin
{$IF defined(CPUX64)}
  // compiled for 64-bit: can't be running on Wow64
  result := false;
{$ELSE}
  // Try to load required function from kernel32
  IsWow64Process := Windows.GetProcAddress(Windows.GetModuleHandle('kernel32'), 'IsWow64Process');
  if Assigned(IsWow64Process) then begin
    // Function is implemented: call it
    if not IsWow64Process(Windows.GetCurrentProcess, IsWow64Result) then
      raise SysUtils.Exception.Create('IsWindows64: bad process handle');
    // Return result of function
    Result := IsWow64Result;
  end
  else
    // Function not implemented: can't be running on Wow64
    Result := False;
{$IFEND}
end;

procedure TComPreviewHandlerFactory.UpdateRegistry(Register: Boolean);
var
  plainFileName: string;
  sAppID, sClassID, ProgID, ServerKeyName, RegPrefix: string;
  RootKey: HKEY;
  RootKey2: HKEY;
begin
  if Instancing = ciInternal then
    Exit;

  ComServer.GetRegRootAndPrefix(RootKey, RegPrefix);
  if ComServer.PerUserRegistration then
    RootKey2 := HKEY_CURRENT_USER
  else
    RootKey2 := HKEY_LOCAL_MACHINE;
  sClassID := GUIDToString(ClassID);
  ProgID := GetProgID;
  ServerKeyName := RegPrefix + 'CLSID\' + sClassID + '\' + ComServer.ServerKey;
  if IsRunningOnWOW64 then
    sAppID := '{534A1E02-D58F-44f0-B58B-36CBED287C7C}' // for Win32 shell extension running on Win64
  else
    sAppID := '{6d2b5079-2f0b-48dd-ab7f-97cec514d30b}';

  if Register then begin
    inherited;
    plainFileName := ExtractFileName(ComServer.ServerFileName);
    CreateRegKey(RegPrefix + 'CLSID\' + sClassID, 'AppID', sAppID, RootKey);
    if ProgID <> '' then begin
      CreateRegKey(ServerKeyName, 'ProgID', ProgID, RootKey);
      CreateRegKey(ServerKeyName, 'VersionIndependentProgID', ProgID, RootKey);
      CreateRegKey(RegPrefix + ProgID + '\shellex\' + SID_IPreviewHandler, '', sClassID, RootKey);
      CreateRegKey(RegPrefix + FileExtension, '', ProgID, RootKey);
      CreateRegKey('SOFTWARE\Microsoft\Windows\CurrentVersion\PreviewHandlers', sClassID, Description, RootKey2);
    end;
  end
  else begin
    if ProgID <> '' then begin
      DeleteRegValue('SOFTWARE\Microsoft\Windows\CurrentVersion\PreviewHandlers', sClassID, RootKey2);
      DeleteRegKey(RegPrefix + FileExtension, RootKey);
      DeleteRegKey(RegPrefix + ProgID + '\shellex', RootKey);
    end;
    inherited;
  end;
end;

destructor TComPreviewHandler.Destroy;
begin
  FPreviewHandler.Free;
  FContainer.Free;
  inherited Destroy;
end;

procedure TComPreviewHandler.CheckContainer;
begin
  if FContainer = nil then begin
    { I sprang for a TPanel here, because it makes things so much simpler. }
    FContainer := TPanel.Create(nil);
    TPanel(FContainer).BevelOuter := bvNone;
    FContainer.SetBackgroundColor(FBackgroundColor);
    FContainer.SetTextFont(FLogFont);
    FContainer.SetTextColor(FTextColor);
    FContainer.SetBoundsRect(FBounds);
    FContainer.ParentWindow := FParentWindow;
  end;
end;

procedure TComPreviewHandler.CheckPreviewHandler;
begin
  if FPreviewHandler = nil then begin
    CheckContainer;
    FPreviewHandler := PreviewHandlerClass.Create(Container);
  end;
end;

function TComPreviewHandler.ContextSensitiveHelp(fEnterMode: LongBool): HRESULT;
begin
  result := E_NOTIMPL;
end;

function TComPreviewHandler.GetSite(const riid: TGUID; out site: IInterface): HRESULT;
begin
  site := nil;
  if FSite = nil then
    result := E_FAIL
  else if Supports(FSite, riid, site) then
    result := S_OK
  else
    result := E_NOINTERFACE;
end;

function TComPreviewHandler.GetWindow(out wnd: HWND): HRESULT;
begin
  if Container = nil then begin
    result := E_FAIL;
  end
  else begin
    wnd := Container.Handle;
    result := S_OK;
  end;
end;

function TComPreviewHandler.IPreviewHandler_DoPreview: HRESULT;
begin
  try
    CheckPreviewHandler;
    InternalDoPreview;
  except
    on E: Exception do begin
    {$IFDEF USE_CODESITE}
      CodeSite.SendException(E);
    {$ENDIF}
    end;
  end;
  result := S_OK;
end;

function TComPreviewHandler.QueryFocus(var phwnd: HWND): HRESULT;
begin
  phwnd := GetFocus;
  result := S_OK;
end;

function TComPreviewHandler.SetBackgroundColor(color: Cardinal): HRESULT;
begin
  FBackgroundColor := color;
  if Container <> nil then
    Container.SetBackgroundColor(FBackgroundColor);
  result := S_OK;
end;

function TComPreviewHandler.SetFocus: HRESULT;
begin
  if Container <> nil then begin
    if GetKeyState(VK_SHIFT) < 0 then
      Container.SetFocusTabLast
    else
      Container.SetFocusTabFirst;
  end;
  result := S_OK;
end;

function TComPreviewHandler.SetFont(const plf: tagLOGFONTW): HRESULT;
begin
  FLogFont := plf;
  if Container <> nil then
    Container.SetTextFont(FLogFont);
  result := S_OK;
end;

function TComPreviewHandler.SetRect(var prc: TRect): HRESULT;
begin
  FBounds := prc;
  if Container <> nil then
    Container.SetBoundsRect(FBounds);
  result := S_OK;
end;

function TComPreviewHandler.SetSite(const pUnkSite: IInterface): HRESULT;
begin
  FSite := PUnkSite;
  FPreviewHandlerFrame := FSite as IPreviewHandlerFrame;
  result := S_OK;
end;

function TComPreviewHandler.SetTextColor(color: Cardinal): HRESULT;
begin
  FTextColor := color;
  if Container <> nil then
    Container.SetTextColor(FTextColor);
  result := S_OK;
end;

function TComPreviewHandler.SetWindow(hwnd: HWND; var prc: TRect): HRESULT;
begin
  FParentWindow := hwnd;
  FBounds := prc;
  if Container <> nil then begin
    Container.ParentWindow := FParentWindow;
    Container.SetBoundsRect(FBounds);
  end;
  result := S_OK;
end;

function TComPreviewHandler.TranslateAccelerator(var pmsg: tagMSG): HRESULT;
begin
  if FPreviewHandlerFrame = nil then
    result := S_FALSE
  else
    result := FPreviewHandlerFrame.TranslateAccelerator(pmsg);
end;

function TComPreviewHandler.Unload: HRESULT;
begin
  if PreviewHandler <> nil then
    PreviewHandler.Unload;
  InternalUnload;
  result := S_OK;
end;

constructor TPreviewHandler.Create(AParent: TWinControl);
begin
  inherited Create;
end;

class procedure TPreviewHandler.Register(const AClassID: TGUID; const AName, ADescription, AFileExtension: string);
begin
  TComPreviewHandlerFactory.Create(Self, AClassID, AName, ADescription, AFileExtension);
end;

procedure TPreviewHandler.Unload;
begin
end;

constructor TIStreamAdapter.Create(ATarget: IStream);
begin
  inherited Create;
  FTarget := ATarget;
end;

function TIStreamAdapter.GetSize: Int64;
var
  statStg: TStatStg;
begin
  if Target.Stat(statStg, STATFLAG_NONAME) = S_OK then
    result := statStg.cbSize
  else
    result := -1;
end;

function TIStreamAdapter.Read(var Buffer; Count: Longint): Longint;
begin
  Target.Read(@Buffer, Count, @result);
end;

function TIStreamAdapter.Seek(const Offset: Int64; Origin: TSeekOrigin): Int64;
begin
  Target.Seek(Offset, Ord(Origin), result);
end;

procedure TIStreamAdapter.SetSize(const NewSize: Int64);
begin
  raise ENotImplemented.Create('SetSize not implemented');
//  Target.SetSize(NewSize);
end;

procedure TIStreamAdapter.SetSize(NewSize: Longint);
begin
  SetSize(Int64(NewSize));
end;

function TIStreamAdapter.Write(const Buffer; Count: Longint): Longint;
begin
  raise ENotImplemented.Create('Write not implemented');
//  Target.Write(@Buffer, Count, @result);
end;

function TComStreamPreviewHandler.GetPreviewHandler: TStreamPreviewHandler;
begin
  Result := inherited PreviewHandler as TStreamPreviewHandler;
end;

function TComStreamPreviewHandler.IInitializeWithStream_Initialize(const pstream: IStream; grfMode: Cardinal): HRESULT;
begin
  FIStream := pStream;
  FMode := grfMode;
  result := S_OK;
end;

procedure TComStreamPreviewHandler.InternalUnload;
begin
  FIStream := nil;
end;

procedure TComStreamPreviewHandler.InternalDoPreview;
var
  stream: TIStreamAdapter;
begin
  stream := TIStreamAdapter.Create(FIStream);
  try
    PreviewHandler.DoPreview(stream);
  finally
    stream.Free;
  end;
end;

function TComFilePreviewHandler.GetPreviewHandler: TFilePreviewHandler;
begin
  Result := inherited PreviewHandler as TFilePreviewHandler;
end;

function TComFilePreviewHandler.IInitializeWithFile_Initialize(pszFilePath: LPCWSTR; grfMode: DWORD): HRESULT;
begin
  FFilePath := pszFilePath;
  FMode := grfMode;
  result := S_OK;
end;

procedure TComFilePreviewHandler.InternalDoPreview;
begin
  PreviewHandler.DoPreview(FFilePath);
end;

procedure TComFilePreviewHandler.InternalUnload;
begin
  FFilePath := '';
end;

class function TFilePreviewHandler.GetComClass: TComClass;
begin
  result := TComFilePreviewHandler;
end;

class function TStreamPreviewHandler.GetComClass: TComClass;
begin
  result := TComStreamPreviewHandler;
end;

initialization
{$IFDEF USE_CODESITE}
  CodeSiteManager.ConnectUsingTcp;
{$ENDIF}
end.

A sample preview handler based on this unit is shown here:

unit MyPreviewHandler;

interface

uses
  PreviewHandler, Classes, Controls, StdCtrls;

const
  {$REGION 'Unique ClassID of your PreviewHandler'}
  ///   <summary>Unique ClassID of your PreviewHandler</summary>
  ///   <remarks>Don't forget to create a new one. Best use Ctrl-G.</remarks>
  {$ENDREGION}
  CLASS_MyPreviewHandler: TGUID = '{64644512-C345-469F-B5FB-EB351E20129D}';

type
  {$REGION 'Sample PreviewHandler'}
  ///   <summary>Sample PreviewHandler</summary>
  ///   <remarks>A sample PreviewHandler. You only have to derive from
  ///   TFilePreviewHandler or TStreamPreviewHandler and override some methods.</remarks>
  {$ENDREGION}
  TMyPreviewHandler = class(TFilePreviewHandler)
  private
    FTextLabel: TLabel;
  protected
  public
    constructor Create(AParent: TWinControl); override;
    procedure Unload; override;
    procedure DoPreview(const FilePath: string); override;
    property TextLabel: TLabel read FTextLabel;
  end;

implementation

uses
  SysUtils;

constructor TMyPreviewHandler.Create(AParent: TWinControl);
begin
  inherited;
  FTextLabel := TLabel.Create(AParent);
  FTextLabel.Parent := AParent;
  FTextLabel.AutoSize := false;
  FTextLabel.Align := alClient;
  FTextLabel.Alignment := taCenter;
  FTextLabel.Layout := tlCenter;
  FTextLabel.WordWrap := true;
end;

procedure TMyPreviewHandler.DoPreview(const FilePath: string);
begin
  TextLabel.Caption := GetPackageDescription(PWideChar(FilePath));
end;

procedure TMyPreviewHandler.Unload;
begin
  TextLabel.Caption := '';
  inherited;
end;

initialization
  { Register your PreviewHandler with the ClassID, name, descripton and file extension }
  TMyPreviewHandler.Register(CLASS_MyPreviewHandler, 'bplfile', 'BPL Binary Preview Handler', '.bpl');
end.

library MyPreviewHandlerLib;

uses
  ComServ,
  PreviewHandler in 'PreviewHandler.pas' {PreviewHandler: CoClass},
  MyPreviewHandler in 'MyPreviewHandler.pas';

exports
  DllGetClassObject,
  DllCanUnloadNow,
  DllRegisterServer,
  DllUnregisterServer,
  DllInstall;

{$R *.RES}

begin
end.

You may be interested in this article in my blog describing some more details on that framework.

ContentLicense: CC BY-SA 3.0


问:
How to get feature names from ELI5 when transformer includes an embedded pipeline
The ELI5 library provides the function transform_feature_names to retrieve the feature names for the output of an sklearn transformer. The documentation says that the function works out of the box when the transformer includes nested Pipelines.

I'm trying to get the function to work on a simplified version of the example in the answer to SO 57528350. My simplified example doesn't need Pipeline, but in real life I will need it in order to add steps to categorical_transformer, and I will also want to add transformers to the ColumnTransformer.

```<code>import eli5
import pandas as pd
from sklearn.compose import ColumnTransformer
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import OneHotEncoder, StandardScaler

X_train = pd.DataFrame({'age': [23, 12, 12, 18],
                        'gender': ['M', 'F', 'F', 'F'],
                        'income': ['high', 'low', 'low', 'medium'],
                        'y': [0, 1, 1, 1]})

categorical_features = ['gender', 'income']
categorical_transformer = Pipeline(
    steps=[('onehot', OneHotEncoder(handle_unknown='ignore'))])

transformers=[('categorical', categorical_transformer, categorical_features)]
preprocessor = ColumnTransformer(transformers)
X_train_transformed = preprocessor.fit(X_train)

eli5.transform_feature_names(preprocessor, list(X_train.columns))
</code>```

This dies with the message

AttributeError: Transformer categorical (type Pipeline) does not provide get_feature_names.

Since the Pipeline is nested in the ColumnTransformer, I understood from the ELI5 documentation that it would be handled.

Do I need to create a modified version of Pipeline with a get_feature_names method or make other custom modifications in order to take advantage of the ELI5 function?

I'm using python 3.7.6, eli5 0.10.1, pandas 0.25.3, and sklearn 0.22.1.

答:
I think the problem is that eli5 is relying on the ColumnTransformer method get_feature_names, which itself asks the Pipeline to get_feature_names, which is not yet implemented in sklearn.

I've opened an Issue with eli5 with your example.

One possible fix: adding a transform_feature_names dispatch for ColumnTransformer; this can be just a modification of its existing get_feature_names to call for eli5 transform_feature_names for each of its component transformers (instead of sklearn's own get_feature_names).  The below seems to work, although I'm not sure how to handle when input_names differs from the training dataframe columns, available in the ColumnTransformer as _df_columns.

```<code>from eli5 import transform_feature_names

@transform_feature_names.register(ColumnTransformer)
def col_tfm_names(transformer, in_names=None):
    if in_names is None:
        from eli5.sklearn.utils import get_feature_names
        # generate default feature names
        in_names = get_feature_names(transformer, num_features=transformer._n_features)
    # return a list of strings derived from in_names
    feature_names = []
    for name, trans, column, _ in transformer._iter(fitted=True):
        if hasattr(transformer, '_df_columns'):
            if ((not isinstance(column, slice))
                    and all(isinstance(col, str) for col in column)):
                names = column
            else:
                names = transformer._df_columns[column]
        else:
            indices = np.arange(transformer._n_features)
            names = ['x%d' % i for i in indices[column]]
        # erm, want to be able to override with in_names maybe???

        if trans == 'drop' or (
                hasattr(column, '__len__') and not len(column)):
            continue
        if trans == 'passthrough':
            feature_names.extend(names)
            continue
        feature_names.extend([name + "__" + f for f in
                              transform_feature_names(trans, in_names=names)])
    return feature_names
</code>```

I also needed to create a dispatch for OneHotEncoder, because its get_feature_names needs the parameter input_features:

```<code>@transform_feature_names.register(OneHotEncoder)
def _ohe_names(est, in_names=None):
    return est.get_feature_names(input_features=in_names)
</code>```

Relevant links:

https://eli5.readthedocs.io/en/latest/autodocs/eli5.html#eli5.transform_feature_names

https://github.com/TeamHG-Memex/eli5/blob/4839d1927c4a68aeff051935d1d4d8a4fb69b46d/eli5/sklearn/transform.py

Body:
The ELI5 library provides the function transform_feature_names to retrieve the feature names for the output of an sklearn transformer. The documentation says that the function works out of the box when the transformer includes nested Pipelines.

I'm trying to get the function to work on a simplified version of the example in the answer to SO 57528350. My simplified example doesn't need Pipeline, but in real life I will need it in order to add steps to categorical_transformer, and I will also want to add transformers to the ColumnTransformer.

import eli5
import pandas as pd
from sklearn.compose import ColumnTransformer
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import OneHotEncoder, StandardScaler

X_train = pd.DataFrame({'age': [23, 12, 12, 18],
                        'gender': ['M', 'F', 'F', 'F'],
                        'income': ['high', 'low', 'low', 'medium'],
                        'y': [0, 1, 1, 1]})

categorical_features = ['gender', 'income']
categorical_transformer = Pipeline(
    steps=[('onehot', OneHotEncoder(handle_unknown='ignore'))])

transformers=[('categorical', categorical_transformer, categorical_features)]
preprocessor = ColumnTransformer(transformers)
X_train_transformed = preprocessor.fit(X_train)

eli5.transform_feature_names(preprocessor, list(X_train.columns))

This dies with the message

AttributeError: Transformer categorical (type Pipeline) does not provide get_feature_names.

Since the Pipeline is nested in the ColumnTransformer, I understood from the ELI5 documentation that it would be handled.

Do I need to create a modified version of Pipeline with a get_feature_names method or make other custom modifications in order to take advantage of the ELI5 function?

I'm using python 3.7.6, eli5 0.10.1, pandas 0.25.3, and sklearn 0.22.1.

Body:
I think the problem is that eli5 is relying on the ColumnTransformer method get_feature_names, which itself asks the Pipeline to get_feature_names, which is not yet implemented in sklearn.

I've opened an Issue with eli5 with your example.

One possible fix: adding a transform_feature_names dispatch for ColumnTransformer; this can be just a modification of its existing get_feature_names to call for eli5 transform_feature_names for each of its component transformers (instead of sklearn's own get_feature_names).  The below seems to work, although I'm not sure how to handle when input_names differs from the training dataframe columns, available in the ColumnTransformer as _df_columns.

from eli5 import transform_feature_names

@transform_feature_names.register(ColumnTransformer)
def col_tfm_names(transformer, in_names=None):
    if in_names is None:
        from eli5.sklearn.utils import get_feature_names
        # generate default feature names
        in_names = get_feature_names(transformer, num_features=transformer._n_features)
    # return a list of strings derived from in_names
    feature_names = []
    for name, trans, column, _ in transformer._iter(fitted=True):
        if hasattr(transformer, '_df_columns'):
            if ((not isinstance(column, slice))
                    and all(isinstance(col, str) for col in column)):
                names = column
            else:
                names = transformer._df_columns[column]
        else:
            indices = np.arange(transformer._n_features)
            names = ['x%d' % i for i in indices[column]]
        # erm, want to be able to override with in_names maybe???

        if trans == 'drop' or (
                hasattr(column, '__len__') and not len(column)):
            continue
        if trans == 'passthrough':
            feature_names.extend(names)
            continue
        feature_names.extend([name + "__" + f for f in
                              transform_feature_names(trans, in_names=names)])
    return feature_names

I also needed to create a dispatch for OneHotEncoder, because its get_feature_names needs the parameter input_features:

@transform_feature_names.register(OneHotEncoder)
def _ohe_names(est, in_names=None):
    return est.get_feature_names(input_features=in_names)

Relevant links:

https://eli5.readthedocs.io/en/latest/autodocs/eli5.html#eli5.transform_feature_names

https://github.com/TeamHG-Memex/eli5/blob/4839d1927c4a68aeff051935d1d4d8a4fb69b46d/eli5/sklearn/transform.py


问:
stuck on about_methods.rb on the EdgeCase Ruby Koans
I'm hacking my way through the EdgeCase RubyKoans (www.rubykoans.com) and am stuck on the method starting at line 35 in about_methods.rb here. Running rake fails predictably and tells me to look at line 36. I'm reasonable sure I have the assert_match correct ("0 for 2") but I don't know what's failing. It's very possible that the assert_raise(___) line should have something inbetween the parentheses, but I have no idea what that should be. Any hints or nudges?  Thanks much.

edit: here's the short snippet of offending code:

```<code>def my_global_method(a,b)
 a + b
end
</code>```

-snip-

```<code>def test_calling_global_methods_with_wrong_number_of_arguments
exception = assert_raise(___) do
  my_global_method
end
assert_match(/"0 for 2"/, exception.message)

exception = assert_raise(___) do
  my_global_method(1,2,3)
end
assert_match(/__/, exception.message)
end
</code>```

答:
After a couple of hours in this problem, I found the solution:</p>

```<code>def test_calling_global_methods_with_wrong_number_of_arguments
    exception = assert_raise(ArgumentError) do
      my_global_method
    end
    myString = "wrong number of arguments (given 0, expected 2)"
    assert_match(/#{Regexp.quote(myString)}/ , exception.message)

    exception = assert_raise(ArgumentError) do
      my_global_method(1,2,3)
    end
    myString = "wrong number of arguments (given 3, expected 2)"
    assert_match(/#{Regexp.quote(myString)}/, exception.message)
end
</code>```

Body:
I'm hacking my way through the EdgeCase RubyKoans (www.rubykoans.com) and am stuck on the method starting at line 35 in about_methods.rb here. Running rake fails predictably and tells me to look at line 36. I'm reasonable sure I have the assert_match correct ("0 for 2") but I don't know what's failing. It's very possible that the assert_raise(___) line should have something inbetween the parentheses, but I have no idea what that should be. Any hints or nudges?  Thanks much.

edit: here's the short snippet of offending code:

def my_global_method(a,b)
 a + b
end

-snip-

def test_calling_global_methods_with_wrong_number_of_arguments
exception = assert_raise(___) do
  my_global_method
end
assert_match(/"0 for 2"/, exception.message)

exception = assert_raise(___) do
  my_global_method(1,2,3)
end
assert_match(/__/, exception.message)
end

Body:
After a couple of hours in this problem, I found the solution:

def test_calling_global_methods_with_wrong_number_of_arguments
    exception = assert_raise(ArgumentError) do
      my_global_method
    end
    myString = "wrong number of arguments (given 0, expected 2)"
    assert_match(/#{Regexp.quote(myString)}/ , exception.message)

    exception = assert_raise(ArgumentError) do
      my_global_method(1,2,3)
    end
    myString = "wrong number of arguments (given 3, expected 2)"
    assert_match(/#{Regexp.quote(myString)}/, exception.message)
end


问:
Can I use a collection initializer with LINQ to return a fully populated collection?
I would like to rewrite the following code in one line, using LINQ. Is it possible?

```<code>var to = new MailAddressCollection();

foreach(string recipient in recipients)
{
    to.Add(new MailAddress(recipient));
}
</code>```

Something like the following would be ideal. As written it returns multiple MailAddressCollections:

```<code>var to = recipients.Select(r => new MailAddressCollection() {new MailAddress(r)});
</code>```

Note that these are framework classes, so I cannot rewrite MailAddressCollection to include a constructor argument.

答:
How about this ...

```<code>var to = new MailAddressCollection(recipients.Select(r => new MailAddress(r));
</code>```

Although, this relies on the presence of a constructor on MailAddressCollection (or its superclass) that takes a IEnumerable<MailAddress> as an argument. If it is a subclass of List<T> this will be the case.

Body:
I would like to rewrite the following code in one line, using LINQ. Is it possible?

var to = new MailAddressCollection();

foreach(string recipient in recipients)
{
    to.Add(new MailAddress(recipient));
}

Something like the following would be ideal. As written it returns multiple MailAddressCollections:

var to = recipients.Select(r => new MailAddressCollection() {new MailAddress(r)});

Note that these are framework classes, so I cannot rewrite MailAddressCollection to include a constructor argument.

Body:
How about this ...

var to = new MailAddressCollection(recipients.Select(r => new MailAddress(r));

Although, this relies on the presence of a constructor on MailAddressCollection (or its superclass) that takes a IEnumerable<MailAddress> as an argument. If it is a subclass of List<T> this will be the case.


问:
Vuetify v-dialog - Dynamic width
is it possible to make the v-dialog have dynamic width? Currently the v-dialog by default has dynamic height which makes it shorten and lengthen depending on the length of content.

But can this be done with width?

I have a v-dialog that contains 4 tabs. 3 of those tabs don't require much width but the last tab contains a table so I'd like the dialog to widen as far as it needs to, to cater for the table, and then shorten again when clicking on either of the first 3 tabs.

Vuetify v-dialog: https://vuetifyjs.com/en/components/dialogs

答:
Write custom css rules and not set width or max-width props. e.g.:

I use a custom class in order to not apply rules to all v-dialog:

```<code><v-dialog v-model="dialog" content-class="v-dialog--custom">
   <!-- dialog content -->
</v-dialog>
</code>```

And create your custom rules:

```<code>.v-dialog--custom {
  width: 100%;
}

/* Desktop */
@media screen and (min-width: 768px) {
  .v-dialog--custom {
    width: 50%;
  }
}
</code>```

You can see this on codepen: https://codepen.io/hans-felix/pen/BajByxx

Title: Vuetify v-dialog - Dynamic width

Body:
Write custom css rules and not set width or max-width props. e.g.:

I use a custom class in order to not apply rules to all v-dialog:

<v-dialog v-model="dialog" content-class="v-dialog--custom">
   <!-- dialog content -->
</v-dialog>

And create your custom rules:

.v-dialog--custom {
  width: 100%;
}

/* Desktop */
@media screen and (min-width: 768px) {
  .v-dialog--custom {
    width: 50%;
  }
}

You can see this on codepen: https://codepen.io/hans-felix/pen/BajByxx


问:
Alphabet Adjacent Pairs in Sequence code
Alphabet Adjacent Pairs in Sequence

Accept a string S which contains only lower case alphabets and print the count of instances C where in a pair of adjacent characters, the right character is next to the left character in the original alphabetical sequence.

Boundary Condition(s):
1 <= Length of S <= 1000

Input Format:
The first line contains S.

Output Format:
The first line contains the integer value C

Example Input/Output 1:
Input:
abegh

Output:
2

Explanation:
ab gh are the two instances.

Example Input/Output 2:
Input:
abcdef

Output:
5

Explanation:
ab bc cd de ef are the five instances.

My Solution:

```<code>import java.util.*;
public class adj{
public static void main(String args[])
{
    Scanner sc=new Scanner (System.in);
    String s=sc.next();
    char t,t1;
    String r[]=new String[100];
    char a[]={'a', 'b', 'c', 'd', 'e', 'f','g', 'h', 'i', 'j', 'k', 'l','m', 'n', 'o', 'p', 'q', 'r','s', 'u', 'v', 'w', 'x', 'y' ,'z'};
    int count=0;
    for(int i=0;i<(s.length()-1);i++)
    {
        t=s.charAt(i);
        t1=s.charAt(i+1);
        //r[i]=t+t1;
        if(t==(a[i]))
        {
            if(t1==(a[i+1]))
                {
                    count++;
                    continue;
                }
            continue;
        }
    }
    System.out.print(count);
  }
}
</code>```

but this code prints only 1 for testcase abegh instead of 2

答:
Short and simple !</p>

```<code>#include<stdio.h>
#include <stdlib.h>

int main()
 {
char s[1002];
scanf("%s",s);
int ac=0;
int an = strlen(s);
for(int i=0;i<an-1;i++)
{
  if((s[i+1]-s[i])==1){
    ac+=1;
  }
}
printf("%d",ac);
}
</code>```

Body:
Alphabet Adjacent Pairs in Sequence

Accept a string S which contains only lower case alphabets and print the count of instances C where in a pair of adjacent characters, the right character is next to the left character in the original alphabetical sequence.

Boundary Condition(s):
1 <= Length of S <= 1000

Input Format:
The first line contains S.

Output Format:
The first line contains the integer value C

Example Input/Output 1:
Input:
abegh

Output:
2

Explanation:
ab gh are the two instances.

Example Input/Output 2:
Input:
abcdef

Output:
5

Explanation:
ab bc cd de ef are the five instances.

My Solution:

import java.util.*;
public class adj{
public static void main(String args[])
{
    Scanner sc=new Scanner (System.in);
    String s=sc.next();
    char t,t1;
    String r[]=new String[100];
    char a[]={'a', 'b', 'c', 'd', 'e', 'f','g', 'h', 'i', 'j', 'k', 'l','m', 'n', 'o', 'p', 'q', 'r','s', 'u', 'v', 'w', 'x', 'y' ,'z'};
    int count=0;
    for(int i=0;i<(s.length()-1);i++)
    {
        t=s.charAt(i);
        t1=s.charAt(i+1);
        //r[i]=t+t1;
        if(t==(a[i]))
        {
            if(t1==(a[i+1]))
                {
                    count++;
                    continue;
                }
            continue;
        }
    }
    System.out.print(count);
  }
}

but this code prints only 1 for testcase abegh instead of 2

Body:
Short and simple !

#include<stdio.h>
#include <stdlib.h>

int main()
 {
char s[1002];
scanf("%s",s);
int ac=0;
int an = strlen(s);
for(int i=0;i<an-1;i++)
{
  if((s[i+1]-s[i])==1){
    ac+=1;
  }
}
printf("%d",ac);
}


问:
" Kubernetes is starting ....." forever error on windows 10
I had a kubernetes single node cluster on my windows 10 machine. Due some errors I had to reinstall the Docker Desktop and since then kubernetes installation has failed while docker installed successfully. All attempts to resolve e.g. deleting the config file in .kube directory and complete reinstallation have failed. See attached pix for details. Installed docker version is Docker version 18.09.2, build 6247962. All search online efforts  do not yield a possible solution. I would appreciate pointers to a solution or walk-around.

答:
I stucked in two kinds of error

system pods running, found labels  but still waiting for labels...

xxxx: EOF

I finally sovled it by following the advice by the following project,
https://github.com/AliyunContainerService/k8s-for-docker-desktop/
Do as it told you, if not work,
remove ~/.kube and ~/Library/Group\ Containers/group.com.docker/pki directory, then restart docker desktop and wait like 5 minutes.
The Kubernetes status is running eventually.


问:
ECS Fargate 1.4 Not Using VPC Endpoints
This is an odd one.  I have an ECS service using Fargate v1.4 in a private subnet.  Since the tasks don't have access to the Internet, I had to configure VPC Endpoints so that tasks could load what they needed from AWS services (e.g. secrets from SSM, the image from ECR, etc.).  This was all and good and worked just fine, until it didn't.  I'm not sure what changed, but one weekend I noticed my servers weren't running anymore and I noticed this error in the console:

```<code>ResourceInitializationError: unable to pull secrets or registry auth: execution resource retrieval failed: unable to retrieve secrets from ssm: service call has been retried 1 time(s): RequestError: send request failed caused by: Post https://ssm.us-ea...
</code>```

That looked familiar from when I was configuring the VPC endpoints, so I went through the console to make sure nothing changed.  As far as I can tell, the configuration looks right (security groups have the proper ingress/egress rules, proper endpoints are configured and connected to the VPC my servers are in, everything is in the same AZ, IAM roles have access to the secret).

As an experiment, I removed the secrets I was trying to load from the task definition to see what would happen.  When a new server spun up, I saw a similar error, but this time for loading the image from ECR:

```<code>ResourceInitializationError: unable to pull secrets or registry auth: execution resource retrieval failed: unable to retrieve ecr registry auth: service call has been retried 1 time(s): RequestError: send request failed caused by: Post https://api.ecr....
</code>```

I also tried to delete and recreate all of the endpoints, just in case, and still no success.

Other (potentially) useful information:

Region: us-east-1

I'm using the latest version of Pulumi

I'm using app autoscaling to spin down the instances during the week

Any help/tips would be appreciated.

答:
Based on the discussion in comments, the cause for the issue was determined to be incorrect CIDR range on the security groups (SGs) for the SSM VPC service endpoint.

General troubleshooting recommendation for the issue are:

check the ingress rules on the SGs for the VPC interface endpoint (port 443 open).

ensure that S3 gateway endpoint is also available and working as it is required by SSM.

check if enableDnsHostnames and DNSSupport are enabled for the VPC

create an instance in the same subnet as the ECS service. Use the instance (after setting up its role with permissions to SSM) to check the SSM interface connectivity. The aim of this is to verify whether the issue is at VPC level or at ECS level.

in the instance, AWS CLI can be used to connect to the SSM endpoint using custom interface URL or the general one for the SSM.

Title: ECS Fargate 1.4 Not Using VPC Endpoints

Body:
This is an odd one.  I have an ECS service using Fargate v1.4 in a private subnet.  Since the tasks don't have access to the Internet, I had to configure VPC Endpoints so that tasks could load what they needed from AWS services (e.g. secrets from SSM, the image from ECR, etc.).  This was all and good and worked just fine, until it didn't.  I'm not sure what changed, but one weekend I noticed my servers weren't running anymore and I noticed this error in the console:

ResourceInitializationError: unable to pull secrets or registry auth: execution resource retrieval failed: unable to retrieve secrets from ssm: service call has been retried 1 time(s): RequestError: send request failed caused by: Post https://ssm.us-ea...

That looked familiar from when I was configuring the VPC endpoints, so I went through the console to make sure nothing changed.  As far as I can tell, the configuration looks right (security groups have the proper ingress/egress rules, proper endpoints are configured and connected to the VPC my servers are in, everything is in the same AZ, IAM roles have access to the secret).

As an experiment, I removed the secrets I was trying to load from the task definition to see what would happen.  When a new server spun up, I saw a similar error, but this time for loading the image from ECR:

ResourceInitializationError: unable to pull secrets or registry auth: execution resource retrieval failed: unable to retrieve ecr registry auth: service call has been retried 1 time(s): RequestError: send request failed caused by: Post https://api.ecr....

I also tried to delete and recreate all of the endpoints, just in case, and still no success.

Other (potentially) useful information:

Region: us-east-1

I'm using the latest version of Pulumi

I'm using app autoscaling to spin down the instances during the week

Any help/tips would be appreciated.


问:
How to insert multiple values to DB using select2 multiple in Laravel 7
When I'm trying to insert all selected values into the DB I get [ result in driver_lisence column.

Here is my blade

    {{__('driver.driver_licence')}}
    <select name="driver_lisence[]" class="form-control select multiple" id="" multiple="multiple">
        <option {{ old('driver_lisence') == 'A' ? 'selected': '' }}  value="A">A</option>
        <option {{ old('driver_lisence') == 'B' ? 'selected': '' }}  value="B">B</option>
        <option {{ old('driver_lisence') == 'C' ? 'selected': '' }}  value="C">C</option>
        <option {{ old('driver_lisence') == 'D' ? 'selected': '' }}  value="C">D</option>
        <option {{ old('driver_lisence') == 'E' ? 'selected': '' }}  value="E">E</option>
    </select>

    @error('driver_lisence')

            {{$message}}

    @enderror

```

<p>Here is my Model </p>

<pre class="lang-php prettyprint-override"><code>protected $fillable = [
    'firstname',
    'lastname',
    'birthday',
    'email',
    'phone',
    'password',
    'gender',
    'image',
    'pasport_id',
    'fin_code',
    'driver_lisence',
    'status',
    'fcm_token',
    'driver_group_id',
    'app_version',
];

protected $casts = [
    'driver_lisence' => 'array'
];
</code>```

Here is my Controller

public function store(DriverRequest $request)
{
    $data = $request->all();

    if ($request->file('image'))
    {
        $data['image'] = request('image')->store('',['disk' => 'uploads']);;
    }

    $data['password'] = Hash::make($data['password']);

    Driver::create($data);

    return  redirect(route('admin.driver.index'))->with(_sessionmessage());
}
```

I just want to select all values and insert into driver_licence column like array.

答: Fixed by my self. problem was in my migration. there im inserted column lenth 1. i deleted it and i works</p>

Body:
When I'm trying to insert all selected values into the DB I get [ result in driver_lisence column.

Here is my blade

    {{__('driver.driver_licence')}}
    <select name="driver_lisence[]" class="form-control select multiple" id="" multiple="multiple">
        <option {{ old('driver_lisence') == 'A' ? 'selected': '' }}  value="A">A</option>
        <option {{ old('driver_lisence') == 'B' ? 'selected': '' }}  value="B">B</option>
        <option {{ old('driver_lisence') == 'C' ? 'selected': '' }}  value="C">C</option>
        <option {{ old('driver_lisence') == 'D' ? 'selected': '' }}  value="C">D</option>
        <option {{ old('driver_lisence') == 'E' ? 'selected': '' }}  value="E">E</option>
    </select>

    @error('driver_lisence')

            {{$message}}

    @enderror

Here is my Model

protected $fillable = [
    'firstname',
    'lastname',
    'birthday',
    'email',
    'phone',
    'password',
    'gender',
    'image',
    'pasport_id',
    'fin_code',
    'driver_lisence',
    'status',
    'fcm_token',
    'driver_group_id',
    'app_version',
];

protected $casts = [
    'driver_lisence' => 'array'
];

Here is my Controller

public function store(DriverRequest $request)
{
    $data = $request->all();

    if ($request->file('image'))
    {
        $data['image'] = request('image')->store('',['disk' => 'uploads']);;
    }

    $data['password'] = Hash::make($data['password']);

    Driver::create($data);

    return  redirect(route('admin.driver.index'))->with(_sessionmessage());
}

I just want to select all values and insert into driver_licence column like array.


问:
Conditional formatting based on snother cell
I have a list of due dates in column j and a list of dates when the reports were submitted in column k

If tge due date is less than today (as in its now overdue) i want to put some formatting on thst overdue date to make it stand out but as soon as the submitted date is filled out i want the formatting to return to normal

How do I accomplish this?

答:
Assume your due date starts on row 2. Select all the due dates and add a conditional formatting rule as follows:

=AND(I2<TODAY(), ISBLANK(J2))

and select the highlight format you want.


问:
Send request from browser from HTTPS to HTTP, mixed content
I'm trying to make a fetch to my API hosted locally from my GitHub page, but I can't due to the mixed content error. Is there a way to get around it? I'm not sending sensitive information or whatever and I don't need a response.</p>

答:
You need to either use HTTPS or HTTP across the board.  You can't use half one and half the other.

I'm not sending sensitive information or whatever

HTTPS is not just about the encryption of the information, but also to ensure that you're connected to an authorized server.  There are many ways connections get hijacked... including broken public WiFi access points with captive portals.  In any case, the browser vendors don't give us much of a choice these days.