问:
How to use a variable inside a function in a R Rmarkdown file, using render
I have a rmarkdown file I knit with rmarkdown::render : I make all my data processing in the .R and then, I knit in a Rmd using function. My problem is, if I encapsulate the render function in order to make my code more readable, it doesn't work anymore. Here is a basic example :
- My .Rmd file :

```<code>---
title: "test"
output: html_document
---

```{r}
printA()
```
</code>```

My R Code that work :

```<code>library(rmarkdown)
a<- 5
printA <- function() {
  return(a)
}
render("c:/users/db7trs/desktop/test.Rmd")
</code>```

but when I encapsulate that in a function, that doesn't work anymore :

```<code>library(rmarkdown)
printA <- function() {
  return(a)
}
rendre <- function(){
  a <- 5
  render("c:/users/db7trs/desktop/test.Rmd")
}

rendre()
</code>```

With this code, I have a quite explicit error : Quitting from lines 7-8 Error in printA() : object 'a' not found.

This problem would be easily solved if I explicitly make a an argument of the printA function, which in this case would anyway be a good practice, but I don't understand why it works differently in this two cases.

答:
Your problem is more that the function printA is not declared inside your rendre() function. (Even if the error message speaks about a). Hence, you can declare your function inside rendre() or inside the Rmd file.

Inside rendre() function

```<code>rendre <- function(){
  printA <- function() {
    return(a)
  }
  a <- 5
  render("c:/users/db7trs/desktop/test.Rmd")
}
</code>```

OR inside the test.Rmd

```<code>---
title: "test"
output: html_document
---

```{r}
printA <- function() {
  return(a)
}
printA()
```
</code>```

Body:
I have a rmarkdown file I knit with rmarkdown::render : I make all my data processing in the .R and then, I knit in a Rmd using function. My problem is, if I encapsulate the render function in order to make my code more readable, it doesn't work anymore. Here is a basic example :
- My .Rmd file :

---
title: "test"
output: html_document
---

```{r}
printA()
```

My R Code that work :

library(rmarkdown)
a<- 5
printA <- function() {
  return(a)
}
render("c:/users/db7trs/desktop/test.Rmd")

but when I encapsulate that in a function, that doesn't work anymore :

library(rmarkdown)
printA <- function() {
  return(a)
}
rendre <- function(){
  a <- 5
  render("c:/users/db7trs/desktop/test.Rmd")
}

rendre()

With this code, I have a quite explicit error : Quitting from lines 7-8 Error in printA() : object 'a' not found.

This problem would be easily solved if I explicitly make a an argument of the printA function, which in this case would anyway be a good practice, but I don't understand why it works differently in this two cases.

Body:
Your problem is more that the function printA is not declared inside your rendre() function. (Even if the error message speaks about a). Hence, you can declare your function inside rendre() or inside the Rmd file.

Inside rendre() function

rendre <- function(){
  printA <- function() {
    return(a)
  }
  a <- 5
  render("c:/users/db7trs/desktop/test.Rmd")
}

OR inside the test.Rmd

---
title: "test"
output: html_document
---

```{r}
printA <- function() {
  return(a)
}
printA()
```


来源: stackexchange

问:
How to find --name of kubernetes cluster in Azure portal?
anyone knows how to find the name of a kubernetes cluster in azure portal? I did not create the cluster but I'm trying to connect to it and I don't know and can't find what to put in the --name tag</p>

答:
Well, the name of the kubernetes cluster is the name of the resource you see in the portal. As simple as that.

Just find the cluster in question and look how its called.

ContentLicense: CC BY-SA 3.0


问:
Double natural order not working as expected
I'm trying to implement selection sort using generics. To do that I receive a comparator (Because I wanted to use the method Comparator#naturalOrder() while testing).

The problem is that when calling it with a Double array it does not work, but when calling it with an Integer array instead, it works.

Here is the selection sort implementation I made:

```<code>public static<V> void selectionSort(V[] arr, Comparator<V> cmp){
    if (arr == null)
        throw new IllegalArgumentException("Invalid array, can't be sorted");

    int minIndex = -1;
    for(int i = 0, j; i<arr.length; i++){
        for (j = i; j<arr.length;j++){
            if (minIndex == -1 || cmp.compare(arr[minIndex],arr[j])>0){
                minIndex = j;
            }
        }
        swap(arr, i, minIndex);
    }
}

private static<V> void swap(V[] arr, int i, int j) {
    V aux = arr[i];
    arr[i]=arr[j];
    arr[j]=aux;
}
</code>```

Here is the test that's failing:

```<code>@Test
public void selectionSortDoubleTest(){
    arrDouble = new Double[]{5.5,2.5,1.2,8.0};
    SelectionSort.selectionSort(arrDouble, Comparator.naturalOrder());
    Assert.assertArrayEquals(new Double[]{1.2,2.5,5.5,8.0}, arrDouble);
}
</code>```

And here is the test that works:

```<code>@Test
public void selectionSortIntegerTest(){
    arr = new Integer[]{2,5,7,1};
    SelectionSort.selectionSort(arr, Comparator.naturalOrder());
    Assert.assertArrayEquals(new Integer[]{1, 2, 5, 7},arr);
}
</code>```

The weird part is that in the first test the arrays differ at position [1], so both start with 1.2, but then arrDouble[1] is 8.0 which doesn't make any sense.

The assertion error message I receive:

```<code>Arrays first differed at element [1];
    Expected :2.5
    Actual   :8.0
</code>```

答: minIndex must be reset to -1 at each iteration of the outer loop. Otherwise you swap the previously found min element with the new one. Using a debugger makes it quite easy to spot such mistakes.

Body:
I'm trying to implement selection sort using generics. To do that I receive a comparator (Because I wanted to use the method Comparator#naturalOrder() while testing).

The problem is that when calling it with a Double array it does not work, but when calling it with an Integer array instead, it works.

Here is the selection sort implementation I made:

public static<V> void selectionSort(V[] arr, Comparator<V> cmp){
    if (arr == null)
        throw new IllegalArgumentException("Invalid array, can't be sorted");

    int minIndex = -1;
    for(int i = 0, j; i<arr.length; i++){
        for (j = i; j<arr.length;j++){
            if (minIndex == -1 || cmp.compare(arr[minIndex],arr[j])>0){
                minIndex = j;
            }
        }
        swap(arr, i, minIndex);
    }
}

private static<V> void swap(V[] arr, int i, int j) {
    V aux = arr[i];
    arr[i]=arr[j];
    arr[j]=aux;
}

Here is the test that's failing:

@Test
public void selectionSortDoubleTest(){
    arrDouble = new Double[]{5.5,2.5,1.2,8.0};
    SelectionSort.selectionSort(arrDouble, Comparator.naturalOrder());
    Assert.assertArrayEquals(new Double[]{1.2,2.5,5.5,8.0}, arrDouble);
}

And here is the test that works:

@Test
public void selectionSortIntegerTest(){
    arr = new Integer[]{2,5,7,1};
    SelectionSort.selectionSort(arr, Comparator.naturalOrder());
    Assert.assertArrayEquals(new Integer[]{1, 2, 5, 7},arr);
}

The weird part is that in the first test the arrays differ at position [1], so both start with 1.2, but then arrDouble[1] is 8.0 which doesn't make any sense.

The assertion error message I receive:

Arrays first differed at element [1];
    Expected :2.5
    Actual   :8.0


问:
Python condensing tuple's to first value
I have a list of tuples that output </p>

```<code>[('city 1', '#' ), ('city 1', '#' ), ('city 2', '#' ), ('city 2', '#'), etc...]
</code>```

<p>What I need to do is to add up all of each city's # value and output a list such that: </p>

```<code>[('city 1', 'sumof#' ), ('city 2', 'sumof#' ), ('city 3', 'sumof#' ), ('city 4', 'sumof#'), etc...]
</code>```

答:
Just use a defaultdict:

```<code>from collections import defaultdict

d = [('city 1', 2 ), ('city 1', 1 ), ('city 2', 2 ), ('city 2', 4)]

sum_values = defaultdict(list)

for city, value in d:
    sum_values[city].append(value)

>>> print([(city, sum(values)) for city, values in sorted(sum_values.items())])
[('city 1', 3), ('city 2', 6)]
</code>```

Body:
I have a list of tuples that output

[('city 1', '#' ), ('city 1', '#' ), ('city 2', '#' ), ('city 2', '#'), etc...]

What I need to do is to add up all of each city's # value and output a list such that:

[('city 1', 'sumof#' ), ('city 2', 'sumof#' ), ('city 3', 'sumof#' ), ('city 4', 'sumof#'), etc...]

Body:
Just use a defaultdict:

from collections import defaultdict

d = [('city 1', 2 ), ('city 1', 1 ), ('city 2', 2 ), ('city 2', 4)]

sum_values = defaultdict(list)

for city, value in d:
    sum_values[city].append(value)

>>> print([(city, sum(values)) for city, values in sorted(sum_values.items())])
[('city 1', 3), ('city 2', 6)]


问:
WSO2 Dev Studio 3.8 does not start, nor attach to WSO2 EI
I went to wso2.com site today and downloaded the WSO2 EI 6.0 server and the Developer Studio 3.8. I tried creating a new project and starting WSO2 EI server from Eclipse. It cannot start the EI server due to a bug in the tooling. The issue is reported here: https://github.com/wso2/devstudio-tooling-ei/issues/6

Then I tried to use the remote server option, but it cannot connect to it either due to another bug in tooling. It seems the 3.8 version is broken.

I was hoping wso2 dev community is quite mature to deliver stable releases. But having such basic features broken is quite worrying.

