问:
How to: [REST] Get and Set Default Reviewers for a repository in Atlassian Stash (Bitbucket Server) programmatically using REST API
So... my current project includes making a script which will configure repositories programmatically on our Stash server (aka BitBucket server). This includes setting the default reviewers for each repository. Is there a REST API for this?</p>

答: I know this is an old issue, but just wanted to note that as of Bitbucket Server 5.1 the default reviewers REST API has been made public: https://developer.atlassian.com/static/rest/bitbucket-server/latest/bitbucket-default-reviewers-rest.html</p>


来源: stackexchange

问:
Powershell - Retrieve List of Groups, Use List To Find Specific Group Member
Good afternoon.  So I have the below line of code that retrieves any AD group with the suffix of -blah1 and blah2.

```<code>import-module activedirectory

$group = Get-ADGroup -Filter { (name -like "*-blah1") -or (name -like "*-blah2") } | Select Name
</code>```

The above code shows groups:

abc-blah1

  abc-blah2

I want to be able to query these groups for a specific user (for example: blahuser).  If the user does not exist in the group, I want to script to tell me.  Any ideas?  Thanks.

答:
You are looking for Get-ADGroupMember and a Where-Object command.</p>

```<code>Get-ADGroup -Filter { (name -like "*-blah1") -or (name -like "*-blah2") } |
    Get-ADGroupMember |
    Where-Object {$_.SamAccountName -match 'blahuser'}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Good afternoon.  So I have the below line of code that retrieves any AD group with the suffix of -blah1 and blah2.

import-module activedirectory

$group = Get-ADGroup -Filter { (name -like "*-blah1") -or (name -like "*-blah2") } | Select Name

The above code shows groups:

abc-blah1

  abc-blah2

I want to be able to query these groups for a specific user (for example: blahuser).  If the user does not exist in the group, I want to script to tell me.  Any ideas?  Thanks.

Body:
You are looking for Get-ADGroupMember and a Where-Object command.

Get-ADGroup -Filter { (name -like "*-blah1") -or (name -like "*-blah2") } |
    Get-ADGroupMember |
    Where-Object {$_.SamAccountName -match 'blahuser'}


问:
NameError: Uninitialized constant Twitter
When I try to run any command that uses the Twitter API in the ruby console, I get the error NameError: uninitialized constant Twitter.

I have named this twitterFeed.rb because I read that it should not be named twitter.rb. This file is placed in my config/initializers folder. I have ran bundle install already, and the line gem 'twitter', '~> 6.2' is in my gem file.

```<code>require 'rubygems'
require 'bundler/setup'

require 'twitter'
require 'json'

client = Twitter::REST::Client.new do |config|
 config.consumer_key = ENV['TWITTER_CONSUMER_KEY']
 config.consumer_secret = ENV['TWITTER_CONSUMER_SECRET']
 config.access_token = ENV['TWITTER_ACCESS_TOKEN']
 config.access_token_secret = ENV['TWITTER_ACCESS_TOKEN_SECRET']
end
</code>```

答:
It looks like you're trying to use irb instead of the Rails console to run your code. When you run through irb (or pry), you aren't actually loading the Rails environment, so none of the gems will be available. You can manually require them, but you still won't have access to the Rails environment.

What you want to do instead is use rails console (or rails c for short).

For example with irb, Twitter isn't loaded:

```<code>rails_dir » irb
2.2.4 :001 > Twitter
NameError: uninitialized constant Twitter
    from (irb):1
    from /Users/bbugh/.rvm/rubies/ruby-2.2.4/bin/irb:11:in `<top (required)>'
</code>```

With rails c, it works just fine:

```<code>rails_dir » rails c
Loading development environment (Rails 5.0.1)
2.2.4 :001 > Twitter
=> Twitter
</code>```

You can take all of those requires out of your initializer - Rails will require the gems automatically by that point. You just need to use rails console when you're doing console work with Rails.

Body:
When I try to run any command that uses the Twitter API in the ruby console, I get the error NameError: uninitialized constant Twitter.

I have named this twitterFeed.rb because I read that it should not be named twitter.rb. This file is placed in my config/initializers folder. I have ran bundle install already, and the line gem 'twitter', '~> 6.2' is in my gem file.

require 'rubygems'
require 'bundler/setup'

require 'twitter'
require 'json'

client = Twitter::REST::Client.new do |config|
 config.consumer_key = ENV['TWITTER_CONSUMER_KEY']
 config.consumer_secret = ENV['TWITTER_CONSUMER_SECRET']
 config.access_token = ENV['TWITTER_ACCESS_TOKEN']
 config.access_token_secret = ENV['TWITTER_ACCESS_TOKEN_SECRET']
end

Body:
It looks like you're trying to use irb instead of the Rails console to run your code. When you run through irb (or pry), you aren't actually loading the Rails environment, so none of the gems will be available. You can manually require them, but you still won't have access to the Rails environment.

What you want to do instead is use rails console (or rails c for short).

For example with irb, Twitter isn't loaded:

rails_dir » irb
2.2.4 :001 > Twitter
NameError: uninitialized constant Twitter
    from (irb):1
    from /Users/bbugh/.rvm/rubies/ruby-2.2.4/bin/irb:11:in `<top (required)>'

With rails c, it works just fine:

rails_dir » rails c
Loading development environment (Rails 5.0.1)
2.2.4 :001 > Twitter
=> Twitter

You can take all of those requires out of your initializer - Rails will require the gems automatically by that point. You just need to use rails console when you're doing console work with Rails.


问:
How can I pick the latest record from the left join in SQL Server?
I have a table view defined as:

```<code>CREATE view [SIR_SUMMARY]
AS
    SELECT
        dimsite.[SiteCode],
        dimsite.[SiteName],
        dimsite.[CityOrLocal] as City,
        dimsite.[State],
        dimsite.PostCode as Zip,
        analysis.[ProductName] as GardeName,
        analysis.[AnalysisTypeName] as ReportingType,
        analysis.LastObsDate as ReportingDate
    FROM
        LOBDW.bjs.udv_BJS_DIM_SITE dimsite
    LEFT JOIN
       [LOBDW].[bjs].[udv_BJS_FACT_SIRA_ANALYSES] analysis ON dimsite.LegSiteId = analysis.LegSiteId
</code>```

The above view returns three records for different ReportingDate; I would like to return single row for the latest ReportingDate.

How can I do that?

答:
You can use window functions:

```<code>create view [SIR_SUMMARY] as
    select . . .
    from LOBDW.bjs.udv_BJS_DIM_SITE bds left join
         (select a.*,
                 row_number() over (partition by LegSiteId order by ReportingDate desc) as seqnum
          from [LOBDW].[bjs].[udv_BJS_FACT_SIRA_ANALYSES] a
         ) a
         on bds.LegSiteId = a.LegSiteId and a.seqnum = 1;
</code>```

Note that I changed the table aliases.  I think shorter ones are easier to use in the query.

Body:
I have a table view defined as:

CREATE view [SIR_SUMMARY]
AS
    SELECT
        dimsite.[SiteCode],
        dimsite.[SiteName],
        dimsite.[CityOrLocal] as City,
        dimsite.[State],
        dimsite.PostCode as Zip,
        analysis.[ProductName] as GardeName,
        analysis.[AnalysisTypeName] as ReportingType,
        analysis.LastObsDate as ReportingDate
    FROM
        LOBDW.bjs.udv_BJS_DIM_SITE dimsite
    LEFT JOIN
       [LOBDW].[bjs].[udv_BJS_FACT_SIRA_ANALYSES] analysis ON dimsite.LegSiteId = analysis.LegSiteId

The above view returns three records for different ReportingDate; I would like to return single row for the latest ReportingDate.

How can I do that?

Body:
You can use window functions:

create view [SIR_SUMMARY] as
    select . . .
    from LOBDW.bjs.udv_BJS_DIM_SITE bds left join
         (select a.*,
                 row_number() over (partition by LegSiteId order by ReportingDate desc) as seqnum
          from [LOBDW].[bjs].[udv_BJS_FACT_SIRA_ANALYSES] a
         ) a
         on bds.LegSiteId = a.LegSiteId and a.seqnum = 1;

Note that I changed the table aliases.  I think shorter ones are easier to use in the query.


答:
By using pd.crosstab

```<code>pd.crosstab(df['value'],df['movie'])
Out[24]:
movie          a        b        c
value
0              4        2        0
10             1        1        0
20             2        0        0
30             0        3        0
40             0        0        2
</code>```

Title: python pivot table of counts

Body:
I have a dataframe df as follows:

| id | movie | value |
|----|-------|-------|
| 1  | a     | 0     |
| 2  | a     | 0     |
| 3  | a     | 20    |
| 4  | a     | 0     |
| 5  | a     | 10    |
| 6  | a     | 0     |
| 7  | a     | 20    |
| 8  | b     | 0     |
| 9  | b     | 0     |
| 10 | b     | 30    |
| 11 | b     | 30    |
| 12 | b     | 30    |
| 13 | b     | 10    |
| 14 | c     | 40    |
| 15 | c     | 40    |

I want to create a 2X2 pivot table of counts as follows:

| Value | count(a) | count(b) | count ( C ) |
|-------|----------|----------|-------------|
| 0     | 4        | 2        | 0           |
| 10    | 1        | 1        | 0           |
| 20    | 2        | 0        | 0           |
| 30    | 0        | 3        | 0           |
| 40    | 0        | 0        | 2           |

I can do this very easily in Excel using Row and Column Labels. How can I do this using Python?

Body:
By using pd.crosstab

pd.crosstab(df['value'],df['movie'])
Out[24]:
movie          a        b        c
value
0              4        2        0
10             1        1        0
20             2        0        0
30             0        3        0
40             0        0        2


问:
How to notify if a class property of a class property has changed?
Let's say I have two classes in my WPF application:

```<code>public class Radio
{
    public int Volume { get; set; }
}

