问:
module 'cv2.cv2' has no attribute 'cv'
```<code>import cv2
import numpy as np
cap = cv2.VideoCapture('1.MP4')
fourcc = cv2.FOURCC(*'XVID')
out  = cv2.videoWriter('output.avi',fourcc,20.0,(640,480))

while (1):
  #Capture frame-by-frame
  #ret = cap.set(3,960),cap.set(4,720)
  ret, frame = cap.read()
  if ret == True:
      frame = cv2.flip(frame,0)
      out.write(frame)

      cv2.imshow('frame',frame)

      if cv2.waitKey(1) == ord('q'):
          break
  else:
      break

cap.release()
out.release()
cv2.destroyAllWindows()
</code>```

As is shown above ,this is a demo in opencv document.while it can work in my PC.
Traceback like this:

```<code>Traceback (most recent call last):
  File "E:\opencv\Pic\test.py", line 34, in <module>
    fourcc = cv2.cv.FOURCC(*'XVID')
AttributeError: module 'cv2.cv2' has no attribute 'cv'
</code>```

And i also see some solution such as change cv2.cv to cv2 ,while the traceback below:

```<code>Traceback (most recent call last):
  File "E:\opencv\Pic\test.py", line 34, in <module>
    fourcc = cv2.FOURCC(*'XVID')
AttributeError: module 'cv2.cv2' has no attribute 'FOURCC'
</code>```

i am very thanks any warm heart solution for my question.

答:
Import the contrib library as well.

```<code>pip install opencv-contrib-python
</code>```

or

```<code>pip3 install opencv-contrib-python
</code>```

Title: module 'cv2.cv2' has no attribute 'cv'

Body:
import cv2
import numpy as np
cap = cv2.VideoCapture('1.MP4')
fourcc = cv2.FOURCC(*'XVID')
out  = cv2.videoWriter('output.avi',fourcc,20.0,(640,480))

while (1):
  #Capture frame-by-frame
  #ret = cap.set(3,960),cap.set(4,720)
  ret, frame = cap.read()
  if ret == True:
      frame = cv2.flip(frame,0)
      out.write(frame)

      cv2.imshow('frame',frame)

      if cv2.waitKey(1) == ord('q'):
          break
  else:
      break

cap.release()
out.release()
cv2.destroyAllWindows()

As is shown above ,this is a demo in opencv document.while it can work in my PC.
Traceback like this:

Traceback (most recent call last):
  File "E:\opencv\Pic\test.py", line 34, in <module>
    fourcc = cv2.cv.FOURCC(*'XVID')
AttributeError: module 'cv2.cv2' has no attribute 'cv'

And i also see some solution such as change cv2.cv to cv2 ,while the traceback below:

Traceback (most recent call last):
  File "E:\opencv\Pic\test.py", line 34, in <module>
    fourcc = cv2.FOURCC(*'XVID')
AttributeError: module 'cv2.cv2' has no attribute 'FOURCC'

i am very thanks any warm heart solution for my question.

Body:
Import the contrib library as well.

pip install opencv-contrib-python

or

pip3 install opencv-contrib-python


来源: stackexchange

问:
Type Not Found In Class When Inside Switch
I'm using a class like an enum because my entries need a custom string representation:

```<code>using System.Collections.Generic;

namespace MyProject
{
    internal class Food
    {
        private string _value = "";

        private Food(string value)
        {
            _value = value;
        }

        public override string ToString()
        {
            return _value;
        }

        internal static Food RedApple = new Food("red_apple");
        internal static Food YellowBanana = new Food("yellow_banana");
        internal static Food GreenMango = new Food("green_mango");
    }
}
</code>```

I can use the static fields like Food.RedApple just fine:

```<code>if (str == Food.RedApple.ToString())
    Console.WriteLine("apple");
else if (str == Food.YellowBanana.ToString())
    Console.WriteLine("banana");
else if (str == Food.GreenMango.ToString())
    Console.WriteLine("mango");
else
    Console.WriteLine("unknown");
</code>```

However, when I use them inside switch statements like so:

```<code>using System;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = "red_apple";

            switch (str)
            {
                case Food.RedApple.ToString():
                    Console.WriteLine("apple");
                    break;
                case Food.YellowBanana.ToString():
                    Console.WriteLine("banana");
                    break;
                case Food.GreenMango.ToString():
                    Console.WriteLine("mango");
                    break;
                default:
                    Console.WriteLine("unknown");
                    break;
            }
        }
    }
}
</code>```

I get the following error:

The type name RedApple does not exist in the type Food [MyProject]

What exactly is going on here, and does this mean that I can't use my class inside switch statements?

答:
i'm not sure what exactly your case is, but in my case(using your code), i'm getting 'CS0150 A constant value is expected.' error message here.

the problem has been answered here: Switch case in C# - a constant value is expected

you might have a look at it first, it may be of some help.

ContentLicense: CC BY-SA 4.0

Body:
I'm using a class like an enum because my entries need a custom string representation:

using System.Collections.Generic;

namespace MyProject
{
    internal class Food
    {
        private string _value = "";

        private Food(string value)
        {
            _value = value;
        }

        public override string ToString()
        {
            return _value;
        }

        internal static Food RedApple = new Food("red_apple");
        internal static Food YellowBanana = new Food("yellow_banana");
        internal static Food GreenMango = new Food("green_mango");
    }
}

I can use the static fields like Food.RedApple just fine:

if (str == Food.RedApple.ToString())
    Console.WriteLine("apple");
else if (str == Food.YellowBanana.ToString())
    Console.WriteLine("banana");
else if (str == Food.GreenMango.ToString())
    Console.WriteLine("mango");
else
    Console.WriteLine("unknown");

However, when I use them inside switch statements like so:

using System;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = "red_apple";

            switch (str)
            {
                case Food.RedApple.ToString():
                    Console.WriteLine("apple");
                    break;
                case Food.YellowBanana.ToString():
                    Console.WriteLine("banana");
                    break;
                case Food.GreenMango.ToString():
                    Console.WriteLine("mango");
                    break;
                default:
                    Console.WriteLine("unknown");
                    break;
            }
        }
    }
}

I get the following error:

The type name RedApple does not exist in the type Food [MyProject]

What exactly is going on here, and does this mean that I can't use my class inside switch statements?


问:
Seems xpath translate not working as expected in java8
I searched a lot to find the exact equivalent but not able to find. The question over here is the translate method of java8- javax.xml.xpath.* is not giving the expected output.

example-

Actual-

```<code>XPathExpression xpathitemtype = xpath.compile("//*[@type=\"" + xpathType + "\"]/ancestor::itemtype");
final NodeList itemType = (NodeList) xpathitemtype.evaluate(document, XPathConstants.NODESET);
</code>```

using translate-

```<code>XPathExpression xpathitemtype = xpath.compile("//*[translate(@type,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')='" + xpathType.toLowerCase() + "']/ancestor::itemtype");
final NodeList itemType = (NodeList) xpathitemtype.evaluate(document, XPathConstants.NODESET);
</code>```

Now i used translate because I like to get the itemType irrespective of the case in the given xml document-

example if value is-
exportMedia or ExportMedia or EXportMEdia any case just return the output.

Now in the above both example returns the same output it seems translate is not working in my case

```<code> <itemtype code="RemoveCatalogVersionJob">
 <attribute qualifier="catalogVersion" type="CatalogVersion">
                    <persistence type="property"/>
                </attribute>
                <attribute qualifier="removedItems" type="ExportMEdia">
                    <persistence type="property"/>
                </attribute>
                <attribute qualifier="notRemovedItems" type="exportMedia">
                    <persistence type="property"/>
                </attribute>
 </itemtype>
</code>```

Now I want the item value if it is any cases of exportMedia

答:
Your code works properly as well as XPath is evaluated properly. The problem is that XPath expression contains "ancestor::itemtype" in the end and both of matched "attribute" elements have only one ancestor with name "itemtype".

If you'll change your code for a test...

```<code>    XPathExpression xpathItemType = xpath.compile("//*[translate(@type,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')='" + xpathType.toLowerCase() + "']/@qualifier");
    final NodeList itemType = (NodeList) xpathItemType.evaluate(document, XPathConstants.NODESET);

    for(int i = 0; i < itemType.getLength(); i ++) {
        System.out.println(itemType.item(i).getNodeValue());
    }
</code>```

... the output will be

```<code>removedItems
notRemovedItems
</code>```

... showing, that both "ExportMEdia" and "exportMedia" matched your expression.

Alternatively you can change your input XML to something like this (just an example without knowing the real scheme):

```<code><items>
    <itemtype code="RemoveCatalogVersionJob">
        <attribute qualifier="notRemovedItems" type="exportMedia">
            <persistence type="property"/>
        </attribute>
    </itemtype>
    <itemtype code="RemoveCatalogVersionJob1">
        <attribute qualifier="removedItems" type="ExportMEdia">
            <persistence type="property"/>
        </attribute>
    </itemtype>
</items>
</code>```

Your code will match both itemtype with code="RemoveCatalogVersionJob" with code="RemoveCatalogVersionJob1".

Body:
I searched a lot to find the exact equivalent but not able to find. The question over here is the translate method of java8- javax.xml.xpath.* is not giving the expected output.

example-

Actual-

XPathExpression xpathitemtype = xpath.compile("//*[@type=\"" + xpathType + "\"]/ancestor::itemtype");
final NodeList itemType = (NodeList) xpathitemtype.evaluate(document, XPathConstants.NODESET);

using translate-

XPathExpression xpathitemtype = xpath.compile("//*[translate(@type,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')='" + xpathType.toLowerCase() + "']/ancestor::itemtype");
final NodeList itemType = (NodeList) xpathitemtype.evaluate(document, XPathConstants.NODESET);

Now i used translate because I like to get the itemType irrespective of the case in the given xml document-

example if value is-
exportMedia or ExportMedia or EXportMEdia any case just return the output.

Now in the above both example returns the same output it seems translate is not working in my case

 <itemtype code="RemoveCatalogVersionJob">
 <attribute qualifier="catalogVersion" type="CatalogVersion">
                    <persistence type="property"/>
                </attribute>
                <attribute qualifier="removedItems" type="ExportMEdia">
                    <persistence type="property"/>
                </attribute>
                <attribute qualifier="notRemovedItems" type="exportMedia">
                    <persistence type="property"/>
                </attribute>
 </itemtype>

