问:
how to call element in static void?
I'm doing a little selenium program with c#. I want to wait max 5 seconds to interact button or something if its visible. I've made a code for it but I cannot call that code inside static void main it says an object is required non-static field. how do I fix this ?
an error : An object reference is required for the non-static field, method, or property 'Program.waitForPageUntilElementIsVisible(By, int)

class Program
    {
        public IWebDriver driver;

```<code>    static void Main(string[] args)
    {
        IWebDriver driver = new ChromeDriver();
        driver.Navigate().GoToUrl("https://www.mail.com/int/");
        IWebElement login = driver.FindElement(By.Id("login-button"));
        login.Click();
        IWebElement email = driver.FindElement(By.Id("login-email"));
        waitForPageUntilElementIsVisible(By.Id("login-email"), 5);
        email.SendKeys("CarlosdanielGrossen95@mail.com");

    }

        public  IWebElement waitForPageUntilElementIsVisible(By locator,int maxseconds)
    {

       return new  WebDriverWait(driver, TimeSpan.FromSeconds(maxseconds))
            .Until(ExpectedConditions.ElementExists((locator)));
    }

}
}
</code>```

An object reference is required for the non-static field, method, or property 'Program.waitForPageUntilElementIsVisible(By, int)

答:
Define this method in a separate class and call this method with PageWait Object.</p>

```<code>public class PageWait
{
  public  IWebElement waitForPageUntilElementIsVisible(By locator,int maxseconds)
    {
       return new  WebDriverWait(driver, TimeSpan.FromSeconds(maxseconds))
            .Until(ExpectedConditions.ElementExists((locator)));
    }
}

class Program {
public IWebDriver driver;

    static void Main(string[] args)
    {
        IWebDriver driver = new ChromeDriver();
        driver.Navigate().GoToUrl("https://www.mail.com/int/");
        IWebElement login = driver.FindElement(By.Id("login-button"));
        login.Click();
        IWebElement email = driver.FindElement(By.Id("login-email"));
        new PageWait().waitForPageUntilElementIsVisible(By.Id("login-email"), 5);
        email.SendKeys("CarlosdanielGrossen95@mail.com");

    }
}
</code>```

Title: how to call element in static void?

Body:
I'm doing a little selenium program with c#. I want to wait max 5 seconds to interact button or something if its visible. I've made a code for it but I cannot call that code inside static void main it says an object is required non-static field. how do I fix this ?
an error : An object reference is required for the non-static field, method, or property 'Program.waitForPageUntilElementIsVisible(By, int)

class Program
    {
        public IWebDriver driver;

    static void Main(string[] args)
    {
        IWebDriver driver = new ChromeDriver();
        driver.Navigate().GoToUrl("https://www.mail.com/int/");
        IWebElement login = driver.FindElement(By.Id("login-button"));
        login.Click();
        IWebElement email = driver.FindElement(By.Id("login-email"));
        waitForPageUntilElementIsVisible(By.Id("login-email"), 5);
        email.SendKeys("CarlosdanielGrossen95@mail.com");

    }

        public  IWebElement waitForPageUntilElementIsVisible(By locator,int maxseconds)
    {

       return new  WebDriverWait(driver, TimeSpan.FromSeconds(maxseconds))
            .Until(ExpectedConditions.ElementExists((locator)));
    }

}
}

An object reference is required for the non-static field, method, or property 'Program.waitForPageUntilElementIsVisible(By, int)

Body:
Define this method in a separate class and call this method with PageWait Object.

public class PageWait
{
  public  IWebElement waitForPageUntilElementIsVisible(By locator,int maxseconds)
    {
       return new  WebDriverWait(driver, TimeSpan.FromSeconds(maxseconds))
            .Until(ExpectedConditions.ElementExists((locator)));
    }
}

class Program {
public IWebDriver driver;

    static void Main(string[] args)
    {
        IWebDriver driver = new ChromeDriver();
        driver.Navigate().GoToUrl("https://www.mail.com/int/");
        IWebElement login = driver.FindElement(By.Id("login-button"));
        login.Click();
        IWebElement email = driver.FindElement(By.Id("login-email"));
        new PageWait().waitForPageUntilElementIsVisible(By.Id("login-email"), 5);
        email.SendKeys("CarlosdanielGrossen95@mail.com");

    }
}


来源: stackexchange

问:
Bash get the command that is piping into a script
Take the following example:

```<code>ls -l | grep -i readme | ./myscript.sh
</code>```

What I am trying to do is get ls -l | grep -i readme as a string variable in myscript.sh. So essentially I am trying to get the whole command before the last pipe to use inside myscript.sh.

Is this possible?

答:
It can't be done generally, but using the history command in bash it can maybe sort of be done, provided certain conditions are met:

history has to be turned on.

Only one shell has been running, or accepting new commands, (or failing that, running myscript.sh), since the start of myscript.sh.

Since command lines with leading spaces are, by default, not saved to the history, the invoking command for myscript.sh must have no leading spaces; or that default must be changed -- see Get bash history to remember only the commands run with space prefixed.

The invoking command needs to end with a &, because without it the new command line wouldn't be added to the history until after myscript.sh was completed.