public class Vehicle
{
    public Radio MusicRadio { get; set; }

    private void Explode()
    {
        if (MusicRadio.Volume == 10)
        {
           Application.Shutdown();
        }
    }
}
</code>```

...where Vehicle has a property which is an instance of the Radio class. In my code behind, I want to set the volume of that radio class when a button is clicked:

```<code>private void startButton_Click(object sender, TextChangedEventArgs e)
{
    Vehicle Xterra = new Vehicle() { MusicRadio = new Radio() };

    for (int i = 0; i < 666; i++)
    {
        Xterra.MusicRadio.Volume = i;
    }
}
</code>```

In the above code, the application should shutdown via the Explode() method once the for loop reaches 10 iterations.

I want my Vehicle class to execute its private function Explode() every time the volume the MusicRadio property changes. How can I make sure it is alerted to this change?

答:
WPF MVC

ViewModel:

```<code>public abstract class ObservableObject : INotifyPropertyChanged, INotifyDataErrorInfo
    {
        public void OnPropertyChanged<T>(Expression<Func<T>> property)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(property.GetMemberInfo().Name));
            }
        }
}

public class TankModel : ObservableObject
{
  public float Level
        {
            get { return level; }
            set
            {
                try
                {
                    if (level != value)
                    {
                        level = value;
                        OnPropertyChanged(() => Level);
                    }
                }
                catch (Exception ex)
                {
                    log.Error(ex);
                }
            }
        }
}
</code>```

Body:
Let's say I have two classes in my WPF application:

public class Radio
{
    public int Volume { get; set; }
}

public class Vehicle
{
    public Radio MusicRadio { get; set; }

    private void Explode()
    {
        if (MusicRadio.Volume == 10)
        {
           Application.Shutdown();
        }
    }
}

...where Vehicle has a property which is an instance of the Radio class. In my code behind, I want to set the volume of that radio class when a button is clicked:

private void startButton_Click(object sender, TextChangedEventArgs e)
{
    Vehicle Xterra = new Vehicle() { MusicRadio = new Radio() };

    for (int i = 0; i < 666; i++)
    {
        Xterra.MusicRadio.Volume = i;
    }
}

In the above code, the application should shutdown via the Explode() method once the for loop reaches 10 iterations.

I want my Vehicle class to execute its private function Explode() every time the volume the MusicRadio property changes. How can I make sure it is alerted to this change?

Body:
WPF MVC

ViewModel:

public abstract class ObservableObject : INotifyPropertyChanged, INotifyDataErrorInfo
    {
        public void OnPropertyChanged<T>(Expression<Func<T>> property)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(property.GetMemberInfo().Name));
            }
        }
}

public class TankModel : ObservableObject
{
  public float Level
        {
            get { return level; }
            set
            {
                try
                {
                    if (level != value)
                    {
                        level = value;
                        OnPropertyChanged(() => Level);
                    }
                }
                catch (Exception ex)
                {
                    log.Error(ex);
                }
            }
        }
}


问:
Maps: merging multiple different-size drawables
I have a problem. I need to merge two different sized pictures (drawables). The idea is to have a picture of someone (loaded dynamically) that is 100x100px and have a transparent background that is bigger (e.g. 100x120). In those last 20 pixels I have an arrow that is supposed to point to a person's location on a map. Then I think I could do something like this:

```<code>Drawable[] layers = new Drawable[2];
layers[0] = res.getDrawable(R.drawable.background_img);
layers[1] = res.getDrawable(R.drawable.icon);
LayerDrawable layerDrawable = new LayerDrawable(layers);
</code>```

But this simply overlays one image onto another ignoring their bounds.

Thanks in advance,
Vaidas

-- UPDATE: Finally solved the problem. Works like a charm :)

```<code>private Drawable createPersonDrawable(Bitmap personImage)
{
    Bitmap resultingBitmap = Bitmap.createBitmap(drawableWidth,
            drawableHeight, Bitmap.Config.ARGB_8888);
    Canvas comboCanvas = new Canvas(resultingBitmap);

    comboCanvas.drawBitmap(personImage, 0, 0, null);

    // Get the bottom part of the image from resources
    Bitmap bottomPart = BitmapFactory.decodeResource(getResources(),
            R.drawable.person_map_icon_bottom);

    comboCanvas.drawBitmap(bottomPart, 0, drawablePersonImageHeight, null);
    comboCanvas.save();

    return new BitmapDrawable(resultingBitmap);
}
</code>```

I found the description here: http://www.jondev.net/articles/Combining_2_Images_in_Android_using_Canvas

答: if you want to change Drawable size and position at LayerDrawable, you can use setLayerSize to change drawable size ,and you can use setLayerInset to control position.

Body:
I have a problem. I need to merge two different sized pictures (drawables). The idea is to have a picture of someone (loaded dynamically) that is 100x100px and have a transparent background that is bigger (e.g. 100x120). In those last 20 pixels I have an arrow that is supposed to point to a person's location on a map. Then I think I could do something like this:

Drawable[] layers = new Drawable[2];
layers[0] = res.getDrawable(R.drawable.background_img);
layers[1] = res.getDrawable(R.drawable.icon);
LayerDrawable layerDrawable = new LayerDrawable(layers);

But this simply overlays one image onto another ignoring their bounds.

Thanks in advance,
Vaidas

-- UPDATE: Finally solved the problem. Works like a charm :)

private Drawable createPersonDrawable(Bitmap personImage)
{
    Bitmap resultingBitmap = Bitmap.createBitmap(drawableWidth,
            drawableHeight, Bitmap.Config.ARGB_8888);
    Canvas comboCanvas = new Canvas(resultingBitmap);

    comboCanvas.drawBitmap(personImage, 0, 0, null);

    // Get the bottom part of the image from resources
    Bitmap bottomPart = BitmapFactory.decodeResource(getResources(),
            R.drawable.person_map_icon_bottom);

    comboCanvas.drawBitmap(bottomPart, 0, drawablePersonImageHeight, null);
    comboCanvas.save();

    return new BitmapDrawable(resultingBitmap);
}

I found the description here: http://www.jondev.net/articles/Combining_2_Images_in_Android_using_Canvas


问:
Form without CSRF token: what are the risks
What exactly are the risks I'm exposing myself to if I don't use csrf tokens in my forms? I'm not looking for simple labels or names of the risks, because these can be confusing. I need to understand what exactly an attacker can do and only under what circumstances they can do this, in plain English.</p>

答: I would advise you to read this excellent article explaining what CSRF is and how you could best protect yourself against it.</p>

ContentLicense: CC BY-SA 2.5


问:
Strip invalid and noncharacters from utf8
I'm loading some data, processing it, then sending data to an application which (fair enough) doesn't allow the invalid utf8 noncharacters U+FDD0 through U+FDEF, as well as the invalid U+FFFE and U+FFFF special characters.

My raw data is out of my control, and some it happens to contain invalid characters that I want to clean.

However, my python code is still sending the application invalid utf8, as it doesn't ignore the noncharacters and other invalid characters.

For example
b'\xef\xbf\xbf'.decode('utf-8', 'ignore') returns '\uffff' instead of ignoring the invalid character, and encode has the same behaviour.

I first debugged this with U+FFFE, which has a wontfix bug related to the BOM. https://bugs.python.org/issue765036

Then I found this massive email list thread (https://bugs.python.org/issue12729) claiming that it's ok to emit noncharacters because applications may want to keep them for internal use.

However, is there any nice python way to emit 'transmitabble' utf8 without these noncharacters and other invalid chars like U+FFFF?

答:
I haven't fully considered the ramifications of this, however, you could strip out those characters that have a unicode category of "non-character":

```<code>>>> s = '\uffff\ufffeSome string that contains \ufdd0, \ufdd1, \ufdef and \ufdf0'
>>> print(s)
Some string that contains , ,  and ﷰ

