问:
Get-ADComputer -filter * -property $Variable
Really baffled by this one. I have a Windows form with checkboxes based on AD attribute names. Once OK I run:

```<code>$ADVARIABLES = @()
Get-Variable -Name OBJ* | ?{ $_.Value.Checkstate -eq 1  } | %{ $ADVARIABLES += $_.Value.Name }
</code>```

To get the attribute names.

If I run:

```<code>Get-ADUser -Filter * -Property $ADVARIABLES | select $ADVARIABLES
</code>```

I get the kind of results I'd expect to see.

If I run:

```<code>Get-ADComputer -Filter * -Property $ADVARIABLES | select $ADVARIABLES
</code>```

I get:

Get-ADComputer : Cannot validate argument on parameter 'Properties'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again.

The attributes on my checkboxes for Get-AdUser include:

Mail, Manager, Department, Title, CanonicalName, Phone, Mobile, HomeDirectory

The attributes for PC are:

SamAccountName, CanonicalName, IPv4Address, Enabled, OperatingSystem

Any ideas? There's definitely no rogue attribute on the $ADVARIABLES tag, it's just being a royal pain in the bum.

EDIT:

Here's the script in full. Working fine for AD Users, not for Computers:

```# Adds .NET assemby's and turns on visual themes in standard PowerShell.
Add-Type -AssemblyName System.Drawing
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Application]::EnableVisualStyles()

# Creates the parent form
$ADREPORT               = New-Object System.Windows.Forms.Form
$ADREPORT.Location      = New-Object System.Drawing.Size( 270,175 )
$ADREPORT.Size          = New-Object System.Drawing.Size( 800,400 )
$ADREPORT.StartPosition = "CenterScreen"
$ADREPORT.BackColor     = "Lavender"
$ADREPORT.Font          = "Calibri, 8.5"

# This creates a label for the title
$ADHEADER               = New-Object System.Windows.Forms.Label
$ADHEADER.Location      = New-Object System.Drawing.Size( 30,20 )
$ADHEADER.Size          = New-Object System.Drawing.Size( 180,20 )
$ADHEADER.Font          = New-Object System.Drawing.Font( "Calibri",11,[System.Drawing.FontStyle]::Bold )
$ADHEADER.Text          = "Choose your attributes"
$ADREPORT.Controls.Add( $ADHEADER )

# This creates a label for the sub-header
$ADTEXT                 = New-Object System.Windows.Forms.Label
$ADTEXT.Location        = New-Object System.Drawing.Size( 30,50 )
$ADTEXT.Size            = New-Object System.Drawing.Size( 300,40 )
$ADTEXT.Text            = "From the list below, select as many attributes as you like to generate a CSV report:"
$ADREPORT.Controls.Add( $ADTEXT )

# Active Directory Users label
$OBJUSERTXT             = New-Object System.Windows.Forms.Label
$OBJUSERTXT.Location    = New-Object System.Drawing.Size( 20,100 )
$OBJUSERTXT.Size        = New-Object System.Drawing.Size( 80,20 )
$OBJUSERTXT.Text        = "USERS:"
$ADREPORT.Controls.Add( $OBJUSERTXT )

# Active Directory Users checkbox - Checked by default
$USERBOX                = New-Object System.Windows.Forms.Checkbox
$USERBOX.Location       = New-Object System.Drawing.Size( 100,98 )
$USERBOX.Size           = New-Object System.Drawing.Size( 20,20 )
$USERBOX.TabIndex       = 0
$USERBOX.Checked        = $TRUE
$ADREPORT.Controls.Add( $USERBOX )

# Active Directory Computers label
$PCXT                   = New-Object System.Windows.Forms.Label
$PCXT.Location          = New-Object System.Drawing.Size( 150,100 )
$PCXT.Size              = New-Object System.Drawing.Size( 80,20 )
$PCXT.Text              = "COMPUTERS:"
$ADREPORT.Controls.Add( $PCXT )

# Active Directory Computers checkbox
$OBJPCBOX               = New-Object System.Windows.Forms.Checkbox
$OBJPCBOX.Location      = New-Object System.Drawing.Size( 230,98 )
$OBJPCBOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJPCBOX.TabIndex      = 9
$ADREPORT.Controls.Add( $OBJPCBOX )

# SamAccountName label
$OBJ01TXT               = New-Object System.Windows.Forms.Label
$OBJ01TXT.Location      = New-Object System.Drawing.Size( 20,120 )
$OBJ01TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ01TXT.Text          = "Username:"
$ADREPORT.Controls.Add( $OBJ01TXT )

# SamAccountName checkbox
$OBJ01BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ01BOX.Location      = New-Object System.Drawing.Size( 100,118 )
$OBJ01BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ01BOX.TabIndex      = 1
$OBJ01BOX.Checked       = $TRUE
$OBJ01BOX.Name          = "SamAccountName"
$ADREPORT.Controls.Add( $OBJ01BOX )

# Full Name label
$OBJ02TXT               = New-Object System.Windows.Forms.Label
$OBJ02TXT.Location      = New-Object System.Drawing.Size( 20,140 )
$OBJ02TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ02TXT.Text          = "Full name:"
$ADREPORT.Controls.Add( $OBJ02TXT )

# Full Name checkbox
$OBJ02BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ02BOX.Location      = New-Object System.Drawing.Size( 100,138 )
$OBJ02BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ02BOX.TabIndex      = 2
$OBJ02BOX.Name          = "Name"
$ADREPORT.Controls.Add( $OBJ02BOX )

# First Name label
$OBJ03TXT               = New-Object System.Windows.Forms.Label
$OBJ03TXT.Location      = New-Object System.Drawing.Size( 20,160 )
$OBJ03TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ03TXT.Text          = "First name:"
$ADREPORT.Controls.Add( $OBJ03TXT )

# First Name checkbox
$OBJ03BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ03BOX.Location      = New-Object System.Drawing.Size( 100,158 )
$OBJ03BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ03BOX.TabIndex      = 3
$OBJ03BOX.Name          = "GivenName"
$ADREPORT.Controls.Add( $OBJ03BOX )

# Surname label
$OBJ04TXT               = New-Object System.Windows.Forms.Label
$OBJ04TXT.Location      = New-Object System.Drawing.Size( 20,180 )
$OBJ04TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ04TXT.Text          = "Surname:"
$ADREPORT.Controls.Add( $OBJ04TXT )

# Surname checkbox
$OBJ04BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ04BOX.Location      = New-Object System.Drawing.Size( 100,178 )
$OBJ04BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ04BOX.TabIndex      = 4
$OBJ04BOX.Name          = "Surname"
$ADREPORT.Controls.Add( $OBJ04BOX )

# Department label
$OBJ05TXT               = New-Object System.Windows.Forms.Label
$OBJ05TXT.Location      = New-Object System.Drawing.Size( 20,200 )
$OBJ05TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ05TXT.Text          = "Department:"
$ADREPORT.Controls.Add( $OBJ05TXT )

# Department checkbox
$OBJ05BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ05BOX.Location      = New-Object System.Drawing.Size( 100,198 )
$OBJ05BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ05BOX.TabIndex      = 5
$OBJ05BOX.Name          = "Department"
$ADREPORT.Controls.Add( $OBJ05BOX )

# Job Title label
$OBJ06TXT               = New-Object System.Windows.Forms.Label
$OBJ06TXT.Location      = New-Object System.Drawing.Size( 20,220 )
$OBJ06TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ06TXT.Text          = "Job Title:"
$ADREPORT.Controls.Add( $OBJ06TXT )

# Job Title checkbox
$OBJ06BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ06BOX.Location      = New-Object System.Drawing.Size( 100,218 )
$OBJ06BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ06BOX.TabIndex      = 6
$OBJ06BOX.Name          = "Title"
$ADREPORT.Controls.Add( $OBJ06BOX )

# Manager Label
$OBJ07TXT               = New-Object System.Windows.Forms.Label
$OBJ07TXT.Location      = New-Object System.Drawing.Size( 20,240 )
$OBJ07TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ07TXT.Text          = "Manager:"
$ADREPORT.Controls.Add( $OBJ07TXT )

# Manager checkbox
$OBJ07BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ07BOX.Location      = New-Object System.Drawing.Size( 100,238 )
$OBJ07BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ07BOX.TabIndex      = 7
$OBJ07BOX.Name          = "Manager"
$ADREPORT.Controls.Add( $OBJ07BOX )

# IP Address label
$OBJ18TXT               = New-Object System.Windows.Forms.Label
$OBJ18TXT.Location      = New-Object System.Drawing.Size( 20,280 )
$OBJ18TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ18TXT.Text          = "IP Address:"
$ADREPORT.Controls.Add( $OBJ18TXT )

# IP Address checkbox
$OBJ18BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ18BOX.Location      = New-Object System.Drawing.Size( 100,278 )
$OBJ18BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ18BOX.TabIndex      = 19
$OBJ18BOX.Name          = "IPv4Address"
$OBJ18BOX.Enabled       = $FALSE
$ADREPORT.Controls.Add( $OBJ18BOX )

# Home Drive Label
$OBJ09TXT               = New-Object System.Windows.Forms.Label
$OBJ09TXT.Location      = New-Object System.Drawing.Size( 150,120 )
$OBJ09TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ09TXT.Text          = "Home Drive:"
$ADREPORT.Controls.Add( $OBJ09TXT )

# Home Drive Checkbox
$OBJ09BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ09BOX.Location      = New-Object System.Drawing.Size( 230,118 )
$OBJ09BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ09BOX.TabIndex      = 10
$OBJ09BOX.Name          = "HomeDirectory"
$ADREPORT.Controls.Add( $OBJ09BOX )

# Email label
$OBJ10TXT               = New-Object System.Windows.Forms.Label
$OBJ10TXT.Location      = New-Object System.Drawing.Size( 150,140 )
$OBJ10TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ10TXT.Text          = "Email:"
$ADREPORT.Controls.Add( $OBJ10TXT )

# Email checkbox
$OBJ10BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ10BOX.Location      = New-Object System.Drawing.Size( 230,138 )
$OBJ10BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ10BOX.TabIndex      = 11
$OBJ10BOX.Name          = "Mail"
$ADREPORT.Controls.Add( $OBJ10BOX )

# Phone label
$OBJ11TXT               = New-Object System.Windows.Forms.Label
$OBJ11TXT.Location      = New-Object System.Drawing.Size( 150,160 )
$OBJ11TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ11TXT.Text          = "Phone:"
$ADREPORT.Controls.Add( $OBJ11TXT )

# Phone checkbox
$OBJ11BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ11BOX.Location      = New-Object System.Drawing.Size( 230,158 )
$OBJ11BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ11BOX.TabIndex      = 12
$OBJ11BOX.Name          = "OfficePhone"
$ADREPORT.Controls.Add( $OBJ11BOX )

# Mobile phone label
$OBJ12TXT               = New-Object System.Windows.Forms.Label
$OBJ12TXT.Location      = New-Object System.Drawing.Size( 150,180 )
$OBJ12TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ12TXT.Text          = "Mobile:"
$ADREPORT.Controls.Add( $OBJ12TXT )

# Mobile phone checkbox
$OBJ12BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ12BOX.Location      = New-Object System.Drawing.Size( 230,178 )
$OBJ12BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ12BOX.TabIndex      = 13
$OBJ12BOX.Name          = "MobilePhone"
$ADREPORT.Controls.Add( $OBJ12BOX )

# Created label
$OBJ13TXT               = New-Object System.Windows.Forms.Label
$OBJ13TXT.Location      = New-Object System.Drawing.Size( 150,200 )
$OBJ13TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ13TXT.Text          = "Creation Date:"
$ADREPORT.Controls.Add( $OBJ13TXT )

# Created checkbox
$OBJ13BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ13BOX.Location      = New-Object System.Drawing.Size( 230,198 )
$OBJ13BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ13BOX.TabIndex      = 14
$OBJ13BOX.Name          = "Created"
$ADREPORT.Controls.Add( $OBJ13BOX )

# Modified label
$OBJ14TXT               = New-Object System.Windows.Forms.Label
$OBJ14TXT.Location      = New-Object System.Drawing.Size( 150,220 )
$OBJ14TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ14TXT.Text          = "Modified Date:"
$ADREPORT.Controls.Add( $OBJ14TXT )

# Modified checkbox
$OBJ14BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ14BOX.Location      = New-Object System.Drawing.Size( 230,218 )
$OBJ14BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ14BOX.TabIndex      = 15
$OBJ14BOX.Name          = "Modified"
$ADREPORT.Controls.Add( $OBJ14BOX )

# Password label
$OBJ15TXT               = New-Object System.Windows.Forms.Label
$OBJ15TXT.Location      = New-Object System.Drawing.Size( 150,240 )
$OBJ15TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ15TXT.Text          = "Password Set:"
$ADREPORT.Controls.Add( $OBJ15TXT )

# Password checkbox
$OBJ15BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ15BOX.Location      = New-Object System.Drawing.Size( 230,238 )
$OBJ15BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ15BOX.TabIndex      = 16
$OBJ15BOX.Name          = "PasswordLastSet"
$ADREPORT.Controls.Add( $OBJ15BOX )

# Enabled label
$OBJ08TXT               = New-Object System.Windows.Forms.Label
$OBJ08TXT.Location      = New-Object System.Drawing.Size( 150,260 )
$OBJ08TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ08TXT.Text          = "Enabled Status:"
$ADREPORT.Controls.Add( $OBJ08TXT )

# Enable checkbox
$OBJ08BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ08BOX.Location      = New-Object System.Drawing.Size( 230,258 )
$OBJ08BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ08BOX.TabIndex      = 17
$OBJ08BOX.Name          = "Enabled"
$ADREPORT.Controls.Add( $OBJ08BOX )

#This creates a label for the 18th attribute - Operating System
$OBJ17TXT               = New-Object System.Windows.Forms.Label
$OBJ17TXT.Location      = New-Object System.Drawing.Size( 150,280 )
$OBJ17TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ17TXT.Text          = "OS:"
$ADREPORT.Controls.Add( $OBJ17TXT )

#This creates the checkbox for the 18th attribute - Operating System
$OBJ17BOX               = New-Object System.Windows.Forms.Checkbox
 $OBJ17BOX.Location     = New-Object System.Drawing.Size( 230,278 )
$OBJ17BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ17BOX.TabIndex      = 18
 $OBJ17BOX.Name         = "OperatingSystem"
 $OBJ17BOX.Enabled      = $FALSE
$ADREPORT.Controls.Add( $OBJ17BOX )

# OU Label
$OBJ16TXT               = New-Object System.Windows.Forms.Label
$OBJ16TXT.Location      = New-Object System.Drawing.Size( 20,260 )
$OBJ16TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ16TXT.Text          = "OU:"
$ADREPORT.Controls.Add( $OBJ16TXT )

# OU Checkbox
$OBJ16BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ16BOX.Location      = New-Object System.Drawing.Size( 100,258 )
$OBJ16BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ16BOX.TabIndex      = 8
$OBJ16BOX.Name          = "CanonicalName"
$ADREPORT.Controls.Add( $OBJ16BOX )

# OK Button
$OK                     = New-Object System.Windows.Forms.Button
$OK.Location            = New-Object System.Drawing.Size( 30,315 )
$OK.Size                = New-Object System.Drawing.Size( 75,23 )
$OK.ForeColor           = "Green"
$OK.Text                = "OK"
$OK.DialogResult        = "OK"
$OK.add_Click( { $ADREPORT.Close() } )
$ADREPORT.Controls.Add( $OK )

# Cancel button
$CANCEL                 = New-Object System.Windows.Forms.Button
$CANCEL.Location        = New-Object System.Drawing.Point( 160,315 )
$CANCEL.Size            = New-Object System.Drawing.Size( 75,23 )
$CANCEL.ForeColor       = "Red"
$CANCEL.Text            = "Cancel"
$CANCEL.DialogResult    = "Cancel"
$ADREPORT.Controls.Add( $CANCEL )

# If PC checkbox ticked, grey out user specific attributes
$OBJPCBOX.Add_CheckStateChanged( {
IF ( $OBJPCBOX.Checked )
     { $USERBOX.Checked    = $FALSE                                  # AD User box
         $OBJ02BOX.Enabled = $FALSE ; $OBJ02BOX.Checked = $FALSE     # Full name
         $OBJ03BOX.Enabled = $FALSE ; $OBJ03BOX.Checked = $FALSE     # First name
         $OBJ04BOX.Enabled = $FALSE ; $OBJ04BOX.Checked = $FALSE     # Surname
         $OBJ05BOX.Enabled = $FALSE ; $OBJ05BOX.Checked = $FALSE     # Department
         $OBJ06BOX.Enabled = $FALSE ; $OBJ06BOX.Checked = $FALSE     # Job Title
         $OBJ07BOX.Enabled = $FALSE ; $OBJ07BOX.Checked = $FALSE     # Manager
         $OBJ09BOX.Enabled = $FALSE ; $OBJ09BOX.Checked = $FALSE     # HomeDirectory
         $OBJ10BOX.Enabled = $FALSE ; $OBJ10BOX.Checked = $FALSE     # Mail
         $OBJ11BOX.Enabled = $FALSE ; $OBJ11BOX.Checked = $FALSE     # Phone
         $OBJ12BOX.Enabled = $FALSE ; $OBJ12BOX.Checked = $FALSE     # Mobile
         $OBJ17BOX.Enabled = $TRUE  ; $OBJ18BOX.Enabled = $TRUE }    # OS & IP Address

# IF User box ticked, untick PC box and un-grey user specific attributes
IF ( $OBJPCBOX.Checked -eq $FALSE )
     { $USERBOX.Checked    = $TRUE  ; $OBJ02BOX.Enabled = $TRUE
         $OBJ03BOX.Enabled = $TRUE  ; $OBJ04BOX.Enabled = $TRUE
         $OBJ05BOX.Enabled = $TRUE  ; $OBJ06BOX.Enabled = $TRUE
         $OBJ07BOX.Enabled = $TRUE  ; $OBJ09BOX.Enabled = $TRUE
         $OBJ10BOX.Enabled = $TRUE  ; $OBJ11BOX.Enabled = $TRUE
         $OBJ12BOX.Enabled = $TRUE
         $OBJ17BOX.Enabled = $FALSE ; $OBJ18BOX.Enabled = $FALSE }

} ) # CLOSES $OBJPCBOX.Add_CheckStateChanged( {

# IF user box ticked, untick PC box
$USERBOX.Add_CheckStateChanged( {
IF ( $USERBOX.Checked -eq $TRUE )
     { $OBJPCBOX.Checked = $FALSE } } )

# Launch the checkbox form.
$ADREPORT.Add_Shown( { $ADREPORT.Activate() } )

# When you've pressed ok...

# /// If you choose ADUsers then first create two empty variables; populate $ADVAIRABLES with the name of each checkbox
#         ticked.
#         Perform an unfiltered search of Active Directory users and select just the attributes from the checkboxes. This
#         is measured for visual feedback.
#         If the Manager attribute is checked, this comes back in DN form ( CN=Graham Jordan,OU=Users,DC=DOMAIN,DC=LOCAL ),
#         so run a Get-Aduser against each DN to bring back the full name.
#         The manager conversion is wrapped up in Write-Progress to give you a visual impression of how far into the change,
#         since this takes a while.
#         If the OU attribute is ticked ( CanonicalName ), then run a replace on each line to remove the domain name, and
#         the users full name leaving just Users/...
#         Finally exports a CSV to your user profile in "AD Report for Users - 28 02 2018 - 12.45.csv" format.

IF ( ( $ADREPORT.ShowDialog() ) -eq "OK" )
   { IF ( $USERBOX.Checked )
        { $ADVARIABLES = @()
          $USERS             = @()

          Write-Host "Performing a search of all users on Active Directory. This part can take a minute or so" -f Green ; ""
          Get-Variable -Name OBJ* | ?{ $_.Value.Checkstate -eq 1    } | %{ $ADVARIABLES += $_.Value.Name }

          $SECONDS = ( Measure-Command {
          $USERS    += Get-ADUser -Filter * -Property $ADVARIABLES | select $ADVARIABLES | sort Name } ).seconds

          Write-Host $USERS.Count user accounts identified in $SECONDS seconds. -f Green ; ""

          IF ( $USERS.Manager -notlike $NULL )
             { $USERS | foreach-object -begin { $COUNT = 0 } -process {
               $USER = $_

               IF ( $USER.Manager )
                  { $USER.Manager = ( ( Get-ADUser $USER.Manager ).Name ).ToString() }
                    $COUNT = $COUNT + 1
                    Write-Progress -Activity "Altering Manager DN's to Manager Name" -Status "Progress: $(
                    $USER.Name )" -PercentComplete ( $COUNT / $USERS.count * 100 ) } }

          IF ( $USER.CanonicalName )
             { Foreach ( $USER in $USERS )
                       { $USER.CanonicalName = $USER.CanonicalName.Substring( $USER.CanonicalName.IndexOf( "/" ) +1 )
                         $USER.CanonicalName = $USER.CanonicalName -replace "/$( $USER.Name )" } }

          $USERS | Export-Csv "$env:USERPROFILE\AD Report for Users - $( Get-Date -Format "dd MMM yyyy - hh.mm" ).csv" -NoClobber -NoTypeInformation -Force }

IF ( $OBJPCBOX.Checked )
   { $ADVARIABLES = @()
     Get-Variable -Name OBJ* | ?{ $_.Value.Checkstate -eq 1    } | %{ $ADVARIABLES += $_.Value.Name }

     Write-Host "Performing a search of all computers on Active Directory. This part can take a minute or so" -f Green ; ""

     $PCS  = @()
     $PCS += Get-ADComputer -Filter * -Properties $ADVARIABLES | select $ADVARIABLES | sort SamAccountName

     IF ( $PCS.CanonicalName )
        { Foreach ( $PC in $PCS )
                  { $PC.CanonicalName = $PC.CanonicalName.Substring( $PC.CanonicalName.IndexOf( "/" ) +1 )
                    $PC.CanonicalName = $PC.CanonicalName -replace "/$( $PC.SamAccountName )$" } }

     $PCS | Export-Csv "$env:USERPROFILE\AD Report for Computers - $( Get-Date -Format "dd MMM yyyy - hh.mm" ).csv" -NoClobber -NoTypeInformation -Force }

}
```