Now I want the item value if it is any cases of exportMedia

Body:
Your code works properly as well as XPath is evaluated properly. The problem is that XPath expression contains "ancestor::itemtype" in the end and both of matched "attribute" elements have only one ancestor with name "itemtype".

If you'll change your code for a test...

    XPathExpression xpathItemType = xpath.compile("//*[translate(@type,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')='" + xpathType.toLowerCase() + "']/@qualifier");
    final NodeList itemType = (NodeList) xpathItemType.evaluate(document, XPathConstants.NODESET);

    for(int i = 0; i < itemType.getLength(); i ++) {
        System.out.println(itemType.item(i).getNodeValue());
    }

... the output will be

removedItems
notRemovedItems

... showing, that both "ExportMEdia" and "exportMedia" matched your expression.

Alternatively you can change your input XML to something like this (just an example without knowing the real scheme):

<items>
    <itemtype code="RemoveCatalogVersionJob">
        <attribute qualifier="notRemovedItems" type="exportMedia">
            <persistence type="property"/>
        </attribute>
    </itemtype>
    <itemtype code="RemoveCatalogVersionJob1">
        <attribute qualifier="removedItems" type="ExportMEdia">
            <persistence type="property"/>
        </attribute>
    </itemtype>
</items>

Your code will match both itemtype with code="RemoveCatalogVersionJob" with code="RemoveCatalogVersionJob1".


问:
Is SSL set on a per machine or per connection basis
Is it possible to have a FTP server using SSL on a application server that does not use SSL?

How would you setup an ASP.NET 2.0 to consume a SSL certificate?

This certianly sounds possible but is it advisable, is it good practice?

答:
FTP is at the application layer, and SSL is lower, at the presentation layer.  The SSL sessions are on a per connection basis. Take a look at the Wikipedia page. The SSL connection is established before anything happens with your application.  Your FTP server probably isn't running inside your .NET application server, is it?  You should be able to setup an SSH server listening for SCP connections separately.  If it really does run from inside your app server, you should be able to listen on a separate port for the SSL connection.

Short of any of that, heres a good link for configuring SSL in IIS.  You don't have to make the certificates mandatory.  That way you can allow unsecured traffic and secure traffic if that fits in with your application model.

OwnerDisplayName: Dean

ContentLicense: CC BY-SA 2.5

OwnerDisplayName: John Ellinwood


问:
SQL -- create column in SELECT to test equality
In SQL Server, I'm dealing with these columns:

tblSchedule

ID

StaffID

StartTime

EndTime

I want to include a boolean field in my result set that indicates whether StartTime and EndTime are equal.  Something analogous to this:

```<code>SELECT StaffID, StartTime, EndTime, (StartTime = EndTime) AS AreEqual
FROM tblSchedule Where StaffID = xxx
</code>```

But I'm not sure of the actual syntax for an operation like that.

答:
I think this is what you are looking for</p>

```<code>SELECT  StaffID
        , StartTime
        , EndTime
        , Case
          When StartTime = EndTime Then 1
          else  0
        End as AreEqual
FROM    tblSchedule
Where   StaffID = xxx
</code>```

ContentLicense: CC BY-SA 3.0

Body:
In SQL Server, I'm dealing with these columns:

tblSchedule

ID

StaffID

StartTime

EndTime

I want to include a boolean field in my result set that indicates whether StartTime and EndTime are equal.  Something analogous to this:

SELECT StaffID, StartTime, EndTime, (StartTime = EndTime) AS AreEqual
FROM tblSchedule Where StaffID = xxx

But I'm not sure of the actual syntax for an operation like that.

Body:
I think this is what you are looking for

SELECT  StaffID
        , StartTime
        , EndTime
        , Case
          When StartTime = EndTime Then 1
          else  0
        End as AreEqual
FROM    tblSchedule
Where   StaffID = xxx


问:
Accessing UI Thread Window from another thread and class for AAD WIndow
I am building a WPF that prompts the user to login to Azure AD, and I am unable to get the call to fire, instead it hangs the UI thread. Here is the code that I am trying to call

```<code> authResult = _application.AcquireTokenInteractive(_scopes)
                          .WithParentActivityOrWindow(new WindowInteropHelper(Application.Current.MainWindow).Handle)
                          .ExecuteAsync().Result;
</code>```

I have tried wrapping this in a dispatcher call, like so

```<code>internal static Dispatcher GetDispatcher(this DispatcherObject source)
{
    //use the application's dispatcher by default
    if (Application.Current != null) return Application.Current.Dispatcher;

    //fallback for WinForms environments
    if (source.Dispatcher != null) return source.Dispatcher;

    // ultimately use the thread's dispatcher
    return Dispatcher.CurrentDispatcher;
}

var dispatcher = MainWindow.main.GetDispatcher();

if (!dispatcher.CheckAccess())
{
    var action = new Action(() => {
        authResult = _application.AcquireTokenInteractive(_scopes)
                     .WithParentActivityOrWindow(new WindowInteropHelper(Application.Current.MainWindow).Handle)
                     .ExecuteAsync().Result;
        });
        dispatcher.Invoke(DispatcherPriority.Normal, action);
        return;
}
</code>```

If I move the interactive call in my MainWindow.xaml.cs, it works fine, but I want to move it to a service class to clean things up. What could I be doing wrong? The above code is in a function that has a signature like this

```<code> public async Task AuthenticateRequestAsync(HttpRequestMessage request)
</code>```

I can provide additional info if needed.

答: Check out juunas's solution. Also if you decide to put that code in a library consider using .ConfigureAwait(false) to avoid undesired scenario. This link talks about it with some examples.</p>

Body:
I am building a WPF that prompts the user to login to Azure AD, and I am unable to get the call to fire, instead it hangs the UI thread. Here is the code that I am trying to call

 authResult = _application.AcquireTokenInteractive(_scopes)
                          .WithParentActivityOrWindow(new WindowInteropHelper(Application.Current.MainWindow).Handle)
                          .ExecuteAsync().Result;

I have tried wrapping this in a dispatcher call, like so

internal static Dispatcher GetDispatcher(this DispatcherObject source)
{
    //use the application's dispatcher by default
    if (Application.Current != null) return Application.Current.Dispatcher;

    //fallback for WinForms environments
    if (source.Dispatcher != null) return source.Dispatcher;

    // ultimately use the thread's dispatcher
    return Dispatcher.CurrentDispatcher;
}

var dispatcher = MainWindow.main.GetDispatcher();

if (!dispatcher.CheckAccess())
{
    var action = new Action(() => {
        authResult = _application.AcquireTokenInteractive(_scopes)
                     .WithParentActivityOrWindow(new WindowInteropHelper(Application.Current.MainWindow).Handle)
                     .ExecuteAsync().Result;
        });
        dispatcher.Invoke(DispatcherPriority.Normal, action);
        return;
}

If I move the interactive call in my MainWindow.xaml.cs, it works fine, but I want to move it to a service class to clean things up. What could I be doing wrong? The above code is in a function that has a signature like this

 public async Task AuthenticateRequestAsync(HttpRequestMessage request)

I can provide additional info if needed.


问:
AutoCompleteTextView on selectiong item 3 warnings appears
This is the declaration of AutoCompleteTextView.

```<code>@Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        if(savedInstanceState==null){
            mViewModel = new ViewModelProvider(this).get(SearchPartyViewModel.class);
        }
        View root=inflater.inflate(R.layout.fragment_new_order, container, false);
        initMessege=(TextView)root.findViewById(R.id.initMessege);
        newOrderPartyProgressBar=(ProgressBar)root.findViewById(R.id.newOrderPartyProgressBar);
        newProductDetailView=(ConstraintLayout)root.findViewById(R.id.newProductDetailView);
        listView=(LinearLayout)root.findViewById(R.id.listView);
        productSearchAutoCompleteTextView=(AutoCompleteTextView)root.findViewById(R.id.productSearchAutoCompleteTextView);
        newOrderParty=(AutoCompleteTextView)root.findViewById(R.id.newOrderParty);
        GetRetailList();
        ArrayAdapter<String> adapter= new ArrayAdapter<String>(getContext(),android.R.layout.simple_spinner_dropdown_item,retailerList);
        newOrderParty.setAdapter(adapter);
        newOrderParty.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Log.i("choosen",retailerList.get(position));
            }
        });
        return root;
    }
</code>```

when a item is selected from the drop down list the following erros appears

```<code>W/IInputConnectionWrapper: getTextBeforeCursor on inactive InputConnection
W/IInputConnectionWrapper: getSelectedText on inactive InputConnection
W/IInputConnectionWrapper: getTextAfterCursor on inactive InputConnection
</code>```

答:
and add   android.R.layout.simple_list_item_1 </p>

```<code>`autocomplete.setOnItemClickListener(new OnItemClickListener() {
  @Override
  public void onItemClick (AdapterView<?> parent, View view, int
  position, long id) {
    //... your stuff
  }
 })`
</code>```

Body:
This is the declaration of AutoCompleteTextView.

@Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        if(savedInstanceState==null){
            mViewModel = new ViewModelProvider(this).get(SearchPartyViewModel.class);
        }
        View root=inflater.inflate(R.layout.fragment_new_order, container, false);
        initMessege=(TextView)root.findViewById(R.id.initMessege);
        newOrderPartyProgressBar=(ProgressBar)root.findViewById(R.id.newOrderPartyProgressBar);
        newProductDetailView=(ConstraintLayout)root.findViewById(R.id.newProductDetailView);
        listView=(LinearLayout)root.findViewById(R.id.listView);
        productSearchAutoCompleteTextView=(AutoCompleteTextView)root.findViewById(R.id.productSearchAutoCompleteTextView);
        newOrderParty=(AutoCompleteTextView)root.findViewById(R.id.newOrderParty);
        GetRetailList();
        ArrayAdapter<String> adapter= new ArrayAdapter<String>(getContext(),android.R.layout.simple_spinner_dropdown_item,retailerList);
        newOrderParty.setAdapter(adapter);
        newOrderParty.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Log.i("choosen",retailerList.get(position));
            }
        });
        return root;
    }

when a item is selected from the drop down list the following erros appears

W/IInputConnectionWrapper: getTextBeforeCursor on inactive InputConnection
W/IInputConnectionWrapper: getSelectedText on inactive InputConnection
W/IInputConnectionWrapper: getTextAfterCursor on inactive InputConnection