>>> s = ''.join(c for c in s if unicodedata.category(c) != 'Cn')
>>> print(s)
Some string that contains , ,  and ﷰ
</code>```

There is some information about character categories here, and here - scroll down to "Restricted Interchange".

It looks like it would be risky to strip out reserved codepoints due to the possibility of them becoming assigned in future versions of the Unicode standard. You need to consider whether it is warranted in your particular case and for your application now and in the future.

Body:
I haven't fully considered the ramifications of this, however, you could strip out those characters that have a unicode category of "non-character":

>>> s = '\uffff\ufffeSome string that contains \ufdd0, \ufdd1, \ufdef and \ufdf0'
>>> print(s)
Some string that contains , ,  and ﷰ

>>> s = ''.join(c for c in s if unicodedata.category(c) != 'Cn')
>>> print(s)
Some string that contains , ,  and ﷰ

There is some information about character categories here, and here - scroll down to "Restricted Interchange".

It looks like it would be risky to strip out reserved codepoints due to the possibility of them becoming assigned in future versions of the Unicode standard. You need to consider whether it is warranted in your particular case and for your application now and in the future.


问:
I want the isset to include a same variable in both S_GET variables.
For example, when you switch a site to a Jedi or Sith theme, you will also include still the same $color2 in both Jedi and Sith themes, without needing the same variable in both themes.

Similar:

```<code>if (isset($_GET['jedi']))
{
  $color = "#299CF5";
  $color2 = "#F456C2";
}

elseif (isset($_GET['sith']))
{
  $color = "#f45341";
  $color2 = "#F456C2";
}
</code>```

It should be like:

```<code>if (isset($_GET['jedi']))
{
  $color = "#299CF5";
}

elseif (isset($_GET['sith']))
{
  $color = "#f45341";
}

elseif (isset($_GET['jedi']) || isset($_GET['sith']))
{
  $color2 = "#F456C2";
}
</code>```

In HTML:

```<code><h3>Change your favourite theme of<span style="color: <?php echo $color ?>">Star Wars</span> of <span style="color: <?php echo $color2 ?>"> Gustavo</span></h3> <br>

<a href="index.php&jedi">Jedi</a> <br>
<a href="index.php&sith">Sith</a> <br>

<?php echo $color; ?> <br>
<?php echo $color2; ?>
</code>```

Output in the Sith theme:

Change your favourite theme of Star Wars of  Gustavo

    Jedi

    Sith

    #f45341

    #F456C2```
</div>
</div>
</p>

<p>Output in the Jedi theme:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><h3>Change your favourite theme of <span style="color: #299CF5">Star Wars</span> of <span style="color: #F456C2"> Gustavo</span></h3>

    Jedi <br>
    Sith <br>
    <br>
    #299CF5 <br>
    #F456C2</code>```

I also tried:

```<code>elseif (!isset($_GET['jedi']) || isset($_GET['sith']))
{
  $color2 = "#F456C2";
}

elseif (!isset($_GET['jedi'], $_GET['sith']))
{
  $color2 = "#F456C2";
}

elseif (isset($_GET['jedi'], $_GET['sith']))
{
  $color2 = "#F456C2";
}
</code>```

All these ways didn't detect the $color2.

答:
all you really need to do is change the 2nd code

```<code>if (isset($_GET['jedi']))
{
  $color = "#299CF5";
}

elseif (isset($_GET['sith']))
{
  $color = "#f45341";
}

elseif (isset($_GET['jedi']) || isset($_GET['sith']))
{
  $color2 = "#F456C2";
}
</code>```

to

```<code>if (isset($_GET['jedi']))
{
  $color = "#299CF5";
}

elseif (isset($_GET['sith']))
{
  $color = "#f45341";
}

if (isset($_GET['jedi']) || isset($_GET['sith']))
{
  $color2 = "#F456C2";
}
</code>```

Body:
For example, when you switch a site to a Jedi or Sith theme, you will also include still the same $color2 in both Jedi and Sith themes, without needing the same variable in both themes.

Similar:

if (isset($_GET['jedi']))
{
  $color = "#299CF5";
  $color2 = "#F456C2";
}

elseif (isset($_GET['sith']))
{
  $color = "#f45341";
  $color2 = "#F456C2";
}

It should be like:

if (isset($_GET['jedi']))
{
  $color = "#299CF5";
}

elseif (isset($_GET['sith']))
{
  $color = "#f45341";
}

elseif (isset($_GET['jedi']) || isset($_GET['sith']))
{
  $color2 = "#F456C2";
}

In HTML:

Change your favourite theme of<span style="color: <?php echo $color ?>">Star Wars of <span style="color: <?php echo $color2 ?>"> Gustavo

Jedi

Sith

<?php echo $color; ?>

<?php echo $color2; ?>

Output in the Sith theme:

Change your favourite theme of Star Wars of  Gustavo

    Jedi

    Sith

    #f45341

    #F456C2

Output in the Jedi theme:

Change your favourite theme of Star Wars of  Gustavo

    Jedi

    Sith

    #299CF5

    #F456C2

I also tried:

elseif (!isset($_GET['jedi']) || isset($_GET['sith']))
{
  $color2 = "#F456C2";
}

elseif (!isset($_GET['jedi'], $_GET['sith']))
{
  $color2 = "#F456C2";
}

elseif (isset($_GET['jedi'], $_GET['sith']))
{
  $color2 = "#F456C2";
}

All these ways didn't detect the $color2.

Body:
all you really need to do is change the 2nd code

if (isset($_GET['jedi']))
{
  $color = "#299CF5";
}

elseif (isset($_GET['sith']))
{
  $color = "#f45341";
}

elseif (isset($_GET['jedi']) || isset($_GET['sith']))
{
  $color2 = "#F456C2";
}

to

if (isset($_GET['jedi']))
{
  $color = "#299CF5";
}

elseif (isset($_GET['sith']))
{
  $color = "#f45341";
}

if (isset($_GET['jedi']) || isset($_GET['sith']))
{
  $color2 = "#F456C2";
}


问:
Putting multiple elements in array through loop
I have multiple inputs in a file like this:

<form action="card_generate.php">
<input type="text" name="tZero">
        <input type="text" name="tOne">
        <input type="text" name="tTwo">
        <input type="text" name="tThree">
</form>```
</div>
</div>

in the file card_generate.php this have to go in an array i have wrote:</p>

<pre class="lang-php prettyprint-override"><code>$tabs = array($_POST["tZero"], $_POST["tOne"], $_POST["tTwo"], $_POST["tThree"]);
</code>```

Is there a way I can put these values in an array through a loop or something instead of putting each value in an array one by one, there can be more values than four values.

答:
You can, using array_push: http://php.net/manual/de/function.array-push.php

You can than just loop like this:

```<code>for($i = 0; $i < 10; $i++) {
    if(isset($_POST["t" . $i])) {
        array_push($array, $_POST["t" . $i]);
    }
}
</code>```

Body:
I have multiple inputs in a file like this:

<form action="card_generate.php">
<input type="text" name="tZero">
        <input type="text" name="tOne">
        <input type="text" name="tTwo">
        <input type="text" name="tThree">
</form>

in the file card_generate.php this have to go in an array i have wrote:

$tabs = array($_POST["tZero"], $_POST["tOne"], $_POST["tTwo"], $_POST["tThree"]);

Is there a way I can put these values in an array through a loop or something instead of putting each value in an array one by one, there can be more values than four values.

Body:
You can, using array_push: http://php.net/manual/de/function.array-push.php

You can than just loop like this:

for($i = 0; $i < 10; $i++) {
    if(isset($_POST["t" . $i])) {
        array_push($array, $_POST["t" . $i]);
    }
}