答:
That was annoying. GUIs are disgusting. So your issue is that if you ran the following command:

```<code>Get-ADComputer -Identity PC01 -Properties 'Created','PasswordLastSet',''
</code>```

It will throw an error because ONE of the properties is a null/empty string. You had a null/empty string in $ADVARIABLES which caused your error.

Per your script I made a modification:

```<code>Get-Variable -Name OBJ* | ?{ $_.Value.Checkstate -eq 1    } | %{
    Write-Host -Object "Adding property '$($_.Value.Name)' from $($_.Name)"
    $ADVARIABLES += $_.Value.Name
}
</code>```

This provided me with the following output:

```<code>Adding property 'SamAccountName' from OBJ01BOX
Adding property 'Created' from OBJ13BOX
Adding property 'PasswordLastSet' from OBJ15BOX
Adding property '' from OBJPCBOX
</code>```

You will need to probably rename $OBJPCBOX or create a better filter when you're populating $ADVARIABLES.

Body:
Really baffled by this one. I have a Windows form with checkboxes based on AD attribute names. Once OK I run:

$ADVARIABLES = @()
Get-Variable -Name OBJ* | ?{ $_.Value.Checkstate -eq 1  } | %{ $ADVARIABLES += $_.Value.Name }

To get the attribute names.

If I run:

Get-ADUser -Filter * -Property $ADVARIABLES | select $ADVARIABLES

I get the kind of results I'd expect to see.

If I run:

Get-ADComputer -Filter * -Property $ADVARIABLES | select $ADVARIABLES

I get:

Get-ADComputer : Cannot validate argument on parameter 'Properties'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again.

The attributes on my checkboxes for Get-AdUser include:

Mail, Manager, Department, Title, CanonicalName, Phone, Mobile, HomeDirectory

The attributes for PC are:

SamAccountName, CanonicalName, IPv4Address, Enabled, OperatingSystem

Any ideas? There's definitely no rogue attribute on the $ADVARIABLES tag, it's just being a royal pain in the bum.

EDIT:

Here's the script in full. Working fine for AD Users, not for Computers:

# Adds .NET assemby's and turns on visual themes in standard PowerShell.
Add-Type -AssemblyName System.Drawing
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Application]::EnableVisualStyles()

# Creates the parent form
$ADREPORT               = New-Object System.Windows.Forms.Form
$ADREPORT.Location      = New-Object System.Drawing.Size( 270,175 )
$ADREPORT.Size          = New-Object System.Drawing.Size( 800,400 )
$ADREPORT.StartPosition = "CenterScreen"
$ADREPORT.BackColor     = "Lavender"
$ADREPORT.Font          = "Calibri, 8.5"