Could someone recommend a combination of EI and Dev Studio that is proven to work?

答: Please use the EI 6.1.1 version with the WSO2 Developer Studio 3.8 version. </p>


问:
How can I create a circle profile picture view over rectangle in android layout?

How to draw the attached layout which is have circle over rectangle.
mean that circle is profile image, and inside the rectangle login information layout. Can any one please suggest this?

答:
Add this in drawable with name shape:

```<code><?xml version="1.0" encoding="UTF-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android">

        <stroke android:width="1dp" android:color="#1B5E20" />
        <corners android:radius="50dp"/>
        <padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
    </shape>
</code>```

This is your layout:

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

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:scaleType="center"
        android:background="@drawable/shape"
        android:src="@drawable/verification_background"/>

    </FrameLayout>
</RelativeLayout>
</code>```

Body:
Add this in drawable with name shape:

<?xml version="1.0" encoding="UTF-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android">

        <stroke android:width="1dp" android:color="#1B5E20" />
        <corners android:radius="50dp"/>
        <padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
    </shape>

This is your layout:

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

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:scaleType="center"
        android:background="@drawable/shape"
        android:src="@drawable/verification_background"/>

    </FrameLayout>
</RelativeLayout>


答:
try below code

```<code>    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:app="http://schemas.android.com/apk/res-auto"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:background="#be464545">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <de.hdodenhof.circleimageview.CircleImageView
            android:id="@+id/user_profile_photo"
            android:layout_width="120dp"
            android:layout_height="120dp"
            android:layout_below="@+id/header_cover_image"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="60dp"
            android:background="@drawable/prof"
            android:elevation="5dp"
            android:scaleType="center"
            app:civ_border_color="#FFF"
            app:civ_border_width="5dp"/>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="30dp"
        android:layout_marginRight="30dp"
        android:layout_marginTop="-60dp"
        android:background="#fff"
        android:elevation="4dp"
        android:orientation="vertical"
        android:padding="20dp">

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:paddingTop="30dp">

            <android.support.design.widget.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <EditText
                    android:id="@+id/username"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:drawableLeft="@drawable/ic_mood_black_24dp"
                    android:drawableTint="#f5701e"
                    android:hint="UserName"
                    android:inputType="textEmailAddress"
                    android:singleLine="true"/>
            </android.support.design.widget.TextInputLayout>

            <android.support.design.widget.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <EditText
                    android:id="@+id/password"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="16dp"
                    android:drawableLeft="@drawable/ic_lock_outline_black_24dp"
                    android:drawableTint="#f5701e"
                    android:hint="Password"
                    android:inputType="textPassword"
                    android:singleLine="true"/>
            </android.support.design.widget.TextInputLayout>

            <Button
                android:id="@+id/btnLogin"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_margin="22dp"
                android:background="#f5701e"
                android:text="Sign In"
                android:textAllCaps="false"
                android:textColor="#fff"
                android:textSize="18sp"/>
        </LinearLayout>

    </RelativeLayout>
    </LinearLayout>
</LinearLayout>
</code>```

layout

for CircleImageView you have to add compile 'de.hdodenhof:circleimageview:2.1.0' dependency in your app level gradle file

Title: How can I create a circle profile picture view over rectangle in android layout?

Body:
How to draw the attached layout which is have circle over rectangle.
mean that circle is profile image, and inside the rectangle login information layout. Can any one please suggest this?

Body:
try below code

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:app="http://schemas.android.com/apk/res-auto"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:background="#be464545">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <de.hdodenhof.circleimageview.CircleImageView
            android:id="@+id/user_profile_photo"
            android:layout_width="120dp"
            android:layout_height="120dp"
            android:layout_below="@+id/header_cover_image"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="60dp"
            android:background="@drawable/prof"
            android:elevation="5dp"
            android:scaleType="center"
            app:civ_border_color="#FFF"
            app:civ_border_width="5dp"/>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="30dp"
        android:layout_marginRight="30dp"
        android:layout_marginTop="-60dp"
        android:background="#fff"
        android:elevation="4dp"
        android:orientation="vertical"
        android:padding="20dp">

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:paddingTop="30dp">

            <android.support.design.widget.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <EditText
                    android:id="@+id/username"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:drawableLeft="@drawable/ic_mood_black_24dp"
                    android:drawableTint="#f5701e"
                    android:hint="UserName"
                    android:inputType="textEmailAddress"
                    android:singleLine="true"/>
            </android.support.design.widget.TextInputLayout>

            <android.support.design.widget.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <EditText
                    android:id="@+id/password"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="16dp"
                    android:drawableLeft="@drawable/ic_lock_outline_black_24dp"
                    android:drawableTint="#f5701e"
                    android:hint="Password"
                    android:inputType="textPassword"
                    android:singleLine="true"/>
            </android.support.design.widget.TextInputLayout>

            <Button
                android:id="@+id/btnLogin"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_margin="22dp"
                android:background="#f5701e"
                android:text="Sign In"
                android:textAllCaps="false"
                android:textColor="#fff"
                android:textSize="18sp"/>
        </LinearLayout>

    </RelativeLayout>
    </LinearLayout>
</LinearLayout>

layout

for CircleImageView you have to add compile 'de.hdodenhof:circleimageview:2.1.0' dependency in your app level gradle file


问:
Curiously recurring pattern using enum in derived class
When I compile this code (with Visual Studio 2017):

```<code>template<class MostDerived>
class BaseClass
{
public:
    typename MostDerived::Units DoStuff()
    {
        MostDerived::Units units;

        return units;
    }
};

class DerivedClass : public BaseClass<DerivedClass>
{
public:
    enum class Units
    {
        Unit1
    };
};

void Invoke()
{
    DerivedClass derivedClass;
    DerivedClass::Units units = derivedClass.DoStuff();
}
</code>```

I get an error:

C2039: 'Units': is not a member of 'DerivedClass'.

Experimenting with it, I've determined that the error occurs when DerivedClass::Units is used as either the result or a parameter to DoStuff() (so returning the result in a by-reference variable doesn't fix the error). I can use Units in the body of the function with no error.

Is this behavior consistent with C++ 17 or is it a bug in Visual C++?

答:
You can fix it using automatic return type deduction. Using Units inside of function is not an error because instantiation of BaseClass<DerivedClass> will only instantiate declarations, not definitions. DoStuff body gets instantiated when it is actually called and at that point Units is not incomplete anymore.

```<code>auto DoStuff()
{
    typename MostDerived::Units units{};
    return units;
}
</code>```

online compiler

Body:
When I compile this code (with Visual Studio 2017):

template<class MostDerived>
class BaseClass
{
public:
    typename MostDerived::Units DoStuff()
    {
        MostDerived::Units units;

        return units;
    }
};

class DerivedClass : public BaseClass<DerivedClass>
{
public:
    enum class Units
    {
        Unit1
    };
};

void Invoke()
{
    DerivedClass derivedClass;
    DerivedClass::Units units = derivedClass.DoStuff();
}

I get an error:

C2039: 'Units': is not a member of 'DerivedClass'.

Experimenting with it, I've determined that the error occurs when DerivedClass::Units is used as either the result or a parameter to DoStuff() (so returning the result in a by-reference variable doesn't fix the error). I can use Units in the body of the function with no error.

Is this behavior consistent with C++ 17 or is it a bug in Visual C++?

Body:
You can fix it using automatic return type deduction. Using Units inside of function is not an error because instantiation of BaseClass<DerivedClass> will only instantiate declarations, not definitions. DoStuff body gets instantiated when it is actually called and at that point Units is not incomplete anymore.

auto DoStuff()
{
    typename MostDerived::Units units{};
    return units;
}

online compiler


问:
What's a good, free source control system for eclipse android development?
My app code is starting to get unmanageable and I want to start source control, primarily because I need to branch my code.

What are some good systems that you have used in the past and what would you recommend to me.

Requirements:

Must be free

Must integrate with eclipse

Must work well with android development plugin

答:
Find EGit Releases here : http://www.eclipse.org/egit/download/

Since Mar 2010 we did a release every 3 months, current release is 0.10.1
Next release is planned for end of Feb 2011 with Helios SR2.

ContentLicense: CC BY-SA 2.5


问:
Is there a way to select an option from dropdown other than using 'Select' class in Selenium?
Is there a way to select an option from drop down other than using 'Select' class in Selenium?</p>

答:
Yes. The other way is, click on the dropdown menu and select the option from the dropdown using click method as below:</p>

```<code>WebElement ele = driver.findElement(By.xpath("<Xpath of dropdown element>"));     // To find the dropdown web element
List<WebElement> options = driver.findElements(By.xpath("<Xpath of dropdown Options"));    // To find the dropdown options
ele.click();      // To click on the dropdown element
options.get(<index>).click();      //To click on the option..
</code>```

Body:
Yes. The other way is, click on the dropdown menu and select the option from the dropdown using click method as below:

WebElement ele = driver.findElement(By.xpath("<Xpath of dropdown element>"));     // To find the dropdown web element
List<WebElement> options = driver.findElements(By.xpath("<Xpath of dropdown Options"));    // To find the dropdown options
ele.click();      // To click on the dropdown element
options.get(<index>).click();      //To click on the option..


问:
MSBuild creating sfproj package fails: The OutputPath property is not set for project
I'm using the following command lines:

```<code>"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" MyApp.sln /p:configuration="Release" /t:Build
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" MyApp.sfproj /p:platform="Any CPU" /p:configuration="Release" /t:Package
</code>```

First line works fine, but second fails with the error

```<code>"MyApp.sfproj" (Package target) (1) ->
"AppProj.csproj" (default target) (4) ->
  C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(724,5): error : The OutputPath property is not set for project 'AppProj.csproj'.
  Please check to make sure that you have specified a validcombination of Configuration and Platform for this project.
  Configuration='Release'  Platform='Any CPU'.
  You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default
  Configuration or Platform that doesn't exist for this project. [AppProj.csproj]