问:
angular-translate not working but not errors
I've just installed angular-translate, but the webpage after this doesn't work.

Here you can find my code:

```<code>app.js

angular
.module('frontEndApp', [
    'ngAnimate',
    'ngAria',
    'ngCookies',
    'ngMessages',
    'ngResource',
    'ngRoute',
    'ngSanitize',
    'ngTouch',
    'ngStorage',
    'ngResource',
    'angular-translate'
])
.config(function ($routeProvider) {
    $routeProvider
        .when('/', {
            templateUrl: 'views/main.html',
            controller: 'MainCtrl',
            controllerAs: 'main'
        })
</code>```

Index.html.

```<code>  <script src="bower_components/angular-translate/angular-translate.js"></script>
<!-- endbower -->
<!-- endbuild -->

<!-- build:js({.tmp,app}) scripts/scripts.js -->
<script src="scripts/app.js"></script>
<script src="scripts/controllers/main.js"></script>
<script src="scripts/controllers/about.js"></script>
<script src="scripts/controllers/prueba/pruebaController.js"></script>
<script src="scripts/controllers/loginController.js"></script>
<script src="scripts/controllers/department/departmentController.js"></script>
<script src="config/appConstants.js"></script>
<script src="config/languajes.js"></script>
</code>```

languajes.js

```<code>'user strict';

var app = angular.module('frontEndApp', ['pascalprecht.translate']);

app.config(['$translateProvider', function ($translateProvider) {

    $translateProvider.translations('en', {
        code: 'Code',
        department: 'Deparment',
        description: 'Description',
        boss: 'Boss',
        project: 'Project'
    });

    $translateProvider.translations('es', {
        code: 'Código',
        department: 'Deparmento',
        description: 'Descripción',
        boss: 'Jefe',
        project: 'Proyecto'
    });

    $translateProvider.preferredLanguage('en');
    // $translateProvider.useSanitizeValueStrategy('escapeParamenters');
}]);

    app.config(['$locationProvider', function ($locationProvider) {
      $locationProvider.html5Mode(true);
    }]);

    app.controller('Ctrl', function ($scope, $translate) {
        $scope.changeLanguage = function (key) {
        $translate.use(key);
      };
    });
</code>```

bower.json

```<code> {
"name": "front-end",
"version": "0.0.0",
"dependencies": {
"angular": "^1.6.6",
"bootstrap-sass-official": "^3.2.0",
"angular-animate": "^1.6.6",
"angular-aria": "^1.6.6",
"angular-cookies": "^1.6.6",
"angular-messages": "^1.6.6",
"angular-resource": "^1.6.6",
"angular-route": "^1.6.6",
"angular-sanitize": "^1.6.6",
"angular-touch": "^1.6.6",
"bootstrap-sass": "bootstrap-sass-official#^3.3.7",
"ngstorage": "^0.3.11",
"angular-translate": "^2.16.0"
},
"devDependencies": {
"angular-mocks": "^1.6.6",
"angularLocalStorage": "ngStorage#^0.3.2"
},
"appPath": "app",
"moduleName": "frontEndApp",
"overrides": {
"bootstrap": {
  "main": [
    "less/bootstrap.less",
    "dist/css/bootstrap.css",
    "dist/js/bootstrap.js"
    ]
   }
 }
}
</code>```

The problem is the system works fine, but when I insert the script

all is gone, the webpage is blank only the header appears.

I have tried several solutions but I have no idea.

https://docs.angularjs.org/error/$injector/nomod?p0=pascalprecht.translate

https://angular-translate.github.io/docs/#/guide

答:
In languajes.js:

angular.module('frontEndApp', ['pascalprecht.translate'])

is telling angular to create a module called frontEndApp - which overrides the module you've created in app.js.

(Overrides because app.js is run before languajes.js due to the order of the scripts in the HTML).

What you need to do:

app.js

```<code>angular
.module('frontEndApp', [
    'ngAnimate',
    'ngAria',
    'ngCookies',
    'ngMessages',
    'ngResource',
    'ngRoute',
    'ngSanitize',
    'ngTouch',
    'ngStorage',
    'ngResource',
    'pascalprecht.translate'
])
.config(function ($routeProvider) {
    $routeProvider
        .when('/', {
            templateUrl: 'views/main.html',
            controller: 'MainCtrl',
            controllerAs: 'main'
        })
</code>```

languajes.js

```<code>'user strict';

var app = angular.module('frontEndApp');

app.config(['$translateProvider', function ($translateProvider) {

    $translateProvider.translations('en', {
        code: 'Code',
        department: 'Deparment',
        description: 'Description',
        boss: 'Boss',
        project: 'Project'
    });

    $translateProvider.translations('es', {
        code: 'Código',
        department: 'Deparmento',
        description: 'Descripción',
        boss: 'Jefe',
        project: 'Proyecto'
    });

    $translateProvider.preferredLanguage('en');
    // $translateProvider.useSanitizeValueStrategy('escapeParamenters');
}]);

app.config(['$locationProvider', function ($locationProvider) {
  $locationProvider.html5Mode(true);
}]);

app.controller('Ctrl', function ($scope, $translate) {
    $scope.changeLanguage = function (key) {
    $translate.use(key);
  };
});
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I've just installed angular-translate, but the webpage after this doesn't work.

Here you can find my code:

app.js

angular
.module('frontEndApp', [
    'ngAnimate',
    'ngAria',
    'ngCookies',
    'ngMessages',
    'ngResource',
    'ngRoute',
    'ngSanitize',
    'ngTouch',
    'ngStorage',
    'ngResource',
    'angular-translate'
])
.config(function ($routeProvider) {
    $routeProvider
        .when('/', {
            templateUrl: 'views/main.html',
            controller: 'MainCtrl',
            controllerAs: 'main'
        })

Index.html.

languajes.js

'user strict';

var app = angular.module('frontEndApp', ['pascalprecht.translate']);

app.config(['$translateProvider', function ($translateProvider) {

    $translateProvider.translations('en', {
        code: 'Code',
        department: 'Deparment',
        description: 'Description',
        boss: 'Boss',
        project: 'Project'
    });

    $translateProvider.translations('es', {
        code: 'Código',
        department: 'Deparmento',
        description: 'Descripción',
        boss: 'Jefe',
        project: 'Proyecto'
    });

    $translateProvider.preferredLanguage('en');
    // $translateProvider.useSanitizeValueStrategy('escapeParamenters');
}]);

    app.config(['$locationProvider', function ($locationProvider) {
      $locationProvider.html5Mode(true);
    }]);

    app.controller('Ctrl', function ($scope, $translate) {
        $scope.changeLanguage = function (key) {
        $translate.use(key);
      };
    });

bower.json

 {
"name": "front-end",
"version": "0.0.0",
"dependencies": {
"angular": "^1.6.6",
"bootstrap-sass-official": "^3.2.0",
"angular-animate": "^1.6.6",
"angular-aria": "^1.6.6",
"angular-cookies": "^1.6.6",
"angular-messages": "^1.6.6",
"angular-resource": "^1.6.6",
"angular-route": "^1.6.6",
"angular-sanitize": "^1.6.6",
"angular-touch": "^1.6.6",
"bootstrap-sass": "bootstrap-sass-official#^3.3.7",
"ngstorage": "^0.3.11",
"angular-translate": "^2.16.0"
},
"devDependencies": {
"angular-mocks": "^1.6.6",
"angularLocalStorage": "ngStorage#^0.3.2"
},
"appPath": "app",
"moduleName": "frontEndApp",
"overrides": {
"bootstrap": {
  "main": [
    "less/bootstrap.less",
    "dist/css/bootstrap.css",
    "dist/js/bootstrap.js"
    ]
   }
 }
}

The problem is the system works fine, but when I insert the script

all is gone, the webpage is blank only the header appears.

I have tried several solutions but I have no idea.

https://docs.angularjs.org/error/$injector/nomod?p0=pascalprecht.translate

https://angular-translate.github.io/docs/#/guide

Body:
In languajes.js:

angular.module('frontEndApp', ['pascalprecht.translate'])

is telling angular to create a module called frontEndApp - which overrides the module you've created in app.js.

(Overrides because app.js is run before languajes.js due to the order of the scripts in the HTML).

What you need to do:

app.js

angular
.module('frontEndApp', [
    'ngAnimate',
    'ngAria',
    'ngCookies',
    'ngMessages',
    'ngResource',
    'ngRoute',
    'ngSanitize',
    'ngTouch',
    'ngStorage',
    'ngResource',
    'pascalprecht.translate'
])
.config(function ($routeProvider) {
    $routeProvider
        .when('/', {
            templateUrl: 'views/main.html',
            controller: 'MainCtrl',
            controllerAs: 'main'
        })

languajes.js

'user strict';

var app = angular.module('frontEndApp');

app.config(['$translateProvider', function ($translateProvider) {

    $translateProvider.translations('en', {
        code: 'Code',
        department: 'Deparment',
        description: 'Description',
        boss: 'Boss',
        project: 'Project'
    });

    $translateProvider.translations('es', {
        code: 'Código',
        department: 'Deparmento',
        description: 'Descripción',
        boss: 'Jefe',
        project: 'Proyecto'
    });

    $translateProvider.preferredLanguage('en');
    // $translateProvider.useSanitizeValueStrategy('escapeParamenters');
}]);

app.config(['$locationProvider', function ($locationProvider) {
  $locationProvider.html5Mode(true);
}]);

app.controller('Ctrl', function ($scope, $translate) {
    $scope.changeLanguage = function (key) {
    $translate.use(key);
  };
});


问:
Working with large csv file in R
any help will be appreciated.

I used the following code to break down my large csv file (4gb) and now I am trying to save the 2nd, 3rd... part into a csv. However, I can only access the first chunk of my data.

Is there anything wrong with my code?
How do I save the second chunk of my data into csv?

```<code>rgfile <- 'filename.csv'