# This creates a label for the title
$ADHEADER               = New-Object System.Windows.Forms.Label
$ADHEADER.Location      = New-Object System.Drawing.Size( 30,20 )
$ADHEADER.Size          = New-Object System.Drawing.Size( 180,20 )
$ADHEADER.Font          = New-Object System.Drawing.Font( "Calibri",11,[System.Drawing.FontStyle]::Bold )
$ADHEADER.Text          = "Choose your attributes"
$ADREPORT.Controls.Add( $ADHEADER )

# This creates a label for the sub-header
$ADTEXT                 = New-Object System.Windows.Forms.Label
$ADTEXT.Location        = New-Object System.Drawing.Size( 30,50 )
$ADTEXT.Size            = New-Object System.Drawing.Size( 300,40 )
$ADTEXT.Text            = "From the list below, select as many attributes as you like to generate a CSV report:"
$ADREPORT.Controls.Add( $ADTEXT )

# Active Directory Users label
$OBJUSERTXT             = New-Object System.Windows.Forms.Label
$OBJUSERTXT.Location    = New-Object System.Drawing.Size( 20,100 )
$OBJUSERTXT.Size        = New-Object System.Drawing.Size( 80,20 )
$OBJUSERTXT.Text        = "USERS:"
$ADREPORT.Controls.Add( $OBJUSERTXT )

# Active Directory Users checkbox - Checked by default
$USERBOX                = New-Object System.Windows.Forms.Checkbox
$USERBOX.Location       = New-Object System.Drawing.Size( 100,98 )
$USERBOX.Size           = New-Object System.Drawing.Size( 20,20 )
$USERBOX.TabIndex       = 0
$USERBOX.Checked        = $TRUE
$ADREPORT.Controls.Add( $USERBOX )

# Active Directory Computers label
$PCXT                   = New-Object System.Windows.Forms.Label
$PCXT.Location          = New-Object System.Drawing.Size( 150,100 )
$PCXT.Size              = New-Object System.Drawing.Size( 80,20 )
$PCXT.Text              = "COMPUTERS:"
$ADREPORT.Controls.Add( $PCXT )

# Active Directory Computers checkbox
$OBJPCBOX               = New-Object System.Windows.Forms.Checkbox
$OBJPCBOX.Location      = New-Object System.Drawing.Size( 230,98 )
$OBJPCBOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJPCBOX.TabIndex      = 9
$ADREPORT.Controls.Add( $OBJPCBOX )

# SamAccountName label
$OBJ01TXT               = New-Object System.Windows.Forms.Label
$OBJ01TXT.Location      = New-Object System.Drawing.Size( 20,120 )
$OBJ01TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ01TXT.Text          = "Username:"
$ADREPORT.Controls.Add( $OBJ01TXT )

# SamAccountName checkbox
$OBJ01BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ01BOX.Location      = New-Object System.Drawing.Size( 100,118 )
$OBJ01BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ01BOX.TabIndex      = 1
$OBJ01BOX.Checked       = $TRUE
$OBJ01BOX.Name          = "SamAccountName"
$ADREPORT.Controls.Add( $OBJ01BOX )

# Full Name label
$OBJ02TXT               = New-Object System.Windows.Forms.Label
$OBJ02TXT.Location      = New-Object System.Drawing.Size( 20,140 )
$OBJ02TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ02TXT.Text          = "Full name:"
$ADREPORT.Controls.Add( $OBJ02TXT )

# Full Name checkbox
$OBJ02BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ02BOX.Location      = New-Object System.Drawing.Size( 100,138 )
$OBJ02BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ02BOX.TabIndex      = 2
$OBJ02BOX.Name          = "Name"
$ADREPORT.Controls.Add( $OBJ02BOX )

# First Name label
$OBJ03TXT               = New-Object System.Windows.Forms.Label
$OBJ03TXT.Location      = New-Object System.Drawing.Size( 20,160 )
$OBJ03TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ03TXT.Text          = "First name:"
$ADREPORT.Controls.Add( $OBJ03TXT )

# First Name checkbox
$OBJ03BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ03BOX.Location      = New-Object System.Drawing.Size( 100,158 )
$OBJ03BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ03BOX.TabIndex      = 3
$OBJ03BOX.Name          = "GivenName"
$ADREPORT.Controls.Add( $OBJ03BOX )

# Surname label
$OBJ04TXT               = New-Object System.Windows.Forms.Label
$OBJ04TXT.Location      = New-Object System.Drawing.Size( 20,180 )
$OBJ04TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ04TXT.Text          = "Surname:"
$ADREPORT.Controls.Add( $OBJ04TXT )

# Surname checkbox
$OBJ04BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ04BOX.Location      = New-Object System.Drawing.Size( 100,178 )
$OBJ04BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ04BOX.TabIndex      = 4
$OBJ04BOX.Name          = "Surname"
$ADREPORT.Controls.Add( $OBJ04BOX )

# Department label
$OBJ05TXT               = New-Object System.Windows.Forms.Label
$OBJ05TXT.Location      = New-Object System.Drawing.Size( 20,200 )
$OBJ05TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ05TXT.Text          = "Department:"
$ADREPORT.Controls.Add( $OBJ05TXT )

# Department checkbox
$OBJ05BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ05BOX.Location      = New-Object System.Drawing.Size( 100,198 )
$OBJ05BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ05BOX.TabIndex      = 5
$OBJ05BOX.Name          = "Department"
$ADREPORT.Controls.Add( $OBJ05BOX )

# Job Title label
$OBJ06TXT               = New-Object System.Windows.Forms.Label
$OBJ06TXT.Location      = New-Object System.Drawing.Size( 20,220 )
$OBJ06TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ06TXT.Text          = "Job Title:"
$ADREPORT.Controls.Add( $OBJ06TXT )

# Job Title checkbox
$OBJ06BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ06BOX.Location      = New-Object System.Drawing.Size( 100,218 )
$OBJ06BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ06BOX.TabIndex      = 6
$OBJ06BOX.Name          = "Title"
$ADREPORT.Controls.Add( $OBJ06BOX )

# Manager Label
$OBJ07TXT               = New-Object System.Windows.Forms.Label
$OBJ07TXT.Location      = New-Object System.Drawing.Size( 20,240 )
$OBJ07TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ07TXT.Text          = "Manager:"
$ADREPORT.Controls.Add( $OBJ07TXT )

# Manager checkbox
$OBJ07BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ07BOX.Location      = New-Object System.Drawing.Size( 100,238 )
$OBJ07BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ07BOX.TabIndex      = 7
$OBJ07BOX.Name          = "Manager"
$ADREPORT.Controls.Add( $OBJ07BOX )

# IP Address label
$OBJ18TXT               = New-Object System.Windows.Forms.Label
$OBJ18TXT.Location      = New-Object System.Drawing.Size( 20,280 )
$OBJ18TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ18TXT.Text          = "IP Address:"
$ADREPORT.Controls.Add( $OBJ18TXT )

# IP Address checkbox
$OBJ18BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ18BOX.Location      = New-Object System.Drawing.Size( 100,278 )
$OBJ18BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ18BOX.TabIndex      = 19
$OBJ18BOX.Name          = "IPv4Address"
$OBJ18BOX.Enabled       = $FALSE
$ADREPORT.Controls.Add( $OBJ18BOX )

# Home Drive Label
$OBJ09TXT               = New-Object System.Windows.Forms.Label
$OBJ09TXT.Location      = New-Object System.Drawing.Size( 150,120 )
$OBJ09TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ09TXT.Text          = "Home Drive:"
$ADREPORT.Controls.Add( $OBJ09TXT )

# Home Drive Checkbox
$OBJ09BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ09BOX.Location      = New-Object System.Drawing.Size( 230,118 )
$OBJ09BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ09BOX.TabIndex      = 10
$OBJ09BOX.Name          = "HomeDirectory"
$ADREPORT.Controls.Add( $OBJ09BOX )

# Email label
$OBJ10TXT               = New-Object System.Windows.Forms.Label
$OBJ10TXT.Location      = New-Object System.Drawing.Size( 150,140 )
$OBJ10TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ10TXT.Text          = "Email:"
$ADREPORT.Controls.Add( $OBJ10TXT )

# Email checkbox
$OBJ10BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ10BOX.Location      = New-Object System.Drawing.Size( 230,138 )
$OBJ10BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ10BOX.TabIndex      = 11
$OBJ10BOX.Name          = "Mail"
$ADREPORT.Controls.Add( $OBJ10BOX )

# Phone label
$OBJ11TXT               = New-Object System.Windows.Forms.Label
$OBJ11TXT.Location      = New-Object System.Drawing.Size( 150,160 )
$OBJ11TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ11TXT.Text          = "Phone:"
$ADREPORT.Controls.Add( $OBJ11TXT )

# Phone checkbox
$OBJ11BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ11BOX.Location      = New-Object System.Drawing.Size( 230,158 )
$OBJ11BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ11BOX.TabIndex      = 12
$OBJ11BOX.Name          = "OfficePhone"
$ADREPORT.Controls.Add( $OBJ11BOX )

# Mobile phone label
$OBJ12TXT               = New-Object System.Windows.Forms.Label
$OBJ12TXT.Location      = New-Object System.Drawing.Size( 150,180 )
$OBJ12TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ12TXT.Text          = "Mobile:"
$ADREPORT.Controls.Add( $OBJ12TXT )

# Mobile phone checkbox
$OBJ12BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ12BOX.Location      = New-Object System.Drawing.Size( 230,178 )
$OBJ12BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ12BOX.TabIndex      = 13
$OBJ12BOX.Name          = "MobilePhone"
$ADREPORT.Controls.Add( $OBJ12BOX )

# Created label
$OBJ13TXT               = New-Object System.Windows.Forms.Label
$OBJ13TXT.Location      = New-Object System.Drawing.Size( 150,200 )
$OBJ13TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ13TXT.Text          = "Creation Date:"
$ADREPORT.Controls.Add( $OBJ13TXT )

# Created checkbox
$OBJ13BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ13BOX.Location      = New-Object System.Drawing.Size( 230,198 )
$OBJ13BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ13BOX.TabIndex      = 14
$OBJ13BOX.Name          = "Created"
$ADREPORT.Controls.Add( $OBJ13BOX )

# Modified label
$OBJ14TXT               = New-Object System.Windows.Forms.Label
$OBJ14TXT.Location      = New-Object System.Drawing.Size( 150,220 )
$OBJ14TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ14TXT.Text          = "Modified Date:"
$ADREPORT.Controls.Add( $OBJ14TXT )

# Modified checkbox
$OBJ14BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ14BOX.Location      = New-Object System.Drawing.Size( 230,218 )
$OBJ14BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ14BOX.TabIndex      = 15
$OBJ14BOX.Name          = "Modified"
$ADREPORT.Controls.Add( $OBJ14BOX )

# Password label
$OBJ15TXT               = New-Object System.Windows.Forms.Label
$OBJ15TXT.Location      = New-Object System.Drawing.Size( 150,240 )
$OBJ15TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ15TXT.Text          = "Password Set:"
$ADREPORT.Controls.Add( $OBJ15TXT )

# Password checkbox
$OBJ15BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ15BOX.Location      = New-Object System.Drawing.Size( 230,238 )
$OBJ15BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ15BOX.TabIndex      = 16
$OBJ15BOX.Name          = "PasswordLastSet"
$ADREPORT.Controls.Add( $OBJ15BOX )

# Enabled label
$OBJ08TXT               = New-Object System.Windows.Forms.Label
$OBJ08TXT.Location      = New-Object System.Drawing.Size( 150,260 )
$OBJ08TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ08TXT.Text          = "Enabled Status:"
$ADREPORT.Controls.Add( $OBJ08TXT )

# Enable checkbox
$OBJ08BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ08BOX.Location      = New-Object System.Drawing.Size( 230,258 )
$OBJ08BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ08BOX.TabIndex      = 17
$OBJ08BOX.Name          = "Enabled"
$ADREPORT.Controls.Add( $OBJ08BOX )

#This creates a label for the 18th attribute - Operating System
$OBJ17TXT               = New-Object System.Windows.Forms.Label
$OBJ17TXT.Location      = New-Object System.Drawing.Size( 150,280 )
$OBJ17TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ17TXT.Text          = "OS:"
$ADREPORT.Controls.Add( $OBJ17TXT )

#This creates the checkbox for the 18th attribute - Operating System
$OBJ17BOX               = New-Object System.Windows.Forms.Checkbox
 $OBJ17BOX.Location     = New-Object System.Drawing.Size( 230,278 )
$OBJ17BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ17BOX.TabIndex      = 18
 $OBJ17BOX.Name         = "OperatingSystem"
 $OBJ17BOX.Enabled      = $FALSE
$ADREPORT.Controls.Add( $OBJ17BOX )

