问:
Single line break in body of powershell MailMessage not working
For some reason when attempting to populate the body of an email in powershell, a single line break using the `n escape sequence is not working, however a double is.

This is my code...

```<code>param([string]$BuildId, [string]$BuildName)

$EmailTo = "[email]"
$EmailFrom = "sepaautomation@gmail.com"
$Subject = "$BuildName $BuildId SpecFlow Reports"
$Body = "The following SpecFlow reports are attached: `n`n"
$SMTPServer = "smtp.sendgrid.net"

$date = Get-Date -Format yyyy-MM-dd

$files = Get-ChildItem "C:\Build\SA.SEPA.Web.UI.Selenium" -Recurse | Where-Object { $_.Name -match "^.*$date.*\.html$" } | % { $_.FullName }

foreach($item in $files)
{
    $Body += "$item `n"
}

$SMTPMessage = New-Object System.Net.Mail.MailMessage($EmailFrom,$EmailTo,$Subject,$Body)

foreach($item in $files)
{
    $attachment = New-Object System.Net.Mail.Attachment($item)
    $SMTPMessage.Attachments.Add($attachment)
}

$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("apikey", "[apiKey]");
$SMTPClient.Send($SMTPMessage)
</code>```

This is the section that is failing to add a line break

```<code>foreach($item in $files)
{
    $Body += "$item `n"
}
</code>```

My email in outlook looks like the following....

You can see that the `n `n double line break has been applied but not the `n. Incidentally if I change to...

```<code>foreach($item in $files)
{
    $Body += "$item `n`n"
}
</code>```

I do see a double line break.

How do I get just a single line break?

答:
If you OK to use HTML body you can use
 for line breaks.
You will need to set following property on your message variable:

```<code>$SMTPMessage.IsBodyHTML = $true

$Body += "$item <br>"
</code>```

Body:
For some reason when attempting to populate the body of an email in powershell, a single line break using the `n escape sequence is not working, however a double is.

This is my code...

param([string]$BuildId, [string]$BuildName)

$EmailTo = "[email]"
$EmailFrom = "sepaautomation@gmail.com"
$Subject = "$BuildName $BuildId SpecFlow Reports"
$Body = "The following SpecFlow reports are attached: `n`n"
$SMTPServer = "smtp.sendgrid.net"

$date = Get-Date -Format yyyy-MM-dd

$files = Get-ChildItem "C:\Build\SA.SEPA.Web.UI.Selenium" -Recurse | Where-Object { $_.Name -match "^.*$date.*\.html$" } | % { $_.FullName }

foreach($item in $files)
{
    $Body += "$item `n"
}

$SMTPMessage = New-Object System.Net.Mail.MailMessage($EmailFrom,$EmailTo,$Subject,$Body)

foreach($item in $files)
{
    $attachment = New-Object System.Net.Mail.Attachment($item)
    $SMTPMessage.Attachments.Add($attachment)
}

$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("apikey", "[apiKey]");
$SMTPClient.Send($SMTPMessage)

This is the section that is failing to add a line break

foreach($item in $files)
{
    $Body += "$item `n"
}

My email in outlook looks like the following....

You can see that the `n `n double line break has been applied but not the `n. Incidentally if I change to...

foreach($item in $files)
{
    $Body += "$item `n`n"
}

I do see a double line break.

How do I get just a single line break?

Body:
If you OK to use HTML body you can use <br> for line breaks.
You will need to set following property on your message variable:

$SMTPMessage.IsBodyHTML = $true

$Body += "$item <br>"


来源: stackexchange

问:
Unrecognized configuration section system.web/system.webServer
I am following the walkthrough for creating a synchronous http handler and choose the registration via integrated mode in IIS 7.5.

Using a web site project in Visual Studio 2010, for .NET 4.0, on IIS 7.5 the error message for the following part in web.config:

```<code><configuration>
    <system.web>
        <compilation debug="false" targetFramework="4.0">
        </compilation>
        <system.webServer>
            <validation validateIntegratedModeConfiguration="false" />
            <handlers>
                <add verb="*" path="*.sample" name="Logger" type="Logger"/>
            </handlers>
        </system.webServer>
        <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
    </system.web>
</configuration>
</code>```

is: Unrecognized configuration section system.web/system.webServer. It si an invalid child element. How should I fix it and why is it not recognized?

答: System.WebServer is a child node of Configuration and not System.Web.  So, move the System.WebServer section outside of the System.Web section.</p>

ContentLicense: CC BY-SA 2.5

Body:
I am following the walkthrough for creating a synchronous http handler and choose the registration via integrated mode in IIS 7.5.

Using a web site project in Visual Studio 2010, for .NET 4.0, on IIS 7.5 the error message for the following part in web.config:

<configuration>
    <system.web>
        <compilation debug="false" targetFramework="4.0">
        </compilation>
        <system.webServer>
            <validation validateIntegratedModeConfiguration="false" />
            <handlers>
                <add verb="*" path="*.sample" name="Logger" type="Logger"/>
            </handlers>
        </system.webServer>
        <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
    </system.web>
</configuration>

is: Unrecognized configuration section system.web/system.webServer. It si an invalid child element. How should I fix it and why is it not recognized?


问:
NullPointerException when referring to val defined in subclass
I have a case class that extends an abstract class. In its primary constructor, the superclass refers to an abstract value that is defined in the subclass.

```<code>abstract class SuperClass {
    def abstractValue: Seq[Int]

    val concreteValue: Int = {
        abstractValue.head
    }
}

case class SubClass() extends SuperClass {
    override val abstractValue: Seq[Int] = Seq(1,2,3)
}
</code>```

What I would expect is that creating an instance of SubClass would result in an object with abstractValue = Seq(1,2,3) and concreteValue = 1. However, creating an instance of SubClass throws a NullPointerException, because Scala tries to initialise concreteValue before abstractValue, which means that the latter is null when the former is initialised.

How do I make this work? Some things I've tried:

Changing the declaration of abstractValue in SubClass from a val to a def solves the problem, but this has the unintended consequence of abstractValue being reinitialised every time it is referenced. This might be fine in the example, but not in the following cases:

The initialisation of abstractValue is expensive.

The initialisation of abstractValue is not repeatable (my use case).

The same goes for changing the declaration of concreteValue in SuperClass from val to def.

Changing the declaration of abstractValue in SuperClass from a def to a val does not solve the problem.

It would probably be possible to solve this using var instead of val, but I like my case class instances immutable, thank you very much.

答:
The only solution I have found that satisfies all restrictions mentioned in the question is changing the initialisation of abstractValue to a lazy one:

```<code>override lazy val abstractValue: Seq[Int] = Seq(1,2,3)
</code>```

This counterintuitively causes the initalisation of abstractValue to happen earlier than it would otherwise. Specifically, it happens "when it's needed", which is during the initialisation of concreteValue.

EDIT: As Shane Perry remarks in the comments, defining concreteValue as lazy (instead of abstractValue) also solves the problem. This approach is both more intuitive and more maintainable.

ContentLicense: CC BY-SA 3.0

Body:
I have a case class that extends an abstract class. In its primary constructor, the superclass refers to an abstract value that is defined in the subclass.

abstract class SuperClass {
    def abstractValue: Seq[Int]

    val concreteValue: Int = {
        abstractValue.head
    }
}

case class SubClass() extends SuperClass {
    override val abstractValue: Seq[Int] = Seq(1,2,3)
}

What I would expect is that creating an instance of SubClass would result in an object with abstractValue = Seq(1,2,3) and concreteValue = 1. However, creating an instance of SubClass throws a NullPointerException, because Scala tries to initialise concreteValue before abstractValue, which means that the latter is null when the former is initialised.

How do I make this work? Some things I've tried:

Changing the declaration of abstractValue in SubClass from a val to a def solves the problem, but this has the unintended consequence of abstractValue being reinitialised every time it is referenced. This might be fine in the example, but not in the following cases:

The initialisation of abstractValue is expensive.

The initialisation of abstractValue is not repeatable (my use case).

The same goes for changing the declaration of concreteValue in SuperClass from val to def.

Changing the declaration of abstractValue in SuperClass from a def to a val does not solve the problem.

It would probably be possible to solve this using var instead of val, but I like my case class instances immutable, thank you very much.

Body:
The only solution I have found that satisfies all restrictions mentioned in the question is changing the initialisation of abstractValue to a lazy one:

override lazy val abstractValue: Seq[Int] = Seq(1,2,3)

This counterintuitively causes the initalisation of abstractValue to happen earlier than it would otherwise. Specifically, it happens "when it's needed", which is during the initialisation of concreteValue.

EDIT: As Shane Perry remarks in the comments, defining concreteValue as lazy (instead of abstractValue) also solves the problem. This approach is both more intuitive and more maintainable.


问:
tensorflow inception retrain
I was following this tutorial at https://www.tensorflow.org/versions/master/tutorials/image_retraining

After I went through a few hurdles, I got retrain.py running. Then I realized the new model was only able to classify images for the new categories I added. I am wondering if there is anything I did wrong here. I thought the new model should handle newly added categories in addition to the 1000 classes pre-trained for. Any input/comment is appreciated. Thanks.

答:
The naive answer is: No you should'nt. Because the idea behind retrain is Transfer Learning.

According to Wikipedia

Transfer Learning focuses on storing knowledge gained while solving one problem and applying it to a different but related problem.

So source and target labels should be different.

But of course you can do what you want by combining source and target datasets and run the model by feeding the combined dataset. In your case training would take too much time, because inception dataset is not really small.

Title: tensorflow inception retrain


问:
Laravel access directly to json array in blade without using foreach statement
in this result:

```<code>LengthAwarePaginator {#251 ▼
  #total: 2
  #lastPage: 1
  #items: Collection {#246 ▼
    #items: array:2 [▼
      0 => ProductCategories {#247 ▼
        ...
        #attributes: array:6 [▼
          "id" => 1
          "category_name" => "test"
          "lang" => "fa"
          "images" => "{"images":{"original":"\/uploads\/post_images\/2017\/1512736029.jpeg","300":"\/uploads\/post_images\/2017\/300_1512736029.jpeg","600":"\/uploads\/post_images\/2017\/600_1512736029.jpeg","900":"\/uploads\/post_images\/2017\/900_1512736029.jpeg"},"thumbnail":"\/uploads\/post_images\/2017\/300_1512736029.jpeg"} ◀"
          "created_at" => "2017-12-08 10:47:56"
          "updated_at" => "2017-12-08 12:27:10"
        ]
        #original: array:6 [▼
          "id" => 1
          "category_name" => "test test"
          "lang" => "fa"
          "images" => "{"images":{"original":"\/uploads\/post_images\/2017\/1512736029.jpeg","300":"\/uploads\/post_images\/2017\/300_1512736029.jpeg","600":"\/uploads\/post_images\/2017\/600_1512736029.jpeg","900":"\/uploads\/post_images\/2017\/900_1512736029.jpeg"},"thumbnail":"\/uploads\/post_images\/2017\/300_1512736029.jpeg"} ◀"
          "created_at" => "2017-12-08 10:47:56"
          "updated_at" => "2017-12-08 12:27:10"
        ]
        ...
      }
      1 => ProductCategories {#248 ▶}
    ]
  }
