问:
Searching Mergesort algorithm using Java's standard LinkedList
I want to sort a LinkedList in Java using a Mergesort algorithm.

I've researched in the internet for a solution but the algorithms I found sort either an Array or a self declared LinkedList. As I mentioned earlier I need an algorithm which sorts the standard java LinkedList (java.util.LinkedList).

In addition to my research I tried to implement one myself but I'm not capable of doing so. I was able to create the 'divide' part but I couldn't program the 'conquer' (merge in the sorted order) part.

This is my code:

private void mergeSort(LinkedList<Integer> list) {
        if (list.size() < 2){
            return;
        }
        int middleindex  = list.size()/2;
        LinkedList<Integer> [] listArr = split(list, middleindex);

        LinkedList<Integer> leftList = listArr[0];
        mergeSort(leftList);

        LinkedList<Integer> rightList = listArr[1];
        mergeSort(rightList);

        sortedMerge(rightList, leftList, list);

    }

    private void sortedMerge(LinkedList<E> right, LinkedList<E> left, LinkedList<E> list){
        //sort and merge
    }

    @SuppressWarnings("unchecked") private static <T> LinkedList<T>[] split(LinkedList<T> list, int index) {
        LinkedList<T> left = new LinkedList<>();

        for (int i = 0; i < index; i++) {
            T t = list.removeFirst();
            left.addLast(t);
        }
        return new LinkedList[] {
                left, list
        };
    }
```

Can someone help me and create the 'sortedMerge()' method?

答:
Example code (including test code in main()) for a bottom up merge sort for Java LinkedList, which uses a small array (32) of lists, (as opposed to top down's approach of splitting and pushing lists onto the stack). Since Java LinkedList doesn't have the C++ equivalent of std::list::splice(), which moves nodes within a list (or from list to list), the nodes and lists are created and deleted, which adds a significant amount of overhead. </p>

```<code>package llsort;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Random;

public class llsort {

    public static LinkedList<Integer> Merge(LinkedList<Integer> ll0, LinkedList<Integer> ll1){
        LinkedList<Integer> ll = new LinkedList<>();
        if(ll0.isEmpty())               // empty list check
            return (ll1);
        if(ll1.isEmpty())
            return (ll0);
        ListIterator <Integer> ll0i = ll0.listIterator(0);
        ListIterator <Integer> ll1i = ll1.listIterator(0);
        Integer e0;
        Integer e1;
        e0 = ll0i.next();               // merge lists
        e1 = ll1i.next();
        while(true){
            if(e0 <= e1){
                ll.add(e0);
                if(ll0i.hasNext()){
                    e0 = ll0i.next();
                    continue;
                }
                ll.add(e1);
                while(ll1i.hasNext())
                    ll.add(ll1i.next());
                break;
            }else{
                ll.add(e1);
                if(ll1i.hasNext()){
                    e1 = ll1i.next();
                    continue;
                }
                ll.add(e0);
                while(ll0i.hasNext())
                    ll.add(ll0i.next());
                break;
            }
        }
        return ll;
    }

    public static LinkedList<Integer> MergeSort(LinkedList<Integer> src){
        final int NUMLIST = 32;
        LinkedList<Integer>[] all = new LinkedList[NUMLIST];
        LinkedList<Integer> ll;
        int i;
        // merge nodes into array
        ll = new LinkedList();
        while(!src.isEmpty()){
            ll.add(src.peek());
            src.remove();
            for(i = 0; i < NUMLIST && all[i]!= null; i++){
                ll = Merge(ll, all[i]);
                all[i] = null;
            }
            if(i == NUMLIST)
                i--;
            all[i] = ll;
            ll = new LinkedList();
        }
        // merge array into list
        ll = new LinkedList();
        for(i = 0; i < NUMLIST; i++)
            if(all[i] != null)
                ll = Merge(ll, all[i]);
        return ll;
    }

    public static void main(String[] args) {
        final int NUMELEM = 2*1024*1024;
        LinkedList<Integer> ll = new LinkedList<>();
        Random r = new Random();
        for(int i = 0; i < NUMELEM; i++)
            ll.addLast(r.nextInt());
        long bgn, end;
        bgn = System.currentTimeMillis();
        ll = MergeSort(ll);
        end = System.currentTimeMillis();
        System.out.println("milliseconds " + (end-bgn));
        // check sort
        while(true){
            int i = ll.peek();
            ll.remove();
            if(ll.isEmpty())
                break;
            if(i > ll.peek()){
                System.out.println("error");
                break;
            }
        }
    }
}
</code>```

Body:
I want to sort a LinkedList in Java using a Mergesort algorithm.

I've researched in the internet for a solution but the algorithms I found sort either an Array or a self declared LinkedList. As I mentioned earlier I need an algorithm which sorts the standard java LinkedList (java.util.LinkedList).

In addition to my research I tried to implement one myself but I'm not capable of doing so. I was able to create the 'divide' part but I couldn't program the 'conquer' (merge in the sorted order) part.

This is my code:

private void mergeSort(LinkedList<Integer> list) {
        if (list.size() < 2){
            return;
        }
        int middleindex  = list.size()/2;
        LinkedList<Integer> [] listArr = split(list, middleindex);

        LinkedList<Integer> leftList = listArr[0];
        mergeSort(leftList);

        LinkedList<Integer> rightList = listArr[1];
        mergeSort(rightList);

        sortedMerge(rightList, leftList, list);

    }

    private void sortedMerge(LinkedList<E> right, LinkedList<E> left, LinkedList<E> list){
        //sort and merge
    }

    @SuppressWarnings("unchecked") private static <T> LinkedList<T>[] split(LinkedList<T> list, int index) {
        LinkedList<T> left = new LinkedList<>();

        for (int i = 0; i < index; i++) {
            T t = list.removeFirst();
            left.addLast(t);
        }
        return new LinkedList[] {
                left, list
        };
    }

Can someone help me and create the 'sortedMerge()' method?

Body:
Example code (including test code in main()) for a bottom up merge sort for Java LinkedList, which uses a small array (32) of lists, (as opposed to top down's approach of splitting and pushing lists onto the stack). Since Java LinkedList doesn't have the C++ equivalent of std::list::splice(), which moves nodes within a list (or from list to list), the nodes and lists are created and deleted, which adds a significant amount of overhead.

package llsort;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Random;

public class llsort {

    public static LinkedList<Integer> Merge(LinkedList<Integer> ll0, LinkedList<Integer> ll1){
        LinkedList<Integer> ll = new LinkedList<>();
        if(ll0.isEmpty())               // empty list check
            return (ll1);
        if(ll1.isEmpty())
            return (ll0);
        ListIterator <Integer> ll0i = ll0.listIterator(0);
        ListIterator <Integer> ll1i = ll1.listIterator(0);
        Integer e0;
        Integer e1;
        e0 = ll0i.next();               // merge lists
        e1 = ll1i.next();
        while(true){
            if(e0 <= e1){
                ll.add(e0);
                if(ll0i.hasNext()){
                    e0 = ll0i.next();
                    continue;
                }
                ll.add(e1);
                while(ll1i.hasNext())
                    ll.add(ll1i.next());
                break;
            }else{
                ll.add(e1);
                if(ll1i.hasNext()){
                    e1 = ll1i.next();
                    continue;
                }
                ll.add(e0);
                while(ll0i.hasNext())
                    ll.add(ll0i.next());
                break;
            }
        }
        return ll;
    }

    public static LinkedList<Integer> MergeSort(LinkedList<Integer> src){
        final int NUMLIST = 32;
        LinkedList<Integer>[] all = new LinkedList[NUMLIST];
        LinkedList<Integer> ll;
        int i;
        // merge nodes into array
        ll = new LinkedList();
        while(!src.isEmpty()){
            ll.add(src.peek());
            src.remove();
            for(i = 0; i < NUMLIST && all[i]!= null; i++){
                ll = Merge(ll, all[i]);
                all[i] = null;
            }
            if(i == NUMLIST)
                i--;
            all[i] = ll;
            ll = new LinkedList();
        }
        // merge array into list
        ll = new LinkedList();
        for(i = 0; i < NUMLIST; i++)
            if(all[i] != null)
                ll = Merge(ll, all[i]);
        return ll;
    }

    public static void main(String[] args) {
        final int NUMELEM = 2*1024*1024;
        LinkedList<Integer> ll = new LinkedList<>();
        Random r = new Random();
        for(int i = 0; i < NUMELEM; i++)
            ll.addLast(r.nextInt());
        long bgn, end;
        bgn = System.currentTimeMillis();
        ll = MergeSort(ll);
        end = System.currentTimeMillis();
        System.out.println("milliseconds " + (end-bgn));
        // check sort
        while(true){
            int i = ll.peek();
            ll.remove();
            if(ll.isEmpty())
                break;
            if(i > ll.peek()){
                System.out.println("error");
                break;
            }
        }
    }
}


来源: stackexchange

问:
convert early binding to late binding without changing object type
This seems like a simple question but I after chasing forums for several hours I think it might be impossible.

I often want to convert a  program from early binding to late binding.  Usually,  it is a vba, visual basic for applications, program that runs under Excel 2010 and windows 7 pro.

For discussion purposes, let’s pretend it is the following.

```<code>Sub EarlyBind()
   ' use IDE > Tools > references > and select “Microsoft Internet Controls”
     Dim shellWins1 as shdocvw.shellwindows
Line1:      Set shellWins1 = New SHDocVw.ShellWindows
      MsgBox TypeName(shellWins1) ' this will display “IShellWindows”
      ' other code that expects to be working with an IshellWindows object …..
 End Sub
</code>```

In my experience, converting such a program to late binding is sometimes hard.

For instance, I found some forums that suggest I change it to

```<code>Set shellwins1 = createobject("Shell.applicaton")
</code>```

But that creates a IShellDispatch5 object, not an IshellWindows object.  That means I have to change other code to accommodate the new object type.  And, of course I have to test that other code for subtle differences.

So, my goal is to find a general solution that will allow me to rewrite “Line1” to create the CORRECT object type with late binding. I also wish to avoid the need setting a reference to "Microsof Internet Controls.  In other words, I want the code to look like this:
    Sub LateBind()

```<code>Dim shellWins1 as object

Line1:      Set shellWins1 = createobject(“xxxxxx.yyyyyy”).zzzzzz

 MsgBox TypeName(shellWins1) ‘ this should display “IShellWindows”

  …..  other code that expects to be working with an IshellWindows object …..

