问:
How to display a list of children that have the tag "toVerify"?
```<code>private static JSONArray getListOfChildPagesAsJSON(Page page) {
    JSONArray pagesArray = new JSONArray();
    try {
        Iterator<Page> childPages = page.listChildren();
        while (childPages.hasNext()) {
            Page childPage = childPages.next();
            JSONObject pageObject = new JSONObject();
            pageObject.put(childPage.getTitle(), childPage.getPath());
            pagesArray.put(pageObject);
        }
    } catch (JSONException e) {
        LOG.error(e.getMessage(), e);
    }
    return pagesArray;
}
</code>```

I have a method that outputs children along the path, how can I change it to output children that has a tag toVerify

答:
You could do :</p>
```<code>if (Arrays.stream(childPage.getTags()).anyMatch("toVerify"::equals)) {
    pageObject.put(childPage.getTitle(), childPage.getPath());
    pagesArray.put(pageObject);
}
</code>```

Body:
private static JSONArray getListOfChildPagesAsJSON(Page page) {
    JSONArray pagesArray = new JSONArray();
    try {
        Iterator<Page> childPages = page.listChildren();
        while (childPages.hasNext()) {
            Page childPage = childPages.next();
            JSONObject pageObject = new JSONObject();
            pageObject.put(childPage.getTitle(), childPage.getPath());
            pagesArray.put(pageObject);
        }
    } catch (JSONException e) {
        LOG.error(e.getMessage(), e);
    }
    return pagesArray;
}

I have a method that outputs children along the path, how can I change it to output children that has a tag toVerify

Body:
You could do :

if (Arrays.stream(childPage.getTags()).anyMatch("toVerify"::equals)) {
    pageObject.put(childPage.getTitle(), childPage.getPath());
    pagesArray.put(pageObject);
}


来源: stackexchange

问:
Concatenate arrays with stack numpy
```<code>import numpy as np

t = np.arange(3)

for i in range(5):
  a = np.arange(3)
  np.stack((t, a))

print(t)
</code>```

output = [0 1 2]

Please some help to contatenate arrays in a loop for, ty!

答:
```<code>import numpy as np

t = np.arange(3)

for i in range(5):
  a = np.arange(3)
  t = np.vstack((t, a))

print(t)
</code>```

Output:

```<code>[[0 1 2]
 [0 1 2]
 [0 1 2]
 [0 1 2]
 [0 1 2]
 [0 1 2]]
</code>```

ContentLicense: CC BY-SA 4.0

Title: Concatenate arrays with stack numpy

Body:
import numpy as np

t = np.arange(3)

for i in range(5):
  a = np.arange(3)
  np.stack((t, a))

print(t)

output = [0 1 2]

Please some help to contatenate arrays in a loop for, ty!

Body:
import numpy as np

t = np.arange(3)

for i in range(5):
  a = np.arange(3)
  t = np.vstack((t, a))

print(t)

Output:

[[0 1 2]
 [0 1 2]
 [0 1 2]
 [0 1 2]
 [0 1 2]
 [0 1 2]]


问:
Shuffle string using Arrays
can someone please explain why my solution is wrong in this case?
Q : You are given a string s and an integer array indices of the same length. The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string.

Return the shuffled string.
Input: s = "codeleet", indices = [4,5,6,7,0,2,1,3]
Output: "leetcode"
Explanation: As shown, "codeleet" becomes "leetcode" after shuffling.

Sol:

```<code>class Solution:
    def restoreString(self, s, indices):
            res = [''] * len(s)
            for i in range (len(s)):
                res.insert(indices[i],s[i])
            return "".join (res)
</code>```

Title: Shuffle string using Arrays

Body:
can someone please explain why my solution is wrong in this case?
Q : You are given a string s and an integer array indices of the same length. The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string.

Return the shuffled string.
Input: s = "codeleet", indices = [4,5,6,7,0,2,1,3]
Output: "leetcode"
Explanation: As shown, "codeleet" becomes "leetcode" after shuffling.

Sol:

class Solution:
    def restoreString(self, s, indices):
            res = [''] * len(s)
            for i in range (len(s)):
                res.insert(indices[i],s[i])
            return "".join (res)

Body:
Your problem is with insert, look at what it is doing over the iteration:

class Solution:
    def restoreString(self, s, indices):
        res = [''] * len(s)
        for i in range (len(s)):
            res.insert(indices[i],s[i])
            print(res)
        return "".join (res)

out:

['', '', '', '', 'c', '', '', '', '']
['', '', '', '', 'c', 'o', '', '', '', '']
['', '', '', '', 'c', 'o', 'd', '', '', '', '']
['', '', '', '', 'c', 'o', 'd', 'e', '', '', '', '']
['l', '', '', '', '', 'c', 'o', 'd', 'e', '', '', '', '']
['l', '', 'e', '', '', '', 'c', 'o', 'd', 'e', '', '', '', '']
['l', 'e', '', 'e', '', '', '', 'c', 'o', 'd', 'e', '', '', '', '']
['l', 'e', '', 't', 'e', '', '', '', 'c', 'o', 'd', 'e', '', '', '', '']

As deceze mentioned in the comments, instead use res[indices[i]] = s[i]

class Solution:
    def restoreString(self, s, indices):
        res = [''] * len(s)
        for i in range (len(s)):
            res[indices[i]] = s[i]
        return "".join (res)

out:

leetcode


问:
HTTP Requests for Git Server
If a remote git server uses HTTP, I figure it must be possible to interact with it using only HTTP requests without using the git programme.

How can this be done?

The reason I am asking is to try and create a git client with the iPadOS Shortcuts app (a GUI-based scripting programme). I’d use git and shell script if I could, but here I am trying to make my iPad compatible with my Linux laptop. Not sure what I was hoping for really.

Anyway, this obviously this has certain issues like not tracking changes. I just wanted to know if this was, by any hack method, possible.

答: You can use HTTP to interact with git. The protocol documentation for that is available here: https://git-scm.com/docs/http-protocol</p>

Title: HTTP Requests for Git Server


问:
Can I do multiple SQL requests as a single request
here's the situation, i have 3 tables that look like this.

```<code>table foo
type number
a    1
b    2
c    3
d    4

table bar
number shape
1      square
2      circle
3      triangle
4      rectangle

table foobar
shape     colour
square    red
circle    green
triangle  blue
rectangle yellow
triangle  purple
</code>```

they all also have unique ids that I have not listed.

I have type but I want to find colour. now I could do three SQL requests to get it but as the SQL is likely to be the bottleneck so I was wondering if I could combine the three SQL requests into one request.

Is it possible to do this and would it run faster than three separate SQL requests

1 would return red and 3 would return blue and purple.

答:
Try something like this:</p>