</code>```

which i get from this query:

```<code>$categories = ProductCategories::paginate(10);
dd($categories);
</code>```

i'm trying to access to "images" column data such as thumbnail and 300 or etc, when i use foreach this data and show that on table i can't access to them, for example:

```<code>{{$categories->images->thumbnail}}
</code>```

but i get Undefined property error and i can't show that

答:
The variable $categories is a Collection, so you need to get each individual object to get its data. For this you'll need to use a foreach.

```<code>@foreach($categories as $category)
    {{ $category->images }}
@endforeach
</code>```

And to have access to thumbnail you'll need to decode the json string that you have in images. For that, you can use json_decode($category->images) function. This will return an array with thumbnail as key.

Body:
in this result:

LengthAwarePaginator {#251 ▼
  #total: 2
  #lastPage: 1
  #items: Collection {#246 ▼
    #items: array:2 [▼
      0 => ProductCategories {#247 ▼
        ...
        #attributes: array:6 [▼
          "id" => 1
          "category_name" => "test"
          "lang" => "fa"
          "images" => "{"images":{"original":"\/uploads\/post_images\/2017\/1512736029.jpeg","300":"\/uploads\/post_images\/2017\/300_1512736029.jpeg","600":"\/uploads\/post_images\/2017\/600_1512736029.jpeg","900":"\/uploads\/post_images\/2017\/900_1512736029.jpeg"},"thumbnail":"\/uploads\/post_images\/2017\/300_1512736029.jpeg"} ◀"
          "created_at" => "2017-12-08 10:47:56"
          "updated_at" => "2017-12-08 12:27:10"
        ]
        #original: array:6 [▼
          "id" => 1
          "category_name" => "test test"
          "lang" => "fa"
          "images" => "{"images":{"original":"\/uploads\/post_images\/2017\/1512736029.jpeg","300":"\/uploads\/post_images\/2017\/300_1512736029.jpeg","600":"\/uploads\/post_images\/2017\/600_1512736029.jpeg","900":"\/uploads\/post_images\/2017\/900_1512736029.jpeg"},"thumbnail":"\/uploads\/post_images\/2017\/300_1512736029.jpeg"} ◀"
          "created_at" => "2017-12-08 10:47:56"
          "updated_at" => "2017-12-08 12:27:10"
        ]
        ...
      }
      1 => ProductCategories {#248 ▶}
    ]
  }

which i get from this query:

$categories = ProductCategories::paginate(10);
dd($categories);

i'm trying to access to "images" column data such as thumbnail and 300 or etc, when i use foreach this data and show that on table i can't access to them, for example:

{{$categories->images->thumbnail}}

but i get Undefined property error and i can't show that

Body:
The variable $categories is a Collection, so you need to get each individual object to get its data. For this you'll need to use a foreach.

@foreach($categories as $category)
    {{ $category->images }}
@endforeach

And to have access to thumbnail you'll need to decode the json string that you have in images. For that, you can use json_decode($category->images) function. This will return an array with thumbnail as key.


问:
How to position views near the screen edges using Constraint Layout?
I am trying to change my GridLayout to the ConstraintLayout.

My grid looks like this:

```<code><android.support.v7.widget.GridLayout android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">

<com.app.widget.CircularColorProgressView
    android:id="@+id/progress_stage_asset"

    android:layout_width="@dimen/circular_color_progress_size_small"
    android:layout_height="@dimen/circular_color_progress_size_small"

    app:layout_gravity="center_horizontal"
    app:layout_column="0"
    app:layout_row="0"

    app:hideText="true"
    app:skipStartColor="true"/>

<TextView
    android:id="@+id/progress_text_stage_asset"

    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="@dimen/margin_small"

    app:layout_gravity="center_horizontal"
    app:layout_column="0"
    app:layout_row="1"

    style="@style/AppWidget.Text.Emphasized"
    android:gravity="center"
    android:textColor="@color/circular_progress_middle_color"
    android:text="text text text" />

<com.app.widget.CircularColorProgressView
    android:id="@+id/progress_stage_sync"

    android:layout_width="@dimen/circular_color_progress_size_small"
    android:layout_height="@dimen/circular_color_progress_size_small"

    app:layout_gravity="center_horizontal"
    app:layout_column="2"
    app:layout_row="0"

    app:hideText="true"
    app:skipStartColor="true"/>

<TextView
    android:id="@+id/progress_text_stage_sync"

    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="@dimen/margin_small"

    app:layout_gravity="center_horizontal"
    app:layout_column="2"
    app:layout_row="1"

    style="@style/AppWidget.Text.Emphasized"
    android:gravity="center"
    android:textColor="@color/circular_progress_middle_color"
    android:text="text text text" />

<com.app.widget.CircularColorProgressView
    android:id="@+id/progress_stage_completed"

    android:layout_width="@dimen/circular_color_progress_size_medium"
    android:layout_height="@dimen/circular_color_progress_size_medium"

    app:layout_gravity="center_horizontal"
    app:layout_column="0"
    app:layout_row="3"

    app:hideText="true"
    app:skipStartColor="true"/>

<TextView
    android:id="@+id/progress_text_stage_completed"

    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="@dimen/margin_small"

    app:layout_gravity="center_horizontal"
    app:layout_column="0"
    app:layout_row="4"

    style="@style/AppWidget.Text.Emphasized"
    android:gravity="center"
    android:textColor="@color/circular_progress_middle_color"
    android:text="@string/msg_in_store_commissioning_stage_completed" />

<View
    android:layout_width="0dp"
    android:layout_height="0dp"

    app:layout_column="1"
    app:layout_row="2"
    app:layout_columnWeight="1"
    app:layout_rowWeight="1"/>

<com.app.widget.CircularColorProgressView
    android:id="@+id/progress_stage_params"

    android:layout_width="@dimen/circular_color_progress_size_small"
    android:layout_height="@dimen/circular_color_progress_size_small"

    app:layout_gravity="center"
    app:layout_column="2"
    app:layout_row="3"

    app:hideText="true"
    app:skipStartColor="true"/>

</android.support.v7.widget.GridLayout>
</code>```

And it produces the output like this:

I am new to ConstraintLayout. Is there an easy way to accomplish the same behaviour using Constraint Layout? I guess it will be more efficient and clean.

Using RelativeLayout will be just to align left, right, bottom etc.
Using LinearLayout will be just to put some empty view in between those Circular views and add the specific weights to them.

But how it can be easly done with ConstraintLayout?

UPDATE:
Here is what i tried with ConstraintLayout so far:

```<code><?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.app.widget.CircularColorProgressView
    android:id="@+id/progress_stage_asset"
    android:layout_width="@dimen/circular_color_progress_size_small"
    android:layout_height="@dimen/circular_color_progress_size_small"
    android:layout_marginStart="16dp"
    app:hideText="true"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:skipStartColor="true" />

<TextView
    android:id="@+id/progress_text_stage_asset"

    style="@style/AppWidget.Text.Emphasized"
    android:layout_width="wrap_content"

    android:layout_height="wrap_content"
    android:layout_marginStart="8dp"
    android:layout_marginTop="12dp"

    android:gravity="center"
    android:text="text text text"
    android:textColor="@color/circular_progress_middle_color"
    app:layout_column="0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/progress_stage_asset"
    app:layout_gravity="center_horizontal"
    app:layout_row="1" />

<com.app.widget.CircularColorProgressView
    android:id="@+id/progress_stage_sync"
    android:layout_width="@dimen/circular_color_progress_size_small"
    android:layout_height="@dimen/circular_color_progress_size_small"
    android:layout_marginEnd="16dp"

    app:hideText="true"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:skipStartColor="true" />

<TextView
    android:id="@+id/progress_text_stage_sync"
    style="@style/AppWidget.Text.Emphasized"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginEnd="8dp"
    android:layout_marginTop="@dimen/margin_small"
    android:gravity="center"
    android:text="text text text"
    android:textColor="@color/circular_progress_middle_color"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/progress_stage_sync"
    app:layout_gravity="center_horizontal" />

<com.app.widget.CircularColorProgressView
    android:id="@+id/progress_stage_completed"

    android:layout_width="@dimen/circular_color_progress_size_medium"
    android:layout_height="@dimen/circular_color_progress_size_medium"

    android:layout_marginBottom="48dp"

    app:hideText="true"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_gravity="center_horizontal"
    app:skipStartColor="true" />

<TextView
    android:id="@+id/progress_text_stage_completed"

    style="@style/AppWidget.Text.Emphasized"
    android:layout_width="wrap_content"

    android:layout_height="wrap_content"

    android:layout_marginStart="3dp"
    android:layout_marginTop="@dimen/margin_small"
    android:gravity="center"
    android:text="@string/msg_in_store_commissioning_stage_completed"
    android:textColor="@color/circular_progress_middle_color"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/progress_stage_completed"
    app:layout_gravity="center_horizontal" />

<com.app.widget.CircularColorProgressView
    android:layout_width="@dimen/circular_color_progress_size_small"
    android:layout_height="@dimen/circular_color_progress_size_small"
    android:layout_marginBottom="80dp"
    android:layout_marginEnd="16dp"
    app:hideText="true"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:skipStartColor="true" />
</code>```

It produces pretty similiar to the Grid:

答:
It will be easy if you use design editor in android studio for accomplishing this.

Add android.support.constraint.ConstraintLayout as Parent in your view

>     To align a view in top - left

```<code>  app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintTop_toTopOf="parent"
</code>```

To align a view in top-right

```<code> app:layout_constraintEnd_toEndOf="parent"
 app:layout_constraintTop_toTopOf="parent"