End Sub
</code>```

I know how to use the vba IDE to find the dll associated with the object.  In this case the dll is Library SHDocVw  C:\Windows\SysWOW64\ieframe.dll.

I have installed OleView and can find the associated IshellWindows “magic numbers” for the  clsId, TypeLib, and Inteface (for instance the interface is 85CB6900-4D95-11CF-960C-0080C7F4EE85).

But, I don’t know how to convert them into a program id that can be used in line1 in the sample code posted above.

I hope someone here can help.
------ With MeHow's help, I now have the answer! ------

To switch 'set myObj = new xxxx.yyyyy' to late binding for arbitrary object types

```<code>Change  set myObj = new xxxx.yyyyy
into    set myObj = CreateObject("xxxx.yyyyy")
</code>```

Very often that will work.

But, in the some cases, (e.g. "shDocVw.ShellWindows.")  it gives error 429 ActiveX component cannot be created.

When that occurs I AM COMPLETELY OUT OF LUCK.  It is impossible to use late binding with that EXACT object class. Instead I must find a substitute class that does approximately the same thing.  (e.g. "Shell.Application").

答: There is a slightly better approach outlined at https://www.experts-exchange.com/questions/28961564/How-to-find-the-class-id-of-an-arbitrary-object-Example-Set-x-CreateObject-New-1C3B4210-F441-11CE-B9EA-00AA006B1A69.html#a41743468.</p>

ContentLicense: CC BY-SA 3.0

Body:
This seems like a simple question but I after chasing forums for several hours I think it might be impossible.

I often want to convert a  program from early binding to late binding.  Usually,  it is a vba, visual basic for applications, program that runs under Excel 2010 and windows 7 pro.

For discussion purposes, let’s pretend it is the following.

Sub EarlyBind()
   ' use IDE > Tools > references > and select “Microsoft Internet Controls”
     Dim shellWins1 as shdocvw.shellwindows
Line1:      Set shellWins1 = New SHDocVw.ShellWindows
      MsgBox TypeName(shellWins1) ' this will display “IShellWindows”
      ' other code that expects to be working with an IshellWindows object …..
 End Sub

In my experience, converting such a program to late binding is sometimes hard.

For instance, I found some forums that suggest I change it to

Set shellwins1 = createobject("Shell.applicaton")

But that creates a IShellDispatch5 object, not an IshellWindows object.  That means I have to change other code to accommodate the new object type.  And, of course I have to test that other code for subtle differences.

So, my goal is to find a general solution that will allow me to rewrite “Line1” to create the CORRECT object type with late binding. I also wish to avoid the need setting a reference to "Microsof Internet Controls.  In other words, I want the code to look like this:
    Sub LateBind()

Dim shellWins1 as object

Line1:      Set shellWins1 = createobject(“xxxxxx.yyyyyy”).zzzzzz

 MsgBox TypeName(shellWins1) ‘ this should display “IShellWindows”

  …..  other code that expects to be working with an IshellWindows object …..

End Sub

I know how to use the vba IDE to find the dll associated with the object.  In this case the dll is Library SHDocVw  C:\Windows\SysWOW64\ieframe.dll.

I have installed OleView and can find the associated IshellWindows “magic numbers” for the  clsId, TypeLib, and Inteface (for instance the interface is 85CB6900-4D95-11CF-960C-0080C7F4EE85).

But, I don’t know how to convert them into a program id that can be used in line1 in the sample code posted above.

I hope someone here can help.
------ With MeHow's help, I now have the answer! ------

To switch 'set myObj = new xxxx.yyyyy' to late binding for arbitrary object types

Change  set myObj = new xxxx.yyyyy
into    set myObj = CreateObject("xxxx.yyyyy")

Very often that will work.

But, in the some cases, (e.g. "shDocVw.ShellWindows.")  it gives error 429 ActiveX component cannot be created.

When that occurs I AM COMPLETELY OUT OF LUCK.  It is impossible to use late binding with that EXACT object class. Instead I must find a substitute class that does approximately the same thing.  (e.g. "Shell.Application").

ContentLicense: CC BY-SA 4.0


问:
How to change already added string column to a Reference in Rails
I've already created a model in Rails to collect some user information

I created the columns as :string initially but I've since changed the way this data is looked up and entered by using separate populated models.

Now instead of entering into these fields as string - i want these columns to be "references" instead.

Is there an easy way to change from the string to reference without having to create a new model entirely?

*do not need to save the existing data

答:
Wanted to add a simpler alternative to the accepted answer that preserves data:</p>

```<code>class ChangeStringToInt < ActiveRecord::Migration[5.1]
  def up
    change_column :table_name, :field_name, :integer, null: false, references: :table_referenced, using: 'field_name::integer'
    add_index :chapter_actions, :field_name
  end

  def down
    change_column :table_name, :field_name, :string, null: false, using: 'field_name::character varying'
    remove_index :table_name, :field_name
  end
end
</code>```

Body:
Wanted to add a simpler alternative to the accepted answer that preserves data:

class ChangeStringToInt < ActiveRecord::Migration[5.1]
  def up
    change_column :table_name, :field_name, :integer, null: false, references: :table_referenced, using: 'field_name::integer'
    add_index :chapter_actions, :field_name
  end

  def down
    change_column :table_name, :field_name, :string, null: false, using: 'field_name::character varying'
    remove_index :table_name, :field_name
  end
end


问:
How can I use "float: left" in a div without breaking the containing element's height?
It seems that floated HTML elements don't expand the heights of their containers. For example, consider the following code:

.portfoliosite {
    background: #777;
    padding: 10px;
    width: 550px;
}
.portfoliothumbnail {
    background: red;
    margin: 0 10px 10px 0;
    float: left;
    height: 150px;
    width: 150px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="portfoliosite">
    <div class="portfoliothumbnail"><!-- Img tag goes here --></div>
    <p class="portfoliotitle">AwesomeSite.Com</p>
    <p class="portfoliodescription">An awesome site I did. It launched on Jan 1, 2009</p>
</div></code>```

Notice how the containing div with the gray background is shorter than the red div, and the red div extends outside the container's boundaries. I'd like the containing element to expand to the size of its contents, including the floated element.

Is there an elegant solution for accomplishing this, preferably one that doesn't involve setting a fixed height or using JavaScript?

答:
You need to clear the float
Clear Fix

Some more information

OwnerDisplayName: Joshua Carmody

Body:
It seems that floated HTML elements don't expand the heights of their containers. For example, consider the following code:

.portfoliosite {
    background: #777;
    padding: 10px;
    width: 550px;
}
.portfoliothumbnail {
    background: red;
    margin: 0 10px 10px 0;
    float: left;
    height: 150px;
    width: 150px;
}

AwesomeSite.Com

An awesome site I did. It launched on Jan 1, 2009

Notice how the containing div with the gray background is shorter than the red div, and the red div extends outside the container's boundaries. I'd like the containing element to expand to the size of its contents, including the floated element.

Is there an elegant solution for accomplishing this, preferably one that doesn't involve setting a fixed height or using JavaScript?

LastEditorDisplayName: Joshua Carmody

OwnerDisplayName: NTulip

ContentLicense: CC BY-SA 2.5


问:
Need help in share point 2010
Anyone from share point 2010 developer? I am new to share point. I have requirement that I want to put few custom tab in share point list link. For example if I click Registration (custom list) link that page will open there I want to place some custom tab like Employee Department…etc

By default when page will open Employee tab will be highlighted and employee registration page will be opened and department registration page will be hidden. And When Department tab is clicked department registration page will be opened and employee registration page will be hidden.

How can I achieve this functionality and how to give the link from tab to corresponding registration page?

Your help is always heartily appreciated.

Thanks,

sumit

答:
Sounds like you might want a custom web part.  Take a look at these links to get started:

http://blog.concurrency.com/sharepoint/create-a-custom-web-part-for-sharepoint-2010/

http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/02/15/intro-to-sharepoint-2010-development-how-to-build-and-deploy-a-web-part.aspx

Things are much easier in 2010 than in 2007 especially for someone getting started with SharePoint.

Title: Need help in share point 2010


问:
Visual Studio 2019 (itself): Exception Has Been Thrown By The Target of an Invocation
Last night I installed Visual Studio 2019 Enterprise, installed most of my usual extensions and played around bit, without issue. Shut it down, then this morning when I fired it back up, just after the VS splash screen I get this:

After that, VS just exits. I've tried running VS in /safemode but the same thing happens. After running ProcDump (Procdump64.exe -w devenv.exe -e 1 -n 1000 -f *TargetInvocationException* -ma > out.txt) no .dmp files are created, but the out.txt file shows this:

```<code>Waiting for process named devenv.exe...

Process:               devenv.exe (10576)
Process image:         C:\Coding\IDE\VS2019\Common7\IDE\devenv.exe
CPU threshold:         n/a
Performance counter:   n/a
Commit threshold:      n/a
Threshold seconds:     n/a
Hung window check:     Disabled
Log debug strings:     Disabled
Exception monitor:     First Chance+Unhandled
Exception filter:      [Includes]
                       *TargetInvocationException*
                       [Excludes]
Terminate monitor:     Disabled
Cloning type:          Disabled
Concurrent limit:      n/a
Avoid outage:          n/a
Number of dumps:       1000
Dump folder:           C:\Downloads\
Dump filename/mask:    PROCESSNAME_YYMMDD_HHMMSS
Queue to WER:          Disabled
Kill after dump:       Disabled

Press Ctrl-C to end monitoring without terminating the process.

[16:33:52] Exception: 04242420
[16:33:53] Exception: E0434352.CLR
[16:33:53] Exception: E0434352.CLR
[16:33:53] Exception: E0434352.CLR
[16:33:53] Exception: E0434352.CLR
[16:33:56] Exception: E0434352.CLR
[16:33:56] Exception: E0434352.CLR
[16:33:56] Exception: E0434352.CLR
[16:33:56] Exception: E0434352.CLR
[16:33:56] Exception: E06D7363.msc
[16:33:56] Exception: E0434352.CLR
[16:33:56] Exception: E0434352.CLR
[16:33:56] Exception: E0434352.CLR
[16:33:56] Exception: E0434352.CLR
[16:33:57] The process has exited.
[16:33:57] Dump count not reached.
</code>```

I've also tried running sfc /scannow, devenv /updateconfiguration, checking for any new Windows updates, and running VS as Admin, but still stuck at this spot. Until I get this fixed Visual Studio 2019 is useless to me. Anyone know of a solution?

答: Well, while I still have no idea what exactly got screwed up, after waiting a while, I decided to try a re-install over the top of the previous installation in hopes of it fixing itself; running the installer showed there's an update to VS 2019 as well as an update to VS 2017, so I updated both and when it was all done vs 2019 was able to start again.</p>

Body:
Last night I installed Visual Studio 2019 Enterprise, installed most of my usual extensions and played around bit, without issue. Shut it down, then this morning when I fired it back up, just after the VS splash screen I get this:

After that, VS just exits. I've tried running VS in /safemode but the same thing happens. After running ProcDump (Procdump64.exe -w devenv.exe -e 1 -n 1000 -f *TargetInvocationException* -ma > out.txt) no .dmp files are created, but the out.txt file shows this:

Waiting for process named devenv.exe...

Process:               devenv.exe (10576)
Process image:         C:\Coding\IDE\VS2019\Common7\IDE\devenv.exe
CPU threshold:         n/a
Performance counter:   n/a
Commit threshold:      n/a
Threshold seconds:     n/a
Hung window check:     Disabled
Log debug strings:     Disabled
Exception monitor:     First Chance+Unhandled
Exception filter:      [Includes]
                       *TargetInvocationException*
                       [Excludes]
Terminate monitor:     Disabled
Cloning type:          Disabled
Concurrent limit:      n/a
Avoid outage:          n/a
Number of dumps:       1000
Dump folder:           C:\Downloads\
Dump filename/mask:    PROCESSNAME_YYMMDD_HHMMSS
Queue to WER:          Disabled
Kill after dump:       Disabled

Press Ctrl-C to end monitoring without terminating the process.

[16:33:52] Exception: 04242420
[16:33:53] Exception: E0434352.CLR
[16:33:53] Exception: E0434352.CLR
[16:33:53] Exception: E0434352.CLR
[16:33:53] Exception: E0434352.CLR
[16:33:56] Exception: E0434352.CLR
[16:33:56] Exception: E0434352.CLR
[16:33:56] Exception: E0434352.CLR
[16:33:56] Exception: E0434352.CLR
[16:33:56] Exception: E06D7363.msc
[16:33:56] Exception: E0434352.CLR
[16:33:56] Exception: E0434352.CLR
[16:33:56] Exception: E0434352.CLR
[16:33:56] Exception: E0434352.CLR
[16:33:57] The process has exited.
[16:33:57] Dump count not reached.

I've also tried running sfc /scannow, devenv /updateconfiguration, checking for any new Windows updates, and running VS as Admin, but still stuck at this spot. Until I get this fixed Visual Studio 2019 is useless to me. Anyone know of a solution?


问:
Implement yoast seo in vue.js
How can I implement yoast seo in vue.js?
I try to search an information in google but I could not found anything related. Do anyone have recommend?</p>

答:
it's a quite complex topic. You either need an SSR setup (e.g. using Nuxt.js) or (what's actually better) you use either this theme:

http://vue-wordpress-demo.bshiluk.com

https://github.com/bucky355/vue-wordpress

or this:

https://wue-theme.tech-nomad.de

https://github.com/Tech-Nomad/wue-theme

The latter one is made by myself due to problems coming with Nuxt.js (window object, keep-alive not working, extra node.js server, not being able to use all the PHP templates). At the time I've started working on it the bucky355 theme didn't exist but it's quite similar to my. Even though I would consider my theme  as more simple to use.

Title: Implement yoast seo in vue.js


问:
Powershell script to create security groups in Azure Active Directory to manage access to Azure SQL
Below is a script that creates groups in Azure AD and then assigns SQL roles to the groups. The script has a dependency on ODBC 17 and sqlcmd utility version 15 and this makes it a bit hard to use in an Azure devops pipeline. I was wondering if someone knows any alternative powershell cmdlets that I can use run the queries in the script against SQL. I have tried the invoke-sqlcmd but ran into an issue trying to authenticate using an onmicrosoft account. when using the sql admin user that you create with the SQL database I can run the commands to set the permissions on the target database but are not able to run the sql query that creates the groups (FROM EXTERNAL PROVIDER) in the master database. So I am a little stuck. The Idea is the add the script to a deployment pipeline and have it automate the creation of AAD groups that will allow operations teams to manage user access to the database. Please help :-)
                <#
                .SYNOPSIS
                    Creates AAD Groups that is used to control access to SQL Server and Database resources</p>

```<code>            .DESCRIPTION
                Based on the SQL Server and Database supplied as a input the script will create the required AAD groups required for every Azure SQL Server

            .INPUTS
                sqlServerName: Name of the sql server (IAAS) or the sql server instance (PAAS)
                sqlDatabaseName: Name of the database
                custom_vars_envResourceGroupName : Resource group the sql server resides in
                sqlAdminUser:
                sqlAdminPassword
                ProjectId
                EnvironmentId
            .OUTPUTS
                Names of the AAD groups that was created

            .NOTES
                Script assumes that it is running in a session that is already connected to Azure RM TODO: Test least privilage
                Script assumes that it is running in a session that is already connected to Azure RM with contributor RBAC rights on the resource group TODO: Test least privilage
                If you are running this manually you need to add the sqlAdmin user into the Server admim group**** TODO: Still need to get the this automated to used the Azure DevOps Service Principle.
                Dont try this with a microsoft account it needs a AAD account to work on the db authenication
                If the qlAdminPassword is passed using clear text dont user "$" or "&" or "/" as special characters in the password.
            .EXAMPLE
            $sqlAdminPasswordnotsecure = "lhfuhwe48234#E"
            $sqlAdminSecurePassword = ConvertTo-SecureString $sqlAdminPasswordnotsecure -AsPlainText -Force
            #.\sqlAADGroupsCreator.ps1 `
                -custom_vars_envResourceGroupName "<Resource Group>"
                -sqlServerName "<Servername>"
                -sqlAdminUser "<eg sqlAdminUser@companydirectory.onmicrosoft.com>"
                -sqlAdminSecurePassword "<complex password>"
                -sqlDatabaseName "<database name>"
                -ProjectId "<Name of project>"
                -EnvironmentId "<environment>"
            #>

            #region parameters
            Param(
                [Parameter(Mandatory = $True)][string]$custom_vars_envResourceGroupName,
                [Parameter(Mandatory = $True)][string]$sqlServerName,
                [Parameter(Mandatory = $True)][string]$sqlAdminUser,
                [Parameter(Mandatory = $True)][securestring]$sqlAdminSecurePassword,
                [Parameter(Mandatory = $True)][string]$sqlDatabaseName,
                [Parameter(Mandatory = $True)][string]$ProjectId,
                [Parameter(Mandatory = $True)][string]$EnvironmentId
            )
            $ErrorActionPreference = "Stop"
            #endregion parameters
            #region secureStringConversion
            #Convert secure string back to plain text to be used in SQL connection
            function Get-PlainText() {
                [CmdletBinding()]
                param
                (
                    [parameter(Mandatory = $true)]
                    [System.Security.SecureString]$SecureString
                )
                BEGIN { }
                PROCESS {
                    $bstr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecureString);

                    try {
                        return [Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr);
                    }
                    finally {
                        [Runtime.InteropServices.Marshal]::FreeBSTR($bstr);
                    }
                }
                END { }
            }

            #Call The function
            $sqlAdminPassword = get-plaintext -SecureString $sqlAdminSecurePassword
            #endregion secureStringConversion
            #region manualParameter
            <#Variables that can be used during testing or running manual
            $custom_vars_envResourceGroupName   = "MATA-APP-0-0-COMMON"
            $sqlServerName = "<server name>"
            $sqlAdminUser = "<SqlAdmin@educationtestgovtnz.onmicrosoft.com>"
            $sqlAdminPassword = "<complex password>"
            $sqlDatabaseName = "<database name>"
            $EnvironmentId = "<environment variable"
            $ProjectId ="<application name or abreviation>"
            #>
            #endregion manualParameter
            #region aadGroupsCreation.
            #Build up database server Url
            $sqlServerURL = $sqlServerName + ".database.windows.net"
            ###Create AAD Groups based on resource group name
            $sqlAdminGroupName = $sqlReadGroupName = $sqlDbContributorGroupName = $sqlDbReadGroupName = ""
            $sqlAdminGroupName = "AL SQL " + ($ProjectId.ToUpper()) + " " + ($EnvironmentId.ToUpper()) + " Admin"
            $sqlReadGroupName = "AL SQL " + ($ProjectId.ToUpper()) + " " + ($EnvironmentId.ToUpper()) + " Read"
            $sqlDbContributorGroupName = "AL DB " + ($sqlServerName.ToUpper()) + " " + ($sqlDatabaseName.ToUpper()) + " Contributor"
            $sqlDbReadGroupName = "AL DB " + ($sqlServerName.ToUpper()) + " " + ($sqlDatabaseName.ToUpper()) + " Read"

            ###Create the Groups in Azure AD if they dont exist then assign access roles to Resource Group
            #SQL LEVEL ADMIN And DB OWNER#
            #Create new group for Owner
            if ($sqlAdminGroupName -ne ((Get-AzureRmADGroup -SearchString $sqlAdminGroupName).displayname)) {
                #$slqAdminGroupDiscription = "Server Admin and database owner access to "+ $sqlServerName
                New-AzureRmADGroup `
                    -DisplayName $sqlAdminGroupName `
                    -MailNickName "NotSet"
            }

            #Update group membership of sqlAdmin group
            $groupUser = Get-AzureRmADGroupMember -GroupDisplayName $sqlAdminGroupName
            if ($sqlAdminUser -ne ($groupUser.UserPrincipalName)) {
                Add-AzureRmADGroupMember -MemberUserPrincipalName $sqlAdminUser -TargetGroupDisplayName $sqlAdminGroupName
            }
            #DB LEVEL CONTRIBUTOR###
            #Create new group for Contributor
            if ($sqlDbContributorGroupName -ne ((Get-AzureRmADGroup -SearchString $sqlDbContributorGroupName).displayname)) {
                #$sqlContributorGroupDiscription = "Contributor access to "+ $sqlDatabase
                New-AzureRmADGroup `
                    -DisplayName $sqlDbContributorGroupName `
                    -MailNickName "NotSet"
            }

            #SQL LEVEL READER###
            #Create new group for ReadOnly
            if ($sqlReadGroupName -ne ((Get-AzureRmADGroup -SearchString $sqlReadGroupName).displayname)) {
                #$RGReadOnlygroupDiscription = "Read Only access to "+ $sqlDatabase
                New-AzureRmADGroup `
                    -DisplayName $sqlReadGroupName `
                    -MailNickName "NotSet"
            }

            #DB LEVEL READER###
            #Create new group for ReadOnly
            if ($sqlDbReadGroupName -ne ((Get-AzureRmADGroup -SearchString $sqlDbReadGroupName).displayname)) {
                #$RGReadOnlygroupDiscription = "Read Only access to "+ $sqlDatabase
                New-AzureRmADGroup `
                    -DisplayName $sqlDbReadGroupName `
                    -MailNickName "NotSet"
            }
            #endregion aadGroupsCreation.
            #region setDbPermissions
            #Enable Azure AD Administrator on the SQL server (SQL / AAD Integration)
            $sqlAdminGroupNameId = (Get-AzureRmADGroup -DisplayName $sqlAdminGroupName).Id
            Set-AzureRmSqlServerActiveDirectoryAdministrator -ResourceGroupName  $custom_vars_envResourceGroupName  -ServerName $sqlServerName -DisplayName $sqlAdminGroupName -ObjectId $sqlAdminGroupNameID

            #SQL Query to create the AAD groups in SQL master and map the appropriate roles to the AAD Groups
            $createSQLUsersQuery = ""
            $createSQLUsersQuery = @"
            CREATE USER [$sqlDbContributorGroupName] FROM EXTERNAL PROVIDER;
            CREATE USER [$sqlReadGroupName] FROM EXTERNAL PROVIDER;
            CREATE USER [$sqlDbReadGroupName] FROM EXTERNAL PROVIDER;
            "@
            #Connect to SQL sever and configure the SQL Sever level logins
            Sqlcmd -S $sqlServerURL -d master -U $sqlAdminUser -P $sqlAdminPassword -G -Q $createSQLUsersQuery

            #SQL Query to create the AAD groups in targeted sqldatabase
            $createSQLDBUsersQuery = ""
            $createSQLDBUsersQuery = @"
            CREATE USER [$sqlAdminGroupName] FROM EXTERNAL PROVIDER;
            CREATE USER [$sqlDbContributorGroupName] FROM EXTERNAL PROVIDER;
            CREATE USER [$sqlReadGroupName] FROM EXTERNAL PROVIDER;
            CREATE USER [$sqlDbReadGroupName] FROM EXTERNAL PROVIDER;
            "@
            #Connect to SQL sever and configure the SQL database level logins
            Sqlcmd -S $sqlServerURL -d $sqlDatabaseName -U $sqlAdminUser -P $sqlAdminPassword -G -Q $createSQLDBUsersQuery

            #SQL Query to set the database level permissions in targeted sqldatabase
            $setSQLDBPermissionsQuery = ""
            $setSQLDBPermissionsQuery = @"
            ALTER ROLE db_owner ADD MEMBER [$sqlAdminGroupName]
            ALTER ROLE db_datareader ADD MEMBER [$sqlReadGroupName]
            ALTER ROLE db_datawriter ADD MEMBER [$sqlDbContributorGroupName]
            ALTER ROLE db_datareader ADD MEMBER [$sqlDbContributorGroupName]
            ALTER ROLE db_datareader ADD MEMBER [$sqlDbReadGroupName]
            "@
            #Connect to SQL sever and configure the SQL database level permissions
            Sqlcmd -S $sqlServerURL -d $sqlDatabaseName -U $sqlAdminUser -P $sqlAdminPassword -G -Q $setSQLDBPermissionsQuery
            #endregion setDbPermissions