# OU Label
$OBJ16TXT               = New-Object System.Windows.Forms.Label
$OBJ16TXT.Location      = New-Object System.Drawing.Size( 20,260 )
$OBJ16TXT.Size          = New-Object System.Drawing.Size( 80,20 )
$OBJ16TXT.Text          = "OU:"
$ADREPORT.Controls.Add( $OBJ16TXT )

# OU Checkbox
$OBJ16BOX               = New-Object System.Windows.Forms.Checkbox
$OBJ16BOX.Location      = New-Object System.Drawing.Size( 100,258 )
$OBJ16BOX.Size          = New-Object System.Drawing.Size( 20,20 )
$OBJ16BOX.TabIndex      = 8
$OBJ16BOX.Name          = "CanonicalName"
$ADREPORT.Controls.Add( $OBJ16BOX )

# OK Button
$OK                     = New-Object System.Windows.Forms.Button
$OK.Location            = New-Object System.Drawing.Size( 30,315 )
$OK.Size                = New-Object System.Drawing.Size( 75,23 )
$OK.ForeColor           = "Green"
$OK.Text                = "OK"
$OK.DialogResult        = "OK"
$OK.add_Click( { $ADREPORT.Close() } )
$ADREPORT.Controls.Add( $OK )

# Cancel button
$CANCEL                 = New-Object System.Windows.Forms.Button
$CANCEL.Location        = New-Object System.Drawing.Point( 160,315 )
$CANCEL.Size            = New-Object System.Drawing.Size( 75,23 )
$CANCEL.ForeColor       = "Red"
$CANCEL.Text            = "Cancel"
$CANCEL.DialogResult    = "Cancel"
$ADREPORT.Controls.Add( $CANCEL )

# If PC checkbox ticked, grey out user specific attributes
$OBJPCBOX.Add_CheckStateChanged( {
IF ( $OBJPCBOX.Checked )
     { $USERBOX.Checked    = $FALSE                                  # AD User box
         $OBJ02BOX.Enabled = $FALSE ; $OBJ02BOX.Checked = $FALSE     # Full name
         $OBJ03BOX.Enabled = $FALSE ; $OBJ03BOX.Checked = $FALSE     # First name
         $OBJ04BOX.Enabled = $FALSE ; $OBJ04BOX.Checked = $FALSE     # Surname
         $OBJ05BOX.Enabled = $FALSE ; $OBJ05BOX.Checked = $FALSE     # Department
         $OBJ06BOX.Enabled = $FALSE ; $OBJ06BOX.Checked = $FALSE     # Job Title
         $OBJ07BOX.Enabled = $FALSE ; $OBJ07BOX.Checked = $FALSE     # Manager
         $OBJ09BOX.Enabled = $FALSE ; $OBJ09BOX.Checked = $FALSE     # HomeDirectory
         $OBJ10BOX.Enabled = $FALSE ; $OBJ10BOX.Checked = $FALSE     # Mail
         $OBJ11BOX.Enabled = $FALSE ; $OBJ11BOX.Checked = $FALSE     # Phone
         $OBJ12BOX.Enabled = $FALSE ; $OBJ12BOX.Checked = $FALSE     # Mobile
         $OBJ17BOX.Enabled = $TRUE  ; $OBJ18BOX.Enabled = $TRUE }    # OS & IP Address

# IF User box ticked, untick PC box and un-grey user specific attributes
IF ( $OBJPCBOX.Checked -eq $FALSE )
     { $USERBOX.Checked    = $TRUE  ; $OBJ02BOX.Enabled = $TRUE
         $OBJ03BOX.Enabled = $TRUE  ; $OBJ04BOX.Enabled = $TRUE
         $OBJ05BOX.Enabled = $TRUE  ; $OBJ06BOX.Enabled = $TRUE
         $OBJ07BOX.Enabled = $TRUE  ; $OBJ09BOX.Enabled = $TRUE
         $OBJ10BOX.Enabled = $TRUE  ; $OBJ11BOX.Enabled = $TRUE
         $OBJ12BOX.Enabled = $TRUE
         $OBJ17BOX.Enabled = $FALSE ; $OBJ18BOX.Enabled = $FALSE }

} ) # CLOSES $OBJPCBOX.Add_CheckStateChanged( {

# IF user box ticked, untick PC box
$USERBOX.Add_CheckStateChanged( {
IF ( $USERBOX.Checked -eq $TRUE )
     { $OBJPCBOX.Checked = $FALSE } } )

# Launch the checkbox form.
$ADREPORT.Add_Shown( { $ADREPORT.Activate() } )

# When you've pressed ok...

# /// If you choose ADUsers then first create two empty variables; populate $ADVAIRABLES with the name of each checkbox
#         ticked.
#         Perform an unfiltered search of Active Directory users and select just the attributes from the checkboxes. This
#         is measured for visual feedback.
#         If the Manager attribute is checked, this comes back in DN form ( CN=Graham Jordan,OU=Users,DC=DOMAIN,DC=LOCAL ),
#         so run a Get-Aduser against each DN to bring back the full name.
#         The manager conversion is wrapped up in Write-Progress to give you a visual impression of how far into the change,
#         since this takes a while.
#         If the OU attribute is ticked ( CanonicalName ), then run a replace on each line to remove the domain name, and
#         the users full name leaving just Users/...
#         Finally exports a CSV to your user profile in "AD Report for Users - 28 02 2018 - 12.45.csv" format.

