问:
how to border with text and border size cuton left,right,top,botton girdview flutter
I want to this output

my dart

    Container(
                  height: SizeConfig.blockSizeVertical * 55,
                  child: Padding(
                    padding: EdgeInsets.all(10.0),
                    child: GridView(
                      physics: const ScrollPhysics(),
                      shrinkWrap: true,

                         Container(
                          width: 300,
                          height: 300,
    //BoxDecoration Widget

                          decoration: BoxDecoration(
                            border: Border.all(
                              color: HexColor.formhex('#c73b08'),
                              width: 20,
                            ),
                            borderRadius: const BorderRadius.only(
                              bottomLeft: const Radius.circular(20.0),
                            ),
                            //Border.all
                            boxShadow: const [
                              BoxShadow(
                                color: Colors.black,

                                offset: Offset(
                                  5.0,
                                  5.0,
                                ), //Offset
                                blurRadius: 10.0,
                                spreadRadius: 2.0,
                              ), //BoxShadow
                              BoxShadow(
                                offset: Offset(0.0, 0.0),
                                blurRadius: 0.0,
                                spreadRadius: 0.0,
                              ), //BoxShadow
                            ],
                          ),

                          child: Column(
                            children: [
                              Positioned(
                                left: 50,
                                top: 12,
                                child: Container(
                                  padding: const EdgeInsets.only(
                                      bottom: 10, left: 10, right: 10),
                                  color: Colors.white,
                                  child: const Text(
                                    'Create an account',
                                    style: TextStyle(
                                        color: Colors.black, fontSize: 12),
                                  ),
                                ),
                              ),
                              Expanded(
                                child: Text('reqular'),
                              ),
                              Expanded(
                                  child: ElevatedButton(
                                onPressed: () {},
                                style: ElevatedButton.styleFrom(
                                  primary: HexColor.formhex('#c02801'),
                                  shape: RoundedRectangleBorder(
                                    borderRadius: BorderRadius.circular(30.0),
                                  ),
                                ),
                                child: Text(
                                  'Select',
                                  textAlign: TextAlign.center,
                                  style: TextStyle(
                                      color: HexColor.formhex('#f7feff'),
                                      fontSize: SizeConfig.safeBlockHorizontal * 4,
                                      decoration: TextDecoration.none),
                                ),
                              )),
                            ],
                          ),
                        );
                      },
                      gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
                          crossAxisCount: 1,
                          mainAxisSpacing: 10,
                          crossAxisSpacing: 10),
                    ),
                  ),
                );