index <- 0

chunkSize <- 100000

con <- file(description = rgfile, open="r")

dataChunk <- read.table(con, nrows= chunkSize, header=T, fill= TRUE, sep= ",")

actualColumnNames <- names(dataChunk)

repeat {

  index <- index + 1

  print(paste('Processing rows:', index * chunkSize))

  if (nrow(dataChunk) != chunkSize){
    print('Processed all files!')
    break
  }

  dataChunk <- read.table(
    con, nrows = chunkSize, skip=0, header = FALSE,
    fill=TRUE, sep = ",", col.names=actualColumnNames
  )

  break

}
</code>```

答:
```<code>library(tidyverse)
library(nycflights13)

# make the problelm reproducible
rgfile <- 'flights.csv'
write_csv(flights, rgfile)

# now, get to work

lines <- as.numeric(R.utils::countLines(rgfile))

chunk_size <- 100000

hdr <- read_csv(rgfile, n_max=2)

fnum <- 1

for (i in seq(1, lines, chunk_size)) {

  suppressMessages(
    read_csv(
      rgfile, col_names=colnames(hdr), skip=(i-1), n_max=chunk_size
    )
  ) -> x

  if (i>1) colnames(x) <- colnames(hdr)

  write_csv(x, sprintf("file%03d.csv", fnum))

  fnum <- fnum + 1

}
</code>```

Title: Working with large csv file in R

Body:
any help will be appreciated.

I used the following code to break down my large csv file (4gb) and now I am trying to save the 2nd, 3rd... part into a csv. However, I can only access the first chunk of my data.

Is there anything wrong with my code?
How do I save the second chunk of my data into csv?

rgfile <- 'filename.csv'

index <- 0

chunkSize <- 100000

con <- file(description = rgfile, open="r")

dataChunk <- read.table(con, nrows= chunkSize, header=T, fill= TRUE, sep= ",")

actualColumnNames <- names(dataChunk)

repeat {

  index <- index + 1

  print(paste('Processing rows:', index * chunkSize))

  if (nrow(dataChunk) != chunkSize){
    print('Processed all files!')
    break
  }

  dataChunk <- read.table(
    con, nrows = chunkSize, skip=0, header = FALSE,
    fill=TRUE, sep = ",", col.names=actualColumnNames
  )

  break

}


问:
android studio 3 emulator, how to enable microphone input for speech recognition
I am unsure how to enable microphone input in my emulator.  It is greyed out.  Is there some code that I can write that will let the microphone detect speech in the android studio (3.0) emulator?

My app works on a real phone, but I need to simulate other devices too. I can't buy all of the real devices.  Thank you!

答:
You can us Android x86 , It Support microphone , bluetooth, etc..
android-x86_64-6.0-r3</p>


问:
Wrong architecture error when loading lgi
I have Lua 5.3 installed on my Mac Sierra OS with Luarocks and it seems to be working fine. In fact, I have lgi installed and this file works without error from the terminal when I run it:

```<code>local lgi = require'lgi'
</code>```

However, in ZeroBrane with the 5.3 interpreter selected, the same file produces the following error:

```<code>/ZeroBraneStudio/bin/lua.app/Contents/MacOS/lua53: error loading module 'lgi.corelgilua51' from file '/usr/local/lib/lua/5.3/lgi/corelgilua51.so':
dlopen(/usr/local/lib/lua/5.3/lgi/corelgilua51.so, 6): no suitable image found.  Did find:
/usr/local/lib/lua/5.3/lgi/corelgilua51.so: mach-o, but wrong architecture
/usr/local/lib/lua/5.3/lgi/corelgilua51.so: mach-o, but wrong architecture
stack traceback:
    [C]: in ?
    [C]: in function 'require'
    /usr/local/share/lua/5.3/lgi/core.lua:14: in main chunk
    [C]: in function 'require'
    /usr/local/share/lua/5.3/lgi/init.lua:19: in main chunk
    [C]: in function 'require'
    /usr/local/share/lua/5.3/lgi.lua:19: in main chunk
    [C]: in function 'require'
    /Users/andrew/src/gstreamer/fun.lua:1: in main chunk
    [C]: in ?
</code>```

I also tried using the installed interpreter:

```<code>path.lua = "/usr/local/bin/lua"
</code>```

but this had no effect.

SO... does anyone have any pointers? Why does the terminal work but ZeroBrane complain about the wrong architecture?

答:
lua53 binary that comes with ZeroBrane Studio is i386 executable (32bit), but the library you are using is probably 64bit, hence the message about the wrong architecture.

```<code>path.lua = "/usr/local/bin/lua"
</code>```

but this had no effect.

If you are using it with Lua 5.3 interpreter, you'll need to set path.lua53 instead; try path.lua53 = "/usr/local/bin/lua" (assuming /usr/local/bin/lua is Lua 5.3 interpreter). See Interpreter Path section in the documentation for details/examples.

Also, this filename (/usr/local/lib/lua/5.3/lgi/corelgilua51.so) looks suspicious, as it mixes 5.3 and 51, but if it works from the command line, it should work from the IDE as well when you set path.lua53.

Body:
I have Lua 5.3 installed on my Mac Sierra OS with Luarocks and it seems to be working fine. In fact, I have lgi installed and this file works without error from the terminal when I run it:

local lgi = require'lgi'

However, in ZeroBrane with the 5.3 interpreter selected, the same file produces the following error:

/ZeroBraneStudio/bin/lua.app/Contents/MacOS/lua53: error loading module 'lgi.corelgilua51' from file '/usr/local/lib/lua/5.3/lgi/corelgilua51.so':
dlopen(/usr/local/lib/lua/5.3/lgi/corelgilua51.so, 6): no suitable image found.  Did find:
/usr/local/lib/lua/5.3/lgi/corelgilua51.so: mach-o, but wrong architecture
/usr/local/lib/lua/5.3/lgi/corelgilua51.so: mach-o, but wrong architecture
stack traceback:
    [C]: in ?
    [C]: in function 'require'
    /usr/local/share/lua/5.3/lgi/core.lua:14: in main chunk
    [C]: in function 'require'
    /usr/local/share/lua/5.3/lgi/init.lua:19: in main chunk
    [C]: in function 'require'
    /usr/local/share/lua/5.3/lgi.lua:19: in main chunk
    [C]: in function 'require'
    /Users/andrew/src/gstreamer/fun.lua:1: in main chunk
    [C]: in ?

I also tried using the installed interpreter:

path.lua = "/usr/local/bin/lua"

but this had no effect.

SO... does anyone have any pointers? Why does the terminal work but ZeroBrane complain about the wrong architecture?

Body:
lua53 binary that comes with ZeroBrane Studio is i386 executable (32bit), but the library you are using is probably 64bit, hence the message about the wrong architecture.

path.lua = "/usr/local/bin/lua"

but this had no effect.

If you are using it with Lua 5.3 interpreter, you'll need to set path.lua53 instead; try path.lua53 = "/usr/local/bin/lua" (assuming /usr/local/bin/lua is Lua 5.3 interpreter). See Interpreter Path section in the documentation for details/examples.

Also, this filename (/usr/local/lib/lua/5.3/lgi/corelgilua51.so) looks suspicious, as it mixes 5.3 and 51, but if it works from the command line, it should work from the IDE as well when you set path.lua53.


问:
Hide 'div' after specific amount of time
I have a div, which is generally used for showing some status messsage like "you have selected some xyz thing"

Now, I need to hide it at interval of specific amount of time (say, 60 secs) after page loads.

Code:

```<code> <div id="msg">You have selected 'Time and Money' magazine</div>
</code>```

How can I perform the above mentioned thing?

Thanks

答:
```<code>$(document).ready(function () {
  setTimeout(function () {
      $('#msg').hide();
  }, 60000);
});
</code>```

Body:
I have a div, which is generally used for showing some status messsage like "you have selected some xyz thing"

Now, I need to hide it at interval of specific amount of time (say, 60 secs) after page loads.

Code:

You have selected 'Time and Money' magazine

How can I perform the above mentioned thing?

Thanks


问:
Change Xamarin form ios launch screen image
I am working on Xamarin form cross platform app where I need to change default launch screen image.
I changed launch screen images from Asset catalog then lunch screen but when app is launched image is showing small and centered with background of default xamarin background color.

How do i change that too ?

答:
Did you check LaunchScreen.storyboard file?
https://developer.xamarin.com/guides/ios/application_fundamentals/working_with_images/launch-screens/</p>


问:
Tapestry 500 error: EnvironmentImpl.stackFor(EnvironmentImpl.java:47) may no longer be invoked
I had a perfectly good Tapestry 5.4 app going last night, and after committing some work and switching to another branch, I started getting a random/transient error I hadn't seen before: a 500 error that only comes up some times, when accessing some pages.

It never happens when I reload the page using a browser command, but weirdly it will happen if I click the nav item for the page or click the nav links for other pages, and subsequent reloads will clear it.

One clue is that this didn't happen before I committed a bunch of work to a branch, then checked out another branch, and merged my new branch in.

```<code>HTTP ERROR 500