</code>```

To align a view in bottom-left

```<code> app:layout_constraintBottom_toBottomOf="parent"
 app:layout_constraintStart_toStartOf="parent"
</code>```

To align a view in bottom-right

```<code>  app:layout_constraintBottom_toBottomOf="parent"
  app:layout_constraintEnd_toEndOf="parent"
</code>```

To align a view to below of another view (in your case the TextView)

```<code> app:layout_constraintTop_toBottomOf="@+id/viewId"
</code>```

Body:
I am trying to change my GridLayout to the ConstraintLayout.

My grid looks like this:

<android.support.v7.widget.GridLayout android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">

<com.app.widget.CircularColorProgressView
    android:id="@+id/progress_stage_asset"

    android:layout_width="@dimen/circular_color_progress_size_small"
    android:layout_height="@dimen/circular_color_progress_size_small"

    app:layout_gravity="center_horizontal"
    app:layout_column="0"
    app:layout_row="0"

    app:hideText="true"
    app:skipStartColor="true"/>

<TextView
    android:id="@+id/progress_text_stage_asset"

    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="@dimen/margin_small"

    app:layout_gravity="center_horizontal"
    app:layout_column="0"
    app:layout_row="1"

    style="@style/AppWidget.Text.Emphasized"
    android:gravity="center"
    android:textColor="@color/circular_progress_middle_color"
    android:text="text text text" />

<com.app.widget.CircularColorProgressView
    android:id="@+id/progress_stage_sync"

    android:layout_width="@dimen/circular_color_progress_size_small"
    android:layout_height="@dimen/circular_color_progress_size_small"

    app:layout_gravity="center_horizontal"
    app:layout_column="2"
    app:layout_row="0"

    app:hideText="true"
    app:skipStartColor="true"/>

<TextView
    android:id="@+id/progress_text_stage_sync"

    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="@dimen/margin_small"

    app:layout_gravity="center_horizontal"
    app:layout_column="2"
    app:layout_row="1"

    style="@style/AppWidget.Text.Emphasized"
    android:gravity="center"
    android:textColor="@color/circular_progress_middle_color"
    android:text="text text text" />

<com.app.widget.CircularColorProgressView
    android:id="@+id/progress_stage_completed"

    android:layout_width="@dimen/circular_color_progress_size_medium"
    android:layout_height="@dimen/circular_color_progress_size_medium"

    app:layout_gravity="center_horizontal"
    app:layout_column="0"
    app:layout_row="3"

    app:hideText="true"
    app:skipStartColor="true"/>

<TextView
    android:id="@+id/progress_text_stage_completed"

    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="@dimen/margin_small"

    app:layout_gravity="center_horizontal"
    app:layout_column="0"
    app:layout_row="4"

    style="@style/AppWidget.Text.Emphasized"
    android:gravity="center"
    android:textColor="@color/circular_progress_middle_color"
    android:text="@string/msg_in_store_commissioning_stage_completed" />

<View
    android:layout_width="0dp"
    android:layout_height="0dp"

    app:layout_column="1"
    app:layout_row="2"
    app:layout_columnWeight="1"
    app:layout_rowWeight="1"/>

<com.app.widget.CircularColorProgressView
    android:id="@+id/progress_stage_params"

    android:layout_width="@dimen/circular_color_progress_size_small"
    android:layout_height="@dimen/circular_color_progress_size_small"

    app:layout_gravity="center"
    app:layout_column="2"
    app:layout_row="3"

    app:hideText="true"
    app:skipStartColor="true"/>

</android.support.v7.widget.GridLayout>

And it produces the output like this:

I am new to ConstraintLayout. Is there an easy way to accomplish the same behaviour using Constraint Layout? I guess it will be more efficient and clean.

Using RelativeLayout will be just to align left, right, bottom etc.
Using LinearLayout will be just to put some empty view in between those Circular views and add the specific weights to them.

But how it can be easly done with ConstraintLayout?

UPDATE:
Here is what i tried with ConstraintLayout so far:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.app.widget.CircularColorProgressView
    android:id="@+id/progress_stage_asset"
    android:layout_width="@dimen/circular_color_progress_size_small"
    android:layout_height="@dimen/circular_color_progress_size_small"
    android:layout_marginStart="16dp"
    app:hideText="true"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:skipStartColor="true" />

<TextView
    android:id="@+id/progress_text_stage_asset"

    style="@style/AppWidget.Text.Emphasized"
    android:layout_width="wrap_content"

    android:layout_height="wrap_content"
    android:layout_marginStart="8dp"
    android:layout_marginTop="12dp"

    android:gravity="center"
    android:text="text text text"
    android:textColor="@color/circular_progress_middle_color"
    app:layout_column="0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/progress_stage_asset"
    app:layout_gravity="center_horizontal"
    app:layout_row="1" />

<com.app.widget.CircularColorProgressView
    android:id="@+id/progress_stage_sync"
    android:layout_width="@dimen/circular_color_progress_size_small"
    android:layout_height="@dimen/circular_color_progress_size_small"
    android:layout_marginEnd="16dp"

    app:hideText="true"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:skipStartColor="true" />

<TextView
    android:id="@+id/progress_text_stage_sync"
    style="@style/AppWidget.Text.Emphasized"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginEnd="8dp"
    android:layout_marginTop="@dimen/margin_small"
    android:gravity="center"
    android:text="text text text"
    android:textColor="@color/circular_progress_middle_color"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/progress_stage_sync"
    app:layout_gravity="center_horizontal" />

<com.app.widget.CircularColorProgressView
    android:id="@+id/progress_stage_completed"

    android:layout_width="@dimen/circular_color_progress_size_medium"
    android:layout_height="@dimen/circular_color_progress_size_medium"

    android:layout_marginBottom="48dp"

    app:hideText="true"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_gravity="center_horizontal"
    app:skipStartColor="true" />

<TextView
    android:id="@+id/progress_text_stage_completed"

    style="@style/AppWidget.Text.Emphasized"
    android:layout_width="wrap_content"

    android:layout_height="wrap_content"

    android:layout_marginStart="3dp"
    android:layout_marginTop="@dimen/margin_small"
    android:gravity="center"
    android:text="@string/msg_in_store_commissioning_stage_completed"
    android:textColor="@color/circular_progress_middle_color"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/progress_stage_completed"
    app:layout_gravity="center_horizontal" />

<com.app.widget.CircularColorProgressView
    android:layout_width="@dimen/circular_color_progress_size_small"
    android:layout_height="@dimen/circular_color_progress_size_small"
    android:layout_marginBottom="80dp"
    android:layout_marginEnd="16dp"
    app:hideText="true"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:skipStartColor="true" />

It produces pretty similiar to the Grid:

Body:
It will be easy if you use design editor in android studio for accomplishing this.

Add android.support.constraint.ConstraintLayout as Parent in your view

>     To align a view in top - left

  app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintTop_toTopOf="parent"

To align a view in top-right

 app:layout_constraintEnd_toEndOf="parent"
 app:layout_constraintTop_toTopOf="parent"

To align a view in bottom-left

 app:layout_constraintBottom_toBottomOf="parent"
 app:layout_constraintStart_toStartOf="parent"

To align a view in bottom-right

  app:layout_constraintBottom_toBottomOf="parent"
  app:layout_constraintEnd_toEndOf="parent"

To align a view to below of another view (in your case the TextView)

 app:layout_constraintTop_toBottomOf="@+id/viewId"


问:
Histogram Bars not Centred over xticks in pyplot.hist
I guess I just didn't use the right keywords, because this probably has been asked before, but I didn't find a solution. Anyway, I have a problem where the the bars of a histogram do not line up with the xticks. I want the bars to be centred over the xticks they correspond to, but they get placed between ticks to fill the space in-between evenly.

```<code>import matplotlib.pyplot as plt

data = [1, 1, 1, 1.5, 2, 4, 4, 4, 4, 4.5, 5, 6, 6.5, 7, 9,9, 9.5]

bins = [x+n for n in range(1, 10) for x in [0.0, 0.5]]+[10.0]

plt.hist(data, bins, rwidth = .3)
plt.xticks(bins)
plt.show()
</code>```

答:
Note that what you are plotting here is not a histogram. A histogram would be

```<code>import matplotlib.pyplot as plt

data = [1, 1, 1, 1.5, 2, 4, 4, 4, 4, 4.5, 5, 6, 6.5, 7, 9,9, 9.5]

bins = [x+n for n in range(1, 10) for x in [0.0, 0.5]]+[10.0]

plt.hist(data, bins, edgecolor="k", alpha=1)
plt.xticks(bins)
plt.show()
</code>```

Here, the bars range between the bins as expected. E.g. you have 3 values in the interval 1 <= x < 1.5.

Conceptually what you want to do here is get a bar plot of the counts of data values. This would not require any bins at all and could be done as follows:

```<code>import numpy as np
import matplotlib.pyplot as plt

data = [1, 1, 1, 1.5, 2, 4, 4, 4, 4, 4.5, 5, 6, 6.5, 7, 9,9, 9.5]

u, inv = np.unique(data, return_inverse=True)
counts = np.bincount(inv)

plt.bar(u, counts, width=0.3)

plt.xticks(np.arange(1,10,0.5))
plt.show()
</code>```

Of course you can "misuse" a histogram plot to get a similar result. This would require to move the center of the bar to the left bin edge, plt.hist(.., align="left").

```<code>import matplotlib.pyplot as plt

data = [1, 1, 1, 1.5, 2, 4, 4, 4, 4, 4.5, 5, 6, 6.5, 7, 9,9, 9.5]

bins = [x+n for n in range(1, 10) for x in [0.0, 0.5]]+[10.0]