The script needs to be a bash script, (it won't work with /bin/dash), and the calling shell needs a little prep work.  Sometime before the script is run first do:

```<code>shopt -s histappend
PROMPT_COMMAND="history -a; history -n"
</code>```

...this makes the bash history heritable.  (Code swiped from unutbu's answer to a related question.)

Then myscript.sh might go:

```<code>#!/bin/bash
history -w
printf 'calling command was: %s\n' \
    "$(history | rev |
       grep "$0" ~/.bash_history | tail -1)"
</code>```

Test run:

```<code>echo googa | ./myscript.sh &
</code>```

Output, (minus the "&" associated cruft):

```<code>calling command was: echo googa | ./myscript.sh &
</code>```

The cruft can be halved by changing "&" to "& fg", but the resulting output won't include the "fg" suffix.

ContentLicense: CC BY-SA 4.0

Body:
Take the following example:

ls -l | grep -i readme | ./myscript.sh

What I am trying to do is get ls -l | grep -i readme as a string variable in myscript.sh. So essentially I am trying to get the whole command before the last pipe to use inside myscript.sh.

Is this possible?

Body:
It can't be done generally, but using the history command in bash it can maybe sort of be done, provided certain conditions are met:

history has to be turned on.

Only one shell has been running, or accepting new commands, (or failing that, running myscript.sh), since the start of myscript.sh.

Since command lines with leading spaces are, by default, not saved to the history, the invoking command for myscript.sh must have no leading spaces; or that default must be changed -- see Get bash history to remember only the commands run with space prefixed.

The invoking command needs to end with a &, because without it the new command line wouldn't be added to the history until after myscript.sh was completed.

The script needs to be a bash script, (it won't work with /bin/dash), and the calling shell needs a little prep work.  Sometime before the script is run first do:

shopt -s histappend
PROMPT_COMMAND="history -a; history -n"

...this makes the bash history heritable.  (Code swiped from unutbu's answer to a related question.)

Then myscript.sh might go:

#!/bin/bash
history -w
printf 'calling command was: %s\n' \
    "$(history | rev |
       grep "$0" ~/.bash_history | tail -1)"

Test run:

echo googa | ./myscript.sh &

Output, (minus the "&" associated cruft):

calling command was: echo googa | ./myscript.sh &

The cruft can be halved by changing "&" to "& fg", but the resulting output won't include the "fg" suffix.


问:
How to FilterItems by Contains
I can collect items if I have the exact string of a text field but I need to collect items if I have a partial string in a text field.

Here is the code that I have for exact match...

```<code>public static async Task<int> Items_With_String(int appId, string textFieldId, string stringToSearch)
{

    var filter = new Dictionary<string, string>
    {
        {textFieldId, stringToSearch }
    };

    var filteredItems = await Program.podio.ItemService.FilterItems(appId: appId, filters: filter);

    foreach (var item in filteredItems.Items)
    {
        Console.WriteLine($"{stringToSearch} found in {item.Title}");
    }

    return filteredItems.Total;
}
</code>```

答:
Instead of FilterItems, you can use Search functionality.

you can refer below link for more info.

https://developers.podio.com/doc/search/search-in-app-4234651

please see the sample

```<code>                bool isContinue = true;
                var limit = 0;
                var offSet = 0;
                while (isContinue)
                {
                    var items = podio.SearchService.SearchInApp(appId, stringToSearch, limit, offset);
                    offSet = offSet + limit;
                    limit = limit + 100;
                    isContinue = // check if you have value;
                }
</code>```

Title: How to FilterItems by Contains

Body:
I can collect items if I have the exact string of a text field but I need to collect items if I have a partial string in a text field.

Here is the code that I have for exact match...

public static async Task<int> Items_With_String(int appId, string textFieldId, string stringToSearch)
{

    var filter = new Dictionary<string, string>
    {
        {textFieldId, stringToSearch }
    };

    var filteredItems = await Program.podio.ItemService.FilterItems(appId: appId, filters: filter);

    foreach (var item in filteredItems.Items)
    {
        Console.WriteLine($"{stringToSearch} found in {item.Title}");
    }

    return filteredItems.Total;
}

Body:
Instead of FilterItems, you can use Search functionality.

you can refer below link for more info.

https://developers.podio.com/doc/search/search-in-app-4234651

please see the sample

                bool isContinue = true;
                var limit = 0;
                var offSet = 0;
                while (isContinue)
                {
                    var items = podio.SearchService.SearchInApp(appId, stringToSearch, limit, offset);
                    offSet = offSet + limit;
                    limit = limit + 100;
                    isContinue = // check if you have value;
                }


问:
Set HTML img attribute to Angular binding
Inside the HTML class for my Angular component, I have an image displaying with:

```<code><div class="row" id="work">
  <div class="col-xl-3 col-lg-4 col-md-6 col-sm-12" id="">
      <img class="img-fluid" width="100%" [height]="height" src="assets/images/logo.png" alt="">
      <img class="img-fluid" width="100%" height="100" src="assets/images/logo.png" alt="">
      <img class="img-fluid" width="100%" height="100" src="assets/images/logo.png" alt="">
  </div>
</div>
</code>```

In my typescript file for the component, I have a height variable being set to "100" on init.

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

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

  height = "500";

  constructor() { }

  ngOnInit() {
    this.height = "500";
  }
}
</code>```

On page load, the image height is equal to the default images height, it it not reading/using my height variable. Probably something silly, but not sure what.

EDIT:

"img-fluid" was the problem. It ignores the height attribute, sets height to auto, so I couldnt set it myself from Typescript.

答:
@penleychan is correct, just wrap height in braces and reference the height variable as its value. But to clarify why yours isn't working as is, you're just missing surrounding quotation marks:

height="{{height}}"

If I'm not mistaken, adding quotes would make yours work as well. But @penleychan's method is much more common.

Body:
Inside the HTML class for my Angular component, I have an image displaying with:

In my typescript file for the component, I have a height variable being set to "100" on init.

import { Component, OnInit } from '@angular/core';

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

  height = "500";

  constructor() { }

  ngOnInit() {
    this.height = "500";
  }
}

On page load, the image height is equal to the default images height, it it not reading/using my height variable. Probably something silly, but not sure what.

EDIT:

"img-fluid" was the problem. It ignores the height attribute, sets height to auto, so I couldnt set it myself from Typescript.


问:
How to find the placement of a List within another List?
I am working with two lists. The first contains a large sequence of strings. The second contains a smaller list of strings. I need to find where the second list exists in the first list.

I worked with enumeration, and due to the large size of the data, this is very slow, I was hoping for a faster way.

```<code>    List<string> first = new List<string>() { "AAA","BBB","CCC","DDD","EEE","FFF" };

    List<string> second = new List<string>() { "CCC","DDD","EEE" };

int x = SomeMagic(first,second);
</code>```

And I would need x to = 2.

答:
Implemented SomeMagic method as below, this will return -1 if no match found, else it will return the index of start element in first list.</p>

```<code>private int SomeMagic(List<string> first, List<string> second)
{
    if (first.Count < second.Count)
    {
        return -1;
    }

    for (int i = 0; i <= first.Count - second.Count; i++)
    {
        List<string> partialFirst = first.GetRange(i, second.Count);
        if (Enumerable.SequenceEqual(partialFirst, second))
            return i;
    }

    return -1;
}
</code>```

Body:
I am working with two lists. The first contains a large sequence of strings. The second contains a smaller list of strings. I need to find where the second list exists in the first list.

I worked with enumeration, and due to the large size of the data, this is very slow, I was hoping for a faster way.

    List<string> first = new List<string>() { "AAA","BBB","CCC","DDD","EEE","FFF" };

    List<string> second = new List<string>() { "CCC","DDD","EEE" };

int x = SomeMagic(first,second);

And I would need x to = 2.

Body:
Implemented SomeMagic method as below, this will return -1 if no match found, else it will return the index of start element in first list.

private int SomeMagic(List<string> first, List<string> second)
{
    if (first.Count < second.Count)
    {
        return -1;
    }

    for (int i = 0; i <= first.Count - second.Count; i++)
    {
        List<string> partialFirst = first.GetRange(i, second.Count);
        if (Enumerable.SequenceEqual(partialFirst, second))
            return i;
    }

    return -1;
}


问:
Can I program a concise row-based shiny UI?
Trying to program a shiny app layout including rows and columns for inputs. Built in functions are best for simple column format. So far managed to nest a load of fluidRows to get the output in the sample code below.

Nesting fluidRow:
R Shiny - how to generate this layout with nested rows in column 2

shiny 4 small textInput boxes side-by-side

Here is a subset of my code:

```<code>ui <- fluidPage(
  h1("XXX"), #Main page title
  fluidRow(
    column(3,
           wellPanel(
             sliderInput(inputId = "time.step",
                         label = "Time",
                         value = 100, min = 0, max = 1000),
             numericInput(inputId = "no_",
                          label = "choose number",
                          value = 8, min = 1, max = 10),
             checkboxGroupInput(inputId = "chr_vec",
                                label = "characters",
                                choices = c("a", "b", "c", "d", "e", "f",
                                            "g", "h", "i", "j", "k"),
                                selected = c("a", "b")
             ), #close checkboxGroupInput
             actionButton("runbutton", "Run")
           ) #close wellPanel
    ), #close column
    #### Parameters ####
    column(8,
           fluidRow(

             conditionalPanel(
               condition = "input.chr_vec.indexOf('a') !== -1",

                    column(12,
           splitLayout("Parameters",
                     numericInput(inputId = "1.numeric.flip.time",
                                  label = "1",
                                  value = 50, min = 0, max = 1000),

                     numericInput(inputId = "2.numeric.start.val",
                                  label = "2",
                                  value = 99, min = 0, max = 1000),

                     numericInput(inputId = "3.numeric.end.val",
                                  label = "3",
                                  value = 100, min = 0, max = 1000),

                     numericInput(inputId = "sd.numeric.stdev",
                                  label = "SD",
                                  value = 0, min = 0, max = 1000)
           ) #close splitLayout
                    ) #close column
             ) #close conditionslPanel
           ), #close fluidRow

           fluidRow(
             conditionalPanel(
               condition = "input.chr_vec.indexOf('b') !== -1",
             column(12,
                    splitLayout("Parameters2",
                                numericInput(inputId = "5.numeric.flip.time",
                                             label = "5",
                                             value = 50, min = 0, max = 1000),

                                numericInput(inputId = "6.numeric.start.val",
                                             label = "6",
                                             value = 99, min = 0, max = 1000)

                    ) #close splitLayout
             ) #cose column
             ) #close conditionalPanel
           ) # close fluidRow

    ) #close column
  )
)
shinyApp(ui, server = function(input, output) { })
</code>```

Things I'm trying to solve:

1) The title 'parameters' is floating oddly like a input field taking up room.

2) in the real code there are roughly a dozen rows of parameters (one row per checkbox on the left), things get real messy especially when the number of rows extends beyond the check input column (aiming for something like the image below).

3) scale and justification - would help a lot if I could scale the font and input fields of the rows of parameters down a little and ideally justify the input fields left rather than centre so they line up nicely (tried this so far: Control the height in fluidRow in R shiny).

Finding some potential solutions using languages I'm not familiar with (CSS) so a little explanation would be very much appreciated :)
Thanks in advance!

答:
CSS is the way to go here, you can do a lot in very few lines of CSS. See https://shiny.rstudio.com/articles/css.html for more information on integrating CSS in R.

In the course of writing this answer I found I could simplify some of your R code. Hierarchy-wise, I'm now just using a conditionalPanel wrapping a fluidRow. I also had to write a simple for loop to generate enough rows to check the overflow problem for 2). Updated R code here:

```<code>library(shiny)

choices <- c("a", "b", "c", "d", "e", "f",
             "g", "h", "i", "j", "k")

rows <- list(8)
for (choice in choices) {
  print(choice)
  row <- conditionalPanel(
    condition = paste0("input.chr_vec.indexOf('", choice, "') !== -1"),
    fluidRow(
      span(paste0("Parameters (", choice, ")")),
      numericInput(
        inputId = "1.numeric.flip.time",
        label = "1",
        value = 50,
        min = 0,
        max = 1000
      ),

      numericInput(
        inputId = "2.numeric.start.val",
        label = "2",
        value = 99,
        min = 0,
        max = 1000
      ),

      numericInput(
        inputId = "3.numeric.end.val",
        label = "3",
        value = 100,
        min = 0,
        max = 1000
      ),

      numericInput(
        inputId = "sd.numeric.stdev",
        label = "SD",
        value = 0,
        min = 0,
        max = 1000
      )
    )
  )
  rows <- append(rows, list(row))
}

ui <- fluidPage(theme = "custom.css",
                h1("XXX"), #Main page title
                fluidRow(
                  column(
                    3,
                    wellPanel(
                      sliderInput(
                        inputId = "time.step",
                        label = "Time",
                        value = 100,
                        min = 0,
                        max = 1000
                      ),
                      numericInput(
                        inputId = "no_",
                        label = "choose number",
                        value = 8,
                        min = 1,
                        max = 10
                      ),
                      checkboxGroupInput(
                        inputId = "chr_vec",
                        label = "characters",
                        choices = choices,
                        selected = c("a", "b")
                      ),
                      #close checkboxGroupInput
                      actionButton("runbutton", "Run")
                    ) #close wellPanel
                  ),
                  #close column
                  #### Parameters ####
                  do.call(column, rows)
                ))
shinyApp(
  ui,
  server = function(input, output) {

  }
)
</code>```

I added theme = "custom.css", to your fluidPage call, and created www/custom.css with the below content:

```<code>.col-sm-8 .row .form-group,.form-control {
  display: inline-block;
  width: 100px;
}

.col-sm-8 .row span {
  width: 150px;
  display: inline-block;
}
</code>```

.col-sm-8 .row .form-group,.form-control is a CSS selector that selects your numeric inputs, those that are in the column of width 8. You can find these class names / HTML structure by right clicking on a running version of your app and going Inspect. The contents of the curly brackets {} define the styling of the selected elements. Setting display to inline-block will cause the blocks to flow horizontally. Setting the width to 100px shrinks the size of your numeric inputs considerably (default is 300px). Swapping the .form-group,.form-control selectors for span will select the row heading. I set this to 150px as that gives enough space for the string "Parameters (a)".

I've deployed this to https://nyou045.shinyapps.io/test/ so you can see a live demo

Hope that helps!

Body:
Trying to program a shiny app layout including rows and columns for inputs. Built in functions are best for simple column format. So far managed to nest a load of fluidRows to get the output in the sample code below.

Nesting fluidRow:
R Shiny - how to generate this layout with nested rows in column 2

shiny 4 small textInput boxes side-by-side

Here is a subset of my code:

ui <- fluidPage(
  h1("XXX"), #Main page title
  fluidRow(
    column(3,
           wellPanel(
             sliderInput(inputId = "time.step",
                         label = "Time",
                         value = 100, min = 0, max = 1000),
             numericInput(inputId = "no_",
                          label = "choose number",
                          value = 8, min = 1, max = 10),
             checkboxGroupInput(inputId = "chr_vec",
                                label = "characters",
                                choices = c("a", "b", "c", "d", "e", "f",
                                            "g", "h", "i", "j", "k"),
                                selected = c("a", "b")
             ), #close checkboxGroupInput
             actionButton("runbutton", "Run")
           ) #close wellPanel
    ), #close column
    #### Parameters ####
    column(8,
           fluidRow(

             conditionalPanel(
               condition = "input.chr_vec.indexOf('a') !== -1",

                    column(12,
           splitLayout("Parameters",
                     numericInput(inputId = "1.numeric.flip.time",
                                  label = "1",
                                  value = 50, min = 0, max = 1000),

                     numericInput(inputId = "2.numeric.start.val",
                                  label = "2",
                                  value = 99, min = 0, max = 1000),

                     numericInput(inputId = "3.numeric.end.val",
                                  label = "3",
                                  value = 100, min = 0, max = 1000),

                     numericInput(inputId = "sd.numeric.stdev",
                                  label = "SD",
                                  value = 0, min = 0, max = 1000)
           ) #close splitLayout
                    ) #close column
             ) #close conditionslPanel
           ), #close fluidRow

           fluidRow(
             conditionalPanel(
               condition = "input.chr_vec.indexOf('b') !== -1",
             column(12,
                    splitLayout("Parameters2",
                                numericInput(inputId = "5.numeric.flip.time",
                                             label = "5",
                                             value = 50, min = 0, max = 1000),

                                numericInput(inputId = "6.numeric.start.val",
                                             label = "6",
                                             value = 99, min = 0, max = 1000)

                    ) #close splitLayout
             ) #cose column
             ) #close conditionalPanel
           ) # close fluidRow

    ) #close column
  )
)
shinyApp(ui, server = function(input, output) { })

Things I'm trying to solve:

1) The title 'parameters' is floating oddly like a input field taking up room.

2) in the real code there are roughly a dozen rows of parameters (one row per checkbox on the left), things get real messy especially when the number of rows extends beyond the check input column (aiming for something like the image below).

3) scale and justification - would help a lot if I could scale the font and input fields of the rows of parameters down a little and ideally justify the input fields left rather than centre so they line up nicely (tried this so far: Control the height in fluidRow in R shiny).

Finding some potential solutions using languages I'm not familiar with (CSS) so a little explanation would be very much appreciated :)
Thanks in advance!

Body:
CSS is the way to go here, you can do a lot in very few lines of CSS. See https://shiny.rstudio.com/articles/css.html for more information on integrating CSS in R.

In the course of writing this answer I found I could simplify some of your R code. Hierarchy-wise, I'm now just using a conditionalPanel wrapping a fluidRow. I also had to write a simple for loop to generate enough rows to check the overflow problem for 2). Updated R code here:

library(shiny)

choices <- c("a", "b", "c", "d", "e", "f",
             "g", "h", "i", "j", "k")

rows <- list(8)
for (choice in choices) {
  print(choice)
  row <- conditionalPanel(
    condition = paste0("input.chr_vec.indexOf('", choice, "') !== -1"),
    fluidRow(
      span(paste0("Parameters (", choice, ")")),
      numericInput(
        inputId = "1.numeric.flip.time",
        label = "1",
        value = 50,
        min = 0,
        max = 1000
      ),

      numericInput(
        inputId = "2.numeric.start.val",
        label = "2",
        value = 99,
        min = 0,
        max = 1000
      ),

      numericInput(
        inputId = "3.numeric.end.val",
        label = "3",
        value = 100,
        min = 0,
        max = 1000
      ),

      numericInput(
        inputId = "sd.numeric.stdev",
        label = "SD",
        value = 0,
        min = 0,
        max = 1000
      )
    )
  )
  rows <- append(rows, list(row))
}

ui <- fluidPage(theme = "custom.css",
                h1("XXX"), #Main page title
                fluidRow(
                  column(
                    3,
                    wellPanel(
                      sliderInput(
                        inputId = "time.step",
                        label = "Time",
                        value = 100,
                        min = 0,
                        max = 1000
                      ),
                      numericInput(
                        inputId = "no_",
                        label = "choose number",
                        value = 8,
                        min = 1,
                        max = 10
                      ),
                      checkboxGroupInput(
                        inputId = "chr_vec",
                        label = "characters",
                        choices = choices,
                        selected = c("a", "b")
                      ),
                      #close checkboxGroupInput
                      actionButton("runbutton", "Run")
                    ) #close wellPanel
                  ),
                  #close column
                  #### Parameters ####
                  do.call(column, rows)
                ))
shinyApp(
  ui,
  server = function(input, output) {

  }
)

I added theme = "custom.css", to your fluidPage call, and created www/custom.css with the below content:

.col-sm-8 .row .form-group,.form-control {
  display: inline-block;
  width: 100px;
}

.col-sm-8 .row span {
  width: 150px;
  display: inline-block;
}

.col-sm-8 .row .form-group,.form-control is a CSS selector that selects your numeric inputs, those that are in the column of width 8. You can find these class names / HTML structure by right clicking on a running version of your app and going Inspect. The contents of the curly brackets {} define the styling of the selected elements. Setting display to inline-block will cause the blocks to flow horizontally. Setting the width to 100px shrinks the size of your numeric inputs considerably (default is 300px). Swapping the .form-group,.form-control selectors for span will select the row heading. I set this to 150px as that gives enough space for the string "Parameters (a)".

I've deployed this to https://nyou045.shinyapps.io/test/ so you can see a live demo

Hope that helps!


问:
JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
I want to run two deployed applications ( .ear )  in two instances of JBoss 6.0 at the same time

I have changed all used ports of both standalone.xml files including http , management-http , etc...

Like this:

application1.ear : socket-binding name="http" port="8080

  application2.ear : socket-binding name="http" port="8081

application1.ear : name="management-http" port="9990

  application2.ear : name="management-http" port="9991

Any Help is appreciated

答:
Following are the two ways to run mutliple JBoss instance on same server.

Bind each instance to a different IP address

This is the easiest and most recommended way to solve this problem. If the server has multiple NICs then this is simple. If not, then one must "multi-home" the server. In other words, assign the server more than one IP address through OS configuration. Start the instances like so:

```<code>$JBOSS_HOME1/bin/run.sh -b <ip-addr-1>
$JBOSS_HOME2/bin/run.sh -b <ip-addr-2>
</code>```

The same $JBOSS_HOME can be used with multiple "profiles" in $JBOSS_HOME/server. For example:

```<code>$JBOSS_HOME/bin/run.sh -b <ip-addr-1> -c node1
$JBOSS_HOME/bin/run.sh -b <ip-addr-2> -c node2
</code>```

Service Binding Manager

Configure the "Service Binding Manager" to tell the JBoss instances which ports to use.

Uncomment the "jboss.system:service=ServiceBindingManager" MBean in $JBOSS_HOME/server/$PROFILE/conf/jboss-service.xml.

```<code><mbean code="org.jboss.services.binding.ServiceBindingManager"
 name="jboss.system:service=ServiceBindingManager">
 <attribute name="ServerName">ports-01</attribute>
 <attribute name="StoreURL">${jboss.home.url}/docs/examples/binding-manager/sample-bindings.xml</attribute>
 <attribute name="StoreFactoryClassName">
   org.jboss.services.binding.XMLServicesStoreFactory
 </attribute>
</mbean>
</code>```

This tells JBoss to use the port numbering scheme defined by "ports-01" in $JBOSS_HOME/docs/examples/binding-manager/sample-bindings.xml. This scheme increases the second most significant digit of every port by 100. For example, the JNDI port is 1099 by default but 1199 using the ports-01 scheme; the HTTP port is 8080 by default but 8180 using the ports-01 scheme. The sample-bindings.xml file contains 4 port schemes:

ports-default

ports-01

ports-02

ports-03

You may want to configure the port set used at start up from the command line or through a system property. If so, adjust the MBean's ServerName to refer to a system property, for example:

```<code><mbean code="org.jboss.services.binding.ServiceBindingManager"
 name="jboss.system:service=ServiceBindingManager">
 <attribute name="ServerName">${jboss.service.binding.set:ports-default}</attribute>
 <attribute name="StoreURL">${jboss.home.url}/docs/examples/binding-manager/sample-bindings.xml</attribute>
 <attribute name="StoreFactoryClassName">
   org.jboss.services.binding.XMLServicesStoreFactory
 </attribute>
</mbean>
</code>```

Now change it through the following property directly on run.sh/run.bat or add it to your run.conf options:

```<code>-Djboss.service.binding.set=ports-01
</code>```

If you need more than 4 port sets defined in sample-bindings.xml by default, please refer to the following article for JBOSS 6 EAP:

https://access.redhat.com/site/solutions/237933

Body:
Following are the two ways to run mutliple JBoss instance on same server.

Bind each instance to a different IP address

This is the easiest and most recommended way to solve this problem. If the server has multiple NICs then this is simple. If not, then one must "multi-home" the server. In other words, assign the server more than one IP address through OS configuration. Start the instances like so:

$JBOSS_HOME1/bin/run.sh -b <ip-addr-1>
$JBOSS_HOME2/bin/run.sh -b <ip-addr-2>

The same $JBOSS_HOME can be used with multiple "profiles" in $JBOSS_HOME/server. For example:

$JBOSS_HOME/bin/run.sh -b <ip-addr-1> -c node1
$JBOSS_HOME/bin/run.sh -b <ip-addr-2> -c node2

Service Binding Manager

Configure the "Service Binding Manager" to tell the JBoss instances which ports to use.

Uncomment the "jboss.system:service=ServiceBindingManager" MBean in $JBOSS_HOME/server/$PROFILE/conf/jboss-service.xml.

<mbean code="org.jboss.services.binding.ServiceBindingManager"
 name="jboss.system:service=ServiceBindingManager">
 <attribute name="ServerName">ports-01</attribute>
 <attribute name="StoreURL">${jboss.home.url}/docs/examples/binding-manager/sample-bindings.xml</attribute>
 <attribute name="StoreFactoryClassName">
   org.jboss.services.binding.XMLServicesStoreFactory
 </attribute>
</mbean>

This tells JBoss to use the port numbering scheme defined by "ports-01" in $JBOSS_HOME/docs/examples/binding-manager/sample-bindings.xml. This scheme increases the second most significant digit of every port by 100. For example, the JNDI port is 1099 by default but 1199 using the ports-01 scheme; the HTTP port is 8080 by default but 8180 using the ports-01 scheme. The sample-bindings.xml file contains 4 port schemes:

ports-default

ports-01

ports-02

ports-03

You may want to configure the port set used at start up from the command line or through a system property. If so, adjust the MBean's ServerName to refer to a system property, for example:

<mbean code="org.jboss.services.binding.ServiceBindingManager"
 name="jboss.system:service=ServiceBindingManager">
 <attribute name="ServerName">${jboss.service.binding.set:ports-default}</attribute>
 <attribute name="StoreURL">${jboss.home.url}/docs/examples/binding-manager/sample-bindings.xml</attribute>
 <attribute name="StoreFactoryClassName">
   org.jboss.services.binding.XMLServicesStoreFactory
 </attribute>
</mbean>

Now change it through the following property directly on run.sh/run.bat or add it to your run.conf options:

-Djboss.service.binding.set=ports-01

If you need more than 4 port sets defined in sample-bindings.xml by default, please refer to the following article for JBOSS 6 EAP:

https://access.redhat.com/site/solutions/237933


问:
How to size content relative to screen size in scrollview for Xamarin?
I have a bunch of buttons I want to stack, but I also want them to be scrollable. How can I set the size of the buttons as a percentage of the actual screen size? I have tried star sizing on a grid layout.</p>

答:
Here you go...10 buttons programmatically added to a ScrollView with each button a percentage of the total screen width and height (50% and 20% respectively), along with a click handler...

```<code>    protected override void OnCreate(Bundle savedInstanceState) {
        base.OnCreate(savedInstanceState);

        // Get Screen Dimensions
        var dm = Resources.DisplayMetrics;
        var widthDP = dm.WidthPixels / dm.Density;
        var heightDP = dm.HeightPixels / dm.Density;
        Android.Util.Log.Info("MyApp", $"Screen Width x Screen Height = {widthDP}dp X {heightDP}dp");

        // Add 10 Buttons in a ScrollView
        var sv = new ScrollView(this);
        var ll = new LinearLayout(this) { Orientation = Android.Widget.Orientation.Vertical };
        sv.AddView(ll);

        for (int i = 0; i < 10; i++) {
            var btn = new Button(this);
            btn.SetBackgroundColor(Color.Blue);
            btn.Text = $"Button #{i+1}";
            btn.Tag = i+1;
            btn.Click += (sender, e) => {
                Android.Util.Log.Info("MyApp", $"Button # {btn.Tag} + Clicked!");
            };
            // Make each button 50% of the total screen width and 20% of the *total* screen height
            var lp = new LinearLayout.LayoutParams(Convert.ToInt32(widthDP * .50), Convert.ToInt32(heightDP * .20));
            lp.SetMargins(0, 10, 0, 0);     // Top margin of 10
            btn.LayoutParameters = lp;
            ll.AddView(btn);
        }

        SetContentView(sv);
    }
</code>```

ScreenShot

Body:
Here you go...10 buttons programmatically added to a ScrollView with each button a percentage of the total screen width and height (50% and 20% respectively), along with a click handler...

    protected override void OnCreate(Bundle savedInstanceState) {
        base.OnCreate(savedInstanceState);

        // Get Screen Dimensions
        var dm = Resources.DisplayMetrics;
        var widthDP = dm.WidthPixels / dm.Density;
        var heightDP = dm.HeightPixels / dm.Density;
        Android.Util.Log.Info("MyApp", $"Screen Width x Screen Height = {widthDP}dp X {heightDP}dp");

        // Add 10 Buttons in a ScrollView
        var sv = new ScrollView(this);
        var ll = new LinearLayout(this) { Orientation = Android.Widget.Orientation.Vertical };
        sv.AddView(ll);

        for (int i = 0; i < 10; i++) {
            var btn = new Button(this);
            btn.SetBackgroundColor(Color.Blue);
            btn.Text = $"Button #{i+1}";
            btn.Tag = i+1;
            btn.Click += (sender, e) => {
                Android.Util.Log.Info("MyApp", $"Button # {btn.Tag} + Clicked!");
            };
            // Make each button 50% of the total screen width and 20% of the *total* screen height
            var lp = new LinearLayout.LayoutParams(Convert.ToInt32(widthDP * .50), Convert.ToInt32(heightDP * .20));
            lp.SetMargins(0, 10, 0, 0);     // Top margin of 10
            btn.LayoutParameters = lp;
            ll.AddView(btn);
        }

        SetContentView(sv);
    }

ScreenShot


问:
What are some good ways to delete files with blank(invisible) names?
I discovered some files with blank names in my code repository, but I don't know how to find them all and delete them.</p>

答:
Try the followwing:

```<code>for i in [^a-zA-Z0-9]*
do
  ls -l "$i"
done
</code>```

You may need to fiddle with the globbing pattern to find just the files with bad names.
When you like what you see, you can change the ls -l to the command that removes the files.

ContentLicense: CC BY-SA 3.0

Body:
Try the followwing:

for i in [^a-zA-Z0-9]*
do
  ls -l "$i"
done

You may need to fiddle with the globbing pattern to find just the files with bad names.
When you like what you see, you can change the ls -l to the command that removes the files.


问:
Rewrite url to another domain while maintaining the last part of url
I have a question similar to this
URL rewrite for part of domain name

Tried to use that rule but it didn't work. I think the url rule could be different.

I have the url:

```<code>olddomain.com/test/ref/s/page

olddomain.com/test/ref/s/page1

olddomain.com/test/ref/s/page2
</code>```

I need to rewrite them and maintain the last part of the url, eg:

```<code>https://www.newdomain.com/test/ref/s/page

https://www.newdomain.com/test/ref/s/page1

https://www.newdomain.com/test/ref/s/page2
</code>```

Edit:
The ending of the url is dynamic so using individual redirection for each link is not practical.

Much thanks for any help.

答:
You can use your .htaccess file to do this, similar to the answer you are referencing. If you just want to send your old urls to your new urls individually, you can achieve this quite easily using the Redirect 301 function inside .htaccess, and uploading to the root of "old domain", like so:

```<code>Redirect 301 /test/ref/s/page https://www.newdomain.com/test/ref/s/page
Redirect 301 /test/ref/s/page1 https://www.newdomain.com/test/ref/s/page1
Redirect 301 /test/ref/s/page2 https://www.newdomain.com/test/ref/s/page2
</code>```

This will individually 301 the index at each of the old urls to the corresponding new url.

If you want to redirect everything from "old domain" to "new domain" just use a rewrite like so:

```<code>RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com [NC]
RewriteRule ^(.*)$ https://newdomain.com/$1 [L,R=301,NC]
</code>```

You would, of course, need to configure this depending on your use of SSL.

Body:
I have a question similar to this
URL rewrite for part of domain name

Tried to use that rule but it didn't work. I think the url rule could be different.

I have the url:

olddomain.com/test/ref/s/page

olddomain.com/test/ref/s/page1

olddomain.com/test/ref/s/page2

I need to rewrite them and maintain the last part of the url, eg:

https://www.newdomain.com/test/ref/s/page

https://www.newdomain.com/test/ref/s/page1

https://www.newdomain.com/test/ref/s/page2

Edit:
The ending of the url is dynamic so using individual redirection for each link is not practical.

Much thanks for any help.

Body:
You can use your .htaccess file to do this, similar to the answer you are referencing. If you just want to send your old urls to your new urls individually, you can achieve this quite easily using the Redirect 301 function inside .htaccess, and uploading to the root of "old domain", like so:

Redirect 301 /test/ref/s/page https://www.newdomain.com/test/ref/s/page
Redirect 301 /test/ref/s/page1 https://www.newdomain.com/test/ref/s/page1
Redirect 301 /test/ref/s/page2 https://www.newdomain.com/test/ref/s/page2

This will individually 301 the index at each of the old urls to the corresponding new url.

If you want to redirect everything from "old domain" to "new domain" just use a rewrite like so:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com [NC]
RewriteRule ^(.*)$ https://newdomain.com/$1 [L,R=301,NC]

You would, of course, need to configure this depending on your use of SSL.


问:
React Data Grid rows disappearing on dynamically providing height
I am trying to make RDG Table which can be expanded(for expansion i have used ReactGridLayout) in height & Width. I am using react-sizeme for dynamically providing height & Width to my component(in my case Example component). Now, Table is getting expanded in height & Width correctly when scrollbar in table is at top.
Below image shows Table with scrollbar at top:

If i expand table, everything will work correctly as in below image:

As soon as we bring Scrollbar somewhat in between and then expand table's height, rows are getting disappeared. These rows become visible as soon as i scroll by just a small amount in table.
For e.g. In below image, Scrollbar is in not in beginning(row6 is visible).

Now if i expand table, some rows are getting disappeared as shown in below image:

I am unable to understand why rows are getting disappeared on expansion when scrollbar is not in beginning.

CodeSandbox Link: https://codesandbox.io/embed/rdg-optimising-scrolling-n6xpj

Edit: Table contains 199 rows currently.

答:
I think no need to change the state for just to make DOM refresh.
you can do it by generating a new key to wrapper div of RDG.

```<code><div key={Math.random()}>
  <ReactDataGrid
    columns={this.state.columns}
    rowGetter={this.rowGetter}
    rowsCount={this.state.rows.length}
    minHeight={height}
    onScroll={this.onScroll}
  />
</div>
</code>```

Try this.

Body:
I think no need to change the state for just to make DOM refresh.
you can do it by generating a new key to wrapper div of RDG.

<div key={Math.random()}>
  <ReactDataGrid
    columns={this.state.columns}
    rowGetter={this.rowGetter}
    rowsCount={this.state.rows.length}
    minHeight={height}
    onScroll={this.onScroll}
  />
</div>

Try this.


问:
I am trying to write a class object that performs manipulation of an image
I believe I have most of the code correct until I get to last line of code. My first time writing a class method. Not sure how specify image location.

Not sure how to proceed

from PIL import Image

class image_play(object):
    def __init__(self, im_name):
        self.im_name = im_name

    def rgb_to_gray_image(self):
        im = Image.open(self.im_name)
        im = im.convert('LA')
        return im

    # editing pixels of image to white
    def loop_over_image(self):
        im = Image.open(self.im_name)
        width, height = im.size
        # nested loop over all pixels of image
        temp = []
        for i in range(width):
            for j in range(height):
                temp.append((255,255,255))#append a tuple for the RGB channel values for each pixel

        image_out = Image.new(im.mode,im.size) #create a new image usig PIl
        image_out.putdata(temp) #use the temp list to create the image
        return image_out

obj = image_play()
```

```TypeError                                 Traceback (most recent call last)
<ipython-input-8-d6175b134ccc> in <module>
     25         return image_out
     26
---> 27 obj = image_play()

TypeError: __init__() missing 1 required positional argument: 'im_name'
```

答:
I added the following code and now all is well.</p>

```<code>pic = image_play('test.png')
picGray = pic.rgb_to_gray_image()
picGray.show()
picWhite = pic.loop_over_image()
picWhite.show()
</code>```

Body:
I believe I have most of the code correct until I get to last line of code. My first time writing a class method. Not sure how specify image location.

Not sure how to proceed

from PIL import Image

class image_play(object):
    def __init__(self, im_name):
        self.im_name = im_name

    def rgb_to_gray_image(self):
        im = Image.open(self.im_name)
        im = im.convert('LA')
        return im

    # editing pixels of image to white
    def loop_over_image(self):
        im = Image.open(self.im_name)
        width, height = im.size
        # nested loop over all pixels of image
        temp = []
        for i in range(width):
            for j in range(height):
                temp.append((255,255,255))#append a tuple for the RGB channel values for each pixel

        image_out = Image.new(im.mode,im.size) #create a new image usig PIl
        image_out.putdata(temp) #use the temp list to create the image
        return image_out

obj = image_play()

TypeError                                 Traceback (most recent call last)
<ipython-input-8-d6175b134ccc> in <module>
     25         return image_out
     26
---> 27 obj = image_play()

TypeError: __init__() missing 1 required positional argument: 'im_name'

Body:
I added the following code and now all is well.

pic = image_play('test.png')
picGray = pic.rgb_to_gray_image()
picGray.show()
picWhite = pic.loop_over_image()
picWhite.show()


问:
CSS Styling not working in external file using background-image
I'm using media queries so I am passing the image to the html page from the external css file but the styling only works if I call the image directly from the html file but not from the external css file.

```<code>HTML code:
<img id="photo" class="photo-frame">

External css code:
#photo {
    background: url('/images/example-photo.jpg') no-repeat;
    width: 200px;
    height: 200px;
}

.photo-frame {
    float: left;
    padding: 10px 10px 30px 10px;
    background-color: #fff !important;
    box-shadow: 2px 2px 3px #aaa;
    transform: rotate(7deg);
    -moz-transform: rotate(7deg);
    -webkit-transform: rotate(7deg);
    -o-transform: rotate(7deg);
    -ms-transform: rotate(7deg);
}
</code>```

So this is to make the photo look like a polaroid photo tilted to one side, the problem I get is the border is not showing white but just a line showing where the border starts. It works okay when I reference the photo from the HTML page and call the photo-frame class but not when I apply an id and pass over the image externally.

答: Try to remove th !important property from background-color of photo-frame class and add !important to background  property of #photo in external css and also use div tag instead of image tag.

Body:
I'm using media queries so I am passing the image to the html page from the external css file but the styling only works if I call the image directly from the html file but not from the external css file.

HTML code:

External css code:
#photo {
    background: url('/images/example-photo.jpg') no-repeat;
    width: 200px;
    height: 200px;
}

.photo-frame {
    float: left;
    padding: 10px 10px 30px 10px;
    background-color: #fff !important;
    box-shadow: 2px 2px 3px #aaa;
    transform: rotate(7deg);
    -moz-transform: rotate(7deg);
    -webkit-transform: rotate(7deg);
    -o-transform: rotate(7deg);
    -ms-transform: rotate(7deg);
}

So this is to make the photo look like a polaroid photo tilted to one side, the problem I get is the border is not showing white but just a line showing where the border starts. It works okay when I reference the photo from the HTML page and call the photo-frame class but not when I apply an id and pass over the image externally.


问:
How to reference other collections in postman
Is there a way to reference other collections from a specific collection. For example, if I have a file upload collection (something that uploads a file), I want to be able to use that from other collections. How would I reference the file upload?

Here's an example of what I'm talking about.

I have a collection where a file is uploaded and a calculation needs to be performed. The test or collection would go something like this where each step is a POST, GET, etc

Upload and run calculation:

Generate a token

make call

copy/save token value

Upload specific file (these would be 3 individual requests)

Upload file

Monitor upload status

Return ID of file uploaded

run calculation

use ID to pass as parameter

pass other values to set up calculation

monitor run

validate results

In another collection I need to validate uploaded files metadata is correct. Not directly related to the one above, but has some similarities

Generate a token

make call

copy/save token value

Upload specific file (these would be 3 individual requests)

Upload file

Monitor upload status

Get final result and return ID of file uploaded

Get me

validate metadata is correct.

Steps 1 and 2 are common functionality, there would be no difference there. How could I extract those two steps as modular components or functionality so I can reference them from any collection?

For additional clarity, we use ReadyAPI and are able to do 'Run Test Case' which can obviously run another test case. We've separated the functionality of token and file uploads into it's own test case and use it as a modular component. I'd like to achieve something similar with Postman.

答:
Unfortunately Postman collections are working a little bit different.

But you can Merge your two collections to a single one, and execute it as one single collections.


问:
Adaptive Card returns undefined in Microsoft Teams but works well in bot emulator
I've created bot that will return an adaptive card when i type a certain command. I've tested it on Bot Framework Emulator and it shows the card.

But when i tested it on Microsoft Teams, it returns undefined :

Bot Framework Emulator

Microsoft Teams

App.js

```<code>require('dotenv-extended').load();

var util = require('util');
var builder = require('botbuilder');
var restify = require('restify');

// Setup Restify Server
var server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () {
    console.log('%s listening to %s', server.name, server.url);
});

// Create chat bot and listen to messages
var connector = new builder.ChatConnector({
    appId: process.env.MICROSOFT_APP_ID,
    appPassword: process.env.MICROSOFT_APP_PASSWORD
});
server.post('/api/messages', connector.listen());

var inMemoryStorage = new builder.MemoryBotStorage();

var bot = new builder.UniversalBot(connector, function (session) {

    if (session.message && session.message.value) {
        // A Card's Submit Action obj was received
        processSubmitAction(session, session.message.value);
        return;
    }
}).set('storage', inMemoryStorage); // Register in memory storage

// Help
bot.dialog('support', require('./support'))
    .triggerAction({
        matches: [/help/i, /support/i, /problem/i]
    });

// log any bot errors into the console
bot.on('error', function (e) {
    console.log('And error ocurred', e);
});

function processSubmitAction(session, value) {
    var defaultErrorMessage = 'Please complete all the field';
    switch (value.type){
        case 'support':
            session.send("Issue Created");
            break;
        default:
            session.send(defaultErrorMessage);
    }
}
</code>```

Support.js

```<code>var builder = require('botbuilder');
module.exports = function (session) {
    var msg = new builder.Message(session)
    .addAttachment({
        contentType: "application/vnd.microsoft.card.adaptive",
        content: {
            type: "AdaptiveCard",
            speak: "<s>Your  meeting about \"Adaptive Card design session\"<break strength='weak'/> is starting at 12:30pm</s><s>Do you want to snooze <break strength='weak'/> or do you want to send a late notification to the attendees?</s>",
               body: [
                {
                    "type": "ColumnSet",
                    "columns": [
                        {
                            "type": "Column",
                            "items": [
                                {
                                    "type": "TextBlock",
                                    "weight": "Bolder",
                                    "text": "Title",
                                    "wrap": true
                                },
                                {
                                    "type": "Input.Text",
                                    "id": "issueName",
                                    "placeholder": "Issue Title"
                                },
                                {
                                    "type": "TextBlock",
                                    "weight": "Bolder",
                                    "text": "Description",
                                    "wrap": true
                                },
                                {
                                    "type": "Input.Text",
                                    "id": "issueDescription",
                                    "placeholder": "Issue Description",
                                    "style": "Email"
                                },
                                {
                                    "type": "TextBlock",
                                    "weight": "Bolder",
                                    "text": "Issue Type"
                                },
                                {
                                    "type": "Input.ChoiceSet",
                                    "id": "issueType",
                                    "placeholder": "Placeholder text",
                                    "choices": [
                                        {
                                            "title": "Bug",
                                            "value": "Bug"
                                        },
                                        {
                                            "title": "Task",
                                            "value": "Task"
                                        },
                                        {
                                            "title": "Improvement",
                                            "value": "Improvement"
                                        },
                                        {
                                            "title": "New Feature",
                                            "value": "New Feature"
                                        }
                                    ],
                                    "style": "expanded"
                                },
                                {
                                    "type": "TextBlock",
                                    "weight": "Bolder",
                                    "text": "Assignee"
                                },
                                {
                                    "type": "Input.Text",
                                    "id": "issueAssignee",
                                    "placeholder": "Assigne Username"
                                }
                            ],
                            "width": 2
                        }
                    ]
                }
            ],
            "actions": [
                {
                    "type": "Action.Submit",
                    "id": "submitBtn",
                    "title": "Submit",
                    "data":{
                        "type":"support"
                    }
                }
            ]
        }
    });
session.send(msg);
session.endDialog();
};
</code>```

Can you tell me where did i do wrong ? Thanks before.

答:
I've changed the code in support.js to :

```<code>var builder = require('botbuilder');
module.exports = function (session) {
    // var customMessage = new builder.Message(session)
    // .text("Hello!")
    // .textFormat("plain")
    // .textLocale("en-us");
    var card = {
        'contentType': 'application/vnd.microsoft.card.adaptive',
        'content': {
            "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
            "type": "AdaptiveCard",
            "version": "1.0",
            "body": [
                        {
                            "type": "ColumnSet",
                            "columns": [
                                {
                                    "type": "Column",
                                    "items": [
                                        {
                                            "type": "TextBlock",
                                            "weight": "Bolder",
                                            "text": "Title",
                                            "wrap": true
                                        },
                                        {
                                            "type": "Input.Text",
                                            "id": "issueName",
                                            "placeholder": "Issue Title"
                                        },
                                        {
                                            "type": "TextBlock",
                                            "weight": "Bolder",
                                            "text": "Description",
                                            "wrap": true
                                        },
                                        {
                                            "type": "Input.Text",
                                            "id": "issueDescription",
                                            "placeholder": "Issue Description",
                                            "style": "Email"
                                        },
                                        {
                                            "type": "TextBlock",
                                            "weight": "Bolder",
                                            "text": "Issue Type"
                                        },
                                        {
                                            "type": "Input.ChoiceSet",
                                            "id": "issueType",
                                            "placeholder": "Placeholder text",
                                            "choices": [
                                                {
                                                    "title": "Bug",
                                                    "value": "Bug"
                                                },
                                                {
                                                    "title": "Task",
                                                    "value": "Task"
                                                },
                                                {
                                                    "title": "Improvement",
                                                    "value": "Improvement"
                                                },
                                                {
                                                    "title": "New Feature",
                                                    "value": "New Feature"
                                                }
                                            ],
                                            "style": "expanded"
                                        },
                                        {
                                            "type": "TextBlock",
                                            "weight": "Bolder",
                                            "text": "Assignee"
                                        },
                                        {
                                            "type": "Input.Text",
                                            "id": "issueAssignee",
                                            "placeholder": "Assigne Username"
                                        }
                                    ],
                                    "width": 2
                                }
                            ]
                        }
                    ],
                    "actions": [
                        {
                            "type": "Action.Submit",
                            "id": "submitBtn",
                            "title": "Submit",
                            "data":{
                                "type":"support"
                            }
                        }
                    ]
                }
    };
    var customMessage = new builder.Message(session)
            .addAttachment(card);
// console.log(session);
session.send(customMessage);
session.endDialog();
};
</code>```

and it's working now

Body:
I've created bot that will return an adaptive card when i type a certain command. I've tested it on Bot Framework Emulator and it shows the card.

But when i tested it on Microsoft Teams, it returns undefined :

Bot Framework Emulator

Microsoft Teams

App.js

require('dotenv-extended').load();

var util = require('util');
var builder = require('botbuilder');
var restify = require('restify');

// Setup Restify Server
var server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () {
    console.log('%s listening to %s', server.name, server.url);
});