Problem accessing /inventory. Reason:

    Method org.apache.tapestry5.internal.services.EnvironmentImpl.stackFor(EnvironmentImpl.java:47) may no longer be invoked.
Caused by:

java.lang.IllegalStateException: Method org.apache.tapestry5.internal.services.EnvironmentImpl.stackFor(EnvironmentImpl.java:47) may no longer be invoked.
    at org.apache.tapestry5.ioc.internal.util.OneShotLock.innerCheck(OneShotLock.java:58)
    at org.apache.tapestry5.ioc.internal.util.OneShotLock.check(OneShotLock.java:37)
    at org.apache.tapestry5.internal.services.EnvironmentImpl.stackFor(EnvironmentImpl.java:47)
    at org.apache.tapestry5.internal.services.EnvironmentImpl.push(EnvironmentImpl.java:111)
    at $Environment_19d467107466.push(Unknown Source)
    at $Environment_19d467107398.push(Unknown Source)
    at org.apache.tapestry5.modules.TapestryModule$25.renderMarkup(TapestryModule.java:1746)
    at $MarkupRenderer_19d467107465.renderMarkup(Unknown Source)
    at org.apache.tapestry5.internal.services.javascript.AddBrowserCompatibilityStyles.renderMarkup(AddBrowserCompatibilityStyles.java:45)
    at $MarkupRenderer_19d467107465.renderMarkup(Unknown Source)
    at org.apache.tapestry5.internal.services.javascript.ConfigureHTMLElementFilter.renderMarkup(ConfigureHTMLElementFilter.java:45)
    at $MarkupRenderer_19d467107465.renderMarkup(Unknown Source)
    at $MarkupRenderer_19d467107461.renderMarkup(Unknown Source)
    at org.apache.tapestry5.internal.services.PageMarkupRendererImpl.renderPageMarkup(PageMarkupRendererImpl.java:47)
    at $PageMarkupRenderer_19d46710745f.renderPageMarkup(Unknown Source)
    at org.apache.tapestry5.internal.services.PageResponseRendererImpl.renderPageResponse(PageResponseRendererImpl.java:64)
    at $PageResponseRenderer_19d4671073fa.renderPageResponse(Unknown Source)
    at org.apache.tapestry5.internal.services.DefaultRequestExceptionHandler.renderException(DefaultRequestExceptionHandler.java:262)
    at org.apache.tapestry5.internal.services.DefaultRequestExceptionHandler.handleRequestException(DefaultRequestExceptionHandler.java:145)
    at $RequestExceptionHandler_19d4671073bc.handleRequestException(Unknown Source)
    at org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:42)
    at $RequestHandler_19d4671073be.service(Unknown Source)
    at org.apache.tapestry5.modules.TapestryModule$3.service(TapestryModule.java:846)
    at $RequestHandler_19d4671073be.service(Unknown Source)
    at org.apache.tapestry5.modules.TapestryModule$2.service(TapestryModule.java:836)
    at $RequestHandler_19d4671073be.service(Unknown Source)
    at org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:89)
    at $RequestHandler_19d4671073be.service(Unknown Source)
    at edu.colostate.cs.cs414.project.jzw.webui.services.AppModule$1.service(AppModule.java:118)
    at $RequestFilter_19d4671073b8.service(Unknown Source)
    at $RequestHandler_19d4671073be.service(Unknown Source)
    at org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:105)
    at org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:95)
    at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:83)
    at org.apache.tapestry5.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:119)
    at $RequestHandler_19d4671073be.service(Unknown Source)
    at $RequestHandler_19d4671073b2.service(Unknown Source)
    at org.apache.tapestry5.modules.TapestryModule$HttpServletRequestHandlerTerminator.service(TapestryModule.java:256)
    at org.apache.tapestry5.internal.gzip.GZipFilter.service(GZipFilter.java:59)
    at $HttpServletRequestHandler_19d4671073b4.service(Unknown Source)
    at org.apache.tapestry5.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java:62)
    at $HttpServletRequestFilter_19d4671073af.service(Unknown Source)
    at $HttpServletRequestHandler_19d4671073b4.service(Unknown Source)
    at org.apache.tapestry5.modules.TapestryModule$1.service(TapestryModule.java:796)
    at $HttpServletRequestHandler_19d4671073b4.service(Unknown Source)
    at $HttpServletRequestHandler_19d4671073ae.service(Unknown Source)
    at org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:166)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
    at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
</code>```

There's a Hibernate error in my logs that I hadn't seen before, either, but I might have missed it earlier:

```<code>[INFO] InternalModule.PageLoader Loaded page 'core/PropertyEditBlocks' (en) in 78.808 ms
[INFO] AppModule.TimingFilter Request time: 2435 ms
[ERROR] Error for /customers
java.lang.NoSuchMethodError: org.hibernate.Session.close()Ljava/sql/Connection;
    at org.apache.tapestry5.internal.hibernate.HibernateSessionManagerImpl.threadDidCleanup(HibernateSessionManagerImpl.java:71)
    at org.apache.tapestry5.ioc.internal.services.PerthreadManagerImpl$2.run(PerthreadManagerImpl.java:107)
    at org.apache.tapestry5.ioc.internal.services.PerthreadManagerImpl.cleanup(PerthreadManagerImpl.java:135)
    at org.apache.tapestry5.ioc.internal.RegistryImpl.cleanupThread(RegistryImpl.java:522)
    at org.apache.tapestry5.ioc.internal.RegistryWrapper.cleanupThread(RegistryWrapper.java:39)
    at org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:175)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
    at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