```<code>SELECT C.colour
FROM foo AS A, bar AS B, foobar AS C
WHERE A.number = B.number
AND B.shape = C.shape
WHERE A.type = '<YOUR-TYPE>'
</code>```

ContentLicense: CC BY-SA 3.0

Body:
here's the situation, i have 3 tables that look like this.

table foo
type number
a    1
b    2
c    3
d    4

table bar
number shape
1      square
2      circle
3      triangle
4      rectangle

table foobar
shape     colour
square    red
circle    green
triangle  blue
rectangle yellow
triangle  purple

they all also have unique ids that I have not listed.

I have type but I want to find colour. now I could do three SQL requests to get it but as the SQL is likely to be the bottleneck so I was wondering if I could combine the three SQL requests into one request.

Is it possible to do this and would it run faster than three separate SQL requests

1 would return red and 3 would return blue and purple.

Body:
Try something like this:

SELECT C.colour
FROM foo AS A, bar AS B, foobar AS C
WHERE A.number = B.number
AND B.shape = C.shape
WHERE A.type = '<YOUR-TYPE>'


问:
How to stop memory leak in useEffect hook react
I am using Effect hook to fetch the datas from server and these data are passed to the react table there i have used the same api call to load the next set of datas from server.
When the application gets loaded i am getting an warning like below

```<code>Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.
</code>```

Effect Hook:

```<code>useEffect(() => {
setPageLoading(true);
props
  .dispatch(fetchCourses())
  .then(() => {
    setPageLoading(false);
  })
  .catch((error: string) => {
    toast.error(error);
    setPageLoading(false);
  });
}, []);
</code>```

React Table Page:

```<code><ReactTable
  className="-striped -highlight"
  columns={columns}
  data={coursesData}
  defaultPage={currentPage}
  defaultPageSize={courses.perPage}
  loading={isLoading}
  manual={true}
  onFetchData={setFilter}
/>
</code>```

Set Filter function:

```<code>const setFilter = (pagination: any) => {
  props.dispatch(updateCoursePageSize(pagination.pageSize));
  props.dispatch(updateCourseCurrentPage(pagination.page + 1));
  setCurrentPage(pagination.page);
  setPerPage(pagination.pageSize);
  setLoading(true);
  props.dispatch(fetchCourses()).then(() => {
    setLoading(false);
  });
};
</code>```

Does anyone know how to clean up the hook in react

答:
you can create a custom hook for that like that :

import * as React from 'react';

export default function useStateWhenMounted<T>(initialValue: T) {
  const [state, setState] = React.useState(initialValue);
  const isMounted = React.useRef(true);
  React.useEffect(() => {
    return () => {
      isMounted.current = false;
    };
  }, []);

  const setNewState = React.useCallback((value) => {
    if (isMounted.current) {
      setState(value);
    }
  }, []);

  return [state, setNewState];
}```

Body:
I am using Effect hook to fetch the datas from server and these data are passed to the react table there i have used the same api call to load the next set of datas from server.
When the application gets loaded i am getting an warning like below

Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.

Effect Hook:

useEffect(() => {
setPageLoading(true);
props
  .dispatch(fetchCourses())
  .then(() => {
    setPageLoading(false);
  })
  .catch((error: string) => {
    toast.error(error);
    setPageLoading(false);
  });
}, []);

React Table Page:

<ReactTable
  className="-striped -highlight"
  columns={columns}
  data={coursesData}
  defaultPage={currentPage}
  defaultPageSize={courses.perPage}
  loading={isLoading}
  manual={true}
  onFetchData={setFilter}
/>

Set Filter function:

const setFilter = (pagination: any) => {
  props.dispatch(updateCoursePageSize(pagination.pageSize));
  props.dispatch(updateCourseCurrentPage(pagination.page + 1));
  setCurrentPage(pagination.page);
  setPerPage(pagination.pageSize);
  setLoading(true);
  props.dispatch(fetchCourses()).then(() => {
    setLoading(false);
  });
};

Does anyone know how to clean up the hook in react


问:
How to get full screen when running Ubuntu 20.04 on Virtualbox
I know this is a fairly commonly asked question, but I've followed the other solutions and none of them seem to solve my problem.
I'm running an Ubuntu 20.04 virtual machine on Virtualbox. I've set up the virtual machine all fine, but would like to view it in full screen mode, but I can't do this. When I go to full screen mode, the "Ubuntu screen" is still windowed and very small.

I know that this way this should work is by installing guest additions, and I've done this. I think it was successful, since when I run lsmod | grep vboxguest, I get the output: vboxguest        45056   0, which I gather means that the Virtualbox kernel module is installed and that the guest additions have been installed correctly.

However, when I try to go to full screen mode, it is still windowed and not full screen

What am I missing here? How can I get full screen?

EDIT: I've looked at: https://superuser.com/questions/408101/virtual-box-not-filling-entire-screen and
https://www.tecmint.com/install-virtualbox-guest-additions-in-ubuntu/
to try to get help

答:
In virtualbox [Host Key] + F works for fullscreening.
1</p>


问:
How do I check a radio button dynamically in Angular?
I am trying to check the radio button if the type.location=='none' but this doesn't seem to work.</p>

```<code><ng-container *ngFor="let type of topping.type">
    <input
        type="radio" class="mr-1" name="{{topping.name}}"
       id="{{type.location}}" [(ngModel)]="topping.location"
        [value]="type.location"
        checked="type.location=='none'">
