问:
How to verify data changed from String to image in C# Tuple / selenium specflow
I'm trying to verify if Image element is displayed which used to be a string element
(C# Selenium using specflow scenario outline Examples).

My apologies that my knowledge of coding is very minimal so my explanation might be not clear but I'll do my best. Sorry it's quite complicated to explain but it might not be that complicate.

Specflow scenario outline Examples:

```<code>//Image column used to fall under Condition when it was string, I've Image column for svg but not sure if I can do that to non-string value

Then I verify "<Name>" with "<Condition>" "<Image>"row is displayed
Examples:
| Name | Condition |  Image |
| Jim  |           |  svg   |
| Jo   |      A    |        |
</code>```

Step Definition:

```<code>Then(@"I verify ""(.*)"" with ""(.*)"" ""(.*)""row is displayed")]
//I've added bool image
        public void ThenIVerifyNameWithRowIsDisplayed(string name, string condition, bool image)
        {
//Added "image" in the existing code
var actualNameDetails = _myPage.GetABC_ByXYZ(name, condition, image);
//This is existing code, Item2 is condition
var actualTag = actualNameDetails.Item2;
//I've added isImageDisplayed, Item3 is Image
var imageDisplayed = actualNameDetails.Item3;

switch (condition)
     {
  case "Image":
      {
       //When it was String
       _context.verify.AreEqual("svg", actualTag, $"Expected svg is displayed");
       //Now I need to update to verify if image exists
       _context.verify.IsTrue(image, imageDisplayed);
       break;
      }
</code>```

Page Object:

```<code>//I've added bool as Item3 and bool isImageDisplayed
public Tuple <string, string, bool> GetABC_ByXYZ(string id, string condition, bool image)
 {
  //the below is used for different condition tags, I didn’t add, this is existing
  string tag = null;
  //I've added bool isImageDisplayed
 bool isImageDisplayed= IsElementDisplayed(By.XPath($"/div..........div/*[local-name()='svg']"));

 //tag
    if (condition == "A")
         {
            tag = GetText(By.XPath($"/div............));
         }
//My condition used to fit in else but not anymore since I've added Image column, what do I do with this else if?
    else if (condition != "" && condition != "A")
         {
            //When element was String
            //tag = GetText(By.XPath($"/div.............."));
            //Now String is changed to svg, I need to update to validate the svg exists. Updated elementID to svg but need to get rid of GetText
           //tag = GetText(By.XPath($"/div........div/*[local-name()='svg']"));
          }
            return Tuple.Create(Name, tag, isImageDisplayed);

</code>```

答:
First of all, if the image has a unique src attribute you can just try to find it in the webpage:

```<code>img[id='TheImageID'][src='TheImageSrc']
</code>```

If you don't know the src attribute value, or that it may change very often - you can take real screen shot of the screen or the element using Selnium:

```<code>Screenshot ss = ((ITakesScreenshot)driver).GetScreenshot();
        ss.SaveAsFile("C://Image.png",
        ScreenshotImageFormat.Png);
</code>```

You may also take a screenshot of a specific element:

```<code> var img = GetElementScreenShot(driver, element);
                    img.Save("test.png", System.Drawing.Imaging.ImageFormat.Png);
</code>```

After saving the images - you can take more images and compare them to the baseline valid image.

Body:
I'm trying to verify if Image element is displayed which used to be a string element
(C# Selenium using specflow scenario outline Examples).

My apologies that my knowledge of coding is very minimal so my explanation might be not clear but I'll do my best. Sorry it's quite complicated to explain but it might not be that complicate.

Specflow scenario outline Examples:

//Image column used to fall under Condition when it was string, I've Image column for svg but not sure if I can do that to non-string value

Then I verify "<Name>" with "<Condition>" "<Image>"row is displayed
Examples:
| Name | Condition |  Image |
| Jim  |           |  svg   |
| Jo   |      A    |        |

Step Definition:

Then(@"I verify ""(.*)"" with ""(.*)"" ""(.*)""row is displayed")]
//I've added bool image
        public void ThenIVerifyNameWithRowIsDisplayed(string name, string condition, bool image)
        {
//Added "image" in the existing code
var actualNameDetails = _myPage.GetABC_ByXYZ(name, condition, image);
//This is existing code, Item2 is condition
var actualTag = actualNameDetails.Item2;
//I've added isImageDisplayed, Item3 is Image
var imageDisplayed = actualNameDetails.Item3;

switch (condition)
     {
  case "Image":
      {
       //When it was String
       _context.verify.AreEqual("svg", actualTag, $"Expected svg is displayed");
       //Now I need to update to verify if image exists
       _context.verify.IsTrue(image, imageDisplayed);
       break;
      }

Page Object:

//I've added bool as Item3 and bool isImageDisplayed
public Tuple <string, string, bool> GetABC_ByXYZ(string id, string condition, bool image)
 {
  //the below is used for different condition tags, I didn’t add, this is existing
  string tag = null;
  //I've added bool isImageDisplayed
 bool isImageDisplayed= IsElementDisplayed(By.XPath($"/div..........div/*[local-name()='svg']"));

 //tag
    if (condition == "A")
         {
            tag = GetText(By.XPath($"/div............));
         }
//My condition used to fit in else but not anymore since I've added Image column, what do I do with this else if?
    else if (condition != "" && condition != "A")
         {
            //When element was String
            //tag = GetText(By.XPath($"/div.............."));
            //Now String is changed to svg, I need to update to validate the svg exists. Updated elementID to svg but need to get rid of GetText
           //tag = GetText(By.XPath($"/div........div/*[local-name()='svg']"));
          }
            return Tuple.Create(Name, tag, isImageDisplayed);

Body:
First of all, if the image has a unique src attribute you can just try to find it in the webpage:

img[id='TheImageID'][src='TheImageSrc']

If you don't know the src attribute value, or that it may change very often - you can take real screen shot of the screen or the element using Selnium:

Screenshot ss = ((ITakesScreenshot)driver).GetScreenshot();
        ss.SaveAsFile("C://Image.png",
        ScreenshotImageFormat.Png);

You may also take a screenshot of a specific element:

 var img = GetElementScreenShot(driver, element);
                    img.Save("test.png", System.Drawing.Imaging.ImageFormat.Png);

After saving the images - you can take more images and compare them to the baseline valid image.


来源: stackexchange

问:
Reusing OpenSSL SSL_CTX for multiple connections
Is it possible to reuse openssl SSL_CTX to connect to multiple servers.

```<code>SSL_CTX *ssl_ctx = SSL_CTX_new(TLS_client_method());
</code>```

and then I use it for multiple connections like this.

```<code>SSL *ssl = SSL_new(ssl_ctx);
</code>```

This seems to be working fine but problem encountered when I am trying to use SSL_CTX_set_cert_verify_callback which has to be invoked from each connection. However it takes ctx as parameter and it hence it overrides callback and the data passed to it.

Any suggestions will be appreciated.

答:
you can use SSL_set_verify for each connection.

```<code>void SSL_set_verify(SSL *s, int mode,
                    int (*verify_callback)(int, X509_STORE_CTX *));
</code>```

ContentLicense: CC BY-SA 4.0

Body:
Is it possible to reuse openssl SSL_CTX to connect to multiple servers.

SSL_CTX *ssl_ctx = SSL_CTX_new(TLS_client_method());

and then I use it for multiple connections like this.

SSL *ssl = SSL_new(ssl_ctx);

This seems to be working fine but problem encountered when I am trying to use SSL_CTX_set_cert_verify_callback which has to be invoked from each connection. However it takes ctx as parameter and it hence it overrides callback and the data passed to it.

Any suggestions will be appreciated.

Body:
you can use SSL_set_verify for each connection.

void SSL_set_verify(SSL *s, int mode,
                    int (*verify_callback)(int, X509_STORE_CTX *));


问:
In Turtle (Haskell), how can I get the output of a command, and do something with it?
I'm a Haskell beginner, trying to translate a shell script into a Turtle script, just as an exercise. In BASH, I'd get the output of some command like so: cmdoutput=$(my-command -option 1 -option 2 and then I could do a case switch in BASH to echo out different messages or run different actions, depending on the value of cmdoutput. How can I achieve that in Haskell Turtle?

Edit: here's the shell script I'm trying to translate:

#!/usr/bin/bash

export CLOCKSTRING=$(emacsclient --eval '(if (org-clocking-p)(org-clock-get-clock-string) -1)' 2>&1 )

case "$CLOCKSTRING" in
    "-1")
        echo "Off!" ;;
    *"server-start"*)
        echo "Off!" ;;
    *"ERROR"*)
        echo "No clock!" ;;
    *)
        echo ${CLOCKSTRING:3:30} ;
esac
```

<p>And here's what I have so far with Turtle: </p>

```{-# LANGUAGE OverloadedStrings #-}

import Turtle
import qualified Control.Foldl as Fold

translate :: Text -> Text
translate response = case response of
 "-1" -> "Got nothin"
 otherwise -> response

main = do
  let cmd2 = "emacsclient --eval '(if (org-clocking-p)(org-clock-get-clock-string) -1)'"

  emacsOut <- fold (inshell cmd2 empty) Fold.head
  print $ translate $ emacsOut
```

答:
You can use shellStrict, and following is my abstracted tool shEval which is  implemented via shellStrict:

```<code>shEval :: Partial => Text -> IO Text
shEval cmd = do
    (rst, out) <- Turtle.shellStrict cmd empty
    case rst of
        Turtle.ExitSuccess -> pure out
        Turtle.ExitFailure code -> terror ("shell process exit with non-zero code (" ++ tshow code ++ ")")
</code>```

Body:
I'm a Haskell beginner, trying to translate a shell script into a Turtle script, just as an exercise. In BASH, I'd get the output of some command like so: cmdoutput=$(my-command -option 1 -option 2 and then I could do a case switch in BASH to echo out different messages or run different actions, depending on the value of cmdoutput. How can I achieve that in Haskell Turtle?

Edit: here's the shell script I'm trying to translate:

#!/usr/bin/bash

export CLOCKSTRING=$(emacsclient --eval '(if (org-clocking-p)(org-clock-get-clock-string) -1)' 2>&1 )

case "$CLOCKSTRING" in
    "-1")
        echo "Off!" ;;
    *"server-start"*)
        echo "Off!" ;;
    *"ERROR"*)
        echo "No clock!" ;;
    *)
        echo ${CLOCKSTRING:3:30} ;
esac

And here's what I have so far with Turtle:

{-# LANGUAGE OverloadedStrings #-}

import Turtle
import qualified Control.Foldl as Fold

translate :: Text -> Text
translate response = case response of
 "-1" -> "Got nothin"
 otherwise -> response

main = do
  let cmd2 = "emacsclient --eval '(if (org-clocking-p)(org-clock-get-clock-string) -1)'"

  emacsOut <- fold (inshell cmd2 empty) Fold.head
  print $ translate $ emacsOut

Body:
You can use shellStrict, and following is my abstracted tool shEval which is  implemented via shellStrict:

shEval :: Partial => Text -> IO Text
shEval cmd = do
    (rst, out) <- Turtle.shellStrict cmd empty
    case rst of
        Turtle.ExitSuccess -> pure out
        Turtle.ExitFailure code -> terror ("shell process exit with non-zero code (" ++ tshow code ++ ")")


问:
Is it possible to add a new similarity metric to an existing index in Elasticsearch?
Let's say there is an existing index with a customized BM25 similarity metric like this:

{
    "settings": {
        "index": {
            "similarity": {
                "BM25_v1": {
                    "type": "BM25",
                    "b": 1.0
                }
            },
            "number_of_replicas": 0,
            "number_of_shards": 3,
            "refresh_interval": "120s"
        }
    }
}
```
<p>And this similarity metric is used for two fields:</p>
<pre class="lang-py prettyprint-override"><code>{
    'some_field': {
        'type': 'text',
        'norms': 'true',
        'similarity': 'BM25_v1'
    },
    'another_field': {
        'type': 'text',
        'norms': 'true',
        'similarity': 'BM25_v1'
    },
}
</code>```

Now, I was wondering if it's possible to add another similarity metric (BM25_v2) to the same index and use this new metric for the another_field, like this:

"index": {
    "similarity": {
        # The existing metric, not changed.
        "BM25_v1": {
            "type": "BM25",
            "b": 1.0
        },
        # The new similarity metric for this index.
        "BM25_v2": {
            "type": "BM25",
            "b": 0.0
        }
    }
}

# ... and use the new metric for one of the fields:

{
    'some_field': {
        'type': 'text',
        'norms': 'true',
        'similarity': 'BM25_v1' # This field uses the same old metric.
    },
    'another_field': {
        'type': 'text',
        'norms': 'true',
        'similarity': 'BM25_v2' # The new metric is used for this field.
    },
}
```

I couldn't find any example for this scenario in the documentation, so I wasn't sure if this is possible at all.

Update: I have already seen this old still-open issue which concerns with dynamic update of similarity metrics in Elasticsearch. But it is not completely clear from that discussion what is and isn't possible. Also there have been some attempts for achieving some level of similarity update; but I think it's not documented (e.g. it is possible to change the parameters of an existing similarity metric, say b or k1 in an existing BM25-based metric).

答:
TLDR;

I believe you can't.

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "Mapper for [title] conflicts with existing mapper:\n\tCannot update parameter [similarity] from [my_similarity] to [my_similarity_v2]"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "Mapper for [title] conflicts with existing mapper:\n\tCannot update parameter [similarity] from [my_similarity] to [my_similarity_v2]"
  },
  "status" : 400
}
```
<p>If you want to, I believe you will have to create a new field and re-index the data.</p>
<h1>To reproduce</h1>
<pre class="lang-json prettyprint-override"><code>PUT /70973345
{
  "settings": {
    "index": {
      "similarity": {
        "my_similarity": {
          "type": "BM25",
          "b": 1.0
        }
      }
    }
  }
}

PUT /70973345/_mapping
{
  "properties" : {
    "title" : { "type" : "text", "similarity" : "my_similarity" }
  }
}
</code>```

We insert some dummy data, and retrieve it.

POST /70973345/_doc
{
  "title": "I love rock'n roll"
}

POST /70973345/_doc
{
  "title": "I love pasta al'arabita"
}

POST /70973345/_doc
{
  "title": "pasta rock's"
}

GET /70973345/_search?explain=true
{
  "query": {
    "match": {
      "title": "pasta"
    }
  }
}
```
<p>If we try to update it the settings without closing, we get an error.</p>
<pre class="lang-json prettyprint-override"><code>{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "Can't update non dynamic settings ...."
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "Can't update non dynamic settings ...."
  },
  "status" : 400
}

</code>```

POST /70973345/_close?wait_for_active_shards=0
```
<pre class="lang-json prettyprint-override"><code>PUT /70973345/_settings
{
  "index": {
    "similarity": {
      "my_similarity": {
        "type": "BM25",
        "b": 1.0
      },
      "my_similarity_v2": {
        "type": "BM25",
        "b": 0
      }
    }
  }
}
</code>```

The update works fine, BUT :

PUT /70973345/_mapping
{
  "properties": {
    "title": {
      "type": "text",
      "similarity": "my_similarity_v2"
    }
  }
}
```
<pre class="lang-json prettyprint-override"><code>{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "Mapper for [title] conflicts with existing mapper:\n\tCannot update parameter [similarity] from [my_similarity] to [my_similarity_v2]"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "Mapper for [title] conflicts with existing mapper:\n\tCannot update parameter [similarity] from [my_similarity] to [my_similarity_v2]"
  },
  "status" : 400
}
</code>```

It will not work, regardless of the open/close status of the index.

Which makes me believe this is not possible. you might need to re-index into a new indice the existing data.

Body:
Let's say there is an existing index with a customized BM25 similarity metric like this:

{
    "settings": {
        "index": {
            "similarity": {
                "BM25_v1": {
                    "type": "BM25",
                    "b": 1.0
                }
            },
            "number_of_replicas": 0,
            "number_of_shards": 3,
            "refresh_interval": "120s"
        }
    }
}

And this similarity metric is used for two fields:

{
    'some_field': {
        'type': 'text',
        'norms': 'true',
        'similarity': 'BM25_v1'
    },
    'another_field': {
        'type': 'text',
        'norms': 'true',
        'similarity': 'BM25_v1'
    },
}

Now, I was wondering if it's possible to add another similarity metric (BM25_v2) to the same index and use this new metric for the another_field, like this:

"index": {
    "similarity": {
        # The existing metric, not changed.
        "BM25_v1": {
            "type": "BM25",
            "b": 1.0
        },
        # The new similarity metric for this index.
        "BM25_v2": {
            "type": "BM25",
            "b": 0.0
        }
    }
}

# ... and use the new metric for one of the fields:

{
    'some_field': {
        'type': 'text',
        'norms': 'true',
        'similarity': 'BM25_v1' # This field uses the same old metric.
    },
    'another_field': {
        'type': 'text',
        'norms': 'true',
        'similarity': 'BM25_v2' # The new metric is used for this field.
    },
}

I couldn't find any example for this scenario in the documentation, so I wasn't sure if this is possible at all.

Update: I have already seen this old still-open issue which concerns with dynamic update of similarity metrics in Elasticsearch. But it is not completely clear from that discussion what is and isn't possible. Also there have been some attempts for achieving some level of similarity update; but I think it's not documented (e.g. it is possible to change the parameters of an existing similarity metric, say b or k1 in an existing BM25-based metric).

Body:
TLDR;

I believe you can't.

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "Mapper for [title] conflicts with existing mapper:\n\tCannot update parameter [similarity] from [my_similarity] to [my_similarity_v2]"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "Mapper for [title] conflicts with existing mapper:\n\tCannot update parameter [similarity] from [my_similarity] to [my_similarity_v2]"
  },
  "status" : 400
}

