问:
Splitting Contents of a File
So I have a file with a list of users in the format like this:

michael:atbWfKL4etk4U:500:500:Michael Ferris:/home/michael:/bin/bash
abigail:&i4KZ5wmac566:501:501:Abigail Smith:/home/abigail:/bin/tcsh

What I need to do is just extract the passwords from the file which in this case are:
"atbWfKL4etk4U" and "&i4KZ5wmac566" and to store them into an array.

This is what I have so far:

```<code>public static void main(String[] args) throws IOException{

    // Create a scanner for keyboard input
    Scanner scan = new Scanner(System.in);

    // Prompt user to select a file to open
    System.out.print("Enter the path of the file: ");
    String filename = scan.nextLine();

    // Open the file
    File file = new File(filename);
    Scanner inputFile = new Scanner(file);

    // Create Array to store each user password in
    String[] passwords = {};

    // Close the file
    scan.close();
    inputFile.close();

}
</code>```

答:
You could read the file line by line using a Scanner object.
Then, you use another Scanner object to read the password.  Here's an example:</p>
```<code>String input = "michael:atbWfKL4etk4U:500:500:Michael Ferris:/home/michael:/bin/bash";
Scanner s = new Scanner(input).useDelimiter(":");
s.next();  //skipping username
String password = s.next();
</code>```

Title: Splitting Contents of a File

Body:
So I have a file with a list of users in the format like this:

michael:atbWfKL4etk4U:500:500:Michael Ferris:/home/michael:/bin/bash
abigail:&i4KZ5wmac566:501:501:Abigail Smith:/home/abigail:/bin/tcsh

What I need to do is just extract the passwords from the file which in this case are:
"atbWfKL4etk4U" and "&i4KZ5wmac566" and to store them into an array.

This is what I have so far:

public static void main(String[] args) throws IOException{

    // Create a scanner for keyboard input
    Scanner scan = new Scanner(System.in);

    // Prompt user to select a file to open
    System.out.print("Enter the path of the file: ");
    String filename = scan.nextLine();

    // Open the file
    File file = new File(filename);
    Scanner inputFile = new Scanner(file);

    // Create Array to store each user password in
    String[] passwords = {};

    // Close the file
    scan.close();
    inputFile.close();

}

Body:
You could read the file line by line using a Scanner object.
Then, you use another Scanner object to read the password.  Here's an example:

String input = "michael:atbWfKL4etk4U:500:500:Michael Ferris:/home/michael:/bin/bash";
Scanner s = new Scanner(input).useDelimiter(":");
s.next();  //skipping username
String password = s.next();


来源: stackexchange

问:
How to find the frequency of characters in a string in Haskell?
How can I count the frequency of characters in a string and then output them in sort of a table?

For example, if I input the word "happy" the result would be

```<code>h 1
a 1
p 2
y 1
</code>```

If this could be ordered in ASCII order too that would be brilliant.

I know I need to use the count function, any other hints would be appreciated.

EDIT: All the answers are brilliant, only I'm such a beginner at Haskell that I don't actually understand what they are doing.

答: func xs = map (\a -> (head a, length a)) $ group $ sort xs

ContentLicense: CC BY-SA 3.0

Body:
How can I count the frequency of characters in a string and then output them in sort of a table?

For example, if I input the word "happy" the result would be

h 1
a 1
p 2
y 1

If this could be ordered in ASCII order too that would be brilliant.

I know I need to use the count function, any other hints would be appreciated.

EDIT: All the answers are brilliant, only I'm such a beginner at Haskell that I don't actually understand what they are doing.


问:
How avoid duplicate records when use annotate() in queryset
I get this queryset for some method an receive one record

```<code>candidates_qs = self.filter_job_type_language_zones(job_type_id, filter_languages, filter_zones)
</code>```

Then i need to cast a charfield to integerfield to compare against some value

```<code>candidates_qs = self.filter_job_type_language_zones(job_type_id, filter_languages, filter_zones)
        candidates_qs = candidates_qs.annotate(
            # cast answer_text as integer to compare with question value
            as_integer=Cast('candidatejobtype__questions_answers__answer_text', IntegerField()))
</code>```

After that my queryset have duplicated records. I try distinct() but didn't work. How avoid duplicate records?

答:
What about relation between models? In your annotation, there is a lookup so my assumption is that it could make duplicates.

There is only one object in queryset, but is in relation with many questions_answers and each has its own answer_text.

I think, some models definitions here would be helpful.

ContentLicense: CC BY-SA 4.0

Body:
I get this queryset for some method an receive one record

candidates_qs = self.filter_job_type_language_zones(job_type_id, filter_languages, filter_zones)

Then i need to cast a charfield to integerfield to compare against some value

candidates_qs = self.filter_job_type_language_zones(job_type_id, filter_languages, filter_zones)
        candidates_qs = candidates_qs.annotate(
            # cast answer_text as integer to compare with question value
            as_integer=Cast('candidatejobtype__questions_answers__answer_text', IntegerField()))

After that my queryset have duplicated records. I try distinct() but didn't work. How avoid duplicate records?


问:
Edit .doc in Word via custom Document Library DispForm.aspx
I have a document library with a workflow that dynamicly sets user permissions to edit these documents when certain criteria is met.
The users who need to edit these items are not the brightest users, so to make it failsafe and simple for them I am customizing the DispForm.aspx to only show 2 fields in the Document Library.

"Document" - Name of the document which is a link that opens the document in MS Word.

"Done?" - Yes/No tickbox.

The user gets an e-mail when they have a task assigned; the e-mail contains an URL to the custom DispForm.aspx, the user clicks the link and voila, they see the customized DispForm.aspx with only 2 fields, they know exactly what to do because they won't get distracted by an information-overdose and the only thing the user has to do is click on the document so it would open in Word, user makes changes to document, saves, ticks "yes" in the "Done?" tickbox and the next workflow starts.

Now I'm having this particular problem, when I customize the document library's DispForm.aspx in Sharepoint Designer and add a custom Sharepoint control (Custom Document Library listform) it does not contain the Name field (which contains the URL). I can manually add that link in Sharepoint Designer but then the document gets opened in the web version of Word and if the user wants to save it, it saves to the local harddrive, instead of the Document Library.

What am I doing wrong? How can I include the right URL to a document in a customized DispForm of a document library which opens the document in Word and saves to the Document library and creates a draft version?

Suggestions, tips or other solutions VERY welcome!

Erik

Currently using: MOSS 2007, Nintex, Sharepoint Designer

答: I wrote a blog on how to get an External Link for Editing a SharePoint Document.  Maybe that can help.</p>

ContentLicense: CC BY-SA 2.5

OwnerDisplayName: Kirk Liemohn


问:
c++, pointers, references, passing from one to another function, std::vector, std::string
i have a specific problem with pointers and references, with std::vector and std::string. Some question are in the following code snipped, some below.

I have basically this code

```<code>//first of all: is this function declaration good?
//or shoudl I already pass the std::vector in another way?
//I'm only reading from it
void func(const std::vector<std::string>& vec)
{
    //I need to call otherFunc(void*) with  a single element from vec:
    //otherFunc(void* arg);
    //with arg being a void* to vec[0]
}
</code>```

My IDE tells me that only &*vec[0] works as parameter for otherFunc, but this doesn't compile...

How is the best way to do these kind of parameter passing?

答:
Firstly, &*vec[0] is meaningless; you probably mean &vec[0] (i.e. the address of the first string in your vector).

But even this won't compile because &vec[0] is of type const std::string *.  Most importantly, it's const.  You could do this:

```<code>otherFunc(const_cast<std::string *>(&vec[0]));
</code>```

BUT!!! Trying to use a const std::string * in the context of a void * sounds like a very bad idea.  How could that possibly ever do anything useful?

Body:
i have a specific problem with pointers and references, with std::vector and std::string. Some question are in the following code snipped, some below.

I have basically this code

//first of all: is this function declaration good?
//or shoudl I already pass the std::vector in another way?
//I'm only reading from it
void func(const std::vector<std::string>& vec)
{
    //I need to call otherFunc(void*) with  a single element from vec:
    //otherFunc(void* arg);
    //with arg being a void* to vec[0]
}

My IDE tells me that only &*vec[0] works as parameter for otherFunc, but this doesn't compile...

How is the best way to do these kind of parameter passing?

Body:
Firstly, &*vec[0] is meaningless; you probably mean &vec[0] (i.e. the address of the first string in your vector).

But even this won't compile because &vec[0] is of type const std::string *.  Most importantly, it's const.  You could do this:

otherFunc(const_cast<std::string *>(&vec[0]));

BUT!!! Trying to use a const std::string * in the context of a void * sounds like a very bad idea.  How could that possibly ever do anything useful?


答:
Your regressor days_to_close is problematic. Notice that you get an error on fitted probabilites numerically 0 or 1 in this simple regression.

```<code>> mod.glm <- glm(factor(CloseWon) ~ days_to_close, data=data,
+                family = binomial('logit'))
Warning messages:
1: glm.fit: algorithm did not converge
2: glm.fit: fitted probabilities numerically 0 or 1 occurred
</code>```

To see why this happens, note

```<code>> table(data$days_to_close > 0, data$CloseWon)

          0   1
  FALSE 124   2
  TRUE    0 132
</code>```

So you see that independent of what value your other regressors get, CloseWon is always 0 whenvever days_to_close is greater than zero. Loosely speaking, this means that the the function you are trying to optimise gets the value of +oo. The optimisation algorithm trips on this and ends up pushing your other regression coefficients to huge values.

There are tons of papers on how to tackle perfect separation. You can start, e.g., here.

Title: GLM Model Summary Problems

Body:
I've run the following GLM model in R, and the summary results are not making sense. The P-values are identical and the coefficients are extremely large. Something is off, but I don't know specifically what.

mod.glm <- glm(factor(CloseWon) ~ days_to_close + factor(state) + number_of_times_contacted + number_of_sales_activities + factor(original_source) + average_pageviews + marketing_emails_delivered + sends_since_last_engagement, data = HSBI_train, family = binomial('logit'))

summary(mod)

Below is the link to the image of my output,
Thanks
[1]: https://i.stack.imgur.com/A5jsQ.jpg

dput as requested:

dput(HSBI)
structure(list(days_to_close = c(143L, 0L, 264L, 0L, 138L, 0L,
117L, 48L, 258L, 0L, 59L, 125L, 204L, 260L, 0L, 210L, 0L, 119L,
0L, 286L, 29L, 0L, 56L, 0L, 0L, 92L, 92L, 94L, 38L, 223L, 284L,
0L, 289L, 278L, 128L, 52L, 137L, 0L, 256L, 0L, 119L, 175L, 225L,
118L, 161L, 129L, 94L, 0L, 33L, 0L, 0L, 26L, 0L, 0L, 0L, 0L,
163L, 112L, 0L, 0L, 0L, 6L, 0L, 0L, 8L, 0L, 0L, 251L, 0L, 0L,
100L, 0L, 118L, 126L, 65L, 0L, 116L, 120L, 0L, 115L, 20L, 40L,
0L, 77L, 0L, 0L, 0L, 0L, 0L, 0L, 184L, 0L, 268L, 0L, 49L, 128L,
0L, 129L, 240L, 0L, 164L, 0L, 73L, 0L, 0L, 200L, 0L, 22L, 0L,
0L, 0L, 0L, 0L, 268L, 20L, 0L, 0L, 31L, 99L, 0L, 0L, 0L, 0L,
263L, 0L, 0L, 265L, 0L, 280L, 174L, 267L, 0L, 0L, 260L, 0L, 0L,
0L, 219L, 0L, 0L, 292L, 0L, 259L, 0L, 0L, 114L, 127L, 127L, 0L,
41L, 0L, 251L, 281L, 0L, 226L, 277L, 268L, 0L, 219L, 0L, 97L,
0L, 0L, 0L, 218L, 0L, 98L, 64L, 0L, 0L, 101L, 0L, 0L, 0L, 0L,
0L, 165L, 0L, 0L, 0L, 0L, 76L, 48L, 233L, 0L, 0L, 0L, 0L, 0L,
0L, 107L, 189L, 0L, 94L, 19L, 223L, 128L, 0L, 0L, 0L, 106L, 246L,
0L, 0L, 118L, 168L, 160L, 0L, 225L, 231L, 222L, 0L, 0L, 122L,
0L, 37L, 236L, 246L, 0L, 16L, 0L, 70L, 0L, 123L, 264L, 0L, 0L,
0L, 0L, 264L, 0L, 41L, 296L, 124L, 198L, 0L, 0L, 0L, 58L, 156L,
166L, 274L, 0L, 88L, 2L, 0L, 124L, 0L, 80L, 41L, 278L, 0L, 0L,
252L, 0L, 80L, 0L, 0L), state = c("", "fl", "fl", "sj", "ga",
"nc", "ga", "in", "ga", "ca", "va", "ca", "va", "tn", "co", "tx",
"fl", "tn", "ca", "tn", "in", "ga", "il", "nj", "ca", "ga", "ga",
"", "", "ga", "ga", "fl", "ga", "nc", "ga", "tx", "", "ga", "ga",
"dc", "ny", "tn", "fl", "va", "ga", "al", "ca", "nv", "ca", "ga",
"sc", "va", "ga", "oh", "ga", "fl", "la", "tn", "ny", "fl", "ca",
"ca", "wa", "ny", "il", "ga", "ca", "fl", "fl", "al", "al", "fl",
"al", "tn", "sc", "", "fl", "ga", "az", "fl", "ga", "", "ca",
"ga", "ga", "oh", "ga", "al", "ga", "", "tx", "sc", "ga", "ny",
"nc", "tn", "co", "oh", "al", "tx", "", "co", "ne", "ny", "fl",
"oh", "ga", "ia", "va", "fl", "sc", "ca", "tn", "ga", "co", "ok",
"ga", "al", "tx", "", "fl", "md", "ga", "al", "tn", "wa", "al",
"oh", "ga", "ga", "", "pa", "oh", "al", "ny", "az", "tn", "oh",
"ga", "tx", "ga", "tx", "tn", "va", "fl", "ga", "ga", "fl", "ny",
"fl", "az", "ga", "ga", "tn", "ga", "", "ga", "pa", "fl", "tn",
"al", "ga", "al", "ga", "ms", "vt", "ca", "fl", "fl", "ky", "oh",
"wa", "fl", "wa", "ga", "az", "il", "al", "nc", "al", "nj", "tx",
"tx", "fl", "la", "ga", "nc", "", "ga", "al", "tx", "oh", "fl",
"tn", "tn", "fl", "ga", "ca", "", "ca", "fl", "ga", "fl", "dc",
"md", "fl", "tx", "oh", "tx", "", "al", "tx", "fl", "tn", "tx",
"ny", "ny", "tn", "az", "ga", "al", "tx", "sc", "tn", "tn", "ca",
"al", "tn", "fl", "al", "tn", "ga", "ga", "ga", "fl", "pa", "tx",
"co", "sc", "tx", "tx", "ga", "ny", "ma", "ny", "fl", "fl", "ca",
"tn", "nv", "ga", "ga", "tx", "", "or", "", "fl", "il"), number_of_times_contacted = c(7L,
5L, 7L, 2L, 40L, 4L, 6L, 6L, 5L, 1L, 3L, 5L, 8L, 8L, 1L, 10L,
4L, 9L, 3L, 10L, 6L, 4L, 7L, 7L, 2L, 9L, 1L, 5L, 3L, 9L, 11L,
4L, 8L, 10L, 10L, 6L, 10L, 3L, 10L, 12L, 5L, 7L, 8L, 5L, 31L,
10L, 6L, 1L, 5L, 20L, 15L, 7L, 3L, 3L, 6L, 6L, 6L, 7L, 2L, 3L,
1L, 2L, 1L, 19L, 2L, 3L, 1L, 10L, 5L, 3L, 7L, 2L, 8L, 9L, 3L,
3L, 8L, 12L, 1L, 7L, 2L, 2L, 4L, 50L, 6L, 4L, 2L, 3L, 1L, 9L,
7L, 3L, 14L, 1L, 3L, 5L, 7L, 4L, 8L, 4L, 6L, 2L, 4L, 7L, 5L,
7L, 7L, 6L, 5L, 6L, 4L, 1L, 5L, 8L, 2L, 1L, 6L, 3L, 4L, 4L, 4L,
1L, 6L, 8L, 4L, 3L, 8L, 11L, 10L, 6L, 8L, 5L, 8L, 6L, 4L, 2L,
10L, 8L, 6L, 8L, 8L, 8L, 8L, 5L, 6L, 4L, 5L, 9L, 12L, 4L, 1L,
11L, 12L, 7L, 9L, 14L, 8L, 3L, 7L, 17L, 8L, 4L, 2L, 33L, 9L,
1L, 4L, 8L, 6L, NA, 7L, 3L, 9L, 2L, 5L, 8L, 6L, 6L, 4L, 10L,
3L, 4L, 3L, 12L, 24L, 9L, 3L, 11L, 3L, 19L, 3L, 7L, 4L, 9L, 6L,
7L, 10L, 1L, 1L, 1L, 4L, 10L, 1L, 3L, 5L, 7L, 6L, 2L, 7L, 9L,
8L, 10L, 6L, 8L, 2L, 3L, 8L, 9L, 1L, 3L, 13L, 10L, 5L, 9L, 8L,
1L, 6L, 12L, 4L, 11L, 10L, 4L, 10L, 10L, 7L, 6L, 3L, 4L, 3L,
6L, 6L, 10L, 4L, 9L, 2L, 21L, 9L, 1L, 4L, 3L, 21L, 8L, 5L, 10L,
3L, 8L, 8L, 7L), number_of_sales_activities = c(8L, 5L, 7L, 2L,
61L, 4L, 7L, 6L, 5L, 1L, 3L, 5L, 8L, 8L, 1L, 10L, 4L, 9L, 3L,
10L, 6L, 4L, 7L, 9L, 2L, 9L, 2L, 5L, 3L, 9L, 11L, 4L, 8L, 10L,
10L, 6L, 14L, 3L, 10L, 14L, 5L, 8L, 8L, 5L, 43L, 10L, 7L, 1L,
5L, 22L, 21L, 7L, 3L, 3L, 7L, 6L, 6L, 7L, 2L, 3L, 1L, 2L, 1L,
28L, 2L, 3L, 1L, 10L, 5L, 4L, 7L, 2L, 8L, 9L, 3L, 3L, 8L, 12L,
1L, 7L, 2L, 2L, 4L, 98L, 6L, 6L, 2L, 3L, 1L, 9L, 7L, 4L, 17L,
2L, 3L, 5L, 7L, 4L, 8L, 4L, 7L, 2L, 5L, 8L, 5L, 7L, 8L, 6L, 5L,
6L, 4L, 1L, 5L, 8L, 2L, 1L, 6L, 3L, 4L, 4L, 4L, 1L, 6L, 9L, 4L,
3L, 8L, 16L, 10L, 6L, 8L, 5L, 9L, 6L, 4L, 2L, 10L, 8L, 7L, 8L,
8L, 8L, 8L, 5L, 6L, 4L, 5L, 9L, 15L, 4L, 1L, 11L, 12L, 9L, 10L,
21L, 8L, 4L, 7L, 21L, 8L, 4L, 2L, 61L, 9L, 1L, 4L, 8L, 7L, NA,
7L, 3L, 9L, 2L, 5L, 9L, 6L, 6L, 4L, 12L, 3L, 5L, 3L, 12L, 35L,
17L, 3L, 12L, 3L, 28L, 3L, 8L, 4L, 9L, 6L, 7L, 10L, 1L, 1L, 1L,
4L, 10L, 1L, 3L, 5L, 7L, 6L, 2L, 7L, 10L, 8L, 10L, 6L, 8L, 3L,
3L, 8L, 9L, 1L, 3L, 20L, 10L, 7L, 9L, 8L, 1L, 6L, 12L, 4L, 12L,
10L, 5L, 10L, 11L, 7L, 7L, 3L, 4L, 3L, 6L, 6L, 11L, 4L, 9L, 2L,
26L, 9L, 1L, 4L, 3L, 39L, 8L, 6L, 10L, 3L, 8L, 8L, 7L), original_source = c("Direct Traffic",
"Paid Social", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Organic Search",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Paid Social", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Paid Social", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Paid Social", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Paid Social",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Paid Social", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Paid Social",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Paid Social",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Paid Social",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Paid Social", "Paid Social",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Paid Social", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Paid Social", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Paid Social",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Organic Search",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Organic Social", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Paid Social", "Paid Social",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Paid Social", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Paid Social", "Direct Traffic",
"Paid Social", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Paid Social",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Paid Social", "Paid Social", "Direct Traffic", "Direct Traffic",
"Paid Social", "Paid Social", "Direct Traffic", "Direct Traffic",
"Organic Search", "Direct Traffic", "Direct Traffic", "Direct Traffic",
"Direct Traffic"), average_pageviews = c(1L, 1L, 2L, 2L, 1L,
2L, 1L, 2L, 7L, 2L, 2L, 1L, 2L, 2L, 2L, 4L, 2L, 2L, 2L, 2L, 2L,
4L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 5L, 1L, 1L, 2L, 2L, 2L, 2L,
2L, 3L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 3L, 2L,
3L, 3L, 2L, 1L, 1L, 4L, 3L, 2L, 2L, 4L, 1L, 2L, 3L, 2L, 1L, 2L,
5L, 2L, 2L, 2L, 3L, 2L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 5L, 6L, 1L, 1L, 4L,
2L, 2L, 2L, 3L, 2L, 1L, 2L, 2L, 2L, 2L, 3L, 1L, 2L, 2L, 2L, 1L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 5L, 2L, 2L, 2L, 6L,
3L, 2L, 2L, 2L, 2L, 1L, 2L, 5L, 1L, 2L, 3L, 2L, 2L, 3L, 1L, 3L,
2L, 2L, 3L, 3L, 2L, 1L, 1L, 2L, 1L, 2L, 3L, 1L, 1L, 3L, 2L, 1L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 4L, 2L, 3L, 1L, 1L,
1L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, 3L, 1L, 1L, 2L, 2L, 1L, 2L,
3L, 2L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 3L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, 4L,
4L, 1L, 2L, 2L, 0L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 3L, 2L, 2L, 2L,
4L, 1L, 3L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 2L), marketing_emails_delivered = c(15L,
6L, 13L, 7L, 65L, 10L, 11L, 11L, 22L, 3L, 8L, 12L, 17L, 15L,
2L, 18L, 9L, 11L, 9L, 20L, 10L, 12L, 11L, 14L, 8L, 11L, 11L,
6L, 8L, 19L, 21L, 3L, 20L, 22L, 15L, 11L, 14L, 8L, 21L, 21L,
11L, 14L, 15L, 11L, 47L, 16L, 10L, 9L, 8L, 22L, 14L, 10L, 8L,
2L, 13L, 15L, 16L, 16L, 2L, 7L, 2L, 9L, 9L, 21L, 9L, 8L, 3L,
21L, 15L, 2L, 11L, 2L, 11L, 16L, 8L, 3L, 16L, 17L, 2L, 16L, 8L,
8L, 9L, 44L, 19L, 9L, 9L, 9L, 3L, 12L, 7L, 9L, 22L, 7L, 8L, 12L,
12L, 12L, 21L, 5L, 16L, 2L, 3L, 18L, 15L, 15L, 21L, 10L, 9L,
10L, 12L, 3L, 13L, 22L, 9L, 6L, 17L, 7L, 10L, 3L, 3L, 9L, 13L,
22L, 14L, 9L, 22L, 8L, 23L, 13L, 20L, 9L, 10L, 22L, 9L, 9L, 18L,
19L, 13L, 19L, 20L, 18L, 13L, 7L, 10L, 11L, 12L, 16L, 19L, 8L,
3L, 13L, 24L, 15L, 28L, 24L, 22L, 4L, 19L, 31L, 15L, 9L, 2L,
44L, 11L, 2L, 10L, 13L, 18L, 3L, 15L, 9L, 19L, 8L, 6L, 9L, 16L,
10L, 5L, 19L, 2L, 9L, 8L, 20L, 14L, 8L, 9L, 21L, 7L, 21L, 11L,
14L, 19L, 15L, 10L, 19L, 16L, 1L, 9L, 3L, 10L, 21L, 3L, 3L, 11L,
15L, 16L, 2L, 11L, 21L, 11L, 22L, 16L, 16L, 9L, 8L, 21L, 21L,
3L, 1L, 20L, 13L, 9L, 16L, 13L, 6L, 10L, 15L, 3L, 20L, 11L, 8L,
21L, 16L, 14L, 8L, 9L, 15L, 8L, 16L, 9L, 23L, 9L, 15L, 2L, 22L,
16L, 3L, 9L, 8L, 31L, 19L, 18L, 21L, 9L, 14L, 19L, 10L), CloseWon = c(1,
0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0,
1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1,
1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0,
1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0,
0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1,
0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1,
0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1,
0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0,
0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0,
1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1,
0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1,
1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0,
1, 0, 1, 0, 0)), class = "data.frame", row.names = c(NA, -258L
))