</ng-container>
</code>```

答:
Try

```<code>[checked]=" type.location==='none' ? true : false"
||
[checked]="type.location=='none'"
</code>```

instead of

```<code>checked="type.location=='none'"
</code>```

Body:
I am trying to check the radio button if the type.location=='none' but this doesn't seem to work.

<ng-container *ngFor="let type of topping.type">
    <input
        type="radio" class="mr-1" name="{{topping.name}}"
       id="{{type.location}}" [(ngModel)]="topping.location"
        [value]="type.location"
        checked="type.location=='none'">
</ng-container>

Body:
Try

[checked]=" type.location==='none' ? true : false"
||
[checked]="type.location=='none'"

instead of

checked="type.location=='none'"


问:
Insert spark Dataframe in partitioned hive table without overwrite the data
I have one dataframe created from a partition table.

I need to insert this data frame in an already created partitioned hive table without overwriting the previous data.

I use partitionBy("columnname"),insertInto("hivetable")
but it give me issue of partitionBy and intsertInto cant use at same time .

答: When you use insertInto there is no need to add PartitionBy or BucketBy in the code. This should be defined in the table creation request.</p>


问:
Not Showing sqlite data in iphone
I have two Tabitems, In first TabItems i have One NavigationViewController. Now When i am running this application it works great but while i am using the sqllite to fetch the data and show in to the tableview cell, it will get crash.
The Crash log is here:

```<code>    2011-08-18 14:19:08.204 iBountyHunter[201:207] Unresolved error Error Domain=NSCocoaErrorDomain Code=134100 "The operation couldn’t be completed. (Cocoa error 134100.)" UserInfo=0x4d4e1a0 {metadata=<CFBasicHash 0x4d4d590 [0x1008400]>{type = immutable dict, count = 7,
entries =>
    2 : <CFString 0x4d4dc90 [0x1008400]>{contents = "NSStoreModelVersionIdentifiers"} = <CFArray 0x4d4dd60 [0x1008400]>{type = immutable, count = 0, values = ()}
    4 : <CFString 0x4d4dce0 [0x1008400]>{contents = "NSPersistenceFrameworkVersion"} = <CFNumber 0x4d4d7e0 [0x1008400]>{value = +248, type = kCFNumberSInt64Type}
    6 : <CFString 0x4d4dd10 [0x1008400]>{contents = "NSStoreModelVersionHashes"} = <CFBasicHash 0x4d4ddf0 [0x1008400]>{type = immutable dict, count = 1,
entries =>
    1 : <CFString 0x4d4dd80 [0x1008400]>{contents = "Fugitive"} = <CFData 0x4d4dda0 [0x1008400]>{length = 32, capacity = 32, bytes = 0xe33370b6e7ca3101f91d25951e8bfe01 ... 9e50237bb313d390}
}

    7 : <CFString 0xe248b0 [0x1008400]>{contents = "NSStoreUUID"} = <CFString 0x4d4db00 [0x1008400]>{contents = "E711F65F-3C5A-4889-872B-6541E4B2863A"}
    8 : <CFString 0xe24720 [0x1008400]>{contents = "NSStoreType"} = <CFString 0xe248f0 [0x1008400]>{contents = "SQLite"}
    9 : <CFString 0x4d4d970 [0x1008400]>{contents = "NSStoreModelVersionHashesVersion"} = <CFNumber 0x4d1e420 [0x1008400]>{value = +3, type = kCFNumberSInt32Type}
    10 : <CFString 0x4d4dd40 [0x1008400]>{contents = "_NSAutoVacuumLevel"} = <CFString 0x4d4de40 [0x1008400]>{contents = "2"}
}
, reason=The model used to open the store is incompatible with the one used to create the store}, {
    metadata =     {
        NSPersistenceFrameworkVersion = 248;
        NSStoreModelVersionHashes =         {
            Fugitive = <e33370b6 e7ca3101 f91d2595 1e8bfe01 3e7fb4de 6ef2a31d 9e50237b b313d390>;
        };
        NSStoreModelVersionHashesVersion = 3;
        NSStoreModelVersionIdentifiers =         (
        );
        NSStoreType = SQLite;
        NSStoreUUID = "E711F65F-3C5A-4889-872B-6541E4B2863A";
        "_NSAutoVacuumLevel" = 2;
    };
    reason = "The model used to open the store is incompatible with the one used to create the store";
}
</code>```

Please help me regarding this.
I dont know where the problem is. . .
Thanks in advance.

答: Every time that you make any data model changes to an iPhone application in development, you need to delete the application from the iPhone simulator or physical device before trying to build the application. When you delete an application on either platform, you delete all of the data associated with it, including the database that uses a now-obsolete data model, which causes Xcode to throw an error.</p>

Title: Not Showing sqlite data in iphone

Body:
I have two Tabitems, In first TabItems i have One NavigationViewController. Now When i am running this application it works great but while i am using the sqllite to fetch the data and show in to the tableview cell, it will get crash.
The Crash log is here:

    2011-08-18 14:19:08.204 iBountyHunter[201:207] Unresolved error Error Domain=NSCocoaErrorDomain Code=134100 "The operation couldn’t be completed. (Cocoa error 134100.)" UserInfo=0x4d4e1a0 {metadata=<CFBasicHash 0x4d4d590 [0x1008400]>{type = immutable dict, count = 7,
entries =>
    2 : <CFString 0x4d4dc90 [0x1008400]>{contents = "NSStoreModelVersionIdentifiers"} = <CFArray 0x4d4dd60 [0x1008400]>{type = immutable, count = 0, values = ()}
    4 : <CFString 0x4d4dce0 [0x1008400]>{contents = "NSPersistenceFrameworkVersion"} = <CFNumber 0x4d4d7e0 [0x1008400]>{value = +248, type = kCFNumberSInt64Type}
    6 : <CFString 0x4d4dd10 [0x1008400]>{contents = "NSStoreModelVersionHashes"} = <CFBasicHash 0x4d4ddf0 [0x1008400]>{type = immutable dict, count = 1,
entries =>
    1 : <CFString 0x4d4dd80 [0x1008400]>{contents = "Fugitive"} = <CFData 0x4d4dda0 [0x1008400]>{length = 32, capacity = 32, bytes = 0xe33370b6e7ca3101f91d25951e8bfe01 ... 9e50237bb313d390}
}

    7 : <CFString 0xe248b0 [0x1008400]>{contents = "NSStoreUUID"} = <CFString 0x4d4db00 [0x1008400]>{contents = "E711F65F-3C5A-4889-872B-6541E4B2863A"}
    8 : <CFString 0xe24720 [0x1008400]>{contents = "NSStoreType"} = <CFString 0xe248f0 [0x1008400]>{contents = "SQLite"}
    9 : <CFString 0x4d4d970 [0x1008400]>{contents = "NSStoreModelVersionHashesVersion"} = <CFNumber 0x4d1e420 [0x1008400]>{value = +3, type = kCFNumberSInt32Type}
    10 : <CFString 0x4d4dd40 [0x1008400]>{contents = "_NSAutoVacuumLevel"} = <CFString 0x4d4de40 [0x1008400]>{contents = "2"}
}
, reason=The model used to open the store is incompatible with the one used to create the store}, {
    metadata =     {
        NSPersistenceFrameworkVersion = 248;
        NSStoreModelVersionHashes =         {
            Fugitive = <e33370b6 e7ca3101 f91d2595 1e8bfe01 3e7fb4de 6ef2a31d 9e50237b b313d390>;
        };
        NSStoreModelVersionHashesVersion = 3;
        NSStoreModelVersionIdentifiers =         (
        );
        NSStoreType = SQLite;
        NSStoreUUID = "E711F65F-3C5A-4889-872B-6541E4B2863A";
        "_NSAutoVacuumLevel" = 2;
    };
    reason = "The model used to open the store is incompatible with the one used to create the store";
}

Please help me regarding this.
I dont know where the problem is. . .
Thanks in advance.


问:
Angular reactive form: Displaying error text when form has error
I´m struggling with displaying error message under the textarea in my form. I have custom-textarea which is a normal texarea component with some handy attributes. One of them is helper text which is displayed below the textarea box. I find the logic of my conditional rendering okay, although it is not being displayed on the screen when the specific error occurs. Hardcoded value for my helper text works, so there is no problem with the text being displayed. Do you have any idea what could be the problem here?</p>
```<code><form [formGroup]="editForm" (ngSubmit)="editComment()">
    <custom-textarea
      formControlName="text"
      helper-text="{{!editForm.valid ? ((editForm.controls.text.errors?.['required'] ? 'Text for the comment is required!' : null) || (editForm.controls.text.errors?.['minlength'] ? 'Minimal length of text is 3 characters!' : null)) : null}}"
    ></custom-textarea>