If you want to, I believe you will have to create a new field and re-index the data.

To reproduce

PUT /70973345
{
  "settings": {
    "index": {
      "similarity": {
        "my_similarity": {
          "type": "BM25",
          "b": 1.0
        }
      }
    }
  }
}

PUT /70973345/_mapping
{
  "properties" : {
    "title" : { "type" : "text", "similarity" : "my_similarity" }
  }
}

We insert some dummy data, and retrieve it.

POST /70973345/_doc
{
  "title": "I love rock'n roll"
}

POST /70973345/_doc
{
  "title": "I love pasta al'arabita"
}

POST /70973345/_doc
{
  "title": "pasta rock's"
}

GET /70973345/_search?explain=true
{
  "query": {
    "match": {
      "title": "pasta"
    }
  }
}

If we try to update it the settings without closing, we get an error.

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "Can't update non dynamic settings ...."
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "Can't update non dynamic settings ...."
  },
  "status" : 400
}

POST /70973345/_close?wait_for_active_shards=0

PUT /70973345/_settings
{
  "index": {
    "similarity": {
      "my_similarity": {
        "type": "BM25",
        "b": 1.0
      },
      "my_similarity_v2": {
        "type": "BM25",
        "b": 0
      }
    }
  }
}

The update works fine, BUT :

PUT /70973345/_mapping
{
  "properties": {
    "title": {
      "type": "text",
      "similarity": "my_similarity_v2"
    }
  }
}

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "Mapper for [title] conflicts with existing mapper:\n\tCannot update parameter [similarity] from [my_similarity] to [my_similarity_v2]"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "Mapper for [title] conflicts with existing mapper:\n\tCannot update parameter [similarity] from [my_similarity] to [my_similarity_v2]"
  },
  "status" : 400
}

It will not work, regardless of the open/close status of the index.

Which makes me believe this is not possible. you might need to re-index into a new indice the existing data.