Body:
Your regressor days_to_close is problematic. Notice that you get an error on fitted probabilites numerically 0 or 1 in this simple regression.

> mod.glm <- glm(factor(CloseWon) ~ days_to_close, data=data,
+                family = binomial('logit'))
Warning messages:
1: glm.fit: algorithm did not converge
2: glm.fit: fitted probabilities numerically 0 or 1 occurred

To see why this happens, note

> table(data$days_to_close > 0, data$CloseWon)

          0   1
  FALSE 124   2
  TRUE    0 132

So you see that independent of what value your other regressors get, CloseWon is always 0 whenvever days_to_close is greater than zero. Loosely speaking, this means that the the function you are trying to optimise gets the value of +oo. The optimisation algorithm trips on this and ends up pushing your other regression coefficients to huge values.

There are tons of papers on how to tackle perfect separation. You can start, e.g., here.


问:
Screenshotting the windows desktop when working through WSL
I'm primarily using Windows, where I run WSL2. So from a python script running in the subsystem, I would like to screenshot whatever is on windows monitor, as simple as such:

v1

```<code>import mss
import os

os.environ['DISPLAY'] = ':0'

with mss.mss() as sct:
    sct.shot()

</code>```

This gives only gives "Segmentation fault" error and no image. So I tried to setup vcxsrv in Windows and I'm able to open stuff from my subsystem in Windows through the server, however I cant get it the other way around..

I just want access to the windows screen so I can screenshot it. Any help about how to access the monitor through wsl would be greatly appreciated, I can't find much on google..

答: if you are on a laptop you could hit the windows button and prtsc to take a screenshot and if you are on PC you could use OBS its recording software that can do pretty much anything.</p>

Body:
I'm primarily using Windows, where I run WSL2. So from a python script running in the subsystem, I would like to screenshot whatever is on windows monitor, as simple as such:

v1

import mss
import os

os.environ['DISPLAY'] = ':0'

with mss.mss() as sct:
    sct.shot()

This gives only gives "Segmentation fault" error and no image. So I tried to setup vcxsrv in Windows and I'm able to open stuff from my subsystem in Windows through the server, however I cant get it the other way around..

I just want access to the windows screen so I can screenshot it. Any help about how to access the monitor through wsl would be greatly appreciated, I can't find much on google..


问:
Attachment in Laravel many-to-many relation
I'm trying to do my first attachment/ detachment. I'm using two tables, user, event, and its pivot, event_user. For this one, I needed to do a button to subscribe the user to an event, so my teacher told me to use an  and route it to the method subscribe. At this moment, the error that comes up is.

Route [subscribe] not defined.

Blade

```<code><a href="{{ route('subscribe', $event->event_id) }}"
    class="btn btn-primary btn-lg">Subscribe</a>
</code>```

Route

```<code>Route::get('/subscribe', [SubscribeController::class, 'index']);
</code>```

SubscribeController

```<code>public function index($id)
{
    $user = Auth::user();
    $user->events->attach($id);

    return view('index');
}
</code>```

I tried putting URL instead of the route in the , and it goes to /subscribe, but comes to an error that says -> Too few arguments to function 0 passed and exactly 1 expected.

I did a dd() in the component to see if the event id was the correct one, and it was. Also, apart from these errors, how can I route a method without changing the route? Can I do it using the indexController (because it's in the index where these events are located)?

答:
First, in order to reference the route by name, you need to give it the name subscribe.
Docs: https://laravel.com/docs/master/routing#named-routes

Second, you want to add that id route parameter that you are trying to use in your controller.
Docs: https://laravel.com/docs/master/routing#required-parameters

So your route should end up looking like this:

```<code>Route::get('/subscribe/{id}', [SubscribeController::class, 'index'])
    ->name('subscribe');
</code>```

And then you'll want to call it like this:

```<code><a href="{{ route('subscribe', ['id' => $event->event_id]) }}"
</code>```

Body:
I'm trying to do my first attachment/ detachment. I'm using two tables, user, event, and its pivot, event_user. For this one, I needed to do a button to subscribe the user to an event, so my teacher told me to use an  and route it to the method subscribe. At this moment, the error that comes up is.

Route [subscribe] not defined.

Blade

event_id) }}"
    class="btn btn-primary btn-lg">Subscribe

Route

Route::get('/subscribe', [SubscribeController::class, 'index']);

SubscribeController

public function index($id)
{
    $user = Auth::user();
    $user->events->attach($id);

    return view('index');
}

I tried putting URL instead of the route in the , and it goes to /subscribe, but comes to an error that says -> Too few arguments to function 0 passed and exactly 1 expected.