</code>```

答:
The answer was removing hibernate-java8 from my dependencies.

-        <dependency>
-                       <groupId>org.hibernate</groupId>
-                       <artifactId>hibernate-java8</artifactId>
-                       <version>5.1.0.Final</version>
-        </dependency>

Body:
I had a perfectly good Tapestry 5.4 app going last night, and after committing some work and switching to another branch, I started getting a random/transient error I hadn't seen before: a 500 error that only comes up some times, when accessing some pages.

It never happens when I reload the page using a browser command, but weirdly it will happen if I click the nav item for the page or click the nav links for other pages, and subsequent reloads will clear it.

One clue is that this didn't happen before I committed a bunch of work to a branch, then checked out another branch, and merged my new branch in.

HTTP ERROR 500

Problem accessing /inventory. Reason:

    Method org.apache.tapestry5.internal.services.EnvironmentImpl.stackFor(EnvironmentImpl.java:47) may no longer be invoked.
Caused by:

java.lang.IllegalStateException: Method org.apache.tapestry5.internal.services.EnvironmentImpl.stackFor(EnvironmentImpl.java:47) may no longer be invoked.
    at org.apache.tapestry5.ioc.internal.util.OneShotLock.innerCheck(OneShotLock.java:58)
    at org.apache.tapestry5.ioc.internal.util.OneShotLock.check(OneShotLock.java:37)
    at org.apache.tapestry5.internal.services.EnvironmentImpl.stackFor(EnvironmentImpl.java:47)
    at org.apache.tapestry5.internal.services.EnvironmentImpl.push(EnvironmentImpl.java:111)
    at $Environment_19d467107466.push(Unknown Source)
    at $Environment_19d467107398.push(Unknown Source)
    at org.apache.tapestry5.modules.TapestryModule$25.renderMarkup(TapestryModule.java:1746)
    at $MarkupRenderer_19d467107465.renderMarkup(Unknown Source)
    at org.apache.tapestry5.internal.services.javascript.AddBrowserCompatibilityStyles.renderMarkup(AddBrowserCompatibilityStyles.java:45)
    at $MarkupRenderer_19d467107465.renderMarkup(Unknown Source)
    at org.apache.tapestry5.internal.services.javascript.ConfigureHTMLElementFilter.renderMarkup(ConfigureHTMLElementFilter.java:45)
    at $MarkupRenderer_19d467107465.renderMarkup(Unknown Source)
    at $MarkupRenderer_19d467107461.renderMarkup(Unknown Source)
    at org.apache.tapestry5.internal.services.PageMarkupRendererImpl.renderPageMarkup(PageMarkupRendererImpl.java:47)
    at $PageMarkupRenderer_19d46710745f.renderPageMarkup(Unknown Source)
    at org.apache.tapestry5.internal.services.PageResponseRendererImpl.renderPageResponse(PageResponseRendererImpl.java:64)
    at $PageResponseRenderer_19d4671073fa.renderPageResponse(Unknown Source)
    at org.apache.tapestry5.internal.services.DefaultRequestExceptionHandler.renderException(DefaultRequestExceptionHandler.java:262)
    at org.apache.tapestry5.internal.services.DefaultRequestExceptionHandler.handleRequestException(DefaultRequestExceptionHandler.java:145)
    at $RequestExceptionHandler_19d4671073bc.handleRequestException(Unknown Source)
    at org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:42)
    at $RequestHandler_19d4671073be.service(Unknown Source)
    at org.apache.tapestry5.modules.TapestryModule$3.service(TapestryModule.java:846)
    at $RequestHandler_19d4671073be.service(Unknown Source)
    at org.apache.tapestry5.modules.TapestryModule$2.service(TapestryModule.java:836)
    at $RequestHandler_19d4671073be.service(Unknown Source)
    at org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:89)
    at $RequestHandler_19d4671073be.service(Unknown Source)
    at edu.colostate.cs.cs414.project.jzw.webui.services.AppModule$1.service(AppModule.java:118)
    at $RequestFilter_19d4671073b8.service(Unknown Source)
    at $RequestHandler_19d4671073be.service(Unknown Source)
    at org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:105)
    at org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:95)
    at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:83)
    at org.apache.tapestry5.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:119)
    at $RequestHandler_19d4671073be.service(Unknown Source)
    at $RequestHandler_19d4671073b2.service(Unknown Source)
    at org.apache.tapestry5.modules.TapestryModule$HttpServletRequestHandlerTerminator.service(TapestryModule.java:256)
    at org.apache.tapestry5.internal.gzip.GZipFilter.service(GZipFilter.java:59)
    at $HttpServletRequestHandler_19d4671073b4.service(Unknown Source)
    at org.apache.tapestry5.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java:62)
    at $HttpServletRequestFilter_19d4671073af.service(Unknown Source)
    at $HttpServletRequestHandler_19d4671073b4.service(Unknown Source)
    at org.apache.tapestry5.modules.TapestryModule$1.service(TapestryModule.java:796)
    at $HttpServletRequestHandler_19d4671073b4.service(Unknown Source)
    at $HttpServletRequestHandler_19d4671073ae.service(Unknown Source)
    at org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:166)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
    at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

There's a Hibernate error in my logs that I hadn't seen before, either, but I might have missed it earlier:

[INFO] InternalModule.PageLoader Loaded page 'core/PropertyEditBlocks' (en) in 78.808 ms
[INFO] AppModule.TimingFilter Request time: 2435 ms
[ERROR] Error for /customers
java.lang.NoSuchMethodError: org.hibernate.Session.close()Ljava/sql/Connection;
    at org.apache.tapestry5.internal.hibernate.HibernateSessionManagerImpl.threadDidCleanup(HibernateSessionManagerImpl.java:71)
    at org.apache.tapestry5.ioc.internal.services.PerthreadManagerImpl$2.run(PerthreadManagerImpl.java:107)
    at org.apache.tapestry5.ioc.internal.services.PerthreadManagerImpl.cleanup(PerthreadManagerImpl.java:135)
    at org.apache.tapestry5.ioc.internal.RegistryImpl.cleanupThread(RegistryImpl.java:522)
    at org.apache.tapestry5.ioc.internal.RegistryWrapper.cleanupThread(RegistryWrapper.java:39)
    at org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:175)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
    at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)


问:
Oracle query for merging multiple rows groupped by id and ordered by date
I need help for writing view for this SQLFiddle. For now data looks like:

```<code>SERIALNUMBER | INSERTDATE           | PARAM1 | PARAM2 | PARAM3 | PARAM4 | PARAM5
3456         | 2017-11-15T12:00:54Z | (null) | (null) | (null) | (null) |  17
3456         | 2017-11-15T12:01:03Z | (null) | (null) |    2   | (null) | (null)
3456         | 2017-11-15T12:07:16Z | (null) | (null) | (null) |    7   | (null)
3456         | 2017-11-15T12:08:08Z | (null) | (null) | (null) | (null) |  19
3456         | 2017-11-15T12:11:32Z |   abc  | (null) | (null) | (null) | (null)
12           | 2017-11-15T12:00:50Z | (null) |    4   | (null) | (null) | (null)
12           | 2017-11-15T12:01:03Z | (null) |    7   | (null) | (null) | (null)
12           | 2017-11-15T12:07:03Z | (null) | (null) | (null) |   te   | (null)
</code>```

The result which I want to receive is data groupped by serialnumber when if there are more columns with not null data groupping should pick newest:

```<code>SERIALNUMBER | INSERTDATE           | PARAM1 | PARAM2 | PARAM3 | PARAM4 | PARAM5
3456         | 2017-11-15T12:00:54Z |   abc  | (null) |    2   |    7   |  19
12           | 2017-11-15T12:00:50Z | (null) |    7   | (null) |   te   | (null)
</code>```

Thanks a lot for any help

答:
You haven't specified the exact rule for this, so I'm guessing you want the maximum value.  If so, this is a simple aggregation:

```<code>select serialnumber, min(InsertDate) as InsertDate,
       max(Param1) as Param1,
       max(Param2) as Param2,
       max(Param3) as Param3,
       max(Param4) as Param4,
       max(Param5) as Param5
from sample
group by serialnumber
order by InsertDate desc;
</code>```

Here is the SQL Fiddle.

I see, the OP does specify that the newest non-NULL value is to be chosen.

In that case:

```<code>select serialnumber, min(InsertDate) as InsertDate,
       max(Param1) keep (dense_rank first order by nvl2(Param1, 1, 2), InsertDate desc) as Param1,
       max(Param2) keep (dense_rank first order by nvl2(Param2, 1, 2), InsertDate desc) as Param2,
       max(Param3) keep (dense_rank first order by nvl2(Param3, 1, 2), InsertDate desc) as Param3,
       max(Param4) keep (dense_rank first order by nvl2(Param4, 1, 2), InsertDate desc) as Param4,
       max(Param5) keep (dense_rank first order by nvl2(Param5, 1, 2), InsertDate desc) as Param5