// Create chat bot and listen to messages
var connector = new builder.ChatConnector({
    appId: process.env.MICROSOFT_APP_ID,
    appPassword: process.env.MICROSOFT_APP_PASSWORD
});
server.post('/api/messages', connector.listen());

var inMemoryStorage = new builder.MemoryBotStorage();

var bot = new builder.UniversalBot(connector, function (session) {

    if (session.message && session.message.value) {
        // A Card's Submit Action obj was received
        processSubmitAction(session, session.message.value);
        return;
    }
}).set('storage', inMemoryStorage); // Register in memory storage

// Help
bot.dialog('support', require('./support'))
    .triggerAction({
        matches: [/help/i, /support/i, /problem/i]
    });

// log any bot errors into the console
bot.on('error', function (e) {
    console.log('And error ocurred', e);
});

function processSubmitAction(session, value) {
    var defaultErrorMessage = 'Please complete all the field';
    switch (value.type){
        case 'support':
            session.send("Issue Created");
            break;
        default:
            session.send(defaultErrorMessage);
    }
}

Support.js

var builder = require('botbuilder');
module.exports = function (session) {
    var msg = new builder.Message(session)
    .addAttachment({
        contentType: "application/vnd.microsoft.card.adaptive",
        content: {
            type: "AdaptiveCard",
            speak: "<s>Your  meeting about \"Adaptive Card design session\"<break strength='weak'/> is starting at 12:30pm</s><s>Do you want to snooze <break strength='weak'/> or do you want to send a late notification to the attendees?</s>",
               body: [
                {
                    "type": "ColumnSet",
                    "columns": [
                        {
                            "type": "Column",
                            "items": [
                                {
                                    "type": "TextBlock",
                                    "weight": "Bolder",
                                    "text": "Title",
                                    "wrap": true
                                },
                                {
                                    "type": "Input.Text",
                                    "id": "issueName",
                                    "placeholder": "Issue Title"
                                },
                                {
                                    "type": "TextBlock",
                                    "weight": "Bolder",
                                    "text": "Description",
                                    "wrap": true
                                },
                                {
                                    "type": "Input.Text",
                                    "id": "issueDescription",
                                    "placeholder": "Issue Description",
                                    "style": "Email"
                                },
                                {
                                    "type": "TextBlock",
                                    "weight": "Bolder",
                                    "text": "Issue Type"
                                },
                                {
                                    "type": "Input.ChoiceSet",
                                    "id": "issueType",
                                    "placeholder": "Placeholder text",
                                    "choices": [
                                        {
                                            "title": "Bug",
                                            "value": "Bug"
                                        },
                                        {
                                            "title": "Task",
                                            "value": "Task"
                                        },
                                        {
                                            "title": "Improvement",
                                            "value": "Improvement"
                                        },
                                        {
                                            "title": "New Feature",
                                            "value": "New Feature"
                                        }
                                    ],
                                    "style": "expanded"
                                },
                                {
                                    "type": "TextBlock",
                                    "weight": "Bolder",
                                    "text": "Assignee"
                                },
                                {
                                    "type": "Input.Text",
                                    "id": "issueAssignee",
                                    "placeholder": "Assigne Username"
                                }
                            ],
                            "width": 2
                        }
                    ]
                }
            ],
            "actions": [
                {
                    "type": "Action.Submit",
                    "id": "submitBtn",
                    "title": "Submit",
                    "data":{
                        "type":"support"
                    }
                }
            ]
        }
    });
session.send(msg);
session.endDialog();
};