</code>```

答:
I think your issue is that you are attempting to run the following T-SQL as the SQL Admin and not the AD Admin that has been configured for your Azure SQL Database instance.

To create an Azure AD-based contained database user (other than the server administrator that owns the database), connect to the database with an Azure AD identity, as a user with at least the ALTER ANY USER permission. Then use the following Transact-SQL syntax:

```<code>CREATE USER <Azure_AD_principal_name> FROM EXTERNAL PROVIDER;
</code>```

Please see this document as it is the primary doc for configuring Azure AD for Azure SQL Database (Single Instance/Elastic Pools), Managed Instance, and Data Warehouse.

As for PowerShell cmdlets, please be aware that AzureRM.sql (supported through 2020) is being deprecated and Az.sql is the new module. More information about the Azure CLI (Link).

For automation scenarios, you need to create credentials from a user name and secure string:

$passwd = ConvertTo-SecureString use a secure password here -AsPlainText -Force
$pscredential = New-Object System.Management.Automation.PSCredential('service principal name/id', $passwd)
Connect-AzAccount -ServicePrincipal -Credential $pscredential -TenantId $tenantId

$params = @{
    'Query' = 'CREATE USER  FROM EXTERNAL PROVIDER'
    'ConnectionString' = 'Data Source=MYSERVER;Initial Catalog=MyDatabase;Integrated Security=True'
}

Invoke-Sqlcmd @params

Body:
Below is a script that creates groups in Azure AD and then assigns SQL roles to the groups. The script has a dependency on ODBC 17 and sqlcmd utility version 15 and this makes it a bit hard to use in an Azure devops pipeline. I was wondering if someone knows any alternative powershell cmdlets that I can use run the queries in the script against SQL. I have tried the invoke-sqlcmd but ran into an issue trying to authenticate using an onmicrosoft account. when using the sql admin user that you create with the SQL database I can run the commands to set the permissions on the target database but are not able to run the sql query that creates the groups (FROM EXTERNAL PROVIDER) in the master database. So I am a little stuck. The Idea is the add the script to a deployment pipeline and have it automate the creation of AAD groups that will allow operations teams to manage user access to the database. Please help :-)
                <#
                .SYNOPSIS
                    Creates AAD Groups that is used to control access to SQL Server and Database resources

            .DESCRIPTION
                Based on the SQL Server and Database supplied as a input the script will create the required AAD groups required for every Azure SQL Server

            .INPUTS
                sqlServerName: Name of the sql server (IAAS) or the sql server instance (PAAS)
                sqlDatabaseName: Name of the database
                custom_vars_envResourceGroupName : Resource group the sql server resides in
                sqlAdminUser:
                sqlAdminPassword
                ProjectId
                EnvironmentId
            .OUTPUTS
                Names of the AAD groups that was created

            .NOTES
                Script assumes that it is running in a session that is already connected to Azure RM TODO: Test least privilage
                Script assumes that it is running in a session that is already connected to Azure RM with contributor RBAC rights on the resource group TODO: Test least privilage
                If you are running this manually you need to add the sqlAdmin user into the Server admim group**** TODO: Still need to get the this automated to used the Azure DevOps Service Principle.
                Dont try this with a microsoft account it needs a AAD account to work on the db authenication
                If the qlAdminPassword is passed using clear text dont user "$" or "&" or "/" as special characters in the password.
            .EXAMPLE
            $sqlAdminPasswordnotsecure = "lhfuhwe48234#E"
            $sqlAdminSecurePassword = ConvertTo-SecureString $sqlAdminPasswordnotsecure -AsPlainText -Force
            #.\sqlAADGroupsCreator.ps1 `
                -custom_vars_envResourceGroupName "<Resource Group>"
                -sqlServerName "<Servername>"
                -sqlAdminUser "<eg sqlAdminUser@companydirectory.onmicrosoft.com>"
                -sqlAdminSecurePassword "<complex password>"
                -sqlDatabaseName "<database name>"
                -ProjectId "<Name of project>"
                -EnvironmentId "<environment>"
            #>

            #region parameters
            Param(
                [Parameter(Mandatory = $True)][string]$custom_vars_envResourceGroupName,
                [Parameter(Mandatory = $True)][string]$sqlServerName,
                [Parameter(Mandatory = $True)][string]$sqlAdminUser,
                [Parameter(Mandatory = $True)][securestring]$sqlAdminSecurePassword,
                [Parameter(Mandatory = $True)][string]$sqlDatabaseName,
                [Parameter(Mandatory = $True)][string]$ProjectId,
                [Parameter(Mandatory = $True)][string]$EnvironmentId
            )
            $ErrorActionPreference = "Stop"
            #endregion parameters
            #region secureStringConversion
            #Convert secure string back to plain text to be used in SQL connection
            function Get-PlainText() {
                [CmdletBinding()]
                param
                (
                    [parameter(Mandatory = $true)]
                    [System.Security.SecureString]$SecureString
                )
                BEGIN { }
                PROCESS {
                    $bstr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecureString);

                    try {
                        return [Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr);
                    }
                    finally {
                        [Runtime.InteropServices.Marshal]::FreeBSTR($bstr);
                    }
                }
                END { }
            }

            #Call The function
            $sqlAdminPassword = get-plaintext -SecureString $sqlAdminSecurePassword
            #endregion secureStringConversion
            #region manualParameter
            <#Variables that can be used during testing or running manual
            $custom_vars_envResourceGroupName   = "MATA-APP-0-0-COMMON"
            $sqlServerName = "<server name>"
            $sqlAdminUser = "<SqlAdmin@educationtestgovtnz.onmicrosoft.com>"
            $sqlAdminPassword = "<complex password>"
            $sqlDatabaseName = "<database name>"
            $EnvironmentId = "<environment variable"
            $ProjectId ="<application name or abreviation>"
            #>
            #endregion manualParameter
            #region aadGroupsCreation.
            #Build up database server Url
            $sqlServerURL = $sqlServerName + ".database.windows.net"
            ###Create AAD Groups based on resource group name
            $sqlAdminGroupName = $sqlReadGroupName = $sqlDbContributorGroupName = $sqlDbReadGroupName = ""
            $sqlAdminGroupName = "AL SQL " + ($ProjectId.ToUpper()) + " " + ($EnvironmentId.ToUpper()) + " Admin"
            $sqlReadGroupName = "AL SQL " + ($ProjectId.ToUpper()) + " " + ($EnvironmentId.ToUpper()) + " Read"
            $sqlDbContributorGroupName = "AL DB " + ($sqlServerName.ToUpper()) + " " + ($sqlDatabaseName.ToUpper()) + " Contributor"
            $sqlDbReadGroupName = "AL DB " + ($sqlServerName.ToUpper()) + " " + ($sqlDatabaseName.ToUpper()) + " Read"

            ###Create the Groups in Azure AD if they dont exist then assign access roles to Resource Group
            #SQL LEVEL ADMIN And DB OWNER#
            #Create new group for Owner
            if ($sqlAdminGroupName -ne ((Get-AzureRmADGroup -SearchString $sqlAdminGroupName).displayname)) {
                #$slqAdminGroupDiscription = "Server Admin and database owner access to "+ $sqlServerName
                New-AzureRmADGroup `
                    -DisplayName $sqlAdminGroupName `
                    -MailNickName "NotSet"
            }

            #Update group membership of sqlAdmin group
            $groupUser = Get-AzureRmADGroupMember -GroupDisplayName $sqlAdminGroupName
            if ($sqlAdminUser -ne ($groupUser.UserPrincipalName)) {
                Add-AzureRmADGroupMember -MemberUserPrincipalName $sqlAdminUser -TargetGroupDisplayName $sqlAdminGroupName
            }
            #DB LEVEL CONTRIBUTOR###
            #Create new group for Contributor
            if ($sqlDbContributorGroupName -ne ((Get-AzureRmADGroup -SearchString $sqlDbContributorGroupName).displayname)) {
                #$sqlContributorGroupDiscription = "Contributor access to "+ $sqlDatabase
                New-AzureRmADGroup `
                    -DisplayName $sqlDbContributorGroupName `
                    -MailNickName "NotSet"
            }

            #SQL LEVEL READER###
            #Create new group for ReadOnly
            if ($sqlReadGroupName -ne ((Get-AzureRmADGroup -SearchString $sqlReadGroupName).displayname)) {
                #$RGReadOnlygroupDiscription = "Read Only access to "+ $sqlDatabase
                New-AzureRmADGroup `
                    -DisplayName $sqlReadGroupName `
                    -MailNickName "NotSet"
            }

            #DB LEVEL READER###
            #Create new group for ReadOnly
            if ($sqlDbReadGroupName -ne ((Get-AzureRmADGroup -SearchString $sqlDbReadGroupName).displayname)) {
                #$RGReadOnlygroupDiscription = "Read Only access to "+ $sqlDatabase
                New-AzureRmADGroup `
                    -DisplayName $sqlDbReadGroupName `
                    -MailNickName "NotSet"
            }
            #endregion aadGroupsCreation.
            #region setDbPermissions
            #Enable Azure AD Administrator on the SQL server (SQL / AAD Integration)
            $sqlAdminGroupNameId = (Get-AzureRmADGroup -DisplayName $sqlAdminGroupName).Id
            Set-AzureRmSqlServerActiveDirectoryAdministrator -ResourceGroupName  $custom_vars_envResourceGroupName  -ServerName $sqlServerName -DisplayName $sqlAdminGroupName -ObjectId $sqlAdminGroupNameID

            #SQL Query to create the AAD groups in SQL master and map the appropriate roles to the AAD Groups
            $createSQLUsersQuery = ""
            $createSQLUsersQuery = @"
            CREATE USER [$sqlDbContributorGroupName] FROM EXTERNAL PROVIDER;
            CREATE USER [$sqlReadGroupName] FROM EXTERNAL PROVIDER;
            CREATE USER [$sqlDbReadGroupName] FROM EXTERNAL PROVIDER;
            "@
            #Connect to SQL sever and configure the SQL Sever level logins
            Sqlcmd -S $sqlServerURL -d master -U $sqlAdminUser -P $sqlAdminPassword -G -Q $createSQLUsersQuery

            #SQL Query to create the AAD groups in targeted sqldatabase
            $createSQLDBUsersQuery = ""
            $createSQLDBUsersQuery = @"
            CREATE USER [$sqlAdminGroupName] FROM EXTERNAL PROVIDER;
            CREATE USER [$sqlDbContributorGroupName] FROM EXTERNAL PROVIDER;
            CREATE USER [$sqlReadGroupName] FROM EXTERNAL PROVIDER;
            CREATE USER [$sqlDbReadGroupName] FROM EXTERNAL PROVIDER;
            "@
            #Connect to SQL sever and configure the SQL database level logins
            Sqlcmd -S $sqlServerURL -d $sqlDatabaseName -U $sqlAdminUser -P $sqlAdminPassword -G -Q $createSQLDBUsersQuery

            #SQL Query to set the database level permissions in targeted sqldatabase
            $setSQLDBPermissionsQuery = ""
            $setSQLDBPermissionsQuery = @"
            ALTER ROLE db_owner ADD MEMBER [$sqlAdminGroupName]
            ALTER ROLE db_datareader ADD MEMBER [$sqlReadGroupName]
            ALTER ROLE db_datawriter ADD MEMBER [$sqlDbContributorGroupName]
            ALTER ROLE db_datareader ADD MEMBER [$sqlDbContributorGroupName]
            ALTER ROLE db_datareader ADD MEMBER [$sqlDbReadGroupName]
            "@
            #Connect to SQL sever and configure the SQL database level permissions
            Sqlcmd -S $sqlServerURL -d $sqlDatabaseName -U $sqlAdminUser -P $sqlAdminPassword -G -Q $setSQLDBPermissionsQuery
            #endregion setDbPermissions