I did a dd() in the component to see if the event id was the correct one, and it was. Also, apart from these errors, how can I route a method without changing the route? Can I do it using the indexController (because it's in the index where these events are located)?

Body:
First, in order to reference the route by name, you need to give it the name subscribe.
Docs: https://laravel.com/docs/master/routing#named-routes

Second, you want to add that id route parameter that you are trying to use in your controller.
Docs: https://laravel.com/docs/master/routing#required-parameters

So your route should end up looking like this:

Route::get('/subscribe/{id}', [SubscribeController::class, 'index'])
    ->name('subscribe');

And then you'll want to call it like this:

<a href="{{ route('subscribe', ['id' => $event->event_id]) }}"


问:
How to test a service subcription to a subject from another service
I have the following services:

```<code>@Injectable({
  providedIn: 'root'
})
export class Service1 {
  dataHasChanged = new Subject();
  private data1;
  private data2;

  constructor() {}

  getData() {
    return {
      data1: this.data1,
      data2: this.data2
    }
  }

  setData(data1, data2) {
    this.data1 = data1;
    this.data2 = data2;
    this.dataHasChanged.next({
      data1: this.data1,
      data2: this.data2;
    })
  }
}
</code>```
```<code>@Injectable({
  providedIn: 'root'
})
export class Service2 {
  constructor(private service1: Service1) {}

  fetchClient(): Observable<ITest> {
    const data = service1.getData();
    return this.http.post(
      '/api-endpoint/123',
       {
         data: data
        }
     );
  }

  reload(): Observable<ITest> {
    return this.service1.dataHasChanged.pipe(
      mergeMap(() => this.fetchClient()),
    );
  }
}

</code>```

I want to test that every time dataHasChanged is triggered, a component which has service2.reload(), receives data from its subscription.

I've create the following test for it:

```<code>describe('Service2', () => {
  let service2: Service2;
  let httpMock: HttpTestingController;
  let service1: Service1;
  let service1Stub: Partial<Service1>;

  beforeEach(() => {
    service1Stub = {
      dataHasChanged: new Subject(),
      getData: function () {
        return {
          data1: 123,
          data2: 12345
        }
      }
    };

    TestBed.configureTestingModule({
      imports: [HttpClientTestingModule],
      providers: [
        Service2,
        {
          provide: Service1,
          useValue: Service1Stub
        }
      ]
    });

    service2 = TestBed.inject(service2);
    httpMock = TestBed.inject(HttpTestingController);
    service1 = TestBed.inject(service1);
  });

it('test', (done: DoneFn) => {
    service2.reload().subscribe((data) => {
      console.log('here')
      expect(data).toBeDefined();
      done();
    });

    service1.dataHasChanged.next()
  })
});
</code>```

The problem is that the test which is in subscribe's callback never executes... What's the proper way to write that test?

答:
I found out that I was forgetting to mock fetchClient method which has http methods.

This worked:

```<code>it('test', (done: DoneFn) => {
    spyOn(service2, 'fetchData').and.returnValue(of{
        data1: 123,
        data2: 123
    })

    service2.reload().subscribe((data) => {
      console.log('here')
      expect(data).toBeDefined();
      done();
    });

    service1.dataHasChanged.next()
  })
</code>```

Body:
I have the following services:

@Injectable({
  providedIn: 'root'
})
export class Service1 {
  dataHasChanged = new Subject();
  private data1;
  private data2;

  constructor() {}

  getData() {
    return {
      data1: this.data1,
      data2: this.data2
    }
  }

  setData(data1, data2) {
    this.data1 = data1;
    this.data2 = data2;
    this.dataHasChanged.next({
      data1: this.data1,
      data2: this.data2;
    })
  }
}

@Injectable({
  providedIn: 'root'
})
export class Service2 {
  constructor(private service1: Service1) {}

  fetchClient(): Observable<ITest> {
    const data = service1.getData();
    return this.http.post(
      '/api-endpoint/123',
       {
         data: data
        }
     );
  }

  reload(): Observable<ITest> {
    return this.service1.dataHasChanged.pipe(
      mergeMap(() => this.fetchClient()),
    );
  }
}

I want to test that every time dataHasChanged is triggered, a component which has service2.reload(), receives data from its subscription.

I've create the following test for it:

describe('Service2', () => {
  let service2: Service2;
  let httpMock: HttpTestingController;
  let service1: Service1;
  let service1Stub: Partial<Service1>;

  beforeEach(() => {
    service1Stub = {
      dataHasChanged: new Subject(),
      getData: function () {
        return {
          data1: 123,
          data2: 12345
        }
      }
    };

    TestBed.configureTestingModule({
      imports: [HttpClientTestingModule],
      providers: [
        Service2,
        {
          provide: Service1,
          useValue: Service1Stub
        }
      ]
    });

    service2 = TestBed.inject(service2);
    httpMock = TestBed.inject(HttpTestingController);
    service1 = TestBed.inject(service1);
  });

it('test', (done: DoneFn) => {
    service2.reload().subscribe((data) => {
      console.log('here')
      expect(data).toBeDefined();
      done();
    });

    service1.dataHasChanged.next()
  })
});

The problem is that the test which is in subscribe's callback never executes... What's the proper way to write that test?

Body:
I found out that I was forgetting to mock fetchClient method which has http methods.

This worked:

it('test', (done: DoneFn) => {
    spyOn(service2, 'fetchData').and.returnValue(of{
        data1: 123,
        data2: 123
    })

    service2.reload().subscribe((data) => {
      console.log('here')
      expect(data).toBeDefined();
      done();
    });

    service1.dataHasChanged.next()
  })


问:
jQuery stopPropagation not stopping click through
I have a panzoom plugin that is working well. When I click on var elem it adds a small div cp_select in the correct location. Then, when I click on that newly created cp_select div, it removes that div. So you can add and remove it accordingly. However, when I click on the cp_select div, it removes it then immediately adds it back in because the click is propagating through. I have tried event.stopPropagation() and event.stopImmediatePropagation() with no luck. Any ideas how to prevent the cp_select firing the map_click(e)?

```<code>window.panzoom = panzoom(elem, {
        onClick(e)     {
            map_click(e);
        }
})

function map_click(e) {

    $(".map_cont").prepend('<div class="cp_select" style="left:'+calc_x+'px ;top:'+calc_y+'px"></div>');

}

 $('body').on('click', '.cp_select', function(event) {

    event.stopImmediatePropagation()
    $(this).remove()
    return false;

});
</code>```

答:
The problem must be specifically with however panzoom is dealing with its onClick, or otherwise in code not shown in the question; if I substitute a plain click event handler on the window in place of your panzoom call, event.stopPropagation() works as expected.

// nonessential code removed and simplified for demo

function map_click() {
  $(".map_cont").prepend('

');
}

$('body').on('click', '.cp_select', function(event) {
  $(this).remove();
  event.stopPropagation();
});

window.onclick = map_click // stand-in for your panzoom function```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.cp_select {
  border: 3px solid;
  height: 20px; width: 20px;
}</code>```

(click anywhere)

```

Body:
I have a panzoom plugin that is working well. When I click on var elem it adds a small div cp_select in the correct location. Then, when I click on that newly created cp_select div, it removes that div. So you can add and remove it accordingly. However, when I click on the cp_select div, it removes it then immediately adds it back in because the click is propagating through. I have tried event.stopPropagation() and event.stopImmediatePropagation() with no luck. Any ideas how to prevent the cp_select firing the map_click(e)?

window.panzoom = panzoom(elem, {
        onClick(e)     {
            map_click(e);
        }
})

function map_click(e) {

    $(".map_cont").prepend('

');

}

 $('body').on('click', '.cp_select', function(event) {

    event.stopImmediatePropagation()
    $(this).remove()
    return false;

});

Body:
The problem must be specifically with however panzoom is dealing with its onClick, or otherwise in code not shown in the question; if I substitute a plain click event handler on the window in place of your panzoom call, event.stopPropagation() works as expected.

// nonessential code removed and simplified for demo

function map_click() {
  $(".map_cont").prepend('<div class="cp_select"></div>');
}

$('body').on('click', '.cp_select', function(event) {
  $(this).remove();
  event.stopPropagation();
});

window.onclick = map_click // stand-in for your panzoom function

.cp_select {
  border: 3px solid;
  height: 20px; width: 20px;
}

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
(click anywhere)
<div class="map_cont"></div>


问:
SQL Server stored procedure
I want it to count then if @intcount > 0 it should show data or else no data found, but when I execute it gives me 'no data found' regardless, what am I doing wrong?

```<code>@FiscalYear int,
@SchoolID int,
@Status int

AS
BEGIN

SET NOCOUNT ON;

declare @sqlstr varchar(2000)
declare @intCount int
set @intCount = 0

set @sqlstr = 'Select @intCount = Count(*)
              From PrivateSchool left outer join Attachment on  Attachment.PrivateSchoolID = PrivateSchool.PrivateSchoolID
              inner join FiscalYearPrivateSchool fp ON  fp.PrivateSchoolID = PrivateSchool.PrivateSchoolID
              Where (FiscalYear = '+convert(varchar, @FiscalYear)+') AND (PrivateSchool.IsActive = 1)'

 IF (@SchoolID != -1)
    SET @sqlstr = @sqlstr + ' AND SchoolID ='+ convert(varchar, @SchoolID)

 IF (@Status = -1)
    SET @sqlstr = @sqlstr + ' AND PrivateSchool.PrivateSchoolID = PrivateSchool.PrivateSchoolID'

 Else IF (@Status = 1)
    SET @sqlstr = @sqlstr + ' AND Attachment.PrivateSchoolID = PrivateSchool.PrivateSchoolID'
 Else
    SET @sqlstr = @sqlstr + ' AND Attachment.PrivateSchoolID is Null'

 If (@intCount > 0)
 BEGIN
 set @sqlstr=   'Select SchoolName as School,
 (Case when Attachment.PrivateSchoolID = PrivateSchool.PrivateSchoolID THEN ''Uploaded''
  ELSE ''Not Uploaded'' END) AS Status,
  COUNT(Attachment.PrivateSchoolID) AS [Count]
              From PrivateSchool left outer join Attachment on  Attachment.PrivateSchoolID = PrivateSchool.PrivateSchoolID
              inner join FiscalYearPrivateSchool fp ON  fp.PrivateSchoolID = PrivateSchool.PrivateSchoolID
              Where (FiscalYear = '+convert(varchar, @FiscalYear)+') AND (PrivateSchool.IsActive = 1)'

 IF (@SchoolID != -1)
    SET @sqlstr = @sqlstr + ' AND SchoolID ='+ convert(varchar, @SchoolID)

 IF (@Status = -1)
    SET @sqlstr = @sqlstr + ' AND PrivateSchool.PrivateSchoolID = PrivateSchool.PrivateSchoolID'

 Else IF (@Status = 1)
    SET @sqlstr = @sqlstr + ' AND Attachment.PrivateSchoolID = PrivateSchool.PrivateSchoolID'
 Else
    SET @sqlstr = @sqlstr + ' AND Attachment.PrivateSchoolID is Null'

    SET @sqlstr = @sqlstr + ' Group by SchoolName, Attachment.PrivateSchoolID, PrivateSchool.PrivateSchoolID'
    SET @sqlstr = @sqlstr + ' Order By SchoolName'
EXEC(@sqlstr)
 END
 ELSE
 Select 'No Data Found' as 'FileUpload'
 END
</code>```

答:
The problem is:

```<code>declare @intCount int
set @intCount = 0
...
<a bunch of code where @intcount doesn't change>
If (@intCount > 0)
</code>```

It's always going to be 0.

Title: SQL Server stored procedure

Body:
I want it to count then if @intcount > 0 it should show data or else no data found, but when I execute it gives me 'no data found' regardless, what am I doing wrong?

@FiscalYear int,
@SchoolID int,
@Status int

AS
BEGIN

SET NOCOUNT ON;

declare @sqlstr varchar(2000)
declare @intCount int
set @intCount = 0

set @sqlstr = 'Select @intCount = Count(*)
              From PrivateSchool left outer join Attachment on  Attachment.PrivateSchoolID = PrivateSchool.PrivateSchoolID
              inner join FiscalYearPrivateSchool fp ON  fp.PrivateSchoolID = PrivateSchool.PrivateSchoolID
              Where (FiscalYear = '+convert(varchar, @FiscalYear)+') AND (PrivateSchool.IsActive = 1)'

 IF (@SchoolID != -1)
    SET @sqlstr = @sqlstr + ' AND SchoolID ='+ convert(varchar, @SchoolID)

 IF (@Status = -1)
    SET @sqlstr = @sqlstr + ' AND PrivateSchool.PrivateSchoolID = PrivateSchool.PrivateSchoolID'

 Else IF (@Status = 1)
    SET @sqlstr = @sqlstr + ' AND Attachment.PrivateSchoolID = PrivateSchool.PrivateSchoolID'
 Else
    SET @sqlstr = @sqlstr + ' AND Attachment.PrivateSchoolID is Null'

 If (@intCount > 0)
 BEGIN
 set @sqlstr=   'Select SchoolName as School,
 (Case when Attachment.PrivateSchoolID = PrivateSchool.PrivateSchoolID THEN ''Uploaded''
  ELSE ''Not Uploaded'' END) AS Status,
  COUNT(Attachment.PrivateSchoolID) AS [Count]
              From PrivateSchool left outer join Attachment on  Attachment.PrivateSchoolID = PrivateSchool.PrivateSchoolID
              inner join FiscalYearPrivateSchool fp ON  fp.PrivateSchoolID = PrivateSchool.PrivateSchoolID
              Where (FiscalYear = '+convert(varchar, @FiscalYear)+') AND (PrivateSchool.IsActive = 1)'

 IF (@SchoolID != -1)
    SET @sqlstr = @sqlstr + ' AND SchoolID ='+ convert(varchar, @SchoolID)

 IF (@Status = -1)
    SET @sqlstr = @sqlstr + ' AND PrivateSchool.PrivateSchoolID = PrivateSchool.PrivateSchoolID'

 Else IF (@Status = 1)
    SET @sqlstr = @sqlstr + ' AND Attachment.PrivateSchoolID = PrivateSchool.PrivateSchoolID'
 Else
    SET @sqlstr = @sqlstr + ' AND Attachment.PrivateSchoolID is Null'

    SET @sqlstr = @sqlstr + ' Group by SchoolName, Attachment.PrivateSchoolID, PrivateSchool.PrivateSchoolID'
    SET @sqlstr = @sqlstr + ' Order By SchoolName'
EXEC(@sqlstr)
 END
 ELSE
 Select 'No Data Found' as 'FileUpload'
 END

Body:
The problem is:

declare @intCount int
set @intCount = 0
...
<a bunch of code where @intcount doesn't change>
If (@intCount > 0)

It's always going to be 0.


问:
Django How to use Postgresql's INSERT INTO ... WHERE conditional insert functionality?
Postgresql has a nice syntax for conditionally inserting:

```<code>INSERT INTO child (name, parent_id)
SELECT :name, :parent_id
WHERE EXISTS (
    SELECT 1
    FROM parent
    WHERE id = :parent_id
        AND parent.user_id = :user_id
)
</code>```

In the above example, nothing would be inserted into the child unless the given :user_id was the owner of the parent row.

Is it possible to simulate this kind of insert in Django?

答:
You can used a clean method in model class:</p>
```<code>from django.utils.translation import gettext as _
from django.core.exceptions import  ValidationError

def clean(self):
    if  self.parent_id and self.parent.user_id  != self.user_id:
        raise ValidationError({'user': _('an user must be same as user of  parent.')})
</code>```

Body:
Postgresql has a nice syntax for conditionally inserting:

INSERT INTO child (name, parent_id)
SELECT :name, :parent_id
WHERE EXISTS (
    SELECT 1
    FROM parent
    WHERE id = :parent_id
        AND parent.user_id = :user_id
)

In the above example, nothing would be inserted into the child unless the given :user_id was the owner of the parent row.

Is it possible to simulate this kind of insert in Django?

Body:
You can used a clean method in model class:

from django.utils.translation import gettext as _
from django.core.exceptions import  ValidationError

def clean(self):
    if  self.parent_id and self.parent.user_id  != self.user_id:
        raise ValidationError({'user': _('an user must be same as user of  parent.')})


问:
jQuery keep checkbox checked while any others are checked
I have more than fifteen checkbox inputs all with the same class, looking something like below:

I want to have only the first input be checked and stay checked when any other input with the same class is checked. If only the first input is checked you should be able to check and uncheck it freely. Only the first one has the ID, #SR01201. The rest only have the class check-12.

Right now, I can freely uncheck and check the first input, and it will get checked if any other inputs with the class check-12 are checked. But once any other input (besides the first one) is checked, it can't be unchecked.

$('.check-12:not(#SR01201)').on('change', function() {
  var $this = $(this);
  var SRTwelveOne = $("#SR01201");
  if ($this.prop('checked', true)) {
    SRTwelveOne.prop('checked', true)
  } else if ($this.prop('checked', false) && $this.siblings().prop('checked', false)) {
    SRTwelveOne.prop('checked', false);
  }
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="checkbox" name="SR-012-01" value="SR-12-01" class="check-12" id="SR01201">
<input type="checkbox" name="SR-012-02" value="SR-12-02" class="check-12">
<input type="checkbox" name="SR-012-03" value="SR-12-03" class="check-12"></code>```

答: The problem is that you're not checking if a checkbox is checked with $this.prop('checked', true) in your if statement. You're actually checking the box. To see if it's a box is checked, use is(":checked")

Body:
I have more than fifteen checkbox inputs all with the same class, looking something like below:

I want to have only the first input be checked and stay checked when any other input with the same class is checked. If only the first input is checked you should be able to check and uncheck it freely. Only the first one has the ID, #SR01201. The rest only have the class check-12.

Right now, I can freely uncheck and check the first input, and it will get checked if any other inputs with the class check-12 are checked. But once any other input (besides the first one) is checked, it can't be unchecked.

$('.check-12:not(#SR01201)').on('change', function() {
  var $this = $(this);
  var SRTwelveOne = $("#SR01201");
  if ($this.prop('checked', true)) {
    SRTwelveOne.prop('checked', true)
  } else if ($this.prop('checked', false) && $this.siblings().prop('checked', false)) {
    SRTwelveOne.prop('checked', false);
  }
});

<input type="checkbox" name="SR-012-01" value="SR-12-01" class="check-12" id="SR01201">
<input type="checkbox" name="SR-012-02" value="SR-12-02" class="check-12">
<input type="checkbox" name="SR-012-03" value="SR-12-03" class="check-12">


问:
node.js: resolve path relative from a test file
I working on a function implementation that is going to be distributed as a npm package.

Once this package has been installed by a consumer as a devDependency, they should be able to load a configuration file by calling a function (let's call it setConfig) from their test files.

I am trying to understand how to resolve a relative path (relative to the test file) when the consumer invokes my function (setConfig('./../some/relative/path/to/config')).

For instance, in the following project structure:

```<code>|- node_modules
   |- my-published-package
      |- dist/file.js (<- this hold setConfig)
|- src
   |- configToLoad.json
   |- __tests__
      |- someTest.spec.js
</code>```

The config could be specified as ../configToLoad.json and the setConfig should be able to resolve the path relatively to the test file path. In other words, the test author would write `importedClassFromPackage.setConfig('../configToLoad.json').

The setConfig function has the following signature:

```<code>setConfig(configPath: string): void {}
</code>```

Where configPath can either be:

a relative path (from the test file that invokes that function)

an absolute path (absolute path of the configuration file)

a module specifier (i.e my-module/path/to/config.json)

答:
First off, when your setConfig() function runs, you have no idea at all where it was called from.  You do not and cannot know the directory of the file that you were called from.

As such, it is the responsibility of the caller to give you a path that you you can just use directly.  It needs to either be a fully qualified path or be a relative path that is relative to the current working directory.  It cannot be a path that is relative to the directory that the caller's module was in (unless that happens to be the same as the current working directory) because you will have no idea what the caller's module directory is.

So, in your desired spec where you want configPath to be any of these:

a relative path (from the test file that invokes that function)

an absolute path (absolute path of the configuration file)

a module specifier (i.e my-module/path/to/config.json)

Only the absolute path option will work or can be made to work.

The relative path won't work because your function does not know the directory of the test file you were called from.

The module specifier won't work because you don't know how to get the directory of that module name and it's ambiguous because it is possible to have the same named module loaded from more than one place (this happens in the real world when dependencies use a common module, but are using different versions of it).

Note, the caller can use path.join() to join their own module directory with the name of the file and pass you that fully qualified path.  In a CommonJS module, the caller gets their own directory from __dirname.  In an ESM module, the caller has to extract the directory from import.meta.url.

Body:
I working on a function implementation that is going to be distributed as a npm package.

Once this package has been installed by a consumer as a devDependency, they should be able to load a configuration file by calling a function (let's call it setConfig) from their test files.

I am trying to understand how to resolve a relative path (relative to the test file) when the consumer invokes my function (setConfig('./../some/relative/path/to/config')).

For instance, in the following project structure:

|- node_modules
   |- my-published-package
      |- dist/file.js (<- this hold setConfig)
|- src
   |- configToLoad.json
   |- __tests__
      |- someTest.spec.js

The config could be specified as ../configToLoad.json and the setConfig should be able to resolve the path relatively to the test file path. In other words, the test author would write `importedClassFromPackage.setConfig('../configToLoad.json').

The setConfig function has the following signature:

setConfig(configPath: string): void {}

Where configPath can either be:

a relative path (from the test file that invokes that function)

an absolute path (absolute path of the configuration file)

a module specifier (i.e my-module/path/to/config.json)


问:
Why a PHP warning appearing in Chrome but not in any other browser?
I'm writing a web application in PHP, and I'm getting the following warning in Google Chrome only:

Warning: Cannot use a scalar value as an array in
  M:\xampp\htdocs\MyProjectTitle\php\classes.php on line 18

Background: Please note that the web app works just fine in all browsers I tested (Firefox, Chrome, IE), but the warning appearing in Chrome is bugging the hell outta me.

Notes: I have tried restarting Chrome and clearing the Chrome cache. I have tried restarting the computer. I have tried searching the source code in FF and IE to see if the warning was just hidden, but to no avail. The warning is only popping up in Google Chrome, and I have no idea why.

UPDATE: Even though Safari also uses WebKit, it does not show the PHP warning. For some reason, Chrome is the only one that has the PHP warning. Weird stuff!

UPDATE: Here's the first 21 lines of code:

```<code>class Presenter {
    public function includeFile($filePath) {
        if (is_readable($filePath)) {
            include $filePath;
        } else {
            echo '<p><strong>ERROR 404</strong></p>';
            echo '<p>The resource you requested could not be located.</p>';
        }
    }

    public function sanitize($string) {
        return preg_replace("/\s/","_",$string);
    }

    public function set($varname,$value) {
        $this->$varname = $value;
        $_SESSION[$this->name][$varname] = $value;

        return $this;   // enables chaining!
    }

    // And there's more code after this, but I have cut it out here.
}
</code>```

Note: The above code is inside a PHP class.

UPDATE: I know exactly what lines of code are causing the warning in Chrome (although I still have no clue why Chrome is the only browser that shows the warning). Since my webapp works perfectly despite the warning in Chrome, I have used @ to suppress the warnings in Chrome (I'll fix the warning later).

答: Probably because you need to do ctr+f5 or restart in your other browser. It probably has a previous version of your page cached, happened to me a lot with Internet Explorer 8. </p>

Body:
I'm writing a web application in PHP, and I'm getting the following warning in Google Chrome only:

Warning: Cannot use a scalar value as an array in
  M:\xampp\htdocs\MyProjectTitle\php\classes.php on line 18

Background: Please note that the web app works just fine in all browsers I tested (Firefox, Chrome, IE), but the warning appearing in Chrome is bugging the hell outta me.

Notes: I have tried restarting Chrome and clearing the Chrome cache. I have tried restarting the computer. I have tried searching the source code in FF and IE to see if the warning was just hidden, but to no avail. The warning is only popping up in Google Chrome, and I have no idea why.

UPDATE: Even though Safari also uses WebKit, it does not show the PHP warning. For some reason, Chrome is the only one that has the PHP warning. Weird stuff!

UPDATE: Here's the first 21 lines of code:

class Presenter {
    public function includeFile($filePath) {
        if (is_readable($filePath)) {
            include $filePath;
        } else {
            echo '
ERROR 404
';
            echo '
The resource you requested could not be located.
';
        }
    }

    public function sanitize($string) {
        return preg_replace("/\s/","_",$string);
    }

    public function set($varname,$value) {
        $this->$varname = $value;
        $_SESSION[$this->name][$varname] = $value;

        return $this;   // enables chaining!
    }

    // And there's more code after this, but I have cut it out here.
}

Note: The above code is inside a PHP class.

UPDATE: I know exactly what lines of code are causing the warning in Chrome (although I still have no clue why Chrome is the only browser that shows the warning). Since my webapp works perfectly despite the warning in Chrome, I have used @ to suppress the warnings in Chrome (I'll fix the warning later).


问:
Running a SolidWorks macro from Python
I write a txt file on Python which contains the coordinates of the control points, which is then read by SolidWorks.

I have written a macro on SolidWorks to save the new modified STL file.

```<code>import numpy as np
import os
def GenerateCoordinates(low,high,size):
    X=np.random.randint(low,high,size)
    Y=np.random.randint(low,high,size)
    #Z=np.random.randint(low,high,size)
    return X,Y
X=GenerateCoordinates(0,6,7)[0]
Y=GenerateCoordinates(0,4,7)[1]
k=0
sketch_number=1 #Generate coordinates
g=open('Cdd.txt','w')
for i in range(1,len(X)):
    g.write('CoordinatesX'+str(i)+'='+str(X[i])+'\n')
    g.write('"D'+str(k)+'@Sketch'+str(sketch_number)+'"'+'=CoordinatesX'+str(i)+'\n')
    k+=1
    g.write('CoordinatesY'+str(i)+'='+str(Y[i])+'\n')
    g.write('"D'+str(k)+'@Sketch'+str(sketch_number)+'"'+'=CoordinatesY'+str(i)+'\n')
    k+=1
    #g.write('CoordinatesZ'+str(k)+'='+str(Z[i])+'\n')
    #g.write('D'+str(k)+'@Sketch'+str(sketch_number)+'=CoordinatesZ'+str(k)+'\n')
g.close() #writes coordinates in a txt file then saves the txt file

os.popen('"C:/Users/Public/Desktop/Program Files/SOLIDWORKS Corp/SOLIDWORKS/.exe"') #I want to call the macro that rebuilds the solidworks part with the modified coordinates.
</code>```

How do I run the macro from Python, to import the new file into Python?

答:
Update in case someone bumps into the same problem: the \m should not be included in the brackets. So for my example, it would be:
os.popen('"C:/Users/Public/Desktop/Program Files/SOLIDWORKS Corp/SOLIDWORKS/.exe" \m "Path to the macro"'). However, this just opens the macro without unfortunately running it.</p>

Title: Running a SolidWorks macro from Python

Body:
I write a txt file on Python which contains the coordinates of the control points, which is then read by SolidWorks.

I have written a macro on SolidWorks to save the new modified STL file.

import numpy as np
import os
def GenerateCoordinates(low,high,size):
    X=np.random.randint(low,high,size)
    Y=np.random.randint(low,high,size)
    #Z=np.random.randint(low,high,size)
    return X,Y
X=GenerateCoordinates(0,6,7)[0]
Y=GenerateCoordinates(0,4,7)[1]
k=0
sketch_number=1 #Generate coordinates
g=open('Cdd.txt','w')
for i in range(1,len(X)):
    g.write('CoordinatesX'+str(i)+'='+str(X[i])+'\n')
    g.write('"D'+str(k)+'@Sketch'+str(sketch_number)+'"'+'=CoordinatesX'+str(i)+'\n')
    k+=1
    g.write('CoordinatesY'+str(i)+'='+str(Y[i])+'\n')
    g.write('"D'+str(k)+'@Sketch'+str(sketch_number)+'"'+'=CoordinatesY'+str(i)+'\n')
    k+=1
    #g.write('CoordinatesZ'+str(k)+'='+str(Z[i])+'\n')
    #g.write('D'+str(k)+'@Sketch'+str(sketch_number)+'=CoordinatesZ'+str(k)+'\n')
g.close() #writes coordinates in a txt file then saves the txt file

os.popen('"C:/Users/Public/Desktop/Program Files/SOLIDWORKS Corp/SOLIDWORKS/.exe"') #I want to call the macro that rebuilds the solidworks part with the modified coordinates.

How do I run the macro from Python, to import the new file into Python?


问:
What is the difference between Web App Bot and Azure Bot

Bot Framework SDK documentation says that Web App Bot is deprecated. But there is no information  about the difference between development with Azure Bot and (deprecated) Web App Bot. What exact changes should be done if we migrate form one service (Web App Bot) to another (Azure Bot)?

答:
The Azure Bot is like the Bot Channel Registration. It is a global resource that identifies your bot to toher Azure resources and contains configurations and settings for the bot's external messaging endpoint, channels (Teams, Web Chat, Email, etc.), Exposing APIs, OAuth settings, and more.

To actually host the bot, you would use an Azure App Service. You would create one during the deployment process.

As the stated in the linked docs, existing resources will continue to work. Note that the docs specify that migration is not supported. Moving forward, when you build a new bot, you should use a combination of an Azure Bot for identity and configuration and an App Service to host and run the bot.


问:
CollectionViewCell drop shadow with rounded corners
I've collectionViewCell and want to drop shadow to it, also want to have rounded corners, but it seems impossibile, cause to drop shadow clipToBounds must be set to false, with that, I can't add rounded corners, is there any kind of a "hack" to achieve my target?

```<code>    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let countryCell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! MySubscribitionsCollectionViewCell
        countryCell.layer.cornerRadius = 10
        countryCell.layer.borderWidth = 1.0
        countryCell.layer.borderColor = UIColor.lightGray.cgColor
        countryCell.layer.backgroundColor = UIColor.white.cgColor
        countryCell.layer.shadowColor = UIColor.black.cgColor
        countryCell.layer.shadowOffset = CGSize(width: 2.0, height: 4.0)
        countryCell.layer.shadowRadius = 10.0
        countryCell.layer.shadowOpacity = 0.5
        countryCell.clipsToBounds = false
}
</code>```

答:
You can use another view to cast the shadow

Something like that

```<code>let shadowView = UIView()
shadowView.layer.masksToBounds = false
        // SET SHADOW

let mainView = UIView()
mainView.layer.cornerRadius = 10
mainView.layer.masksToBounds = true

shadowView.addSubview(mainView)
</code>```

In the case of a cell, you can set the shadow on the cell itself, and set the rounding of the corners and your custom views on the contentView of collectionViewCell

Body:
I've collectionViewCell and want to drop shadow to it, also want to have rounded corners, but it seems impossibile, cause to drop shadow clipToBounds must be set to false, with that, I can't add rounded corners, is there any kind of a "hack" to achieve my target?

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let countryCell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! MySubscribitionsCollectionViewCell
        countryCell.layer.cornerRadius = 10
        countryCell.layer.borderWidth = 1.0
        countryCell.layer.borderColor = UIColor.lightGray.cgColor
        countryCell.layer.backgroundColor = UIColor.white.cgColor
        countryCell.layer.shadowColor = UIColor.black.cgColor
        countryCell.layer.shadowOffset = CGSize(width: 2.0, height: 4.0)
        countryCell.layer.shadowRadius = 10.0
        countryCell.layer.shadowOpacity = 0.5
        countryCell.clipsToBounds = false
}

Body:
You can use another view to cast the shadow

Something like that

let shadowView = UIView()
shadowView.layer.masksToBounds = false
        // SET SHADOW

let mainView = UIView()
mainView.layer.cornerRadius = 10
mainView.layer.masksToBounds = true

shadowView.addSubview(mainView)

In the case of a cell, you can set the shadow on the cell itself, and set the rounding of the corners and your custom views on the contentView of collectionViewCell


问:
CSS Style switcher in JavaScript on an Asp .Net server
I am trying to create a mobile website and can do it with just CSS, but the server master pages MUST be in their current locations, I am planning to use a Javascript "Style Switcher" to change the stylesheets but most mobile browsers don't have java support, so is there a way using java (or any other "language" that is either supported by mobile phones or can be run server-side) to run server-side that can also stop some of the page elements from loading (for mobile bandwidth issues) and change a few lines of the master code?

I was thinking of using this (with some edits):
How to Use JavaScript to Change a Cascading Style Sheet (CSS) Dynamically

I cannot use PHP as our hosting provider will not install it.

I do not have Asp .Net access (as a user) but do have FTP access.

答: You could use CSS media queries to adjust width of site for device making the request.</p>


问:
App wont install from some devices on Android12
I have a problem that at first android 12 wouldnt install the app from Google Play store because the

```<code>exported="false"
</code>```

wasnt declared in the manifest for activities.

So I put the exported flag in only the Launcher activity and Broadcast Reciever and then it installed on my device and the emulators.

The problem is that some users are still reporting that they cannot install the app still from Google Play.

So what Im wondering is Do you have to set the

```<code>exported="false"
</code>```

flag in every activity and broadcast reciever? because there are still a bunch of activities with no exported flag set, Could that be the problem? Maybe some devices are stricter with manifest

```<code><receiver
            android:name="com.appboy.AppboyGcmReceiver"
            android:permission="com.google.android.c2dm.permission.SEND"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

                 />
            </intent-filter>
        </receiver>
</code>```

Thank you for your time.

答:
The actual problem was that the file provider was matching other app because there was an error in the build.gradle where it was being set. The applicationId was null for some reason making the file provider

null.fileProvider

Turns out, the McDonald's app has the same issue, if you have null.fileProvider and try to install the app with McDonald's already installed it won't install.

Posting this so others can see.

Body:
I have a problem that at first android 12 wouldnt install the app from Google Play store because the

exported="false"

wasnt declared in the manifest for activities.

So I put the exported flag in only the Launcher activity and Broadcast Reciever and then it installed on my device and the emulators.

The problem is that some users are still reporting that they cannot install the app still from Google Play.

So what Im wondering is Do you have to set the

exported="false"

flag in every activity and broadcast reciever? because there are still a bunch of activities with no exported flag set, Could that be the problem? Maybe some devices are stricter with manifest

<receiver
            android:name="com.appboy.AppboyGcmReceiver"
            android:permission="com.google.android.c2dm.permission.SEND"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

                 />
            </intent-filter>
        </receiver>

Thank you for your time.


问:
How to get into each element in a nested list and compare it with the equivalent in all elements in another list?
I need to get into each element in a nested list and compare it with the equivalent in all elements in another list.

I have two nested lists:

LB=

[[1, 0, 1, 0],

[1, 1, 1, 1],

[0, 0, 1, 0]]

LK=

[[1, 0, 1, 0],

[0, 0, 1, 1],

[1, 1, 1, 1],

[0, 0, 1, 0],

[1, 1, 0, 0],

[0, 0, 0, 0]
]

Analysis flow:

I take the first sublist from LK (i.e., [1, 0, 1, 0]) and compare its individual elements (i.e., 1, 0, 1, 0) with subsequent elements from the sublists LB [1, 0, 1, 0], [1, 1, 1, 1], and [0, 0, 1, 0].
I then take the second sublist from LK (i.e., [0, 0, 1, 1]) and compare its individual elements (i.e., 0, 0, 1, 1) with the subsequent elements from the LB sublist [1, 0, 1, 0], [1, 1, 1, 1, 1], and [0, 0, 1, 0]
I then take the third sublist from LK (i.e., [1, 1, 1, 1]) and compare its individual elements (i.e., 1, 1, 1, 1) with the subsequent elements from the LB sublist [1, 0, 1, 0], [1, 1, 1, 1, 1], and [0, 0, 1, 0]

Here is my attempt at the code, but I know it doesn't work properly and doesn't contain all the conditions.

```<code>for i in LK, LB:
    for j in i:
        while j < (len(LK)-1):
            if j == 0:
                j += 1
            elif j != 0:
                i += 1
            else:
                print(LB[i])
</code>```

Additional conditions:

if a given element in a list in LK is equal to 0 and the digit at the same position in LB is also equal to 0 then proceed to compare the next digit in the given list. When you get to the end of the sublist in the LK list, i.e. you pass [1, 0, 1, 0] and the condition with zeroes is fulfilled, write me this element from the LB list

if given element in the list in LK is equal 0, but digit in the same position in the list LB is not equal 0 then skip this case and check another sublist from LB

if there is no element 0 in the list LK (list [1, 1, 1, 1]) then write a sublist from LB

We perform such an iteration for all the elements in the list LB comparing them with the sublists from LK.

In the analyzed example during the comparison:

the first sublist from LK ([1, 0, 1, 0]) => should be extracted from the list LB: [1, 0, 1, 0] and [0, 0, 1, 0]

the second sublist from LK ([0, 0, 1, 1]) => should be printed from the list LB: [0, 0, 1, 0]

the third sublist from LK ([1, 1, 1, 1, 1]) => should be printed from the lists LB: [1, 0, 1, 0], [1, 1, 1, 1] and [0, 0, 1, 0]

the fourth sublist from LK ([0, 0, 1, 0]) => should be printed from the list LB: [0, 0, 1, 0]

the fifth sublist from LK ([1, 1, 0, 0]) => no element should be written out from the list LB

sixth sublist from LK ([0, 0, 0, 0]) => no element should be written out from the list LB

Output:
Displayed LB sublists that meet the conditions (LB sublists can be displayed in several sectors)

答:
I am a bit confused as to what exactly you want output, but if you just want to output which lists are equal, this is easily accomplished without needing to iterate through each element:</p>
```<code>for lk_row_index, lk_row in enumerate(LK):
    for lr_row_index, lr_row in enumerate(LR):
        if lk_row != lr_row:
            print(f"LR row {lr_row_index} is not equal to LK row {lk_row_index}")
        else:
            print(f"LR row {lr_row_index} is equal to LK row {lk_row_index}")
</code>```

Body:
I need to get into each element in a nested list and compare it with the equivalent in all elements in another list.

I have two nested lists:

LB=

[[1, 0, 1, 0],

[1, 1, 1, 1],

[0, 0, 1, 0]]

LK=

[[1, 0, 1, 0],

[0, 0, 1, 1],

[1, 1, 1, 1],

[0, 0, 1, 0],

[1, 1, 0, 0],

[0, 0, 0, 0]
]

Analysis flow:

I take the first sublist from LK (i.e., [1, 0, 1, 0]) and compare its individual elements (i.e., 1, 0, 1, 0) with subsequent elements from the sublists LB [1, 0, 1, 0], [1, 1, 1, 1], and [0, 0, 1, 0].
I then take the second sublist from LK (i.e., [0, 0, 1, 1]) and compare its individual elements (i.e., 0, 0, 1, 1) with the subsequent elements from the LB sublist [1, 0, 1, 0], [1, 1, 1, 1, 1], and [0, 0, 1, 0]
I then take the third sublist from LK (i.e., [1, 1, 1, 1]) and compare its individual elements (i.e., 1, 1, 1, 1) with the subsequent elements from the LB sublist [1, 0, 1, 0], [1, 1, 1, 1, 1], and [0, 0, 1, 0]

Here is my attempt at the code, but I know it doesn't work properly and doesn't contain all the conditions.

for i in LK, LB:
    for j in i:
        while j < (len(LK)-1):
            if j == 0:
                j += 1
            elif j != 0:
                i += 1
            else:
                print(LB[i])

Additional conditions:

if a given element in a list in LK is equal to 0 and the digit at the same position in LB is also equal to 0 then proceed to compare the next digit in the given list. When you get to the end of the sublist in the LK list, i.e. you pass [1, 0, 1, 0] and the condition with zeroes is fulfilled, write me this element from the LB list

if given element in the list in LK is equal 0, but digit in the same position in the list LB is not equal 0 then skip this case and check another sublist from LB

if there is no element 0 in the list LK (list [1, 1, 1, 1]) then write a sublist from LB

We perform such an iteration for all the elements in the list LB comparing them with the sublists from LK.

In the analyzed example during the comparison:

the first sublist from LK ([1, 0, 1, 0]) => should be extracted from the list LB: [1, 0, 1, 0] and [0, 0, 1, 0]

the second sublist from LK ([0, 0, 1, 1]) => should be printed from the list LB: [0, 0, 1, 0]

the third sublist from LK ([1, 1, 1, 1, 1]) => should be printed from the lists LB: [1, 0, 1, 0], [1, 1, 1, 1] and [0, 0, 1, 0]

the fourth sublist from LK ([0, 0, 1, 0]) => should be printed from the list LB: [0, 0, 1, 0]

the fifth sublist from LK ([1, 1, 0, 0]) => no element should be written out from the list LB

sixth sublist from LK ([0, 0, 0, 0]) => no element should be written out from the list LB

Output:
Displayed LB sublists that meet the conditions (LB sublists can be displayed in several sectors)

Body:
I am a bit confused as to what exactly you want output, but if you just want to output which lists are equal, this is easily accomplished without needing to iterate through each element:

for lk_row_index, lk_row in enumerate(LK):
    for lr_row_index, lr_row in enumerate(LR):
        if lk_row != lr_row:
            print(f"LR row {lr_row_index} is not equal to LK row {lk_row_index}")
        else:
            print(f"LR row {lr_row_index} is equal to LK row {lk_row_index}")


问:
After x groups of spaces select the next bunch of chars - regex
I need help creating a reflex expression.

I have a file/string with a lot of lines, but I've only listed the first two as these are the only ones that matter. The value I am trying to extract is from the second line only and is the 5th group along; in this case it will the 2nd number 8. As you can see though, the first three bunches of chars are not words. The brackets are colour codes and need to stay there. There may also be another string further down like the second row, I need it to return the first value only (not multiple matches).

```<code>[56f442] M    WS  BS   S   T    W    A  Ld  Sv   [-]
[98ffa7]12"[-]   [98ffa7]3+[-]   [98ffa7]3+[-]   8   8   26   4   9   3+   [-][-]
</code>```

Thanks

答:
To capture the group of non-whitespace (\S+) after the 4th group (?:\S+\s+){4} that's after the first newline ^.*?\n.*?

```<code>^.*?\n.*?(?:\S+\s+){4}(\S+)
</code>```

Body:
I need help creating a reflex expression.

I have a file/string with a lot of lines, but I've only listed the first two as these are the only ones that matter. The value I am trying to extract is from the second line only and is the 5th group along; in this case it will the 2nd number 8. As you can see though, the first three bunches of chars are not words. The brackets are colour codes and need to stay there. There may also be another string further down like the second row, I need it to return the first value only (not multiple matches).

[56f442] M    WS  BS   S   T    W    A  Ld  Sv   [-]
[98ffa7]12"[-]   [98ffa7]3+[-]   [98ffa7]3+[-]   8   8   26   4   9   3+   [-][-]

Thanks

Body:
To capture the group of non-whitespace (\S+) after the 4th group (?:\S+\s+){4} that's after the first newline ^.*?\n.*?

^.*?\n.*?(?:\S+\s+){4}(\S+)


问:
Calculate difference in variable within same day in two nc file
I have two NC files with ERA5land precipitation data from the months AMJJASO of 2001-2020. One NC file of precipitation data from UTC 00.00 and one NC file with precipitation data from UTC 12.00. I would like to subtract the precipitation from UTC 00.00 from the precipitation at timeslot 12.00, hence;

UTC12.00 - UTC00.00 = UTCprecip

I have previously used cdo as

```<code>cdo sub UTC12.nc UTC00.nc UTCprecip.nc
</code>```

but was looking for something like daysub, not ydaysub though(!).

But does this simple subtraction using cdo sub occur within each day only?

Or do I have to use a different call?

答:
Rob's answer is correct, I was just wondering though what you want to get from this?  The ERA5 land description of precip is that

This variable is accumulated from the beginning of the forecast time
to the end of the forecast step.

I'm trying to understand what you are trying to achieve, if the files are accumulated and you subtract one from the other, are you not getting the 12 hour accumulated precip?

Anyway

```<code>cdo sub in1.nc in2.nc out.nc
</code>```

would do this, but then you would also need a

```<code>cdo sub in2.nc in1.nc out.nc
</code>```

to get the 12-24 hour precip.  I'm waiting for my download to finish and will update this as necessary.

By the way, if you want more details on how sub, broadcasting and the time stamp locking with daysub, monsub and yearsub works, you can check out this video I recently posted on this topic.

Body:
I have two NC files with ERA5land precipitation data from the months AMJJASO of 2001-2020. One NC file of precipitation data from UTC 00.00 and one NC file with precipitation data from UTC 12.00. I would like to subtract the precipitation from UTC 00.00 from the precipitation at timeslot 12.00, hence;

UTC12.00 - UTC00.00 = UTCprecip

I have previously used cdo as

cdo sub UTC12.nc UTC00.nc UTCprecip.nc

but was looking for something like daysub, not ydaysub though(!).

But does this simple subtraction using cdo sub occur within each day only?

Or do I have to use a different call?

Body:
Rob's answer is correct, I was just wondering though what you want to get from this?  The ERA5 land description of precip is that

This variable is accumulated from the beginning of the forecast time
to the end of the forecast step.

I'm trying to understand what you are trying to achieve, if the files are accumulated and you subtract one from the other, are you not getting the 12 hour accumulated precip?

Anyway

cdo sub in1.nc in2.nc out.nc

would do this, but then you would also need a

cdo sub in2.nc in1.nc out.nc

to get the 12-24 hour precip.  I'm waiting for my download to finish and will update this as necessary.

By the way, if you want more details on how sub, broadcasting and the time stamp locking with daysub, monsub and yearsub works, you can check out this video I recently posted on this topic.


问:
Finding categories that make up 70% of total turnover in SQL
I want to find the categories that make up a certain percentage of sales, and segment them according to their percentages in SQL. To do this, I must first sort them by their revenues in descending order and then select the top N percent. For example, if the total revenue is 20M:

```<code>Category Revenue
1        6.000.000
2        4.000.000
3        4.000.000
4        3.000.000
5        1.500.000
6        500.000
7        400.000
8        300.000
9        200.000
10       100.000

Total    20.000.000
</code>```

-Categories that make up 70% (14M) of revenue - segment A

-Categories that make up 15% (3M) - segment B

-Categories that make up 10% (2M) - segment C

-Categories that make up 5% (1M) - segment D

So, the segments should be like this:

```<code>Category Segment
1        A
2        A
3        A
4        B
5        C
6        C
7        D
8        D
9        D
10       D

</code>```

答:
This answer uses window functions like the previous answer, but includes a CASE expression instead of multiple CTEs.</p>
```<code>WITH
cte AS (
SELECT category, revenue,
    sum(revenue) OVER(ORDER BY revenue DESC, category)*1. /*multiply by 1. (or use CAST) to avoid integer truncation in immediate next step*/
        /sum(revenue) OVER() RunTtlPct /*Running total of sales, as a percent of the grand total*/
FROM t)

SELECT category, revenue,
    CASE
        WHEN RunTtlPct <= 0.7 THEN 'A'
        WHEN RunTtlPct <= 0.85 THEN 'B'
        WHEN RunTtlPct <= 0.95 THEN 'C'
        ELSE 'D'
    END Segment
FROM cte /*cte was included to avoid repeating RunTtlPct's expression in every WHEN clause.*/
</code>```

Body:
I want to find the categories that make up a certain percentage of sales, and segment them according to their percentages in SQL. To do this, I must first sort them by their revenues in descending order and then select the top N percent. For example, if the total revenue is 20M:

Category Revenue
1        6.000.000
2        4.000.000
3        4.000.000
4        3.000.000
5        1.500.000
6        500.000
7        400.000
8        300.000
9        200.000
10       100.000

Total    20.000.000

-Categories that make up 70% (14M) of revenue - segment A

-Categories that make up 15% (3M) - segment B

-Categories that make up 10% (2M) - segment C

-Categories that make up 5% (1M) - segment D

So, the segments should be like this:

Category Segment
1        A
2        A
3        A
4        B
5        C
6        C
7        D
8        D
9        D
10       D

Body:
This answer uses window functions like the previous answer, but includes a CASE expression instead of multiple CTEs.

WITH
cte AS (
SELECT category, revenue,
    sum(revenue) OVER(ORDER BY revenue DESC, category)*1. /*multiply by 1. (or use CAST) to avoid integer truncation in immediate next step*/
        /sum(revenue) OVER() RunTtlPct /*Running total of sales, as a percent of the grand total*/
FROM t)

SELECT category, revenue,
    CASE
        WHEN RunTtlPct <= 0.7 THEN 'A'
        WHEN RunTtlPct <= 0.85 THEN 'B'
        WHEN RunTtlPct <= 0.95 THEN 'C'
        ELSE 'D'
    END Segment
FROM cte /*cte was included to avoid repeating RunTtlPct's expression in every WHEN clause.*/


问:
Is it possible to change python virtualenv name, shown in prompt?
Is there any way to change name, that is shown in prompt, while virtualenv activated?

```<code>username@host:~$ python3 -m venv venv
username@host:~$ source venv/bin/activate
(venv) username@host:~$
</code>```

But i need it to be shown as something like this:

```<code>username@host:~$ python3 -m venv venv
username@host:~$ source venv/bin/activate
(some_arbitrary_name) username@host:~$
</code>```

UPD:
Thanks for answers. Prompt name can not be changed after creation, however, there is a way to show some arbitrary name in prompt other than folder name:

```<code>username@host:~$ python3 -m venv .venv --prompt some_arbitrary_name
username@host:~$ source venv/bin/activate
(some_arbitrary_name) username@host:~$
</code>```

答:
The prompt is modified in the bin/activate script, so just change the line that adds (venv).  It looks something like this:

```<code>if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
    _OLD_VIRTUAL_PS1="${PS1:-}"
    PS1="(venv) ${PS1:-}"
    export PS1
fi
</code>```

Just change that (venv) to your name of choice.

Note that in more recent venv versions the above code looks like this:

```<code>if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then
    _OLD_VIRTUAL_PS1="${PS1-}"
    if [ "x" != x ] ; then
        PS1="() ${PS1-}"
    else
        PS1="(`basename \"$VIRTUAL_ENV\"`) ${PS1-}"
    fi
    export PS1
fi

</code>```

You can still just replace

```<code>(`basename \"$VIRTUAL_ENV\"`)
</code>```

with a simple string like (my_venv)

Body:
Is there any way to change name, that is shown in prompt, while virtualenv activated?

username@host:~$ python3 -m venv venv
username@host:~$ source venv/bin/activate
(venv) username@host:~$

But i need it to be shown as something like this:

username@host:~$ python3 -m venv venv
username@host:~$ source venv/bin/activate
(some_arbitrary_name) username@host:~$

UPD:
Thanks for answers. Prompt name can not be changed after creation, however, there is a way to show some arbitrary name in prompt other than folder name:

username@host:~$ python3 -m venv .venv --prompt some_arbitrary_name
username@host:~$ source venv/bin/activate
(some_arbitrary_name) username@host:~$

Body:
The prompt is modified in the bin/activate script, so just change the line that adds (venv).  It looks something like this:

if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
    _OLD_VIRTUAL_PS1="${PS1:-}"
    PS1="(venv) ${PS1:-}"
    export PS1
fi

Just change that (venv) to your name of choice.

Note that in more recent venv versions the above code looks like this:

if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then
    _OLD_VIRTUAL_PS1="${PS1-}"
    if [ "x" != x ] ; then
        PS1="() ${PS1-}"
    else
        PS1="(`basename \"$VIRTUAL_ENV\"`) ${PS1-}"
    fi
    export PS1
fi

You can still just replace

(`basename \"$VIRTUAL_ENV\"`)

with a simple string like (my_venv)


问:
Flutter - Splash Screen Setting
I want to set Splash Screen with an image.
It doesn't work properly.

Let me show you my settings.

So I changed the part as

```<code>android:src="@mipmap/launch_image"
</code>```

But when I open app splash screen image is not launch_image.
But the splash image is ic_launcher.png image
I want to set ic_laucher.png as icon image
and I want to set launch_image.png as splash screen image.

Can you let me know how to do it?

答: I maintain a package on pub.dev that sets up the splash screen for you automatically: https://pub.dev/packages/flutter_native_splash.  I think you will find it a lot easier than setting up the splash screen manually.</p>

Title: Flutter - Splash Screen Setting

Body:
I want to set Splash Screen with an image.
It doesn't work properly.

Let me show you my settings.

So I changed the part as

android:src="@mipmap/launch_image"

But when I open app splash screen image is not launch_image.
But the splash image is ic_launcher.png image
I want to set ic_laucher.png as icon image
and I want to set launch_image.png as splash screen image.

Can you let me know how to do it?


问:
Import CSV file from Onedrive - Excel Web - Office Script
I would like to create script in order to allow user of file.xlsx stored into Onedrive to import date from file.csv (into same folder of file.xlsx into Onedrive). And then, process these data with other script.

Folder X

----- file.xlsx

----- file.csv

My users get access via a business licence to Excel Web (no Desktop application).

I read Office Script documentation and I didn't find function to load csv content into worksheet (via Excel Web).

答:
Are you able to use Power Automate in your organization? If so, you can use the OneDrive connector to load the .csv file and create a new xlsx file. An Office Script could then fill the .xlsx file with the data by parsing the comma-separated values (here's a Stack thread on how to do that).

There's a sample that shows this whole process in the MSFT docs: Convert CSV files to Excel workbooks.


问:
Why wp-options table is 60GB but backup is 24Mb
After Deleting Transients. Cleaning autoload Options. Setting log_days in my.cnf to 1, an many more tricks... My wp-options says its size is 50GB... however when I backup the file is 24MB.

I'm clearly missing something that is causing me huge binlog files and space problems on the server.

It as bitnami Wordpress installation on a Lightsail server

Any clues will be appreciated

Thanks

答:
Summary of the comment thread above:

A combination of using OPTIMIZE TABLE to defragment the InnoDB tables after deleting lots of data, and PURGE BINARY LOGS to prune the accumulated binary logs helped to reduce the storage usage.


问:
strange issue of undefined in url in UAT env. in local it is working:
can anybody please help on this.

I have strange issue in API. My backend is created in php and UI in react.
in my env file below path are present.

```<code>API_URL=http://localhost:8080
FRONT_URL=http://localhost:80
</code>```

so API_URL is for backend and FRONT_URL is for UI. I have called my API like below in react.

```<code> axios
      .get(process.env.API_URL+ '/code';)
      .then()
      .error
</code>```

my code is working properly. same API I can access from reactas well as postman. there is no issue.
But when we deployed our application in UAT URL is appending undefined between API name and API URL.
Below are API value in UAT env file.

```<code>FRONT_URL=https://uat-solve.dell.com
API_URL=https://api.uat-solve.dell.com
</code>```

Now my application throwing error. it is not running. when I checked what URL it is trying to reach out then it came below.

```<code>https://api.uat-solve.dell.com/undefined/code
</code>```

It is appending undefined in between. when I tried to access same url from postman after removing undefined output is coming.

What could be the possible reason of it? this is the new component in react. existing application working properly

Edit 1:-

I changed env variable to REACT_APP* but still it did not work.

答:
The Create React App documentation states that you must prefix all environment variables within your .env files with REACT_APP_ for them to be available from within your code process.env.REACT_APP_<variable name>

If you don't want to use REACT_APP_ prefix, you can use env-create-react-app

Body:
can anybody please help on this.

I have strange issue in API. My backend is created in php and UI in react.
in my env file below path are present.

API_URL=http://localhost:8080
FRONT_URL=http://localhost:80

so API_URL is for backend and FRONT_URL is for UI. I have called my API like below in react.

 axios
      .get(process.env.API_URL+ '/code';)
      .then()
      .error

my code is working properly. same API I can access from reactas well as postman. there is no issue.
But when we deployed our application in UAT URL is appending undefined between API name and API URL.
Below are API value in UAT env file.

FRONT_URL=https://uat-solve.dell.com
API_URL=https://api.uat-solve.dell.com

Now my application throwing error. it is not running. when I checked what URL it is trying to reach out then it came below.

https://api.uat-solve.dell.com/undefined/code

It is appending undefined in between. when I tried to access same url from postman after removing undefined output is coming.

What could be the possible reason of it? this is the new component in react. existing application working properly

Edit 1:-

I changed env variable to REACT_APP* but still it did not work.


问:
Notebook validation failed: Non-unique cell id 'hawaiian-pregnancy' detected. Corrected to '8fbbc816'.:
i have copied the notebook to create another version and all the time getting this strange errors, Does anyone have a clue how to get rid of it?</p>

答:
The best temporary solution so far is the following, from this GitHub issue:

First select all the cells in the Jupyter Notebook, then press the "cut/scissors" button (don't panic, at this point your Notebook will be empty), and finally press the "paste" button.


问:
Is it possible to recover deleted shelved files in perforce?
I had some changes shelved in a change list. Looks like I've deleted those shelved files by mistake. I don't keep much hopes of recovering them but given that shelving puts the changes in the server,  Is there any chance that these are still accessible somewhere?

Thank you

答:
I knew this was a thing, but I forgot and my coworker saved my bacon with a 15 file shelve that I accidentally deleted:

In my case, VS2019 was still opened and had all of my files in it. Going to each file and Undo-ing a few times restored the shelved version of the files. Was able to save them, and then just had to diff each file with current version to make sure only my intended changes were there.


问:
ai-form-recognizer vs. cognitiveservices-computervision
Currently using @azure/ai-form-recognizer 3.2.0 to OCR from images and PDF like:

```<code>const poller = await MsClient.beginRecognizeInvoices(stream,
            {
                onProgress: (state) => {}
            });
const [ocrResult] = await poller.pollUntilDone();
</code>```

What's the diff or relationship of @azure/cognitiveservices-computervision? I'm only interested in OCR.

答:
There are several key differences between the two. Form Recognizer's primary goal is to structure data from forms and other digitized documents for further processing. The key here is that Form Recognizer provides features that can help better contextualize the information that is read from said documents than just stand-alone optical character recognition. From the Form Recognizer documentation (emphasis mine):

Azure Form Recognizer is a cloud-based Azure Applied AI Service that uses machine-learning models to extract and analyze form fields, text, and tables from your documents. Form Recognizer analyzes your forms and documents, extracts text and data, maps field relationships as key-value pairs, and returns a structured JSON output. You quickly get accurate results that are tailored to your specific content without excessive manual intervention or extensive data science expertise. Use Form Recognizer to automate your data processing in applications and workflows, enhance data-driven strategies, and enrich document search capabilities.

On the other hand, Azure Computer Vision provides three distinct features. While the OCR tenet below describes something similar to Form Recognizer, it's more general-purpose in use in that it does not provide as robust  contextualization of key/value pairs that Form Recognizer does. The service also provides higher-level AI functionality for processing images and video to identify people/celebrities, landmarks, and common objects in them (among others). From the Computer Vision documentation:

Service
Description

Optical Character Recognition (OCR)
The Optical Character Recognition (OCR) service extracts text from images. You can use the new Read API to extract printed and handwritten text from photos and documents. It uses deep-learning-based models and works with text on a variety of surfaces and backgrounds. These include business documents, invoices, receipts, posters, business cards, letters, and whiteboards. The OCR APIs support extracting printed text in several languages...

Image Analysis
The Image Analysis service extracts many visual features from images, such as objects, faces, adult content, and auto-generated text descriptions. Follow the Image Analysis quickstart to get started.

Spatial Analysis
The Spatial Analysis service analyzes the presence and movement of people on a video feed and produces events that other systems can respond to. Install the Spatial Analysis container to get started.

At first glance, there is some overlap between the two, but upon further inspection there are clear delineations for the primary use cases for the two.

Body:
Currently using @azure/ai-form-recognizer 3.2.0 to OCR from images and PDF like:

const poller = await MsClient.beginRecognizeInvoices(stream,
            {
                onProgress: (state) => {}
            });
const [ocrResult] = await poller.pollUntilDone();

What's the diff or relationship of @azure/cognitiveservices-computervision? I'm only interested in OCR.


问:
my terminal inserts and enters the letter "Y" after most git commands
Myself and a coworker have started experiencing an odd issue where the "Y" character is inserted and then entered after nearly every git command. (Git add. , git commit, git push etc)

I am using Visual studio and typing my commands in the terminal window.

This issue does not break any functionality, it's just weird and very hard to google.

答:
Probably because of the new setting:

Terminal > Integrated: Auto Replies

see v1.64 Release Notes

Do you have anything in this setting: "terminal.integrated.autoReplies"?

The feature is supposed to be opt-in so it shouldn't be doing that unless you have something in that setting.  Unless there is a git extension that is doing that "for you".  You could look through any git extension settings you may have installed to see if they enable an auto replies feature - I don't think the built-in git extension does.

In your case if you don't have a "terminal.integrated.autoReplies" that looks like a bug to me.


问:
casting to int python with symbol
so I want to cast these to ints but when I use the built-in function int() I get an error, I don't want to make a custom function that checks the first character,so I was wondering if there was a way to convert these to ints.

答:
From what we found in the discussion under your question:

You have the mathematical unicode symbol "minus sign" instead of the ASCII symbol "hyphen-minus" in your string.

The problem can be solved by replacing the non-workning symbol with the working one:

int(CDMAOutput[idx].replace(chr(8722), '-')))
```

Title: casting to int python with symbol


问:
Where to get Credits used by particular session_id in Snowflake
I am looking for an option to get the credit usage by specific session_id in Snowflake. is it possible to get the same? as i understand all credits are charged based on warehouse level. so curious if we can get those credits OR cost in USD for particular Session_id?</p>

答:
It's almost impossible to find the compute credits used by a session unless the session runs the queries in a dedicated warehouse.

As you mentioned, compute credits are charged based on how long a warehouse runs (stays online/operational). So it's not possible to distribute these credits to the queries. You can find how many concurrent queries were running on the warehouse and then share the credits evenly for each query, but this will not be a fair distribution. A query may use less resources and take a longer time to execute. In this case, "sharing the credits evenly between concurrent queries" will ignore this and evaluate this query as the most expensive one. Thus, the session executed that "slow" query will pay most of the bill :)

You may dedicate a warehouse to the session if you need to bill/record compute credits per session (or per user).