</code>```

for some projects in my application.

I have the following PropertyGroup defined in the relevant csproj:

```<code>  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\x64\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <PlatformTarget>x64</PlatformTarget>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\x64\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <PlatformTarget>x64</PlatformTarget>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
</code>```

When I deploy application from VS2015/2017 it works great and bin\pkg is created as expected.

答:
When trying to build on VSTS I was experiencing the same issue after upgrading Microsoft.VisualStudio.Azure.Fabric.MSBuild to 1.6.3 (from 1.6.1).

I fixed it by changing all target platforms to 'Any CPU' which were previously 'x64'.

See https://github.com/Azure/service-fabric-issues/issues/64#issuecomment-323942996.

Body:
I'm using the following command lines:

"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" MyApp.sln /p:configuration="Release" /t:Build
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" MyApp.sfproj /p:platform="Any CPU" /p:configuration="Release" /t:Package

First line works fine, but second fails with the error

"MyApp.sfproj" (Package target) (1) ->
"AppProj.csproj" (default target) (4) ->
  C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(724,5): error : The OutputPath property is not set for project 'AppProj.csproj'.
  Please check to make sure that you have specified a validcombination of Configuration and Platform for this project.
  Configuration='Release'  Platform='Any CPU'.
  You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default
  Configuration or Platform that doesn't exist for this project. [AppProj.csproj]

for some projects in my application.

I have the following PropertyGroup defined in the relevant csproj:

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\x64\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <PlatformTarget>x64</PlatformTarget>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\x64\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <PlatformTarget>x64</PlatformTarget>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>

When I deploy application from VS2015/2017 it works great and bin\pkg is created as expected.


问:
xamarin ios custom back button differs between 11 and 10.3
I am using a custom back button in my application.

Code to generate the button

```<code>protected UIBarButtonItem CreateBackButton(string localizationKey, EventHandler handler)
{
    UIImage image = UIImage.FromBundle("BackIcon");

    UIButton customButton = new UIButton(UIButtonType.Custom);
    customButton.SetTitle(NSBundle.MainBundle.LocalizedString(localizationKey, null), UIControlState.Normal);
    customButton.SetImage(image.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), UIControlState.Normal);
    customButton.BackButtonStyle();

    customButton.TouchUpInside += handler;

    var backButton = new UIBarButtonItem(customButton);

    return backButton;
}
</code>```

UPDATE

```<code>    internal static UIButton BackButtonStyle(this UIButton button)
    {
        button.SetTitleColor(ViewModelHelper.FromHex(PrimaryAppColor).ToNative(), UIControlState.Normal);
        button.TintColor = ViewModelHelper.FromHex(PrimaryAppColor).ToNative();

        return button;
    }
</code>```

PrimaryAppColor is a simple RGB string value in hex style.

The code is called in the "ViewDidLoad" like following:

```<code>    public override void ViewDidLoad()
    {
        ---Snipped---

        this.NavigationItem.SetHidesBackButton(true, false);
        this.NavigationItem.LeftBarButtonItem = this.CreateBackButton("localizedBackKey", this.OnBackButtonPressed);

        ---Snipped---
    }
</code>```

Pls see attached screen shots for the result. First one is the expected look!

Does any of you have an idea why it is showing the View title and my custom button.

THX

答:
It is because you forgot to set frame on the Button , so the text and image got overlap.

Solution:

```<code>customButton.Frame = new CGRect(0,0,100,44);
</code>```

Body:
I am using a custom back button in my application.

Code to generate the button

protected UIBarButtonItem CreateBackButton(string localizationKey, EventHandler handler)
{
    UIImage image = UIImage.FromBundle("BackIcon");

    UIButton customButton = new UIButton(UIButtonType.Custom);
    customButton.SetTitle(NSBundle.MainBundle.LocalizedString(localizationKey, null), UIControlState.Normal);
    customButton.SetImage(image.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), UIControlState.Normal);
    customButton.BackButtonStyle();

    customButton.TouchUpInside += handler;

    var backButton = new UIBarButtonItem(customButton);

    return backButton;
}

UPDATE

    internal static UIButton BackButtonStyle(this UIButton button)
    {
        button.SetTitleColor(ViewModelHelper.FromHex(PrimaryAppColor).ToNative(), UIControlState.Normal);
        button.TintColor = ViewModelHelper.FromHex(PrimaryAppColor).ToNative();

        return button;
    }

PrimaryAppColor is a simple RGB string value in hex style.

The code is called in the "ViewDidLoad" like following:

    public override void ViewDidLoad()
    {
        ---Snipped---

        this.NavigationItem.SetHidesBackButton(true, false);
        this.NavigationItem.LeftBarButtonItem = this.CreateBackButton("localizedBackKey", this.OnBackButtonPressed);

        ---Snipped---
    }

Pls see attached screen shots for the result. First one is the expected look!

Does any of you have an idea why it is showing the View title and my custom button.

THX

Body:
It is because you forgot to set frame on the Button , so the text and image got overlap.

Solution:

customButton.Frame = new CGRect(0,0,100,44);


问:
Free heap size does not increase in Maven

When I run maven-jetty-plugin, I run next command:

```<code>mvn -DMAVEN_OPTS="-Xmx1024m -Xms512m" -Djetty.port=8080 jetty:run
</code>```

but when I try to output free heap size with

```<code>Long heapFreeSize = Runtime.getRuntime().freeMemory();
</code>```

It always outputs something about about 30000000.

I suppose it's size in bytes, so about 30 megabytes.

Why then free heap memory did not increase?

答:
MAVEN_OPTS is an environment variable, which is read by Maven and used as the command line arguments for forking java processes. Command line arguments control how the Java executable is started, e.g. stuff like memory settings.

-D is used for setting Java System Properties, which is something completely different than command line arguments. Java System Properties can be read programmatically, e.g. by using System.getProperties().

Windows:

```<code>SET MAVEN_OPTS="-Xmx1024m -Xms512m"
mvn -Djetty.port=8080 jetty:run
</code>```

Linux:

```<code>export MAVEN_OPTS="-Xmx1024m -Xms512m"
mvn -Djetty.port=8080 jetty:run
</code>```

Body:
When I run maven-jetty-plugin, I run next command:

mvn -DMAVEN_OPTS="-Xmx1024m -Xms512m" -Djetty.port=8080 jetty:run

but when I try to output free heap size with

Long heapFreeSize = Runtime.getRuntime().freeMemory();

It always outputs something about about 30000000.

I suppose it's size in bytes, so about 30 megabytes.

Why then free heap memory did not increase?

Body:
MAVEN_OPTS is an environment variable, which is read by Maven and used as the command line arguments for forking java processes. Command line arguments control how the Java executable is started, e.g. stuff like memory settings.

-D is used for setting Java System Properties, which is something completely different than command line arguments. Java System Properties can be read programmatically, e.g. by using System.getProperties().

Windows:

SET MAVEN_OPTS="-Xmx1024m -Xms512m"
mvn -Djetty.port=8080 jetty:run

Linux:

export MAVEN_OPTS="-Xmx1024m -Xms512m"
mvn -Djetty.port=8080 jetty:run


答:
Simplest way for doing this.

```<code>dependencies: compile 'com.android.support:appcompat-v7:23.1.1'
              compile 'com.android.support:design:23.1.1'
              compile 'com.android.support:cardview-v7:23.1.1'

<android.support.v7.widget.CardView
    android:layout_width="80dp"
    android:layout_height="80dp"
    android:elevation="12dp"
    android:id="@+id/view2"
   app:cardCornerRadius="40dp"
    android:layout_centerHorizontal="true"
    android:innerRadius="0dp"
    android:shape="ring"
    android:thicknessRatio="1.9">
    <ImageView
        android:layout_height="80dp"
        android:layout_width="match_parent"
        android:id="@+id/imageView1"
        android:src="@drawable/YOUR_IMAGE"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true">
    </ImageView>
 </android.support.v7.widget.CardView>
</code>```

Body:
Simplest way for doing this.

dependencies: compile 'com.android.support:appcompat-v7:23.1.1'
              compile 'com.android.support:design:23.1.1'
              compile 'com.android.support:cardview-v7:23.1.1'

<android.support.v7.widget.CardView
    android:layout_width="80dp"
    android:layout_height="80dp"
    android:elevation="12dp"
    android:id="@+id/view2"
   app:cardCornerRadius="40dp"
    android:layout_centerHorizontal="true"
    android:innerRadius="0dp"
    android:shape="ring"
    android:thicknessRatio="1.9">
    <ImageView
        android:layout_height="80dp"
        android:layout_width="match_parent"
        android:id="@+id/imageView1"
        android:src="@drawable/YOUR_IMAGE"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true">
    </ImageView>
 </android.support.v7.widget.CardView>


问:
How to use other Layout for page the _Layout.vbhtml in .net mvc 3 view
I want to use a different layout for all the Views in one folder. It's all my Panel views controlled by PanelController.vb

```<code>Function LogIn() As ActionResult
    Return View()