plt.hist(data, bins, align="left", rwidth = .6)
plt.xticks(bins)
plt.show()
</code>```

This results in the same plot as above.

Body:
I guess I just didn't use the right keywords, because this probably has been asked before, but I didn't find a solution. Anyway, I have a problem where the the bars of a histogram do not line up with the xticks. I want the bars to be centred over the xticks they correspond to, but they get placed between ticks to fill the space in-between evenly.

import matplotlib.pyplot as plt

data = [1, 1, 1, 1.5, 2, 4, 4, 4, 4, 4.5, 5, 6, 6.5, 7, 9,9, 9.5]

bins = [x+n for n in range(1, 10) for x in [0.0, 0.5]]+[10.0]

plt.hist(data, bins, rwidth = .3)
plt.xticks(bins)
plt.show()

Body:
Note that what you are plotting here is not a histogram. A histogram would be

import matplotlib.pyplot as plt

data = [1, 1, 1, 1.5, 2, 4, 4, 4, 4, 4.5, 5, 6, 6.5, 7, 9,9, 9.5]

bins = [x+n for n in range(1, 10) for x in [0.0, 0.5]]+[10.0]

plt.hist(data, bins, edgecolor="k", alpha=1)
plt.xticks(bins)
plt.show()

Here, the bars range between the bins as expected. E.g. you have 3 values in the interval 1 <= x < 1.5.

Conceptually what you want to do here is get a bar plot of the counts of data values. This would not require any bins at all and could be done as follows:

import numpy as np
import matplotlib.pyplot as plt

data = [1, 1, 1, 1.5, 2, 4, 4, 4, 4, 4.5, 5, 6, 6.5, 7, 9,9, 9.5]

u, inv = np.unique(data, return_inverse=True)
counts = np.bincount(inv)

plt.bar(u, counts, width=0.3)

plt.xticks(np.arange(1,10,0.5))
plt.show()

Of course you can "misuse" a histogram plot to get a similar result. This would require to move the center of the bar to the left bin edge, plt.hist(.., align="left").

import matplotlib.pyplot as plt

data = [1, 1, 1, 1.5, 2, 4, 4, 4, 4, 4.5, 5, 6, 6.5, 7, 9,9, 9.5]

bins = [x+n for n in range(1, 10) for x in [0.0, 0.5]]+[10.0]

plt.hist(data, bins, align="left", rwidth = .6)
plt.xticks(bins)
plt.show()

This results in the same plot as above.


问:
What is the difference between std::unique_ptr<type> and type&&?
I can't get difference between two variants:

```<code>class test {
    std::unique_ptr<std::vector<float>> m_field;
    test(const std::vector<float>&& values) : m_field{std::make_unique<vector<float>>(std::move(values))} {}
};
</code>```

And

```<code>class test {
    const std::vector<float>&& m_field;
    test(const std::vector<float>&& values) : m_field{std::move(values)} {}
};
</code>```

In the first variant the default destructor will remove unique_ptr and inner vector automatically but what will happen in the second variant how will the default destructor work?

What variant is better?

P.S. Maybe it's easy but I am looking for and can't find. My English isn't good, please, don't send me to hard docs.

答:
First test class is useful when we remove const in constructor, it should be

```<code>class test {
public:
std::unique_ptr<std::vector<float>> m_field;
test(std::vector<float>&& values) : m_field{std::make_unique<vector<float>>(std::move(values))} {}
};
</code>```

because move operation can be done on non-const object.
For example

```<code>vector<float> v(20, 3.0);
test t(move(v));
cout << v.size() << endl; // print 20 if `const` will be in constructor definition
                     // print 0 if `const` specifier is missed in constructor, object was moved
</code>```

Second test class is nonsense. Destructor of this class does nothing. In constructor m_field member is initialized and points at passed vector, and it is all, nothing more is done in ctor/dtor of this class.

Body:
I can't get difference between two variants:

class test {
    std::unique_ptr<std::vector<float>> m_field;
    test(const std::vector<float>&& values) : m_field{std::make_unique<vector<float>>(std::move(values))} {}
};

And

class test {
    const std::vector<float>&& m_field;
    test(const std::vector<float>&& values) : m_field{std::move(values)} {}
};

In the first variant the default destructor will remove unique_ptr and inner vector automatically but what will happen in the second variant how will the default destructor work?

What variant is better?

P.S. Maybe it's easy but I am looking for and can't find. My English isn't good, please, don't send me to hard docs.

Body:
First test class is useful when we remove const in constructor, it should be

class test {
public:
std::unique_ptr<std::vector<float>> m_field;
test(std::vector<float>&& values) : m_field{std::make_unique<vector<float>>(std::move(values))} {}
};

because move operation can be done on non-const object.
For example

vector<float> v(20, 3.0);
test t(move(v));
cout << v.size() << endl; // print 20 if `const` will be in constructor definition
                     // print 0 if `const` specifier is missed in constructor, object was moved

Second test class is nonsense. Destructor of this class does nothing. In constructor m_field member is initialized and points at passed vector, and it is all, nothing more is done in ctor/dtor of this class.


问:
R: Conditional combinations of dataframe
I want to create a dataframe from combinations of the var-column in following dataframe

```<code>data <- data.frame("var"=c("x", "y", "z", "xy", "xz"),
                   "val"=c("1", "2", "3", "4",  "5"))
</code>```

Unlike expand.grid I have the requirement that the combinations in var cannot contain each letter more than once. So the resulting dataframe must become

```<code>dataRes <- data.frame("var"=c("x+y+z", "y+xz", "xy+z"),
                      "val"=c("6",     "7",    "7"))
</code>```

Here is a second example

```<code>data <- data.frame("var"=c("x", "y", "z", "xy", "xz", "yz"),
                   "val"=c("1", "2", "3", "4",  "5", "6"))
</code>```

where the desired output is

```<code>dataRes <- data.frame("var"=c("x+y+z", "y+xz", "xy+z", "x+yz"),
                      "val"=c("6",     "7",    "7", "7"))
</code>```

Is there a generic function in R for this, or do I simply have to make all combinations and then do a string-search to weed out all combinations where a letter appears more than once?

答:
This follows your suggestion of making all combinations and then weeding out the ones where one of the variables exists more than once:

```<code>x <- 3;y <- 2;z <- 4;vars <- c("x", "y", "z");oper <- c("+", "*")
combinations <- expand.grid(vars, oper, vars, oper,  vars)
combinations <- combinations[apply(combinations[c(1,3,5)], 1, FUN = anyDuplicated)==0, ]
pairs <- do.call(paste, c(combinations, sep=""))
result <- data.frame(expr = pairs, result = sapply(pairs, function(k) eval(parse(text = k))), row.names = 1:length(pairs))
result
</code>```

I am relatively sure that there is no dedicated command for this.

Body:
I want to create a dataframe from combinations of the var-column in following dataframe

data <- data.frame("var"=c("x", "y", "z", "xy", "xz"),
                   "val"=c("1", "2", "3", "4",  "5"))

Unlike expand.grid I have the requirement that the combinations in var cannot contain each letter more than once. So the resulting dataframe must become

dataRes <- data.frame("var"=c("x+y+z", "y+xz", "xy+z"),
                      "val"=c("6",     "7",    "7"))

Here is a second example

data <- data.frame("var"=c("x", "y", "z", "xy", "xz", "yz"),
                   "val"=c("1", "2", "3", "4",  "5", "6"))

where the desired output is

dataRes <- data.frame("var"=c("x+y+z", "y+xz", "xy+z", "x+yz"),
                      "val"=c("6",     "7",    "7", "7"))

Is there a generic function in R for this, or do I simply have to make all combinations and then do a string-search to weed out all combinations where a letter appears more than once?

Body:
This follows your suggestion of making all combinations and then weeding out the ones where one of the variables exists more than once:

x <- 3;y <- 2;z <- 4;vars <- c("x", "y", "z");oper <- c("+", "*")
combinations <- expand.grid(vars, oper, vars, oper,  vars)
combinations <- combinations[apply(combinations[c(1,3,5)], 1, FUN = anyDuplicated)==0, ]
pairs <- do.call(paste, c(combinations, sep=""))
result <- data.frame(expr = pairs, result = sapply(pairs, function(k) eval(parse(text = k))), row.names = 1:length(pairs))
result

I am relatively sure that there is no dedicated command for this.


问:
Java template project for Automation Testing for a new WebApp? In any framework
Can anybody suggest me any preset template project for a new web application?

Using Java and Selenium Webdriver I’m looking for a skeleton project with preset pages and basic methods for automation. For pages like LoginPage, BasePage etc. With list of web elements, which will be corrected and specified of course.

Framework could be like Gauge, Sahi, TestNG or something similiar.

What I need is a template project, to not start from absolute scratch. Thank you for any help.

答:
I am often in the situation where I ask myself "how do I rapidly prototype a java & maven web app with login and basic authentication?"

Using Java and Spring Boot, you can follow one of the tutorials on Spring website, such as: https://spring.io/guides/gs/securing-web/. It's a partial response to a question that is a little bit too broad.


问:
Searchkick: import scope with group clause
I'm trying to group page fragments by kind and aggregate html content.
Here is how my search import scope looks like:

```<code>scope :search_import, -> {
  select("kind, string_agg(html_content, '\r\n') AS html_content")
  .group(:kind)
}
</code>```

When I attempt to reindex records searchkick uses find_in_batches which automatically sets the order to ascending on the primary key to make the batch ordering work. This leads me to the following error: column "page_fragments.id" must appear in the GROUP BY clause or be used in an aggregate function.

Clearly, I can't add id to the group clause and I've tried to workaround this by adding id aggregation to the select: COUNT (*) AS id. However, a clear indication of a primary key "page_fragments"."id" in the order clause misses the alias.

The question is what possibly can be done? Looks like a dead end.

答: I ended up with creating separate model PageFragmentAgg and adding callbacks to PageFragment in order to rebuild concatenated data that should be indexed.

Body:
I'm trying to group page fragments by kind and aggregate html content.
Here is how my search import scope looks like:

scope :search_import, -> {
  select("kind, string_agg(html_content, '\r\n') AS html_content")
  .group(:kind)
}

When I attempt to reindex records searchkick uses find_in_batches which automatically sets the order to ascending on the primary key to make the batch ordering work. This leads me to the following error: column "page_fragments.id" must appear in the GROUP BY clause or be used in an aggregate function.

Clearly, I can't add id to the group clause and I've tried to workaround this by adding id aggregation to the select: COUNT (*) AS id. However, a clear indication of a primary key "page_fragments"."id" in the order clause misses the alias.

The question is what possibly can be done? Looks like a dead end.


问:
Hibernate insert into Database new records only
I am trying to write some object into the database, I wrote the following code which is working fine but the problem is that because I am using a while loop, hibernate is treating every object as a new record, which causing the database to be filled with already existed value

My question is, which annotation or technique that I can use to only write the new records (new object's value) into the database, without writing the same object again incase it was written before (Insert only if not exists)

Here is my code

```<code>public class Parser {
  public static void logParser() throws IOException {
    // Creating the configuration object
    Configuration cfg = new Configuration();
    cfg.configure("hibernate.cfg.xml");
    // Ccreating the session factory object
    SessionFactory factory = cfg.buildSessionFactory();
    String fileName = "example.txt";
    File logfile = new File("fileName");
    Scanner scanner = new Scanner(new File(fileName), "UTF-8");
    while (scanner.hasNext()) {
      String s = scanner.nextLine();
      if (s.startsWith("Start")) {
        String[] logArray = s.split("\\|");
         System.out.println(Arrays.toString(logArray));
        // here is the session object
        Session session = factory.openSession();
        // transaction
        Transaction t = session.beginTransaction();
        // here is where the object is being written into the DB
        NetGroup ng = new NetGroup();
        ng.setNetGroup(logArray[2]);
        session.persist(ng);
        session.saveOrUpdate(ng);
        t.commit();
        session.close();
        System.out.println("Successfully created an object and wrote its values into database ");
        System.out.println();
      }
    }
    scanner.close();
    System.out.println("Successfully updated the Data Base");
  }
  }