Can you tell me where did i do wrong ? Thanks before.

Body:
I've changed the code in support.js to :

var builder = require('botbuilder');
module.exports = function (session) {
    // var customMessage = new builder.Message(session)
    // .text("Hello!")
    // .textFormat("plain")
    // .textLocale("en-us");
    var card = {
        'contentType': 'application/vnd.microsoft.card.adaptive',
        'content': {
            "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
            "type": "AdaptiveCard",
            "version": "1.0",
            "body": [
                        {
                            "type": "ColumnSet",
                            "columns": [
                                {
                                    "type": "Column",
                                    "items": [
                                        {
                                            "type": "TextBlock",
                                            "weight": "Bolder",
                                            "text": "Title",
                                            "wrap": true
                                        },
                                        {
                                            "type": "Input.Text",
                                            "id": "issueName",
                                            "placeholder": "Issue Title"
                                        },
                                        {
                                            "type": "TextBlock",
                                            "weight": "Bolder",
                                            "text": "Description",
                                            "wrap": true
                                        },
                                        {
                                            "type": "Input.Text",
                                            "id": "issueDescription",
                                            "placeholder": "Issue Description",
                                            "style": "Email"
                                        },
                                        {
                                            "type": "TextBlock",
                                            "weight": "Bolder",
                                            "text": "Issue Type"
                                        },
                                        {
                                            "type": "Input.ChoiceSet",
                                            "id": "issueType",
                                            "placeholder": "Placeholder text",
                                            "choices": [
                                                {
                                                    "title": "Bug",
                                                    "value": "Bug"
                                                },
                                                {
                                                    "title": "Task",
                                                    "value": "Task"
                                                },
                                                {
                                                    "title": "Improvement",
                                                    "value": "Improvement"
                                                },
                                                {
                                                    "title": "New Feature",
                                                    "value": "New Feature"
                                                }
                                            ],
                                            "style": "expanded"
                                        },
                                        {
                                            "type": "TextBlock",
                                            "weight": "Bolder",
                                            "text": "Assignee"
                                        },
                                        {
                                            "type": "Input.Text",
                                            "id": "issueAssignee",
                                            "placeholder": "Assigne Username"
                                        }
                                    ],
                                    "width": 2
                                }
                            ]
                        }
                    ],
                    "actions": [
                        {
                            "type": "Action.Submit",
                            "id": "submitBtn",
                            "title": "Submit",
                            "data":{
                                "type":"support"
                            }
                        }
                    ]
                }
    };
    var customMessage = new builder.Message(session)
            .addAttachment(card);
// console.log(session);
session.send(customMessage);
session.endDialog();
};