问:
xcode 4 + phonegap ... not update JS upon build?
I've run into a weird issue that has had me scratching my head for the past hour.

I'm working on an iPad app using Xcode 4 and PhoneGap. It's using jQuery. I've put all my JS into a scripts.js file.

Things are working well.

I spend about an hour doing a lot of CSS tweaking. I'd update the CSS file, stop the app, rebuild, and push to the iPad simulator or my iPad. That's been working fine. Every update to the CSS file is reflected on the new build.

I then needed to update the JS file. I couldn't get things to work and then I finally realized none of my JS changes were actually be put into the build. I finally blanked out my JS file completely, rebuilt, and it's still not updating.

The file I'm updated is being updated in the finder in the project folder (I can right-click 'view in finder' and that file is, indeed, updated).

So I'm stumped. Is the xcode compiler caching the JS file somehow instead of grabbing the updated file? Is there a way to force it to grab the updated JS?

答: I found it necessary to hold the Option button when clicking the menu command which turns the command from "Clean" to "Clean Build Folder..." and this caused my assets to be refreshed.</p>

ContentLicense: CC BY-SA 3.0


问:
Rails, ActiveRecord, query id in array of ints, keep order of passed array
I am thinking about the best solution for a problem.
Let's say that we have a list of ids of ActiveRecord model:

```<code>ids = [1, 100, 5, 30, 4, 2, 88, 44]
</code>```

Then I would like to make query that selects all users for example with ids from the list but to keep the order.
If I do

```<code>User.where(id: ids)
</code>```

the response will be a list of users with asc order by id, but I want the order to be the same as in the array.

What do you think that it's the best solution here? Select all users and then to manipulate the list of ActiveRecord objects? Maybe there is a more clever way to do that.

Thanks!

答:
If you're searching by primary key you can use find, which accepts an array and guarantees order.

```<code>User.find(ids)
</code>```

Few "downsides"/"extra features":

it will return an array instead of relation, so it needs to be called at the very end of your chaining.

it will raise ActiveRecord::NotFound exception if any of the given ids is not present in the database

Body:
I am thinking about the best solution for a problem.
Let's say that we have a list of ids of ActiveRecord model:

ids = [1, 100, 5, 30, 4, 2, 88, 44]

Then I would like to make query that selects all users for example with ids from the list but to keep the order.
If I do

User.where(id: ids)

the response will be a list of users with asc order by id, but I want the order to be the same as in the array.

What do you think that it's the best solution here? Select all users and then to manipulate the list of ActiveRecord objects? Maybe there is a more clever way to do that.

Thanks!

Body:
If you're searching by primary key you can use find, which accepts an array and guarantees order.

User.find(ids)

Few "downsides"/"extra features":

it will return an array instead of relation, so it needs to be called at the very end of your chaining.

it will raise ActiveRecord::NotFound exception if any of the given ids is not present in the database


问:
How to add props in the component
I am using this above Flatlist with a component. So here I am saying an icon in the variable back. I want to send some color to this svg icon from {item.back}. How can i do this so that if any conditions change I will send a color to Icons and change its color?</p>
```<code>const data = [{ back: <Icon/>}]

<FlatList
  showsVerticalScrollIndicator={false}
  keyExtractor={(item, index) => index}
  data={data}
  renderItem={() => <Item />}
/>;

const Item_view = ({ item, index }) => {
  const { navigateTo } = item;
  return <View>{item.back}</View>;
};
</code>```

答:
In generally, Use your SVG as a component, then all the SVG goodness is accessible:

 For example:

```<code>const MenuIcon = (props) =>(
    <svg xmlns="http://www.w3.org/2000/svg" fill={props.fill} className={props.class}></svg>
)
</code>```

And in your render

```<code><li>
   <a href="/" className="sidebar__link">
      <MenuIcon fill="white"/>
    </a>
</li>
</code>```

Title: How to add props in the component

Body:
I am using this above Flatlist with a component. So here I am saying an icon in the variable back. I want to send some color to this svg icon from {item.back}. How can i do this so that if any conditions change I will send a color to Icons and change its color?

const data = [{ back: <Icon/>}]

<FlatList
  showsVerticalScrollIndicator={false}
  keyExtractor={(item, index) => index}
  data={data}
  renderItem={() => <Item />}
/>;

const Item_view = ({ item, index }) => {
  const { navigateTo } = item;
  return <View>{item.back}</View>;
};

Body:
In generally, Use your SVG as a component, then all the SVG goodness is accessible:

 For example:

const MenuIcon = (props) =>(
    <svg xmlns="http://www.w3.org/2000/svg" fill={props.fill} className={props.class}></svg>
)

And in your render

<li>
   <a href="/" className="sidebar__link">
      <MenuIcon fill="white"/>
    </a>
</li>


问:
Compare 2 columns in same excel sheet in pandas
In excel sheet i want to compare the 2 columns. The column names like file_1 and file_2. by using these 2 cols want to create the another col like 'diff' by using excel formula [countifs]. In case , if file_1 and file_2 column records matched it should be 0 (Zero) in diff column otherwise it should be 1. But, i am not as excepted result. Could please help anyone.

here is my inputs :

```<code>   file_1    file_2
    G          G
    A          B
    C          F
    E          H
    A          C
    H          E
</code>```

Output Dataframe :

```<code>    file_1       file_2       diff
     G          G              0
     A          B              1
     C          F              1
     E          H              0
     A          C              0
     H          E              0
</code>```

Sample code :

```<code>     df = pd.read_excel('file1.xlsx')
     df1 = df[df['file_1'].isin(df['file_2'])]
     df['diff'] = df1
     print(df)
</code>```

答:
This should work;</p>
```<code>import pandas as pd
import numpy as np
df['diff'] = np.where(df['file_1'] == df['file_2'] , '0', '1')
</code>```

Body:
In excel sheet i want to compare the 2 columns. The column names like file_1 and file_2. by using these 2 cols want to create the another col like 'diff' by using excel formula [countifs]. In case , if file_1 and file_2 column records matched it should be 0 (Zero) in diff column otherwise it should be 1. But, i am not as excepted result. Could please help anyone.

here is my inputs :

   file_1    file_2
    G          G
    A          B
    C          F
    E          H
    A          C
    H          E

Output Dataframe :

    file_1       file_2       diff
     G          G              0
     A          B              1
     C          F              1
     E          H              0
     A          C              0
     H          E              0

Sample code :

     df = pd.read_excel('file1.xlsx')
     df1 = df[df['file_1'].isin(df['file_2'])]
     df['diff'] = df1
     print(df)

Body:
This should work;

import pandas as pd
import numpy as np
df['diff'] = np.where(df['file_1'] == df['file_2'] , '0', '1')


问:
Using RestSharp to access Content in RestResponse
I'm unable to figure out how to access the content from a RestResponse that requires a POST.  I can view the results in the Visual Studio Debugger but can't access it using "response.content".  Any suggestions?

Visual Studio Debugging View

答: Content is public property, so there's no issue accessing it as response.Content. If you have it failing somehow, please post your code and the compilation error.


问:
How to plot only bigger communities with Igraph package in Python?
I am new in the networks world and I need help with the python package Igraph.
I created my network and I applied community_walktrap() for the clustering. Now, I would like to plot just the clusters with more than 10 elements. Do you know how I can do this?
To plot everything, I am using:

```<code>ig.plot(clusters, mark_groups = True, bbox=(1000,1000), vertex_label=g.vs['name'])
</code>```

But I do not know if there is a way to exclude the smaller clusters.

Thank you in advace!

答:
Unfortunately it's not as easy as it should be, but here's a quick sketch:</p>
```<code>def subgraph_of_large_clusters(clustering: VertexClustering, threshold: int) -> VertexClustering:
    sizes = clustering.sizes()
    members = [i for i, c in enumerate(clustering.membership) if sizes[c] >= threshold]
    new_graph = clustering.graph.subgraph(members)
    new_membership = [clustering.membership[i] for i in members]
    return VertexClustering(new_graph, new_membership)

g = Graph.GRG(10000, 0.02)
cl = g.community_walktrap().as_clustering()
plot(subgraph_of_large_clusters(cl, 100))
</code>```

Body:
I am new in the networks world and I need help with the python package Igraph.
I created my network and I applied community_walktrap() for the clustering. Now, I would like to plot just the clusters with more than 10 elements. Do you know how I can do this?
To plot everything, I am using:

ig.plot(clusters, mark_groups = True, bbox=(1000,1000), vertex_label=g.vs['name'])

But I do not know if there is a way to exclude the smaller clusters.

Thank you in advace!

Body:
Unfortunately it's not as easy as it should be, but here's a quick sketch:

def subgraph_of_large_clusters(clustering: VertexClustering, threshold: int) -> VertexClustering:
    sizes = clustering.sizes()
    members = [i for i, c in enumerate(clustering.membership) if sizes[c] >= threshold]
    new_graph = clustering.graph.subgraph(members)
    new_membership = [clustering.membership[i] for i in members]
    return VertexClustering(new_graph, new_membership)

g = Graph.GRG(10000, 0.02)
cl = g.community_walktrap().as_clustering()
plot(subgraph_of_large_clusters(cl, 100))


问:
access to a class variable
I'm trying to access to a class variable through an instance method through an eval (Function)

```<code>class Foo
  @classVariable = "helow"

class Bar extends Foo
  bar: -> (new Function("console.log(Foo.classVariable)")).call @
  baz: -> console.log(Foo.classVariable)

(new Bar()).baz()
(new Bar()).bar()
</code>```

but method bar raise an error, telling me ReferenceError: Foo is not defined

Any advices ?
Is there another to access a class variable ?

答:
When you create a function by passing a string to the Function constructor, that function can only see the global scope (see the MDN docs). If you wrote

```<code>class (window ? global).Foo
  ...
</code>```

then your code would work. Alternatively, instead of using the Function constructor, just use eval:

```<code>bar: -> eval "console.log(Foo.classVariable);"
</code>```

Title: access to a class variable

Body:
I'm trying to access to a class variable through an instance method through an eval (Function)

class Foo
  @classVariable = "helow"

class Bar extends Foo
  bar: -> (new Function("console.log(Foo.classVariable)")).call @
  baz: -> console.log(Foo.classVariable)

(new Bar()).baz()
(new Bar()).bar()

but method bar raise an error, telling me ReferenceError: Foo is not defined

Any advices ?
Is there another to access a class variable ?

Body:
When you create a function by passing a string to the Function constructor, that function can only see the global scope (see the MDN docs). If you wrote

class (window ? global).Foo
  ...

then your code would work. Alternatively, instead of using the Function constructor, just use eval:

bar: -> eval "console.log(Foo.classVariable);"


问:
azure-functions-maven-plugin final jar missing libraries in classpath
I am try to deploy Java Azure function app from my local machine. My tech stack is fallows,

```<code>Azure Function App OS: Linux
Azure Functions Core Tools (2.0.3)
Springboot 2.6.3
spring-boot-maven-plugin 2.6.3
azure-functions-maven-plugin 1.14.3
azure-functions-java-library 1.4.2
spring-cloud-function-adapter-azure 3.2.1
</code>```

Here is my pom.xml

```<code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.3</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <groupId>com.avol.func</groupId>
    <artifactId>springcloud-eh-func</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>Azure Java Functions</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>11</java.version>
        <azure.functions.maven.plugin.version>1.14.3</azure.functions.maven.plugin.version>
        <azure.functions.java.library.version>1.4.2</azure.functions.java.library.version>
        <functionAppName>poc-java-func-apsp</functionAppName>
        <resource.groupname>AvolPOCs</resource.groupname>
        <appserviceplan.name>ASP-AvolPOCs-84f2</appserviceplan.name>
        <azure.region>southcentralus</azure.region>
        <azure.subscriptionid>xxxxxx</azure.subscriptionid>
        <stagingDirectory>${project.build.directory}/azure-functions/${functionAppName}</stagingDirectory>
        <start-class>com.avol.func.SpringAppRunner</start-class>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.microsoft.azure.functions</groupId>
            <artifactId>azure-functions-java-library</artifactId>
            <version>${azure.functions.java.library.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-function-adapter-azure</artifactId>
            <version>3.2.1</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>applicationinsights-spring-boot-starter</artifactId>
            <version>2.6.3</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>applicationinsights-logging-logback</artifactId>
            <version>2.6.3</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.22</version>
        </dependency>
        <!-- Test -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>5.8.2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>4.2.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-function-dependencies</artifactId>
                <version>3.2.1</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.microsoft.azure.functions</groupId>
                <artifactId>azure-functions-java-library</artifactId>
                <version>${azure.functions.java.library.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>obj</directory>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.2.0</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${stagingDirectory}/lib</outputDirectory>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>false</overWriteSnapshots>
                            <overWriteIfNewer>true</overWriteIfNewer>
                            <includeScope>runtime</includeScope>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.microsoft.azure</groupId>
                <artifactId>azure-functions-maven-plugin</artifactId>
                <version>${azure.functions.maven.plugin.version}</version>
                <configuration>
                    <subscriptionId>${azure.subscriptionid}</subscriptionId>
                    <!-- function app name -->
                    <appName>${functionAppName}</appName>
                    <!-- function app resource group -->
                    <resourceGroup>${resource.groupname}</resourceGroup>
                    <!-- function app service plan name -->
                    <appServicePlanName>${appserviceplan.name}</appServicePlanName>
                    <!-- function app region-->
                    <!-- refers https://github.com/microsoft/azure-maven-plugins/wiki/Azure-Functions:-Configuration-Details#supported-regions for all valid values -->
                    <region>${azure.region}</region>
                    <!-- function pricingTier, default to be consumption if not specified -->
                    <!-- refers https://github.com/microsoft/azure-maven-plugins/wiki/Azure-Functions:-Configuration-Details#supported-pricing-tiers for all valid values -->
                    <!-- <pricingTier></pricingTier> -->
                    <!-- Whether to disable application insights, default is false -->
                    <disableAppInsights>false</disableAppInsights>
                    <runtime>
                        <os>linux</os>
                        <javaVersion>11</javaVersion>
                    </runtime>
                    <appSettings>
                        <property>
                            <name>FUNCTIONS_EXTENSION_VERSION</name>
                            <value>~4</value>
                        </property>
                        <property>
                            <name>FUNCTIONS_WORKER_RUNTIME</name>
                            <value>java</value>
                        </property>
                    </appSettings>
                </configuration>
                <executions>
                    <execution>
                        <id>package-functions</id>
                        <goals>
                            <goal>package</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.2.0</version>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <overwrite>true</overwrite>
                            <outputDirectory>
                                ${project.build.directory}/azure-functions/${functionAppName}
                            </outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${project.basedir}/src/main/resources
                                    </directory>
                                    <includes>
                                        <include>**</include>
                                    </includes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.6.3</version>
                <dependencies>
                    <dependency>
                        <groupId>org.springframework.boot.experimental</groupId>
                        <artifactId>spring-boot-thin-layout</artifactId>
                        <version>1.0.28.RELEASE</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
</project>
</code>```

Here is my maven build logs,

```<code>$ mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------< com.avol.func:springcloud-eh-func >----------------
[INFO] Building Azure Java Functions 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ springcloud-eh-func ---
[INFO] Deleting C:\Users\padaldl\workspace\projects\Avol-POCs\src\Java\JavaFunAppPOC\springcloud-eh-func\target
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ springcloud-eh-func ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ springcloud-eh-func ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 10 source files to C:\Users\padaldl\workspace\projects\Avol-POCs\src\Java\JavaFunAppPOC\springcloud-eh-func\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ springcloud-eh-func ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory C:\Users\padaldl\workspace\projects\Avol-POCs\src\Java\JavaFunAppPOC\springcloud-eh-func\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ springcloud-eh-func ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ springcloud-eh-func ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-dependency-plugin:3.2.0:copy-dependencies (copy-dependencies) @ springcloud-eh-func ---
[INFO] Copying azure-functions-java-library-1.4.2.jar to C:\Users\padaldl\workspace\projects\Avol-POCs\src\Java\JavaFunAppPOC\springcloud-eh-func\target\azure-functions\poc-java-func-apsp\lib\azure-functions-java-library-1.4.2.jar
[INFO]
[INFO] --- maven-jar-plugin:3.2.2:jar (default-jar) @ springcloud-eh-func ---
[INFO] Building jar: C:\Users\padaldl\workspace\projects\Avol-POCs\src\Java\JavaFunAppPOC\springcloud-eh-func\target\springcloud-eh-func-1.0.0-SNAPSHOT.jar
[INFO]
[INFO] --- azure-functions-maven-plugin:1.14.3:package (package-functions) @ springcloud-eh-func ---
[INFO] Java home : C:/Users/padaldl/workspace/installedsws/zulu-11-azure-jdk_11.52.13-11.0.13-win_x64
[INFO] Artifact compile version : 11
[INFO]
[INFO] Step 1 of 8: Searching for Azure Functions entry points
[INFO] 2 Azure Functions entry point(s) found.
[INFO]
[INFO] Step 2 of 8: Generating Azure Functions configurations
[INFO] Generation done.
[INFO]
[INFO] Step 3 of 8: Validating generated configurations
[INFO] Validation done.
[INFO]
[INFO] Step 4 of 8: Saving host.json
[INFO] Successfully saved to C:\Users\padaldl\workspace\projects\Avol-POCs\src\Java\JavaFunAppPOC\springcloud-eh-func\target\azure-functions\poc-java-func-apsp\host.json
[INFO]
[INFO] Step 5 of 8: Saving local.settings.json
[INFO] Successfully saved to C:\Users\padaldl\workspace\projects\Avol-POCs\src\Java\JavaFunAppPOC\springcloud-eh-func\target\azure-functions\poc-java-func-apsp\local.settings.json
[INFO]
[INFO] Step 6 of 8: Saving configurations to function.json
[INFO] Starting processing function: uppercase
[INFO] Successfully saved to C:\Users\padaldl\workspace\projects\Avol-POCs\\src\Java\JavaFunAppPOC\springcloud-eh-func\target\azure-functions\poc-java-func-apsp\uppercase\function.json
[INFO] Starting processing function: assetSync
[INFO] Successfully saved to C:\Users\padaldl\workspace\projects\Avol-POCs\src\Java\JavaFunAppPOC\springcloud-eh-func\target\azure-functions\poc-java-func-apsp\assetSync\function.json
[INFO]
[INFO] Step 7 of 8: Copying JARs to staging directoryC:\Users\padaldl\workspace\projects\Avol-POCs\src\Java\JavaFunAppPOC\springcloud-eh-func\target\azure-functions\poc-java-func-apsp
[INFO] Copied successfully.
[INFO] Step 8 of 8: Installing function extensions if needed
[INFO] Extension bundle specified, skip install extension
[INFO] Successfully built Azure Functions.
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:copy-resources (copy-resources) @ springcloud-eh-func ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 2 resources
[INFO]
[INFO] --- spring-boot-maven-plugin:2.6.3:repackage (repackage) @ springcloud-eh-func ---
[INFO] Replacing main artifact with repackaged archive
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  29.790 s
[INFO] Finished at: 2022-02-03T19:39:15+05:30
[INFO] ------------------------------------------------------------------------

</code>```

Function App works fine in local from IntellIJ IDEA, and as well run through mvn azure-functions:run command.

When I run the jar using java command java -jar <> it fails with error No Class Definition found error.

mvn azure-functions:deploy succeeded without any issue, and am able to see functions created on azure, but when I trigger function it fails with 500 Internal Error.