Body:
and add   android.R.layout.simple_list_item_1

`autocomplete.setOnItemClickListener(new OnItemClickListener() {
  @Override
  public void onItemClick (AdapterView<?> parent, View view, int
  position, long id) {
    //... your stuff
  }
 })`


问:
Flutter - Font Awesome Icon overflow with Text
I'm using FontAwesomeIcon Plugin in my application.

Some Icons from FontAwesomeIcon plugin are overlap with Text widget like below Image.

I can solve this problem by adding some width between Text and Icon, but that is not good. so how to solve this problem.

I need like this Image.

here i'm not adding any width between icon and text.

Code:

```<code>Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                Row(
                  children: <Widget>[
                    Icon(
                      Icons.trip_origin,
                      color: Colors.white,
                    ),
                    Text(
                      'TP-23',
                      style: TextStyle(color: Colors.white),
                    )
                  ],
                ),
                Row(
                  children: <Widget>[
                    Icon(
                      FontAwesomeIcons.idCard,
                      color: Colors.white,
                    ),
                    Text(
                      'TP-23',
                      style: TextStyle(color: Colors.white),
                    )
                  ],
                )
              ],
            ),
</code>```

答:
Are you looking like this ?</p>

```<code>Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                Row(
                  children: <Widget>[
                    Icon(
                      Icons.trip_origin,
                      color: Colors.white,
                    ),
                    SizeBox(width:10) //as per your requirement
                    Text(
                      'TP-23',
                      style: TextStyle(color: Colors.white),
                    )
                  ],
                ),
                Row(
                  children: <Widget>[
                    Icon(
                      FontAwesomeIcons.idCard,
                      color: Colors.white,
                    ),
                    SizeBox(width:10) //as per your requirement
                    Text(
                      'TP-23',
                      style: TextStyle(color: Colors.white),
                    )
                  ],
                )
              ],
            ),
</code>```

Body:
I'm using FontAwesomeIcon Plugin in my application.

Some Icons from FontAwesomeIcon plugin are overlap with Text widget like below Image.

I can solve this problem by adding some width between Text and Icon, but that is not good. so how to solve this problem.

I need like this Image.

here i'm not adding any width between icon and text.

Code:

Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                Row(
                  children: <Widget>[
                    Icon(
                      Icons.trip_origin,
                      color: Colors.white,
                    ),
                    Text(
                      'TP-23',
                      style: TextStyle(color: Colors.white),
                    )
                  ],
                ),
                Row(
                  children: <Widget>[
                    Icon(
                      FontAwesomeIcons.idCard,
                      color: Colors.white,
                    ),
                    Text(
                      'TP-23',
                      style: TextStyle(color: Colors.white),
                    )
                  ],
                )
              ],
            ),

Body:
Are you looking like this ?

Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                Row(
                  children: <Widget>[
                    Icon(
                      Icons.trip_origin,
                      color: Colors.white,
                    ),
                    SizeBox(width:10) //as per your requirement
                    Text(
                      'TP-23',
                      style: TextStyle(color: Colors.white),
                    )
                  ],
                ),
                Row(
                  children: <Widget>[
                    Icon(
                      FontAwesomeIcons.idCard,
                      color: Colors.white,
                    ),
                    SizeBox(width:10) //as per your requirement
                    Text(
                      'TP-23',
                      style: TextStyle(color: Colors.white),
                    )
                  ],
                )
              ],
            ),


问:
How to define schema table level
I am using EF Core 2.1 with C# for my application.

For some reason, there are a few tables for which I want the schema to be dbo while for others app

```<code>public class MyAppContext : DbContext
{
    private const string _dbSchema = "app";

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.HasDefaultSchema(_dbSchema);
        modelBuilder.ApplyConfiguration(new RegionConfiguration());
        base.OnModelCreating(modelBuilder);
    }
}
</code>```

While for some entities, I want to override the default schema & set it.

```<code>public class RegionConfiguration : IEntityTypeConfiguration<Region>
{
    public void Configure(EntityTypeBuilder<Region> builder)
    {
        // Didn't find any such method -> builder.HasSchema("dbo");
        builder.HasKey(x => x.RegionId); //Primary Key
    }
}
</code>```

How to address this?

答:
Use ToTable method:</p>

```<code>public class RegionConfiguration : IEntityTypeConfiguration<Region>
{
    public void Configure(EntityTypeBuilder<Region> builder)
    {
        builder.HasKey(x => x.RegionId); //Primary Key
        builder.ToTable("TableName", "dbo");
        // or  builder.ToTable(nameof(<entity>), "dbo");
    }
}
</code>```

Title: How to define schema table level

Body:
I am using EF Core 2.1 with C# for my application.

For some reason, there are a few tables for which I want the schema to be dbo while for others app

public class MyAppContext : DbContext
{
    private const string _dbSchema = "app";

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.HasDefaultSchema(_dbSchema);
        modelBuilder.ApplyConfiguration(new RegionConfiguration());
        base.OnModelCreating(modelBuilder);
    }
}

While for some entities, I want to override the default schema & set it.

public class RegionConfiguration : IEntityTypeConfiguration<Region>
{
    public void Configure(EntityTypeBuilder<Region> builder)
    {
        // Didn't find any such method -> builder.HasSchema("dbo");
        builder.HasKey(x => x.RegionId); //Primary Key
    }
}

How to address this?

Body:
Use ToTable method:

public class RegionConfiguration : IEntityTypeConfiguration<Region>
{
    public void Configure(EntityTypeBuilder<Region> builder)
    {
        builder.HasKey(x => x.RegionId); //Primary Key
        builder.ToTable("TableName", "dbo");
        // or  builder.ToTable(nameof(<entity>), "dbo");
    }
}


问:
Click function on checkbox for toggeling table elements
I have been trying to use this JS for hiding some html table th and td elements.

```<code>$(document).ready(function(){
    $('th.proces').hide();
    $('td.proces').hide();
    $('#hide_proces').click(function() {
        if($(this).attr('checked'))
        {
            $('th.proces').show();
            $('td.proces').show();
        }
        else
        {
            $('th.proces').hide();
            $('td.proces').hide();
        }
    });
});
</code>```

When the page is loaded the items are hidden, so that is working.

Now I have this checkbox, and when checked the th and td elements should be made visible again.

```<code><input id="hide_proces" type="checkbox"/>
<th class="proces">Proces</th>
<td class="proces">some content</td>
</code>```

When the checkbox is checked the elements are still not visible, also no errors in the console. Any suggestions?

答:
try this</p>

```<code>$(document).ready(function(){
    $('th.proces').hide();
    $('td.proces').hide();
    const $hideProcess = $('#hide_proces');
    $hideProcess.click(function() {
        if($hideProcess.is(':checked'))
        {
            $('th.proces').show();
            $('td.proces').show();
        }
        else
        {
            $('th.proces').hide();
            $('td.proces').hide();
        }
    });
});
</code>```

Body:
I have been trying to use this JS for hiding some html table th and td elements.

$(document).ready(function(){
    $('th.proces').hide();
    $('td.proces').hide();
    $('#hide_proces').click(function() {
        if($(this).attr('checked'))
        {
            $('th.proces').show();
            $('td.proces').show();
        }
        else
        {
            $('th.proces').hide();
            $('td.proces').hide();
        }
    });
});

When the page is loaded the items are hidden, so that is working.

Now I have this checkbox, and when checked the th and td elements should be made visible again.

<input id="hide_proces" type="checkbox"/>
Proces
some content

When the checkbox is checked the elements are still not visible, also no errors in the console. Any suggestions?

Body:
try this

$(document).ready(function(){
    $('th.proces').hide();
    $('td.proces').hide();
    const $hideProcess = $('#hide_proces');
    $hideProcess.click(function() {
        if($hideProcess.is(':checked'))
        {
            $('th.proces').show();
            $('td.proces').show();
        }
        else
        {
            $('th.proces').hide();
            $('td.proces').hide();
        }
    });
});


问:
MySQL workbench extended properties?
I've been working for a while with SQL Server and I use Extended Properties to tag databases, tables and columns. Most of the time an item can have more than one Extended Properties.

For example, a column could have a property DisplayName and Version that are used by a web client that walk the database.

For reasons beyond my control, I must migrate my SQL server database to MySQL.

The thing is that the concept of Extented Properties doesn't seem to exist with MySQL Workbench.
Is there an equivalent? If not, what do you guys do to compensate the lack of this feature?

Many thanks!

答:
For reasons beyond my control, I must migrate my SQL server database to MySQL.