Body:
I think your issue is that you are attempting to run the following T-SQL as the SQL Admin and not the AD Admin that has been configured for your Azure SQL Database instance.

To create an Azure AD-based contained database user (other than the server administrator that owns the database), connect to the database with an Azure AD identity, as a user with at least the ALTER ANY USER permission. Then use the following Transact-SQL syntax:

CREATE USER <Azure_AD_principal_name> FROM EXTERNAL PROVIDER;

Please see this document as it is the primary doc for configuring Azure AD for Azure SQL Database (Single Instance/Elastic Pools), Managed Instance, and Data Warehouse.

As for PowerShell cmdlets, please be aware that AzureRM.sql (supported through 2020) is being deprecated and Az.sql is the new module. More information about the Azure CLI (Link).

For automation scenarios, you need to create credentials from a user name and secure string:

$passwd = ConvertTo-SecureString use a secure password here -AsPlainText -Force
$pscredential = New-Object System.Management.Automation.PSCredential('service principal name/id', $passwd)
Connect-AzAccount -ServicePrincipal -Credential $pscredential -TenantId $tenantId

$params = @{
    'Query' = 'CREATE USER  FROM EXTERNAL PROVIDER'
    'ConnectionString' = 'Data Source=MYSERVER;Initial Catalog=MyDatabase;Integrated Security=True'
}

Invoke-Sqlcmd @params


问:
Deployed ASP.Net application not returning data
Please excuse my lack of information over the subject as this is my first site I am trying to deploy on IIS.

A little background information

I have deployed an ASP.Net MVC web application to our locally hosted IIS server. This application uses some csv files stored on a different server called our G drive. Users using this application will be various engineers from my work place that are directly connected to the network and or VPN in.

When running the code locally on my machine in IIS Express, I get data returned just fine from my services I wrote for pulling the csv data. As soon as I deploy and reach the site, if I try to call the function to  pull data I get nothing returned.

What I have checked

I have checked the network tab to ensure the request is going through. See picture below.

The only difference is no data is coming back.

Settings I have tried

Enabled Windows Authentication on IIS

Enabled Anonymous Authentication on IIS

Web app information

In the web app in visual studio if I look at the properties I have enabled Anonymous authentication.

The Question

Am I missing some kind of authentication or need to add authentication to the IIS server? As I said I can reach the website just fine, its just any calls to retrieve data from the G drive returns nothing.

I believe it has to do with the fact our G drive requires users to be authenticated (through windows authentication) in order to access the hard drives. So how would I go about setting up the IIS server and ASP.Net web app for this?

UPDATE

I was in fact catching the error in the application. When changed to just throw the error I get an internal server error.

答:
When you run application on your machine in IISExpress it runs under your authentication and is able to read G drive.

For IIS to do something similar, you will need to ask your network admin to create an account specifically for your application and give it access to your G drive. Then in IIS create an application pool and run it under that newly created account. And finally run your application in IIS under that newly created pool.


问:
5 Column background DIV to fill empty space
I need all of my columns on a page to appear be the same height. I'd be fine doing this if there were just one background colour but there are 5, taking up 20% of the width each on a desktop.