and it's working now


问:
SweetAlerts - Load Once
I am wondering if there is a way to load a SweetAlert ONCE, with a cookie. I have tried multiple methods and they have not worked mostly because I am a newbie. Here is my code without the cookies...

--

<link rel="stylesheet" type="text/css" href="dist/sweetalert.css">
#test

```

(The code above will not work if you run the snippet as the files pertaining to SweetAlerts are hosted on my own site)

答:
You can use local storage property of the window

Local storage alert item value is 0 then show sweet-alert

```<code><link href="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/7.33.1/sweetalert2.css" rel="stylesheet" type="text/css">
<script src="https://code.jquery.com/jquery-3.4.1.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/7.33.1/sweetalert2.js"></script>

<script>
    $(document).ready(function(){

        var swal_alert = localStorage.getItem("alert");

        if(swal_alert != 1){
            swal({
                title: "District Closed",
                text: "Severe snow is causing major accidents and is unsafe for our students and staff. The district is closed including schools & offices, updates will be posted here. This popup closes fifteen (15) seconds after loading the page or clicking the status button.",
                timer: 15000,
                type: "error",
                showConfirmButton: false
            });
        }

        localStorage.setItem("alert", "1");

    });

</script>
</code>```

Title: SweetAlerts - Load Once

Body:
I am wondering if there is a way to load a SweetAlert ONCE, with a cookie. I have tried multiple methods and they have not worked mostly because I am a newbie. Here is my code without the cookies...

--

<link rel="stylesheet" type="text/css" href="dist/sweetalert.css">
#test

(The code above will not work if you run the snippet as the files pertaining to SweetAlerts are hosted on my own site)

Body:
You can use local storage property of the window

Local storage alert item value is 0 then show sweet-alert

<link href="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/7.33.1/sweetalert2.css" rel="stylesheet" type="text/css">
<script src="https://code.jquery.com/jquery-3.4.1.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/7.33.1/sweetalert2.js"></script>

<script>
    $(document).ready(function(){

        var swal_alert = localStorage.getItem("alert");

        if(swal_alert != 1){
            swal({
                title: "District Closed",
                text: "Severe snow is causing major accidents and is unsafe for our students and staff. The district is closed including schools & offices, updates will be posted here. This popup closes fifteen (15) seconds after loading the page or clicking the status button.",
                timer: 15000,
                type: "error",
                showConfirmButton: false
            });
        }

        localStorage.setItem("alert", "1");

    });

</script>


问:
Clustering some graph form matrix
A few questions on stackoverflow mention similar problem, but...

I have a square matrix, for example like this:

```<code>  |  A  |  B  |  C  |  D
A |  1  |  1  |  0  |  0
B |  1  |  1  |  1  |  0
C |  0  |  1  |  1  |  0
D |  0  |  0  |  0  |  1
</code>```

The square matrix can be of any size (can be 1000x1000 or larger). I want to get clusters (I don't know how many...). For the above example I should get two clusters:

A, B, C (because A-B and B-C)

D

答:
The example you gave is a classic clique detection, well studied in graph theory with several algorithms. It gets more interesting when you allow some edges to be missing. This will lead to modularity etc.

What you have is an unweighted adjacency matrix. There are clustering algorithms that work on this - affinity propagation needs an affinity, and hierarchical agglomerative clustering can be implemented with similarities (beware, most implementations use distances)

In your case, you can trivially use 1-X as distance matrix for many many clustering algorithm except k-means and GMM and a few other exceptions that require a coordinate matrix.

Title: Clustering some graph form matrix

Body:
A few questions on stackoverflow mention similar problem, but...

I have a square matrix, for example like this:

  |  A  |  B  |  C  |  D
A |  1  |  1  |  0  |  0
B |  1  |  1  |  1  |  0
C |  0  |  1  |  1  |  0
D |  0  |  0  |  0  |  1

The square matrix can be of any size (can be 1000x1000 or larger). I want to get clusters (I don't know how many...). For the above example I should get two clusters:

A, B, C (because A-B and B-C)

D


问:
Why is my code only outputting the answers for the 1st and last inputs?
Here, I am supposed to calculate the numerical value of a letter. I am able to calculate it, but when I enter 3 different inputs, I only receive the 1st and the last.

I have tried using different letters, I don't really know what to try, as I'm pretty new to Python.

```<code>line1 = ["A","B","C"]
list1 = []
for i in line1:
  if i == "A":
    list1.append(1)