Good luck with that... (If it's about the money, try to convince your boss to use PostgreSQL instead.)

More seriously: whichever database you're using has a system catalog somewhere. Adding properties and tags are nothing more than a few entries to that catalog.

If you were using PostgreSQL, these tables would be in the pg_catalog schema. In so far as MySQL is concerned, the tables are in the information_schema:

http://dev.mysql.com/doc/refman/5.6/en/information-schema.html

To add extra properties, tags, etc. you can always add tables (in your own shema/database) and insert that meta data as needed. The syntax won't be fancy SQL constructs, but it'll get the job done.

Title: MySQL workbench extended properties?


问:
Linkedlist implementation in Java doesnot seem like linkedlist as in C++
I was going through the LinkedList and seen the implementation in Java. Back in days when I tried and implemented the linkedlist, it was with pointers and addresses and a lot of hard work. With Java the implementation is easier but still took some doing on my part. What I know of linked list is clear from following diagram,where 1,2,3,4 are nodes of the linkedlist.

However In java, the code I came across made me to think of the LinkedList as following diagram.

The implementation code of linkedlist in Java is as follows,

```<code>class LinkedListNode
{
    LinkedListNode nextNode = null;//consider this member variable
    int data;
    public LinkedListNode(int data)
    {
        this.data = data;
    }
    void appendItemToLinkedList(int newData)
    {
        LinkedListNode end = new LinkedListNode(newData);
        LinkedListNode temp = this;
        while (temp.nextNode != null) { temp = temp.nextNode; }
        temp.nextNode = end;

    }
}
</code>```

and

```<code>public static void main(String[] args)
    {
        LinkedListNode list = new LinkedListNode(10);
        list.appendItemToLinkedList(20);
        list.appendItemToLinkedList(30);
        list.appendItemToLinkedList(40);
        list.appendItemToLinkedList(50);
        list.appendItemToLinkedList(60);
    }
</code>```

In the diagram , you can clearly see the node objects are inside the other node objects. Is it really a linked list.Or A parent container holding other container inside it and so on?

答:
Linked list in C++ above

THE MAIN DIFFERENCE IS THAT IN JAVA, THE HEAD IS NOT JUST A POINTER(without data) pointing to the first element. Even head has both data and the pointer to second element(ONLY EXCEPT THE CASE WHERE LIST IS EMPTY). In short every element in the linked list in java has 2 pointers and data, except head which has a pointer to next element and its data. I am not sure about the last element though.

Body:
I was going through the LinkedList and seen the implementation in Java. Back in days when I tried and implemented the linkedlist, it was with pointers and addresses and a lot of hard work. With Java the implementation is easier but still took some doing on my part. What I know of linked list is clear from following diagram,where 1,2,3,4 are nodes of the linkedlist.

However In java, the code I came across made me to think of the LinkedList as following diagram.

The implementation code of linkedlist in Java is as follows,

class LinkedListNode
{
    LinkedListNode nextNode = null;//consider this member variable
    int data;
    public LinkedListNode(int data)
    {
        this.data = data;
    }
    void appendItemToLinkedList(int newData)
    {
        LinkedListNode end = new LinkedListNode(newData);
        LinkedListNode temp = this;
        while (temp.nextNode != null) { temp = temp.nextNode; }
        temp.nextNode = end;

    }
}

and

public static void main(String[] args)
    {
        LinkedListNode list = new LinkedListNode(10);
        list.appendItemToLinkedList(20);
        list.appendItemToLinkedList(30);
        list.appendItemToLinkedList(40);
        list.appendItemToLinkedList(50);
        list.appendItemToLinkedList(60);
    }

In the diagram , you can clearly see the node objects are inside the other node objects. Is it really a linked list.Or A parent container holding other container inside it and so on?


问:
Customize NSIS installer with Electron-builder
I want to customize NSIS script - e.g. remove Finish Page and run app immediately after install (assisted installer is used).

I use modifying scrpt: include: build/installer.nsh.

It opens myApp after install but Finish page is still there.

```<code>!include MUI2.nsh

!macro customInstall
  ExecWait '"$INSTDIR\myapp.exe" /sw'
!macroend
</code>```

I mean I don't want to show the last page Completing myApp Setup as shown in gif.

Any help appreciated.

答:
Finally I did it in build/installer.nsh:

```<code>!macro RunApp
  ${StdUtils.ExecShellAsUser} $0 "$launchLink" "open" ""
!macroend

!macro customInstall
    !insertmacro RunApp
    !insertmacro quitSuccess
!macroend
</code>```

Body:
I want to customize NSIS script - e.g. remove Finish Page and run app immediately after install (assisted installer is used).

I use modifying scrpt: include: build/installer.nsh.

It opens myApp after install but Finish page is still there.

!include MUI2.nsh

!macro customInstall
  ExecWait '"$INSTDIR\myapp.exe" /sw'
!macroend

I mean I don't want to show the last page Completing myApp Setup as shown in gif.

Any help appreciated.

Body:
Finally I did it in build/installer.nsh:

!macro RunApp
  ${StdUtils.ExecShellAsUser} $0 "$launchLink" "open" ""
!macroend

!macro customInstall
    !insertmacro RunApp
    !insertmacro quitSuccess
!macroend


问:
problem running this assembly program
I have this previous year exam question which i need to understand.
This uses 8bit Atmel processor

Can you explain to me what would happen?

Image file : http://i.stack.imgur.com/Sv6fJ.jpg

Please view image file for clear description of the problem.

Thank you very much!

答:
The exam question says "this process is only allowed to have one page in main memory".

The program takes two pages.  If a process can only have one page in memory, what does that imply?

Where in the program does the break between pages fall?  What is the program doing on either side of the break?

Given the answers to (1) and (2), what does that mean for the efficiency of the program?

Given (3), where might you want the page break to fall?

How could you change where in the program the page break is?

Title: problem running this assembly program


问:
I want to get realtime data from Firebase Firestore, I am trying to use stream but cant seem to be getting it
I am an absolute beginner at this, so please help.
My goal here is to achieve to create a new document inside collection called sensors on Firestore, everytime a new user registers. I am able to get that done, but then I want to fetch field of the document with that specific user's userid only. I have tried following code as well but it gets me a list of all created documents, I only want a single particular document with particular userid.

The following solution I tried was from a youtuber TheNetNinja, but it gets entire list of all documents in my collection:

```<code>  //sensor list from snapshot
  List<Sensor> _sensorListFromSnapshot(QuerySnapshot snapshot) {
    return snapshot.documents.map((doc) {
      return Sensor(
        fireRead: doc.data['fireRead'] ?? false,
        airQuality: doc.data['airQuality'] ?? 0,
        carbonMonoxide: doc.data['carbonMonoxide'] ?? 0,
        lpg: doc.data['lpg'] ?? 0,
        smoke: doc.data['smoke'] ?? 0,
      );
    }).toList();
  }

  //get sensors stream
  Stream<List<Sensor>> get sensors {
    return sensorData.snapshots().map(_sensorListFromSnapshot);
  }

</code>```

So then I ended up trying follwing code just by guessing because I dont really understand these Streams- Providers and other classes of dart-flutter:

```<code> Sensor specificSensorFromSnapshot(DocumentSnapshot event) {
    return Sensor(
      fireRead: event.data['fireRead'] ?? false,
      airQuality: event.data['airQuality'] ?? 0,
      carbonMonoxide: event.data['carbonMonoxide'] ?? 0,
      lpg: event.data['lpg'] ?? 0,
      smoke: event.data['smoke'] ?? 0,
    );
  }

  Stream<Sensor> get sensor {
    final DocumentReference specificSensorData =
        Firestore.instance.collection('sensors').document(uid);
    return specificSensorData.snapshots().map(specificSensorFromSnapshot);
  }

</code>```

I have a model class called Sensor:

```<code>class Sensor {
  final int airQuality;
  final bool fireRead;
  final int carbonMonoxide;
  final int smoke;
  final int lpg;

  Sensor(
      {this.fireRead,
      this.smoke,
      this.carbonMonoxide,
      this.airQuality,
      this.lpg});
}
</code>```

答:
There are many ways of returning documents using the document id.

I would recommend you to take a look at the below questions already answered by the community. They are not exactly your case - they are in other programming languages - but they should provide you some approaches on how to return only documents per a specific id, on your case, the id from the user.

Query firestore database for document id

Firestore Getting documents id from collection

How to get document id from firestore database

Let me know if the information helped you!

Body:
I am an absolute beginner at this, so please help.
My goal here is to achieve to create a new document inside collection called sensors on Firestore, everytime a new user registers. I am able to get that done, but then I want to fetch field of the document with that specific user's userid only. I have tried following code as well but it gets me a list of all created documents, I only want a single particular document with particular userid.

The following solution I tried was from a youtuber TheNetNinja, but it gets entire list of all documents in my collection:

  //sensor list from snapshot
  List<Sensor> _sensorListFromSnapshot(QuerySnapshot snapshot) {
    return snapshot.documents.map((doc) {
      return Sensor(
        fireRead: doc.data['fireRead'] ?? false,
        airQuality: doc.data['airQuality'] ?? 0,
        carbonMonoxide: doc.data['carbonMonoxide'] ?? 0,
        lpg: doc.data['lpg'] ?? 0,
        smoke: doc.data['smoke'] ?? 0,
      );
    }).toList();
  }

  //get sensors stream
  Stream<List<Sensor>> get sensors {
    return sensorData.snapshots().map(_sensorListFromSnapshot);
  }

So then I ended up trying follwing code just by guessing because I dont really understand these Streams- Providers and other classes of dart-flutter:

 Sensor specificSensorFromSnapshot(DocumentSnapshot event) {
    return Sensor(
      fireRead: event.data['fireRead'] ?? false,
      airQuality: event.data['airQuality'] ?? 0,
      carbonMonoxide: event.data['carbonMonoxide'] ?? 0,
      lpg: event.data['lpg'] ?? 0,
      smoke: event.data['smoke'] ?? 0,
    );
  }

  Stream<Sensor> get sensor {
    final DocumentReference specificSensorData =
        Firestore.instance.collection('sensors').document(uid);
    return specificSensorData.snapshots().map(specificSensorFromSnapshot);
  }

I have a model class called Sensor:

class Sensor {
  final int airQuality;
  final bool fireRead;
  final int carbonMonoxide;
  final int smoke;
  final int lpg;

  Sensor(
      {this.fireRead,
      this.smoke,
      this.carbonMonoxide,
      this.airQuality,
      this.lpg});
}


问:
Is there any way to receive List<LocalDate> by Spring Boot JPA Repository
Im trying to receive the LocalDate attribute of an entity. But I got a cannot convert type exception. And Im trying search answers by Spring Boot JPA document, but nothing helpful.

Gradle Config

```<code>plugins {
    id 'org.springframework.boot' version '2.2.0.RELEASE'
    id 'io.spring.dependency-management' version '1.0.7.RELEASE'
    id 'java'
}

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

dependencies {
    implementation group: 'com.h2database', name: 'h2', version: '1.4.200'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation('org.springframework.boot:spring-boot-starter-test')
}

</code>```

Configuration

```<code>spring:
  datasource:
    driver-class-name: org.h2.Driver
    username: sa
    password: sa
    type: com.zaxxer.hikari.HikariDataSource
    url: jdbc:h2:mem:db;DB_CLOSE_DELAY=-1
    hikari:
      maximum-pool-size: 100

  jpa:
    generate-ddl: true
    show-sql: true
    hibernate:
      ddl-auto: create-drop
</code>```

Entity

@Getter
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
@Entity
@Table(name = "db_test")
public class TestEntity {
    @Id
    private String id;
    private Integer age;
    private LocalDate birthday;
}
```

<p><strong>Repository</strong></p>

<pre class="lang-java prettyprint-override"><code>@Repository
public interface TestRepository extends JpaRepository<TestEntity, String> {

    @Query(nativeQuery = true, value = "SELECT DISTINCT birthday from db_test")
    List<LocalDate> findAllBirthday();

}
</code>```

Test Method

@SpringBootTest
@RunWith(SpringRunner.class)
public class TestRepositoryTest {

    @Autowired
    private TestRepository testRepository;

    @Test
    public void findAllBirthday() {
        TestEntity entity = new TestEntity("OK", 1, LocalDate.parse("2019-01-01"));
        testRepository.save(entity);

        List<LocalDate> result = testRepository.findAllBirthday();
        Assert.assertEquals(1, result.size());
    }
}
```

<p><strong>Exception</strong></p>

```org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.util.ArrayList<?>] to type [@org.springframework.data.jpa.repository.Query java.util.List<java.time.LocalDate>] for value '[2019-01-01, 2019-01-02, 2019-01-03]'; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.sql.Date] to type [@org.springframework.data.jpa.repository.Query java.time.LocalDate]
    at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:47)
    at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:191)
    at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:212)
    at org.springframework.data.repository.core.support.QueryExecutionResultHandler.postProcessInvocationResult(QueryExecutionResultHandler.java:166)
    at org.springframework.data.repository.core.support.QueryExecutionResultHandler.postProcessInvocationResult(QueryExecutionResultHandler.java:77)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:605)