</code>```

答:
Your issue is happened because in each loop you create a new entity and persist it, then you commit and close the session, so when begin a new transaction in second loop there is no reference between the already persisted entity and second one, so new entity will be created.

You need to re find your entity then update it if existed, else create new one and persist it.

That code will fix your issue

```<code> public class Parser {
    public static void logParser() throws IOException {
        // Creating the configuration object
        Configuration cfg = new Configuration();
        cfg.configure("hibernate.cfg.xml");
        // Ccreating the session factory object
        SessionFactory factory = cfg.buildSessionFactory();
        String logFileName = "example.txt";
        File logfile = new File("fileName");
        Scanner scanner = new Scanner(new File(fileName), "UTF-8");
        // here is the session object
        Session session = factory.openSession();
        // transaction
        Transaction t = session.beginTransaction();

        while (scanner.hasNext()) {
            String s = scanner.nextLine();
            if (s.startsWith("Start")) {
                String[] logArray = s.split("\\|");
                System.out.println(Arrays.toString(logArray));
                Query query = session.createQuery("FROM " + getTableName() + " Where  your condition "); // use unique filed
                List<NetGroup> list = query.list();
                if(list.size()==0){
                    NetGroup ng =new NetGroup();
                }else{
                    ng =list.get(0);
                }
               ng.setNetGroup(logArray[2]);

                session.saveOrUpdate(ng);
                System.out.println("Successfully created an object and wrote its values into database ");
                System.out.println();
            }
        }
        session.close();
        t.commit();
        scanner.close();
        System.out.println("Successfully updated the Data Base");
    }
}
</code>```

Make sure put valid condition instead of "your condition"

Body:
I am trying to write some object into the database, I wrote the following code which is working fine but the problem is that because I am using a while loop, hibernate is treating every object as a new record, which causing the database to be filled with already existed value

My question is, which annotation or technique that I can use to only write the new records (new object's value) into the database, without writing the same object again incase it was written before (Insert only if not exists)

Here is my code

public class Parser {
  public static void logParser() throws IOException {
    // Creating the configuration object
    Configuration cfg = new Configuration();
    cfg.configure("hibernate.cfg.xml");
    // Ccreating the session factory object
    SessionFactory factory = cfg.buildSessionFactory();
    String fileName = "example.txt";
    File logfile = new File("fileName");
    Scanner scanner = new Scanner(new File(fileName), "UTF-8");
    while (scanner.hasNext()) {
      String s = scanner.nextLine();
      if (s.startsWith("Start")) {
        String[] logArray = s.split("\\|");
         System.out.println(Arrays.toString(logArray));
        // here is the session object
        Session session = factory.openSession();
        // transaction
        Transaction t = session.beginTransaction();
        // here is where the object is being written into the DB
        NetGroup ng = new NetGroup();
        ng.setNetGroup(logArray[2]);
        session.persist(ng);
        session.saveOrUpdate(ng);
        t.commit();
        session.close();
        System.out.println("Successfully created an object and wrote its values into database ");
        System.out.println();
      }
    }
    scanner.close();
    System.out.println("Successfully updated the Data Base");
  }
  }

Body:
Your issue is happened because in each loop you create a new entity and persist it, then you commit and close the session, so when begin a new transaction in second loop there is no reference between the already persisted entity and second one, so new entity will be created.

You need to re find your entity then update it if existed, else create new one and persist it.

That code will fix your issue

 public class Parser {
    public static void logParser() throws IOException {
        // Creating the configuration object
        Configuration cfg = new Configuration();
        cfg.configure("hibernate.cfg.xml");
        // Ccreating the session factory object
        SessionFactory factory = cfg.buildSessionFactory();
        String logFileName = "example.txt";
        File logfile = new File("fileName");
        Scanner scanner = new Scanner(new File(fileName), "UTF-8");
        // here is the session object
        Session session = factory.openSession();
        // transaction
        Transaction t = session.beginTransaction();

        while (scanner.hasNext()) {
            String s = scanner.nextLine();
            if (s.startsWith("Start")) {
                String[] logArray = s.split("\\|");
                System.out.println(Arrays.toString(logArray));
                Query query = session.createQuery("FROM " + getTableName() + " Where  your condition "); // use unique filed
                List<NetGroup> list = query.list();
                if(list.size()==0){
                    NetGroup ng =new NetGroup();
                }else{
                    ng =list.get(0);
                }
               ng.setNetGroup(logArray[2]);

                session.saveOrUpdate(ng);
                System.out.println("Successfully created an object and wrote its values into database ");
                System.out.println();
            }
        }
        session.close();
        t.commit();
        scanner.close();
        System.out.println("Successfully updated the Data Base");
    }
}

Make sure put valid condition instead of "your condition"


问:
Using Typedoc with aurelia
I'm trying to create documentation by using TypeDoc in our Aurelia project. Unfortunately we aren't able to produce any output because TypeDoc cannot resolve modules imports inside the typescript files. Has someone created documentation from a Typescript/aurelia project by using typedoc? Any suggestions?</p>

答:
We're using TypeDoc for our Aurelia Control package and it's quite straightforward.
The NPM script looks like the following:

```<code>"typedoc": "./node_modules/.bin/typedoc --mode modules --tsconfig ./tsconfig.typedoc.json --out documentation --excludePrivate --theme default --readme readme.md ./src"
</code>```

tsconfig.typedoc.json contains the followings:

```<code>{
    "extends": "./tsconfig.json",
    "files": [
        "src/index.ts"
    ]
}
</code>```

You can check the result here:
https://community.sensenet.com/api/sn-controls-aurelia/

Title: Using Typedoc with aurelia

Body:
We're using TypeDoc for our Aurelia Control package and it's quite straightforward.
The NPM script looks like the following:

"typedoc": "./node_modules/.bin/typedoc --mode modules --tsconfig ./tsconfig.typedoc.json --out documentation --excludePrivate --theme default --readme readme.md ./src"

tsconfig.typedoc.json contains the followings:

{
    "extends": "./tsconfig.json",
    "files": [
        "src/index.ts"
    ]
}

You can check the result here:
https://community.sensenet.com/api/sn-controls-aurelia/


问:
Change format of date column in CSV

I have CSV file with the following format

Column_a,Column_b,Column_c,Column_date
a,b,c,08-jun-2017 00:00 to UP (ENG)
```

<p>I want to convert the data with name <code>Column_date</code></p>

<p>Example: <code>08-jun-2017 00:00 to UP (ENG)</code> should be converted to <code>17W23D4 to UP (ENG)</code></p>

<p>The format is year within century <code>17</code>; week of year <code>W23</code>; day of week <code>D4</code>. The days go from Monday (1) to Sunday (7).</p>

<p>So the final CSV should look like:</p>

<pre class="lang-none prettyprint-override"><code>Column_a,Column_b,Column_c,Column_date
a,b,c,17W23D4 to UP (ENG)
</code>```

It would be great if can do in a .bat file, but another scripting language is also okay.

答:
In Perl, you can use Time::Piece:

```<code>$ perl -MTime::Piece -wE '
    $tp = Time::Piece->strptime("08-jun-2017 00:00", "%d-%b-%Y %H:%M");
    say $tp->yy, "W", $tp->week, "D", $tp->day_of_week'
17W23D4
</code>```

You first need to extract the date and time from the string, though.

You can use -F, to split each line on commas into the @F array, then use a regex to extract the timestamp:

```<code>perl -MTime::Piece -F, -anE '
    print, next if $. == 1;
    ($timestring, $rest)
        = pop(@F) =~ /([0-9]{2}-[a-z]{3}-[0-9]{4} [0-9]{2}:[0-9]{2})(.*)/;
    $tp = Time::Piece->strptime($timestring, "%d-%b-%Y %H:%M");
    say join ",", @F, $tp->yy . "W" . $tp->week . "D" . $tp->day_of_week . $rest;
' -- input.csv
</code>```

IIRC, on MSWin you need to switch single and double quotes.

See pop, perlre, join for more details.

Title: Change format of date column in CSV

Body:
I have CSV file with the following format

Column_a,Column_b,Column_c,Column_date
a,b,c,08-jun-2017 00:00 to UP (ENG)

I want to convert the data with name Column_date

Example: 08-jun-2017 00:00 to UP (ENG) should be converted to 17W23D4 to UP (ENG)

The format is year within century 17; week of year W23; day of week D4. The days go from Monday (1) to Sunday (7).

So the final CSV should look like:

Column_a,Column_b,Column_c,Column_date
a,b,c,17W23D4 to UP (ENG)

It would be great if can do in a .bat file, but another scripting language is also okay.

Body:
In Perl, you can use Time::Piece:

$ perl -MTime::Piece -wE '
    $tp = Time::Piece->strptime("08-jun-2017 00:00", "%d-%b-%Y %H:%M");
    say $tp->yy, "W", $tp->week, "D", $tp->day_of_week'
17W23D4

You first need to extract the date and time from the string, though.

You can use -F, to split each line on commas into the @F array, then use a regex to extract the timestamp:

perl -MTime::Piece -F, -anE '
    print, next if $. == 1;
    ($timestring, $rest)
        = pop(@F) =~ /([0-9]{2}-[a-z]{3}-[0-9]{4} [0-9]{2}:[0-9]{2})(.*)/;
    $tp = Time::Piece->strptime($timestring, "%d-%b-%Y %H:%M");
    say join ",", @F, $tp->yy . "W" . $tp->week . "D" . $tp->day_of_week . $rest;
' -- input.csv

IIRC, on MSWin you need to switch single and double quotes.

See pop, perlre, join for more details.


问:
Javascript: Splice Multidimensional Object
I'm having this Object/Array Structure :

```<code>Obj = {
    "User": {
        "user1": [{
            "desc": "NG60",
            "Id": 3473631702,
            "Status": "offline"
        }],

        "user2": [{
            "desc": "somevalue",
            "Id": 963346121,
            "Status": "offline"
        },
        {
            "desc": "othervalue",  // SPLICE THIS OUT
            "Id": 963346122,      // SPLICE THIS OUT
            "Status": "offline"  // SPLICE THIS OUT
        }],

        "user3": [{
            "desc": "whatever",
            "Id": 972878784
        }]
    }
}
</code>```

I want to filter out different values, dynamically (fixed in this example)
and if there are no Ids left, I want to delete the whole user Array.

For example, if I want to filter out the 2nd Array Element of user2:

```<code> for(var users in Obj) {
     for(var Ids in Obj[users]) {
         if(Obj[users][Ids].Id == 963346122){
             Obj[users][Ids].splice(0, 1); // ERROR HERE
         }
     }
     if(Obj[users][Ids] == undefined) {
         delete Obj[users];
     }
 }