End Function
</code>```

Currently all the views in my project utilize _Layout.vbhtml for the layout etc.

How can I make these specific pages utilize e.g. _PanelLayout.vbhtml instead of the default?

See below of what files I am talking about:

I am using Visual Studio 2010, .NET MVC 3, Pages are Razor or something like that.

答:
The question specifically calls for vbhtml (or vb.net) page.  The accepted answer is for cshtml (C#) razor page.   The correct answer for vb.net is:</p>

```<code>@CODE
Layout ="~/Views/Shared/_PanelLayout.vbhtml"
End Code
</code>```

Body:
I want to use a different layout for all the Views in one folder. It's all my Panel views controlled by PanelController.vb

Function LogIn() As ActionResult
    Return View()
End Function

Currently all the views in my project utilize _Layout.vbhtml for the layout etc.

How can I make these specific pages utilize e.g. _PanelLayout.vbhtml instead of the default?

See below of what files I am talking about:

I am using Visual Studio 2010, .NET MVC 3, Pages are Razor or something like that.

Body:
The question specifically calls for vbhtml (or vb.net) page.  The accepted answer is for cshtml (C#) razor page.   The correct answer for vb.net is:

@CODE
Layout ="~/Views/Shared/_PanelLayout.vbhtml"
End Code


答:
Try this

```<code><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_account_detail"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <View
        android:id="@+id/view"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:background="@color/colorPrimary" />

    <ScrollView
        android:id="@+id/scrolView_account"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <RelativeLayout
            android:id="@+id/linear_account"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <android.support.v7.widget.CardView
                    android:id="@+id/cardView_account_details"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp"
                    android:layout_marginTop="70dp"
                    app:cardCornerRadius="5dp"
                    app:cardElevation="5dp"
                    app:cardUseCompatPadding="true">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="@color/colorAccent"
                        android:orientation="vertical">

                        <LinearLayout
                            android:id="@+id/linear_account_input_details"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="50dp"
                            android:orientation="vertical"
                            android:padding="10dp">

                            <TextView
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="20dp"
                                android:gravity="center"
                                android:text="NILU"
                                android:textSize="30sp" />

                            <EditText
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:drawableLeft="@mipmap/ic_launcher_round"
                                android:hint="Enter Email" />

                            <EditText
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:drawableLeft="@mipmap/ic_launcher_round"
                                android:hint="Enter Paasword" />

                            <Button
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"

                                android:background="@drawable/temp"
                                android:text="Login" />

                        </LinearLayout>

                    </LinearLayout>

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

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="This is demo" />

            </LinearLayout>

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <de.hdodenhof.circleimageview.CircleImageView
                    android:id="@+id/imageview_account_profile"
                    android:layout_width="150dp"
                    android:layout_height="150dp"
                    android:layout_alignParentTop="true"
                    android:layout_centerHorizontal="true"
                    android:src="@mipmap/ic_launcher_round"
                    app:civ_border_color="@color/colorWhite"
                    app:civ_border_width="2dp" />

            </RelativeLayout>

        </RelativeLayout>

    </ScrollView>

</RelativeLayout>
</code>```

now create a @drawable/temp.xml in res/drawable folder like this

```<code><?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

    <stroke
        android:width="1dp"
        android:color="@color/colorBlue" />
    <solid android:color="@color/colorAccentCompany" />
    <corners android:radius="50dp" />
</shape>
</code>```

And Don't forgot compile this dependencies

```<code>compile 'com.android.support:cardview-v7:26.+'
compile 'de.hdodenhof:circleimageview:2.1.0'
</code>```

Body:
Try this

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_account_detail"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <View
        android:id="@+id/view"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:background="@color/colorPrimary" />

    <ScrollView
        android:id="@+id/scrolView_account"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <RelativeLayout
            android:id="@+id/linear_account"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <android.support.v7.widget.CardView
                    android:id="@+id/cardView_account_details"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp"
                    android:layout_marginTop="70dp"
                    app:cardCornerRadius="5dp"
                    app:cardElevation="5dp"
                    app:cardUseCompatPadding="true">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="@color/colorAccent"
                        android:orientation="vertical">

                        <LinearLayout
                            android:id="@+id/linear_account_input_details"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="50dp"
                            android:orientation="vertical"
                            android:padding="10dp">

                            <TextView
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="20dp"
                                android:gravity="center"
                                android:text="NILU"
                                android:textSize="30sp" />

                            <EditText
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:drawableLeft="@mipmap/ic_launcher_round"
                                android:hint="Enter Email" />

                            <EditText
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:drawableLeft="@mipmap/ic_launcher_round"
                                android:hint="Enter Paasword" />

                            <Button
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"

                                android:background="@drawable/temp"
                                android:text="Login" />

                        </LinearLayout>

                    </LinearLayout>

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

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="This is demo" />

            </LinearLayout>

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <de.hdodenhof.circleimageview.CircleImageView
                    android:id="@+id/imageview_account_profile"
                    android:layout_width="150dp"
                    android:layout_height="150dp"
                    android:layout_alignParentTop="true"
                    android:layout_centerHorizontal="true"
                    android:src="@mipmap/ic_launcher_round"
                    app:civ_border_color="@color/colorWhite"
                    app:civ_border_width="2dp" />

            </RelativeLayout>

        </RelativeLayout>

    </ScrollView>

</RelativeLayout>

now create a @drawable/temp.xml in res/drawable folder like this

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

    <stroke
        android:width="1dp"
        android:color="@color/colorBlue" />
    <solid android:color="@color/colorAccentCompany" />
    <corners android:radius="50dp" />
</shape>

And Don't forgot compile this dependencies

compile 'com.android.support:cardview-v7:26.+'
compile 'de.hdodenhof:circleimageview:2.1.0'


问:
serving static files from ingress-nginx
I have a express web server with static files. Let's call this my express-deployment.

I'd like to use my ingress-nginx to serve static files from my express-deployment without ever actually hitting my express server.

In nginx this is done with the location directive where you point to files locally hosted. While I see an option for locations-snippet in the ingress-nginx configMap, I'm not entirely sure how I would have this point to files in another container.

Is this possible with ingress-nginx? If so how would I go about it?  Alternatively, is this something that requires an nginx container to be hosted along side my express server? (Seems odd that I would need 2 nginx for that)

答: In theory, you could have a PV in in RWX mode mounted to both express and ingress and provide custom config to the nginx-ingress pods, but that should be avoided. Ingress Controller has one responsibility - implement Ingress rules defined in your cluster. To serve static content you should have a pod that does that, which indeed means ie. running second nginx in your stack. The thing is, that you should treat your ingress controller as part of the infrastructure providing generic cluster functionality, and serving static files from some place (or container if they are versioned/built as docker images) is de facto part of your application.</p>

Title: serving static files from ingress-nginx


问:
Is there any way to use TypeFace directly by passing URL?
I am trying to use font directly from api. This is an api of font ABeeZee
http://fonts.gstatic.com/s/abeezee/v11/kpplLynmYgP0YtlJA3atRw.ttf

Normally if my font is stored in assets/fonts folder i could use

```<code>TextView heading = (TextView) view.findViewById(R.id.heading);
    Typeface typeFace = Typeface.createFromAsset(context.getAssets(), "fonts/ABeZee.ttf");
    heading.setTypeface(typeFace);
    heading.setText(headerInfo.getName().trim());
</code>```

but i want to use it directly passing api. Is there any way?

答:
If you are pre-downloading the fonts. So save them in app cache directory

```<code>getFilesDir()- To get your own files dir , your package name and "/files" need to be appended to it.
</code>```

In that way you fonts will be secure(Less chances that user will manually delete them). Check for file before creating typeface.

```<code>private Typeface getFont(String filePath){
    File file=new File(filePath);
    if(file.exists()) {
        Typeface typeface = Typeface.createFromFile("filePath");
        return typeface;
    }
    return null;
}
</code>```

Body:
I am trying to use font directly from api. This is an api of font ABeeZee
http://fonts.gstatic.com/s/abeezee/v11/kpplLynmYgP0YtlJA3atRw.ttf

Normally if my font is stored in assets/fonts folder i could use

TextView heading = (TextView) view.findViewById(R.id.heading);
    Typeface typeFace = Typeface.createFromAsset(context.getAssets(), "fonts/ABeZee.ttf");
    heading.setTypeface(typeFace);
    heading.setText(headerInfo.getName().trim());

but i want to use it directly passing api. Is there any way?

Body:
If you are pre-downloading the fonts. So save them in app cache directory

getFilesDir()- To get your own files dir , your package name and "/files" need to be appended to it.

In that way you fonts will be secure(Less chances that user will manually delete them). Check for file before creating typeface.

private Typeface getFont(String filePath){
    File file=new File(filePath);
    if(file.exists()) {
        Typeface typeface = Typeface.createFromFile("filePath");
        return typeface;
    }
    return null;
}


问:
Selenium compilation error due to bad class file
My Java web application is upgraded from JDK 1.6 to JDK 1.8 version and I am updating the test environment to use the updated Selenium components as well.

Below mentioned are the updated Jars which I included in the pom.xml.

```<code>    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.0.0</version>
        <type>jar</type>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-server-standalone</artifactId>
        <version>3.0.0</version>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-support</artifactId>
        <version>3.0.0</version>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-leg-rc</artifactId>
        <version>3.0.0</version>
    </dependency>