```

Additional information:

Maybe Im not express my thought well. Here is my operation:

using H2 as default database.

writing JUnit4 test method.

running test under spring boot test environment.

hoping there will return List, BUT ONLY GOT EXCEPTION.

答:
How do you create fields in the database? If you're using MySQL your birthday field data type must as DATE!
otherwise, this is expected because of casting.</p>

Body:
Im trying to receive the LocalDate attribute of an entity. But I got a cannot convert type exception. And Im trying search answers by Spring Boot JPA document, but nothing helpful.

Gradle Config

plugins {
    id 'org.springframework.boot' version '2.2.0.RELEASE'
    id 'io.spring.dependency-management' version '1.0.7.RELEASE'
    id 'java'
}

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

dependencies {
    implementation group: 'com.h2database', name: 'h2', version: '1.4.200'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation('org.springframework.boot:spring-boot-starter-test')
}

Configuration

spring:
  datasource:
    driver-class-name: org.h2.Driver
    username: sa
    password: sa
    type: com.zaxxer.hikari.HikariDataSource
    url: jdbc:h2:mem:db;DB_CLOSE_DELAY=-1
    hikari:
      maximum-pool-size: 100

  jpa:
    generate-ddl: true
    show-sql: true
    hibernate:
      ddl-auto: create-drop

Entity

@Getter
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
@Entity
@Table(name = "db_test")
public class TestEntity {
    @Id
    private String id;
    private Integer age;
    private LocalDate birthday;
}

Repository

@Repository
public interface TestRepository extends JpaRepository<TestEntity, String> {

    @Query(nativeQuery = true, value = "SELECT DISTINCT birthday from db_test")
    List<LocalDate> findAllBirthday();

}

Test Method

@SpringBootTest
@RunWith(SpringRunner.class)
public class TestRepositoryTest {

    @Autowired
    private TestRepository testRepository;

    @Test
    public void findAllBirthday() {
        TestEntity entity = new TestEntity("OK", 1, LocalDate.parse("2019-01-01"));
        testRepository.save(entity);

        List<LocalDate> result = testRepository.findAllBirthday();
        Assert.assertEquals(1, result.size());
    }
}

Exception

org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.util.ArrayList<?>] to type [@org.springframework.data.jpa.repository.Query java.util.List<java.time.LocalDate>] for value '[2019-01-01, 2019-01-02, 2019-01-03]'; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.sql.Date] to type [@org.springframework.data.jpa.repository.Query java.time.LocalDate]
    at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:47)
    at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:191)
    at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:212)
    at org.springframework.data.repository.core.support.QueryExecutionResultHandler.postProcessInvocationResult(QueryExecutionResultHandler.java:166)
    at org.springframework.data.repository.core.support.QueryExecutionResultHandler.postProcessInvocationResult(QueryExecutionResultHandler.java:77)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:605)

Additional information:

Maybe Im not express my thought well. Here is my operation:

using H2 as default database.

writing JUnit4 test method.

running test under spring boot test environment.

hoping there will return List, BUT ONLY GOT EXCEPTION.


问:
How to find out name of package I want to remove with Yum in Amazon Fedora EC2 instance
So I installed Python 3.7 on my EC2 Fedora instance with Yum, later I needed to remove it. However, when I did yum -list, it showed all the "sub-packages" installed with python.

I just typed yum remove python3 and it worked, but what is the "proper" way of figuring out what name you need to type to remove a package cleaningly?

答:
Your question is not very clear, but I'll try to answer.

1. You installed python3.7 your self

when you installed python3.7, you typed

```<code>yum install python3
</code>```

so if you want to remove it, you can type the same name that you use to install it:

```<code>yum remove python3
</code>```

2. someone else installed it

In this case you can trace the binary that you want to remove, let's say python3.7. First you can see what is the full path of that binary:

```<code>which python3.7
</code>```

which gives

```<code>/usr/bin/python3.7
</code>```

now you can query which package installed that file:

```<code>rpm -qf /usr/bin/python3.7
</code>```

which will yield the full package name, something like:

```<code>python36-3.6.8-2.module_el8.0.0+33+0a10c0e1.x86_64
</code>```

which you can then use to remove it:

```<code>yum remove python36-3.6.8-2.module_el8.0.0+33+0a10c0e1.x86_64
</code>```

Body:
Your question is not very clear, but I'll try to answer.

1. You installed python3.7 your self

when you installed python3.7, you typed

yum install python3

so if you want to remove it, you can type the same name that you use to install it:

yum remove python3

2. someone else installed it

In this case you can trace the binary that you want to remove, let's say python3.7. First you can see what is the full path of that binary:

which python3.7

which gives

/usr/bin/python3.7

now you can query which package installed that file:

rpm -qf /usr/bin/python3.7

which will yield the full package name, something like:

python36-3.6.8-2.module_el8.0.0+33+0a10c0e1.x86_64

which you can then use to remove it:

yum remove python36-3.6.8-2.module_el8.0.0+33+0a10c0e1.x86_64


问:
How correctly filter column with data separated by a comma?
Let's say I have such DataFrame.

```<code>+-----------+
|amount     |
+-----------+
|100,200,300|
|73         |
|56,89      |
+-----------+
</code>```

Also, I have an array with numbers: var array = Array(200, 73).

I want to filter this DataFrame by the array and take such a result:

```<code>+-----------+
|amount     |
+-----------+
|100,200,300|
|73         |
+-----------+
</code>```

I used such code but it doesn't work the way I thought it would

```<code>df.filter(col("amount").isin(array: _*))
</code>```

My next code returns such a result:

```<code>+-----------+
|amount     |
+-----------+
|73         |
+-----------+
</code>```

What's wrong I did?

答:
The isin method, compare the exact version of left hand side string with array of values in right side. The issue in your case is, it tried to compare the string "100,200,300" with string "200", obviously it won't match.

One way of solving the issue is to explode the string column split by comma and then do apply the isin method on the exploded column it will work.

```<code>df.withColumn("exploded", explode(split(col("amount"), ",")))
.filter(col("exploded").isin(array: _*))
.drop(col("exploded"))
.show()
</code>```

Body:
Let's say I have such DataFrame.

+-----------+
|amount     |
+-----------+
|100,200,300|
|73         |
|56,89      |
+-----------+

Also, I have an array with numbers: var array = Array(200, 73).

I want to filter this DataFrame by the array and take such a result:

+-----------+
|amount     |
+-----------+
|100,200,300|
|73         |
+-----------+

I used such code but it doesn't work the way I thought it would

df.filter(col("amount").isin(array: _*))

My next code returns such a result:

+-----------+
|amount     |
+-----------+
|73         |
+-----------+

What's wrong I did?

Body:
The isin method, compare the exact version of left hand side string with array of values in right side. The issue in your case is, it tried to compare the string "100,200,300" with string "200", obviously it won't match.

One way of solving the issue is to explode the string column split by comma and then do apply the isin method on the exploded column it will work.

df.withColumn("exploded", explode(split(col("amount"), ",")))
.filter(col("exploded").isin(array: _*))
.drop(col("exploded"))
.show()


问:
Matcher find a pattern but throw No match available on `start` method
I want to get the a sub string of the text after the regex, therefore I check if it exist with find, then I try to get start / end / group but java.lang.IllegalStateException: No match available is thrown.

```<code>String text = "Hello bob, remind me to do a lot of things today";
pattern = Pattern.compile("remind.*.to.");
// Looking for "remind <anyWord> to "
if (pattern.matcher(text).find())
{
    pattern.matcher(text).group();
}
</code>```

The regex is found, therefore I in the condition, but start() (/any other int method) throw an exception.

答:
Problem is that you're using pattern.matcher(text) again and that creates another Matcher instance and when you call start() on a new instance it throws exception since find or matches or lookingAt has not been called before.

You may use it like this:

```<code>String text = "Hello bob, remind me to do a lot of things today";
final Pattern pattern = Pattern.compile("remind.*\\hto\\h");
Matcher m = pattern.matcher(text); // create it only once
// Looking for "remind <anyWord> to "
if (m.find()) {
    System.err.println( "Start: " + m.start() + ", match: " + m.group() );
}
</code>```

Also note changes in your regex. \h matches a horizontal whitespace whereas .to. will match any character before and after to hence your regex will match:

```<code>"remind me to do a lot of things tod"
</code>```

instead of intended:

```<code>"remind me to do "
</code>```

Body:
I want to get the a sub string of the text after the regex, therefore I check if it exist with find, then I try to get start / end / group but java.lang.IllegalStateException: No match available is thrown.

String text = "Hello bob, remind me to do a lot of things today";
pattern = Pattern.compile("remind.*.to.");
// Looking for "remind <anyWord> to "
if (pattern.matcher(text).find())
{
    pattern.matcher(text).group();
}

The regex is found, therefore I in the condition, but start() (/any other int method) throw an exception.

Body:
Problem is that you're using pattern.matcher(text) again and that creates another Matcher instance and when you call start() on a new instance it throws exception since find or matches or lookingAt has not been called before.

You may use it like this:

String text = "Hello bob, remind me to do a lot of things today";
final Pattern pattern = Pattern.compile("remind.*\\hto\\h");
Matcher m = pattern.matcher(text); // create it only once
// Looking for "remind <anyWord> to "
if (m.find()) {
    System.err.println( "Start: " + m.start() + ", match: " + m.group() );
}

Also note changes in your regex. \h matches a horizontal whitespace whereas .to. will match any character before and after to hence your regex will match:

"remind me to do a lot of things tod"

instead of intended:

"remind me to do "


问:
add a SortedSet directly to a Map
i want to add a SortedSet directly into a map.

my Map looks as follows:

```<code>Map<Integer, SortedSet<String>> categorizedResult = new HashMap<>();
</code>```

currently i'm adding the SortedSet as follows:

```<code>SortedSet<String> sSOne = new TreeSet<>();
SortedSet<String> sSTwo = new TreeSet<>();