</code>```

I get this Error:

User[users][Ids].splice(0, 1) is not a function

How to splice only the Array Element that I'm addressing, not the complete user2 Array?

答:
Problem: the splice you used was pointing to string not Object/Array. Use delete rather than splice for Object removal.

Better for future filters:

```<code>//using same Obj:
for (i in Obj) {
    if (Obj.hasOwnProperty(i)) {
        var subObj = Obj[i];
        for (j in subObj) {
            var child = subObj[j];
            for (k in subObj[j]) {
                if(child[k].Id == 963346122){ //this user contains specified id the delete this user.
                    delete  child[k];
                }
            }
         }
    }
}
</code>```

Body:
I'm having this Object/Array Structure :

Obj = {
    "User": {
        "user1": [{
            "desc": "NG60",
            "Id": 3473631702,
            "Status": "offline"
        }],

        "user2": [{
            "desc": "somevalue",
            "Id": 963346121,
            "Status": "offline"
        },
        {
            "desc": "othervalue",  // SPLICE THIS OUT
            "Id": 963346122,      // SPLICE THIS OUT
            "Status": "offline"  // SPLICE THIS OUT
        }],

        "user3": [{
            "desc": "whatever",
            "Id": 972878784
        }]
    }
}

I want to filter out different values, dynamically (fixed in this example)
and if there are no Ids left, I want to delete the whole user Array.

For example, if I want to filter out the 2nd Array Element of user2:

 for(var users in Obj) {
     for(var Ids in Obj[users]) {
         if(Obj[users][Ids].Id == 963346122){
             Obj[users][Ids].splice(0, 1); // ERROR HERE
         }
     }
     if(Obj[users][Ids] == undefined) {
         delete Obj[users];
     }
 }

I get this Error:

User[users][Ids].splice(0, 1) is not a function

How to splice only the Array Element that I'm addressing, not the complete user2 Array?

Body:
Problem: the splice you used was pointing to string not Object/Array. Use delete rather than splice for Object removal.

Better for future filters:

//using same Obj:
for (i in Obj) {
    if (Obj.hasOwnProperty(i)) {
        var subObj = Obj[i];
        for (j in subObj) {
            var child = subObj[j];
            for (k in subObj[j]) {
                if(child[k].Id == 963346122){ //this user contains specified id the delete this user.
                    delete  child[k];
                }
            }
         }
    }
}


问:
React 16.2 <Fragment> gives Uncaught error: Element type is invalid
I just updated to react 16.2 and I want to use the cool Fragment feature. However I get strange error as soon as just use it in a simple way:

```<code><React.Fragment>asd</React.Fragment>
</code>```

The error states: Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: symbol.

When I log the above code and just a random component I have defined I get this information:

```<code>$$typeof: Symbol(react.element)
key: null
props: {children: "asd"}
ref: null
type: Symbol(react.fragment)
...
</code>```

When I log my element I get the almost same information:

```<code>$$typeof: Symbol(react.element)
key: null
props: {children: "sfdghs"}
ref: null
type:ƒ Column(_ref)
</code>```

My question is: why does the app expect string or function.

All related dependancies from my package.json are as such:

"devDependencies": {... "@types/react": "^16.0.0" ...}

"dependencies" : {... "react": "^16.2.0", "typescript": "2.6.2" ...}

If anyone can give me any information on how to debug this, I will be very grateful!

答: You need a minimum of 16.2.0 for both react & react-dom.

Body:
I just updated to react 16.2 and I want to use the cool Fragment feature. However I get strange error as soon as just use it in a simple way:

<React.Fragment>asd</React.Fragment>

The error states: Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: symbol.

When I log the above code and just a random component I have defined I get this information:

$$typeof: Symbol(react.element)
key: null
props: {children: "asd"}
ref: null
type: Symbol(react.fragment)
...

When I log my element I get the almost same information:

$$typeof: Symbol(react.element)
key: null
props: {children: "sfdghs"}
ref: null
type:ƒ Column(_ref)

My question is: why does the app expect string or function.

All related dependancies from my package.json are as such:

"devDependencies": {... "@types/react": "^16.0.0" ...}

"dependencies" : {... "react": "^16.2.0", "typescript": "2.6.2" ...}

If anyone can give me any information on how to debug this, I will be very grateful!

ContentLicense: CC BY-SA 4.0


问:
Could not transfer artifacts from/to central maven repo when using Spring Framework Cloud
I am trying to create a maven project using Spring Framework Cloud.
I defined pom.xml file as below

```<code><parent>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-parent</artifactId>
        <version>Brixton.RELEASE</version>
    </parent>

    <properties>
        <!-- Stand-alone RESTFul application for testing only -->
        <start-class>io.pivotal.microservices.services.Main</start-class>
    </properties>

    <dependencies>
        <dependency>
            <!-- Setup Spring Boot -->
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <!-- Setup Spring MVC & REST, use Embedded Tomcat -->
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

        <dependency>
            <!-- Setup Spring Data common components -->
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-commons</artifactId>
        </dependency>

        <dependency>
            <!-- Testing starter -->
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
        </dependency>

        <dependency>
            <!-- Setup Spring Data JPA Repository support -->
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <dependency>
            <!-- In-memory database for testing/demos -->
            <groupId>org.hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
        </dependency>

        <dependency>
            <!-- Spring Cloud starter -->
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter</artifactId>
        </dependency>

        <dependency>
            <!-- Eureka service registration -->
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka-server</artifactId>
        </dependency>
    </dependencies>
</code>```

When trying to build maven getting error for all dependencies as

Could not transfer artifacts from/to central (https://repo.maven.apache.org/maven2)

Multiple annotations found at this line:
    - Failure to transfer org.springframework:spring-orm:jar:4.2.6.RELEASE from
  https://repo.maven.apache.org/maven2 was cached in the local
  repository, resolution will not be     reattempted until the update
  interval of central has elapsed or updates are forced. Original error:
  Could not transfer artifact
  org.springframework:spring-orm:jar:4.2.6.RELEASE from/to central

  (https://repo.maven.apache.org/maven2): The operation was cancelled.
  org.eclipse.aether.transfer.ArtifactTransferException: Failure to
  transfer org.springframework:spring-orm:jar:
     4.2.6.RELEASE from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the
  update interval of central has elapsed or updates are      forced.
  Original error: Could not transfer artifact
  org.springframework:spring-orm:jar:4.2.6.RELEASE from/to central
  (https://repo.maven.apache.org/maven2): The operation was cancelled.
  at

  org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.newException(DefaultUpdateCheckManager.java:238)
  at

  org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.checkArtifact(DefaultUpdateCheckManager.java:206)
  at

  org.eclipse.aether.internal.impl.DefaultArtifactResolver.gatherDownloads(DefaultArtifactResolver.java:585)
  at

  org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:503)
  at

  org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421)
  at

  org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)
  at

  org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:367)
  at

When I go to the location, I can clearly see the Jar files are present in that location.
Is there something else I need to add to my pom.xml?

答:
I tried the same pom.xml inEclipse IDE and surprisingly it worked there as it is.

To make it work on STS, I added following properties

```<code><properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <start-class>io.pivotal.microservices.services.Main</start-class>
        <spring-cloud.version>Brixton.RELEASE</spring-cloud.version>
    </properties>