</code>```

When I run a Job in Jenkins, it is throwing a compilation error as mentioned below.

```<code>        [ERROR] COMPILATION ERROR :
        [INFO] -------------------------------------------------------------
        [ERROR] D:\Jenkins\workspace\WIDFLY-trunk\src\test\java\com\company\test\dragon\acceptance\test\shiftscheduling\switchautm\switchtimes\SwitchingTimesAbsTest.java:[3,-1] cannot access org.openqa.selenium.support.PageFactory
        bad class file: org\openqa\selenium\support\PageFactory.class(org\openqa\selenium\support:PageFactory.class)
        class file has wrong version 52.0, should be 50.0
        [INFO] 1 error
        [INFO] -------------------------------------------------------------
        [INFO] ------------------------------------------------------------------------
        [INFO] BUILD FAILURE
        [INFO] ------------------------------------------------------------------------
        [INFO] Total time: 31.294s
        [INFO] Finished at: Mon Dec 04 CET 2017
        [INFO] Final Memory: 13M/31M
        [INFO] ------------------------------------------------------------------------
        Waiting for Jenkins to finish collecting data
        [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project test: Compilation failure
        [ERROR] D:\Jenkins\workspace\WIDFLY-trunk\src\test\java\com\company\test\dragon\acceptance\test\shiftscheduling\switchautm\switchtimes\SwitchingTimesAbsTest.java:[3,-1] cannot access org.openqa.selenium.support.PageFactory
        [ERROR] bad class file: org\openqa\selenium\support\PageFactory.class(org\openqa\selenium\support:PageFactory.class)
        [ERROR] class file has wrong version 52.0, should be 50.0
        [ERROR] -> [Help 1]
</code>```

What is that I am missing? I think it has a problem with selenium-support jar version but I have tried with lower version too and I am getting the same error.

Note: If I execute directly using maven in CMD prompt I am not getting any errors. Jenkins job execution only throws this error.

Kindly help please.

答:
The error does gives us a hint with what's going wrong as :

```<code>cannot access org.openqa.selenium.support.PageFactory
</code>```

and

```<code>class file has wrong version 52.0, should be 50.0
</code>```

The most likely solution for you will be to :

Upgrade JDK to recent version JDK 8u151

Use recent version of Selenium Maven Dependencies current being v3.8.1

Try to use selenium-java dependency only.

```<code><dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.8.1</version>
</dependency>
</code>```

If you are using RemoteWebDriver implementation, you still need to start a Selenium server. The best way is to download the selenium-server-standalone.jar from the Selenium Downloads page and just use it. You can also embed the Selenium Server into your own project, if you add the following dependency to your pom.xml:

```<code><dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-server</artifactId>
    <version>3.8.1</version>
</dependency>
</code>```

selenium-support is no longer a valid dependency so you can remove it.

Do maven clean and maven install

Re-Run your Test

Body:
My Java web application is upgraded from JDK 1.6 to JDK 1.8 version and I am updating the test environment to use the updated Selenium components as well.

Below mentioned are the updated Jars which I included in the pom.xml.

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.0.0</version>
        <type>jar</type>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-server-standalone</artifactId>
        <version>3.0.0</version>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-support</artifactId>
        <version>3.0.0</version>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-leg-rc</artifactId>
        <version>3.0.0</version>
    </dependency>

When I run a Job in Jenkins, it is throwing a compilation error as mentioned below.

        [ERROR] COMPILATION ERROR :
        [INFO] -------------------------------------------------------------
        [ERROR] D:\Jenkins\workspace\WIDFLY-trunk\src\test\java\com\company\test\dragon\acceptance\test\shiftscheduling\switchautm\switchtimes\SwitchingTimesAbsTest.java:[3,-1] cannot access org.openqa.selenium.support.PageFactory
        bad class file: org\openqa\selenium\support\PageFactory.class(org\openqa\selenium\support:PageFactory.class)
        class file has wrong version 52.0, should be 50.0
        [INFO] 1 error
        [INFO] -------------------------------------------------------------
        [INFO] ------------------------------------------------------------------------
        [INFO] BUILD FAILURE
        [INFO] ------------------------------------------------------------------------
        [INFO] Total time: 31.294s
        [INFO] Finished at: Mon Dec 04 CET 2017
        [INFO] Final Memory: 13M/31M
        [INFO] ------------------------------------------------------------------------
        Waiting for Jenkins to finish collecting data
        [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project test: Compilation failure
        [ERROR] D:\Jenkins\workspace\WIDFLY-trunk\src\test\java\com\company\test\dragon\acceptance\test\shiftscheduling\switchautm\switchtimes\SwitchingTimesAbsTest.java:[3,-1] cannot access org.openqa.selenium.support.PageFactory
        [ERROR] bad class file: org\openqa\selenium\support\PageFactory.class(org\openqa\selenium\support:PageFactory.class)
        [ERROR] class file has wrong version 52.0, should be 50.0
        [ERROR] -> [Help 1]

What is that I am missing? I think it has a problem with selenium-support jar version but I have tried with lower version too and I am getting the same error.

Note: If I execute directly using maven in CMD prompt I am not getting any errors. Jenkins job execution only throws this error.

Kindly help please.

Body:
The error does gives us a hint with what's going wrong as :

cannot access org.openqa.selenium.support.PageFactory

and

class file has wrong version 52.0, should be 50.0

The most likely solution for you will be to :

Upgrade JDK to recent version JDK 8u151

Use recent version of Selenium Maven Dependencies current being v3.8.1

Try to use selenium-java dependency only.

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.8.1</version>
</dependency>

If you are using RemoteWebDriver implementation, you still need to start a Selenium server. The best way is to download the selenium-server-standalone.jar from the Selenium Downloads page and just use it. You can also embed the Selenium Server into your own project, if you add the following dependency to your pom.xml:

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-server</artifactId>
    <version>3.8.1</version>
</dependency>

selenium-support is no longer a valid dependency so you can remove it.

Do maven clean and maven install

Re-Run your Test


问:
pip wont install anything getting numerous erros etc
So I have python 2.7
have pip installed
pip is upgraded
cant install anything i get all kinds of errors and have tried all kinds of solutions.
why do i have to type: C:\Users\kingj>python -m pip install
instead of pip install without getting: C:\Users\kingj>pip install
'pip' is not recognized as an internal or external command,
operable program or batch file.

everyone else seems to just type pip install etc... i have to do python -m pip install

then when i do do it like that i get this:C:\Users\kingj>python -m pip install django-json
Collecting django-json
  Could not fetch URL https://pypi.python.org/simple/django-json/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:661) - skipping
  Could not find a version that satisfies the requirement django-json (from versions: )
No matching distribution found for django-json

even though i have tried multiple packages by name and i get only that message?!

答: Sounds like your PATH variable isn't pointing to pip correctly. I'm not sure what the correct directory is in Windows as I'm a mac user. But i would start by looking there. Also, it may be worth uninstalling and reinstalling Python. I know there is a checkbox for updating your PATH variable when you do a fresh install of Python. Also, the newest versions of Python ship with pip correctly installed for you. If that is unsuccessful, check here: How do I install pip on Windows?</p>


问:
query in mongoDb using JavaScript
This is my sample documents in DB.

```<code>{
    "_id":1,
    "object":{
        "featureOne":true,
        "featureTwo":false,
        "featureThree":false,
        "featureFour":false
    }
}, {
    "_id":2,
    "object":{
        "featureOne":false,
        "featureTwo":false,
        "featureThree":false,
        "featureFour":false
    }
}, {
    "_id":3,
    "object":{
        "featureOne":true,
        "featureTwo":false,
        "featureThree":false,
        "featureFour":false
    }
}
</code>```

I want to get one object with "featureOne": true and another with "featureOne": false in a single query. I have knowledge on finding data using a particular key and value. But how can I get the data using same key of true and false values in a single query. Present I am using this code

```<code>db.collection(collectionName).find({"featureOne":true, {limit:1}).toArray(function(err, results) {
    db.collection(collectionName).find("featureOne":,false{limit:2}).toArray(function(err,res {
        console.log(results,res);
    });
});
</code>```

Is there any better way to achieve this?

答:
I think your approach is good. But in both cases your limit can be 1
In Mongoose, for example, you could call findOne, but with the official driver I think your approach is correct.

If you want to avoid both calls, you can extract all the elements of the collection and loop through them in code until you get one of each value. Probably more efficient than the other approach if you don't have many documents in your collection.

Title: query in mongoDb using JavaScript

Body:
This is my sample documents in DB.

{
    "_id":1,
    "object":{
        "featureOne":true,
        "featureTwo":false,
        "featureThree":false,
        "featureFour":false
    }
}, {
    "_id":2,
    "object":{
        "featureOne":false,
        "featureTwo":false,
        "featureThree":false,
        "featureFour":false
    }
}, {
    "_id":3,
    "object":{
        "featureOne":true,
        "featureTwo":false,
        "featureThree":false,
        "featureFour":false
    }
}

I want to get one object with "featureOne": true and another with "featureOne": false in a single query. I have knowledge on finding data using a particular key and value. But how can I get the data using same key of true and false values in a single query. Present I am using this code

db.collection(collectionName).find({"featureOne":true, {limit:1}).toArray(function(err, results) {
    db.collection(collectionName).find("featureOne":,false{limit:2}).toArray(function(err,res {
        console.log(results,res);
    });
});

Is there any better way to achieve this?


问:
Add a id/class to the
 generated by the asp.net DataList control
My question is dealing with the DataList control. I am trying to add a click event to the rows of the "table" in the OnItemDataBound event.

The problem I'm having is I can't get a reference (through a row id attribute) to the "row" being generated by the DataList control (and more specifically the item template).  Is there a way to add id attributes to the rows being generated by the item template?

Thank you.

答: You should probably create your own ItemTemplate for it.</p>

Title: Add a id/class to the <tr> generated by the asp.net DataList control


问:
thousands Operator in highcharts
am trying to as thousand operator in highcharts with Angular js.

I have called set options before calling the charts :

```<code>Highcharts.setOptions({
        lang: {
            decimalPoint : '.',
            thousandsSep: ','
         }
        });
</code>```

And then when I define thousand operator as this.{points[0].y:,.0f} in the following code it is showing me "Unexpected Expression { and injector " and [$injector:unpr] unresolved dependencies error.

```<code>tooltip: {
        style: {
            fontFamily: 'Roboto',
            fontSize: '12px'
        },
        formatter: function () {
            var headerFormat = '<span style="color: #000">Date: <b>' + Highcharts.dateFormat('%Y-%m-%d', new Date(this.x)) + '</b></span><br/>';
            var seriesOneLine = '<span style="color:' + this.points[0].color + '">\u25CF</span> ' + this.points[0].series.name + ': <b>' + this.{points[0].y:,.0f}+ '</b><br/>';
            var seriesTwoLine = '<span style="color:' + this.points[1].color + '">\u25CF</span> ' + this.points[1].series.name + ': <b>' + Math.round(this.points[1].y) + '</b><br/>';
            var seriesThreeLine = '<span style="color:' + this.points[2].color + '">\u25CF</span> Threshold %: <b>'+this.points[2].point.data.alertThresholdPercentage.toFixed(2)+'%</b><br/>';
            return headerFormat + seriesOneLine + seriesTwoLine + seriesThreeLine;
        }
    }
},
</code>```

Any pointer for solution would be very helpful.

答:
for thousand separate you can use like this format</p>

```<code>formatter: function () {
      return '<b>' + this.series.name + ': ' + Highcharts.numberFormat((this.y.toFixed(2) / 1000), 0, '.') + 'k';
                       }
</code>```

Title: thousands Operator in highcharts

Body:
am trying to as thousand operator in highcharts with Angular js.

I have called set options before calling the charts :

Highcharts.setOptions({
        lang: {
            decimalPoint : '.',
            thousandsSep: ','
         }
        });

And then when I define thousand operator as this.{points[0].y:,.0f} in the following code it is showing me "Unexpected Expression { and injector " and [$injector:unpr] unresolved dependencies error.

tooltip: {
        style: {
            fontFamily: 'Roboto',
            fontSize: '12px'
        },
        formatter: function () {
            var headerFormat = 'Date: ' + Highcharts.dateFormat('%Y-%m-%d', new Date(this.x)) + '
';
            var seriesOneLine = '\u25CF ' + this.points[0].series.name + ': ' + this.{points[0].y:,.0f}+ '
';
            var seriesTwoLine = '\u25CF ' + this.points[1].series.name + ': ' + Math.round(this.points[1].y) + '
';
            var seriesThreeLine = '\u25CF Threshold %: '+this.points[2].point.data.alertThresholdPercentage.toFixed(2)+'%
';
            return headerFormat + seriesOneLine + seriesTwoLine + seriesThreeLine;
        }
    }
},

Any pointer for solution would be very helpful.

Body:
for thousand separate you can use like this format

formatter: function () {
      return '<b>' + this.series.name + ': ' + Highcharts.numberFormat((this.y.toFixed(2) / 1000), 0, '.') + 'k';
                       }


问:
Blade: Undefined Variable Inside Foreach Loop

I have a controller which gets an array of a User's diaries from my database and passes them to my view:

<?php

public function readDiaries($hash)
{
    $user = User::where('hash', $hash)->first();
    $diaries = Diary::where('user_id', $user->id)->get();

    return view('app.diary.readDiaries', ['diaries' => $diaries]);
}
```

<p>In my view, I am looping through the diaries using a <code>@foreach</code> loop.</p>

<pre class="lang-php prettyprint-override"><code><div id="diaries" class="card-columns">
    @if (count($diaries) > 0)
        @foreach ($diaries as $dairy)
            {{ var_dump($diary) }}
        @endforeach
    @endif
</div>
</code>```

But I am getting the following undefined variable error...

Undefined variable: diary (View: C:\xampp\htdocs\personal_projects\Active\diary_app\resources\views\app\diary\readDiaries.blade.php)

Why is my $diary variable undefined inside the @foreach loop?

答:
```<code>@foreach ($diaries as $dairy)
 {{ var_dump($diary) }}
@endforeach
</code>```

you used ($diaries as $dairy) in foreach
but in foreach you used ($diary)

you want edit this {{ var_dump($diary) }} to {{ var_dump($dairy) }}
or you want edit @foreach ($diaries as $dairy) to @foreach ($diaries as $diary)

ContentLicense: CC BY-SA 4.0

Body:
I have a controller which gets an array of a User's diaries from my database and passes them to my view:

<?php

public function readDiaries($hash)
{
    $user = User::where('hash', $hash)->first();
    $diaries = Diary::where('user_id', $user->id)->get();

    return view('app.diary.readDiaries', ['diaries' => $diaries]);
}

In my view, I am looping through the diaries using a @foreach loop.

    @if (count($diaries) > 0)
        @foreach ($diaries as $dairy)
            {{ var_dump($diary) }}
        @endforeach
    @endif

But I am getting the following undefined variable error...

Undefined variable: diary (View: C:\xampp\htdocs\personal_projects\Active\diary_app\resources\views\app\diary\readDiaries.blade.php)

Why is my $diary variable undefined inside the @foreach loop?

Body:
@foreach ($diaries as $dairy)
 {{ var_dump($diary) }}
@endforeach

you used ($diaries as $dairy) in foreach
but in foreach you used ($diary)

you want edit this {{ var_dump($diary) }} to {{ var_dump($dairy) }}
or you want edit @foreach ($diaries as $dairy) to @foreach ($diaries as $diary)


问:
Disable Button on click if the app doesn't install
I have two buttons on splash screen and I want check if app install or not and give result if app install the button start is work and users can click to go main activity and the other button is disabled click and if the app doesn't install the button start disable and button install and download is working.. how do this?  </p>

```<code>  final Button down_install = (Button) findViewById(R.id.bt_down_install);
        final Button start = (Button) findViewById(R.id.bt_start);
        start.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                    boolean isAppInstalled = appInstalledOrNot("com.facebook.android");
                    if (isAppInstalled) {
                        Intent Start_screen = new Intent(SplashScreen.this, MainActivity.class);
                        startActivity(Start_screen);

                    } else {

                        start.setEnabled(false);

                }

            }

            private boolean appInstalledOrNot(String uri) {
                PackageManager pm = getPackageManager();
                try {
                    pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
                    return true;
                } catch (PackageManager.NameNotFoundException e) {
                }

                return false;

            }
        });