</form>
</code>```
```<code>export class EditCommentComponent implements OnInit {
@Input() comment: Comment;
editForm: FormGroup;
ngOnInit(): void {
    this.editForm = new FormGroup({
      text: new FormControl('', [Validators.required, Validators.minLength(3)]),
    });
}

ngOnChanges(): void {
    this.editForm.controls.text.setValue(this.comment.text);
  }
</code>```

答:
In your .html file add this:

```<code><form [formGroup]="editForm" (ngSubmit)="editComment()">
    <custom-textarea
      formControlName="text"
      helper-text="{{!editForm.valid ? ((editForm.controls.text.errors?.['required'] ? 'Text for the comment is required!' : null) || (editForm.controls.text.errors?.['minlength'] ? 'Minimal length of text is 3 characters!' : null)) : null}}"
    ></custom-textarea>
<span class="error invalid-feedback"
                  *ngIf="editForm.errors? && editForm.controls.text">Error in form</span>
</form>
</code>```

I assume that you are using bootstrap and you can use this class "error invalid-feedback"

Body:
I´m struggling with displaying error message under the textarea in my form. I have custom-textarea which is a normal texarea component with some handy attributes. One of them is helper text which is displayed below the textarea box. I find the logic of my conditional rendering okay, although it is not being displayed on the screen when the specific error occurs. Hardcoded value for my helper text works, so there is no problem with the text being displayed. Do you have any idea what could be the problem here?

<form [formGroup]="editForm" (ngSubmit)="editComment()">
    <custom-textarea
      formControlName="text"
      helper-text="{{!editForm.valid ? ((editForm.controls.text.errors?.['required'] ? 'Text for the comment is required!' : null) || (editForm.controls.text.errors?.['minlength'] ? 'Minimal length of text is 3 characters!' : null)) : null}}"
    ></custom-textarea>
</form>

export class EditCommentComponent implements OnInit {
@Input() comment: Comment;
editForm: FormGroup;
ngOnInit(): void {
    this.editForm = new FormGroup({
      text: new FormControl('', [Validators.required, Validators.minLength(3)]),
    });
}

ngOnChanges(): void {
    this.editForm.controls.text.setValue(this.comment.text);
  }

Body:
In your .html file add this:

<form [formGroup]="editForm" (ngSubmit)="editComment()">
    <custom-textarea
      formControlName="text"
      helper-text="{{!editForm.valid ? ((editForm.controls.text.errors?.['required'] ? 'Text for the comment is required!' : null) || (editForm.controls.text.errors?.['minlength'] ? 'Minimal length of text is 3 characters!' : null)) : null}}"
    ></custom-textarea>
<span class="error invalid-feedback"
                  *ngIf="editForm.errors? && editForm.controls.text">Error in form</span>
</form>

I assume that you are using bootstrap and you can use this class "error invalid-feedback"


问:
IONIC 4 - Tabs icons remain selected when routed programatically
Using Ionic 4, and tabs.
Suppose that we have Tab1 / Tab2 / Tab3 with the default app generated by Ionic.
I want to use the hardware back button, to exit app if I'm in Tab1, but I need to go back on Tab1 if I am in an other tab.

Currently my code works, but :
For example if I am in Tab2 then I use the hardware back button, then the routing works, I am redirected to Tab1, but Tab2 icon remain selected. (Tab1 icon is also selected but it's normal since I have been routed to this tab)

tabs.html :

```<code><ion-tab-bar slot="bottom">
  <ion-tab-button tab="tab1">
    <ion-icon name="flash"></ion-icon>
    <ion-label>Tab One</ion-label>
  </ion-tab-button>

  <ion-tab-button tab="tab2">
    <ion-icon name="apps"></ion-icon>
    <ion-label>Tab Two</ion-label>
  </ion-tab-button>

  <ion-tab-button tab="tab3">
    <ion-icon name="send"></ion-icon>
    <ion-label>Tab Three</ion-label>
  </ion-tab-button>
</ion-tab-bar>
</code>```

Tab1.ts :

```<code>ionViewWillEnter() {
    this.subscription = this.platform.backButton.subscribe(() => {
      navigator['app'].exitApp();
    });
 }
</code>```

Tab2.ts :

```<code>  ionViewWillEnter() {
    this.subscription = this.platform.backButton.subscribe(() => {
      this.navCtrl.navigateRoot('/tabs');
  });
 }
</code>```

In Tab2.ts navcontroller route well to /tabs (which mean, in the routing rules, go to tab1.)
Of course, in both case, subscription is unsubscribe in an ionViewDidLeave lifecycle hook.

But anyway, how to make the tab2 icon unselected when hardware back button is used to navigate to tab1 ?
It's like if the tabbar was notified that tab1 has been selected (because Tab1 icon is automatically selected), but tabbar wasn't notified to unselect Tab2 icon. That mean I have two icons selected in tabbar.

Thanks

答:
In Ionic 5 the following worked for me:</p>
```<code>ion-tab-button:not(.tab-selected) {
    --color-selected: var(--color);
}
</code>```

Body:
Using Ionic 4, and tabs.
Suppose that we have Tab1 / Tab2 / Tab3 with the default app generated by Ionic.
I want to use the hardware back button, to exit app if I'm in Tab1, but I need to go back on Tab1 if I am in an other tab.

Currently my code works, but :
For example if I am in Tab2 then I use the hardware back button, then the routing works, I am redirected to Tab1, but Tab2 icon remain selected. (Tab1 icon is also selected but it's normal since I have been routed to this tab)

tabs.html :

<ion-tab-bar slot="bottom">
  <ion-tab-button tab="tab1">
    <ion-icon name="flash"></ion-icon>
    <ion-label>Tab One</ion-label>
  </ion-tab-button>

  <ion-tab-button tab="tab2">
    <ion-icon name="apps"></ion-icon>
    <ion-label>Tab Two</ion-label>
  </ion-tab-button>

  <ion-tab-button tab="tab3">
    <ion-icon name="send"></ion-icon>
    <ion-label>Tab Three</ion-label>
  </ion-tab-button>
</ion-tab-bar>

Tab1.ts :

ionViewWillEnter() {
    this.subscription = this.platform.backButton.subscribe(() => {
      navigator['app'].exitApp();
    });
 }

Tab2.ts :

  ionViewWillEnter() {
    this.subscription = this.platform.backButton.subscribe(() => {
      this.navCtrl.navigateRoot('/tabs');
  });
 }

In Tab2.ts navcontroller route well to /tabs (which mean, in the routing rules, go to tab1.)
Of course, in both case, subscription is unsubscribe in an ionViewDidLeave lifecycle hook.

But anyway, how to make the tab2 icon unselected when hardware back button is used to navigate to tab1 ?
It's like if the tabbar was notified that tab1 has been selected (because Tab1 icon is automatically selected), but tabbar wasn't notified to unselect Tab2 icon. That mean I have two icons selected in tabbar.

Thanks

Body:
In Ionic 5 the following worked for me:

ion-tab-button:not(.tab-selected) {
    --color-selected: var(--color);
}


问:
A dictionary inside of a dictionary in PowerShell
So, I'm rather new to PowerShell and just can't figure out how to use the arrays/lists/hashtables. I basically want to do the following portrayed by Python:

```<code>entries = {
    'one' : {
        'id': '1',
        'text': 'ok'
    },
    'two' : {
        'id': '2',
        'text': 'no'
    }
}

for entry in entries:
    print(entries[entry]['id'])
</code>```

Output:

1

2

But how does this work in PowerShell? I've tried the following:

```<code>$entries = @{
    one = @{
        id = "1";
        text = "ok"
    };
    two = @{
        id = "2";
        text = "no"
    }
}
</code>```

And now I can't figure out how to access the information.

```<code>foreach ($entry in $entries) {
   Write-Host $entries[$entry]['id']
}
</code>```

=> Error

答:
PowerShell prevents implicit iteration over dictionaries to avoid accidental "unrolling".

You can work around this and loop through the contained key-value pairs by calling GetEnumerator() explicitly:

```<code>foreach($kvp in $entries.GetEnumerator()){
    Write-Host $kvp.Value['id']
}
</code>```

For something closer to the python example, you can also extract the key values and iterate over those:

```<code>foreach($key in $entries.get_Keys()){
    Write-Host $entries[$key]['id']
}
</code>```

Note: You'll find that iterating over $entries.Keys works too, but I strongly recommend never using that, because PowerShell resolves dictionary keys via property access, so you'll get unexpected behavior if the dictionary contains an entry with the key "Keys":

```<code>$entries = @{
    Keys = 'a','b'
    a = 'discoverable'
    b = 'also discoverable'
    c = 'you will never find me'
}

foreach($key in $entries.Keys){ # suddenly resolves to just `'a', 'b'`
    Write-Host $entries[$key]
}
</code>```

You'll see only the output:

```<code>discoverable
also discoverable
</code>```

Not the Keys or c entries

Body:
So, I'm rather new to PowerShell and just can't figure out how to use the arrays/lists/hashtables. I basically want to do the following portrayed by Python:

entries = {
    'one' : {
        'id': '1',
        'text': 'ok'
    },
    'two' : {
        'id': '2',
        'text': 'no'
    }
}

for entry in entries:
    print(entries[entry]['id'])

Output:

1

2

But how does this work in PowerShell? I've tried the following:

$entries = @{
    one = @{
        id = "1";
        text = "ok"
    };
    two = @{
        id = "2";
        text = "no"
    }
}

And now I can't figure out how to access the information.

foreach ($entry in $entries) {
   Write-Host $entries[$entry]['id']
}

=> Error

Body:
PowerShell prevents implicit iteration over dictionaries to avoid accidental "unrolling".

You can work around this and loop through the contained key-value pairs by calling GetEnumerator() explicitly:

foreach($kvp in $entries.GetEnumerator()){
    Write-Host $kvp.Value['id']
}

For something closer to the python example, you can also extract the key values and iterate over those:

foreach($key in $entries.get_Keys()){
    Write-Host $entries[$key]['id']
}

Note: You'll find that iterating over $entries.Keys works too, but I strongly recommend never using that, because PowerShell resolves dictionary keys via property access, so you'll get unexpected behavior if the dictionary contains an entry with the key "Keys":

$entries = @{
    Keys = 'a','b'
    a = 'discoverable'
    b = 'also discoverable'
    c = 'you will never find me'
}

foreach($key in $entries.Keys){ # suddenly resolves to just `'a', 'b'`
    Write-Host $entries[$key]
}

You'll see only the output:

discoverable
also discoverable

Not the Keys or c entries


答:
If you print res before doing join, we can see that it's equal to

```<code>['l', 'e', '', 't', 'e', '', '', '', 'c', 'o', 'd', 'e', '', '', '', '']
</code>```

With insert, you are not replacing elements in your array, but you are adding new ones.

Instead you can do res[indices[i]] = s[i]

```<code>class Solution:
    def restoreString(self, s, indices):
        res = [''] * len(s)
        for i in range (len(s)):
            res[indices[i]] = s[i]
        return "".join (res)
</code>```

Title: Shuffle string using Arrays

Body:
If you print res before doing join, we can see that it's equal to

['l', 'e', '', 't', 'e', '', '', '', 'c', 'o', 'd', 'e', '', '', '', '']

With insert, you are not replacing elements in your array, but you are adding new ones.

Instead you can do res[indices[i]] = s[i]

class Solution:
    def restoreString(self, s, indices):
        res = [''] * len(s)
        for i in range (len(s)):
            res[indices[i]] = s[i]
        return "".join (res)


问:
With SSO (like for example Keycloak), how does one handle/synchronise users in own databases?
Consider the following scenario: you have a SSO service (let's say Keycloak), and X applications, that have their own databases, where somewhere in each database, you're referencing a user_id. How to handle this? How to satisfy the foreign constrain problem? Should one synchronise Keycloak, and the applications? How? What are some best practices? What are some experiences?

答:
I've been using Keycloak for several years, and in my experience there are several scenarios regarding synchronizing user data between Keycloak
and your application's database :

Your application is the owner of the user data.

Keycloak is only used for authentication/authorization purposes. In this scenario, your application  creates/updates a keycloak user using the admin rest API when needed.

Keycloak is the owner of the user data and you don't need more info than the userid in your database.

In this scenario everything regarding users could be managed by Keycloak (registration, user account parameters, even resource sharing using the authorization services).
Users would be referenced by userid in the database when needed.

NB: You can easily add custom data to the user in Keycloak using the user attributes but one interesting possibility is to extend the user model directly using this : https://www.keycloak.org/docs/latest/server_development/index.html#_extensions_jpa

Keycloak is the owner of the user data and you need more than just the user id (email, firstname, etc)

If performance is not an issue, you could retrieve user info via the Admin Rest API when needed.

If performance is an issue you'll need a copy of Keycloak's user data in your app's database, and you would want that copy to be updated on every user changes.
To do that you could implement callbacks in keycloak (using SPIs: https://www.keycloak.org/docs/latest/server_development/index.html#_events), that will notify your application when an user is created/updated.

NB : You could also use a Change Data Capture tools (like Debezium: https://debezium.io/) to synchronize Keycloak's database with yours.

There's pros and cons to each scenario, you'll have to choose the one which better suits your needs :)


问:
How do I retain function parameter types in a returned Record of functions
I have a simple function which takes an object of functions as a parameter and returns that object.

type Func = () => void
type Async = () => Promise<void>

const foo = <K extends string>(fns: Record<K, Func | Async) => fns
```
<p>Ideally each function should be able to accept parameters and retain the type signature of the parameters in the object when it is returned from the function. Something like this:</p>
<pre class="lang-js prettyprint-override"><code>const fns = foo({
  foo: (a: string, b: string) => {}
  asyncFoo: async (a: string, b: string) => {}
})

// typescript doesn't know that a, b are parameters
// will complain that I am passing these parameters
// since they don't exist in the type signature
fns.foo('a', 'b')
await fns.asyncFoo('a', 'b')
</code>```

How do I type this function so the object of functions returned from it can infer/retain the parameter types?

Side note: the actual code for this is inspired from @redux-toolkit and a great example of this kind of behavior is with createSlice() and how the actions retain the payload typings from the reducers passed to the function.

答:
I found the answer here after posting this lol.

Basically I needed to add this typing:

type Func = (...args: any[]) => void
type AsyncFunc = (...args: any[]) => Promise<void>

const foo = <K extends Record<keyof K, Func | AsyncFunc>>(fns: K) => fns
```

Body:
I have a simple function which takes an object of functions as a parameter and returns that object.

type Func = () => void
type Async = () => Promise<void>

const foo = <K extends string>(fns: Record<K, Func | Async) => fns

Ideally each function should be able to accept parameters and retain the type signature of the parameters in the object when it is returned from the function. Something like this:

const fns = foo({
  foo: (a: string, b: string) => {}
  asyncFoo: async (a: string, b: string) => {}
})

// typescript doesn't know that a, b are parameters
// will complain that I am passing these parameters
// since they don't exist in the type signature
fns.foo('a', 'b')
await fns.asyncFoo('a', 'b')

How do I type this function so the object of functions returned from it can infer/retain the parameter types?

Side note: the actual code for this is inspired from @redux-toolkit and a great example of this kind of behavior is with createSlice() and how the actions retain the payload typings from the reducers passed to the function.


问:
Excel cell Value as SQL query where statement
I am very new to SQL, I want to import data from SQL Server to Excel using this query

```<code>SELECT
    Model, Factory, TargetTime, TotalEvalMins
FROM
    AMSView
WHERE
    WeekNumber = 45 AND WeekYear = 2021
</code>```

I want to change the week number & year dynamically by taking user input from a cell.

Can anyone please suggest how to change the query?

Let's say the user values week & year in worksheet sample in A1,A2 , how can I write that query?

Since the amount of data is huge I must apply where while querying the data instead of applying filters in Excel.

Sorry for my bad English

答:
Name each of your cells that you will use as parameters. This page describes the process.

Name a cell

```<code>1. Select a cell.

2. In the Name Box, type a name.

3. Press Enter.
</code>```

For each cell containing a parameter for your query:

Select the cell

Use Data>Get & Transform Data>From Table/Range. This will open the PowerQuery Editor. You will see something like this:

Right-click the cell in row 1 in the grid in the Power Query Editor and select 'Drill Down'. This converts the query on your parameter cell to a named value which can be used in other queries. It looks like this:

Now in Excel, use Data>Get Data and create your query from the database. I created a sample table in a local SQL Server database called AMSView, then connected to it with the query text in your post. When finishing the query connection, select 'Transform' so the query opens in the PowerQuery Editor.

Now, use Home>Advanced Editor and edit as follows by replacing the fixed values in the WHERE clause with concatenated names of your parameter cells, converted to text. For brevity, I have only used one parameter. If you've used capital letters in your cell names, remember, the M language is case-sensitive, so the concatenated parameter name must have identical casing to the named value.

```<code>let
    Source = Sql.Database("localhost", "StackOverflowTest", [Query="SELECT #(lf)    Model, Factory, TargetTime, TotalEvalMins #(lf)FROM #(lf)    AMSView #(lf)WHERE #(lf)    WeekNumber = " & Number.ToText(week_number)])
in
    Source
</code>```

Once your query is finished, use Home>Close & Load to load the results to the workbook. Now, when your parameter cells change, you need only refresh the query (right-click, refresh) and the data will be filtered as required.

Body:
I am very new to SQL, I want to import data from SQL Server to Excel using this query

SELECT
    Model, Factory, TargetTime, TotalEvalMins
FROM
    AMSView
WHERE
    WeekNumber = 45 AND WeekYear = 2021

I want to change the week number & year dynamically by taking user input from a cell.

Can anyone please suggest how to change the query?

Let's say the user values week & year in worksheet sample in A1,A2 , how can I write that query?

Since the amount of data is huge I must apply where while querying the data instead of applying filters in Excel.

Sorry for my bad English

Body:
Name each of your cells that you will use as parameters. This page describes the process.

Name a cell

1. Select a cell.

2. In the Name Box, type a name.

3. Press Enter.

For each cell containing a parameter for your query:

Select the cell

Use Data>Get & Transform Data>From Table/Range. This will open the PowerQuery Editor. You will see something like this:

Right-click the cell in row 1 in the grid in the Power Query Editor and select 'Drill Down'. This converts the query on your parameter cell to a named value which can be used in other queries. It looks like this:

Now in Excel, use Data>Get Data and create your query from the database. I created a sample table in a local SQL Server database called AMSView, then connected to it with the query text in your post. When finishing the query connection, select 'Transform' so the query opens in the PowerQuery Editor.

Now, use Home>Advanced Editor and edit as follows by replacing the fixed values in the WHERE clause with concatenated names of your parameter cells, converted to text. For brevity, I have only used one parameter. If you've used capital letters in your cell names, remember, the M language is case-sensitive, so the concatenated parameter name must have identical casing to the named value.

let
    Source = Sql.Database("localhost", "StackOverflowTest", [Query="SELECT #(lf)    Model, Factory, TargetTime, TotalEvalMins #(lf)FROM #(lf)    AMSView #(lf)WHERE #(lf)    WeekNumber = " & Number.ToText(week_number)])
in
    Source

Once your query is finished, use Home>Close & Load to load the results to the workbook. Now, when your parameter cells change, you need only refresh the query (right-click, refresh) and the data will be filtered as required.


问:
Can I make dataframe that summarises/aggregates data from a much larger one?
I've got a horrendously large dataframe (covering hundreds of days worth of data) that contains data of the following pattern:

```<code>df = data.frame(date = c('2021-01-09', '2021-01-09', '2021-01-09', '2021-01-09', '2021-01-09', '2021-01-09', '2021-01-09', '2021-01-09', '2021-01-09', '2021-01-09'),
                category = c(UKS, USD, UKS, UKS, USD, USD, UKS, USD, UKZ, UKY),
                time = c(07:59:53, 08:00:03, 08:00:03, 08:00:03, 08:00:03, 08:00:04, 08:00:08, 08:00:11, 08:00:14, 08:00:15)
                quantity = c(0.001, 0.003, 0.018, 0.010, 0.043, 0.005, 0.023, 0.005, 0.001, 0.008)
                cumvol = c(0.001, 0.004, 0.022, 0.032, 0.075, 0.080, 0.103, 0.108, 0.109, 0.117)
                type = c(TSV, OSN, TSS, TSV, TSS, TSS, OSN, TSV, OSN, TSS)
</code>```

This dataframe cannot be changed, however what I would like to do is create a 'summary' dataframe from this one that sums together the total quantity for each category and type per day, as well as providing a total quantity on that day.

So using the above example:

```<code>For 2021-01-09
Total Quantity = 0.117
Total UKS = 0.052
Total USD = 0.056
Total UKZ = 0.001
Total UKY = 0.008
</code>```

Does anyone have any advice on how to achieve this for all the days I have data for?

答:
Your table requires some fixing, but once you do that, you can do this

```<code>library(data.table)
setDT(df)

df[, .(cat_total = sum(quantity)), by=.(date,category)] %>%
  .[, date_total:=sum(cat_total), by=date] %>%
  .[]

</code>```

Output:

```<code>         date category cat_total date_total
1: 2021-01-09      UKS     0.052      0.117
2: 2021-01-09      USD     0.056      0.117
3: 2021-01-09      UKZ     0.001      0.117
4: 2021-01-09      UKY     0.008      0.117
</code>```

Body:
I've got a horrendously large dataframe (covering hundreds of days worth of data) that contains data of the following pattern:

df = data.frame(date = c('2021-01-09', '2021-01-09', '2021-01-09', '2021-01-09', '2021-01-09', '2021-01-09', '2021-01-09', '2021-01-09', '2021-01-09', '2021-01-09'),
                category = c(UKS, USD, UKS, UKS, USD, USD, UKS, USD, UKZ, UKY),
                time = c(07:59:53, 08:00:03, 08:00:03, 08:00:03, 08:00:03, 08:00:04, 08:00:08, 08:00:11, 08:00:14, 08:00:15)
                quantity = c(0.001, 0.003, 0.018, 0.010, 0.043, 0.005, 0.023, 0.005, 0.001, 0.008)
                cumvol = c(0.001, 0.004, 0.022, 0.032, 0.075, 0.080, 0.103, 0.108, 0.109, 0.117)
                type = c(TSV, OSN, TSS, TSV, TSS, TSS, OSN, TSV, OSN, TSS)

This dataframe cannot be changed, however what I would like to do is create a 'summary' dataframe from this one that sums together the total quantity for each category and type per day, as well as providing a total quantity on that day.

So using the above example:

For 2021-01-09
Total Quantity = 0.117
Total UKS = 0.052
Total USD = 0.056
Total UKZ = 0.001
Total UKY = 0.008

Does anyone have any advice on how to achieve this for all the days I have data for?

Body:
Your table requires some fixing, but once you do that, you can do this

library(data.table)
setDT(df)

df[, .(cat_total = sum(quantity)), by=.(date,category)] %>%
  .[, date_total:=sum(cat_total), by=date] %>%
  .[]

Output:

         date category cat_total date_total
1: 2021-01-09      UKS     0.052      0.117
2: 2021-01-09      USD     0.056      0.117
3: 2021-01-09      UKZ     0.001      0.117
4: 2021-01-09      UKY     0.008      0.117


问:
How to know deep inside component hierarchy we have a special component, efficiently?
I'm creating a form builder using React.

The point is, everything is dynamic.

A form can have fields, or field groups. Each field group can have many fields. Each field can have it's own controls, hints, valdiations, etc.

This means that a form is a component hierarchy. A tree of components.

Now I want to know if in this tree, any Upload field exist at all.

Because if there is no Upload field, then I submit the form using application/json content type. Otherwise I would submit the form using application/form-data content type.

I know I can traverse the entire JSON of component props. But that seems very inefficient.

Is there a way to traverse React's component tree in an efficient way?

答:
Easiest way is vanilla JS.</p>
```<code>const FORM_SELECTOR = '#some-form-id';
const UPLOAD_SELECTOR = '.some-upload-class';

const form = document.querySelector(FORM_SELECTOR)
if(form.querySelectorAll(UPLOAD_SELECTOR).length) {
  // upload exists
} else {
  // upload does not exist
}
</code>```

Body:
Easiest way is vanilla JS.

const FORM_SELECTOR = '#some-form-id';
const UPLOAD_SELECTOR = '.some-upload-class';

const form = document.querySelector(FORM_SELECTOR)
if(form.querySelectorAll(UPLOAD_SELECTOR).length) {
  // upload exists
} else {
  // upload does not exist
}


问:
IOptionsMonitor not working inside docker container
Is it possible to detect appsettings changes with IOptionsMonitor when running a (C# .NET 5) web application inside docker?

I have an application that, when run locally, fires the OnChange event of my options monitor whenever I touch the appsettings.json file. However, the event is not fired when running the application in a docker container with mounted appsettings file.

答:
Docker do not send change notifications to file provider by default, but you can
use environment variable ENV DOTNET_USE_POLLING_FILE_WATCHER=true.

Some file systems, such as Docker containers and network shares, may
not reliably send change notifications. Set the
DOTNET_USE_POLLING_FILE_WATCHER environment variable to 1 or true to
poll the file system for changes every four seconds (not
configurable).

You can read more here: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/file-providers?view=aspnetcore-6.0#watch-for-changes


问:
Error: EMFILE: too many open files - React Native CLI
I try to run a react-native-cli project using react-native start, and the metro bundler fails, saying the following:  </p>

```<code>events.js 187
throw er; //Unhandled 'error' event

Error: EMFILE: too many open files, watch

Emitted 'error' event on NodeWatcher isntance at:
     at NodeWatcher: checkedEmitError (.../react-native-project/node_modules/sane/src/node_watcher.js:143:12)
     at FSWatcher.emit (events.js:210:5)
     at FSEvent.FSWatcher:_handle onchange (internal/fs/watchers.js:129:12) {
   errno: -24,
   syscall: 'watch',
   code : 'EMFILE',
   filename: null
)
Process terminated. Press <enter> to close the window
</code>```

答:
Try "brew install watchman" command,

if "brew" not install then follow below steps

Follow this steps, This is worked for me.

Body:
I try to run a react-native-cli project using react-native start, and the metro bundler fails, saying the following:

events.js 187
throw er; //Unhandled 'error' event

Error: EMFILE: too many open files, watch

Emitted 'error' event on NodeWatcher isntance at:
     at NodeWatcher: checkedEmitError (.../react-native-project/node_modules/sane/src/node_watcher.js:143:12)
     at FSWatcher.emit (events.js:210:5)
     at FSEvent.FSWatcher:_handle onchange (internal/fs/watchers.js:129:12) {
   errno: -24,
   syscall: 'watch',
   code : 'EMFILE',
   filename: null
)
Process terminated. Press <enter> to close the window


问:
How do I get background image size in jQuery?
The problem is simple. How do I get a div's background image size (width and height) in jQuery. Is it even possible? I thought this would work:

```<code>jQuery('#myDiv').css('background-image').height();
</code>```

The error message I get is that this is not a function.

答:
I made the same thing for the width :)</p>

```<code>$.fn.getBgWidth = function () {
    var width = 0;
    var path = $(this).css('background-image').replace('url', '').replace('(', '').replace(')', '').replace('"', '').replace('"', '');
    var tempImg = '<img id="tempImg" src="' + path + '"/>';
    $('body').append(tempImg); // add to DOM before </body>
    $('#tempImg').hide(); //hide image
    width = $('#tempImg').width(); //get width
    $('#tempImg').remove(); //remove from DOM
    return width;
};
</code>```

Body:
The problem is simple. How do I get a div's background image size (width and height) in jQuery. Is it even possible? I thought this would work:

jQuery('#myDiv').css('background-image').height();

The error message I get is that this is not a function.

Body:
I made the same thing for the width :)

$.fn.getBgWidth = function () {
    var width = 0;
    var path = $(this).css('background-image').replace('url', '').replace('(', '').replace(')', '').replace('"', '').replace('"', '');
    var tempImg = '<img id="tempImg" src="' + path + '"/>';
    $('body').append(tempImg); // add to DOM before </body>
    $('#tempImg').hide(); //hide image
    width = $('#tempImg').width(); //get width
    $('#tempImg').remove(); //remove from DOM
    return width;
};


问:
Python - Using same cookie with different request
I need to make three requests with same cookie. If I make first request using this command:

```<code>s = requests.Session()
r1 = s.post("https://example.com/first.php", headers=headers1)
print(r1.cookies)
r2 = s.post("https://example.com/second.php", headers=headers1)
print(r2.cookies)
</code>```

I get this output:

```<code><RequestsCookieJar[<Cookie PHPSESSID=3ht1qgfl4ot4lnrfemspkkk2ts for example.com/>]>
<RequestsCookieJar[]>
</code>```

It seems there is not used same cookie in second request. I have tried also another approach:

```<code>r1 = requests.post("https://example.com/first.php", headers=headers1)
print(r1.cookies)
r2 = requests.post("https://example.com/second.php", headers=headers1, cookies=r1.cookies)
print(r2.cookies)
</code>```

I get this output - same problem:

```<code><RequestsCookieJar[<Cookie PHPSESSID=mje0prfv97un49tkq381turq2d for example.com/>]>
<RequestsCookieJar[]>
</code>```

Could someone help me, how to use same cookie in second request?

答:
It was written in requests docs about the cookies won't be sent in the second request

https://docs.python-requests.org/en/master/user/advanced/#:~:text=This%20example%20will%20only%20send%20the%20cookies%20with%20the%20first%20request,%20but%20not%20the%20second

I think you can try to store the cookies and load it

import requests

s = requests.Session()
r1 = s.post("https://example.com/first.php", headers=headers1)
print(r1.cookies)
cookies = requests.utils.dict_from_cookiejar(r1.cookies)
s.cookies.update(cookies)
r2 = s.post("https://example.com/second.php", headers=headers1)
print(r2.cookies)
r3 = s.post("https://example.com/third.php", headers=headers1)
print(r3.cookies)
```

you can see more information here https://docs.python-requests.org/en/master/api/#api-cookies

Body:
I need to make three requests with same cookie. If I make first request using this command:

s = requests.Session()
r1 = s.post("https://example.com/first.php", headers=headers1)
print(r1.cookies)
r2 = s.post("https://example.com/second.php", headers=headers1)
print(r2.cookies)

I get this output:

<RequestsCookieJar[<Cookie PHPSESSID=3ht1qgfl4ot4lnrfemspkkk2ts for example.com/>]>
<RequestsCookieJar[]>

It seems there is not used same cookie in second request. I have tried also another approach:

r1 = requests.post("https://example.com/first.php", headers=headers1)
print(r1.cookies)
r2 = requests.post("https://example.com/second.php", headers=headers1, cookies=r1.cookies)
print(r2.cookies)

I get this output - same problem:

<RequestsCookieJar[<Cookie PHPSESSID=mje0prfv97un49tkq381turq2d for example.com/>]>
<RequestsCookieJar[]>

Could someone help me, how to use same cookie in second request?

Body:
It was written in requests docs about the cookies won't be sent in the second request

https://docs.python-requests.org/en/master/user/advanced/#:~:text=This%20example%20will%20only%20send%20the%20cookies%20with%20the%20first%20request,%20but%20not%20the%20second

I think you can try to store the cookies and load it

import requests

s = requests.Session()
r1 = s.post("https://example.com/first.php", headers=headers1)
print(r1.cookies)
cookies = requests.utils.dict_from_cookiejar(r1.cookies)
s.cookies.update(cookies)
r2 = s.post("https://example.com/second.php", headers=headers1)
print(r2.cookies)
r3 = s.post("https://example.com/third.php", headers=headers1)
print(r3.cookies)

you can see more information here https://docs.python-requests.org/en/master/api/#api-cookies


问:
how to draw a elegant vertical line between two divs placed up and down?
I have two divs placed up and down as mentioned in the image. I want to draw a vertical connecting line between these two divs. I used pipe (|) font to do this. But, it is not looking elegant. Can someone help me to draw an elegant vertical line between the divs?

答:
Use border-left:4px dashed blue; property to create a dashed line for connecting the two divs.

.box {
  width:80%;
  margin-left:10%;
  height:70px;
  background: grey;
}
.vl {
  border-left: 4px dashed blue;
  height: 40px;
  margin-left:50%
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="box"></div>
<div class="vl"></div>
<div class="box"></div></code>```

Body:
Use border-left:4px dashed blue; property to create a dashed line for connecting the two divs.

.box {
  width:80%;
  margin-left:10%;
  height:70px;
  background: grey;
}
.vl {
  border-left: 4px dashed blue;
  height: 40px;
  margin-left:50%
}

<div class="box"></div>
<div class="vl"></div>
<div class="box"></div>