from sample
group by serialnumber
order by InsertDate desc;
</code>```

And the corresponding SQL Fiddle.

Body:
I need help for writing view for this SQLFiddle. For now data looks like:

SERIALNUMBER | INSERTDATE           | PARAM1 | PARAM2 | PARAM3 | PARAM4 | PARAM5
3456         | 2017-11-15T12:00:54Z | (null) | (null) | (null) | (null) |  17
3456         | 2017-11-15T12:01:03Z | (null) | (null) |    2   | (null) | (null)
3456         | 2017-11-15T12:07:16Z | (null) | (null) | (null) |    7   | (null)
3456         | 2017-11-15T12:08:08Z | (null) | (null) | (null) | (null) |  19
3456         | 2017-11-15T12:11:32Z |   abc  | (null) | (null) | (null) | (null)
12           | 2017-11-15T12:00:50Z | (null) |    4   | (null) | (null) | (null)
12           | 2017-11-15T12:01:03Z | (null) |    7   | (null) | (null) | (null)
12           | 2017-11-15T12:07:03Z | (null) | (null) | (null) |   te   | (null)

The result which I want to receive is data groupped by serialnumber when if there are more columns with not null data groupping should pick newest:

SERIALNUMBER | INSERTDATE           | PARAM1 | PARAM2 | PARAM3 | PARAM4 | PARAM5
3456         | 2017-11-15T12:00:54Z |   abc  | (null) |    2   |    7   |  19
12           | 2017-11-15T12:00:50Z | (null) |    7   | (null) |   te   | (null)

Thanks a lot for any help

Body:
You haven't specified the exact rule for this, so I'm guessing you want the maximum value.  If so, this is a simple aggregation:

select serialnumber, min(InsertDate) as InsertDate,
       max(Param1) as Param1,
       max(Param2) as Param2,
       max(Param3) as Param3,
       max(Param4) as Param4,
       max(Param5) as Param5
from sample
group by serialnumber
order by InsertDate desc;

Here is the SQL Fiddle.

I see, the OP does specify that the newest non-NULL value is to be chosen.

In that case:

select serialnumber, min(InsertDate) as InsertDate,
       max(Param1) keep (dense_rank first order by nvl2(Param1, 1, 2), InsertDate desc) as Param1,
       max(Param2) keep (dense_rank first order by nvl2(Param2, 1, 2), InsertDate desc) as Param2,
       max(Param3) keep (dense_rank first order by nvl2(Param3, 1, 2), InsertDate desc) as Param3,
       max(Param4) keep (dense_rank first order by nvl2(Param4, 1, 2), InsertDate desc) as Param4,
       max(Param5) keep (dense_rank first order by nvl2(Param5, 1, 2), InsertDate desc) as Param5
from sample
group by serialnumber
order by InsertDate desc;

And the corresponding SQL Fiddle.


问:
How to create symboic link from Azure Linux M to Azure file storage
I want to create a symbolic link. the mount point is Azure Linux VM and the target is azure storage. I have used the following command to create the symbolic link:

```<code>sudo mount -t cifs //<accout name>.file.core.windows.net/<share name> [mount point] -o vers=3.0,username=<username>,password=<pwd>,dir_mode=0777,file_mode=0777,sec=ntlmssp
</code>```

But getting following:

```<code>mount error(11): Resource temporarily unavailable
</code>```

dmesg | tail gives:

```<code>CIFS VFS: Server eassmbstorageaccount.file.core.windows.net has not responded in 120 seconds. Reconnecting...
CIFS VFS: cifs_mount failed w/return code = -11
</code>```

答:
We can mount Azure file share to Linux VM like this:

Ubuntu:

1.install cifs-utils

```<code> sudo apt-get update
 sudo apt-get install cifs-utils
</code>```

2.create a folder for the mount point:

```<code>mkdir mymountpoint
</code>```

3.Use the mount command to mount the Azure file share:

```<code>sudo mount -t cifs //jasonvmdiag800.file.core.windows.net/jasonvm ./mymountpoint -o vers=2.1,username=jasonvmdiag800,password=t0gU45xhKVlCQZY3L0WYHiEcoyc1vAvKS1FZEgCZpxxrHFRg==,dir_mode=0777,file_mode=0777,serverino
</code>```

Remember to replace storage-account-name, share-name, and storage-account-key with the proper information.

```<code>sudo mount -t cifs //<storage-account-name>.file.core.windows.net/<share-name> ./mymountpoint -o vers=2.1,username=<storage-account-name>,password=<storage-account-key>,dir_mode=0777,file_mode=0777,serverino
</code>```

Note:

Azure files share requires SMB 2, Microsoft recommends the following Linux distributions:

```<code>Ubuntu Server 14.04+
RHEL 7+
CentOS 7+
Debian 8
openSUSE 13.2+
SUSE Linux Enterprise Server 12
</code>```

More information about mount Azure file share, please refer to this link.

By the way, please check is there another cifs share mounted, and check that share state. Also you can remove all mount files and remount.

Body:
I want to create a symbolic link. the mount point is Azure Linux VM and the target is azure storage. I have used the following command to create the symbolic link:

sudo mount -t cifs //<accout name>.file.core.windows.net/<share name> [mount point] -o vers=3.0,username=<username>,password=<pwd>,dir_mode=0777,file_mode=0777,sec=ntlmssp

But getting following:

mount error(11): Resource temporarily unavailable

dmesg | tail gives:

CIFS VFS: Server eassmbstorageaccount.file.core.windows.net has not responded in 120 seconds. Reconnecting...
CIFS VFS: cifs_mount failed w/return code = -11

Body:
We can mount Azure file share to Linux VM like this:

Ubuntu:

1.install cifs-utils

 sudo apt-get update
 sudo apt-get install cifs-utils

2.create a folder for the mount point:

mkdir mymountpoint

3.Use the mount command to mount the Azure file share:

sudo mount -t cifs //jasonvmdiag800.file.core.windows.net/jasonvm ./mymountpoint -o vers=2.1,username=jasonvmdiag800,password=t0gU45xhKVlCQZY3L0WYHiEcoyc1vAvKS1FZEgCZpxxrHFRg==,dir_mode=0777,file_mode=0777,serverino

Remember to replace storage-account-name, share-name, and storage-account-key with the proper information.

sudo mount -t cifs //<storage-account-name>.file.core.windows.net/<share-name> ./mymountpoint -o vers=2.1,username=<storage-account-name>,password=<storage-account-key>,dir_mode=0777,file_mode=0777,serverino

Note:

Azure files share requires SMB 2, Microsoft recommends the following Linux distributions:

Ubuntu Server 14.04+
RHEL 7+
CentOS 7+
Debian 8
openSUSE 13.2+
SUSE Linux Enterprise Server 12

More information about mount Azure file share, please refer to this link.

By the way, please check is there another cifs share mounted, and check that share state. Also you can remove all mount files and remount.


问:
Trying to parse XML file with
 tags
I have been trying to parse the contents of an XML file using PowerShell and have I have made some decent progress, but I ran into something I cant find an answer to. I hope someone can point me in the right direction or help me understand how to get the value of some content in my XML which is contained within some P tags. Here is an example of my XML file;

<?xml version="1.0"?>
<HVD version="2.0">
<Environment>

10

258

</Environment>
</HVD>
```

<p>I can get the Name label in <code><Environment></code> to show up by using the following, but I cannot figure out how to get the values from the <code><p></code> tags themselves;</p>

<pre class="lang-bsh prettyprint-override"><code>[xml]$xml = Get-Content myFile.xml;
$xml.HVD.Environment;
</code>```

Can anyone help out a beginner here?

答:
try this:

```<code>[xml]$xml = get-content myfile.xml
$Version=($xml.HVD.Environment.P | where Name -eq 'version')."#text"
$ID=($xml.HVD.Environment.P | where Name -eq 'ID')."#text"
</code>```

or this

```<code>$Version=$xml.HVD.Environment.P[0]."#text";
$ID=$xml.HVD.Environment.P[1]."#text";
</code>```

Title: Trying to parse XML file with <p> tags

Body:
I have been trying to parse the contents of an XML file using PowerShell and have I have made some decent progress, but I ran into something I cant find an answer to. I hope someone can point me in the right direction or help me understand how to get the value of some content in my XML which is contained within some P tags. Here is an example of my XML file;

<?xml version="1.0"?>
<HVD version="2.0">
<Environment>

10

258

</Environment>
</HVD>

I can get the Name label in <Environment> to show up by using the following, but I cannot figure out how to get the values from the
 tags themselves;

[xml]$xml = Get-Content myFile.xml;
$xml.HVD.Environment;

Can anyone help out a beginner here?

Body:
try this:

[xml]$xml = get-content myfile.xml
$Version=($xml.HVD.Environment.P | where Name -eq 'version')."#text"
$ID=($xml.HVD.Environment.P | where Name -eq 'ID')."#text"

or this

$Version=$xml.HVD.Environment.P[0]."#text";
$ID=$xml.HVD.Environment.P[1]."#text";