</code>```

答:
try {
        //use packagename of app which you want to check
            getPackageManager().getPackageInfo("com.example.helloworld", PackageManager.GET_ACTIVITIES);</p>

```<code>    } catch (PackageManager.NameNotFoundException e) {
    }
</code>```

Body:
I have two buttons on splash screen and I want check if app install or not and give result if app install the button start is work and users can click to go main activity and the other button is disabled click and if the app doesn't install the button start disable and button install and download is working.. how do this?

  final Button down_install = (Button) findViewById(R.id.bt_down_install);
        final Button start = (Button) findViewById(R.id.bt_start);
        start.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                    boolean isAppInstalled = appInstalledOrNot("com.facebook.android");
                    if (isAppInstalled) {
                        Intent Start_screen = new Intent(SplashScreen.this, MainActivity.class);
                        startActivity(Start_screen);

                    } else {

                        start.setEnabled(false);

                }

            }

            private boolean appInstalledOrNot(String uri) {
                PackageManager pm = getPackageManager();
                try {
                    pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
                    return true;
                } catch (PackageManager.NameNotFoundException e) {
                }

                return false;

            }
        });

Body:
try {
        //use packagename of app which you want to check
            getPackageManager().getPackageInfo("com.example.helloworld", PackageManager.GET_ACTIVITIES);

    } catch (PackageManager.NameNotFoundException e) {
    }


问:
why Catch block is executing after return statement in C#
I am trying to use try catch in C# application but I am facing problem suppose first-time internet issue came and then again it tries to sync second-time internet came then after return statement it's going again in catch(CommunicationException comEx) block and return false.

why its happening

```<code>int SyncFailCount = 0;
private bool SyncCustomers(long TenantId, DataTable dtCusomers)
{
   bool IsSyncSuccess = false;
    try
    {
        SyncQBClient client = new SyncQBClient();
        client.SynvCustomer(TenantId, dtCusomers);
        SyncFailCount = 0;
        IsSyncSuccess = true;
    }
    catch (CommunicationException comEx) // Mohan: Exception due to Internet issue
    {
        SyncFailCount = SyncFailCount + 1;
        Thread.Sleep(300);
        if (SyncFailCount <= 5)
        {
            SyncCustomers(TenantId, dtCusomers);
        }
    }
    catch (TimeoutException TimeoutEx) // Mohan: Exception due to timeout from web service
    {
        SyncFailCount = SyncFailCount + 1;
        Thread.Sleep(300);
        if (SyncFailCount <= 5)
        {
            SyncCustomers(TenantId, dtCusomers);
        }
        SyncFailCount = 0;
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message, "CashPundit", MessageBoxButtons.OK, MessageBoxIcon.Error);
        SyncFailCount = 0;
    }
    return IsSyncSuccess;
}
</code>```

答:
I am not too sure which .net framework you are using but 4.0 and above  i would recommned using Task method instead of thread This is sample only hope you can use this example</p>

```<code>class Program
{
    static void Main(string[] args)
    {
        Task<int> task = new Task<int>(Test);
        task.ContinueWith(ExceptionHandler, TaskContinuationOptions.OnlyOnFaulted);
        task.Start();
        Console.ReadLine();
    }

    static int Test()
    {
        throw new Exception();
    }

    static void ExceptionHandler(Task<int> task)
    {
        var exception = task.Exception;
        Console.WriteLine(exception);
    }
}
</code>```

Body:
I am trying to use try catch in C# application but I am facing problem suppose first-time internet issue came and then again it tries to sync second-time internet came then after return statement it's going again in catch(CommunicationException comEx) block and return false.

why its happening

int SyncFailCount = 0;
private bool SyncCustomers(long TenantId, DataTable dtCusomers)
{
   bool IsSyncSuccess = false;
    try
    {
        SyncQBClient client = new SyncQBClient();
        client.SynvCustomer(TenantId, dtCusomers);
        SyncFailCount = 0;
        IsSyncSuccess = true;
    }
    catch (CommunicationException comEx) // Mohan: Exception due to Internet issue
    {
        SyncFailCount = SyncFailCount + 1;
        Thread.Sleep(300);
        if (SyncFailCount <= 5)
        {
            SyncCustomers(TenantId, dtCusomers);
        }
    }
    catch (TimeoutException TimeoutEx) // Mohan: Exception due to timeout from web service
    {
        SyncFailCount = SyncFailCount + 1;
        Thread.Sleep(300);
        if (SyncFailCount <= 5)
        {
            SyncCustomers(TenantId, dtCusomers);
        }
        SyncFailCount = 0;
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message, "CashPundit", MessageBoxButtons.OK, MessageBoxIcon.Error);
        SyncFailCount = 0;
    }
    return IsSyncSuccess;
}

Body:
I am not too sure which .net framework you are using but 4.0 and above  i would recommned using Task method instead of thread This is sample only hope you can use this example

class Program
{
    static void Main(string[] args)
    {
        Task<int> task = new Task<int>(Test);
        task.ContinueWith(ExceptionHandler, TaskContinuationOptions.OnlyOnFaulted);
        task.Start();
        Console.ReadLine();
    }

    static int Test()
    {
        throw new Exception();
    }

    static void ExceptionHandler(Task<int> task)
    {
        var exception = task.Exception;
        Console.WriteLine(exception);
    }
}


问:
django rest framework nested filter
I want to get all the "Registro_Entrada" and filter them by "Entrante" when "fk_tipo_entrante" is equal to "2".

On VIEWS.py I have:

```<code>class GetPersonalEntranteRegistro_EntradaAPIView(generics.ListAPIView):
    serializer_class = Registro_EntradaNestedSerializer
    def get_queryset(self):
        entrante = Entrante.objects.all().filter(fk_tipo_entrante=2)
        registro = Registro_Entrada.objects.filter(fk_entrante = entrante.pk)
        return registro