I suspect function failing in azure due to external dependencies not added to classpath of jar. From the stackoverflow I found similar question here, suggestion is to go with maven assembly plugin, but my question is why should we use Assembly plugin when I am using springboot plugin?

答:
Finally issue got resolved after installing Azure Functions Core Tools version 4.x through MSI installer on windows.

https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=v4%2Cwindows%2Ccsharp%2Cportal%2Cbash#v2

And it looks like azure functions refer /lib folder under staging directory when function triggers, it need not be springboot fat jar.

Body:
I am try to deploy Java Azure function app from my local machine. My tech stack is fallows,

Azure Function App OS: Linux
Azure Functions Core Tools (2.0.3)
Springboot 2.6.3
spring-boot-maven-plugin 2.6.3
azure-functions-maven-plugin 1.14.3
azure-functions-java-library 1.4.2
spring-cloud-function-adapter-azure 3.2.1

Here is my pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.3</version>
        <relativePath/>
    </parent>

    <groupId>com.avol.func</groupId>
    <artifactId>springcloud-eh-func</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>Azure Java Functions</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>11</java.version>
        <azure.functions.maven.plugin.version>1.14.3</azure.functions.maven.plugin.version>
        <azure.functions.java.library.version>1.4.2</azure.functions.java.library.version>
        <functionAppName>poc-java-func-apsp</functionAppName>
        <resource.groupname>AvolPOCs</resource.groupname>
        <appserviceplan.name>ASP-AvolPOCs-84f2</appserviceplan.name>
        <azure.region>southcentralus</azure.region>
        <azure.subscriptionid>xxxxxx</azure.subscriptionid>
        <stagingDirectory>${project.build.directory}/azure-functions/${functionAppName}</stagingDirectory>
        <start-class>com.avol.func.SpringAppRunner</start-class>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.microsoft.azure.functions</groupId>
            <artifactId>azure-functions-java-library</artifactId>
            <version>${azure.functions.java.library.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-function-adapter-azure</artifactId>
            <version>3.2.1</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>applicationinsights-spring-boot-starter</artifactId>
            <version>2.6.3</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>applicationinsights-logging-logback</artifactId>
            <version>2.6.3</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.22</version>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>5.8.2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>4.2.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-function-dependencies</artifactId>
                <version>3.2.1</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.microsoft.azure.functions</groupId>
                <artifactId>azure-functions-java-library</artifactId>
                <version>${azure.functions.java.library.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>obj</directory>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.2.0</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${stagingDirectory}/lib</outputDirectory>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>false</overWriteSnapshots>
                            <overWriteIfNewer>true</overWriteIfNewer>
                            <includeScope>runtime</includeScope>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.microsoft.azure</groupId>
                <artifactId>azure-functions-maven-plugin</artifactId>
                <version>${azure.functions.maven.plugin.version}</version>
                <configuration>
                    <subscriptionId>${azure.subscriptionid}</subscriptionId>

                    <appName>${functionAppName}</appName>

                    <resourceGroup>${resource.groupname}</resourceGroup>

                    <appServicePlanName>${appserviceplan.name}</appServicePlanName>

                    <region>${azure.region}</region>

                    <disableAppInsights>false</disableAppInsights>
                    <runtime>
                        <os>linux</os>
                        <javaVersion>11</javaVersion>
                    </runtime>
                    <appSettings>
                        <property>
                            <name>FUNCTIONS_EXTENSION_VERSION</name>
                            <value>~4</value>
                        </property>
                        <property>
                            <name>FUNCTIONS_WORKER_RUNTIME</name>
                            <value>java</value>
                        </property>
                    </appSettings>
                </configuration>
                <executions>
                    <execution>
                        <id>package-functions</id>
                        <goals>
                            <goal>package</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.2.0</version>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <overwrite>true</overwrite>
                            <outputDirectory>
                                ${project.build.directory}/azure-functions/${functionAppName}
                            </outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${project.basedir}/src/main/resources
                                    </directory>
                                    <includes>
                                        <include>**</include>
                                    </includes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.6.3</version>
                <dependencies>
                    <dependency>
                        <groupId>org.springframework.boot.experimental</groupId>
                        <artifactId>spring-boot-thin-layout</artifactId>
                        <version>1.0.28.RELEASE</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
</project>

Here is my maven build logs,

$ mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------< com.avol.func:springcloud-eh-func >----------------
[INFO] Building Azure Java Functions 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ springcloud-eh-func ---
[INFO] Deleting C:\Users\padaldl\workspace\projects\Avol-POCs\src\Java\JavaFunAppPOC\springcloud-eh-func\target
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ springcloud-eh-func ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ springcloud-eh-func ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 10 source files to C:\Users\padaldl\workspace\projects\Avol-POCs\src\Java\JavaFunAppPOC\springcloud-eh-func\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ springcloud-eh-func ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory C:\Users\padaldl\workspace\projects\Avol-POCs\src\Java\JavaFunAppPOC\springcloud-eh-func\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ springcloud-eh-func ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ springcloud-eh-func ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-dependency-plugin:3.2.0:copy-dependencies (copy-dependencies) @ springcloud-eh-func ---
[INFO] Copying azure-functions-java-library-1.4.2.jar to C:\Users\padaldl\workspace\projects\Avol-POCs\src\Java\JavaFunAppPOC\springcloud-eh-func\target\azure-functions\poc-java-func-apsp\lib\azure-functions-java-library-1.4.2.jar
[INFO]
[INFO] --- maven-jar-plugin:3.2.2:jar (default-jar) @ springcloud-eh-func ---
[INFO] Building jar: C:\Users\padaldl\workspace\projects\Avol-POCs\src\Java\JavaFunAppPOC\springcloud-eh-func\target\springcloud-eh-func-1.0.0-SNAPSHOT.jar
[INFO]
[INFO] --- azure-functions-maven-plugin:1.14.3:package (package-functions) @ springcloud-eh-func ---
[INFO] Java home : C:/Users/padaldl/workspace/installedsws/zulu-11-azure-jdk_11.52.13-11.0.13-win_x64
[INFO] Artifact compile version : 11
[INFO]
[INFO] Step 1 of 8: Searching for Azure Functions entry points
[INFO] 2 Azure Functions entry point(s) found.
[INFO]
[INFO] Step 2 of 8: Generating Azure Functions configurations
[INFO] Generation done.
[INFO]
[INFO] Step 3 of 8: Validating generated configurations
[INFO] Validation done.
[INFO]
[INFO] Step 4 of 8: Saving host.json
[INFO] Successfully saved to C:\Users\padaldl\workspace\projects\Avol-POCs\src\Java\JavaFunAppPOC\springcloud-eh-func\target\azure-functions\poc-java-func-apsp\host.json
[INFO]
[INFO] Step 5 of 8: Saving local.settings.json
[INFO] Successfully saved to C:\Users\padaldl\workspace\projects\Avol-POCs\src\Java\JavaFunAppPOC\springcloud-eh-func\target\azure-functions\poc-java-func-apsp\local.settings.json
[INFO]
[INFO] Step 6 of 8: Saving configurations to function.json
[INFO] Starting processing function: uppercase
[INFO] Successfully saved to C:\Users\padaldl\workspace\projects\Avol-POCs\\src\Java\JavaFunAppPOC\springcloud-eh-func\target\azure-functions\poc-java-func-apsp\uppercase\function.json
[INFO] Starting processing function: assetSync
[INFO] Successfully saved to C:\Users\padaldl\workspace\projects\Avol-POCs\src\Java\JavaFunAppPOC\springcloud-eh-func\target\azure-functions\poc-java-func-apsp\assetSync\function.json
[INFO]
[INFO] Step 7 of 8: Copying JARs to staging directoryC:\Users\padaldl\workspace\projects\Avol-POCs\src\Java\JavaFunAppPOC\springcloud-eh-func\target\azure-functions\poc-java-func-apsp
[INFO] Copied successfully.
[INFO] Step 8 of 8: Installing function extensions if needed
[INFO] Extension bundle specified, skip install extension
[INFO] Successfully built Azure Functions.
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:copy-resources (copy-resources) @ springcloud-eh-func ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 2 resources
[INFO]
[INFO] --- spring-boot-maven-plugin:2.6.3:repackage (repackage) @ springcloud-eh-func ---
[INFO] Replacing main artifact with repackaged archive
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  29.790 s
[INFO] Finished at: 2022-02-03T19:39:15+05:30
[INFO] ------------------------------------------------------------------------

Function App works fine in local from IntellIJ IDEA, and as well run through mvn azure-functions:run command.

When I run the jar using java command java -jar <> it fails with error No Class Definition found error.

mvn azure-functions:deploy succeeded without any issue, and am able to see functions created on azure, but when I trigger function it fails with 500 Internal Error.

I suspect function failing in azure due to external dependencies not added to classpath of jar. From the stackoverflow I found similar question here, suggestion is to go with maven assembly plugin, but my question is why should we use Assembly plugin when I am using springboot plugin?


问:
Does Godot have 3D Lights Textures/Cookies
I was wondering if there is a way to put a texture on a 3d Light. In unity it was called cookies.

This is an example of a cookie:

答:
I added this to my sample project:

https://github.com/tavurth/godot-simple-fps-camera

It works by setting two lights, one a little behind the other.
Then you use Sprite3D to mask the rear light and you can set the shadow color for the cookie and the world separately.


问:
Uploading text file to jFrog artifactory with python requests
I wrote the falling short code snippet to play around with requests and artifactory. I'm trying to upload a simple text file.

```<code>import requests

url = "https://myurl.jfrog.io/artifactory"
auth = ("myusername", "mypassword")
file_name = "test.txt"

response = requests.put(url + "/data/" + file_name, auth=auth, data=open(file_name, "rb"))
print(response.status_code)
</code>```

I'm getting error code 405, what am I doing wrong? There are hardly any examples of using requests to work with artifactory

答:
The specified request seems to be redirected to  https://myurl.jfrog.io/artifactory/data/<file_name> which is not an actual repository within an Artifactory instance.

The 405 response code ("Method Not Allowed") gives a good hint.

Try creating a repository within Artifactory and append it after /artifactory, so it should be :

https://myurl.jfrog.io/artifactory/<repository_key>/data/<file_name>

Please find additional information in the REST API documentation:
https://www.jfrog.com/confluence/display/JFROG/Artifactory+REST+API#ArtifactoryRESTAPI-DeployArtifact

Body:
I wrote the falling short code snippet to play around with requests and artifactory. I'm trying to upload a simple text file.

import requests

url = "https://myurl.jfrog.io/artifactory"
auth = ("myusername", "mypassword")
file_name = "test.txt"

response = requests.put(url + "/data/" + file_name, auth=auth, data=open(file_name, "rb"))
print(response.status_code)

I'm getting error code 405, what am I doing wrong? There are hardly any examples of using requests to work with artifactory


问:
The return type 'dynamic' isn't a 'Map<String, dynamic>?' from let
I have the same func in different files, but here i got an error</p>
```<code>    Map<String, dynamic>? getJson(String key) =>
      _sharedPreferences.getString(key)?.let((it) => jsonDecode(it));

</code>```
```<code> The return type 'dynamic' isn't a 'Map<String, dynamic>?',
as required by the closure's context.dartreturn_of_invalid_type_from_closure
</code>```

答:
You need to cast it, see below</p>
```<code>    Map<String, dynamic>? getJson(String key) =>
      _sharedPreferences.getString(key)?.let((it) => (jsonDecode(it) as Map<String, dynamic>));
</code>```

Body:
I have the same func in different files, but here i got an error

    Map<String, dynamic>? getJson(String key) =>
      _sharedPreferences.getString(key)?.let((it) => jsonDecode(it));

 The return type 'dynamic' isn't a 'Map<String, dynamic>?',
as required by the closure's context.dartreturn_of_invalid_type_from_closure

Body:
You need to cast it, see below

    Map<String, dynamic>? getJson(String key) =>
      _sharedPreferences.getString(key)?.let((it) => (jsonDecode(it) as Map<String, dynamic>));


问:
Return consecutive items or single items with null property from an array of objects as array of subsets
I'm looking for a solution on how to extract only consecutive objects with a null property from an array of objects, please see the example below.

Important note:

Array.proptype.filter((item)=> item.y === null) doesn't solve the problem here, .filter method will simply return an array objects where y is equal null.

What I'm willing to achieve here is actually quite more sophisticated than returning a simple array, the goal is to write a method that can iterate through each item in the array, check if the next item also has a null y, if true, the next item must be added to the extracted subset of objects.

Consecutive items are simply the items that come after each other, if the object with the index 3 has a null y property and the object with index 4 has a null y property as well, objects with indexes 3 and 4 can be considered as consecutive items,

If the item with index 8 has a null y but the items respectively with indexes 7 and 9 doesn't have a null y, only the item with index 8 must be added to the extracted subset.

First use case:

the method must be able to spot consecutive nulls and extract them as a subset of the original input set.

input:

```<code>['spider', null, null, null, 'cat','horse', 'eagle']
</code>```

output:

```<code>[
 [null, null, null], <= one subset of nulls representing the nulls between 'spider' and 'cat'
]
</code>```

Second use case:

The method must be able to consider single null items and also extract them into a single item subset array.

input:

```<code>['spider', null, null, null, 'cat', null, 'horse', 'eagle']

</code>```

output:

```<code>[
 [null, null, null], <== first subset
 [null], <== second subset representing the null item between the 'cat' and 'horse'
]
</code>```

Given the dataSet below, I want to extract the items where y property is null.

output pattern

```<code>[
  [first-subset-of-consecutive-nulls],
  [second-subset-of-consecutive-nulls],
  [....]
]
</code>```

Please note that the expected output data structure is an array of arrays and not an array of objects.

Here's a more real-life dataSet example with the expected output.
The expected output should be an array of arrays that contain a subset of the dataSet where the y property is null and the objects are consecutive.

```<code>const dataSet = [
 {x: 'foo', y: 'random-y'},
 {x: 'bar', y: 'random-y'},
 {x: 'yo', y: null}, <=
 {x: 'random', y: null}, <=
 {x: 'lorem', y: null}, <=
 {x: 'ipsum', y: 'random-y'},
 {x: 'dolor', y: 'random-y'},
 {x: 'var', y: null}, <=
 {x: 'mit', y: null}, <=
 {x: 'oder', y: 'random-y'},
 {x: 'whatever', y: null}, <=
 {x: 'something', y: 'random-y'}
];

// Method signature e.g extractSuccesiveNullBy(objectProp: string, from: Array<any>);

extractSuccessiveNullsBy('y', dataSet);
</code>```

Expected output:

```<code>[
  [ {x: 'yo', y: null}, {x: 'random', y: null}, {x: 'lorem', y: null}],
  [ {x: 'var', y: null}, {x: 'mit', y: null}],
  [ {x: 'whatever', y: null]
]
</code>```

Any proposal will be well appreciated.
Thanks.

答:
Sorry, misunderstood, you can loop through the array and see if the previous data was null.

```<code>function extractSuccessiveNullsBy(array, objectProp) {
    let result = [];
    let previous = false;
    for (const data of array) {
        if (data[objectProp] === null) {
            if (previous) {
                result[result.length - 1].push(data);
            } else {
                result.push([data]);
            }
            previous = true;
        } else {
            previous = false;
        }
    }
    return result;
}
</code>```

Live Example:

const dataSet = [
 {x: 'foo', y: 'random-y'},
 {x: 'bar', y: 'random-y'},
 {x: 'yo', y: null}, // <=
 {x: 'random', y: null}, // <=
 {x: 'lorem', y: null}, // <=
 {x: 'ipsum', y: 'random-y'},
 {x: 'dolor', y: 'random-y'},
 {x: 'var', y: null}, // <=
 {x: 'mit', y: null}, // <=
 {x: 'oder', y: 'random-y'},
 {x: 'whatever', y: null}, // <=
 {x: 'something', y: 'random-y'}
];
function extractSuccessiveNullsBy(array, objectProp) {
    let result = [];
    let previous = false;
    for (const data of array) {
        if (data[objectProp] === null) {
            if (previous) {
                result[result.length - 1].push(data);
            } else {
                result.push([data]);
            }
            previous = true;
        } else {
            previous = false;
        }
    }
    return result;
}
console.log(extractSuccessiveNullsBy(dataSet, "y"));```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.as-console-wrapper {
    max-height: 100% !important;
}</code>```

Body:
I'm looking for a solution on how to extract only consecutive objects with a null property from an array of objects, please see the example below.

Important note:

Array.proptype.filter((item)=> item.y === null) doesn't solve the problem here, .filter method will simply return an array objects where y is equal null.

What I'm willing to achieve here is actually quite more sophisticated than returning a simple array, the goal is to write a method that can iterate through each item in the array, check if the next item also has a null y, if true, the next item must be added to the extracted subset of objects.

Consecutive items are simply the items that come after each other, if the object with the index 3 has a null y property and the object with index 4 has a null y property as well, objects with indexes 3 and 4 can be considered as consecutive items,

If the item with index 8 has a null y but the items respectively with indexes 7 and 9 doesn't have a null y, only the item with index 8 must be added to the extracted subset.

First use case:

the method must be able to spot consecutive nulls and extract them as a subset of the original input set.

input:

['spider', null, null, null, 'cat','horse', 'eagle']

output:

[
 [null, null, null], <= one subset of nulls representing the nulls between 'spider' and 'cat'
]

Second use case:

The method must be able to consider single null items and also extract them into a single item subset array.

input:

['spider', null, null, null, 'cat', null, 'horse', 'eagle']

output:

[
 [null, null, null], <== first subset
 [null], <== second subset representing the null item between the 'cat' and 'horse'
]

Given the dataSet below, I want to extract the items where y property is null.

output pattern

[
  [first-subset-of-consecutive-nulls],
  [second-subset-of-consecutive-nulls],
  [....]
]

Please note that the expected output data structure is an array of arrays and not an array of objects.

Here's a more real-life dataSet example with the expected output.
The expected output should be an array of arrays that contain a subset of the dataSet where the y property is null and the objects are consecutive.

const dataSet = [
 {x: 'foo', y: 'random-y'},
 {x: 'bar', y: 'random-y'},
 {x: 'yo', y: null}, <=
 {x: 'random', y: null}, <=
 {x: 'lorem', y: null}, <=
 {x: 'ipsum', y: 'random-y'},
 {x: 'dolor', y: 'random-y'},
 {x: 'var', y: null}, <=
 {x: 'mit', y: null}, <=
 {x: 'oder', y: 'random-y'},
 {x: 'whatever', y: null}, <=
 {x: 'something', y: 'random-y'}
];

// Method signature e.g extractSuccesiveNullBy(objectProp: string, from: Array<any>);

extractSuccessiveNullsBy('y', dataSet);

Expected output:

[
  [ {x: 'yo', y: null}, {x: 'random', y: null}, {x: 'lorem', y: null}],
  [ {x: 'var', y: null}, {x: 'mit', y: null}],
  [ {x: 'whatever', y: null]
]

Any proposal will be well appreciated.
Thanks.

Body:
Sorry, misunderstood, you can loop through the array and see if the previous data was null.

function extractSuccessiveNullsBy(array, objectProp) {
    let result = [];
    let previous = false;
    for (const data of array) {
        if (data[objectProp] === null) {
            if (previous) {
                result[result.length - 1].push(data);
            } else {
                result.push([data]);
            }
            previous = true;
        } else {
            previous = false;
        }
    }
    return result;
}

Live Example:

const dataSet = [
 {x: 'foo', y: 'random-y'},
 {x: 'bar', y: 'random-y'},
 {x: 'yo', y: null}, // <=
 {x: 'random', y: null}, // <=
 {x: 'lorem', y: null}, // <=
 {x: 'ipsum', y: 'random-y'},
 {x: 'dolor', y: 'random-y'},
 {x: 'var', y: null}, // <=
 {x: 'mit', y: null}, // <=
 {x: 'oder', y: 'random-y'},
 {x: 'whatever', y: null}, // <=
 {x: 'something', y: 'random-y'}
];
function extractSuccessiveNullsBy(array, objectProp) {
    let result = [];
    let previous = false;
    for (const data of array) {
        if (data[objectProp] === null) {
            if (previous) {
                result[result.length - 1].push(data);
            } else {
                result.push([data]);
            }
            previous = true;
        } else {
            previous = false;
        }
    }
    return result;
}
console.log(extractSuccessiveNullsBy(dataSet, "y"));

.as-console-wrapper {
    max-height: 100% !important;
}


问:
Set text align to center in an Excel document using OpenXML with C#
I have a document that my asp.net page is creating and I need to align the text of certain columns to center. I have opened the document after manually center the columns in openXML SDK but the code that is reflected does not achieve the desired outcome.

This is how I am setting the custom widths of these columns and I would like to add to this function (method, whatevs) the capability to center the text:

```<code>private static Column CreateColumnData(UInt32 StartColumnIndex, UInt32 EndColumnIndex, double ColumnWidth)
    {
        Column column;
        column = new Column();
        column.Min = StartColumnIndex;
        column.Max = EndColumnIndex;
        column.Width = ColumnWidth;
        column.CustomWidth = true;
        //the SDK says to add this next line to center the text but it doesn't work
        column.Style = (UInt32Value)6U;

        return column;
    }
</code>```

I'm open to another way but I think that the solution has got to be very simple I just can't seem to get it. If anyone can help that would be great.

NOTE: Please keep in mind that I am using OpenXML and will not be using Microsoft.Office.Interop.Excel

答:
In case you are looking how to aligne text in excel cell, you need to apply the alignement on the cellFormat objects

```<code> CellFormat cellFormat = new CellFormat() { NumberFormatId = 0, FontId = 0,
 FillId = 0, BorderId = 0, ApplyAlignment = true };
 Alignment alignment = new Alignment();
 alignment.Vertical = VerticalAlignmentValues.Center;
 alignment.Horizontal = HorizontalAlignmentValues.Center;
 CellFormat.Alignment = alignment;
</code>```

you can read more in microsoft documentation

https://learn.microsoft.com/en-us/dotnet/api/documentformat.openxml.spreadsheet.cellformat.alignment?view=openxml-2.8.1

Body:
I have a document that my asp.net page is creating and I need to align the text of certain columns to center. I have opened the document after manually center the columns in openXML SDK but the code that is reflected does not achieve the desired outcome.

This is how I am setting the custom widths of these columns and I would like to add to this function (method, whatevs) the capability to center the text:

private static Column CreateColumnData(UInt32 StartColumnIndex, UInt32 EndColumnIndex, double ColumnWidth)
    {
        Column column;
        column = new Column();
        column.Min = StartColumnIndex;
        column.Max = EndColumnIndex;
        column.Width = ColumnWidth;
        column.CustomWidth = true;
        //the SDK says to add this next line to center the text but it doesn't work
        column.Style = (UInt32Value)6U;

        return column;
    }

I'm open to another way but I think that the solution has got to be very simple I just can't seem to get it. If anyone can help that would be great.

NOTE: Please keep in mind that I am using OpenXML and will not be using Microsoft.Office.Interop.Excel

Body:
In case you are looking how to aligne text in excel cell, you need to apply the alignement on the cellFormat objects

 CellFormat cellFormat = new CellFormat() { NumberFormatId = 0, FontId = 0,
 FillId = 0, BorderId = 0, ApplyAlignment = true };
 Alignment alignment = new Alignment();
 alignment.Vertical = VerticalAlignmentValues.Center;
 alignment.Horizontal = HorizontalAlignmentValues.Center;
 CellFormat.Alignment = alignment;

you can read more in microsoft documentation

https://learn.microsoft.com/en-us/dotnet/api/documentformat.openxml.spreadsheet.cellformat.alignment?view=openxml-2.8.1


问:
Find span with 2 attributes Selenium
Just trying to code a web scraper with selenium which searchs for a span in a div which has an other span with a title in it.

```<code><div class="col-lg-3 col-6 attributes-column"><div class="p-3 bg-color-third d-flex flex-column border-radius-8px h-100 position-relative attributes-main"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAD4SURBVHgB3ZXNEYIwEIVfGA/iiRLszBawArACpQOtDDrAEwkX1iyQ8WY2BDj4zfAzzNtskn1sgI1R7qXXfUFEuf2SeaMIb3t/Hk/HqyiBMeZug3IEQqBbmqalV2g60xptSGt9hgDWsb43fSvRg8V8IQBpzAHLacTKJSuQkmBjRFsUY2HvCtjC1o6laHCGdQq5dVr5HeRHDWIt7K/BPHP7QzUQ4HR2SzNZgkimBFNhIN2G4ASkqOKngqrnetRYiTEBN6yBhsqtZFdi+9RORf7vBIEWdjql1BjnbXZsYWvfYrYwpNBArzGRRNx13SNBcpF2U56U6Kxegw+CobhgOuqV7gAAAABJRU5ErkJggg==" alt="copy"><span class="fs-11px text-uppercase letter-spacing-3 text-truncate tw-text-secondary" title="Total Volume (ALL Time, ALL Marketplaces)">Total Volume (ALL Time, ALL Marketplaces)</span><span class="text-white fs-14px text-truncate attribute-value" title="5325.23 ◎">5325.23 ◎</span></div></div>
</code>```

The problem is that there are multiple divs with this class. So I have to find only this div which has the span with the title=Total Volume (ALL Time, ALL Marketplaces) in it and then print the span with the class=text-white fs-14px text-truncate attribute-value

Can anyone help me with this problem?
So I only can scrap the right span in the div?

Thank you very much <3

答:
You can locate the span with class=text-white fs-14px text-truncate attribute-value by several ways. I would prefer this XPath:

//div[contains(@class,'attributes-column') and .//span[@title='Total Volume (ALL Time, ALL Marketplaces)']]//span[contains(@class,'attribute-value')]
```

Title: Find span with 2 attributes Selenium

Body:
Just trying to code a web scraper with selenium which searchs for a span in a div which has an other span with a title in it.

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAD4SURBVHgB3ZXNEYIwEIVfGA/iiRLszBawArACpQOtDDrAEwkX1iyQ8WY2BDj4zfAzzNtskn1sgI1R7qXXfUFEuf2SeaMIb3t/Hk/HqyiBMeZug3IEQqBbmqalV2g60xptSGt9hgDWsb43fSvRg8V8IQBpzAHLacTKJSuQkmBjRFsUY2HvCtjC1o6laHCGdQq5dVr5HeRHDWIt7K/BPHP7QzUQ4HR2SzNZgkimBFNhIN2G4ASkqOKngqrnetRYiTEBN6yBhsqtZFdi+9RORf7vBIEWdjql1BjnbXZsYWvfYrYwpNBArzGRRNx13SNBcpF2U56U6Kxegw+CobhgOuqV7gAAAABJRU5ErkJggg==" alt="copy">Total Volume (ALL Time, ALL Marketplaces)5325.23 ◎

The problem is that there are multiple divs with this class. So I have to find only this div which has the span with the title=Total Volume (ALL Time, ALL Marketplaces) in it and then print the span with the class=text-white fs-14px text-truncate attribute-value

Can anyone help me with this problem?
So I only can scrap the right span in the div?

Thank you very much <3


问:
Why "message here" text seems like bold
I'm using jQuery to append
, and it's appending an extra close icon but I can't see why. If you run the code snippet below and click on "Add more" link, you'll see an additional times (x) icon, and the "message here" text seems bolded.

$(function() {

  $("#add").click(function() {
    $('

<input type="text" class="form-control" placeholder="Domain">

 message here

').appendTo("#DomainsList");
  });

  $("#DomainsList").on("click", ".remove", function() {
    $(this).closest('.domainName').remove();
  });
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" integrity="sha512-1ycn6IcaQQ40/MKBW2W4Rhis/DbILU74C1vSrLJxCq57o941Ym01SwNsOMqvEBFlcgUa6xLiPY/NS5R+E6ztJQ==" crossorigin="anonymous" referrerpolicy="no-referrer"
/>
<section id="DomainsList">
  <div class="row">
    <div class="col">
      <div class="input-group mb-2">
        <span class="input-group-text bg-white"><i class="fas fa-lock text-secondary"></i></span>
        <input type="text" class="form-control" placeholder="Domains">
      </div>
    </div>
    <div class="col">message here</div>
  </div>
</section>
<i class="fas fa-plus-circle"></i> Add More</code>```

答:
This problem is caused by typing error.

 tag should close with .

In your code,  close with
.

Using template characters(`) instead of single quotes(') will help with readability when adding code as a string.

$(function () {
  $("#add").click(function () {
    $(`

            <input type="text" class="form-control" placeholder="Domain"/>

 message here

    `).appendTo("#DomainsList");
  });

  $("#DomainsList").on("click", ".remove", function () {
    $(this).closest(".domainName").remove();
  });
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" integrity="sha512-1ycn6IcaQQ40/MKBW2W4Rhis/DbILU74C1vSrLJxCq57o941Ym01SwNsOMqvEBFlcgUa6xLiPY/NS5R+E6ztJQ==" crossorigin="anonymous" referrerpolicy="no-referrer"
/>
<section id="DomainsList">
  <div class="row">
    <div class="col">
      <div class="input-group mb-2">
        <span class="input-group-text bg-white"><i class="fas fa-lock text-secondary"></i></span>
        <input type="text" class="form-control" placeholder="Domains">
      </div>
    </div>
    <div class="col">message here</div>
  </div>
</section>
<i class="fas fa-plus-circle"></i> Add More</code>```

Title: Why "message here" text seems like bold

Body:
I'm using jQuery to append
, and it's appending an extra close icon but I can't see why. If you run the code snippet below and click on "Add more" link, you'll see an additional times (x) icon, and the "message here" text seems bolded.

$(function() {

  $("#add").click(function() {
    $('

<input type="text" class="form-control" placeholder="Domain">

 message here

').appendTo("#DomainsList");
  });

  $("#DomainsList").on("click", ".remove", function() {
    $(this).closest('.domainName').remove();
  });
});

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" integrity="sha512-1ycn6IcaQQ40/MKBW2W4Rhis/DbILU74C1vSrLJxCq57o941Ym01SwNsOMqvEBFlcgUa6xLiPY/NS5R+E6ztJQ==" crossorigin="anonymous" referrerpolicy="no-referrer"
/>

        <input type="text" class="form-control" placeholder="Domains">

message here

 Add More

Body:
This problem is caused by typing error.

<i> tag should close with </i>.

In your code, <i> close with </li>.

Using template characters(`) instead of single quotes(') will help with readability when adding code as a string.

$(function () {
  $("#add").click(function () {
    $(`
      <div class="row domainName">
        <div class="col">
          <div class="input-group mb-2">
            <span class="input-group-text bg-white">
              <i class="fas fa-lock text-secondary"></i>
            </span>
            <input type="text" class="form-control" placeholder="Domain"/>
              <span class="remove input-group-text bg-white">
                <a href="javascript:void(0);">
                  <i class="fas fa-times"></i>
                </a>
              </span>
          </div>
        </div>
        <div class="col"> message here </div>
      </div>
    `).appendTo("#DomainsList");
  });

  $("#DomainsList").on("click", ".remove", function () {
    $(this).closest(".domainName").remove();
  });
});

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" integrity="sha512-1ycn6IcaQQ40/MKBW2W4Rhis/DbILU74C1vSrLJxCq57o941Ym01SwNsOMqvEBFlcgUa6xLiPY/NS5R+E6ztJQ==" crossorigin="anonymous" referrerpolicy="no-referrer"
/>
<section id="DomainsList">
  <div class="row">
    <div class="col">
      <div class="input-group mb-2">
        <span class="input-group-text bg-white"><i class="fas fa-lock text-secondary"></i></span>
        <input type="text" class="form-control" placeholder="Domains">
      </div>
    </div>
    <div class="col">message here</div>
  </div>
</section>
<a href="javascript:void(0);" id="add"><i class="fas fa-plus-circle"></i> Add More</a>


问:
CSS background-image not showing up (sometimes)
I'm trying to set the background-image-property in CSS.

Here's my Code:

body{
  background-color: #2C2F33 ;
  background-image: url(https://i.postimg.cc/htbpRQ6f/0f73b4070e4238fe757656ba68e24c44af64c970.jpg);
  background-size: cover;
  background-attachment: fixed;
  font-family: 'Roboto', 'Arial', 'sans-serif';
  color:white;
}```

Everything is working fine, but sometimes after starting Firefox, the Background-Image won't show up.

It will get loaded, if i'm using Strg+F5.

So the background-image isn't set properly in cache.

Does anyone know how to set it properly?

答:
I shorted and update your code a little bit, It's worked on codepen every time. You could try it, Hope it will solve your problem.

The code:

```<code>body{
  background: url("https://i.postimg.cc/htbpRQ6f/0f73b4070e4238fe757656ba68e24c44af64c970.jpg"), #2C2F33;
  background-size: cover;
  font-family: 'Roboto', 'Arial', 'sans-serif';
  color:white;
}
</code>```

Also see from code snippet:

body{
  background: url("https://i.postimg.cc/htbpRQ6f/0f73b4070e4238fe757656ba68e24c44af64c970.jpg"), #2C2F33;
  background-size: cover;
  font-family: 'Roboto', 'Arial', 'sans-serif';
  color:white;
}```

Body:
I'm trying to set the background-image-property in CSS.

Here's my Code:

body{
  background-color: #2C2F33 ;
  background-image: url(https://i.postimg.cc/htbpRQ6f/0f73b4070e4238fe757656ba68e24c44af64c970.jpg);
  background-size: cover;
  background-attachment: fixed;
  font-family: 'Roboto', 'Arial', 'sans-serif';
  color:white;
}

Everything is working fine, but sometimes after starting Firefox, the Background-Image won't show up.

It will get loaded, if i'm using Strg+F5.

So the background-image isn't set properly in cache.

Does anyone know how to set it properly?

Body:
I shorted and update your code a little bit, It's worked on codepen every time. You could try it, Hope it will solve your problem.

The code:

body{
  background: url("https://i.postimg.cc/htbpRQ6f/0f73b4070e4238fe757656ba68e24c44af64c970.jpg"), #2C2F33;
  background-size: cover;
  font-family: 'Roboto', 'Arial', 'sans-serif';
  color:white;
}

Also see from code snippet:

body{
  background: url("https://i.postimg.cc/htbpRQ6f/0f73b4070e4238fe757656ba68e24c44af64c970.jpg"), #2C2F33;
  background-size: cover;
  font-family: 'Roboto', 'Arial', 'sans-serif';
  color:white;
}


问:
PowerApps - adding same set of data in multiple time
I am trying to doing powerapps

I created a design something similar to this

I want to  the same design in 10 times.. 10 set of design.. How can I do this..
Now what I am doing is, I created 1st set and copy paste to 10 times and again and again adjusting the position. Is this a correct method?  how can we reuse the same design ? I tried component, but data source binding is not possible in component..
how can I do this?

答: Select all the components, group them, and you only have to readjust your group.</p>


问:
Could not find a version that satisfies the requirement torch>=1.0.0?
Could not find a version that satisfies the requirement torch>=1.0.0
No matching distribution found for torch>=1.0.0 (from stanfordnlp)</p>

答:
I want to pip install  " torch>=1.4.0,  torchvision>=0.5.0 ",  but in a conda env with python=3.0, this is not right.
I tried create a new conda env with python=3.7, and pip install  " torch>=1.4.0,  torchvision>=0.5.0 " again, it is ok.


问:
Tkinter - Counting lines in a Text widget with word wrapping
I'd like to know how to get the number of lines in a Tkinter Text widget that has word wrap enabled.

In this example, there are 3 lines in the text widget :

```<code>from Tkinter import *

root = Tk()
text = Text(root, width = 12, height = 5, wrap = WORD)
text.insert(END, 'This is an example text.')
text.pack()

root.mainloop()
</code>```

But methods that work for non-wrapped text, like :

```<code>int(text_widget.index('end-1c').split('.')[0])
</code>```

will return 1 instead of 3. Is there another method that would properly count wrapped lines (and return 3 in my example) ?

Thanks for your help !

答:
I know this is very old but, I wanted to throw a possible current(2022) answer for those working with wrapping lines on windows 10.

```<code>import tkinter as tk

def inspect_wrapline(event=None):
  start = f"{tk.INSERT} linestart"
  end   = f"{tk.INSERT} lineend"
  counter = event.widget.count(start, end, "displaylines")

  print("number of lines after first line", counter)

  start = f"{tk.INSERT} display linestart"
  end   = f"{tk.INSERT} display lineend +1c"
  dline = event.widget.get(start, end)

  print("Text on the displayline", dline)

root_window = tk.Tk()
text_widget = tk.Text(root_window)
text_widget.pack()
text_widget.insert("This is an example text.")
text_widget.bind("<Control-l>", inspect_wrapline)

root_window.mainloop()
</code>```

Output:

insert @ line 0:
(2,)
This is an

insert @ line 1:
(2,)
example

insert @ line 2:
(2,)
text.

Terminology:

Displayline: a single line of text from left to right in the widget viewing area.

Logic line: a string of text regardless of wraps. There is only 1 'logic line' in a line that wraps (or at least that is my understanding.).

Note:

Even though the option is a "displayline" it will yield a displayline even if it is not currently visible in the viewing area.

Hope this helps some wayward tkinter users trying to figure out wrapping lines.

Body:
I'd like to know how to get the number of lines in a Tkinter Text widget that has word wrap enabled.

In this example, there are 3 lines in the text widget :

from Tkinter import *

root = Tk()
text = Text(root, width = 12, height = 5, wrap = WORD)
text.insert(END, 'This is an example text.')
text.pack()

root.mainloop()

But methods that work for non-wrapped text, like :

int(text_widget.index('end-1c').split('.')[0])

will return 1 instead of 3. Is there another method that would properly count wrapped lines (and return 3 in my example) ?

Thanks for your help !

Body:
I know this is very old but, I wanted to throw a possible current(2022) answer for those working with wrapping lines on windows 10.

import tkinter as tk

def inspect_wrapline(event=None):
  start = f"{tk.INSERT} linestart"
  end   = f"{tk.INSERT} lineend"
  counter = event.widget.count(start, end, "displaylines")

  print("number of lines after first line", counter)

  start = f"{tk.INSERT} display linestart"
  end   = f"{tk.INSERT} display lineend +1c"
  dline = event.widget.get(start, end)

  print("Text on the displayline", dline)

root_window = tk.Tk()
text_widget = tk.Text(root_window)
text_widget.pack()
text_widget.insert("This is an example text.")
text_widget.bind("<Control-l>", inspect_wrapline)

root_window.mainloop()

Output:

insert @ line 0:
(2,)
This is an

insert @ line 1:
(2,)
example

insert @ line 2:
(2,)
text.

Terminology:

Displayline: a single line of text from left to right in the widget viewing area.

Logic line: a string of text regardless of wraps. There is only 1 'logic line' in a line that wraps (or at least that is my understanding.).

Note:

Even though the option is a "displayline" it will yield a displayline even if it is not currently visible in the viewing area.

Hope this helps some wayward tkinter users trying to figure out wrapping lines.