else:
  if i == "B":
    list1.append(2)
  else:
    if i == "C":
      list1.append(3)
    else:
      if i == "D":
        list1.append(4)
      else:
        if i == "E":
          list1.append(5)
        else:
          if i == "F":
            list1.append(6)
          else:
            if i == "G":
              list1.append(7)
            else:
              if i == "H":
                list1.append(8)
              else:
                if i == "I":
                  list1.append(9)
                else:
                  if i == "J":
                    list1.append(10)
                  else:
                    if i == "K":
                      list1.append(11)
                    else:
                      if i == "L":
                        list1.append(12)
                      else:
                        if i == "M":
                          list1.append(13)
                        else:
                          if i == "N":
                            list1.append(14)
                          else:
                            if i == "O":
                              list1.append(15)
                            else:
                              if i == "P":
                                list1.append(16)
                              else:
                                if i == "Q":
                                  list1.append(17)
                                else:
                                  if i == "R":
                                    list1.append(18)
                                  else:
                                    if i == "S":
                                      list1.append(19)
                                    else:
                                      if i == "T":
                                        list1.append(20)
                                      else:
                                        if i == "U":
                                          list1.append(21)
                                        else:
                                          if i == "V":
                                            list1.append(22)
                                          else:
                                            if i == "W":
                                              list1.append(23)
                                            else:
                                              if i == "X":
                                                list1.append(24)
                                              else:
                                                if i == "Y":
                                                  list1.append(25)
                                                else:
                                                  if i == "Z":
                                                    list1.append(26)