</code>```

On SERIALIZERS.py I have:

```<code>class Registro_EntradaNestedSerializer(serializers.ModelSerializer):
    fk_tarifa = TarifaSerializer(many=False)
    fk_entrante = EntranteNestedSerializer(many=False)
    class Meta:
        model = Registro_Entrada
        fields = ('_all_')
</code>```

On MODELS.py I have:

```<code>class Entrante(models.Model):
    fk_credencial = models.ForeignKey(Credencial,related_name='credencial_entrada',on_delete=models.CASCADE)
    fk_placa = models.ForeignKey(Placa, related_name='credencial_placa',on_delete=models.CASCADE)
    fk_tipo_entrante = models.ForeignKey(Tipo_Entrante,related_name='entrante_tipo',on_delete=models.CASCADE)
    fk_persona = models.ForeignKey(Persona,related_name='entrante_persona',on_delete=models.CASCADE)
    estatus = models.IntegerField(default=1)

class Registro_Entrada(models.Model):
    fecha_entrada = models.DateTimeField(auto_now_add=True)
    fecha_salida = models.DateTimeField(null=True)
    fk_tarifa = models.ForeignKey(Tarifa,related_name='registro_tarifa',on_delete=models.CASCADE)
    fk_entrante = models.ForeignKey(Entrante,related_name='regitro_entrante',on_delete=models.CASCADE)
    costo = models.DecimalField(decimal_places=2, max_digits=50)
    saldo = models.DecimalField(decimal_places=2,max_digits=50)
    estatus = models.IntegerField(default=1)
</code>```

It shows the following error:

'QuerySet' object has no attribute 'pk'

答:
if you need to filter by many pk form first query you can try use __in without pk:

```<code>entrante = Entrante.objects.filter(fk_tipo_entrante=2)
registro = Registro_Entrada.objects.filter(fk_entrante__in=entrante)
#                                                    ^^^^        ^^^
</code>```

read more details django in

Title: django rest framework nested filter

Body:
I want to get all the "Registro_Entrada" and filter them by "Entrante" when "fk_tipo_entrante" is equal to "2".

On VIEWS.py I have:

class GetPersonalEntranteRegistro_EntradaAPIView(generics.ListAPIView):
    serializer_class = Registro_EntradaNestedSerializer
    def get_queryset(self):
        entrante = Entrante.objects.all().filter(fk_tipo_entrante=2)
        registro = Registro_Entrada.objects.filter(fk_entrante = entrante.pk)
        return registro

On SERIALIZERS.py I have:

class Registro_EntradaNestedSerializer(serializers.ModelSerializer):
    fk_tarifa = TarifaSerializer(many=False)
    fk_entrante = EntranteNestedSerializer(many=False)
    class Meta:
        model = Registro_Entrada
        fields = ('_all_')

On MODELS.py I have:

class Entrante(models.Model):
    fk_credencial = models.ForeignKey(Credencial,related_name='credencial_entrada',on_delete=models.CASCADE)
    fk_placa = models.ForeignKey(Placa, related_name='credencial_placa',on_delete=models.CASCADE)
    fk_tipo_entrante = models.ForeignKey(Tipo_Entrante,related_name='entrante_tipo',on_delete=models.CASCADE)
    fk_persona = models.ForeignKey(Persona,related_name='entrante_persona',on_delete=models.CASCADE)
    estatus = models.IntegerField(default=1)

class Registro_Entrada(models.Model):
    fecha_entrada = models.DateTimeField(auto_now_add=True)
    fecha_salida = models.DateTimeField(null=True)
    fk_tarifa = models.ForeignKey(Tarifa,related_name='registro_tarifa',on_delete=models.CASCADE)
    fk_entrante = models.ForeignKey(Entrante,related_name='regitro_entrante',on_delete=models.CASCADE)
    costo = models.DecimalField(decimal_places=2, max_digits=50)
    saldo = models.DecimalField(decimal_places=2,max_digits=50)
    estatus = models.IntegerField(default=1)

It shows the following error:

'QuerySet' object has no attribute 'pk'

Body:
if you need to filter by many pk form first query you can try use __in without pk:

entrante = Entrante.objects.filter(fk_tipo_entrante=2)
registro = Registro_Entrada.objects.filter(fk_entrante__in=entrante)
#                                                    ^^^^        ^^^

read more details django in


问:
Integrate Tfs Service Hook with Jeknins: Pass branch name dynamically to Jenkins Job
I am trying to compile code in Jenkins, when pushing code to TFS, and
passing the branch name dynamically.

I am using the TFS Hook, and i couldn't find how to pass the branch name
though the http Get call to Jenkins.

Any idea how to make it happen ?

thanks,
Eran.

Above is the TFS Service Hook, where i am trying to pass the branch name dynamically to Jenkins.

答:
It's not able to pass the branch name in TFS  dynamically. When you set the Trigger of the event type--code pushed, there will be filters of branch. You have to select the branch here.

Branch: The branch that code was pushed into

If you want the branch in TFS repo to be dynamically pushed,  you could set the branch value= any as a workaround.


答:
If there is an exception in SyncCustomers() you will call SyncCustomers.

As far as good.

Let's pretend that your second run is good and would return True (at return IsSyncSuccess;)

And here is the problem, you are not catching the return statement in your exception handling - the True is getting lost in the catch block.

Instead of recursively calling the method, may try a while loop to get the synchronization work, no matter if there is an exception or not.

```<code>int SyncFailCount = 0;
private bool SyncCustomers(long TenantId, DataTable dtCusomers)
{
    bool IsSyncSuccess = false;

    // While there is no success do the loop
    while (!IsSyncSuccess)
    {
        try
        {
            SyncQBClient client = new SyncQBClient();
            client.SynvCustomer(TenantId, dtCusomers);
            SyncFailCount = 0;
            IsSyncSuccess = true;
        }
        catch (CommunicationException comEx) // Mohan: Exception due to Internet issue
        {
            SyncFailCount = SyncFailCount + 1;
            Thread.Sleep(300);
        }
        catch (TimeoutException TimeoutEx) // Mohan: Exception due to timeout from web service
        {
            SyncFailCount = SyncFailCount + 1;
            Thread.Sleep(300);
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message, "CashPundit", MessageBoxButtons.OK, MessageBoxIcon.Error);
            SyncFailCount = 0;
            break;
        }

        // If there are more than 5 Sync Fails, break the loop and return false
        if (SyncFailCount > 5)
        {
            SyncFailCount = 0;
            break;
        }
    }

    return IsSyncSuccess;
}
</code>```

Title: why Catch block is executing after return statement in C#

Body:
If there is an exception in SyncCustomers() you will call SyncCustomers.

As far as good.

Let's pretend that your second run is good and would return True (at return IsSyncSuccess;)

And here is the problem, you are not catching the return statement in your exception handling - the True is getting lost in the catch block.

Instead of recursively calling the method, may try a while loop to get the synchronization work, no matter if there is an exception or not.

int SyncFailCount = 0;
private bool SyncCustomers(long TenantId, DataTable dtCusomers)
{
    bool IsSyncSuccess = false;

    // While there is no success do the loop
    while (!IsSyncSuccess)
    {
        try
        {
            SyncQBClient client = new SyncQBClient();
            client.SynvCustomer(TenantId, dtCusomers);
            SyncFailCount = 0;
            IsSyncSuccess = true;
        }
        catch (CommunicationException comEx) // Mohan: Exception due to Internet issue
        {
            SyncFailCount = SyncFailCount + 1;
            Thread.Sleep(300);
        }
        catch (TimeoutException TimeoutEx) // Mohan: Exception due to timeout from web service
        {
            SyncFailCount = SyncFailCount + 1;
            Thread.Sleep(300);
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message, "CashPundit", MessageBoxButtons.OK, MessageBoxIcon.Error);
            SyncFailCount = 0;
            break;
        }

        // If there are more than 5 Sync Fails, break the loop and return false
        if (SyncFailCount > 5)
        {
            SyncFailCount = 0;
            break;
        }
    }

    return IsSyncSuccess;
}


问:
C++ class definition
I've run across a class defined as follows:

```<code>class SYS_LIB_API Version
{
public:
somefunctions()
...
}
</code>```

I don't understand the class SYS_LIB_API Version line. I'm used to seeing:

```<code>class Version
{
public:
somefunctions()
...
}
</code>```

答: SYS_LIB_API is undoubtedly a macro, but I couldn't tell you what it does unless I had access to the same code.</p>

Title: C++ class definition

Body:
I've run across a class defined as follows:

class SYS_LIB_API Version
{
public:
somefunctions()
...
}

I don't understand the class SYS_LIB_API Version line. I'm used to seeing:

class Version
{
public:
somefunctions()
...
}


答:
add this line at the end of each catch Block</p>

```<code>return IsSyncSuccess;
</code>```

Body:
add this line at the end of each catch Block

return IsSyncSuccess;


问:
How can I create a circle profile picture view over rectangle in android layout?

How to draw the attached layout which is have circle over rectangle.
mean that circle is profile image, and inside the rectangle login information layout. Can any one please suggest this?

答:
Here Xml code,</p>

```<code>   <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

            <com.mylibrary.widgets.CircularImageView
                android:id="@+id/profile_profileimg"
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="10dp"
                android:src="@drawable/no_user_image" />

  </RelativeLayout>