```

how to border with text and border size cuton left,right,top,botton girdview flutter.

答:
try this code:</p>
```<code>Stack(
      alignment: Alignment.center,
      children: [
        Container(
          child: Text('TITLE'),
          padding: EdgeInsets.all(16),
          decoration: BoxDecoration(
            color: Colors.red,
            borderRadius: BorderRadius.circular(20),
          ),
          width: 350,
          height: 200,
        ),
        Positioned(
          bottom: 10,
          right: 10,
          left: 10,
          child: Container(
            height: 140,
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.circular(20),
            ),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.end,
              children: [
                Text('some text'),
                InkWell(
                  onTap: () {},
                  child: Container(
                    decoration: BoxDecoration(
                      color: Colors.red,
                      borderRadius: BorderRadius.circular(10),
                    ),
                    alignment: Alignment.center,
                    width: 150,
                    margin: EdgeInsets.only(bottom: 10),
                    padding: EdgeInsets.symmetric(vertical: 10),
                    child: Text(
                      'SELECT',
                      style: TextStyle(
                          fontSize: 16,
                          fontWeight: FontWeight.bold,
                          color: Colors.white),
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
      ],
    )
</code>```

Body:
I want to this output

my dart

    Container(
                  height: SizeConfig.blockSizeVertical * 55,
                  child: Padding(
                    padding: EdgeInsets.all(10.0),
                    child: GridView(
                      physics: const ScrollPhysics(),
                      shrinkWrap: true,

                         Container(
                          width: 300,
                          height: 300,
    //BoxDecoration Widget

                          decoration: BoxDecoration(
                            border: Border.all(
                              color: HexColor.formhex('#c73b08'),
                              width: 20,
                            ),
                            borderRadius: const BorderRadius.only(
                              bottomLeft: const Radius.circular(20.0),
                            ),
                            //Border.all
                            boxShadow: const [
                              BoxShadow(
                                color: Colors.black,

                                offset: Offset(
                                  5.0,
                                  5.0,
                                ), //Offset
                                blurRadius: 10.0,
                                spreadRadius: 2.0,
                              ), //BoxShadow
                              BoxShadow(
                                offset: Offset(0.0, 0.0),
                                blurRadius: 0.0,
                                spreadRadius: 0.0,
                              ), //BoxShadow
                            ],
                          ),

                          child: Column(
                            children: [
                              Positioned(
                                left: 50,
                                top: 12,
                                child: Container(
                                  padding: const EdgeInsets.only(
                                      bottom: 10, left: 10, right: 10),
                                  color: Colors.white,
                                  child: const Text(
                                    'Create an account',
                                    style: TextStyle(
                                        color: Colors.black, fontSize: 12),
                                  ),
                                ),
                              ),
                              Expanded(
                                child: Text('reqular'),
                              ),
                              Expanded(
                                  child: ElevatedButton(
                                onPressed: () {},
                                style: ElevatedButton.styleFrom(
                                  primary: HexColor.formhex('#c02801'),
                                  shape: RoundedRectangleBorder(
                                    borderRadius: BorderRadius.circular(30.0),
                                  ),
                                ),
                                child: Text(
                                  'Select',
                                  textAlign: TextAlign.center,
                                  style: TextStyle(
                                      color: HexColor.formhex('#f7feff'),
                                      fontSize: SizeConfig.safeBlockHorizontal * 4,
                                      decoration: TextDecoration.none),
                                ),
                              )),
                            ],
                          ),
                        );
                      },
                      gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
                          crossAxisCount: 1,
                          mainAxisSpacing: 10,
                          crossAxisSpacing: 10),
                    ),
                  ),
                );

how to border with text and border size cuton left,right,top,botton girdview flutter.

Body:
try this code:

Stack(
      alignment: Alignment.center,
      children: [
        Container(
          child: Text('TITLE'),
          padding: EdgeInsets.all(16),
          decoration: BoxDecoration(
            color: Colors.red,
            borderRadius: BorderRadius.circular(20),
          ),
          width: 350,
          height: 200,
        ),
        Positioned(
          bottom: 10,
          right: 10,
          left: 10,
          child: Container(
            height: 140,
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.circular(20),
            ),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.end,
              children: [
                Text('some text'),
                InkWell(
                  onTap: () {},
                  child: Container(
                    decoration: BoxDecoration(
                      color: Colors.red,
                      borderRadius: BorderRadius.circular(10),
                    ),
                    alignment: Alignment.center,
                    width: 150,
                    margin: EdgeInsets.only(bottom: 10),
                    padding: EdgeInsets.symmetric(vertical: 10),
                    child: Text(
                      'SELECT',
                      style: TextStyle(
                          fontSize: 16,
                          fontWeight: FontWeight.bold,
                          color: Colors.white),
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
      ],
    )


来源: stackexchange

问:
How to create a url that opens a tab downloads a file and closes the tab
I want to create an URL that when clicked upon opens a tab, downloads a file, and closes that tab. Do you guys know how to do it?
Following is an example: https://cdn.discordapp.com/attachments/850262728428748830/937385812671209502/vineboom.ogg

I am quite new to this and overwhelmed to know where to start. Can somebody assist me with this?
I tried messing with Anchor tag but that is not the answer. According to my research figured it has something to do with NodeJS and ExpressJS. Still no idea of what to do.

答:
Create require variables as shown and then created a function with whatever name you like, here I am using "onLoad" as the name. This function just checks for the file name in the URL's file parameter specified then tries to find it in the server.

var url_string = window.location; //window.location.href
var url = new URL(url_string);
var file = url.searchParams.get("file");
var dFile = file;

function onLoad() {
    var hiddenElement = document.createElement('a');

hiddenElement.href = `${dFile}`;
hiddenElement.target = '_blank';
hiddenElement.download = `${dFile}`;
hiddenElement.click();
close()
}```
</div>
</div>

Make sure to add onLoad function into the body with event listener of "onload"</p>
<pre class="lang-html prettyprint-override"><code><!DOCTYPE html>
<body onload="onLoad()">
</body>
</code>```

ContentLicense: CC BY-SA 4.0

Body:
Create require variables as shown and then created a function with whatever name you like, here I am using "onLoad" as the name. This function just checks for the file name in the URL's file parameter specified then tries to find it in the server.

var url_string = window.location; //window.location.href
var url = new URL(url_string);
var file = url.searchParams.get("file");
var dFile = file;

function onLoad() {
    var hiddenElement = document.createElement('a');

hiddenElement.href = `${dFile}`;
hiddenElement.target = '_blank';
hiddenElement.download = `${dFile}`;
hiddenElement.click();
close()
}

Make sure to add onLoad function into the body with event listener of "onload"

<!DOCTYPE html>
<body onload="onLoad()">
</body>


问:
Using SignalR Core on .NET 4.6.1
As said in the SignalR differences documentation we can use SignalR Core on .NET 4.6.1 and latter...

So I know the code for the startup and configuration for both cases:

SignalR Core:

ConfigureServices

//Add SignalR service
services.AddSignalR();
```

<p><em>Startup</em></p>

<pre class="lang-cs prettyprint-override"><code>app.UseSignalR(routes =>
{
    routes.MapHub<NotificationsHub>("/notification");
});
</code>```

SignalR:

Startup

app.Map("/signalr", map =>
{
    map.UseCors(CorsOptions.AllowAll);
    var hubConfiguration = new HubConfiguration { };
    hubConfiguration.EnableDetailedErrors = true;
    map.RunSignalR(hubConfiguration);
});
```

And my question is, what I need to do in the .NET 4.6.1 startup to map my SignalR hub and etc...?
I can't find any documentation about this particular case.

Update1:
I tried to run the same code and obviously changed the client code to use the SignalR core approach and what I get now is (not authorized) during negotiation request.

答:
While this question was already answered by the OP I think a more complete answer is warranted for the benefit of others who may stumble across it.

ASP.NET Core versions 1 through 2.2 supported targetting .NET Framework v4.6.1+ to ease transitioning from ASP.NET v4 to ASP.NET Core. This support was dropped in ASP.NET Core v3.

While both SignalR and SignalR Core have nuget packages targetting .NET Framework v4.6.1+ they have different dependencies. This is made slightly more confusing due to one of the SignalR nuget packages being called Microsoft.AspNet.SignalR.Core.

The long and short of it is SignalR Core was built upon ASP.NET Core. You cannot use SignalR Core without it. If you want to use SignalR Core while still targetting .NET Framework v4.6.1-v4.8 you can do so only by creating a ASP.NET Core v1-v2.2 project then changing it's target framework to .v4.6.1-v4.8.

For ASP.NET v4 applications as of this writing the latest supported version of SignalR is v2.4.3.

Title: Using SignalR Core on .NET 4.6.1

Body:
As said in the SignalR differences documentation we can use SignalR Core on .NET 4.6.1 and latter...

So I know the code for the startup and configuration for both cases:

SignalR Core:

ConfigureServices

//Add SignalR service
services.AddSignalR();

Startup

app.UseSignalR(routes =>
{
    routes.MapHub<NotificationsHub>("/notification");
});

SignalR:

Startup

app.Map("/signalr", map =>
{
    map.UseCors(CorsOptions.AllowAll);
    var hubConfiguration = new HubConfiguration { };
    hubConfiguration.EnableDetailedErrors = true;
    map.RunSignalR(hubConfiguration);
});

And my question is, what I need to do in the .NET 4.6.1 startup to map my SignalR hub and etc...?
I can't find any documentation about this particular case.

Update1:
I tried to run the same code and obviously changed the client code to use the SignalR core approach and what I get now is (not authorized) during negotiation request.


问:
Why no tail() or head() method in List to get last or first element?
I recently had a discussion with a collegue why the List interface in Java doesn't have a head() and tail() method.

In order to implement such a functionality would have to write a wrapper that looked something like this:

```<code>public E head() {
 if (underlyingList == null || underlyingList.isEmpty())
  return null;

 return underlyingList.get(0);
}

public E tail() {
 if (underlyingList == null || underlyingList.isEmpty())
  return null;

 return underlyingList.get(underlyingList.size()-1);
}
</code>```

I'm not aware of all List implementations but I assume that at least in LinkedList and ArrayList it should be pretty trivial to get the last and first element (constant time).

So the question is:

Is there a specific reason why it is not a good idea to provide a tail method to any List implementation?

答:
You should use a List, to make it easier.
When you use recursion on a list you have to think like this...
The list has an head(the first element) and a tail(all the other elements except the head).
With recursion you need to do what you want on the head and then call the function on the tail, so that you always have a list with size = size - 1</p>
```<code>public static void main(String[] args) {
    ArrayList<Integer> list = new ArrayList<>();

    list.add(11);
    list.add(12);
    list.add(0);
    list.add(3);
    list.add(1);
    list.add(4);
    list.add(11);

    System.out.println(countOccurrences(list, 11));

}

public static int countOccurrences(List<Integer> list, int n) {
    if (list.size() == 0) {//if list is empty return 0
        return 0;
    }else {
        if(list.get(0) == n) {//if head of list is equal to n add 1 and call the function on the tail of the list
            return 1 + countOccurrences(list.subList(1, list.size()), n);
        }else {//else if it's not equal to n call the function on the tail of the list without adding 1
            return countOccurrences(list.subList(1, list.size()), n);
        }
    }
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I recently had a discussion with a collegue why the List interface in Java doesn't have a head() and tail() method.

In order to implement such a functionality would have to write a wrapper that looked something like this:

public E head() {
 if (underlyingList == null || underlyingList.isEmpty())
  return null;

 return underlyingList.get(0);
}

public E tail() {
 if (underlyingList == null || underlyingList.isEmpty())
  return null;

 return underlyingList.get(underlyingList.size()-1);
}

I'm not aware of all List implementations but I assume that at least in LinkedList and ArrayList it should be pretty trivial to get the last and first element (constant time).

So the question is:

Is there a specific reason why it is not a good idea to provide a tail method to any List implementation?

Body:
You should use a List, to make it easier.
When you use recursion on a list you have to think like this...
The list has an head(the first element) and a tail(all the other elements except the head).
With recursion you need to do what you want on the head and then call the function on the tail, so that you always have a list with size = size - 1

public static void main(String[] args) {
    ArrayList<Integer> list = new ArrayList<>();

    list.add(11);
    list.add(12);
    list.add(0);
    list.add(3);
    list.add(1);
    list.add(4);
    list.add(11);

    System.out.println(countOccurrences(list, 11));

}

public static int countOccurrences(List<Integer> list, int n) {
    if (list.size() == 0) {//if list is empty return 0
        return 0;
    }else {
        if(list.get(0) == n) {//if head of list is equal to n add 1 and call the function on the tail of the list
            return 1 + countOccurrences(list.subList(1, list.size()), n);
        }else {//else if it's not equal to n call the function on the tail of the list without adding 1
            return countOccurrences(list.subList(1, list.size()), n);
        }
    }
}


问:
Difference between "fill" and "expand" options for tkinter pack method
What's the difference between the "fill" and "expand" options for Tkinter's pack method?

I have actually looked up about it everywhere, and I am unable to find the satisfactory answer. I found the following:

fill option: it determines whether to use up more space or keep
"one's own" dimensions.

expand option: it deals with the expansion of parent widget.

The problem is that these two sound more or less the same. I even tried out a few examples by toggling between the 4 values of fill and 2 values of expand but received more or less the same output in 2 or 3 cases, because of which I have this query.

答:
I'm also a man who struggled to understand how those options work together.

Thankfully, finally got clear understanding with Ronald's visual explanation.

So I made some program to simulate how pack works.

https://github.com/thom-jp/tkinter_pack_simulator

Here is the image of running program:


问:
How can I get an Entity with its referenced entity ids in a ManyToMany relation?
I have an basic spring application that uses hibernate and mapstruct

There are two Entities, each are implemented to have their subchild entities as List attribute in a ManyToMany relation

So there is

```<code>EntityA.class
with List<EntityB> (fetchType Lazy)
</code>```

and vice versa

Now when my client calls, it wants to get a DTO that represents like following:

```<code>EntityADTO
with List<Long> entityBIds
</code>```

How can I get my EntityA with only the Ids of EntityB most efficient and without loading the complete EntityB and post process it after?

Thanks a lot!

答:
In addition to @Fladdimir's answer which is a great approach if you only need the list of values occasionally, JPA allows defining Entity Graphs that can specify what in an object graph you want loaded. This can allow you to define your entity and specific attributes from child/referenced entities in the graph, allowing objects to be returned but the bulk of the data unfetched. This can allow you to process Entity B instances, but without them being fully populated.
There are many tutorials but I've referenced https://www.baeldung.com/jpa-entity-graph more than once. As the tutorial referenced mentions though, Hibernate might have some issues with how it handles attributes that are normally eagerly fetched, so it might not work the way you want (but will with other JPA providers like EclipseLink, which is where I've used this).

Alternatively, if this is a collection of IDs you are going to want/need frequently, you can modify your object model to have them fetched differently.

```<code>public class EntityA {
  ..
  @ElementCollection
  @CollectionTable(name = "RELATION_TABLE_NAME", joinColumns = @JoinColumn(name = "A_ID", insertable=false, updatable=false))
  @Column(name = "B_ID", insertable=false, updatable=false)
  List<Long> bIds;
}
</code>```

This allows fetching the foriegn keys automatically in your AEntity. I've made it read-only, assuming you'd keep the existing A->B relationship and use that to set things. Doing so though means that these two relationships are entirely separate, and so might result in different queries to fetch this same set of data.

If that is a concern, you can alter things again, and remove the existing A->B relationship, and stick it in an intermediary object AB.

```<code>public class EntityA {
  ..
  @ElementCollection
  @CollectionTable(name = "RELATION_TABLE_NAME", joinColumns = @JoinColumn(name = "A_ID"))
  List<AB> listOfBs;
}

@Embeddable
public class AB {
  @Column("B_ID", insertable=false, updatable=false)
  Long bId;

  @ManyToOne(fetch=LAZY)
  @JoinColumn(name = "B_ID")
  B b;
}
</code>```

This would allow you to fetch As and use B's ID values without having to fetch from the B table. Note that I've marked the basic bId property as read-only, assuming that your existing app would be setting things by assigning a B reference to the relationship, but you could mark the relationship as read-only instead, and set the FK value using the bId. This might be more efficient long term, as you don't have to look up the B instance to set the relationship.

Alternatively again, you can make AB an entity instead of an embeddable, and allow it to exist and be queried upon outside of As and Bs. There are quite a few options though, and ways to map it, and not likely necessary for a simple model and use case.

Body:
I have an basic spring application that uses hibernate and mapstruct

There are two Entities, each are implemented to have their subchild entities as List attribute in a ManyToMany relation

So there is

EntityA.class
with List<EntityB> (fetchType Lazy)

and vice versa

Now when my client calls, it wants to get a DTO that represents like following:

EntityADTO
with List<Long> entityBIds

How can I get my EntityA with only the Ids of EntityB most efficient and without loading the complete EntityB and post process it after?

Thanks a lot!

Body:
In addition to @Fladdimir's answer which is a great approach if you only need the list of values occasionally, JPA allows defining Entity Graphs that can specify what in an object graph you want loaded. This can allow you to define your entity and specific attributes from child/referenced entities in the graph, allowing objects to be returned but the bulk of the data unfetched. This can allow you to process Entity B instances, but without them being fully populated.
There are many tutorials but I've referenced https://www.baeldung.com/jpa-entity-graph more than once. As the tutorial referenced mentions though, Hibernate might have some issues with how it handles attributes that are normally eagerly fetched, so it might not work the way you want (but will with other JPA providers like EclipseLink, which is where I've used this).

Alternatively, if this is a collection of IDs you are going to want/need frequently, you can modify your object model to have them fetched differently.

public class EntityA {
  ..
  @ElementCollection
  @CollectionTable(name = "RELATION_TABLE_NAME", joinColumns = @JoinColumn(name = "A_ID", insertable=false, updatable=false))
  @Column(name = "B_ID", insertable=false, updatable=false)
  List<Long> bIds;
}

This allows fetching the foriegn keys automatically in your AEntity. I've made it read-only, assuming you'd keep the existing A->B relationship and use that to set things. Doing so though means that these two relationships are entirely separate, and so might result in different queries to fetch this same set of data.

If that is a concern, you can alter things again, and remove the existing A->B relationship, and stick it in an intermediary object AB.

public class EntityA {
  ..
  @ElementCollection
  @CollectionTable(name = "RELATION_TABLE_NAME", joinColumns = @JoinColumn(name = "A_ID"))
  List<AB> listOfBs;
}

@Embeddable
public class AB {
  @Column("B_ID", insertable=false, updatable=false)
  Long bId;

  @ManyToOne(fetch=LAZY)
  @JoinColumn(name = "B_ID")
  B b;
}

This would allow you to fetch As and use B's ID values without having to fetch from the B table. Note that I've marked the basic bId property as read-only, assuming that your existing app would be setting things by assigning a B reference to the relationship, but you could mark the relationship as read-only instead, and set the FK value using the bId. This might be more efficient long term, as you don't have to look up the B instance to set the relationship.

Alternatively again, you can make AB an entity instead of an embeddable, and allow it to exist and be queried upon outside of As and Bs. There are quite a few options though, and ways to map it, and not likely necessary for a simple model and use case.


问:
git submodule "you need to resolve your current index first" but there are no merge conflicts
I have this weird issue that I just can't solve. Jenkins is doing the building from a repository.

It checks out the app's current commit (this is correct), and it then initialises submodules (also correct, and finds the correct commit).

But when it tries to do git submodule update --init --recursive repo, it bails with:

app/views/license/edit.html: needs merge

The problem is there are no conflicts, and that file in the current committed source is perfectly fine...

I just have no idea where to go from here.

```<code> > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url git@bitbucket.org:TEAM/api-backend.git # timeout=10
Fetching upstream changes from git@bitbucket.org:TEAM/api-backend.git
 > git --version # timeout=10
using GIT_SSH to set credentials
 > git fetch --tags --progress git@bitbucket.org:TEAM/api-backend.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse refs/remotes/origin/dev^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/refs/heads/dev^{commit} # timeout=10
Checking out Revision 99ab7742966fd82f21044e7bf5f405eaf3bd085b (refs/remotes/origin/dev)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 99ab7742966fd82f21044e7bf5f405eaf3bd085b
Commit message: "Front-end update"
 > git rev-list --no-walk 99ab7742966fd82f21044e7bf5f405eaf3bd085b # timeout=10
 > git remote # timeout=10
 > git submodule init # timeout=10
 > git submodule sync # timeout=10
 > git config --get remote.origin.url # timeout=10
 > git submodule init # timeout=10
 > git config -f .gitmodules --get-regexp ^submodule\.(.+)\.url # timeout=10
 > git config --get submodule.compose/web.url # timeout=10
 > git config -f .gitmodules --get submodule.compose/web.path # timeout=10
 > git submodule update --init --recursive compose/web
hudson.plugins.git.GitException: Command "git submodule update --init --recursive compose/web" returned status code 1:
stdout: app/views/license/edit.html: needs merge

stderr: error: you need to resolve your current index first
Unable to checkout '71e9f5f5d30ec8b2bcd7d341e4b607ab123a4ece' in submodule path 'compose/web'
</code>```

I tried a dummy commit with some changes to the file in question and merged to dev to branch, but that didn't solve it...

What confuses me, is why isn't it telling me there are conflicts when I merge?

Further tests

I did a fresh clone of the parent repository and ran git submodule --init --recursive compose/web. And it cloned and checked out the right branch successfully...

So I can't even replicate this locally.

How can I fix it?

答:
I got to this location from a completely different pathway. I tried to bail out of a bad merge and broke the local tree. I can't tell if this is due to a bug in git or some other pathway, but I ran git merge --quit followed by git switch master (the current workspace was a detached head so it doesn't need to be put back in a sane state). The tree became broken as it had a merge conflicted file but no merge in progress.

Krishnamoorthy Acharya's deleted answer contains the base form of how to salvage it, updated here:

```<code>git reset
git restore .
git switch master
</code>```

After git reset, the merge-conflicted file changed to edited, then git restore . abandoned all pending changes so git switch was happy.

Body:
I have this weird issue that I just can't solve. Jenkins is doing the building from a repository.

It checks out the app's current commit (this is correct), and it then initialises submodules (also correct, and finds the correct commit).

But when it tries to do git submodule update --init --recursive repo, it bails with:

app/views/license/edit.html: needs merge

The problem is there are no conflicts, and that file in the current committed source is perfectly fine...

I just have no idea where to go from here.

 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url git@bitbucket.org:TEAM/api-backend.git # timeout=10
Fetching upstream changes from git@bitbucket.org:TEAM/api-backend.git
 > git --version # timeout=10
using GIT_SSH to set credentials
 > git fetch --tags --progress git@bitbucket.org:TEAM/api-backend.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse refs/remotes/origin/dev^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/refs/heads/dev^{commit} # timeout=10
Checking out Revision 99ab7742966fd82f21044e7bf5f405eaf3bd085b (refs/remotes/origin/dev)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 99ab7742966fd82f21044e7bf5f405eaf3bd085b
Commit message: "Front-end update"
 > git rev-list --no-walk 99ab7742966fd82f21044e7bf5f405eaf3bd085b # timeout=10
 > git remote # timeout=10
 > git submodule init # timeout=10
 > git submodule sync # timeout=10
 > git config --get remote.origin.url # timeout=10
 > git submodule init # timeout=10
 > git config -f .gitmodules --get-regexp ^submodule\.(.+)\.url # timeout=10
 > git config --get submodule.compose/web.url # timeout=10
 > git config -f .gitmodules --get submodule.compose/web.path # timeout=10
 > git submodule update --init --recursive compose/web
hudson.plugins.git.GitException: Command "git submodule update --init --recursive compose/web" returned status code 1:
stdout: app/views/license/edit.html: needs merge

stderr: error: you need to resolve your current index first
Unable to checkout '71e9f5f5d30ec8b2bcd7d341e4b607ab123a4ece' in submodule path 'compose/web'

I tried a dummy commit with some changes to the file in question and merged to dev to branch, but that didn't solve it...

What confuses me, is why isn't it telling me there are conflicts when I merge?

Further tests

I did a fresh clone of the parent repository and ran git submodule --init --recursive compose/web. And it cloned and checked out the right branch successfully...

So I can't even replicate this locally.

How can I fix it?

Body:
I got to this location from a completely different pathway. I tried to bail out of a bad merge and broke the local tree. I can't tell if this is due to a bug in git or some other pathway, but I ran git merge --quit followed by git switch master (the current workspace was a detached head so it doesn't need to be put back in a sane state). The tree became broken as it had a merge conflicted file but no merge in progress.

Krishnamoorthy Acharya's deleted answer contains the base form of how to salvage it, updated here:

git reset
git restore .
git switch master

After git reset, the merge-conflicted file changed to edited, then git restore . abandoned all pending changes so git switch was happy.


问:
How to convert to 1-dimensional list a list of a string that is list that contains int elements
Can't figure out how to make a proper 1-dimensional list out of

```<code>a = ['[2,5911,3391,10687,9796,15870,11533]']
a[1:-1]

</code>```

i want to get
[2,5911,3391,10687,9796,15870,11533]

Slices don't seem to work there

Is there any elegant way to do it without writing 2 for loops
Appreciate all the help

答:
You can use the standard package json for that, in particular the loads method that can deserialize a string:

```<code>import json

a = ['[2,5911,3391,10687,9796,15870,11533]']

json.loads(a[0])
# [2, 5911, 3391, 10687, 9796, 15870, 11533]
</code>```

Or if you expect a to contain more than just one element:

```<code>a_converted = [json.loads(_el) for _el in a]
# [[2, 5911, 3391, 10687, 9796, 15870, 11533]]
</code>```

The advantage here is that this will work even if the string contains other data types like floats or strings.

Body:
Can't figure out how to make a proper 1-dimensional list out of

a = ['[2,5911,3391,10687,9796,15870,11533]']
a[1:-1]

i want to get
[2,5911,3391,10687,9796,15870,11533]

Slices don't seem to work there

Is there any elegant way to do it without writing 2 for loops
Appreciate all the help

Body:
You can use the standard package json for that, in particular the loads method that can deserialize a string:

import json

a = ['[2,5911,3391,10687,9796,15870,11533]']

json.loads(a[0])
# [2, 5911, 3391, 10687, 9796, 15870, 11533]

Or if you expect a to contain more than just one element:

a_converted = [json.loads(_el) for _el in a]
# [[2, 5911, 3391, 10687, 9796, 15870, 11533]]

The advantage here is that this will work even if the string contains other data types like floats or strings.


问:
How can I have an image anchor when I scroll through text?
I have a page on my site that has a lot of text on the right hand side, and I have an image on the left hand side. I want that image to stay with the user as they scroll through the text.</p>

答:
You could use position fixed I believe. I adapted this example from w3schools..

https://www.w3schools.com/howto/howto_css_sticky_element.asp

body {
display: flex;

}
div.fixed {
  position: fixed;
  top: 0;
  background-image: url("https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Image_created_with_a_mobile_phone.png/1200px-Image_created_with_a_mobile_phone.png");

  width: 100px;
  height: 100vh
}

p { margin-left: 150px}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="fixed">fixed</div>

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit.</p></code>```

Body:
You could use position fixed I believe. I adapted this example from w3schools..

https://www.w3schools.com/howto/howto_css_sticky_element.asp

body {
display: flex;

}
div.fixed {
  position: fixed;
  top: 0;
  background-image: url("https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Image_created_with_a_mobile_phone.png/1200px-Image_created_with_a_mobile_phone.png");

  width: 100px;
  height: 100vh
}

p { margin-left: 150px}

<div class="fixed">fixed</div>

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta. Cras ac leo purus. Mauris quis diam velit.</p>


问:
Validate a file name on Windows
```<code>public static boolean isValidName(String text)
{
    Pattern pattern = Pattern.compile("^[^/./\\:*?\"<>|]+$");
    Matcher matcher = pattern.matcher(text);
    boolean isMatch = matcher.matches();
    return isMatch;
}
</code>```

Does this method guarantee a valid filename on Windows?

答:
Not sure how to implement it in Java (either Regex or own method).  But, Windows OS has the following rules to create file/directory in the file system:

Name is not only be Dots

Windows device names like  AUX, CON, NUL, PRN, COM1, COM2, COM3,
COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5,
LPT6, LPT7, LPT8, LPT9, cannot be used for a file name nor for the
first segment of a file name (i.e. test1 in test1.txt).

Device names are case insensitive. (i.e. prn, PRN, Prn, etc. are
identical.)

All characters greater than ASCII 31 to be used except "*/:<>?\|

So, the program needs to stick with these rules.  Hope, it covers the validation rules for your question.

Title: Validate a file name on Windows

Body:
public static boolean isValidName(String text)
{
    Pattern pattern = Pattern.compile("^[^/./\\:*?\"<>|]+$");
    Matcher matcher = pattern.matcher(text);
    boolean isMatch = matcher.matches();
    return isMatch;
}

Does this method guarantee a valid filename on Windows?


问:
read_csv a MultiIndex DataFrame: problem when the first row is empty
After a long calculation I have finally obtained my DataFrame with MultiIndex columns:

```<code>columns = pd.MultiIndex.from_product([[0, 1], [0, 1]])
df = pd.DataFrame(np.ones((2, 4))], columns=columns)
df
Out[14]:
     0         1
     0    1    0    1
0  1.0  1.0  1.0  1.0
1  1.0  1.0  1.0  1.0
</code>```

I now save it to a csv file, and read it back later on with no problem.

```<code>df.to_csv("asd.csv")
df = pd.read_csv("asd.csv", header=[0, 1], index_col=[0])
df
Out[15]:
     0         1
     0    1    0    1
0  1.0  1.0  1.0  1.0
1  1.0  1.0  1.0  1.0
</code>```

Repeating the same process with a DataFrame whose first row is filled with NaNs...

```<code>columns= pd.MultiIndex.from_product([[0, 1], [0, 1]])
df = pd.DataFrame([np.full(4, np.nan), np.ones(4)], columns=columns)
df
Out[16]:
     0         1
     0    1    0    1
0  NaN  NaN  NaN  NaN
1  1.0  1.0  1.0  1.0
</code>```

... gives the following undesired result:

```<code>df.to_csv("asd.csv")
df = pd.read_csv("asd.csv", header=[0, 1], index_col=[0])
df
Out[17]:
     0         1
     0    1    0    1
0
1  1.0  1.0  1.0  1.0
</code>```

Inspecting the index shows that what should be the first row is actually interpreted as the row's name.

```<code>df.index
Out[18]: Int64Index([1], dtype='int64', name='0')
</code>```

Any ideas about how to solve this?

答:
The trick seems to be loading the MultiIndex columns using read_csv first, then set the first column as the index in a separate step, finally remove the index names.

Here you have the whole workflow:

```<code># Create df
columns = pd.MultiIndex.from_product([[0, 1], [0, 1]])
df = pd.DataFrame([np.full(4, np.nan), np.ones(4)], columns=columns)
# Save df
df.to_csv("asd.csv")
# Read df, don't specify index columns
df = pd.read_csv("asd.csv", header=[0, 1])
# Set first column as index, replacing the existing one
df.set_index(df.columns[0], inplace=True)
# Erase index names
df.index.names = [None] * df.index.nlevels
df
Out[101]:
     0         1
     0    1    0    1
0  NaN  NaN  NaN  NaN
1  1.0  1.0  1.0  1.0
</code>```

Body:
After a long calculation I have finally obtained my DataFrame with MultiIndex columns:

columns = pd.MultiIndex.from_product([[0, 1], [0, 1]])
df = pd.DataFrame(np.ones((2, 4))], columns=columns)
df
Out[14]:
     0         1
     0    1    0    1
0  1.0  1.0  1.0  1.0
1  1.0  1.0  1.0  1.0

I now save it to a csv file, and read it back later on with no problem.

df.to_csv("asd.csv")
df = pd.read_csv("asd.csv", header=[0, 1], index_col=[0])
df
Out[15]:
     0         1
     0    1    0    1
0  1.0  1.0  1.0  1.0
1  1.0  1.0  1.0  1.0

Repeating the same process with a DataFrame whose first row is filled with NaNs...

columns= pd.MultiIndex.from_product([[0, 1], [0, 1]])
df = pd.DataFrame([np.full(4, np.nan), np.ones(4)], columns=columns)
df
Out[16]:
     0         1
     0    1    0    1
0  NaN  NaN  NaN  NaN
1  1.0  1.0  1.0  1.0

... gives the following undesired result:

df.to_csv("asd.csv")
df = pd.read_csv("asd.csv", header=[0, 1], index_col=[0])
df
Out[17]:
     0         1
     0    1    0    1
0
1  1.0  1.0  1.0  1.0

Inspecting the index shows that what should be the first row is actually interpreted as the row's name.

df.index
Out[18]: Int64Index([1], dtype='int64', name='0')

Any ideas about how to solve this?

Body:
The trick seems to be loading the MultiIndex columns using read_csv first, then set the first column as the index in a separate step, finally remove the index names.

Here you have the whole workflow:

# Create df
columns = pd.MultiIndex.from_product([[0, 1], [0, 1]])
df = pd.DataFrame([np.full(4, np.nan), np.ones(4)], columns=columns)
# Save df
df.to_csv("asd.csv")
# Read df, don't specify index columns
df = pd.read_csv("asd.csv", header=[0, 1])
# Set first column as index, replacing the existing one
df.set_index(df.columns[0], inplace=True)
# Erase index names
df.index.names = [None] * df.index.nlevels
df
Out[101]:
     0         1
     0    1    0    1
0  NaN  NaN  NaN  NaN
1  1.0  1.0  1.0  1.0


问:
Debian: "command -v <command>" still returns path after removing the package?
I've uninstalled the stylus package on my Debian by sudo apt-get remove --purge node-stylus.

Now it says when I try to run the stylus command: stylus: command not found. So it works as it should.

But in my scripts I check whether Stylus is installed or not by:

```<code>if ! command -v sudo stylus &> /dev/null; then
    echo "ERROR: Stylus is not installed!"
    exit 1
fi
</code>```

And for some reason command -v stylus still returns /usr/bin/stylus thus the script won't fail.

I checked /usr/bin/ and there is no stylus there.

Could someone explain to me please why does this work like this?

答:
Bash maintains a cache for lookups; you want to do

```<code>hash -r stylus
</code>```

to force it to forget the old value.

Separately, of course, don't use command -v sudo when you actually want command -v stylus, as already pointed out in a comment.

Body:
I've uninstalled the stylus package on my Debian by sudo apt-get remove --purge node-stylus.

Now it says when I try to run the stylus command: stylus: command not found. So it works as it should.

But in my scripts I check whether Stylus is installed or not by:

if ! command -v sudo stylus &> /dev/null; then
    echo "ERROR: Stylus is not installed!"
    exit 1
fi

And for some reason command -v stylus still returns /usr/bin/stylus thus the script won't fail.

I checked /usr/bin/ and there is no stylus there.

Could someone explain to me please why does this work like this?

Body:
Bash maintains a cache for lookups; you want to do

hash -r stylus

to force it to forget the old value.

Separately, of course, don't use command -v sudo when you actually want command -v stylus, as already pointed out in a comment.


问:
When I union two datasets in Snowflake SQL, Should the length, Scale and precision be exactly same between two tables?
```<code>Table 1
ID value  DataType
001    A    VARCHAR(10)
002    A    VARCHAR(10)
003    B    VARCHAR(10)
004    C    VARCHAR(10)

Table 1
ID value  DataType
001    A    VARCHAR(100)
002    A    VARCHAR(100)
003    B    VARCHAR(100)
004    C    VARCHAR(100)
</code>```

Will the Union in Snowflake be safe, if the datatype is same but the length, scale and precision differs between two tables?

答: No - the scale and precision don't have to be the same - just the datatype</p>

Body:
Table 1
ID value  DataType
001    A    VARCHAR(10)
002    A    VARCHAR(10)
003    B    VARCHAR(10)
004    C    VARCHAR(10)

Table 1
ID value  DataType
001    A    VARCHAR(100)
002    A    VARCHAR(100)
003    B    VARCHAR(100)
004    C    VARCHAR(100)

Will the Union in Snowflake be safe, if the datatype is same but the length, scale and precision differs between two tables?


问:
How can I render different news components into the Navbar Component & display their data on the Navbar page, On Click of Navbar menu links
I have made landing page where onClick of button it redirects to the Menus page/component where I have declared Navbar component & here only I want to render the different news category component on click of multiple nav menus of Navbar.

By using react-router-dom V6 how can I render different categories of news component underneath of Navbar.

Below is the code which I have tried yet.

App.js

```<code>import React from 'react';
import {Routes,Route} from 'react-router-dom';
import LandingPage from './Components/LandingPage';
import Menus from './Component/Menus;

const App = () => {
  return (
    <>
      <Routes>
        <Route path='/' element={<LandingPage/>} />
        <Route path='menus'    element={<Menus/>} />
      </Routes>
    </>
  )
};
export default App;
</code>```

Menus.js

```<code>import Navbar from './Navbar';

const Menus = () => {
  return (
    <div>
      <Navbar/>
    </div>
  );
};
export default Menus;
</code>```

Navbar.js

```<code>import '../Styles/Navbar.css';
import Entertainment from './Entertainment';
import Business from './Business';
import Health from './Health';
import Science from './Science';
import Sports from './Sports';
import Technology from './Technology';
import {Link,Route,Routes} from 'react-router-dom';
import {useState} from 'react';

const Navbar = ()=>{
  const [isMobile,setIsMobile] = useState(false);
  return(
    <>
      <nav className="navbar">
        <h3 className="logo">theNews</h3>
        <ul className={isMobile?'nav-links-mobile':'nav-links'}
          onClick={()=>setIsMobile(false)}>
          <Link to='/business' className='business'><li>Business</li></Link>
          <Link to='/fun' className='fun'><li>Entertainment</li></Link>
          <Link to='/health' className='health'><li>Health</li></Link>
          <Link to='/science' className='science'><li>Science</li></Link>
          <Link to='/sports' className='sports'><li>Sports</li></Link>
          <Link to='/tech' className='tech'><li>Technology</li></Link>
        </ul>
          <button className='mobile-menu-icon' onClick={()=>setIsMobile(!isMobile)}>
           {isMobile? <i className='fas fa-times'></i>:<i className='fas fa-bars' ></i>}
          </button>
      </nav>
      <div>
      <Routes>
        <Route path='business'  element={<Business/>}/>
        <Route path='health'    element={<Health/>} />
        <Route path='science'   element={<Science/>} />
        <Route path='sports'    element={<Sports/>} />
        <Route path='tech'      element={<Technology/>} />
        <Route path='fun'       element={<Entertainment/>} />
        </Routes>
      </div>
    </>
  )
}
export default Navbar;
</code>```

答:
If I understand your question correctly you are wanting to render Menus on the "/menus" path, and then also render sub-routes in Navbar being rendered by Menus. In react-router-dom v6 route paths are now always exactly matched, and the "/menus" root path precludes matching and rendering  sub-routes.

The solution is to append a "*" wildcard matcher to the root path to allow additional route matching.

```<code><Routes>
  <Route path="/" element={<LandingPage/>} />
  <Route path="/menus/*" element={<Menus/>} />
</Routes>
</code>```

Additionally, in Navbar you are rendering relative route paths but specifying absolute route links. These should be in agreement. Remove the leading "/" character from the links so they are also relative to the "/menus" route path.

```<code>const Navbar = () => {
  const [isMobile, setIsMobile] = useState(false);
  return(
    <>
      <nav className="navbar">
        <h3 className="logo">theNews</h3>
        <ul className={isMobile?'nav-links-mobile':'nav-links'}
          onClick={()=>setIsMobile(false)}>
          <Link to='business' className='business'><li>Business</li></Link>
          <Link to='fun' className='fun'><li>Entertainment</li></Link>
          <Link to='health' className='health'><li>Health</li></Link>
          <Link to='science' className='science'><li>Science</li></Link>
          <Link to='sports' className='sports'><li>Sports</li></Link>
          <Link to='tech' className='tech'><li>Technology</li></Link>
        </ul>
          <button className='mobile-menu-icon' onClick={()=>setIsMobile(!isMobile)}>
           {isMobile? <i className='fas fa-times'></i>:<i className='fas fa-bars' ></i>}
          </button>
      </nav>
      <div>
      <Routes>
        <Route path='business'  element={<Business/>}/>
        <Route path='health'    element={<Health/>} />
        <Route path='science'   element={<Science/>} />
        <Route path='sports'    element={<Sports/>} />
        <Route path='tech'      element={<Technology/>} />
        <Route path='fun'       element={<Entertainment/>} />
        </Routes>
      </div>
    </>
  )
}
</code>```

Body:
I have made landing page where onClick of button it redirects to the Menus page/component where I have declared Navbar component & here only I want to render the different news category component on click of multiple nav menus of Navbar.

By using react-router-dom V6 how can I render different categories of news component underneath of Navbar.

Below is the code which I have tried yet.

App.js

import React from 'react';
import {Routes,Route} from 'react-router-dom';
import LandingPage from './Components/LandingPage';
import Menus from './Component/Menus;

const App = () => {
  return (
    <>
      <Routes>
        <Route path='/' element={<LandingPage/>} />
        <Route path='menus'    element={<Menus/>} />
      </Routes>
    </>
  )
};
export default App;

Menus.js

import Navbar from './Navbar';

const Menus = () => {
  return (

      <Navbar/>

  );
};
export default Menus;

Navbar.js

import '../Styles/Navbar.css';
import Entertainment from './Entertainment';
import Business from './Business';
import Health from './Health';
import Science from './Science';
import Sports from './Sports';
import Technology from './Technology';
import {Link,Route,Routes} from 'react-router-dom';
import {useState} from 'react';

const Navbar = ()=>{
  const [isMobile,setIsMobile] = useState(false);
  return(
    <>

theNews

setIsMobile(false)}>
          <Link to='/business' className='business'>
Business
</Link>
          <Link to='/fun' className='fun'>
Entertainment
</Link>
          <Link to='/health' className='health'>
Health
</Link>
          <Link to='/science' className='science'>
Science
</Link>
          <Link to='/sports' className='sports'>
Sports
</Link>
          <Link to='/tech' className='tech'>
Technology
</Link>

          <button className='mobile-menu-icon' onClick={()=>setIsMobile(!isMobile)}>
           {isMobile? :}
          </button>

      <Routes>
        <Route path='business'  element={<Business/>}/>
        <Route path='health'    element={<Health/>} />
        <Route path='science'   element={<Science/>} />
        <Route path='sports'    element={<Sports/>} />
        <Route path='tech'      element={<Technology/>} />
        <Route path='fun'       element={<Entertainment/>} />
        </Routes>

    </>
  )
}
export default Navbar;

Body:
If I understand your question correctly you are wanting to render Menus on the "/menus" path, and then also render sub-routes in Navbar being rendered by Menus. In react-router-dom v6 route paths are now always exactly matched, and the "/menus" root path precludes matching and rendering  sub-routes.

The solution is to append a "*" wildcard matcher to the root path to allow additional route matching.

<Routes>
  <Route path="/" element={<LandingPage/>} />
  <Route path="/menus/*" element={<Menus/>} />
</Routes>

Additionally, in Navbar you are rendering relative route paths but specifying absolute route links. These should be in agreement. Remove the leading "/" character from the links so they are also relative to the "/menus" route path.

const Navbar = () => {
  const [isMobile, setIsMobile] = useState(false);
  return(
    <>
      <nav className="navbar">
        <h3 className="logo">theNews</h3>
        <ul className={isMobile?'nav-links-mobile':'nav-links'}
          onClick={()=>setIsMobile(false)}>
          <Link to='business' className='business'><li>Business</li></Link>
          <Link to='fun' className='fun'><li>Entertainment</li></Link>
          <Link to='health' className='health'><li>Health</li></Link>
          <Link to='science' className='science'><li>Science</li></Link>
          <Link to='sports' className='sports'><li>Sports</li></Link>
          <Link to='tech' className='tech'><li>Technology</li></Link>
        </ul>
          <button className='mobile-menu-icon' onClick={()=>setIsMobile(!isMobile)}>
           {isMobile? <i className='fas fa-times'></i>:<i className='fas fa-bars' ></i>}
          </button>
      </nav>
      <div>
      <Routes>
        <Route path='business'  element={<Business/>}/>
        <Route path='health'    element={<Health/>} />
        <Route path='science'   element={<Science/>} />
        <Route path='sports'    element={<Sports/>} />
        <Route path='tech'      element={<Technology/>} />
        <Route path='fun'       element={<Entertainment/>} />
        </Routes>
      </div>
    </>
  )
}


问:
Vite build warns: script can't be bundled without type="module" attribute

```
```# Vite terminal after running "npm run build"
build started...

答:
I think I figured it out, but as always ymmv.

You might be able to do this in main.js or app.vue if you need it global, but I only needed the external script on one page. The old-school approach seemed to do it:

```<code>    mounted() {
      let externalScript = document.createElement('script');
      externalScript.setAttribute('src', 'https://[scripturletc].min.js')
      document.head.appendChild(externalScript)
    }
</code>```

note: if you're doing your components in the new vue3 way, I think the above lines would go in your setup block.

Body:
I think I figured it out, but as always ymmv.

You might be able to do this in main.js or app.vue if you need it global, but I only needed the external script on one page. The old-school approach seemed to do it:

    mounted() {
      let externalScript = document.createElement('script');
      externalScript.setAttribute('src', 'https://[scripturletc].min.js')
      document.head.appendChild(externalScript)
    }

note: if you're doing your components in the new vue3 way, I think the above lines would go in your setup block.


问:
flutter migration to null-safety - Bad state: Error: package has unmigrated dependencies - own screens
I try to migrate a flutter project to null-safety. I get the feedback that all packages are compatible and upgrated.
When I run  dart migrate, my own writen screens (which I want to migrate) are criticized as unmigrated dependencies.

1)

```<code> $ dart pub outdated --mode=null-safety
    Resolving...
    Showing dependencies that are currently not opted in to null-safety.
    [x] indicates versions without null safety support.
    [+] indicates versions opting in to null safety.

    Computing null safety support...
    All your dependencies declare support for null-safety.
</code>```

```<code>$ dart pub upgrade --null-safety
  ...
  dio: ^4.0.5-beta1 -> ^4.0.4
  firebase_core: ^1.11.0 -> ^1.12.0
</code>```

```<code>$ dart pub get
  ...
  Got dependencies!
</code>```

```<code>$ dart migrate
Analyzing project...
[-------------------------------------------------/]
Bad state: Error: package has unmigrated dependencies.

Before migrating your package, we recommend ensuring that every library it
imports (either directly or indirectly) has been migrated to null safety, so
that you will be able to run your unit tests in sound null checking mode.  You
are currently importing the following non-null-safe libraries:

  package:prosz/Screens/bottombar/tabbar.dart
  package:prosz/Screens/chat.dart
  package:brosz/Screens/chatPost.dart
  ...
Please upgrade the packages containing these libraries to null safe versions
before continuing.  To see what null safe package versions are available, run
the following command: `dart pub outdated --mode=null-safety`.

To skip this check and try to migrate anyway, re-run with the flag
`--skip-import-check`.
</code>```

versions

```<code>$ flutter --version
Flutter 2.8.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 77d935af4d (7 weeks ago) • 2021-12-16 08:37:33 -0800
Engine • revision 890a5fca2e
Tools • Dart 2.15.1
</code>```

pubspec

```<code>environment:
  sdk: ">=2.1.0 <3.0.0"
</code>```

changing pubspec to sdk: ">=2.12.0 <3.0.0" fixes the problem, but causes:

```<code>311 analysis issues found
.....
The migration tool didn't start, due to analysis errors.

The following steps might fix your problem:
1. Set the lower SDK constraint (in pubspec.yaml) to a version before 2.12.
2. Run `dart pub get`.
3. Try running `dart migrate` again.
</code>```

答:
here is my own answer: the number of analysis issues found are not the same when run "dart migrate" form ">=2.1.0 <3.0.0" and ">=2.12.0 <3.0.0".
There are much more when I run from ">=2.12.0 <3.0.0". (and especially wrong ones, because dart thinks the code has already been migrated)

So the right way is to start "dart migrate" from ">=2.1.0 <3.0.0" and fix the analysis issues found by hand. These analysis issues are mainly syntax changes of the upgraded packages, which can be found on pub.dev, in the respective changelogs

You get in this trouble if you start migration from flutter 2.8.1.

Body:
I try to migrate a flutter project to null-safety. I get the feedback that all packages are compatible and upgrated.
When I run  dart migrate, my own writen screens (which I want to migrate) are criticized as unmigrated dependencies.

1)

 $ dart pub outdated --mode=null-safety
    Resolving...
    Showing dependencies that are currently not opted in to null-safety.
    [x] indicates versions without null safety support.
    [+] indicates versions opting in to null safety.

    Computing null safety support...
    All your dependencies declare support for null-safety.

$ dart pub upgrade --null-safety
  ...
  dio: ^4.0.5-beta1 -> ^4.0.4
  firebase_core: ^1.11.0 -> ^1.12.0

$ dart pub get
  ...
  Got dependencies!

$ dart migrate
Analyzing project...
[-------------------------------------------------/]
Bad state: Error: package has unmigrated dependencies.

Before migrating your package, we recommend ensuring that every library it
imports (either directly or indirectly) has been migrated to null safety, so
that you will be able to run your unit tests in sound null checking mode.  You
are currently importing the following non-null-safe libraries:

  package:prosz/Screens/bottombar/tabbar.dart
  package:prosz/Screens/chat.dart
  package:brosz/Screens/chatPost.dart
  ...
Please upgrade the packages containing these libraries to null safe versions
before continuing.  To see what null safe package versions are available, run
the following command: `dart pub outdated --mode=null-safety`.

To skip this check and try to migrate anyway, re-run with the flag
`--skip-import-check`.

versions

$ flutter --version
Flutter 2.8.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 77d935af4d (7 weeks ago) • 2021-12-16 08:37:33 -0800
Engine • revision 890a5fca2e
Tools • Dart 2.15.1

pubspec

environment:
  sdk: ">=2.1.0 <3.0.0"

changing pubspec to sdk: ">=2.12.0 <3.0.0" fixes the problem, but causes:

311 analysis issues found
.....
The migration tool didn't start, due to analysis errors.

The following steps might fix your problem:
1. Set the lower SDK constraint (in pubspec.yaml) to a version before 2.12.
2. Run `dart pub get`.
3. Try running `dart migrate` again.


问:
Current file targeting function returning an expected default value
I'm trying to use location_directory= os.path.dirname(os.getcwd()) for a folder location, but this function is returning a directory above, I will explain with results and what I ask for help on how to proceed. The framework what I´m using is dash .
I´m trying to do this :

```<code>location_diretory= os.path.dirname(os.getcwd())

PATH = f"{location_diretory}/data/"
</code>```

When I try this PATH, return D:\name\data but the correct directory is D:\name\name\data.

I have 2 diretories in this project, i´m using pycharm for it. The current arquive .py, have the same name in the Diretory "name" and Diretory "name2".

答:
when you use location_directory= os.path.dirname(os.getcwd()) actually you search for not the current directory, but you search for parent directory (the directory thet containe the current directory)

use this:

```<code>location_directory= os.getcwd()
PATH = f"{location_diretory}/data/"
</code>```

Body:
I'm trying to use location_directory= os.path.dirname(os.getcwd()) for a folder location, but this function is returning a directory above, I will explain with results and what I ask for help on how to proceed. The framework what I´m using is dash .
I´m trying to do this :

location_diretory= os.path.dirname(os.getcwd())

PATH = f"{location_diretory}/data/"

When I try this PATH, return D:\name\data but the correct directory is D:\name\name\data.

I have 2 diretories in this project, i´m using pycharm for it. The current arquive .py, have the same name in the Diretory "name" and Diretory "name2".

Body:
when you use location_directory= os.path.dirname(os.getcwd()) actually you search for not the current directory, but you search for parent directory (the directory thet containe the current directory)

use this:

location_directory= os.getcwd()
PATH = f"{location_diretory}/data/"


问:
Check if a COMPLEX object exists in Core Data table?
I have the following tables in Core Data:

Cinema (movies)
Movie (title, times)
DateTime (startTime, endTime)

Basically there are several cinemas, each cinema can have several movies, also each movie can be shown in different cinemas, lastly each movie can have several show times(DateTime)

when I want to insert a movie into the database, I know its title and show time(startDate, endDate), I need to know if the movie is already in database, so what I do is:

```<code>- (BOOL)movieExistsInDB:(NSString *)title StartDate:(NSDate *)startDate EndDate:(NSDate *)endDate {
    NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
    NSEntityDescription *entity =
    [NSEntityDescription entityForName:@"Movie"
            inManagedObjectContext:self.context];
    [request setEntity:entity];

    NSPredicate *predicate = [NSPredicate predicateWithFormat:
                          @"title LIKE %@ AND timetable.startDate == %@ AND timetable.endDate == %@",
                          title,
                          startDate,
                          endDate];

    [request setPredicate:predicate];

    NSError *error = nil;
    NSUInteger count = [context countForFetchRequest:request error:&error];

    if (!error) {
        return count > 0;
    }

    return NO;
}
</code>```

it does not seem to work, so what is the problem?

Thanks!

edit:
error message:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'to-many key not allowed here'

答: If you want to know whether or not there's a Movie entity for a given title, you don't need the dates in your predicate.

Body:
I have the following tables in Core Data:

Cinema (movies)
Movie (title, times)
DateTime (startTime, endTime)

Basically there are several cinemas, each cinema can have several movies, also each movie can be shown in different cinemas, lastly each movie can have several show times(DateTime)

when I want to insert a movie into the database, I know its title and show time(startDate, endDate), I need to know if the movie is already in database, so what I do is:

- (BOOL)movieExistsInDB:(NSString *)title StartDate:(NSDate *)startDate EndDate:(NSDate *)endDate {
    NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
    NSEntityDescription *entity =
    [NSEntityDescription entityForName:@"Movie"
            inManagedObjectContext:self.context];
    [request setEntity:entity];

    NSPredicate *predicate = [NSPredicate predicateWithFormat:
                          @"title LIKE %@ AND timetable.startDate == %@ AND timetable.endDate == %@",
                          title,
                          startDate,
                          endDate];

    [request setPredicate:predicate];

    NSError *error = nil;
    NSUInteger count = [context countForFetchRequest:request error:&error];

    if (!error) {
        return count > 0;
    }

    return NO;
}

it does not seem to work, so what is the problem?

Thanks!

edit:
error message:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'to-many key not allowed here'


问:
Quasar build in history mode on apache server. But it only load index.html instead router defined component
Quasar project work in dev mode. But after build using quasar build command. It only load index.html only.</p>

答:
You need a file .htaccess (root of your index.html) with this inside :

RewriteEngine On

<IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
</IfModule>

# RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]
```

read carefully for the Access-Control-Allow-Origin
ref. https://httpd.apache.org/docs/2.4/howto/htaccess.html

Body:
You need a file .htaccess (root of your index.html) with this inside :

RewriteEngine On

<IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
</IfModule>

# RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]

read carefully for the Access-Control-Allow-Origin
ref. https://httpd.apache.org/docs/2.4/howto/htaccess.html