print(list1)
</code>```

I expect my output to be 1, 2, and 3 as I am inputting "A", "B", "C"

答:
```<code>line1 = ["A","B","C"]
list1 = [ ord(i) - 64 for i in line1]
print(list1)
</code>```

Is probably a better way to do it.

To answer your question, looking at your code, the first else statement appears outside of the for loop, so only when you exit the for loop will you go inside the else statement, since the last element of line1 is not 'A'.
You should be very careful about indentation in Python.

Body:
Here, I am supposed to calculate the numerical value of a letter. I am able to calculate it, but when I enter 3 different inputs, I only receive the 1st and the last.

I have tried using different letters, I don't really know what to try, as I'm pretty new to Python.

line1 = ["A","B","C"]
list1 = []
for i in line1:
  if i == "A":
    list1.append(1)
else:
  if i == "B":
    list1.append(2)
  else:
    if i == "C":
      list1.append(3)
    else:
      if i == "D":
        list1.append(4)
      else:
        if i == "E":
          list1.append(5)
        else:
          if i == "F":
            list1.append(6)
          else:
            if i == "G":
              list1.append(7)
            else:
              if i == "H":
                list1.append(8)
              else:
                if i == "I":
                  list1.append(9)
                else:
                  if i == "J":
                    list1.append(10)
                  else:
                    if i == "K":
                      list1.append(11)
                    else:
                      if i == "L":
                        list1.append(12)
                      else:
                        if i == "M":
                          list1.append(13)
                        else:
                          if i == "N":
                            list1.append(14)
                          else:
                            if i == "O":
                              list1.append(15)
                            else:
                              if i == "P":
                                list1.append(16)
                              else:
                                if i == "Q":
                                  list1.append(17)
                                else:
                                  if i == "R":
                                    list1.append(18)
                                  else:
                                    if i == "S":
                                      list1.append(19)
                                    else:
                                      if i == "T":
                                        list1.append(20)
                                      else:
                                        if i == "U":
                                          list1.append(21)
                                        else:
                                          if i == "V":
                                            list1.append(22)
                                          else:
                                            if i == "W":
                                              list1.append(23)
                                            else:
                                              if i == "X":
                                                list1.append(24)
                                              else:
                                                if i == "Y":
                                                  list1.append(25)
                                                else:
                                                  if i == "Z":
                                                    list1.append(26)

print(list1)

I expect my output to be 1, 2, and 3 as I am inputting "A", "B", "C"

Body:
line1 = ["A","B","C"]
list1 = [ ord(i) - 64 for i in line1]
print(list1)

Is probably a better way to do it.

To answer your question, looking at your code, the first else statement appears outside of the for loop, so only when you exit the for loop will you go inside the else statement, since the last element of line1 is not 'A'.
You should be very careful about indentation in Python.


问:
How to check if all array values are blank in Javascript
I have an array like:

```<code>["", "", "", "1", "", ""]
</code>```

I want to alert when all the array values are blanks, i.e, when the array is like this:

```<code>["", "", "", "", "", ""]
</code>```

How can I achieve this.

答:
```<code>var arr1 = ["", "", "", "1", "", ""];
var arr2 = ["", "", "", "", "", ""];