.container {
    display: table;
    float: left;
    width: 100%;
    background: linear-gradient(to right,  #91F5AD 20%, #8FBFE0 20%, #7C77B9 20%, #0BC9CD 20%, #05A8AA 20%);
}

.col1 {
    float: left;
    width: 20%;
    background-color: #91F5AD;
}

@media only screen and (max-width: 500px) {
.col1{
    float: left;
    width: 100%;
    background-color: #91F5AD;
}
}

.col2 {
    float: left;
    width: 20%;
    background-color: #8FBFE0;
}

@media only screen and (max-width: 500px) {
.col2{
    float: left;
    width: 100%;
    background-color: #8FBFE0;
}
}

.col3 {
    float: left;
    width: 20%;
    background-color: #7C77B9;
}

@media only screen and (max-width: 500px) {
.col3{
    float: left;
    width: 100%;
    background-color: #7C77B9;
}
}

.col4 {
    float: left;
    width: 20%;
    background-color: #0BC9CD;
}

@media only screen and (max-width: 500px) {
.col4{
    float: left;
    width: 100%;
    background-color: #0BC9CD;
}
}

.col5 {
    float: left;
    width: 20%;
    background-color: #05A8AA;
}

@media only screen and (max-width: 500px) {
.col5{
    float: left;
    width: 100%;
    background-color: #05A8AA;
}
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="container">
<div class="col1"><br></div>
<div class="col2"><br></div>
<div class="col3"><br></div>
<div class="col4"><br></div>
<div class="col5"><br></div>
</div></code>```

I need the container to replicate the pattern of the DIV backgrounds in order to make it seem as though they're all the same height.

If you see below, you'll see the issue.

    .container {
        display: table;
        float: left;
        width: 100%;
        background: linear-gradient(to right,  #91F5AD 20%, #8FBFE0 20%, #7C77B9 20%, #0BC9CD 20%, #05A8AA 20%);
    }

    .col1 {
        float: left;
        width: 20%;
        background-color: #91F5AD;
    }

    @media only screen and (max-width: 500px) {
    .col1{
        float: left;
        width: 100%;
        background-color: #91F5AD;
    }
    }

    .col2 {
        float: left;
        width: 20%;
        background-color: #8FBFE0;
    }

    @media only screen and (max-width: 500px) {
    .col2{
        float: left;
        width: 100%;
        background-color: #8FBFE0;
    }
    }

    .col3 {
        float: left;
        width: 20%;
        background-color: #7C77B9;
    }

    @media only screen and (max-width: 500px) {
    .col3{
        float: left;
        width: 100%;
        background-color: #7C77B9;
    }
    }

    .col4 {
        float: left;
        width: 20%;
        background-color: #0BC9CD;
    }

    @media only screen and (max-width: 500px) {
    .col4{
        float: left;
        width: 100%;
        background-color: #0BC9CD;
    }
    }

    .col5 {
        float: left;
        width: 20%;
        background-color: #05A8AA;
    }

    @media only screen and (max-width: 500px) {
    .col5{
        float: left;
        width: 100%;
        background-color: #05A8AA;
    }
    }```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="container">
<div class="col1"><br></div>
<div class="col2"><br></div>
<div class="col3"><br></div>
<div class="col4"><br></div>
<div class="col5"><br></div>
<br><br>
</div>
<p>The green is fine but the rest don't match above themselves</p></code>```

Any help would be appreciated. Thanks in advance.

答:
You are doing a lot of css stuff that makes me wonder if my submission will be sufficient, but:

.container {
  display: flex;
  flex-wrap: wrap;
  height: 100px; // or whatever
}

.container div {
  width: 20%;
  height: 100%;
}

.col1 {
  background-color: red; //or whatever
}

.col2 {
  background-color: orange; //or whatever
}

.col3 {
  background-color: yellow; //or whatever
}

.col4 {
  background-color: blue; //or whatever
}

.col5 {
  background-color: indigo; //or whatever
}

.container .content {
  width: 100%;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="container">
<div class="col1"><br></div>
<div class="col2"><br></div>
<div class="col3"><br></div>
<div class="col4"><br></div>
<div class="col5"><br></div>
<div class="content">Put whatever you want here, including other elements</div>
</div></code>```

Body:
I need all of my columns on a page to appear be the same height. I'd be fine doing this if there were just one background colour but there are 5, taking up 20% of the width each on a desktop.

.container {
    display: table;
    float: left;
    width: 100%;
    background: linear-gradient(to right,  #91F5AD 20%, #8FBFE0 20%, #7C77B9 20%, #0BC9CD 20%, #05A8AA 20%);
}

.col1 {
    float: left;
    width: 20%;
    background-color: #91F5AD;
}

@media only screen and (max-width: 500px) {
.col1{
    float: left;
    width: 100%;
    background-color: #91F5AD;
}
}

.col2 {
    float: left;
    width: 20%;
    background-color: #8FBFE0;
}

@media only screen and (max-width: 500px) {
.col2{
    float: left;
    width: 100%;
    background-color: #8FBFE0;
}
}

.col3 {
    float: left;
    width: 20%;
    background-color: #7C77B9;
}

@media only screen and (max-width: 500px) {
.col3{
    float: left;
    width: 100%;
    background-color: #7C77B9;
}
}

.col4 {
    float: left;
    width: 20%;
    background-color: #0BC9CD;
}

@media only screen and (max-width: 500px) {
.col4{
    float: left;
    width: 100%;
    background-color: #0BC9CD;
}
}

.col5 {
    float: left;
    width: 20%;
    background-color: #05A8AA;
}

@media only screen and (max-width: 500px) {
.col5{
    float: left;
    width: 100%;
    background-color: #05A8AA;
}
}

I need the container to replicate the pattern of the DIV backgrounds in order to make it seem as though they're all the same height.

If you see below, you'll see the issue.

    .container {
        display: table;
        float: left;
        width: 100%;
        background: linear-gradient(to right,  #91F5AD 20%, #8FBFE0 20%, #7C77B9 20%, #0BC9CD 20%, #05A8AA 20%);
    }

    .col1 {
        float: left;
        width: 20%;
        background-color: #91F5AD;
    }

    @media only screen and (max-width: 500px) {
    .col1{
        float: left;
        width: 100%;
        background-color: #91F5AD;
    }
    }

    .col2 {
        float: left;
        width: 20%;
        background-color: #8FBFE0;
    }

    @media only screen and (max-width: 500px) {
    .col2{
        float: left;
        width: 100%;
        background-color: #8FBFE0;
    }
    }

    .col3 {
        float: left;
        width: 20%;
        background-color: #7C77B9;
    }

    @media only screen and (max-width: 500px) {
    .col3{
        float: left;
        width: 100%;
        background-color: #7C77B9;
    }
    }

    .col4 {
        float: left;
        width: 20%;
        background-color: #0BC9CD;
    }

    @media only screen and (max-width: 500px) {
    .col4{
        float: left;
        width: 100%;
        background-color: #0BC9CD;
    }
    }

    .col5 {
        float: left;
        width: 20%;
        background-color: #05A8AA;
    }

    @media only screen and (max-width: 500px) {
    .col5{
        float: left;
        width: 100%;
        background-color: #05A8AA;
    }
    }

The green is fine but the rest don't match above themselves

Any help would be appreciated. Thanks in advance.

Body:
You are doing a lot of css stuff that makes me wonder if my submission will be sufficient, but:

.container {
  display: flex;
  flex-wrap: wrap;
  height: 100px; // or whatever
}

.container div {
  width: 20%;
  height: 100%;
}

.col1 {
  background-color: red; //or whatever
}

.col2 {
  background-color: orange; //or whatever
}

.col3 {
  background-color: yellow; //or whatever
}

.col4 {
  background-color: blue; //or whatever
}

.col5 {
  background-color: indigo; //or whatever
}

.container .content {
  width: 100%;
}

<div class="container">
<div class="col1"><br></div>
<div class="col2"><br></div>
<div class="col3"><br></div>
<div class="col4"><br></div>
<div class="col5"><br></div>
<div class="content">Put whatever you want here, including other elements</div>
</div>


问:
How to use bootstrap popover in angular 7 using jquery?
I am trying to implement bootstrap4 popover using jquery in angular7. I have included "popper.js" in index.html and included using npm too. but it's not working.

Uncaught TypeError: jquery__WEBPACK_IMPORTED_MODULE_2__(...).popover is not a function

this error only appears in the console.

HTML:(sample.component.html)

```<code><button id="option2" autocomplete="off" data-toggle="popover"> Public</button>
</code>```

Jquery: (sample.component.ts)

```<code>import { Component, OnInit } from '@angular/core';
import * as $ from 'jquery';

@Component({
  selector: 'app-sample',
  templateUrl: './sample.component.html',
  styleUrls: ['./sample.component.css']
})
export class SampleComponent implements OnInit {

  constructor() { }
  ngOnInit() {
    $(document).ready(function(){
      $('[data-toggle="popover"]').popover();
      $('#option2').popover({
         html: true,
        content: function() {
          return $("#div").html();
        },
         placement: 'bottom'
      });
    });
  }
</code>```

How to achieve bootstrap popover in angular 7?

答:
Attention: using jQuery in Angular is not a good practice as @ErikHer implied. The interesting thing in this case is to use the ng-bootstrap library, which is a library developed in the angular standards with the elements Bootstrap 4 or less. Also you can use Bootstrap 5, where they stopped using jQuery.

Anyway, the method below works, but it is not recommended.

Thank you @ErikHer for making the answer more complete.

Change your component file to that way:

```<code>import { Component, OnInit } from '@angular/core';
declare var $: any; // ADD THIS
import * as $ from 'jquery';

@Component({
  selector: 'app-sample',
  templateUrl: './sample.component.html',
  styleUrls: ['./sample.component.css']
})
export class SampleComponent implements OnInit {

  constructor() { }
  ngOnInit() {
    $('[data-toggle="popover"]').popover();
  }
</code>```

You don't need use $(document).ready() because the NgOnInit() do the same thing.
And the $('[data-toggle="popover"]').popover(); will start all Popover you have in your component.

You can use title, data-placement and data-content attributes for make the Popover like:

```<code><button id="option2" autocomplete="off" data-toggle="popover" data-placement="bottom" title="popover's title" data-content="popover's text"> Public</button>
</code>```

Or you can initialize the popover with the function that you used in NgOnInit():

```<code>$('#option2').popover({
         html: true,
        content: function() {
          return $("#div").html();
        },
         placement: 'bottom'
      });
</code>```

Hope this helps.

Body:
I am trying to implement bootstrap4 popover using jquery in angular7. I have included "popper.js" in index.html and included using npm too. but it's not working.

Uncaught TypeError: jquery__WEBPACK_IMPORTED_MODULE_2__(...).popover is not a function

this error only appears in the console.

HTML:(sample.component.html)

<button id="option2" autocomplete="off" data-toggle="popover"> Public</button>

Jquery: (sample.component.ts)

import { Component, OnInit } from '@angular/core';
import * as $ from 'jquery';

@Component({
  selector: 'app-sample',
  templateUrl: './sample.component.html',
  styleUrls: ['./sample.component.css']
})
export class SampleComponent implements OnInit {

  constructor() { }
  ngOnInit() {
    $(document).ready(function(){
      $('[data-toggle="popover"]').popover();
      $('#option2').popover({
         html: true,
        content: function() {
          return $("#div").html();
        },
         placement: 'bottom'
      });
    });
  }

How to achieve bootstrap popover in angular 7?

Body:
Attention: using jQuery in Angular is not a good practice as @ErikHer implied. The interesting thing in this case is to use the ng-bootstrap library, which is a library developed in the angular standards with the elements Bootstrap 4 or less. Also you can use Bootstrap 5, where they stopped using jQuery.

Anyway, the method below works, but it is not recommended.

Thank you @ErikHer for making the answer more complete.

Change your component file to that way:

import { Component, OnInit } from '@angular/core';
declare var $: any; // ADD THIS
import * as $ from 'jquery';

@Component({
  selector: 'app-sample',
  templateUrl: './sample.component.html',
  styleUrls: ['./sample.component.css']
})
export class SampleComponent implements OnInit {

  constructor() { }
  ngOnInit() {
    $('[data-toggle="popover"]').popover();
  }

You don't need use $(document).ready() because the NgOnInit() do the same thing.
And the $('[data-toggle="popover"]').popover(); will start all Popover you have in your component.

You can use title, data-placement and data-content attributes for make the Popover like:

<button id="option2" autocomplete="off" data-toggle="popover" data-placement="bottom" title="popover's title" data-content="popover's text"> Public</button>

Or you can initialize the popover with the function that you used in NgOnInit():

$('#option2').popover({
         html: true,
        content: function() {
          return $("#div").html();
        },
         placement: 'bottom'
      });

Hope this helps.


问:
hide bootstrap divs one by one when geeting a particular resolution(responsive)
parentRow is a row containing 3 or more divs. It should not go to second row. The first div "Apple" should be visible in every resolution. The second div "Orange" should be visible for col-md-4 and col-lg-4 and col-xl-4 while 3rd div "Pineapple" should be visible only for col-lg-4 and col-xl-4?

In short there is a row containing 3 or more divs (Bootstrap 4.3.1 grids) when the screen is resized the divs should hide one by one and at smaller resolution one div(grid) should remain visible?

Shorter and effective method is welcomed. Please avoid media queries.

        Apple

        Orange

        Pineapple

```

答:
This bit of code you can put on any page for a quick reference when you do a lot of resizing tests.

It show just the div with the name = active size of the screen and make the rest hidden:

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

XL

LG

MD

SM

XS

  ```

Body:
This bit of code you can put on any page for a quick reference when you do a lot of resizing tests.

It show just the div with the name = active size of the screen and make the rest hidden:

<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>

<body>
    <div class="d-none d-xl-block          ">XL</div>
    <div class="d-none d-lg-block d-xl-none">LG</div>
    <div class="d-none d-md-block d-lg-none">MD</div>
    <div class="d-none d-sm-block d-md-none">SM</div>
    <div class="       d-xs-block d-sm-none">XS</div>
  </body>


问:
Tensorflow 2.0 : frozen graph support
Will the support for frozen graph continue in tensorflow 2.0 or deprecated?
I mean the scripts and APIs to create/optimize frozen graph from saved_model. Also the APIs to run the inference for the same.

Assuming it will be supported in future, what is the recommended method to run the inference on frozen graph in tensorflow 2.0 ?

答:
The freeze graph APIs - freeze_graph.py and converter_variables_to_constants - will not be supported in TensorFlow 2.0.

In 2.0, the primary export format is SavedModels so APIs are built to directly support SavedModels.
 Inference on existing frozen graphs can be run using the v1.compat path.

Title: Tensorflow 2.0 : frozen graph support


问:
iOS 4 periodic location updates using GPS while app is in background
Is it possible to have the phone power up the GPS every say 30 minutes and get the user's location while the app is in a background state?

The significant location change service is a little too unprecise for my needs.

I am trying to track a phone at all times without killing the battery life too much. Any suggestions are more than welcome!

答:
I have a very similar requirement:  my app is supposed to take highly accurate location snapshots at a periodic interval (typically 1 minute) and it has to do so even if the device is sleeping or the app is in the background.

To accomplish this in the foreground I implemented a system which turns on the location service, waits for a location of the desired accuracy, then shuts off the service until a timer fires.  This process repeats and seems to work as expected: half a dozen inaccurate location readings are returned (in the space of a few seconds) before an accurate one is received.

Testing has shown that this approach WILL work when the device is sleeping, which surprised me!  So now we just have to worry about when the app is backgrounded.

Here is the mechanism I am using to extend this to data collection while in the background:

Set the info.plist value to indicate that location updates are needed by the app, even when not in the foreground.  This is documented in the "Tracking The User's Location" section of the Apple SDK docs.  It guarantees that location updates will be delivered to the app even in the background, or sleeping.

However, this approach doesn't allow (out of the box) a periodic collection, but, instead notices are sent whenever the location services see a location change as defined by the desired accuracy value.

Unfortunately, if you turn off location services data collection after the app is backgrounded it no longer receives notices (the app is in the background, remember?).   So I'm exploring using the setKeepAliveTimeout:handle method on UIApplication to ALSO do a periodic check, effectively replacing my foreground timer.  [Note -- to register the KeepAlive handler you also have to set the info.plist to indicate the app is doing VOIP] When the KeepAlive handler gets called it turns on location services in the handler, gather data, then turn off the location services.  Testing has shown that this DOES re-start the location services notifications.  But I'm seeing the KeepAlive handler only getting called at 10 minute intervals (600 seconds) and I'm not sure if that is good enough.

Note that the setKeepAliveTimeout:handle method is intended for VOIP applications, and apparently Apple examines apps that use it VERY closely.  In my case this is an app for a client who uses Wireless Distribution, not the Apple store, so it isn't an issue for me.

However, if this approach works it seems to satisfy a need not met by the Apple API:  balancing the need for highly accurate location data, while only collecting that data at intervals to conserve battery life.  Apple really should support a timed collection model, and not just based on accuracy.  Ah, well!

Cheers


问:
How can I force gradle to redownload dependencies?
How can I tell gradle to redownload dependencies from repositories?</p>

答:
For Android Studio 3.4.1

Simply open the gradle tab (can be located on the right) and right-click on the parent in the list (should be called "Android"), then select "Refresh dependencies".

This should resolve your issue.


问:
unable to delete keys with prefix from redis
How does one deletes keys with certain prefix from Redis 5+?

I've tried following, yet didn't work for me(

```<code>root@1acb94e11aa2:/data# redis-cli --version
redis-cli 5.0.4
root@1acb94e11aa2:/data# redis-cli -n 9 KEYS ISO:* | wc -l
935
root@1acb94e11aa2:/data# redis-cli -n 9 KEYS ISO:* | xargs -0 redis-cli -n 9 DEL
(integer) 0
root@1acb94e11aa2:/data# redis-cli -n 9 KEYS ISO:* | wc -l
935
root@1acb94e11aa2:/data# redis-cli -n 9 --scan --pattern ISO:* | xargs -0 redis-cli -n 9 unlink
(integer) 0
root@1acb94e11aa2:/data#
</code>```

Please advise.

答:
FIX:</p>

```<code>root@1acb94e11aa2:/data# redis-cli -n 9 KEYS ISO:* | xargs -d "\n" redis-cli -n 9 del
(integer) 262
root@1acb94e11aa2:/data#
root@1acb94e11aa2:/data# redis-cli -n 9 KEYS ISO:*
(empty list or set)
root@1acb94e11aa2:/data#
</code>```

Body:
How does one deletes keys with certain prefix from Redis 5+?

I've tried following, yet didn't work for me(

root@1acb94e11aa2:/data# redis-cli --version
redis-cli 5.0.4
root@1acb94e11aa2:/data# redis-cli -n 9 KEYS ISO:* | wc -l
935
root@1acb94e11aa2:/data# redis-cli -n 9 KEYS ISO:* | xargs -0 redis-cli -n 9 DEL
(integer) 0
root@1acb94e11aa2:/data# redis-cli -n 9 KEYS ISO:* | wc -l
935
root@1acb94e11aa2:/data# redis-cli -n 9 --scan --pattern ISO:* | xargs -0 redis-cli -n 9 unlink
(integer) 0
root@1acb94e11aa2:/data#

Please advise.

Body:
FIX:

root@1acb94e11aa2:/data# redis-cli -n 9 KEYS ISO:* | xargs -d "\n" redis-cli -n 9 del
(integer) 262
root@1acb94e11aa2:/data#
root@1acb94e11aa2:/data# redis-cli -n 9 KEYS ISO:*
(empty list or set)
root@1acb94e11aa2:/data#


问:
How to join two queries while keeping "City" as common filter for first column
I am trying to join these two separate queries. Each of them on its own works. One is for 2019 and one is for 2018.. I am trying to have 7 total columns. The first being "city" which is where the two queries both share and then 6 more columns (3 for 2019 & 3 for 2018). Thank you for your help!

I've tried using join and union, but I believe my syntax is off

```<code>select  coalesce(city, 'Total') as "City",
    sum(reservations.number_of_nights) as "2019 AAA",
    sum(reservations.accommodation_fare+reservations.cleaning_fee)/sum(reservations.number_of_nights) as "2019 BBB",
    sum(reservations.accommodation_fare+reservations.cleaning_fee) as "2019 CCC"
    from reservations
        join listings on reservations.listings_id = listings.id
        where status = 'YYYY'
        and city <> 'XXXX'
        and reservations.deleted_at is null
            group by rollup(city)
            order by city asc;

select  coalesce(city, 'Total') as "City",
    sum(reservations.number_of_nights) as "2018 AAA",
    sum(reservations.accommodation_fare+reservations.cleaning_fee)/sum(reservations.number_of_nights) as "2018 BBB",
    sum(reservations.accommodation_fare+reservations.cleaning_fee) as "2018 CCC"
    from reservations
        join listings on reservations.listings_id = listings.id
        where guesty_status = 'YYYY'
        and city <> 'XXXX'
        and reservations.deleted_at is null
            group by rollup(city)
            order by city asc;
</code>```

答:
One way is to use each query as a derived table:</p>

```<code>select
    City,
    [2019 AAA],
    [2019 BBB],
    [2019 CCC],
    [2018 AAA],
    [2018 BBB],
    [2018 CCC]
from (

    select  coalesce(city, 'Total') as [City],
        sum(reservations.number_of_nights) as [2019 AAA],
        sum(reservations.accommodation_fare+reservations.cleaning_fee)/sum(reservations.number_of_nights) as [2019 BBB],
        sum(reservations.accommodation_fare+reservations.cleaning_fee) as [2019 CCC]
        from reservations
            join listings on reservations.listings_id = listings.id
            where status = 'YYYY'
            and city <> 'XXXX'
            and reservations.deleted_at is null
                group by rollup(city)
    ) as t2019
join (
    select  coalesce(city, 'Total') as [City],
        sum(reservations.number_of_nights) as [2018 AAA],
        sum(reservations.accommodation_fare+reservations.cleaning_fee)/sum(reservations.number_of_nights) as [2018 BBB],
        sum(reservations.accommodation_fare+reservations.cleaning_fee) as [2018 CCC]
        from reservations
            join listings on reservations.listings_id = listings.id
            where guesty_status = 'YYYY'
            and city <> 'XXXX'
            and reservations.deleted_at is null
                group by rollup(city)
) as t2018
on t2018.City = t2019.City
order by City;
</code>```

Body:
I am trying to join these two separate queries. Each of them on its own works. One is for 2019 and one is for 2018.. I am trying to have 7 total columns. The first being "city" which is where the two queries both share and then 6 more columns (3 for 2019 & 3 for 2018). Thank you for your help!

I've tried using join and union, but I believe my syntax is off

select  coalesce(city, 'Total') as "City",
    sum(reservations.number_of_nights) as "2019 AAA",
    sum(reservations.accommodation_fare+reservations.cleaning_fee)/sum(reservations.number_of_nights) as "2019 BBB",
    sum(reservations.accommodation_fare+reservations.cleaning_fee) as "2019 CCC"
    from reservations
        join listings on reservations.listings_id = listings.id
        where status = 'YYYY'
        and city <> 'XXXX'
        and reservations.deleted_at is null
            group by rollup(city)
            order by city asc;

select  coalesce(city, 'Total') as "City",
    sum(reservations.number_of_nights) as "2018 AAA",
    sum(reservations.accommodation_fare+reservations.cleaning_fee)/sum(reservations.number_of_nights) as "2018 BBB",
    sum(reservations.accommodation_fare+reservations.cleaning_fee) as "2018 CCC"
    from reservations
        join listings on reservations.listings_id = listings.id
        where guesty_status = 'YYYY'
        and city <> 'XXXX'
        and reservations.deleted_at is null
            group by rollup(city)
            order by city asc;

Body:
One way is to use each query as a derived table:

select
    City,
    [2019 AAA],
    [2019 BBB],
    [2019 CCC],
    [2018 AAA],
    [2018 BBB],
    [2018 CCC]
from (

    select  coalesce(city, 'Total') as [City],
        sum(reservations.number_of_nights) as [2019 AAA],
        sum(reservations.accommodation_fare+reservations.cleaning_fee)/sum(reservations.number_of_nights) as [2019 BBB],
        sum(reservations.accommodation_fare+reservations.cleaning_fee) as [2019 CCC]
        from reservations
            join listings on reservations.listings_id = listings.id
            where status = 'YYYY'
            and city <> 'XXXX'
            and reservations.deleted_at is null
                group by rollup(city)
    ) as t2019
join (
    select  coalesce(city, 'Total') as [City],
        sum(reservations.number_of_nights) as [2018 AAA],
        sum(reservations.accommodation_fare+reservations.cleaning_fee)/sum(reservations.number_of_nights) as [2018 BBB],
        sum(reservations.accommodation_fare+reservations.cleaning_fee) as [2018 CCC]
        from reservations
            join listings on reservations.listings_id = listings.id
            where guesty_status = 'YYYY'
            and city <> 'XXXX'
            and reservations.deleted_at is null
                group by rollup(city)
) as t2018
on t2018.City = t2019.City
order by City;


问:
Making / Testing a Connection Using VersionOne .Net SDK
I'm new to VersionOne and have limited C#. Need help connecting and testing connection to VersionOne instance using .Net SDK to make sure I'm actually making a connection.

I have some sample code that runs without error, but not sure it is connecting.

```<code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VersionOne.SDK.APIClient;

namespace VersionOneExtract3
{
    public class Connection1
    {
         V1Connector connector = V1Connector

    .WithInstanceUrl("https://www14.v1host.com/MyCompanySite")

    .WithUserAgentHeader("VersionOneExtract2", "1.0")

    .WithWindowsIntegrated("XA\\MyUsername", "MyPassword")

    .Build();
    }
}
enter code here
</code>```

No results or errors. Is there a way I can create a variable and have it return some sort of confirmed connection info? Help appreciated!

答:
The code that you posted creates a VersionOne connector which is used to connect to the VersionOne API.  I'm assuming that you replaced the username and password with random data for privacy reasons, along with the URL. Make sure that those details are correct.

After you have your connector setup you'll want to use it to query various resources from the api.  One example of such is below:

```<code>IServices services = new Services(connector);
Oid memberId = services.GetOid("Member:20");
Query query = new Query(memberId);
QueryResult result = services.Retrieve(query);
Asset member = result.Assets[0];
</code>```

The reason that you're not seeing any feedback from the code you posted it because in reality, it doesn't really do much other than take in some configuration data and then spit out a type of API client.

Be sure to have a good look at the documentation as they do a fairly decent job of explaining how to work with their SDK.

https://community.versionone.com/VersionOne_Connect/Developer_Library/Get_an_SDK/.NET_SDK

Body:
I'm new to VersionOne and have limited C#. Need help connecting and testing connection to VersionOne instance using .Net SDK to make sure I'm actually making a connection.

I have some sample code that runs without error, but not sure it is connecting.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VersionOne.SDK.APIClient;

namespace VersionOneExtract3
{
    public class Connection1
    {
         V1Connector connector = V1Connector

    .WithInstanceUrl("https://www14.v1host.com/MyCompanySite")

    .WithUserAgentHeader("VersionOneExtract2", "1.0")

    .WithWindowsIntegrated("XA\\MyUsername", "MyPassword")

    .Build();
    }
}
enter code here

No results or errors. Is there a way I can create a variable and have it return some sort of confirmed connection info? Help appreciated!

Body:
The code that you posted creates a VersionOne connector which is used to connect to the VersionOne API.  I'm assuming that you replaced the username and password with random data for privacy reasons, along with the URL. Make sure that those details are correct.

After you have your connector setup you'll want to use it to query various resources from the api.  One example of such is below:

IServices services = new Services(connector);
Oid memberId = services.GetOid("Member:20");
Query query = new Query(memberId);
QueryResult result = services.Retrieve(query);
Asset member = result.Assets[0];

The reason that you're not seeing any feedback from the code you posted it because in reality, it doesn't really do much other than take in some configuration data and then spit out a type of API client.

Be sure to have a good look at the documentation as they do a fairly decent job of explaining how to work with their SDK.

https://community.versionone.com/VersionOne_Connect/Developer_Library/Get_an_SDK/.NET_SDK


问:
Facebook share text
I have these links on my site

```<code><a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" class="fb_share_button" onclick="return fbs_click('http://site.com/profile/4')" target="_blank" style="text-decoration:none;"></a>
<a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" class="fb_share_button" onclick="return fbs_click('http://site.com/profile/5')" target="_blank" style="text-decoration:none;"></a>
<a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" class="fb_share_button" onclick="return fbs_click('http://site.com/profile/8')" target="_blank" style="text-decoration:none;"></a>
<a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" class="fb_share_button" onclick="return fbs_click('http://site.com/profile/9')" target="_blank" style="text-decoration:none;"></a>
<a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" class="fb_share_button" onclick="return fbs_click('http://site.com/profile/10')" target="_blank" style="text-decoration:none;"></a>
</code>```

with this javascript

```<code><script>
function fbs_click(location_place) {
        u=location_place;
        t=document.title;
        window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
        return false;
    }
</script>
</code>```

and i want to know if there is a way to add text or some sort to each one uniquely so that each link as a different body ..here is my code working but where and how do i add a description of some sort

答: You should add Open Graph tags to the pages that you wish to share - that's how the sharer picks them up, and the nice thing is that if someone decides to just share a link in their feed the same information is picked up. The Facebook URL Linter is a great tool for figuring out what Facebook sees when it's looking for Open Graph information.</p>

Title: Facebook share text

Body:
I have these links on my site

<a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" class="fb_share_button" onclick="return fbs_click('http://site.com/profile/4')" target="_blank" style="text-decoration:none;">
<a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" class="fb_share_button" onclick="return fbs_click('http://site.com/profile/5')" target="_blank" style="text-decoration:none;">
<a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" class="fb_share_button" onclick="return fbs_click('http://site.com/profile/8')" target="_blank" style="text-decoration:none;">
<a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" class="fb_share_button" onclick="return fbs_click('http://site.com/profile/9')" target="_blank" style="text-decoration:none;">
<a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" class="fb_share_button" onclick="return fbs_click('http://site.com/profile/10')" target="_blank" style="text-decoration:none;">

with this javascript

and i want to know if there is a way to add text or some sort to each one uniquely so that each link as a different body ..here is my code working but where and how do i add a description of some sort


问:
How to divide between groups of rows using dplyr with multiple columns?
My question is an extension of this question. I want to figure out how to divide between groups of rows using dplyr with multiple columns, instead of for a single variable.

I have this dataframe:

```<code>x <- data.frame(
    name = rep(letters[1:4], each = 2),
    condition = rep(c("A", "B"), times = 4),
    value1 = c(2,10,4,20,8,40,20,100),
    value2 = c(2,10,4,20,8,40,20,100)
)
#   name condition value1 value2
# 1    a         A     2       2
# 2    a         B    10       10
# 3    b         A     4       4
# 4    b         B    20       20
# 5    c         A     8       8
# 6    c         B    40       40
# 7    d         A    20       20
# 8    d         B   100       100
</code>```

I want to group by name and divide the value of rows with condition == "B" with those with condition == "A", to get this:

```<code>data.frame(
    name = letters[1:4],
    value1 = c(5,5,5,5),
    value2 = c(5,5,5,5)
)
#   name value1 value2
# 1    a     5       5
# 2    b     5       5
# 3    c     5       5
# 4    d     5       5
</code>```

There is the most upvoted answer there by Steven Beaupré for the original question with a single variable:

```<code>x %>%
group_by(name) %>%
summarise(value = value[condition == "B"] / value[condition == "A"])
</code>```

But that answer is for single value case, I don't know how to extend to "summarise_at" and "summarise_all". I tried to use "dot", but cannot figure out the correct syntax.

答:
I figured out a way to do it.</p>

```<code>x %>% gather(variable, value, -(name:condition)) %>%
group_by(variable,name) %>%
summarise(value = value[condition == "B"] / value[condition == "A"]) %>%
spread(variable,value)

#  name  value1 value2
#   <fct>  <dbl>  <dbl>
# 1 a          5      5
# 2 b          5      5
# 3 c          5      5
# 4 d          5      5
</code>```

Body:
My question is an extension of this question. I want to figure out how to divide between groups of rows using dplyr with multiple columns, instead of for a single variable.

I have this dataframe:

x <- data.frame(
    name = rep(letters[1:4], each = 2),
    condition = rep(c("A", "B"), times = 4),
    value1 = c(2,10,4,20,8,40,20,100),
    value2 = c(2,10,4,20,8,40,20,100)
)
#   name condition value1 value2
# 1    a         A     2       2
# 2    a         B    10       10
# 3    b         A     4       4
# 4    b         B    20       20
# 5    c         A     8       8
# 6    c         B    40       40
# 7    d         A    20       20
# 8    d         B   100       100

I want to group by name and divide the value of rows with condition == "B" with those with condition == "A", to get this:

data.frame(
    name = letters[1:4],
    value1 = c(5,5,5,5),
    value2 = c(5,5,5,5)
)
#   name value1 value2
# 1    a     5       5
# 2    b     5       5
# 3    c     5       5
# 4    d     5       5

There is the most upvoted answer there by Steven Beaupré for the original question with a single variable:

x %>%
group_by(name) %>%
summarise(value = value[condition == "B"] / value[condition == "A"])

But that answer is for single value case, I don't know how to extend to "summarise_at" and "summarise_all". I tried to use "dot", but cannot figure out the correct syntax.

Body:
I figured out a way to do it.

x %>% gather(variable, value, -(name:condition)) %>%
group_by(variable,name) %>%
summarise(value = value[condition == "B"] / value[condition == "A"]) %>%
spread(variable,value)

#  name  value1 value2
#   <fct>  <dbl>  <dbl>
# 1 a          5      5
# 2 b          5      5
# 3 c          5      5
# 4 d          5      5


问:
how to copy a vector in std::vector<Eigen::vectorXd> to another vector in another std::vector<Eigen::vectorXd>
how to copy a vector (Eigen::vectorXd) in std::vector<Eigen::vectorXd> to another vector (Eigen::vectorXd) in another std::vector<Eigen::vectorXd>

```<code>std::vector< Eigen::VectorXd > samples;
std::vector< Eigen::VectorXd > boea_samples;
</code>```

I would like to do

```<code>samples[i] = boea_samples[i];
</code>```

But it does not work and without error when compile. It just stops when run samples[i] = boea_samples[i];

Thanks!

答:
Eigen only supports fixed size vectors being used in STL containers. Even then it is not straight forward. The Eigen library implement their own allocater for their objects. This causes that you need to take some extra steps when using Eigen objects in STL containers.

This is an example from the documentation Eigen:

```<code>#include<Eigen/StdVector>
/* ... */
std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> >
</code>```

What you see is that besides the data type also the allocater is specified as a template argument.

You can read more in this somewhat hidden chapter of the Eigen documentation:
https://eigen.tuxfamily.org/dox/group__TopicStlContainers.html

Body:
how to copy a vector (Eigen::vectorXd) in std::vector<Eigen::vectorXd> to another vector (Eigen::vectorXd) in another std::vector<Eigen::vectorXd>

std::vector< Eigen::VectorXd > samples;
std::vector< Eigen::VectorXd > boea_samples;

I would like to do

samples[i] = boea_samples[i];

But it does not work and without error when compile. It just stops when run samples[i] = boea_samples[i];

Thanks!

Body:
Eigen only supports fixed size vectors being used in STL containers. Even then it is not straight forward. The Eigen library implement their own allocater for their objects. This causes that you need to take some extra steps when using Eigen objects in STL containers.

This is an example from the documentation Eigen:

#include<Eigen/StdVector>
/* ... */
std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> >

What you see is that besides the data type also the allocater is specified as a template argument.

You can read more in this somewhat hidden chapter of the Eigen documentation:
https://eigen.tuxfamily.org/dox/group__TopicStlContainers.html


问:
What should I do with the JWT token when a user decides to update his profile info?
I am making a simple MERN application and there are users (authorized) that can update their profile info.

I am using JWTs and I create the token with some info about the user, but if he decides to update this info, what should I do? Delete the current token from localStorage and create a new one?

答: It might be depend on what you are gonna do with jsonwebtoken. If you are doing just authentication with this then just leave it until expire and get another token from api.</p>