</code>```

Refer Unable to download/import package org.springframework.cloud.config.server.EnableConfigServer

This worked for me, though I am still curious about the difference.

Body:
I am trying to create a maven project using Spring Framework Cloud.
I defined pom.xml file as below

<parent>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-parent</artifactId>
        <version>Brixton.RELEASE</version>
    </parent>

    <properties>

        <start-class>io.pivotal.microservices.services.Main</start-class>
    </properties>

    <dependencies>
        <dependency>

            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>

            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

        <dependency>

            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-commons</artifactId>
        </dependency>

        <dependency>

            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
        </dependency>

        <dependency>

            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <dependency>

            <groupId>org.hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
        </dependency>

        <dependency>

            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter</artifactId>
        </dependency>

        <dependency>

            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka-server</artifactId>
        </dependency>
    </dependencies>

When trying to build maven getting error for all dependencies as

Could not transfer artifacts from/to central (https://repo.maven.apache.org/maven2)

Multiple annotations found at this line:
    - Failure to transfer org.springframework:spring-orm:jar:4.2.6.RELEASE from
  https://repo.maven.apache.org/maven2 was cached in the local
  repository, resolution will not be     reattempted until the update
  interval of central has elapsed or updates are forced. Original error:
  Could not transfer artifact
  org.springframework:spring-orm:jar:4.2.6.RELEASE from/to central

  (https://repo.maven.apache.org/maven2): The operation was cancelled.
  org.eclipse.aether.transfer.ArtifactTransferException: Failure to
  transfer org.springframework:spring-orm:jar:
     4.2.6.RELEASE from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the
  update interval of central has elapsed or updates are      forced.
  Original error: Could not transfer artifact
  org.springframework:spring-orm:jar:4.2.6.RELEASE from/to central
  (https://repo.maven.apache.org/maven2): The operation was cancelled.
  at

  org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.newException(DefaultUpdateCheckManager.java:238)
  at

  org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.checkArtifact(DefaultUpdateCheckManager.java:206)
  at

  org.eclipse.aether.internal.impl.DefaultArtifactResolver.gatherDownloads(DefaultArtifactResolver.java:585)
  at

  org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:503)
  at

  org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421)
  at

  org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)
  at

  org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:367)
  at

When I go to the location, I can clearly see the Jar files are present in that location.
Is there something else I need to add to my pom.xml?

Body:
I tried the same pom.xml inEclipse IDE and surprisingly it worked there as it is.

To make it work on STS, I added following properties

<properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <start-class>io.pivotal.microservices.services.Main</start-class>
        <spring-cloud.version>Brixton.RELEASE</spring-cloud.version>
    </properties>

Refer Unable to download/import package org.springframework.cloud.config.server.EnableConfigServer

This worked for me, though I am still curious about the difference.


问:
How can I create arc shape ios swift
I have an application with some buttons. I want to create a arc shape button like the following image

How can I do it? I use the following code to achieve this.

```<code>button.layer.cornerRadius =  button.bounds.size.height
</code>```

and

```<code>button.layer.cornerRadius =  0.5*button.bounds.size.height
</code>```

I also tried this with the using of width

```<code>button.layer.cornerRadius =  button.bounds.size.width
</code>```

and

```<code>button.layer.cornerRadius =  0.5*button.bounds.size.width
</code>```

How can I do it? Please someone help me to solve this.

答:
Another image posted by @Jack in above comments and asked help, here is the image:

I couldn't answer him as comment, so pasting my playground here instead.

```<code>let shapeView = UIView(frame: CGRect(x: 0, y: 0, width: 360, height: 60))
let shapeSize = shapeView.frame.size
shapeView.backgroundColor = UIColor.white

let path = CGMutablePath()
path.move(to: CGPoint.zero)

let curveWidthOneFourth = shapeSize.width / 4
let curveHeight = shapeSize.height * 0.2
path.addCurve(to: CGPoint(x: curveWidthOneFourth * 2, y: curveHeight), control1: .zero, control2: CGPoint(x: curveWidthOneFourth, y: curveHeight))
path.addCurve(to: CGPoint(x: shapeSize.width, y: 0), control1: CGPoint(x: curveWidthOneFourth * 3, y: curveHeight), control2: CGPoint(x: shapeSize.width, y: 0))
path.addLine(to: CGPoint(x: shapeSize.width, y: shapeSize.height))
path.addLine(to: CGPoint(x: 0, y: shapeSize.height))
path.addLine(to: CGPoint.zero)
</code>```

And add our path to a view's layer:

```<code>let layer = CAShapeLayer()
layer.path = path
layer.fillColor = UIColor.red.cgColor
shapeView.layer.addSublayer(layer)
</code>```

Title: How can I create arc shape ios swift

Body:
I have an application with some buttons. I want to create a arc shape button like the following image

How can I do it? I use the following code to achieve this.

button.layer.cornerRadius =  button.bounds.size.height

and

button.layer.cornerRadius =  0.5*button.bounds.size.height

I also tried this with the using of width

button.layer.cornerRadius =  button.bounds.size.width

and

button.layer.cornerRadius =  0.5*button.bounds.size.width

How can I do it? Please someone help me to solve this.

Body:
Another image posted by @Jack in above comments and asked help, here is the image:

I couldn't answer him as comment, so pasting my playground here instead.

let shapeView = UIView(frame: CGRect(x: 0, y: 0, width: 360, height: 60))
let shapeSize = shapeView.frame.size
shapeView.backgroundColor = UIColor.white

let path = CGMutablePath()
path.move(to: CGPoint.zero)

let curveWidthOneFourth = shapeSize.width / 4
let curveHeight = shapeSize.height * 0.2
path.addCurve(to: CGPoint(x: curveWidthOneFourth * 2, y: curveHeight), control1: .zero, control2: CGPoint(x: curveWidthOneFourth, y: curveHeight))
path.addCurve(to: CGPoint(x: shapeSize.width, y: 0), control1: CGPoint(x: curveWidthOneFourth * 3, y: curveHeight), control2: CGPoint(x: shapeSize.width, y: 0))
path.addLine(to: CGPoint(x: shapeSize.width, y: shapeSize.height))
path.addLine(to: CGPoint(x: 0, y: shapeSize.height))
path.addLine(to: CGPoint.zero)

And add our path to a view's layer:

let layer = CAShapeLayer()
layer.path = path
layer.fillColor = UIColor.red.cgColor
shapeView.layer.addSublayer(layer)


问:
Replace text from controller and put it inside property file
Replace text from controller and put it inside property file

What  I have already:

My controller:

```<code>redirectAttrs.addFlashAttribute("userName", "Hello, " + someForm.getName() + " nice to meet you.");
</code>```

My thymeleaf

```<code><p class="text-danger" th:text="${userName}">userName</p>
</code>```

I know that I can easly use my properties like this:

My message.properties:

user.name=Tom

My thymeleaf:

```<code><a th:text="#{user.name}"></a>
</code>```

But can I reach what I want if there is a value inside?

My user.name=Hello, {name} nice to meet you.

I would like probably do something like this:

in my controller just:

```<code>redirectAttrs.addFlashAttribute("userName", someForm.getName());
</code>```

and in my thymeleaf:

```<code><a th:text="#{user.name(name=${userName})}"></a>
</code>```

Is that even possible? How finally should thymeleaf looks like in case like this?

答:
Change your property value like following:

```<code>user.name=Hello, {0} nice to meet you.
</code>```

And then pass userName like below:

```<code><a th:text="#{user.name(${userName})}"></a>
</code>```

The rule is you can add add multiple variables in your property using{0}, {1}, {2}, .... {n}.  And you can pass values like th:text="#{user.name(${param0},${param1},${param2}, ..., ${paramN} )}"

Body:
Replace text from controller and put it inside property file

What  I have already:

My controller:

redirectAttrs.addFlashAttribute("userName", "Hello, " + someForm.getName() + " nice to meet you.");

My thymeleaf

userName

I know that I can easly use my properties like this:

My message.properties:

user.name=Tom

My thymeleaf:

But can I reach what I want if there is a value inside?

My user.name=Hello, {name} nice to meet you.

I would like probably do something like this:

in my controller just:

redirectAttrs.addFlashAttribute("userName", someForm.getName());

and in my thymeleaf:

Is that even possible? How finally should thymeleaf looks like in case like this?

Body:
Change your property value like following:

user.name=Hello, {0} nice to meet you.

And then pass userName like below:

<a th:text="#{user.name(${userName})}"></a>

The rule is you can add add multiple variables in your property using{0}, {1}, {2}, .... {n}.  And you can pass values like th:text="#{user.name(${param0},${param1},${param2}, ..., ${paramN} )}"


问:
Unable to integrate downloaded HTML template in wordpress Theme
I am trying to Convert my HTML template into Wordpress template.But on browser it is only showing content without CSS. I refered the procedure from: https://www.elegantthemes.com/blog/tips-tricks/converting-html-sites-to-wordpress-sites
here I added a below given statement on the top of a CSS file.I am confused about what to write in Theme URI and Author URI, as Right now I am workin on localhost server.

```<code>/*
Theme Name: ThemeIntegration
Theme URI: ??
Description: A brief description.
Version: 1.0
Author: You
Author URI: ??
*/
</code>```

I am only getting Simple html content without styling.

答:
You need to add css and js files either in header or functions.php file, that tutorial is incomplete you can refer this link

If you have only 1 css then you can directly write it in style.css

Body:
I am trying to Convert my HTML template into Wordpress template.But on browser it is only showing content without CSS. I refered the procedure from: https://www.elegantthemes.com/blog/tips-tricks/converting-html-sites-to-wordpress-sites
here I added a below given statement on the top of a CSS file.I am confused about what to write in Theme URI and Author URI, as Right now I am workin on localhost server.

/*
Theme Name: ThemeIntegration
Theme URI: ??
Description: A brief description.
Version: 1.0
Author: You
Author URI: ??
*/

I am only getting Simple html content without styling.


问:
Basic Python imports question
If I have a src directory setup like this:

```<code>main.py
pkg1:
    __init__.py
    util.py
pkg2:
    __init__.py
    test.py