function checkArrValEmpty(arr) {
  let count = 0;
  for(let i = 0; i < arr.length; i++) {
    if(arr[i].trim().length === 0) {`enter code here`
      count++;
    }
  }
  return count === arr.length
}

console.log(checkArrValEmpty(arr2));
console.log(checkArrValEmpty(arr1));
</code>```

Body:
I have an array like:

["", "", "", "1", "", ""]

I want to alert when all the array values are blanks, i.e, when the array is like this:

["", "", "", "", "", ""]

How can I achieve this.


问:
How can I disable save password popup in Selenium?
I am using Selenium version 3.141.59 for Java and I would like to disable password popup while initializing the driver for Chrome and Firefox.

I am using the Options syntax since the DesiredCapabilities alternative is now deprecated. My code look like this, but it is not working:

Firefox

FirefoxOptions options = new FirefoxOptions();
options.addPreference("signon.rememberSignons", false);
webDriver = new FirefoxDriver(options);
```

<ul>
<li>Chrome</li>
</ul>

<pre class="lang-java prettyprint-override"><code>ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setExperimentalOption("credentials_enable_service", false);
chromeOptions.setExperimentalOption("profile.password_manager_enabled", false);
webDriver = new ChromeDriver(chromeOptions);
</code>```

How can I add that option to the options object before creating the driver?

答:
Below are java code, which worked for me. I am using selenium 3.3.1 with selenium-chrome-driver 3.3.1 and Java 8.</p>

```<code>ChromeOptions options = new ChromeOptions();
options.addArguments("--start-maximized");
options.addArguments("--disable-web-security");
options.addArguments("--no-proxy-server");

Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("credentials_enable_service", false);
prefs.put("profile.password_manager_enabled", false);

options.setExperimentalOption("prefs", prefs);
</code>```

Body:
I am using Selenium version 3.141.59 for Java and I would like to disable password popup while initializing the driver for Chrome and Firefox.

I am using the Options syntax since the DesiredCapabilities alternative is now deprecated. My code look like this, but it is not working:

Firefox

FirefoxOptions options = new FirefoxOptions();
options.addPreference("signon.rememberSignons", false);
webDriver = new FirefoxDriver(options);

Chrome

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setExperimentalOption("credentials_enable_service", false);
chromeOptions.setExperimentalOption("profile.password_manager_enabled", false);
webDriver = new ChromeDriver(chromeOptions);

How can I add that option to the options object before creating the driver?

Body:
Below are java code, which worked for me. I am using selenium 3.3.1 with selenium-chrome-driver 3.3.1 and Java 8.

ChromeOptions options = new ChromeOptions();
options.addArguments("--start-maximized");
options.addArguments("--disable-web-security");
options.addArguments("--no-proxy-server");

Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("credentials_enable_service", false);
prefs.put("profile.password_manager_enabled", false);

options.setExperimentalOption("prefs", prefs);


问:
snippet for creating object from destructured array
For example, I had an array with 3 numbers:

```<code>var arr = [124, -50, 24];
</code>```

and I need to convert this array to the object:

```<code>{
   x: 124,
   y: -50,
   z: 24
}
</code>```

I don`t want to use "old-style" syntax for this, for example:

```<code>{
  x: arr[0],
  y: arr[1],
  z: arr[2]
}
</code>```

so for now, I`m using that syntax:

```<code>const [x, y, z] = [...arr];
const obj = {x, y, z};
</code>```

But, is there is any way to do this with a straight dectructuring array to object without need of temporary variables?

答:
Just use this</p>

```<code>let obj = {...arr}
</code>```

Body:
For example, I had an array with 3 numbers:

var arr = [124, -50, 24];

and I need to convert this array to the object:

{
   x: 124,
   y: -50,
   z: 24
}

I don`t want to use "old-style" syntax for this, for example:

{
  x: arr[0],
  y: arr[1],
  z: arr[2]
}

so for now, I`m using that syntax:

const [x, y, z] = [...arr];
const obj = {x, y, z};

But, is there is any way to do this with a straight dectructuring array to object without need of temporary variables?

Body:
Just use this

let obj = {...arr}