sSOne.add("Some String in Set one");
sSTwo.add("Some String in Set two");

categorizedResult.put(1, sSOne);
categorizedResult.put(2, sSTwo);

// return Map or something...

</code>```

Now imagine a Map with atleast 10 SortedSets. Obviously the process of adding all of these 10 SortedSets gets confusing and annoying quite fast.
Is there a way to directly add the SortedSet into the Map without the more or less redundant SortedSets(sSOne, sSTwo)? Overwriting the previous value is not desired. The above code is executed in a loop.
Im thinking of something like this:

```<code>Map<Integer, SortedSet<String>> categorizedResult = new HashMap<>();

categorizedResult.put(1, addDirectlyToMap("Some String in Set one");
categorizedResult.put(2, addDirectlyToMap("Some String in Set two");

</code>```

Thanks in advance

答:
Another option would be to create a Facade like structure for your Map e.g.

public class SortedMapFacade extends HashMap<Integer, SortedSet> {

    public SortedSet<String> put(Integer key, String value) {
        SortedSet sortedSet = get(key);
        if (sortedSet == null) {
            sortedSet = new TreeSet();
        }
        sortedSet.add(value);
        return put(key, sortedSet);
    }

}

```

<p>This will provide you with an extra helper method for your Map and can be used as follows</p>

```SortedMapFacade mapFacade = new SortedMapFacade();
mapFacade.put(1, "A value");
mapFacade.put(1, "Another value");
mapFacade.put(2, "Yet another value");

```

Title: add a SortedSet directly to a Map

Body:
i want to add a SortedSet directly into a map.

my Map looks as follows:

Map<Integer, SortedSet<String>> categorizedResult = new HashMap<>();

currently i'm adding the SortedSet as follows:

SortedSet<String> sSOne = new TreeSet<>();
SortedSet<String> sSTwo = new TreeSet<>();

sSOne.add("Some String in Set one");
sSTwo.add("Some String in Set two");

categorizedResult.put(1, sSOne);
categorizedResult.put(2, sSTwo);

// return Map or something...

Now imagine a Map with atleast 10 SortedSets. Obviously the process of adding all of these 10 SortedSets gets confusing and annoying quite fast.
Is there a way to directly add the SortedSet into the Map without the more or less redundant SortedSets(sSOne, sSTwo)? Overwriting the previous value is not desired. The above code is executed in a loop.
Im thinking of something like this:

Map<Integer, SortedSet<String>> categorizedResult = new HashMap<>();

categorizedResult.put(1, addDirectlyToMap("Some String in Set one");
categorizedResult.put(2, addDirectlyToMap("Some String in Set two");

Thanks in advance

Body:
Another option would be to create a Facade like structure for your Map e.g.

public class SortedMapFacade extends HashMap<Integer, SortedSet> {

    public SortedSet<String> put(Integer key, String value) {
        SortedSet sortedSet = get(key);
        if (sortedSet == null) {
            sortedSet = new TreeSet();
        }
        sortedSet.add(value);
        return put(key, sortedSet);
    }

}

This will provide you with an extra helper method for your Map and can be used as follows

SortedMapFacade mapFacade = new SortedMapFacade();
mapFacade.put(1, "A value");
mapFacade.put(1, "Another value");
mapFacade.put(2, "Yet another value");


问:
Python how to insert extracted title from name field and add it to its specific column and index?
I am trying to extract the title from name field in a dataframe and append into new column using python:

```<code>import pandas as pd
df = pd.DataFrame(columns = ['id', 'name'])
df = df.append({'id': 123, 'name': 'Mr. Rooney'}, ignore_index=True)
df = df.append({'id': 124, 'name': 'Miss. Aniston'}, ignore_index=True)
df = df.append({'id': 125, 'name': 'Sir. Alex'}, ignore_index=True)
</code>```

And then I have the following list containing title names:

```<code>titles = ['Miss.', 'Mr.', 'Master', 'Sir.', 'Mrs.']
</code>```

I've added a new column to the data frame:

```<code>df['Title']=''
</code>```

Now I will iterate all the rows and write the existing title of each name at its corresponding row:

```<code>for idx, row in (df.iterrows()):
  for t in titles:
    if(t in row['name']):
      df['Title']=t
</code>```

Apparently I am not been able to iterate over each index. I am new to python for data science.

How to extract the title for each row and add to its corespondent index?

答:
Try this way:

your pattern:

```<code>titles = r"([Miss|Mr|Master|Sir|Mrs]+.)"
</code>```

New column title would be:

```<code>df['title']=df['name'].str.extract(titles)
</code>```

Body:
I am trying to extract the title from name field in a dataframe and append into new column using python:

import pandas as pd
df = pd.DataFrame(columns = ['id', 'name'])
df = df.append({'id': 123, 'name': 'Mr. Rooney'}, ignore_index=True)
df = df.append({'id': 124, 'name': 'Miss. Aniston'}, ignore_index=True)
df = df.append({'id': 125, 'name': 'Sir. Alex'}, ignore_index=True)

And then I have the following list containing title names:

titles = ['Miss.', 'Mr.', 'Master', 'Sir.', 'Mrs.']

I've added a new column to the data frame:

df['Title']=''

Now I will iterate all the rows and write the existing title of each name at its corresponding row:

for idx, row in (df.iterrows()):
  for t in titles:
    if(t in row['name']):
      df['Title']=t

Apparently I am not been able to iterate over each index. I am new to python for data science.

How to extract the title for each row and add to its corespondent index?

Body:
Try this way:

your pattern:

titles = r"([Miss|Mr|Master|Sir|Mrs]+.)"

New column title would be:

df['title']=df['name'].str.extract(titles)


问:
Is there a way to unsuppress a column in ToolPanel in ag-grid?
I need a specific column to show in the ToolPanel in specific cases only.

So in the columnDefs, I've set the suppressToolPanel: true for that column.

However, I can't find a way to unsuppress it, and show that specific column in the ToolPanel in the case I need it.

PS, I've tried column visibility but that doesn't work because even when hiding the column, it still shows in the ToolPanel. The only way to hide it in the ToolPanel is to suppress it.

答:
Unfortunately, suppressColumnsToolPanel can't be a function like editable property.

suppressColumnsToolPanel    Set to true if you do not want this column or group to appear in the Columns Tool Panel.

but you can create own custom toolpanel component and track (and change) whatever you want


答:
You have to call pattern.matcher(text) one time, to do this, just create a Matcher like so:

```<code>Matcher matcher = pattern.matcher(text);
if (matcher.find()) {
    String result = matcher.group();
    //output: "remind me to do a lot of things tod"
}
</code>```

Title: Matcher find a pattern but throw No match available on `start` method

Body:
You have to call pattern.matcher(text) one time, to do this, just create a Matcher like so:

Matcher matcher = pattern.matcher(text);
if (matcher.find()) {
    String result = matcher.group();
    //output: "remind me to do a lot of things tod"
}


问:
Spring boot cannot find my template view There was an unexpected error (type=Not Found, status=404)
I spent almost a day trying to fix this without any luck

i am integrating spring boot mongodb and thymeleaf

Here is my controller

```<code>@Controller
public class ItemController {
  @Autowired
  private ItemService itemService;

  @GetMapping("/items")
  public String home(Model model) {
    model.addAttribute("items", new ItemEntity());
    List<ItemEntity> items = itemService.findAll();
    model.addAttribute("items", items);
    return "item";
  }
}
</code>```

this is my html template

```<code><!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <title>Title</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"/>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
</head>
<body>
<div class="container-fluid">
    <div class="row">
        <div class="col-md-12">
            <h2>FileUpload</h2>
            <form action="" th:action="@{'/fileupload'}" th:object="${item}" method="post"
                  enctype='multipart/form-data'>
                <div class="form-group">
                    <label for="fileupload">File Upload(excel or csv)</label>
                    <input type="file" class="form-control" id="file" name="file" th:field="*{file}"/>
                </div>
                <button type="submit" class="btn btn-default">Submit</button>
            </form>
        </div>
        <div class="col-md-12">
            <h2>All items</h2>
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th>height</th>
                    <th>width</th>
                    <th>length</th>
                    <th>weight</th>
                    <th>securityLevel</th>
                    <th>file type</th>
                </tr>
                </thead>
                <tbody>
                <tr th:each="item : ${items}">
                    <td th:text="${item.height}">John</td>
                    <td th:text="${item.width}">Doe</td>
                    <td th:text="${item.length}">john@example.com</td>
                    <td th:text="${item.weight}">john@example.com</td>
                    <td th:text="${item.securityLevel}">john@example.com</td>
                    <td th:text="${item.fileType}">john@example.com</td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
</body>
</html>
</code>```

build.gradle

```<code>plugins {
    id 'org.springframework.boot' version '2.2.4.RELEASE'
    id 'io.spring.dependency-management' version '1.0.9.RELEASE'
    id 'java'
}

group = 'com.vending'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
    implementation 'org.springframework.boot:spring-boot-devtools'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
    implementation 'org.springframework.boot:spring-boot-starter-web'
    compile group: 'com.opencsv', name: 'opencsv', version: '4.4'
    compile group: 'org.apache.poi', name: 'poi', version: '3.9'
    compile group: 'commons-io', name: 'commons-io', version: '2.6'
    compile group: 'org.thymeleaf', name: 'thymeleaf', version: '2.0.5'
    compile group: 'nz.net.ultraq.thymeleaf', name: 'thymeleaf-layout-dialect', version: '1.2'
}

test {
    useJUnitPlatform()
}
</code>```

i also have these for mongod inside application.properties

```<code>spring.data.mongodb.database=vending
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
</code>```

when i run VendingApplication and go to http://localhost:8080/items i get this

Whitelabel Error Page
  This application has no explicit mapping for /error, so you are seeing this as a fallback.

Sat Feb 15 03:26:41 EST 2020
  There was an unexpected error (type=Not Found, status=404).
  No message available

it looks like spring is failing to resolve templates view for some reason

UPDATE:

The problem came from the database name which did not map mine

```<code>application.properties
spring.data.mongodb.database=your_db_name
</code>```

答:
For the once who it might concern, the problem for me was coming from the database name on the application.properties spring.data.mongodb.database

I had to map it to my document collection

Body:
I spent almost a day trying to fix this without any luck

i am integrating spring boot mongodb and thymeleaf

Here is my controller

@Controller
public class ItemController {
  @Autowired
  private ItemService itemService;

  @GetMapping("/items")
  public String home(Model model) {
    model.addAttribute("items", new ItemEntity());
    List<ItemEntity> items = itemService.findAll();
    model.addAttribute("items", items);
    return "item";
  }
}

this is my html template

<!DOCTYPE html>

    <meta charset="UTF-8"/>
    <title>Title</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"/>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>

FileUpload

            <form action="" th:action="@{'/fileupload'}" th:object="${item}" method="post"
                  enctype='multipart/form-data'>

                    File Upload(excel or csv)
                    <input type="file" class="form-control" id="file" name="file" th:field="*{file}"/>

                <button type="submit" class="btn btn-default">Submit</button>
            </form>

All items

                    height
                    width
                    length
                    weight
                    securityLevel
                    file type

                    John
                    Doe
                    john@example.com
                    john@example.com
                    john@example.com
                    john@example.com

build.gradle

plugins {
    id 'org.springframework.boot' version '2.2.4.RELEASE'
    id 'io.spring.dependency-management' version '1.0.9.RELEASE'
    id 'java'
}

group = 'com.vending'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
    implementation 'org.springframework.boot:spring-boot-devtools'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
    implementation 'org.springframework.boot:spring-boot-starter-web'
    compile group: 'com.opencsv', name: 'opencsv', version: '4.4'
    compile group: 'org.apache.poi', name: 'poi', version: '3.9'
    compile group: 'commons-io', name: 'commons-io', version: '2.6'
    compile group: 'org.thymeleaf', name: 'thymeleaf', version: '2.0.5'
    compile group: 'nz.net.ultraq.thymeleaf', name: 'thymeleaf-layout-dialect', version: '1.2'
}

test {
    useJUnitPlatform()
}

i also have these for mongod inside application.properties

spring.data.mongodb.database=vending
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017

when i run VendingApplication and go to http://localhost:8080/items i get this

Whitelabel Error Page
  This application has no explicit mapping for /error, so you are seeing this as a fallback.

Sat Feb 15 03:26:41 EST 2020
  There was an unexpected error (type=Not Found, status=404).
  No message available

it looks like spring is failing to resolve templates view for some reason

UPDATE:

The problem came from the database name which did not map mine

application.properties
spring.data.mongodb.database=your_db_name


问:
How to validate decimal value in vee validate 3.0 version
I want to validate latitude and logitude value and my code is

```<code>    <ValidationProvider :name=waypointLang.form.latitude rules="required|decimal">
        <div slot-scope="{ errors }">
            <input v-model="waypoint.latitude" readonly name="latitude" type="text" autofocus :placeholder="waypointLang.form.latitude" class="form-control" id="latitude"/>
                   <span class="required-field">{{ errors[0]}}</span>
        </div>
    </ValidationProvider>
</code>```

I got error No such validator 'decimal' exists.

Thanks in advance

答:
You can also solve this with BigNumber.js if you need to support larger numbers and exponentials:</p>

```<code>Validator.extend('decimals', {
    validate(value, args) {
        const decimals = new BigNumber(value).decimalPlaces()

        if (args[0] === null || args[0] === undefined) {
            return decimals >= 0
        }

        return decimals <= args[0]
    }
})
</code>```

Body:
I want to validate latitude and logitude value and my code is

    <ValidationProvider :name=waypointLang.form.latitude rules="required|decimal">

            <input v-model="waypoint.latitude" readonly name="latitude" type="text" autofocus :placeholder="waypointLang.form.latitude" class="form-control" id="latitude"/>
                   {{ errors[0]}}

    </ValidationProvider>

I got error No such validator 'decimal' exists.

Thanks in advance

Body:
You can also solve this with BigNumber.js if you need to support larger numbers and exponentials:

Validator.extend('decimals', {
    validate(value, args) {
        const decimals = new BigNumber(value).decimalPlaces()

        if (args[0] === null || args[0] === undefined) {
            return decimals >= 0
        }

        return decimals <= args[0]
    }
})


问:
How to create a left navbar with bootstrap?
How to create a left navbar with bootstrap ?
I did it

```<code><nav class="btn-group-vertical float-left navbar">
    <button routerLink="product/home" routerLinkActive="is-active" class="btn btn-outline-dark">Home</button>
    <button routerLink="product/favorite" routerLinkActive="is-active" class="btn btn-outline-dark">Favorite</button>
</nav>
</code>```

But the problem that i see it as unexpected

I want that all hoe work be with good position
but use bootstrap 4 well

Thank for help :-)

答:
Here it is a nice, modern and responsive approach that I used in one of my projects. I hope it helps.

Note: The javascript part would be replaced by a shared service in your angular application's core module where you should use BehaviourSubject to communicate the state of the sidenav from another component.

Quick example:

```<code>export class SidenavService {

    private sidenavState$ = new BehaviorSubject<boolean>(false);

    ...
</code>```

const sidenav = document.querySelector('#sidenav');

const toggleSidenav = state => {
  sidenav.className = state ?
  sidenav.className.replace('closed', 'opened') :
  sidenav.className.replace('opened', 'closed');
}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.grid-container {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 60px 1fr 60px;
  grid-template-areas: 'header''main''footer';
  height: 100vh;
}

@media only screen and (min-width: 768px) {
  .grid-container {
    grid-template-columns: 260px 1fr;
    grid-template-areas: "sidenav header""sidenav main""sidenav footer";
  }
}

.sidenav {
  grid-area: sidenav;
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 260px;
  padding: 0 .8rem;
  position: fixed;
  overflow-y: auto;
  z-index: 4;
  transform: translateX(-300px);
  box-shadow: 0 1rem 2rem rgba(0, 0, 0, .5);
  transition: all .1s linear;
  background-color: #fff;
}

.sidenav.opened {
  transform: translateX(0);
}

.sidenav__open-icon:hover {
  background-color: #ececec;
}

.sidenav__close-icon {
  position: absolute;
  visibility: visible;
  top: 5px;
  right: 5px;
  cursor: pointer;
  font-size: 20px;
  width: 20px;
  height: 20px;
  color: #e0e0e0;
  display: grid;
  place-items: center;
  border: solid 1px transparent;
  border-radius: 50%;
  background-color: transparent;
}

@media only screen and (min-width: 768px) {
  .sidenav {
    transform: translateX(0);
  }
  .sidenav__close-icon {
    visibility: hidden;
  }
}

ul.sidenav__list {
  padding: 0;
  margin-top: 1rem;
  list-style-type: none;
  max-width: 340px;
  overflow-y: auto;
}

li.sidenav__list-item {
  margin-bottom: 4px;
  background-color: #ddd;
  border: solid 1px transparent;
  border-radius: 6px;
  border-bottom: solid 4px #d2d2d2;
}

li.sidenav__list-item>a {
  width: 100%;
  padding: .7rem 1rem;
  display: block;
  position: relative;
  color: #333;
  text-decoration: none;
}

li.sidenav__list-item>a:hover,
li.sidenav__sublist-item>a:hover {
  background-color: #d2d2d2;
  cursor: pointer;
}

.sidenav__icon {
  width: 40px;
  padding: 0 2px;
  display: inline-block;
  margin-right: .4rem;
}

li.sidenav__list-item>a .caret {
  position: absolute;
  right: 16px;
  top: auto;
}

li.sidenav__list-item>a .caret>i {
  font-size: 12px;
}

ul.sidenav__sublist {
  padding: 0;
  list-style-type: none;
}

li.sidenav__sublist-item:first-child {
  margin: .5rem 0 0;
}

li.sidenav__sublist-item>a {
  width: 100%;
  padding: .5rem 1rem;
  font-size: 80%;
  display: block;
  position: relative;
  color: #333;
  border: solid 1px transparent;
  border-radius: 4px;
}

[role="nav-menu"],
[role="nav-dropdown-item"] {
  cursor: pointer !important;
}

[role="nav-dropdown"] {
  cursor: default !important;
}

.header {
  grid-area: header;
  background-color: #ddd;
}

main {
  grid-area: main;
}

footer {
  grid-area: footer;
}</code>```

<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<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">

          Home

          Configuration

              Option 1

              Option 2

      header

      body

      footer

  <button onclick="toggleSidenav(true)">open</button>
  <button onclick="toggleSidenav(false)">close</button>

```

Body:
How to create a left navbar with bootstrap ?
I did it

    <button routerLink="product/home" routerLinkActive="is-active" class="btn btn-outline-dark">Home</button>
    <button routerLink="product/favorite" routerLinkActive="is-active" class="btn btn-outline-dark">Favorite</button>

But the problem that i see it as unexpected

I want that all hoe work be with good position
but use bootstrap 4 well

Thank for help :-)

Body:
Here it is a nice, modern and responsive approach that I used in one of my projects. I hope it helps.

Note: The javascript part would be replaced by a shared service in your angular application's core module where you should use BehaviourSubject to communicate the state of the sidenav from another component.

Quick example:

export class SidenavService {

    private sidenavState$ = new BehaviorSubject<boolean>(false);

    ...

const sidenav = document.querySelector('#sidenav');

const toggleSidenav = state => {
  sidenav.className = state ?
  sidenav.className.replace('closed', 'opened') :
  sidenav.className.replace('opened', 'closed');
}

.grid-container {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 60px 1fr 60px;
  grid-template-areas: 'header''main''footer';
  height: 100vh;
}

@media only screen and (min-width: 768px) {
  .grid-container {
    grid-template-columns: 260px 1fr;
    grid-template-areas: "sidenav header""sidenav main""sidenav footer";
  }
}

.sidenav {
  grid-area: sidenav;
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 260px;
  padding: 0 .8rem;
  position: fixed;
  overflow-y: auto;
  z-index: 4;
  transform: translateX(-300px);
  box-shadow: 0 1rem 2rem rgba(0, 0, 0, .5);
  transition: all .1s linear;
  background-color: #fff;
}

.sidenav.opened {
  transform: translateX(0);
}

.sidenav__open-icon:hover {
  background-color: #ececec;
}

.sidenav__close-icon {
  position: absolute;
  visibility: visible;
  top: 5px;
  right: 5px;
  cursor: pointer;
  font-size: 20px;
  width: 20px;
  height: 20px;
  color: #e0e0e0;
  display: grid;
  place-items: center;
  border: solid 1px transparent;
  border-radius: 50%;
  background-color: transparent;
}

@media only screen and (min-width: 768px) {
  .sidenav {
    transform: translateX(0);
  }
  .sidenav__close-icon {
    visibility: hidden;
  }
}

ul.sidenav__list {
  padding: 0;
  margin-top: 1rem;
  list-style-type: none;
  max-width: 340px;
  overflow-y: auto;
}

li.sidenav__list-item {
  margin-bottom: 4px;
  background-color: #ddd;
  border: solid 1px transparent;
  border-radius: 6px;
  border-bottom: solid 4px #d2d2d2;
}

li.sidenav__list-item>a {
  width: 100%;
  padding: .7rem 1rem;
  display: block;
  position: relative;
  color: #333;
  text-decoration: none;
}

li.sidenav__list-item>a:hover,
li.sidenav__sublist-item>a:hover {
  background-color: #d2d2d2;
  cursor: pointer;
}

.sidenav__icon {
  width: 40px;
  padding: 0 2px;
  display: inline-block;
  margin-right: .4rem;
}

li.sidenav__list-item>a .caret {
  position: absolute;
  right: 16px;
  top: auto;
}

li.sidenav__list-item>a .caret>i {
  font-size: 12px;
}

ul.sidenav__sublist {
  padding: 0;
  list-style-type: none;
}

li.sidenav__sublist-item:first-child {
  margin: .5rem 0 0;
}

li.sidenav__sublist-item>a {
  width: 100%;
  padding: .5rem 1rem;
  font-size: 80%;
  display: block;
  position: relative;
  color: #333;
  border: solid 1px transparent;
  border-radius: 4px;
}

[role="nav-menu"],
[role="nav-dropdown-item"] {
  cursor: pointer !important;
}

[role="nav-dropdown"] {
  cursor: default !important;
}

.header {
  grid-area: header;
  background-color: #ddd;
}

main {
  grid-area: main;
}

footer {
  grid-area: footer;
}

<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<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">

<div class="grid-container">
  <div id="sidenav" class="sidenav closed">
    <ul class="sidenav__list">
      <li class="sidenav__list-item">
        <!-- Menú con navegación -->
        <a role="nav-menu">
          <span class="sidenav__icon">
          <i class="{{m.iconoMenu}}"></i>
          </span>
          <span class="sidenav__title">Home</span>
        </a>
      </li>

      <!-- Menú sin navegación -->
      <li class="sidenav__list-item">
        <a class="accordion-toggle collapsed toggle-switch" data-toggle="collapse" href="#submenu-1" role="nav-dropdown">
          <span class="sidenav__icon">
            <i class="fas fa-home"></i>
          </span>
          <span class="sidenav__title">
          Configuration
          </span>
          <b class="caret">
            <i class="fas fa-caret-down"></i>
          </b>
        </a>
        <ul id="submenu-1" class="sidenav__sublist panel-collapse collapse panel-switch" role="menu">
          <li class="sidenav__sublist-item" role="nav-dropdown-item">
            <a href="#">
              <span class="sidenav__icon"><i class="fas fa-cog"></i></span>
              <span class="sidenav__title">Option 1</span>
            </a>
          </li>
          <li class="sidenav__sublist-item" role="nav-dropdown-item">
            <a href="#">
              <span class="sidenav__icon"><i class="fas fa-cog"></i></span>
              <span class="sidenav__title">Option 2</span>
            </a>
          </li>
        </ul>
      </li>
    </ul>
  </div>
  <div class="header">
    <div class="container-fluid">
      header
    </div>
  </div>
  <main>
    <div class="container-fluid">
      body
    </div>
  </main>
  <footer>
    <div class="container-fluid">
      footer
    </div>
  </footer>
</div>

<div style="position: absolute; right: 40px; top: 80px">
  <button onclick="toggleSidenav(true)">open</button>
  <button onclick="toggleSidenav(false)">close</button>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>


问:
Attempt to present UIViewController on UIViewController whose view is not in the window hierarchy
Just started using Xcode 4.5 and I got this error in the console:

Warning: Attempt to present < finishViewController: 0x1e56e0a0 > on < ViewController: 0x1ec3e000> whose view is not in the window hierarchy!

The view is still being presented and everything in the app is working fine. Is this something new in iOS 6?

This is the code I'm using to change between views:

```<code>UIStoryboard *storyboard = self.storyboard;
finishViewController *finished =
[storyboard instantiateViewControllerWithIdentifier:@"finishViewController"];

[self presentViewController:finished animated:NO completion:NULL];
</code>```

答:
The message appear as warning and sometimes the code refuses to work. (!Needs Citation: Newer SDK's might have strict rules).

I have encountered it for more than one reason, mostly complicated viewcontroller scenarios. Here's an example.

```<code>Scenario: MainViewController (responsible to load: ViewControllerA & ViewControllerB)
</code>```

Present ViewControllerA from MainViewController and without dismissing the ViewControllerA you try to present viewControllerB from MainViewController (using a delegate method).

In this scenario, you'd have to make sure your ViewControllerA is dismissed and then the ViewControllerB is called.

Because after presenting ViewControllerA (ViewControllerA becomes responsible for displaying views and viewcontrollers and when MainViewController attempts to load another viewcontoller, it refuses to work with throwing a warning).

Body:
Just started using Xcode 4.5 and I got this error in the console:

Warning: Attempt to present < finishViewController: 0x1e56e0a0 > on < ViewController: 0x1ec3e000> whose view is not in the window hierarchy!

The view is still being presented and everything in the app is working fine. Is this something new in iOS 6?

This is the code I'm using to change between views:

UIStoryboard *storyboard = self.storyboard;
finishViewController *finished =
[storyboard instantiateViewControllerWithIdentifier:@"finishViewController"];

[self presentViewController:finished animated:NO completion:NULL];

Body:
The message appear as warning and sometimes the code refuses to work. (!Needs Citation: Newer SDK's might have strict rules).

I have encountered it for more than one reason, mostly complicated viewcontroller scenarios. Here's an example.

Scenario: MainViewController (responsible to load: ViewControllerA & ViewControllerB)

Present ViewControllerA from MainViewController and without dismissing the ViewControllerA you try to present viewControllerB from MainViewController (using a delegate method).

In this scenario, you'd have to make sure your ViewControllerA is dismissed and then the ViewControllerB is called.

Because after presenting ViewControllerA (ViewControllerA becomes responsible for displaying views and viewcontrollers and when MainViewController attempts to load another viewcontoller, it refuses to work with throwing a warning).


问:
MySQL: Error Code: 1118 Row size too large (> 8126). Changing some columns to TEXT or BLOB
I want to create a table of 325 column:

```<code>CREATE TABLE NAMESCHEMA.NAMETABLE
(
      ROW_ID TEXT NOT NULL ,        //this is the primary key

324 column of these types:
      CHAR(1),
      DATE,
      DECIMAL(10,0),
      DECIMAL(10,7),
      TEXT,
      LONG,

) ROW_FORMAT=COMPRESSED;
</code>```

I replaced all the VARCHAR with the TEXT and i have added Barracuda in the my.ini file of MySQL, this is the attributes added:

```<code>innodb_file_per_table=1
innodb_file_format=Barracuda
innodb_file_format_check = ON
</code>```

but i still have this error:

```<code>Error Code: 1118
 Row size too large (> 8126). Changing some columns to TEXT or BLOB may help. In current row format, BLOB prefix of 0 bytes is stored inline.
</code>```

EDIT: I can't change the structure of the database because it's legacy application/system/database. The create of a new table, it's an export of the legacy database.

EDIT2: i wrote this question that is similar to others but inside there are some solution that i found on internet like VARCHAR and Barracuda, but i still have that problem so i decided to open a new question with already the classic answer inside for seeing if someone have other answers

答:
For MariaDB users (version >= 10.2.2) and MySQL (version >= 5.7), the simple solution is:</p>

```<code>ALTER TABLE `table` ROW_FORMAT=DYNAMIC;
</code>```

Body:
I want to create a table of 325 column:

CREATE TABLE NAMESCHEMA.NAMETABLE
(
      ROW_ID TEXT NOT NULL ,        //this is the primary key

324 column of these types:
      CHAR(1),
      DATE,
      DECIMAL(10,0),
      DECIMAL(10,7),
      TEXT,
      LONG,

) ROW_FORMAT=COMPRESSED;

I replaced all the VARCHAR with the TEXT and i have added Barracuda in the my.ini file of MySQL, this is the attributes added:

innodb_file_per_table=1
innodb_file_format=Barracuda
innodb_file_format_check = ON

but i still have this error:

Error Code: 1118
 Row size too large (> 8126). Changing some columns to TEXT or BLOB may help. In current row format, BLOB prefix of 0 bytes is stored inline.

EDIT: I can't change the structure of the database because it's legacy application/system/database. The create of a new table, it's an export of the legacy database.

EDIT2: i wrote this question that is similar to others but inside there are some solution that i found on internet like VARCHAR and Barracuda, but i still have that problem so i decided to open a new question with already the classic answer inside for seeing if someone have other answers

Body:
For MariaDB users (version >= 10.2.2) and MySQL (version >= 5.7), the simple solution is:

ALTER TABLE `table` ROW_FORMAT=DYNAMIC;


问:
How to download s3 object directly into memory in java
Is it possible to download S3object in Java directly into memory and get it removed when i'm done with  the task?

答:
For example, convert file data to string:</p>

```<code>S3Object s3object = s3.getObject(new GetObjectRequest(bucketName, key));
S3ObjectInputStream inputStream = s3object.getObjectContent();
StreamUtils.copyToString(inputStream, StandardCharsets.UTF_8);
</code>```

Body:
For example, convert file data to string:

S3Object s3object = s3.getObject(new GetObjectRequest(bucketName, key));
S3ObjectInputStream inputStream = s3object.getObjectContent();
StreamUtils.copyToString(inputStream, StandardCharsets.UTF_8);