</code>```

Can you tell me the best way to import pkg1.util from main.py and from test.py?

Thanks! (If I need to have another __init__.py file in the root directory, let me know?)

答:
From main.py:

```<code>import pkg1.util
</code>```

From test.py:

```<code>from ..pkg1 import util
</code>```

Title: Basic Python imports question

Body:
If I have a src directory setup like this:

main.py
pkg1:
    __init__.py
    util.py
pkg2:
    __init__.py
    test.py

Can you tell me the best way to import pkg1.util from main.py and from test.py?

Thanks! (If I need to have another __init__.py file in the root directory, let me know?)

Body:
From main.py:

import pkg1.util

From test.py:

from ..pkg1 import util


问:
how to split a text file by line gaps in java
I am reading a text file in Java that looks like this,

"
Q1. You are given a train data set having 1000 columns and 1 million rows. The data set is based on a classification problem. Your manager has asked you to reduce the dimension of this data so that model computation time can be reduced. Your machine has memory constraints. What would you do? (You are free to make practical assumptions.)

Q2. Is rotation necessary in PCA? If yes, Why? What will happen if you don’t rotate the components?

Q3. You are given a data set. The data set has missing values which spread along 1 standard deviation from the median. What percentage of data would remain unaffected? Why? "

Now, I want to read this file and then store each of these sentences(questions) in a string array. How can I do that in java?

I tried this,

```<code>String mlq = new String(Files.readAllBytes(Paths.get("MLques.txt")));
String[] mlq1=mlq.split("\n\n");
</code>```

But this is not working.

答:
This is a piece of code from one of my project.

```<code>public static List<String> readStreamByLines(InputStream in) throws IOException {
    return IOUtils.readLines(in, StandardCharsets.UTF_8).stream()
                  .map(String::trim)
                  .collect(Collectors.toList());
}
</code>```

But!!! If you have really big file, then collecting all content into a List is not good. You have to read InputStream line by line and do all you need for every single row.

Body:
I am reading a text file in Java that looks like this,

"
Q1. You are given a train data set having 1000 columns and 1 million rows. The data set is based on a classification problem. Your manager has asked you to reduce the dimension of this data so that model computation time can be reduced. Your machine has memory constraints. What would you do? (You are free to make practical assumptions.)

Q2. Is rotation necessary in PCA? If yes, Why? What will happen if you don’t rotate the components?

Q3. You are given a data set. The data set has missing values which spread along 1 standard deviation from the median. What percentage of data would remain unaffected? Why? "

Now, I want to read this file and then store each of these sentences(questions) in a string array. How can I do that in java?

I tried this,

String mlq = new String(Files.readAllBytes(Paths.get("MLques.txt")));
String[] mlq1=mlq.split("\n\n");

But this is not working.

Body:
This is a piece of code from one of my project.

public static List<String> readStreamByLines(InputStream in) throws IOException {
    return IOUtils.readLines(in, StandardCharsets.UTF_8).stream()
                  .map(String::trim)
                  .collect(Collectors.toList());
}

But!!! If you have really big file, then collecting all content into a List is not good. You have to read InputStream line by line and do all you need for every single row.


问:
How to merge two different pandas data frame in python
by thought is using iterate the data frame column and check for required data in another column using condition checks.
suggest is it correct or any other way.

答: You should have a look at pandas merge function.


问:
Storm Topology not submit due to multiple log4j files
Storm Topology submit is failing due to multiple log4j error.

In local eclipse, it working. But when submit the topology in Storm cluster, topology submission is failing.

I am using Storm version 1.1.1  & kafka_2.9.2 (0.8.1.1). How do I find log4j files coming from jars through maven in eclipse?

```<code>         <dependency>
            <groupId>org.apache.storm</groupId>
            <artifactId>storm-core</artifactId>
            <version>1.1.1</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <artifactId>log4j-over-slf4j</artifactId>
                    <groupId>org.slf4j</groupId>
                </exclusion>
                 <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>logback-classic</groupId>
                    <artifactId>ch.qos.logback</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
     <dependency>
        <groupId>org.apache.kafka</groupId>
        <artifactId>kafka_2.9.2</artifactId>
        <version>0.8.1.1</version>
        <exclusions>
            <exclusion>
                <groupId>org.apache.zookeeper</groupId>
                <artifactId>zookeeper</artifactId>
            </exclusion>
            <exclusion>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
</code>```

Error log:

```<code>SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/apache-storm-1.0.1/lib/log4j-slf4j-impl-2.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/apps/project/demo/app/demo-app.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Exception in thread "main" java.lang.IllegalAccessError: tried to access method org.apache.logging.log4j.core.lookup.MapLookup.newMap(I)Ljava/util/HashMap; from class org.apache.logging.log4j.core.lookup.MainMapLookup
        at org.apache.logging.log4j.core.lookup.MainMapLookup.<clinit>(MainMapLookup.java:37)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.apache.logging.log4j.core.util.ReflectionUtil.instantiate(ReflectionUtil.java:185)
        at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:65)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:346)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:161)
        at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:359)
        at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:420)
        at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:138)
        at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:147)
        at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:41)
        at org.apache.logging.log4j.LogManager.getContext(LogManager.java:175)
        at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:102)
        at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)
        at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:42)
        at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:277)
        at org.apache.log4j.Category.<init>(Category.java:56)
        at org.apache.log4j.Logger.<init>(Logger.java:35)
        at org.apache.log4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:59)
        at org.apache.log4j.Logger.getLogger(Logger.java:39)
        at org.apache.log4j.Logger.getLogger(Logger.java:43)
        at com.demo.apps.my.topology.BaseTopology.<clinit>(BaseTopology.java:19)
</code>```

答:
In eclipse, in Dependency Hierarchy view, filtered log4j, slf4j jars.

Observed that some other dependent jars also has log4j slf4j jars.

After excluded all duplicate jars, rebuilt the application.

Now no duplicate jars found and able to submit topology.

So check Maven Dependency Hierarchy view and remove duplicate jars.

Body:
Storm Topology submit is failing due to multiple log4j error.

In local eclipse, it working. But when submit the topology in Storm cluster, topology submission is failing.

I am using Storm version 1.1.1  & kafka_2.9.2 (0.8.1.1). How do I find log4j files coming from jars through maven in eclipse?

         <dependency>
            <groupId>org.apache.storm</groupId>
            <artifactId>storm-core</artifactId>
            <version>1.1.1</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <artifactId>log4j-over-slf4j</artifactId>
                    <groupId>org.slf4j</groupId>
                </exclusion>
                 <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>logback-classic</groupId>
                    <artifactId>ch.qos.logback</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
     <dependency>
        <groupId>org.apache.kafka</groupId>
        <artifactId>kafka_2.9.2</artifactId>
        <version>0.8.1.1</version>
        <exclusions>
            <exclusion>
                <groupId>org.apache.zookeeper</groupId>
                <artifactId>zookeeper</artifactId>
            </exclusion>
            <exclusion>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

Error log:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/apache-storm-1.0.1/lib/log4j-slf4j-impl-2.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/apps/project/demo/app/demo-app.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Exception in thread "main" java.lang.IllegalAccessError: tried to access method org.apache.logging.log4j.core.lookup.MapLookup.newMap(I)Ljava/util/HashMap; from class org.apache.logging.log4j.core.lookup.MainMapLookup
        at org.apache.logging.log4j.core.lookup.MainMapLookup.<clinit>(MainMapLookup.java:37)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.apache.logging.log4j.core.util.ReflectionUtil.instantiate(ReflectionUtil.java:185)
        at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:65)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:346)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:161)
        at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:359)
        at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:420)
        at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:138)
        at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:147)
        at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:41)
        at org.apache.logging.log4j.LogManager.getContext(LogManager.java:175)
        at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:102)
        at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)
        at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:42)
        at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:277)
        at org.apache.log4j.Category.<init>(Category.java:56)
        at org.apache.log4j.Logger.<init>(Logger.java:35)
        at org.apache.log4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:59)
        at org.apache.log4j.Logger.getLogger(Logger.java:39)
        at org.apache.log4j.Logger.getLogger(Logger.java:43)
        at com.demo.apps.my.topology.BaseTopology.<clinit>(BaseTopology.java:19)


问:
SoapUI multi-node match assertion
I have the following structure in response

I need an assertion that would check that for the given Role a given Action is present.

I know how to check for specific node with exists(...), but how do I check for an action for the role? fe. Assert that REVOKE_ROLE, UPDATE_ROLE exist for myRole.

I tried to put both expression in the same assertion, but it seems SoapUI allows only one expression per assertion. If I put them in separate assertions it will match all actions I look for regardless of the role. Is this kind of check possible using the XPath Match or am I doing it wrong and I should use some other assertion?

答:
I managed to solve this using XQuery Match

expression:

```<code><Result>
{
for $x in //ns1:getUserA/RolePro/RoleProv/Role[ns4:Abbreviation="myRole"]
return data($x/../Prov/Provi/ns4:Abbreviation/text())
}
</Result>
</code>```

expected result:

```<code><Result>REVOKE_ROLE UPDATE_ROLE GRANT_ROLE</Result>
</code>```

Title: SoapUI multi-node match assertion

Body:
I managed to solve this using XQuery Match

expression:

<Result>
{
for $x in //ns1:getUserA/RolePro/RoleProv/Role[ns4:Abbreviation="myRole"]
return data($x/../Prov/Provi/ns4:Abbreviation/text())
}
</Result>

expected result:

<Result>REVOKE_ROLE UPDATE_ROLE GRANT_ROLE</Result>


问:
webpack hangs at on "95% emit" / "95% emitting"
This is my production webpack config. The two quotes in the title refer to webpack2 and webpack respectively. Both hang for me with a similar error.

This is my command to trigger the build

set NODE_ENV=production && webpack --config config/webpack.config.prod.js --progress --display-error-details

What am I missing?

Here is the output after running npm run pack which correlates to my production webpack build:

```<code>$ npm run pack

> somedir@ pack C:\somedir
> set NODE_ENV=production && webpack --config config/webpack.config.prod.js --progress --display-error-details
                           95% emitting
</code>```

答:
```<code>npm rebuild node-sass
</code>```

solved ist by me.

Body:
This is my production webpack config. The two quotes in the title refer to webpack2 and webpack respectively. Both hang for me with a similar error.

This is my command to trigger the build

set NODE_ENV=production && webpack --config config/webpack.config.prod.js --progress --display-error-details

What am I missing?

Here is the output after running npm run pack which correlates to my production webpack build:

$ npm run pack

> somedir@ pack C:\somedir
> set NODE_ENV=production && webpack --config config/webpack.config.prod.js --progress --display-error-details
                           95% emitting

Body:
npm rebuild node-sass

solved ist by me.


问:
Invalid Toolchain. Itunes store operation failed
As soon as I updated xcode to 9.2 , I cannot validate my archived builds. I get this error message every time:

Invalid Toolchain. New apps and app updates must be built with the public (GM) versions of Xcode 6 or later, macOS, and iOS SDK or later. Don't submit apps built with beta software including beta macOS builds.

Is this something wrong with Apple's new relase of xcode? Otherwise, I didn't change anything that would make this project using "Beta software".

答:
From Xcode -> Go to Organizer -> Under Archives, select the build and right click to Show in finder -> Select the Project and right click to -> Show Package Contents -> Double click on Info.plist and add a row. The key is  BuildMachineOSBuild and the Type is String and the Value is 16G29 (Value is based on your Mac OS Version. Please follow the below given link)

https://support.apple.com/en-in/HT201260   .....Check the version number for your Mac OS version and set the value in the Info.plist

For example if your Mac OS version is 10.12.6 then add this to your plist

```<code><key>BuildMachineOSBuild</key>
<string>16G29</string>
</code>```

You are ready to send your build to iTunes Connect

Body:
From Xcode -> Go to Organizer -> Under Archives, select the build and right click to Show in finder -> Select the Project and right click to -> Show Package Contents -> Double click on Info.plist and add a row. The key is  BuildMachineOSBuild and the Type is String and the Value is 16G29 (Value is based on your Mac OS Version. Please follow the below given link)

https://support.apple.com/en-in/HT201260   .....Check the version number for your Mac OS version and set the value in the Info.plist

For example if your Mac OS version is 10.12.6 then add this to your plist

<key>BuildMachineOSBuild</key>
<string>16G29</string>

You are ready to send your build to iTunes Connect