IF ( ( $ADREPORT.ShowDialog() ) -eq "OK" )
   { IF ( $USERBOX.Checked )
        { $ADVARIABLES = @()
          $USERS             = @()

          Write-Host "Performing a search of all users on Active Directory. This part can take a minute or so" -f Green ; ""
          Get-Variable -Name OBJ* | ?{ $_.Value.Checkstate -eq 1    } | %{ $ADVARIABLES += $_.Value.Name }

          $SECONDS = ( Measure-Command {
          $USERS    += Get-ADUser -Filter * -Property $ADVARIABLES | select $ADVARIABLES | sort Name } ).seconds

          Write-Host $USERS.Count user accounts identified in $SECONDS seconds. -f Green ; ""

          IF ( $USERS.Manager -notlike $NULL )
             { $USERS | foreach-object -begin { $COUNT = 0 } -process {
               $USER = $_

               IF ( $USER.Manager )
                  { $USER.Manager = ( ( Get-ADUser $USER.Manager ).Name ).ToString() }
                    $COUNT = $COUNT + 1
                    Write-Progress -Activity "Altering Manager DN's to Manager Name" -Status "Progress: $(
                    $USER.Name )" -PercentComplete ( $COUNT / $USERS.count * 100 ) } }

          IF ( $USER.CanonicalName )
             { Foreach ( $USER in $USERS )
                       { $USER.CanonicalName = $USER.CanonicalName.Substring( $USER.CanonicalName.IndexOf( "/" ) +1 )
                         $USER.CanonicalName = $USER.CanonicalName -replace "/$( $USER.Name )" } }

          $USERS | Export-Csv "$env:USERPROFILE\AD Report for Users - $( Get-Date -Format "dd MMM yyyy - hh.mm" ).csv" -NoClobber -NoTypeInformation -Force }

IF ( $OBJPCBOX.Checked )
   { $ADVARIABLES = @()
     Get-Variable -Name OBJ* | ?{ $_.Value.Checkstate -eq 1    } | %{ $ADVARIABLES += $_.Value.Name }

     Write-Host "Performing a search of all computers on Active Directory. This part can take a minute or so" -f Green ; ""

     $PCS  = @()
     $PCS += Get-ADComputer -Filter * -Properties $ADVARIABLES | select $ADVARIABLES | sort SamAccountName

     IF ( $PCS.CanonicalName )
        { Foreach ( $PC in $PCS )
                  { $PC.CanonicalName = $PC.CanonicalName.Substring( $PC.CanonicalName.IndexOf( "/" ) +1 )
                    $PC.CanonicalName = $PC.CanonicalName -replace "/$( $PC.SamAccountName )$" } }

     $PCS | Export-Csv "$env:USERPROFILE\AD Report for Computers - $( Get-Date -Format "dd MMM yyyy - hh.mm" ).csv" -NoClobber -NoTypeInformation -Force }

}

Body:
That was annoying. GUIs are disgusting. So your issue is that if you ran the following command:

Get-ADComputer -Identity PC01 -Properties 'Created','PasswordLastSet',''

It will throw an error because ONE of the properties is a null/empty string. You had a null/empty string in $ADVARIABLES which caused your error.

Per your script I made a modification:

Get-Variable -Name OBJ* | ?{ $_.Value.Checkstate -eq 1    } | %{
    Write-Host -Object "Adding property '$($_.Value.Name)' from $($_.Name)"
    $ADVARIABLES += $_.Value.Name
}

This provided me with the following output:

Adding property 'SamAccountName' from OBJ01BOX
Adding property 'Created' from OBJ13BOX
Adding property 'PasswordLastSet' from OBJ15BOX
Adding property '' from OBJPCBOX

You will need to probably rename $OBJPCBOX or create a better filter when you're populating $ADVARIABLES.


来源: stackexchange

问:
Combining Firebase Auth with Firebase Realtime Database or Google Cloud Datastore?
I'm planning a web application that requires user auth, plus the ability to display data for the users that is stored in a database. No interaction between the users is needed (yet), however the users should be able create objects and query their "own" objects. For example I list 10 book names (10 book objects), and User A should be able to pick a book and create a new object, call it userNoteObject that contains the name of a choosen book and a short note (that he/she writes).

With a basic pseudo code one book object would look like this:

```<code>bookObj = {"id": 1, "name": "book name"}
</code>```

And the user's note object would be something like this:

```<code>userNoteObject = {
             "id": 1,
             "book_name": "random book name",
             "owner_userid": "a1b2c3d",
             "note": "some random string"
                  }
</code>```

With MySQL I would create three tables, one for the users and one for the userNoteObject-s and another for the bookObj-s. Everytime an user saves a note, I would add it to the table that lists the saved notes. Then I can simply query the notes that belongs to X user based on the user's owner_userid. It's a quite simple functionality.

After reading about the possibilities I've made a decision to go with Firebase Auth (because in the future I might need Android and iOS compatibility) + Google Cloud Datastore or Firebase Realtime Database. However I'm a little bit scared about the Realtime Database of Firebase since I've never worked any DB like it. I also like to be able to modify records manually with something like PhpMyAdmin and I assume Cloud Datastore has a visual interface like that.

I'm familiar with JSON handling and creating JSON files, however the JSON based database is strange for me at the moment. Therefore I'm thinking about that maybe the other option would be a better choice. It's very important that I don't need realtime db features. I would load X number of entries into the table that holds the bookObj-s and sometimes update them. I assume when the user creates an userNoteObject it would be saved quickly with both and after deleting an userNoteObject I could refresh the page close to realtime with Datastore. But the table that holds the book objects must be able to store millions of entries easily.

So the important things:

One db table should be able to handle millions of records easily

Easy as possible querying

Visual interface for the DB (if it's possible)

I don't need realtime features like dynamic game score display/saving

Other info:

I would like to use Angular.js

I'm familiar with Python if it can help in something

So my question is that which database would be better for my needs? At the moment I say Datastore, but I'm totally new with these services so I'm not really against the Realtime Database, but Datastore looks more suitable since it has a visual interface. However I'm also not sure that how would work Datastore with Firebase. If there is a third option like combining both, Realtime Database for the objects save by the user and the static objects for Datastore for example, I would love to hear about it too. My overall goal is to be able to write and query the db easy and fast as it's possible and easily use it with Firebase auth.

UPDATE: I just discovered Firebase's Cloud Firestore, so if it can be more useful I could use it.

答:
If you are going to use Firebase I would recommend you use Cloud Firestore instead of either Cloud Datastore or Firebase realtime database. You get the benefits of a real-time database plus a true document based JSON data store. The one downside is that you don`t have a UI to interact with the data. Datastore has one but its not as robust as say PHPMyAdmin. And since these are NoSQL datastores SQL support is pretty limited.

If you really want a true relational back-end you could try Cloud SQL which is basically MySQL running on Google Servers.

ContentLicense: CC BY-SA 3.0

Body:
I'm planning a web application that requires user auth, plus the ability to display data for the users that is stored in a database. No interaction between the users is needed (yet), however the users should be able create objects and query their "own" objects. For example I list 10 book names (10 book objects), and User A should be able to pick a book and create a new object, call it userNoteObject that contains the name of a choosen book and a short note (that he/she writes).

With a basic pseudo code one book object would look like this:

bookObj = {"id": 1, "name": "book name"}

And the user's note object would be something like this:

userNoteObject = {
             "id": 1,
             "book_name": "random book name",
             "owner_userid": "a1b2c3d",
             "note": "some random string"
                  }

With MySQL I would create three tables, one for the users and one for the userNoteObject-s and another for the bookObj-s. Everytime an user saves a note, I would add it to the table that lists the saved notes. Then I can simply query the notes that belongs to X user based on the user's owner_userid. It's a quite simple functionality.

After reading about the possibilities I've made a decision to go with Firebase Auth (because in the future I might need Android and iOS compatibility) + Google Cloud Datastore or Firebase Realtime Database. However I'm a little bit scared about the Realtime Database of Firebase since I've never worked any DB like it. I also like to be able to modify records manually with something like PhpMyAdmin and I assume Cloud Datastore has a visual interface like that.

I'm familiar with JSON handling and creating JSON files, however the JSON based database is strange for me at the moment. Therefore I'm thinking about that maybe the other option would be a better choice. It's very important that I don't need realtime db features. I would load X number of entries into the table that holds the bookObj-s and sometimes update them. I assume when the user creates an userNoteObject it would be saved quickly with both and after deleting an userNoteObject I could refresh the page close to realtime with Datastore. But the table that holds the book objects must be able to store millions of entries easily.

So the important things:

One db table should be able to handle millions of records easily

Easy as possible querying

Visual interface for the DB (if it's possible)

I don't need realtime features like dynamic game score display/saving

Other info:

I would like to use Angular.js

I'm familiar with Python if it can help in something

So my question is that which database would be better for my needs? At the moment I say Datastore, but I'm totally new with these services so I'm not really against the Realtime Database, but Datastore looks more suitable since it has a visual interface. However I'm also not sure that how would work Datastore with Firebase. If there is a third option like combining both, Realtime Database for the objects save by the user and the static objects for Datastore for example, I would love to hear about it too. My overall goal is to be able to write and query the db easy and fast as it's possible and easily use it with Firebase auth.

UPDATE: I just discovered Firebase's Cloud Firestore, so if it can be more useful I could use it.


问:
How do I crop internal HTML elements at CSS3 rounded borders?
I have a div inside another div. The outer div has rounded borders using CSS3. The problem is, if I set a background color on the inner div it bleeds through into the corners. Here's a test page to show what I mean: http://www.webdevout.net/test?0O

I suspect it's not a renderer issue, as the same thing happens in Chrome, FF, and Opera. How do I get the inner div to crop at the rounded borders? Setting border-radius on the inner div to inherit doesn't cut it, the borders don't match up.

EDIT: The inner div is actually a header for more content inside the outer div, so applying the rounded borders to the inner div instead will not work.

答: overflow:hidden should do it... Or actually, it doesn't... give another set of rounded corners to the inside container. </p>

ContentLicense: CC BY-SA 2.5


问:
Which JavaThread in JVM is mutator thread?
The concept of mutator thread is related to Garbage Collection.

The basic threading model in Hotspot is a 1:1 mapping between Java threads (an instance of java.lang.Thread) and native operating system threads.

What do the different (HotSpot) JVM thread types do?

In hotspot/src/share/vm/runtime/thread.hpp

```<code>// Class hierarchy
// - Thread
//   - NamedThread
//     - VMThread
//     - ConcurrentGCThread
//     - WorkerThread
//       - GangWorker
//       - GCTaskThread
//   - JavaThread
//     - various subclasses eg CompilerThread, ServiceThread
//   - WatcherThread
</code>```

JavaThread is the nearest one to mutator thread. However, JavaThread has some children classes:

CodeCacheSweeperThread,

CompilerThread,      //  Usually I see C1, C2 compiler in JVM

jmitiAgentThread,

ServiceThread.

I don't think CodeCacheSweeperThread, CompilerThread, jmitiAgentThread are mutator threads... But how is ServiceThread?

Besides, I think CompilerThread should be an internal thread of JVM but not a mutator thread.

How to distinguish a mutator thread that is a Java program, say which thread does service the following single thread program (1:1 mapping)?

```<code>public class HelloWorld {

    public static void main(String[] args) {
        // Prints "Hello, World" to the terminal window.
        System.out.println("Hello, World");
    }

}
</code>```

答:
The concept of mutator thread is related to Garbage Collection.

AFAIK, It's not a term generally associated with Java as every thread is assumed to be able to modify the heap.  There are exceptions such as the compiler threads which only modify the native code translations.

In general, I would assume any thread can modify state unless you have a specific reason to believe otherwise.

Body:
The concept of mutator thread is related to Garbage Collection.

The basic threading model in Hotspot is a 1:1 mapping between Java threads (an instance of java.lang.Thread) and native operating system threads.

What do the different (HotSpot) JVM thread types do?

In hotspot/src/share/vm/runtime/thread.hpp

// Class hierarchy
// - Thread
//   - NamedThread
//     - VMThread
//     - ConcurrentGCThread
//     - WorkerThread
//       - GangWorker
//       - GCTaskThread
//   - JavaThread
//     - various subclasses eg CompilerThread, ServiceThread
//   - WatcherThread

JavaThread is the nearest one to mutator thread. However, JavaThread has some children classes:

CodeCacheSweeperThread,

CompilerThread,      //  Usually I see C1, C2 compiler in JVM

jmitiAgentThread,

ServiceThread.

I don't think CodeCacheSweeperThread, CompilerThread, jmitiAgentThread are mutator threads... But how is ServiceThread?

Besides, I think CompilerThread should be an internal thread of JVM but not a mutator thread.

How to distinguish a mutator thread that is a Java program, say which thread does service the following single thread program (1:1 mapping)?

public class HelloWorld {

    public static void main(String[] args) {
        // Prints "Hello, World" to the terminal window.
        System.out.println("Hello, World");
    }

}


问:
if statement in Django template issue
I am trying to compare value inside template of django. if statement is not working
here is my code
Model class:

```<code>class Run(models.Model):
    run_id = models.AutoField(primary_key=True)
    run_name = models.CharField(unique=True, max_length=30)
    pms_id = models.ForeignKey('ProcessManagementSystem', db_column = 'pms_id')

def __unicode__(self):
    return self.run_name

class ProcessManagementSystem(models.Model):
    pms_id = models.AutoField(primary_key=True)
    pms_name = models.CharField(unique=True, max_length=30)

def __unicode__(self):
       return self.pms_name
</code>```

My template

```<code>{% for run in all_runs %}
        {{run.pms_id}}
        {% if run.pms_id == "PMSName1" %}
                    {{run.pms_id}}
        {% endif %}
{% endfor %}
</code>```

the interesting thing is when I am printing {{run.pms_id}} , it is not showing the ID, It is showing pms_name (maybe because of return self.pms_name)

So during compare, I am trying to compare with name i.e. "PMSName1" instead of id But still no luck.
Any suggestion how to compare?

Thanks

答:
A ForeignKey field in Django does not give you simply the ID; it gives you the actual related object. You shouldn't use the _id format, because Django actually creates the underlying database column by adding _id to the name of the field. So, you have a db column called pms_id_id.

In the template, the object is not equal to either the id or the name. You can access the ID field directly:

```<code>{% if run.pms_id_id == whatever %}
</code>```

or access the id of the related object:

```<code>{% if run.pms_id.pms_id == whatever %}
</code>```

The advantage of the first form is that it doesn't trigger a db lookup for the related object; the advantage of the second is that you could compare against any of the fields, using eg run.pms_id.pms_name for example.

Title: if statement in Django template issue

Body:
I am trying to compare value inside template of django. if statement is not working
here is my code
Model class:

class Run(models.Model):
    run_id = models.AutoField(primary_key=True)
    run_name = models.CharField(unique=True, max_length=30)
    pms_id = models.ForeignKey('ProcessManagementSystem', db_column = 'pms_id')

def __unicode__(self):
    return self.run_name

class ProcessManagementSystem(models.Model):
    pms_id = models.AutoField(primary_key=True)
    pms_name = models.CharField(unique=True, max_length=30)

def __unicode__(self):
       return self.pms_name

My template

{% for run in all_runs %}
        {{run.pms_id}}
        {% if run.pms_id == "PMSName1" %}
                    {{run.pms_id}}
        {% endif %}
{% endfor %}

the interesting thing is when I am printing {{run.pms_id}} , it is not showing the ID, It is showing pms_name (maybe because of return self.pms_name)

So during compare, I am trying to compare with name i.e. "PMSName1" instead of id But still no luck.
Any suggestion how to compare?

Thanks

Body:
A ForeignKey field in Django does not give you simply the ID; it gives you the actual related object. You shouldn't use the _id format, because Django actually creates the underlying database column by adding _id to the name of the field. So, you have a db column called pms_id_id.

In the template, the object is not equal to either the id or the name. You can access the ID field directly:

{% if run.pms_id_id == whatever %}

or access the id of the related object:

{% if run.pms_id.pms_id == whatever %}

The advantage of the first form is that it doesn't trigger a db lookup for the related object; the advantage of the second is that you could compare against any of the fields, using eg run.pms_id.pms_name for example.


问:
Putting div directly above footer
I am currently making an app. I would like the time to be directly above the footer instead of below the google translator. Is there anyway to do this? I have attached a picture at the end to show how it is looking like right now.

```<code><!-- codes that not related-->

    <div id="demo"></div> <!-- TIME -->

<footer data-role="footer" class="ui-footer-fixed">
    <h4>Copyright 2017</h4>
</footer>
</code>```

I have added in the css as requested below.

```<code>.ui-header,
.ui-footer {
border-width: 1px 0;
border-style: solid;
position: relative;
}

.ui-header:empty,
.ui-footer:empty {
min-height: 2.6875em;
}

.ui-header .ui-title,
.ui-footer .ui-title {
font-size: 1em;
min-height: 1.1em;
text-align: center;
display: block;
margin: 0 30%;
padding: .7em 0;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
outline: 0 !important;
}

.ui-footer .ui-title {
margin: 0 1em;
}
.ui-content {
border-width: 0;
overflow: visible;
overflow-x: hidden;
padding: 1em;
}

/* Corner styling for dialogs and popups */
.ui-corner-all > .ui-header:first-child,
.ui-corner-all > .ui-content:first-child,
.ui-corner-all > .ui-footer:first-child {
-webkit-border-top-left-radius: inherit;
border-top-left-radius: inherit;
-webkit-border-top-right-radius: inherit;
border-top-right-radius: inherit;
}

.ui-corner-all > .ui-header:last-child,
.ui-corner-all > .ui-content:last-child,
.ui-corner-all > .ui-footer:last-child {
-webkit-border-bottom-left-radius: inherit;
border-bottom-left-radius: inherit;
-webkit-border-bottom-right-radius: inherit;
border-bottom-right-radius: inherit;
}
</code>```

答:
Will something like the below work for you?

I had to tweak your HTML markup a little bit to show how it would work.

.ui-footer-fixed {
  position: fixed;
  bottom: 0;
  width: 100%;
}

#demo, h4 {
  margin:  0;
  padding: 5px;
}

.center {
  text-align: center;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><article class='center'>
  <header>
    <h1>Heading</h1>
  </header>
</article>

<article>
  <div>Main body of page</div>
</article>

<article class='center'>
  <footer data-role="footer" class="ui-footer-fixed">
    <div id="demo">
      4th December 2017 @16:40
    </div>
    <h4>Copyright 2017</h4>
  </footer>
<article></code>```

Title: Putting div directly above footer

Body:
I am currently making an app. I would like the time to be directly above the footer instead of below the google translator. Is there anyway to do this? I have attached a picture at the end to show how it is looking like right now.

Copyright 2017

I have added in the css as requested below.

.ui-header,
.ui-footer {
border-width: 1px 0;
border-style: solid;
position: relative;
}

.ui-header:empty,
.ui-footer:empty {
min-height: 2.6875em;
}

.ui-header .ui-title,
.ui-footer .ui-title {
font-size: 1em;
min-height: 1.1em;
text-align: center;
display: block;
margin: 0 30%;
padding: .7em 0;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
outline: 0 !important;
}

.ui-footer .ui-title {
margin: 0 1em;
}
.ui-content {
border-width: 0;
overflow: visible;
overflow-x: hidden;
padding: 1em;
}

/* Corner styling for dialogs and popups */
.ui-corner-all > .ui-header:first-child,
.ui-corner-all > .ui-content:first-child,
.ui-corner-all > .ui-footer:first-child {
-webkit-border-top-left-radius: inherit;
border-top-left-radius: inherit;
-webkit-border-top-right-radius: inherit;
border-top-right-radius: inherit;
}

.ui-corner-all > .ui-header:last-child,
.ui-corner-all > .ui-content:last-child,
.ui-corner-all > .ui-footer:last-child {
-webkit-border-bottom-left-radius: inherit;
border-bottom-left-radius: inherit;
-webkit-border-bottom-right-radius: inherit;
border-bottom-right-radius: inherit;
}

Body:
Will something like the below work for you?

I had to tweak your HTML markup a little bit to show how it would work.

.ui-footer-fixed {
  position: fixed;
  bottom: 0;
  width: 100%;
}

#demo, h4 {
  margin:  0;
  padding: 5px;
}

.center {
  text-align: center;
}

<article class='center'>
  <header>
    <h1>Heading</h1>
  </header>
</article>

<article>
  <div>Main body of page</div>
</article>

<article class='center'>
  <footer data-role="footer" class="ui-footer-fixed">
    <div id="demo">
      4th December 2017 @16:40
    </div>
    <h4>Copyright 2017</h4>
  </footer>
<article>


问:
Split string with split_part in Asian language
I have a column with Asian addresses. I want to extract the substring until the first whitespace. However, this does not work here. My suspicion is that it has to do with the Asian language, but I do not why nor how to deal with this issue.

That's the code:

```<code>select address, split_part(address, ' ', 1) from asian
</code>```

Exemplary output (no splitting has happened!). As you can see there are spaces.

```<code>address
"千葉県富津市新富２０−１　新日本製鐵株式会社　技術開発本部内"
split_part
"千葉県富津市新富２０−１　新日本製鐵株式会社　技術開発本部内"
</code>```

答:
you can hack ideographic space with chr(), eg:

```<code>t=# select split_part('千葉県富津市新富２０−１　新日本製鐵株式会社　技術開発本部内',chr(12288),1);
       split_part
-------------------------
 千葉県富津市新富２０−１
(1 row)

t=# select split_part('千葉県富津市新富２０−１　新日本製鐵株式会社　技術開発本部内',chr(12288),2);
     split_part
--------------------
 新日本製鐵株式会社
(1 row)
</code>```

Body:
I have a column with Asian addresses. I want to extract the substring until the first whitespace. However, this does not work here. My suspicion is that it has to do with the Asian language, but I do not why nor how to deal with this issue.

That's the code:

select address, split_part(address, ' ', 1) from asian

Exemplary output (no splitting has happened!). As you can see there are spaces.

address
"千葉県富津市新富２０−１　新日本製鐵株式会社　技術開発本部内"
split_part
"千葉県富津市新富２０−１　新日本製鐵株式会社　技術開発本部内"

Body:
you can hack ideographic space with chr(), eg:

t=# select split_part('千葉県富津市新富２０−１　新日本製鐵株式会社　技術開発本部内',chr(12288),1);
       split_part
-------------------------
 千葉県富津市新富２０−１
(1 row)

t=# select split_part('千葉県富津市新富２０−１　新日本製鐵株式会社　技術開発本部内',chr(12288),2);
     split_part
--------------------
 新日本製鐵株式会社
(1 row)


问:
gl readPixels coordinate system: read and check more than one point
I need to read a block of pixels from the picking buffer to check the surrounding points for collisions, like in the picture below:

I am clicking on my canvas at x, y - so I define a square region of, let say, 11x11 pixels, centered at cX, cY and then I read from the picking buffer just in one shot starting from x1, y1:

```<code>var w = 11, h = 11, cX = x, cY = cH - y, rc = ~~(0.5*w), x1 = cX - rc, y1 = cY + rc;

gl.readPixels(x1, y1, w, h, gl.RGBA, gl.UNSIGNED_BYTE, pickBuf);
</code>```

Then, i am looping from the center of my buffer walking to the outside, following the red arrows, while checking for a positive response inside the picking buffer (collision found):

```<code>function readAt(i, pickBuf) {
    return pickBuf[i] << 16 | pickBuf[i+1] << 8 | pickBuf[i+2];
}

var l = rc;
while(l--) {
    /* Top-Left sector */
    var r = rc+(rc-l), c = l, p = r*w + c, i = 4*p;
    found = readAt(i, pickBuf) > 0;
    /* Top-Right sector */
    var r = rc+(rc-l), c = rc+(rc-l), p = r*w + c, i = 4*p;
    found = readAt(i, pickBuf) > 0;
    /* Bottom-Left sector */
    var r = l, c = l, p = r*w + c, i = 4*p;
    found = readAt(i, pickBuf) > 0;
    /* Bottom-Right sector */
    var r = l, c = rc+(rc-l), p = r*w + c, i = 4*p;
    found = readAt(i, pickBuf) > 0;
}
</code>```

The piece of code is working and I am able to pick a geometry, but now I believe I haven't understand correctly the whole coordinate system, because the collision result is always above and left of the point where it should be. Why this happens?

It seems to me that readPixels should read the bytes starting from the bottom-left corner of the canvas, to the top-right corner. Is that true, or I am missing something?

I am aware that the glcoordinate system is Y-inverted against my canvas, so I am defining the center of the picking buffer at cY = cH - y and the Y starting point for the picking buffer at y1 = cY + rc, but anyway this is giving me wrong results during my walk from the center to the outside of my picking square box. Where goes my interpretation of the coordinate system wrong?

答:
It seems to me that readPixels should read the bytes starting from the
  bottom-left corner of the canvas, to the top-right corner. Is that
  true, or i am missing something?

Thats true

anyway this is giving me wrong results during my walk

With the exception of the middle pixel not being checked, it works for me, I suspect the issue to be elsewhere in your code.

// picking
c.addEventListener('click',function (e) {
  var
    cX = e.offsetX, // x within canvas
    cY = ctx.drawingBufferHeight - e.offsetY // y within canvas inverted, drawingbufferheight is same as canvas height
  ;

  var
    area = 11,
    halfArea = (area/2)|0,
    sX = cX-halfArea,
    sY = cY-halfArea
  ;
  console.log('Picking from ', sX, sY, area,area);
  // read data
  var data = new Uint8Array(area*area*4);
  ctx.readPixels(sX,sY,area,area,ctx.RGBA,ctx.UNSIGNED_BYTE,data);
  // draw cross
  (function (pickBuf,rc,w) {
  function readAt(i, pickBuf) {
      return pickBuf[i]=pickBuf[i+1]=pickBuf[i+2]=0;
  }
  // this is your unmodified loop
  var l = rc;
  while(l--) {
      /* Top-Left sector */
      var r = rc+(rc-l), c = l, p = r*w + c, i = 4*p;
      found = readAt(i, pickBuf) > 0;
      /* Top-Right sector */
      var r = rc+(rc-l), c = rc+(rc-l), p = r*w + c, i = 4*p;
      found = readAt(i, pickBuf) > 0;
      /* Bottom-Left sector */
      var r = l, c = l, p = r*w + c, i = 4*p;
      found = readAt(i, pickBuf) > 0;
      /* Bottom-Right sector */
      var r = l, c = rc+(rc-l), p = r*w + c, i = 4*p;
      found = readAt(i, pickBuf) > 0;
  }
  })(data,halfArea,area);

  // create preview
  var octx = document.createElement('canvas').getContext('2d');
  octx.canvas.classList.add('preview');
  octx.canvas.width = octx.canvas.height = area;
  var idata = octx.createImageData(area,area);
  idata.data.set(data);
  octx.putImageData(idata,0,0);
  ctx.canvas.parentElement.insertBefore(octx.canvas,ctx.canvas);
});

// context setup
var ctx = c.getContext('webgl',{preserveDrawingBuffer:true});
ctx.canvas.width = ctx.canvas.height = 256;
ctx.viewport(0,0,256,256);
// shader setup
var vs=ctx.createShader(ctx.VERTEX_SHADER),fs=ctx.createShader(ctx.FRAGMENT_SHADER),prg=ctx.createProgram();
ctx.shaderSource(vs,`
  attribute vec2 vPos;
  void main(){gl_Position=vec4(vPos,0,1);}
`);
ctx.shaderSource(fs,`
  precision highp float;
  void main(){
  vec2 p=(gl_FragCoord.xy/256.)*2.-1.;
  gl_FragColor=vec4(sign(p),sign(-p.r),1);
  }
`);
ctx.compileShader(vs);
ctx.compileShader(fs);
ctx.attachShader(prg,vs);
ctx.attachShader(prg,fs);
ctx.linkProgram(prg);
// screenspace setup
var ssq = ctx.createBuffer();
ctx.bindBuffer(ctx.ARRAY_BUFFER,ssq);
ctx.bufferData(ctx.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,1,1,-1,1]),ctx.STATIC_DRAW);
ctx.vertexAttribPointer(0,2,ctx.FLOAT,false,0,0);
ctx.enableVertexAttribArray(0);
// draw
ctx.useProgram(prg);
ctx.drawArrays(ctx.TRIANGLE_FAN,0,4);```
<pre class="snippet-code-css lang-css prettyprint-override"><code>h2{text-align:center;font-family: Arial,sans-serif;}
#c{display:block;margin:0 auto;outline:1px solid red;cursor:crosshair;}

.preview {
width: 64px;
height: 64px;
outline: none;
display:inline;
image-rendering: pixelated;
transform:scaleY(-1);
margin: 10px;
}</code>```