</code>```

Body:
Here Xml code,

   <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

            <com.mylibrary.widgets.CircularImageView
                android:id="@+id/profile_profileimg"
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="10dp"
                android:src="@drawable/no_user_image" />

  </RelativeLayout>


问:
MSBuild AfterBuild messages not showing real-time
I have something like the following in the .csproj file for an ASP.NET MVC 4 project in Visual Studio 2012:

```<code><Target Name="AfterBuild">
  <CallTarget Targets="InstallBuildDependencies" />
  <CallTarget Targets="BuildAssets" />
</Target>
<Target Name="InstallBuildDependencies">
  <Message Text="Installing build dependencies:" Importance="high" />
  <Exec Command="npm install" />
</Target>
  <Target Name="BuildAssets">
  <Message Text="Building assets:" Importance="high" />
  <Exec Command="grunt build" />
</Target>
</code>```

and something like this in a .pubmxl for the same project:

```<code>  <PropertyGroup>
    <!-- Other properties here -->
    <InstallBuildDependenciesCmd>npm install</InstallBuildDependenciesCmd>
    <BuildDistAssetsCmd>grunt dist</BuildDistAssetsCmd>
    <PipelineDependsOn>
      InstallBuildDependencies;
      BuildDistAssets;
    </PipelineDependsOn>
  </PropertyGroup>
  <Target Name="InstallBuildDependencies">
    <Message Text="Installing build dependencies:" Importance="high" />
    <Exec Command="$(InstallBuildDependenciesCmd)" />
  </Target>
  <Target Name="BuildDistAssets" AfterTargets="InstallBuildDependencies">
    <Message Text="Building distribution assets:" Importance="high" />
    <Exec Command="$(BuildDistAssetsCmd)" />
  </Target>
</code>```

The issue is that, in the first snippet, none of the messages or output from the commands displays in the Ouput console in Visual Studio until everything in the build has finished. This is not ideal since it would be better to see the messages and command output in "real-time".

In the second snippet, both the messages and command output DO show in "real-time" in the Output console.

Is it possible to get the messages from the first first snippet to display in real-time like the messages in the second snippet do? Why am I experiencing this inconsistency?

答:
Super late answer, but recently stumbled with this same issue.
It seems that this is not possible, according to the Exec Task documentation in the Remarks section:

However, the Exec task, unlike a more specific task, cannot gather output from the tool or command that it runs.

Hope this saves some time for anyone else.

Body:
I have something like the following in the .csproj file for an ASP.NET MVC 4 project in Visual Studio 2012:

<Target Name="AfterBuild">
  <CallTarget Targets="InstallBuildDependencies" />
  <CallTarget Targets="BuildAssets" />
</Target>
<Target Name="InstallBuildDependencies">
  <Message Text="Installing build dependencies:" Importance="high" />
  <Exec Command="npm install" />
</Target>
  <Target Name="BuildAssets">
  <Message Text="Building assets:" Importance="high" />
  <Exec Command="grunt build" />
</Target>

and something like this in a .pubmxl for the same project:

  <PropertyGroup>

    <InstallBuildDependenciesCmd>npm install</InstallBuildDependenciesCmd>
    <BuildDistAssetsCmd>grunt dist</BuildDistAssetsCmd>
    <PipelineDependsOn>
      InstallBuildDependencies;
      BuildDistAssets;
    </PipelineDependsOn>
  </PropertyGroup>
  <Target Name="InstallBuildDependencies">
    <Message Text="Installing build dependencies:" Importance="high" />
    <Exec Command="$(InstallBuildDependenciesCmd)" />
  </Target>
  <Target Name="BuildDistAssets" AfterTargets="InstallBuildDependencies">
    <Message Text="Building distribution assets:" Importance="high" />
    <Exec Command="$(BuildDistAssetsCmd)" />
  </Target>

The issue is that, in the first snippet, none of the messages or output from the commands displays in the Ouput console in Visual Studio until everything in the build has finished. This is not ideal since it would be better to see the messages and command output in "real-time".

In the second snippet, both the messages and command output DO show in "real-time" in the Output console.

Is it possible to get the messages from the first first snippet to display in real-time like the messages in the second snippet do? Why am I experiencing this inconsistency?


问:
JavaFX 8: Intercepting appication "exit"
In order to verify that all changes made by the user have been saved I want to intercept the exiting/quitting of a JavaFX application.

Is there a common way-to-go to achieve this like overriding an event or is there more to it?

答: In the class Application there is the stop method which you can override possibly.</p>


问:
React Application. Submit button is only returning "type" and not the actual value submitted to it
I want this application to be able to add a new animal object but when i console.log to see the output of my handle submit function it returns the string "type". Ive narrowed down the bug to be in my map method that returns the animal type: value='type'>{type}
but im unsure what to replace here to get the desired output of whats submitted</p>

```<code>handleSubmit(e) {
    console.log(this.refs.type.value)
    e.preventDefault()
}

render() {
let typeOptions = this.props.types.map(type => {
    return (<option key={type} value='type'>{type}</option>)
})
 return (
   <div>
     <h3>Add an Animal</h3>
     <form onSubmit={this.handleSubmit.bind(this)}>
         <div>
             <label>Species</label><br />
             <input type='text' ref='species' />
        </div>
        <div>
             <label>Type</label><br />
             <select ref="type" >
                {typeOptions}
             </select>
        </div>
        <input type='submit' value='submit' />
    </form>
 </div>
</code>```

答:
```<code>return (<option key={type} value='type'>{type}</option>)
                ^^ 1       ^^ 2          ^^ 3
</code>```

What is this key attribute? It does not exist in HTML. Get rid of it

Look here. You have set the value to be the hard-coded string 'type'. Don't do that. Use a variable.

Here you've used a variable. Do the same thing for the value attribute.

Body:
I want this application to be able to add a new animal object but when i console.log to see the output of my handle submit function it returns the string "type". Ive narrowed down the bug to be in my map method that returns the animal type: value='type'>{type}
but im unsure what to replace here to get the desired output of whats submitted

handleSubmit(e) {
    console.log(this.refs.type.value)
    e.preventDefault()
}

render() {
let typeOptions = this.props.types.map(type => {
    return (<option key={type} value='type'>{type}</option>)
})
 return (

Add an Animal

     <form onSubmit={this.handleSubmit.bind(this)}>

             Species

             <input type='text' ref='species' />

             Type

             <select ref="type" >
                {typeOptions}
             </select>

        <input type='submit' value='submit' />
    </form>

Body:
return (<option key={type} value='type'>{type}</option>)
                ^^ 1       ^^ 2          ^^ 3

What is this key attribute? It does not exist in HTML. Get rid of it

Look here. You have set the value to be the hard-coded string 'type'. Don't do that. Use a variable.

Here you've used a variable. Do the same thing for the value attribute.


问:
Array.prototype.includes - not transformed with babel
I cannot figure out how to get this code to transform to compatible code in Node.js v4 env: [].includes('anything')

Becuase this throws an error in Node.js v4 Error: includes is not a function...

Can anyone help me understand why babel does not transform .includes()? I have tried using babel-preset-es2015 and babel-preset-es2016 as well as the babel repl: Example babel repl code usage

答:
You need to import babel-polyfill to use static methods like Array.from or Object.assign, instance methods like Array.prototype.includes.

If you don't want to modify globals, checkout the transform-runtime plugin. This means you won't be able to use the instance methods mentioned above like Array.prototype.includes.