Click 2 Pick

<canvas id="c"></canvas>```

Body:
I need to read a block of pixels from the picking buffer to check the surrounding points for collisions, like in the picture below:

I am clicking on my canvas at x, y - so I define a square region of, let say, 11x11 pixels, centered at cX, cY and then I read from the picking buffer just in one shot starting from x1, y1:

var w = 11, h = 11, cX = x, cY = cH - y, rc = ~~(0.5*w), x1 = cX - rc, y1 = cY + rc;

gl.readPixels(x1, y1, w, h, gl.RGBA, gl.UNSIGNED_BYTE, pickBuf);

Then, i am looping from the center of my buffer walking to the outside, following the red arrows, while checking for a positive response inside the picking buffer (collision found):

function readAt(i, pickBuf) {
    return pickBuf[i] << 16 | pickBuf[i+1] << 8 | pickBuf[i+2];
}

var l = rc;
while(l--) {
    /* Top-Left sector */
    var r = rc+(rc-l), c = l, p = r*w + c, i = 4*p;
    found = readAt(i, pickBuf) > 0;
    /* Top-Right sector */
    var r = rc+(rc-l), c = rc+(rc-l), p = r*w + c, i = 4*p;
    found = readAt(i, pickBuf) > 0;
    /* Bottom-Left sector */
    var r = l, c = l, p = r*w + c, i = 4*p;
    found = readAt(i, pickBuf) > 0;
    /* Bottom-Right sector */
    var r = l, c = rc+(rc-l), p = r*w + c, i = 4*p;
    found = readAt(i, pickBuf) > 0;
}

The piece of code is working and I am able to pick a geometry, but now I believe I haven't understand correctly the whole coordinate system, because the collision result is always above and left of the point where it should be. Why this happens?

It seems to me that readPixels should read the bytes starting from the bottom-left corner of the canvas, to the top-right corner. Is that true, or I am missing something?

I am aware that the glcoordinate system is Y-inverted against my canvas, so I am defining the center of the picking buffer at cY = cH - y and the Y starting point for the picking buffer at y1 = cY + rc, but anyway this is giving me wrong results during my walk from the center to the outside of my picking square box. Where goes my interpretation of the coordinate system wrong?

Body:
It seems to me that readPixels should read the bytes starting from the
  bottom-left corner of the canvas, to the top-right corner. Is that
  true, or i am missing something?

Thats true

anyway this is giving me wrong results during my walk

With the exception of the middle pixel not being checked, it works for me, I suspect the issue to be elsewhere in your code.

// picking
c.addEventListener('click',function (e) {
  var
    cX = e.offsetX, // x within canvas
    cY = ctx.drawingBufferHeight - e.offsetY // y within canvas inverted, drawingbufferheight is same as canvas height
  ;

  var
    area = 11,
    halfArea = (area/2)|0,
    sX = cX-halfArea,
    sY = cY-halfArea
  ;
  console.log('Picking from ', sX, sY, area,area);
  // read data
  var data = new Uint8Array(area*area*4);
  ctx.readPixels(sX,sY,area,area,ctx.RGBA,ctx.UNSIGNED_BYTE,data);
  // draw cross
  (function (pickBuf,rc,w) {
  function readAt(i, pickBuf) {
      return pickBuf[i]=pickBuf[i+1]=pickBuf[i+2]=0;
  }
  // this is your unmodified loop
  var l = rc;
  while(l--) {
      /* Top-Left sector */
      var r = rc+(rc-l), c = l, p = r*w + c, i = 4*p;
      found = readAt(i, pickBuf) > 0;
      /* Top-Right sector */
      var r = rc+(rc-l), c = rc+(rc-l), p = r*w + c, i = 4*p;
      found = readAt(i, pickBuf) > 0;
      /* Bottom-Left sector */
      var r = l, c = l, p = r*w + c, i = 4*p;
      found = readAt(i, pickBuf) > 0;
      /* Bottom-Right sector */
      var r = l, c = rc+(rc-l), p = r*w + c, i = 4*p;
      found = readAt(i, pickBuf) > 0;
  }
  })(data,halfArea,area);

  // create preview
  var octx = document.createElement('canvas').getContext('2d');
  octx.canvas.classList.add('preview');
  octx.canvas.width = octx.canvas.height = area;
  var idata = octx.createImageData(area,area);
  idata.data.set(data);
  octx.putImageData(idata,0,0);
  ctx.canvas.parentElement.insertBefore(octx.canvas,ctx.canvas);
});

// context setup
var ctx = c.getContext('webgl',{preserveDrawingBuffer:true});
ctx.canvas.width = ctx.canvas.height = 256;
ctx.viewport(0,0,256,256);
// shader setup
var vs=ctx.createShader(ctx.VERTEX_SHADER),fs=ctx.createShader(ctx.FRAGMENT_SHADER),prg=ctx.createProgram();
ctx.shaderSource(vs,`
  attribute vec2 vPos;
  void main(){gl_Position=vec4(vPos,0,1);}
`);
ctx.shaderSource(fs,`
  precision highp float;
  void main(){
  vec2 p=(gl_FragCoord.xy/256.)*2.-1.;
  gl_FragColor=vec4(sign(p),sign(-p.r),1);
  }
`);
ctx.compileShader(vs);
ctx.compileShader(fs);
ctx.attachShader(prg,vs);
ctx.attachShader(prg,fs);
ctx.linkProgram(prg);
// screenspace setup
var ssq = ctx.createBuffer();
ctx.bindBuffer(ctx.ARRAY_BUFFER,ssq);
ctx.bufferData(ctx.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,1,1,-1,1]),ctx.STATIC_DRAW);
ctx.vertexAttribPointer(0,2,ctx.FLOAT,false,0,0);
ctx.enableVertexAttribArray(0);
// draw
ctx.useProgram(prg);
ctx.drawArrays(ctx.TRIANGLE_FAN,0,4);

h2{text-align:center;font-family: Arial,sans-serif;}
#c{display:block;margin:0 auto;outline:1px solid red;cursor:crosshair;}

.preview {
width: 64px;
height: 64px;
outline: none;
display:inline;
image-rendering: pixelated;
transform:scaleY(-1);
margin: 10px;
}

<h2>Click 2 Pick</h2>
<canvas id="c"></canvas>


问:
ASP.NET Core 2.0 Get a List of Models and then get the Model Columns - options for this
ASP.NET Core 2.0  Get a List of Models and then get the Model Columns - What are my options for this?. There are 2 key items that I'm trying to accomplish. 1. Get a list of Models from ApplicationDBContext with GetModels(). This part works fine and I get a list of models. 2. Get a list of Columns from a Model with GetModelColumns and passing the the modelName as a string. How do I get the results for PropertyInfo?

Since I cannot instatiate a new PropertyInfo() should I use typeof ?

using System.Reflection;

```<code>    public static List<PropertyInfo> GetModels()
    {
        //Get the list of Models in ApplicationDbContext
        var propertyInfoList = typeof(ApplicationDbContext).GetProperties().ToList();
        return propertyInfoList;
    }

    public static PropertyInfo GetModelColumns(string modelName)
    {
        //return the Columns associated with the Model
    //How should this be done?
        //Cannot instatiate a new PropertyInfo()
        //Use typeof?
        var propertyInfo = new PropertyInfo();
        var propertyInfoList = GetModels();
        propertyInfo = propertyInfoList.Single(s => s.Name == modelName);
        return propertyInfo;
    }

    public async Task<IActionResult> DetailsAsync(string? modelName)
    {
    string strColumnName="";
    var myModel = GetModelColumns(modelName));
    foreach(var item in myModel)
        {
           strColumnName=item.Name;
        }
}
</code>```

答:
I would do this slightly differently. There's no point getting all of the properties of your context when you only want a single model. Secondly, the property type is going to be a DbSet<T> so you need to get the generic type. So you can do something like this:

```<code>public static IEnumerable<string> GetColumns<TEntity>(string modelName)
{
    var property = typeof(TEntity)
        .GetProperties()
        .Single(s => s.Name == modelName);

    return property.PropertyType
        .GetGenericArguments() //Get the generic type of the DbSet
        .SelectMany(t => t.GetProperties()
            .Select(pi => pi.Name));
}
</code>```

You should probably put some type checking and validation on this, but this could be called like this:

```<code>var columns = GetColumns<ApplicationDbContext>("SomeProperty");
</code>```

Body:
ASP.NET Core 2.0  Get a List of Models and then get the Model Columns - What are my options for this?. There are 2 key items that I'm trying to accomplish. 1. Get a list of Models from ApplicationDBContext with GetModels(). This part works fine and I get a list of models. 2. Get a list of Columns from a Model with GetModelColumns and passing the the modelName as a string. How do I get the results for PropertyInfo?

Since I cannot instatiate a new PropertyInfo() should I use typeof ?

using System.Reflection;

    public static List<PropertyInfo> GetModels()
    {
        //Get the list of Models in ApplicationDbContext
        var propertyInfoList = typeof(ApplicationDbContext).GetProperties().ToList();
        return propertyInfoList;
    }

    public static PropertyInfo GetModelColumns(string modelName)
    {
        //return the Columns associated with the Model
    //How should this be done?
        //Cannot instatiate a new PropertyInfo()
        //Use typeof?
        var propertyInfo = new PropertyInfo();
        var propertyInfoList = GetModels();
        propertyInfo = propertyInfoList.Single(s => s.Name == modelName);
        return propertyInfo;
    }

    public async Task<IActionResult> DetailsAsync(string? modelName)
    {
    string strColumnName="";
    var myModel = GetModelColumns(modelName));
    foreach(var item in myModel)
        {
           strColumnName=item.Name;
        }
}

Body:
I would do this slightly differently. There's no point getting all of the properties of your context when you only want a single model. Secondly, the property type is going to be a DbSet<T> so you need to get the generic type. So you can do something like this:

public static IEnumerable<string> GetColumns<TEntity>(string modelName)
{
    var property = typeof(TEntity)
        .GetProperties()
        .Single(s => s.Name == modelName);

    return property.PropertyType
        .GetGenericArguments() //Get the generic type of the DbSet
        .SelectMany(t => t.GetProperties()
            .Select(pi => pi.Name));
}

You should probably put some type checking and validation on this, but this could be called like this:

var columns = GetColumns<ApplicationDbContext>("SomeProperty");


问:
Does ColdFusion Builder have split screen editing like Homesite+, and how do I turn it on?
Does ColdFusion Builder have split screen editing like Homesite+, and how do I turn it on?  How do I activate word wrap?

Thanks much!

答: In ColdFusion Builder 2016 the keyboard shortcut is: (CTRL+SHIFT+_) AND (CTRL+SHIFT+{)</p>


问:
type signature of uncurry function
```<code>uncurry f=\(a,b)->f a b
</code>```

uncurry converts a curried function to a function on pairs, but the function above just converts it to a curried function f a b. Doesn't that contradict the definition of the uncurry function?

答:
You can write a function which behaves the same way (and with the same signature) without a lambda:

```<code>uncurry' :: (a -> b -> c) -> ((a, b) -> c)
uncurry' f (a,b) = f a b
</code>```

I think this version is easier to read. If you have a tupel and a function which takes two single values (or more exact, which takes one value and returns a function that takes the next value), the uncurry' function does the "unwrapping" of the tuple for us.

Generally if you see something like

```<code>f x y z = x + y + z
</code>```

it's the same as

```<code>f = \x y z -> x + y + z
</code>```

or

```<code>f x = \y -> (\z -> x + y + z)
</code>```

Title: type signature of uncurry function

Body:
uncurry f=\(a,b)->f a b

uncurry converts a curried function to a function on pairs, but the function above just converts it to a curried function f a b. Doesn't that contradict the definition of the uncurry function?

Body:
You can write a function which behaves the same way (and with the same signature) without a lambda:

uncurry' :: (a -> b -> c) -> ((a, b) -> c)
uncurry' f (a,b) = f a b

I think this version is easier to read. If you have a tupel and a function which takes two single values (or more exact, which takes one value and returns a function that takes the next value), the uncurry' function does the "unwrapping" of the tuple for us.

Generally if you see something like

f x y z = x + y + z

it's the same as

f = \x y z -> x + y + z

or

f x = \y -> (\z -> x + y + z)


问:
Passing # character in url with python
I have the following code:

```<code>@app.route('/famcall/Audio/AudioMng_PlayDTMF/<string:output_stream>/<string:dtmf>/<string:duration>/<string:gap>', methods=['GET'])
    def fam_audio_play_dtmf(output_stream, dtmf, duration, gap):
        params = [self.mapAudioOutputStream.business_to_tech(output_stream), dtmf, duration, gap]
        return self.call_fam_function_and_wait_response("AudioMng_PlayDTMF", params)
</code>```

and I want to use the character # in my url because it´s a value that can be used for dtmf. Is there an encode function in python which can help me in this? Or should I forget this scenario?

答: You can use a replacement: replace # with %23.

Title: Passing # character in url with python

Body:
I have the following code:

@app.route('/famcall/Audio/AudioMng_PlayDTMF/<string:output_stream>/<string:dtmf>/<string:duration>/<string:gap>', methods=['GET'])
    def fam_audio_play_dtmf(output_stream, dtmf, duration, gap):
        params = [self.mapAudioOutputStream.business_to_tech(output_stream), dtmf, duration, gap]
        return self.call_fam_function_and_wait_response("AudioMng_PlayDTMF", params)

and I want to use the character # in my url because it´s a value that can be used for dtmf. Is there an encode function in python which can help me in this? Or should I forget this scenario?


问:
Cordova cannot read property 'name' of undefined with --target
Whenver I run ionic/cordova emulator command with the --target param specified, I get the cannot read property 'name' of undefined error. Was wondering if anyone else has gotten this before, and if there is a fix available.

Commands Run: ionic cordova emulate ios --target="iPhone-6, 10.3" and ionic cordova emulate ios --target "iPhone-6, 10.3"

Here is my ionic info

cli packages:

```<code>@ionic/cli-utils  : 1.9.2
ionic (Ionic CLI) : 3.9.2
</code>```

global packages:

```<code>Cordova CLI : 7.0.1
</code>```

local packages:

```<code>@ionic/app-scripts : 2.1.4
Cordova Platforms  : android 6.1.2 ios 4.4.0
Ionic Framework    : ionic-angular 3.6.0
</code>```

System:

```<code>Android SDK Tools : 25.2.2
ios-deploy        : 1.8.5
ios-sim           : 6.0.0
Node              : v6.8.1
npm               : 3.10.8
OS                : macOS Sierra
Xcode             : Xcode 8.3.3 Build version 8E3004b
</code>```

答:
If you run the following and get no devices (as shown):

```<code>cordova run ios --list
Available ios devices:
Available ios virtual devices:
</code>```

This is likely due to Ionic specifying old ios-sim version 4.4.0 instead of the latest.

```<code>cd platforms/ios/cordova && npm install ios-sim@latest
$ cd ../../../
$ cordova platform rm ios
$ cordova platform add ios@4.5.0
$ ionic cordova emulate ios --target --list
> cordova run ios --list --target --emulator
Available ios devices:

Available ios virtual devices:

iPhone-5s, 11.0
iPhone-6, 11.0
iPhone-6-Plus, 11.0
iPhone-6s, 11.0
iPhone-6s-Plus, 11.0
iPad-Air, 11.0
iPad-Air-2, 11.0
iPhone-7, 11.0
iPhone-7-Plus, 11.0
iPhone-SE, 11.0
iPad--5th-generation-, 11.0
iPad-Pro--12-9-inch---2nd-generation-, 11.0
iPad-Pro--10-5-inch-, 11.0
Apple-Watch-38mm, watchOS 4.0
Apple-Watch-42mm, watchOS 4.0
Apple-Watch-Series-2-38mm, watchOS 4.0
Apple-Watch-Series-2-42mm, watchOS 4.0
Apple-TV-1080p, tvOS 11.0
Apple-TV-4K-4K, tvOS 11.0
Apple-TV-4K-1080p, tvOS 11.0
iPad-Pro--9-7-inch-, 11.0
iPad-Pro, 11.0
</code>```

You can read more about this issue here on Git

Body:
Whenver I run ionic/cordova emulator command with the --target param specified, I get the cannot read property 'name' of undefined error. Was wondering if anyone else has gotten this before, and if there is a fix available.

Commands Run: ionic cordova emulate ios --target="iPhone-6, 10.3" and ionic cordova emulate ios --target "iPhone-6, 10.3"

Here is my ionic info

cli packages:

@ionic/cli-utils  : 1.9.2
ionic (Ionic CLI) : 3.9.2

global packages:

Cordova CLI : 7.0.1

local packages:

@ionic/app-scripts : 2.1.4
Cordova Platforms  : android 6.1.2 ios 4.4.0
Ionic Framework    : ionic-angular 3.6.0

System:

Android SDK Tools : 25.2.2
ios-deploy        : 1.8.5
ios-sim           : 6.0.0
Node              : v6.8.1
npm               : 3.10.8
OS                : macOS Sierra
Xcode             : Xcode 8.3.3 Build version 8E3004b

Body:
If you run the following and get no devices (as shown):

cordova run ios --list
Available ios devices:
Available ios virtual devices:

This is likely due to Ionic specifying old ios-sim version 4.4.0 instead of the latest.

cd platforms/ios/cordova && npm install ios-sim@latest
$ cd ../../../
$ cordova platform rm ios
$ cordova platform add ios@4.5.0
$ ionic cordova emulate ios --target --list
> cordova run ios --list --target --emulator
Available ios devices:

Available ios virtual devices:

iPhone-5s, 11.0
iPhone-6, 11.0
iPhone-6-Plus, 11.0
iPhone-6s, 11.0
iPhone-6s-Plus, 11.0
iPad-Air, 11.0
iPad-Air-2, 11.0
iPhone-7, 11.0
iPhone-7-Plus, 11.0
iPhone-SE, 11.0
iPad--5th-generation-, 11.0
iPad-Pro--12-9-inch---2nd-generation-, 11.0
iPad-Pro--10-5-inch-, 11.0
Apple-Watch-38mm, watchOS 4.0
Apple-Watch-42mm, watchOS 4.0
Apple-Watch-Series-2-38mm, watchOS 4.0
Apple-Watch-Series-2-42mm, watchOS 4.0
Apple-TV-1080p, tvOS 11.0
Apple-TV-4K-4K, tvOS 11.0
Apple-TV-4K-1080p, tvOS 11.0
iPad-Pro--9-7-inch-, 11.0
iPad-Pro, 11.0

You can read more about this issue here on Git


问:
MATLAB index within groups
Given a vector A of group numbers (such as the one returned by findgroups), how to return a vector B of the same length containing indices of elements within groups of A?

For example, if A = [1 1 1 2 2 2 1 1 2 2] then B = [1 2 3 1 2 3 4 5 4 5].

Add 1

My own solution to this is

```<code>s = splitapply(@(x) {x, [1:numel(x)]'}, [1:numel(A)]', A(:))
B(vertcat(s{:,1})) = vertcat(s{:,2})
</code>```

but it seems somewhat convoluted.

答:
A solution using sort and accumarray:

```<code>[s is]=sort(A);
idx = accumarray(s(:),1,[],@(x){1:numel(x)});
B(is)=[idx{:}];
</code>```

Another solution using the image processing toolbox:

```<code>p=regionprops(A,'PixelIdxList');
B = zeros(size(A));
for k = 1: numel(p)
    B(p(k).PixelIdxList) = 1:numel(p(k).PixelIdxList);
end
</code>```

Title: MATLAB index within groups

Body:
Given a vector A of group numbers (such as the one returned by findgroups), how to return a vector B of the same length containing indices of elements within groups of A?

For example, if A = [1 1 1 2 2 2 1 1 2 2] then B = [1 2 3 1 2 3 4 5 4 5].

Add 1

My own solution to this is

s = splitapply(@(x) {x, [1:numel(x)]'}, [1:numel(A)]', A(:))
B(vertcat(s{:,1})) = vertcat(s{:,2})

but it seems somewhat convoluted.

Body:
A solution using sort and accumarray:

[s is]=sort(A);
idx = accumarray(s(:),1,[],@(x){1:numel(x)});
B(is)=[idx{:}];

Another solution using the image processing toolbox:

p=regionprops(A,'PixelIdxList');
B = zeros(size(A));
for k = 1: numel(p)
    B(p(k).PixelIdxList) = 1:numel(p(k).PixelIdxList);
end


问:
mongodb 3.4.3 Permission denied wiredtiger_kv_engine.cpp 267 error with ubuntu 16
I'm having problems lauching mongod as a service:
How is it possible that it works when I do sudo mongod -f /etc/mongod.conf but when launching it with sudo service mongod start I get an error in the log

Assertion: 28595:13: Permission denied src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 267

I'm running mongodb on ubuntu 16

I followed exactly the instructions in the mongodb documentation for installation of that version, so is this a bug? Any suggestions how to solve this are appreciated.

Additional information:

The mongodb service startup script looks like this and runs it as user mongodb, could this be connected to the error?
lib/systemd/system/mongodb.service:

```<code>[Unit]
Description=MongoDB Database Service
Wants=network.target
After=network.target

[Service]
ExecStart=/usr/bin/mongod --config /etc/mongod.conf
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
User=mongodb
Group=mongodb
StandardOutput=syslog
StandardError=syslog

[Install]
WantedBy=multi-user.target
</code>```

答:
There are three set-ups that triggers this kind of problem :

MongoDB installation is configured to create database files at a given path and this path does not exist on your current system. This path is called  dbpath in mongo.

In your case, check if /data/db exist. If it doesn't or if it is empty, mongod is trying the wrong dbpath. You need to find it, it's usually under /var/lib/mongodb.

Once you found it there's two thing you can do. First, copy all the file from there to /data/db. Second, change your dbpath under the mongod.conf file, which is located (in linux) at /etc/mongod.conf. Make sure to start mongod with the --config specifying the configuration file.

MongoDB does not have the permission to read one or more files or directories corresponding to its dbpath.

chown mongodb:mongodb dbpath -R.

MongoDB is missing WiredTiger.wt . This can happen if you remove files under the dbpath or if there's a device failure. We do it for testing a recovery strategy for example.

If you're sure dbpath is correct and that there's no instance of WiredTiger.wt there. Your database is broken. There are no ways to ensure integrity if you lose this file. Reinstall mongodb by :

sudo apt-get purge mongodb-org*

sudo rm -r dbpath

sudo apt-get install mongodb-org

Edit :
Or copy dbpath from one of your replicas.

Body:
I'm having problems lauching mongod as a service:
How is it possible that it works when I do sudo mongod -f /etc/mongod.conf but when launching it with sudo service mongod start I get an error in the log

Assertion: 28595:13: Permission denied src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 267

I'm running mongodb on ubuntu 16

I followed exactly the instructions in the mongodb documentation for installation of that version, so is this a bug? Any suggestions how to solve this are appreciated.

Additional information:

The mongodb service startup script looks like this and runs it as user mongodb, could this be connected to the error?
lib/systemd/system/mongodb.service:

[Unit]
Description=MongoDB Database Service
Wants=network.target
After=network.target

[Service]
ExecStart=/usr/bin/mongod --config /etc/mongod.conf
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
User=mongodb
Group=mongodb
StandardOutput=syslog
StandardError=syslog

[Install]
WantedBy=multi-user.target

ContentLicense: CC BY-SA 4.0


问:
Styled Components: props for hover

I want to apply a &:hover only when a prop is passed - in this situacion: animated

```<code>const AnimationContainer = styled.div`
  transform: translate(0%);
  transition: 0.3s ease-out;

  &:hover { // apply hover only when $(props.animated) is paased
     position: fixed;
     transform: translate(0%, -30%);
     transition: 0.3s ease-out;
   }
`;
</code>```

Does anyone have a suggestion how to do it?
I guess it would be possible to apply the styling for every property just starting with .. :$(props => props.animated ? ..), but is there a simpler solution?

答:
Yup! Like this:

```<code>import styled, { css } from 'styled-components'

const AnimationContainer = styled.div`
  transform: translate(0%);
  transition: 0.3s ease-out;

  ${props => props.animated && css`
    &:hover {
      position: fixed;
      transform: translate(0%, -30%);
      transition: 0.3s ease-out;
    }
  `}
`

export default AnimationContainer
</code>```

And then you may use it like this:

```<code>import AnimationContainer from './path/to/AnimationContainer

// some component here…
  render() {
    return (
      <!-- some JSX element… -->
        <AnimationContainer animated>
          With animation
        </AnimationContainer>
        <AnimationContainer>
          Without animation
        </AnimationContainer>
      <!-- end of some JSX element… -->
    )
  }
</code>```

Learn more about props and css in Styled Components.

Title: Styled Components: props for hover

Body:
I want to apply a &:hover only when a prop is passed - in this situacion: animated

const AnimationContainer = styled.div`
  transform: translate(0%);
  transition: 0.3s ease-out;

  &:hover { // apply hover only when $(props.animated) is paased
     position: fixed;
     transform: translate(0%, -30%);
     transition: 0.3s ease-out;
   }
`;

Does anyone have a suggestion how to do it?
I guess it would be possible to apply the styling for every property just starting with .. :$(props => props.animated ? ..), but is there a simpler solution?

Body:
Yup! Like this:

import styled, { css } from 'styled-components'

const AnimationContainer = styled.div`
  transform: translate(0%);
  transition: 0.3s ease-out;

  ${props => props.animated && css`
    &:hover {
      position: fixed;
      transform: translate(0%, -30%);
      transition: 0.3s ease-out;
    }
  `}
`

export default AnimationContainer

And then you may use it like this:

import AnimationContainer from './path/to/AnimationContainer

// some component here…
  render() {
    return (
      <!-- some JSX element… -->
        <AnimationContainer animated>
          With animation
        </AnimationContainer>
        <AnimationContainer>
          Without animation
        </AnimationContainer>
      <!-- end of some JSX element… -->
    )
  }

Learn more about props and css in Styled Components.


问:
Detect duplicate MP3 files with different bitrates and/or different ID3 tags?
How could I detect (preferably with Python) duplicate MP3 files that can be encoded with different bitrates (but they are the same song) and ID3 tags that can be incorrect?

I know I can do an MD5 checksum of the files content but that won't work for different bitrates. And I don't know if ID3 tags have influence in generating the MD5 checksum. Should I re-encode MP3 files that have a different bitrate and then I can do the checksum? What do you recommend?

答:
The exact same question that people at the old AudioScrobbler and currently at MusicBrainz have worked on since long ago. For the time being, the Python project that can aid in your quest, is Picard, which will tag audio files (not only MPEG 1 Layer 3 files) with a GUID (actually, several of them), and from then on, matching the tags is quite simple.

If you prefer to do it as a project of your own, libofa might be of help.

OwnerDisplayName: Antonio Melé

OwnerDisplayName: ΤΖΩΤΖΙΟΥ


问:
How to change progress bar's progress color in Android
I'm using an horizontal progress bar in my Android application, and I want to change its progress color (which is Yellow by default). How can I do it using code (not XML)?

答:
You can try to change your Styles, Themes, or using android:indeterminateTint="@color/yourColor" anywhere you want, but there's just one way o doing that will work on any Android SKD version:

If you progress bar is not indeterminate, please use:

```<code>progressBar.getProgressDrawable().setColorFilter(ContextCompat.getColor(context, R.color.yourColor), PorterDuff.Mode.SRC_IN );
</code>```

If you progress bar is indeterminate, please use:

```<code>progressBar.getIndeterminateDrawable().setColorFilter(ContextCompat.getColor(getContext(), R.color.yourColor), PorterDuff.Mode.SRC_IN );
</code>```

It's sad that Android is such a mess!

Body:
You can try to change your Styles, Themes, or using android:indeterminateTint="@color/yourColor" anywhere you want, but there's just one way o doing that will work on any Android SKD version:

If you progress bar is not indeterminate, please use:

progressBar.getProgressDrawable().setColorFilter(ContextCompat.getColor(context, R.color.yourColor), PorterDuff.Mode.SRC_IN );

If you progress bar is indeterminate, please use:

progressBar.getIndeterminateDrawable().setColorFilter(ContextCompat.getColor(getContext(), R.color.yourColor), PorterDuff.Mode.SRC_IN );

It's sad that Android is such a mess!