问:
same command using exec giving different output
I am migrating from one server to another and see that the same exec command gives different output. I am not sure what i need to check and ensure so that i see consistent output

```<code>Example of the command that is executed:

java -jar /var/www/html/PhpTikaWrapper-master/vendor/tika-app-1.5.jar -m one.jpg
</code>```

1) Server 1(This is what i want)

```<code>Array
(
    [0] => Chroma BlackIsZero: true
    [1] => Chroma ColorSpaceType: RGB
    [2] => Chroma NumChannels: 4
    [3] => Compression CompressionTypeName: deflate
    [4] => Compression Lossless: true
    [5] => Compression NumProgressiveScans: 1
    [6] => Content-Length: 9371
    [7] => Content-Type: image/png
    [8] => Data BitsPerSample: 8 8 8 8
    [9] => Data PlanarConfiguration: PixelInterleaved
    [10] => Data SampleFormat: UnsignedIntegral
    [11] => Dimension ImageOrientation: Normal
    [12] => Dimension PixelAspectRatio: 1.0
    [13] => IHDR: width=150, height=75, bitDepth=8, colorType=RGBAlpha, compressionMethod=deflate, filterMethod=adaptive, interlaceMethod=none
    [14] => Text TextEntry: keyword=Software, value=Adobe ImageReady, encoding=ISO-8859-1, compression=none
    [15] => Transparency Alpha: nonpremultipled
    [16] => height: 75
    [17] => resourceName: Orca-logo.png
    [18] => tEXt tEXtEntry: keyword=Software, value=Adobe ImageReady
    [19] => tiff:BitsPerSample: 8 8 8 8
    [20] => tiff:ImageLength: 75
    [21] => tiff:ImageWidth: 150
    [22] => width: 150
)
</code>```

Server 2(This is what i am getting in new server):

```<code>Array
(
    [0] => Comments: Lavc56.5.100
    [1] => Component 1: Y component: Quantization table 0, Sampling factors 2 horiz/2 vert
    [2] => Component 2: Cb component: Quantization table 0, Sampling factors 1 horiz/1 vert
    [3] => Component 3: Cr component: Quantization table 0, Sampling factors 1 horiz/1 vert
    [4] => Compression Type: Baseline
    [5] => Content-Length: 25259
    [6] => Content-Type: image/jpeg
    [7] => Data Precision: 8 bits
    [8] => Image Height: 840 pixels
    [9] => Image Width: 840 pixels
    [10] => Jpeg Comment: Lavc56.5.100
    [11] => Number of Components: 3
    [12] => Resolution Units: none
    [13] => X Resolution: 1 dot
    [14] => Y Resolution: 1 dot
    [15] => comment: Lavc56.5.100
    [16] => resourceName: ankita2_comp.jpg
    [17] => tiff:BitsPerSample: 8
    [18] => tiff:ImageLength: 840
    [19] => tiff:ImageWidth: 840
    [20] => w:comments: Lavc56.5.100
)
</code>```

Java version on both server is same and as follows

```<code>java version "1.7.0_141"
OpenJDK Runtime Environment (rhel-2.6.10.1.el6_9-x86_64 u141-b02)
OpenJDK 64-Bit Server VM (build 24.141-b02, mixed mode)
</code>```

Also, the command does not return width on the new server.

Any help would be appreciated. Thanks.

答:
I have identified the issue, actually apache tikka provide different format of response for different file type provided.

For JPEG we will get a different response and for png we will get a different response as i was getting above.

Hope this saves someones time in future.

Body:
I am migrating from one server to another and see that the same exec command gives different output. I am not sure what i need to check and ensure so that i see consistent output

Example of the command that is executed:

java -jar /var/www/html/PhpTikaWrapper-master/vendor/tika-app-1.5.jar -m one.jpg

1) Server 1(This is what i want)

Array
(
    [0] => Chroma BlackIsZero: true
    [1] => Chroma ColorSpaceType: RGB
    [2] => Chroma NumChannels: 4
    [3] => Compression CompressionTypeName: deflate
    [4] => Compression Lossless: true
    [5] => Compression NumProgressiveScans: 1
    [6] => Content-Length: 9371
    [7] => Content-Type: image/png
    [8] => Data BitsPerSample: 8 8 8 8
    [9] => Data PlanarConfiguration: PixelInterleaved
    [10] => Data SampleFormat: UnsignedIntegral
    [11] => Dimension ImageOrientation: Normal
    [12] => Dimension PixelAspectRatio: 1.0
    [13] => IHDR: width=150, height=75, bitDepth=8, colorType=RGBAlpha, compressionMethod=deflate, filterMethod=adaptive, interlaceMethod=none
    [14] => Text TextEntry: keyword=Software, value=Adobe ImageReady, encoding=ISO-8859-1, compression=none
    [15] => Transparency Alpha: nonpremultipled
    [16] => height: 75
    [17] => resourceName: Orca-logo.png
    [18] => tEXt tEXtEntry: keyword=Software, value=Adobe ImageReady
    [19] => tiff:BitsPerSample: 8 8 8 8
    [20] => tiff:ImageLength: 75
    [21] => tiff:ImageWidth: 150
    [22] => width: 150
)

Server 2(This is what i am getting in new server):

Array
(
    [0] => Comments: Lavc56.5.100
    [1] => Component 1: Y component: Quantization table 0, Sampling factors 2 horiz/2 vert
    [2] => Component 2: Cb component: Quantization table 0, Sampling factors 1 horiz/1 vert
    [3] => Component 3: Cr component: Quantization table 0, Sampling factors 1 horiz/1 vert
    [4] => Compression Type: Baseline
    [5] => Content-Length: 25259
    [6] => Content-Type: image/jpeg
    [7] => Data Precision: 8 bits
    [8] => Image Height: 840 pixels
    [9] => Image Width: 840 pixels
    [10] => Jpeg Comment: Lavc56.5.100
    [11] => Number of Components: 3
    [12] => Resolution Units: none
    [13] => X Resolution: 1 dot
    [14] => Y Resolution: 1 dot
    [15] => comment: Lavc56.5.100
    [16] => resourceName: ankita2_comp.jpg
    [17] => tiff:BitsPerSample: 8
    [18] => tiff:ImageLength: 840
    [19] => tiff:ImageWidth: 840
    [20] => w:comments: Lavc56.5.100
)

Java version on both server is same and as follows

java version "1.7.0_141"
OpenJDK Runtime Environment (rhel-2.6.10.1.el6_9-x86_64 u141-b02)
OpenJDK 64-Bit Server VM (build 24.141-b02, mixed mode)

Also, the command does not return width on the new server.

Any help would be appreciated. Thanks.


来源: stackexchange

问:
Can I force an iPhone user to upgrade an application?
Is it possible to force the user to upgrade once there is a new version of my application available in the iTunes Store?

I am presently working on an application. However, I want to force the upgrade whenever I upload a newer version, because the upgrade will have more features and I want to discard the previous version. Is this possible by default with iPhone or do I have to write my own implementation to check the current version and compare it to the store?

答:
You can use below url to get the information of any app
You just know your Apple ID of your app.

You can get this Apple ID in the itunesconnect.com>your app>app information page

GET: http://itunes.apple.com/lookup?id=

ContentLicense: CC BY-SA 2.5

ContentLicense: CC BY-SA 3.0


问:
How to do multiple pattern check with awk regExp and print in excel format
I have a log file which contains millions line like this:

10.0.7.92 - - [05/Jun/2017:03:50:06 +0000] "GET /adserver/html5/inwapads/?category=[IAB]&size=320x280&ak=AY1234&output=vast&version=1.1&sleepAfter=&requester=John&adFormat=preappvideo HTTP/1.1" 200 131 "-" "Mozilla/5.0 (Linux; Android 6.0.1; SM-S120VL Build/MMB29M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/58.0.3029.83 Mobile Safari/537.36" 0.000 1029 520 127.0.0.1

10.0.6.91 - - [05/Jun/2017:03:50:06 +0000] "GET /adserver/html5/inwapads/?category=[IAB]&output=vast&version=1.1&sleepAfter=&requester=John&size=320x280&ak=AY1234&adFormat=preappvideo HTTP/1.1" 200 131 "-" "Mozilla/5.0 (Linux; Android 6.0.1; SM-S120VL Build/MMB29M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/58.0.3029.83 Mobile Safari/537.36" 0.000 1029 520 127.0.0.1

I want print output of every line like this in excel with different columns:

```<code>inwapads    AY1234  john    320x280
</code>```

How to do that use awk or do I need to use another method.

答:
You use sed hold pattern like this:</p>

```<code>$ sed 's/.*html5\/\(.*\)\/?category.*size=\(.*\)\&ak=\(.*\)\&output.*\.*requester=\(.*\)\&adFormat.*/\1 \3 \4 \2/' inputfile
inwapads AY1234 John 320x280
</code>```

Body:
I have a log file which contains millions line like this:

10.0.7.92 - - [05/Jun/2017:03:50:06 +0000] "GET /adserver/html5/inwapads/?category=[IAB]&size=320x280&ak=AY1234&output=vast&version=1.1&sleepAfter=&requester=John&adFormat=preappvideo HTTP/1.1" 200 131 "-" "Mozilla/5.0 (Linux; Android 6.0.1; SM-S120VL Build/MMB29M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/58.0.3029.83 Mobile Safari/537.36" 0.000 1029 520 127.0.0.1

10.0.6.91 - - [05/Jun/2017:03:50:06 +0000] "GET /adserver/html5/inwapads/?category=[IAB]&output=vast&version=1.1&sleepAfter=&requester=John&size=320x280&ak=AY1234&adFormat=preappvideo HTTP/1.1" 200 131 "-" "Mozilla/5.0 (Linux; Android 6.0.1; SM-S120VL Build/MMB29M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/58.0.3029.83 Mobile Safari/537.36" 0.000 1029 520 127.0.0.1

I want print output of every line like this in excel with different columns:

inwapads    AY1234  john    320x280

How to do that use awk or do I need to use another method.

Body:
You use sed hold pattern like this:

$ sed 's/.*html5\/\(.*\)\/?category.*size=\(.*\)\&ak=\(.*\)\&output.*\.*requester=\(.*\)\&adFormat.*/\1 \3 \4 \2/' inputfile
inwapads AY1234 John 320x280


问:
Using MSBuild with Hudson?
I am building a CI Server using Hudson to deploy .NET applications.  My problem is that it keeps throwing the error:

```<code>error MSB4019: The imported project
"C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications
\Microsoft.WebApplication.targets" was not found. Confirm that the path
 in the <Import> declaration is correct, and that the file exists on disk.
</code>```

Do I need to have VisualStudio installed on my CI server?

答:
Annoyingly this Microsoft.WebApplication.targets file is only shipped with Visual Studio and not with the plain .NET SDK.

In principle it should be possible to take a working Visual Studio install and copy this file,  However, it doesn't appear to be as straightforward as copying one file. As you copy more and more stuff, you wonder where you cross the line from 'patching your SDK installation' to 're-creating the Visual Studio install' (and therefore requiring another licence).

In summary, installing Visual Studio appears to be the only way to build projects that need Microsoft.WebApplication.targets. Non-web projects work OK.

Title: Using MSBuild with Hudson?

Body:
I am building a CI Server using Hudson to deploy .NET applications.  My problem is that it keeps throwing the error:

error MSB4019: The imported project
"C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications
\Microsoft.WebApplication.targets" was not found. Confirm that the path
 in the <Import> declaration is correct, and that the file exists on disk.

Do I need to have VisualStudio installed on my CI server?


问:
Storing birthday in database, what type to use if there's missing values
I am collecting sports data for a database I will be creating soon, and one of the columns I have for one of my tables is player birthdays. I am using R to scrape and collect the data, and here is what it currently looks like:

```<code>head(my_df)

        Name        BirthDate     Age                 Place  Height  Weight
1       Mike                       NA                            NA      NA
2     Austin  August 17, 1994  22.295 Roseville, California      73     210
3       Koby January 19, 1997  20.140      Wolfforth, Texas      70     255
4         Ty             1991  26.000       Amarillo, Texas      70     165
5       Cole                       NA                            NA      NA
6       Jeff    July 24, 1995  21.320     Boulder, Colorado      72     200

dput(head(my_df))
structure(list(Name = c("Mike", "Austin", "Koby", "Ty", "Cole",
"Jeff"), BirthDate = c("", "August 17, 1994", "January 19, 1997",
"1991", "", "July 24, 1995"), Age = c(NA, 22.295, 20.14, 26,
NA, 21.32), Place = c("", "Roseville, California", "Wolfforth, Texas",
"Amarillo, Texas", "", "Boulder, Colorado"), Height = c(NA, 73,
70, 70, NA, 72), Weight = c(NA, 210L, 255L, 165L, NA, 200L)), .Names = c("Name",
"BirthDate", "Age", "Place", "Height", "Weight"), row.names = 25:30, class = "data.frame")
</code>```

The BirthDate column has two inconsistencies that make appropriate formatting difficult:

there are entirely missing values

for some columns, I have the birthyear but am missing Day and Month.

I'm relatively new with databases and am trying to plan ahead with this. Does anybody have any thoughts on the best way to handle this? To be more specific, how can I write the R code to format the column the right way?

答:
Not a complete answer but a direction to try...
Genealogy databases, which have similar problems, will often have an extra column (a sort of meta-date column) that expresses confidence in, or quality of, the birth-date column. This can then be used at query-time to mediate the results returned. Could be "estimated", "not given", "year only" to suit your app.</p>

Body:
I am collecting sports data for a database I will be creating soon, and one of the columns I have for one of my tables is player birthdays. I am using R to scrape and collect the data, and here is what it currently looks like:

head(my_df)

        Name        BirthDate     Age                 Place  Height  Weight
1       Mike                       NA                            NA      NA
2     Austin  August 17, 1994  22.295 Roseville, California      73     210
3       Koby January 19, 1997  20.140      Wolfforth, Texas      70     255
4         Ty             1991  26.000       Amarillo, Texas      70     165
5       Cole                       NA                            NA      NA
6       Jeff    July 24, 1995  21.320     Boulder, Colorado      72     200

dput(head(my_df))
structure(list(Name = c("Mike", "Austin", "Koby", "Ty", "Cole",
"Jeff"), BirthDate = c("", "August 17, 1994", "January 19, 1997",
"1991", "", "July 24, 1995"), Age = c(NA, 22.295, 20.14, 26,
NA, 21.32), Place = c("", "Roseville, California", "Wolfforth, Texas",
"Amarillo, Texas", "", "Boulder, Colorado"), Height = c(NA, 73,
70, 70, NA, 72), Weight = c(NA, 210L, 255L, 165L, NA, 200L)), .Names = c("Name",
"BirthDate", "Age", "Place", "Height", "Weight"), row.names = 25:30, class = "data.frame")

The BirthDate column has two inconsistencies that make appropriate formatting difficult:

there are entirely missing values

for some columns, I have the birthyear but am missing Day and Month.

I'm relatively new with databases and am trying to plan ahead with this. Does anybody have any thoughts on the best way to handle this? To be more specific, how can I write the R code to format the column the right way?


问:
Function with variable parameter type
I have these two functions which are basically the same:

```<code>private Order getOrder( List<Order> orders, String gcsId )
{
    Predicate<Order> predicate = c -> c.getGcsId().equals( gcsId );
    Order obj = orders.stream().filter( predicate ).findFirst().get();
    return obj;
}

private OrderLine getOrderLine( List<OrderLine> orderLines, String gcsId )
{
    Predicate<OrderLine> predicate = c -> c.getGcsId().equals( gcsId );
    OrderLine obj = orderLines.stream().filter( predicate ).findFirst().get();
    return obj;
}
</code>```

The only difference is the type of the first parameter. How can I create a single function with the first parameter having a variable type?

Edit: This is how I call those functions in another method of the same class:

```<code>Order order = getOrder( orders, orderId );
OrderLine orderLine = getOrderLine( order.getOrderLines(), orderLineId );
</code>```

答:
First you should create an interface like that and your classes should implement this interface:

```<code>public interface IOrder {

   String getGcsId();
}

public class Order implements IOrder {
  // Content of your class
}

public class OrderLine implements IOrder {
  // Content of your class
}
</code>```

After that you can write your method like that using generics:

```<code>private <T extends IOrder> T getOrder( List<T> orders, String gcsId )
{
    Predicate<T> predicate = c -> c.getGcsId().equals( gcsId );
    T obj = orders.stream().filter( predicate ).findFirst().get();
    return obj;
}
</code>```

Title: Function with variable parameter type

Body:
I have these two functions which are basically the same:

private Order getOrder( List<Order> orders, String gcsId )
{
    Predicate<Order> predicate = c -> c.getGcsId().equals( gcsId );
    Order obj = orders.stream().filter( predicate ).findFirst().get();
    return obj;
}

private OrderLine getOrderLine( List<OrderLine> orderLines, String gcsId )
{
    Predicate<OrderLine> predicate = c -> c.getGcsId().equals( gcsId );
    OrderLine obj = orderLines.stream().filter( predicate ).findFirst().get();
    return obj;
}

The only difference is the type of the first parameter. How can I create a single function with the first parameter having a variable type?

Edit: This is how I call those functions in another method of the same class:

Order order = getOrder( orders, orderId );
OrderLine orderLine = getOrderLine( order.getOrderLines(), orderLineId );

Body:
First you should create an interface like that and your classes should implement this interface:

public interface IOrder {

   String getGcsId();
}

public class Order implements IOrder {
  // Content of your class
}

public class OrderLine implements IOrder {
  // Content of your class
}

After that you can write your method like that using generics:

private <T extends IOrder> T getOrder( List<T> orders, String gcsId )
{
    Predicate<T> predicate = c -> c.getGcsId().equals( gcsId );
    T obj = orders.stream().filter( predicate ).findFirst().get();
    return obj;
}


问:
How can i get the Cell address from excel
How can i get the Cell address from excel given a row and column number for example

row 2 and col 3 should return C2... Please help

答:
I'm using zero-based row and column index. So I had to adapt the code of prior answers to the following.
It took some trial and error to get this right for all possible addresses i.E. A1, Z2, AA2, ZZ10, ...</p>

```<code>    public string GetAddress(int col, int row)
    {
        col++;
        StringBuilder sb = new StringBuilder();
        do
        {
            col--;
            sb.Insert(0, (char)('A' + (col % 26)));
            col /= 26;

        } while (col > 0);
        sb.Append(row + 1);
        return sb.ToString();
    }
</code>```

Body:
I'm using zero-based row and column index. So I had to adapt the code of prior answers to the following.
It took some trial and error to get this right for all possible addresses i.E. A1, Z2, AA2, ZZ10, ...

    public string GetAddress(int col, int row)
    {
        col++;
        StringBuilder sb = new StringBuilder();
        do
        {
            col--;
            sb.Insert(0, (char)('A' + (col % 26)));
            col /= 26;

        } while (col > 0);
        sb.Append(row + 1);
        return sb.ToString();
    }


问:
sorting the xmlElement by the child value with sort attribute value provided by User

<root>
 <SectionItem>
   <Cell columnid="1" InSeconds="1496761802">06/06/2017  03:10:02 PM</Cell>
   <Cell columnid="2"> Error</Cell>
   <Cell columnid="3"> abc</Cell>
   <Cell columnid="4">  None</Cell>
   <Cell columnid="5">  1 </Cell>
   <Cell columnid="6"> N/A</Cell>
   <Cell columnid="7"> efg</Cell>
  </SectionItem>
  <SectionItem>
   <Cell columnid="1" InSeconds="1496743990">06/06/2017  10:13:10 AM</Cell>
   <Cell columnid="2"> Error</Cell>3
   <Cell columnid="3"> o</Cell>
   <Cell columnid="4"> None</Cell>
   <Cell columnid="5"> 1 </Cell>
   <Cell columnid="6">  N/A </Cell>
   <Cell columnid="7"> ice age</Cell>
  </SectionItem>
  <SectionItem>
   <Cell columnid="1" InSeconds="1496227357">31/05/2017  10:42:37 AM</Cell>
   <Cell columnid="2"> Error</Cell>
   <Cell columnid="3">  Microsoft-Windows-CAPI2</Cell>
   <Cell columnid="4">  N/A</Cell>
   <Cell columnid="5"> 513</Cell>
   <Cell columnid="6"> N/A</Cell>
   <Cell columnid="7">Access is denied.. </Cell>
  </SectionItem>
  <SectionItem>
   <Cell columnid="1" InSeconds="1495568786">23/05/2017  07:46:26 PM</Cell>
   <Cell columnid="2"> Error</Cell>
   <Cell columnid="3"> Microsoft-Windows-Immersive-Shell</Cell>
   <Cell columnid="4">  N/A</Cell>
   <Cell columnid="5">2484</Cell>
   <Cell columnid="6">SR</Cell>
   <Cell columnid="7">hello</Cell>
  </SectionItem>
  <SectionItem>
   <Cell columnid="1" InSeconds="1495568789">23/05/2017  07:46:29 PM</Cell>
   <Cell columnid="2">Error</Cell>
   <Cell columnid="3"> Application Hang </Cell>
   <Cell columnid="4"> N/A</Cell>
   <Cell columnid="5">1002</Cell>
   <Cell columnid="6"> N/A</Cell>
   <Cell columnid="7"> here is a error</Cell>
  </SectionItem>
  <SectionItem>
   <Cell columnid="1" InSeconds="1495568740">23/05/2017  07:45:40 PM</Cell>
   <Cell columnid="2"> Error</Cell>
   <Cell columnid="3"> Application Error</Cell>
   <Cell columnid="4"> Application Crashing Events</Cell>
   <Cell columnid="5">1000</Cell>
   <Cell columnid="6"> N/A</Cell>
   <Cell columnid="7"> error number 3</Cell>
  </SectionItem>
</root>```
</div>
</div>
</p>

<p>If i want to sort the sectionItem element base on Cell element value of the Cell attribute columnID giving by user, how can i approach this? Thank you in advance.</p>

<p>e.g. if user give colunid "1", then we want to sort the sectionItem base on the value of Cell with columnid="1".
if user give colunid "3", then we want to sort the sectionItem base on the value of Cell with columnid="3".</p>

<p>Hope that will make the question easier to understand as i am having difficulty putting the question together.</p>

<p>If i am sorting  with columnid="3"</p>

<p>i should get the the below output:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><root>
 <SectionItem>
   <Cell columnid="1" InSeconds="1496761802">06/06/2017  03:10:02 PM</Cell>
   <Cell columnid="2"> Error</Cell>
   <Cell columnid="3"> abc</Cell>
   <Cell columnid="4">  None</Cell>
   <Cell columnid="5">  1 </Cell>
   <Cell columnid="6"> N/A</Cell>
   <Cell columnid="7"> efg</Cell>
  </SectionItem>
  <SectionItem>
   <Cell columnid="1" InSeconds="1495568740">23/05/2017  07:45:40 PM</Cell>
   <Cell columnid="2"> Error</Cell>
   <Cell columnid="3"> Application Error</Cell>
   <Cell columnid="4"> Application Crashing Events</Cell>
   <Cell columnid="5">1000</Cell>
   <Cell columnid="6"> N/A</Cell>
   <Cell columnid="7"> error number 3</Cell>
  </SectionItem>
   <SectionItem>
   <Cell columnid="1" InSeconds="1495568789">23/05/2017  07:46:29 PM</Cell>
   <Cell columnid="2">Error</Cell>
   <Cell columnid="3"> Application Hang </Cell>
   <Cell columnid="4"> N/A</Cell>
   <Cell columnid="5">1002</Cell>
   <Cell columnid="6"> N/A</Cell>
   <Cell columnid="7"> here is a error</Cell>
  </SectionItem>
  <SectionItem>
   <Cell columnid="1" InSeconds="1496227357">31/05/2017  10:42:37 AM</Cell>
   <Cell columnid="2"> Error</Cell>
   <Cell columnid="3">  Microsoft-Windows-CAPI2</Cell>
   <Cell columnid="4">  N/A</Cell>
   <Cell columnid="5"> 513</Cell>
   <Cell columnid="6"> N/A</Cell>
   <Cell columnid="7">Access is denied.. </Cell>
  </SectionItem>
  <SectionItem>
   <Cell columnid="1" InSeconds="1495568786">23/05/2017  07:46:26 PM</Cell>
   <Cell columnid="2"> Error</Cell>
   <Cell columnid="3"> Microsoft-Windows-Immersive-Shell</Cell>
   <Cell columnid="4">  N/A</Cell>
   <Cell columnid="5">2484</Cell>
   <Cell columnid="6">SR</Cell>
   <Cell columnid="7">hello</Cell>
  </SectionItem>
   <SectionItem>
   <Cell columnid="1" InSeconds="1496743990">06/06/2017  10:13:10 AM</Cell>
   <Cell columnid="2"> Error</Cell>3
   <Cell columnid="3"> o</Cell>
   <Cell columnid="4"> None</Cell>
   <Cell columnid="5"> 1 </Cell>
   <Cell columnid="6">  N/A </Cell>
   <Cell columnid="7"> ice age</Cell>
  </SectionItem>
</root></code>```

答:
You really have a datatable and should use mehtod DataTable.ReadXml(), but you didn't posted all the real xml data so I couldn't parse the xml with your input.  Instead I put parsed the xml input a data table using a custom xml linq parser.  It also didn't help that you added extra spaces in the innertex so I had to trim out the spaces.</p>

```<code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using System.Data;
using System.Globalization;

namespace ConsoleApplication1
{
    class Program
    {
        const string FILENAME = @"c:\temp\test.xml";
        static void Main(string[] args)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("Time", typeof(DateTime));
            dt.Columns.Add("Results", typeof(string));
            dt.Columns.Add("Name", typeof(string));
            dt.Columns.Add("Col 4", typeof(string));
            dt.Columns.Add("ID", typeof(int));
            dt.Columns.Add("Col 5", typeof(string));
            dt.Columns.Add("Status", typeof(string));

         //<Cell columnid="1" InSeconds="1496227357">31/05/2017  10:42:37 AM</Cell>
         //<Cell columnid="2"> Error</Cell>
         //<Cell columnid="3">  Microsoft-Windows-CAPI2</Cell>
         //<Cell columnid="4">  N/A</Cell>
         //<Cell columnid="5"> 513</Cell>
         //<Cell columnid="6"> N/A</Cell>
         //<Cell columnid="7">Access is denied.. </Cell>

            XDocument doc = XDocument.Load(FILENAME);

            foreach (XElement sectionItem in doc.Descendants("SectionItem"))
            {
                XElement[] cells = sectionItem.Elements("Cell").ToArray();
                DataRow newRow = dt.Rows.Add(new object[] {
                   DateTime.ParseExact( (string)cells[0],"dd/MM/yyyy  hh:mm:ss tt", CultureInfo.InvariantCulture),
                   ((string)cells[1]).Trim(),
                   ((string)cells[2]).Trim(),
                   ((string)cells[3]).Trim(),
                   (int)cells[4],
                   ((string)cells[5]).Trim(),
                   ((string)cells[6]).Trim(),

                });
            }

            dt = dt.AsEnumerable().OrderBy(x => x.Field<string>("Name")).CopyToDataTable();

        }

    }

}
</code>```

Body:
<root>
 <SectionItem>
   <Cell columnid="1" InSeconds="1496761802">06/06/2017  03:10:02 PM</Cell>
   <Cell columnid="2"> Error</Cell>
   <Cell columnid="3"> abc</Cell>
   <Cell columnid="4">  None</Cell>
   <Cell columnid="5">  1 </Cell>
   <Cell columnid="6"> N/A</Cell>
   <Cell columnid="7"> efg</Cell>
  </SectionItem>
  <SectionItem>
   <Cell columnid="1" InSeconds="1496743990">06/06/2017  10:13:10 AM</Cell>
   <Cell columnid="2"> Error</Cell>3
   <Cell columnid="3"> o</Cell>
   <Cell columnid="4"> None</Cell>
   <Cell columnid="5"> 1 </Cell>
   <Cell columnid="6">  N/A </Cell>
   <Cell columnid="7"> ice age</Cell>
  </SectionItem>
  <SectionItem>
   <Cell columnid="1" InSeconds="1496227357">31/05/2017  10:42:37 AM</Cell>
   <Cell columnid="2"> Error</Cell>
   <Cell columnid="3">  Microsoft-Windows-CAPI2</Cell>
   <Cell columnid="4">  N/A</Cell>
   <Cell columnid="5"> 513</Cell>
   <Cell columnid="6"> N/A</Cell>
   <Cell columnid="7">Access is denied.. </Cell>
  </SectionItem>
  <SectionItem>
   <Cell columnid="1" InSeconds="1495568786">23/05/2017  07:46:26 PM</Cell>
   <Cell columnid="2"> Error</Cell>
   <Cell columnid="3"> Microsoft-Windows-Immersive-Shell</Cell>
   <Cell columnid="4">  N/A</Cell>
   <Cell columnid="5">2484</Cell>
   <Cell columnid="6">SR</Cell>
   <Cell columnid="7">hello</Cell>
  </SectionItem>
  <SectionItem>
   <Cell columnid="1" InSeconds="1495568789">23/05/2017  07:46:29 PM</Cell>
   <Cell columnid="2">Error</Cell>
   <Cell columnid="3"> Application Hang </Cell>
   <Cell columnid="4"> N/A</Cell>
   <Cell columnid="5">1002</Cell>
   <Cell columnid="6"> N/A</Cell>
   <Cell columnid="7"> here is a error</Cell>
  </SectionItem>
  <SectionItem>
   <Cell columnid="1" InSeconds="1495568740">23/05/2017  07:45:40 PM</Cell>
   <Cell columnid="2"> Error</Cell>
   <Cell columnid="3"> Application Error</Cell>
   <Cell columnid="4"> Application Crashing Events</Cell>
   <Cell columnid="5">1000</Cell>
   <Cell columnid="6"> N/A</Cell>
   <Cell columnid="7"> error number 3</Cell>
  </SectionItem>
</root>

If i want to sort the sectionItem element base on Cell element value of the Cell attribute columnID giving by user, how can i approach this? Thank you in advance.

e.g. if user give colunid "1", then we want to sort the sectionItem base on the value of Cell with columnid="1".
if user give colunid "3", then we want to sort the sectionItem base on the value of Cell with columnid="3".

Hope that will make the question easier to understand as i am having difficulty putting the question together.

If i am sorting  with columnid="3"

i should get the the below output:

<root>
 <SectionItem>
   <Cell columnid="1" InSeconds="1496761802">06/06/2017  03:10:02 PM</Cell>
   <Cell columnid="2"> Error</Cell>
   <Cell columnid="3"> abc</Cell>
   <Cell columnid="4">  None</Cell>
   <Cell columnid="5">  1 </Cell>
   <Cell columnid="6"> N/A</Cell>
   <Cell columnid="7"> efg</Cell>
  </SectionItem>
  <SectionItem>
   <Cell columnid="1" InSeconds="1495568740">23/05/2017  07:45:40 PM</Cell>
   <Cell columnid="2"> Error</Cell>
   <Cell columnid="3"> Application Error</Cell>
   <Cell columnid="4"> Application Crashing Events</Cell>
   <Cell columnid="5">1000</Cell>
   <Cell columnid="6"> N/A</Cell>
   <Cell columnid="7"> error number 3</Cell>
  </SectionItem>
   <SectionItem>
   <Cell columnid="1" InSeconds="1495568789">23/05/2017  07:46:29 PM</Cell>
   <Cell columnid="2">Error</Cell>
   <Cell columnid="3"> Application Hang </Cell>
   <Cell columnid="4"> N/A</Cell>
   <Cell columnid="5">1002</Cell>
   <Cell columnid="6"> N/A</Cell>
   <Cell columnid="7"> here is a error</Cell>
  </SectionItem>
  <SectionItem>
   <Cell columnid="1" InSeconds="1496227357">31/05/2017  10:42:37 AM</Cell>
   <Cell columnid="2"> Error</Cell>
   <Cell columnid="3">  Microsoft-Windows-CAPI2</Cell>
   <Cell columnid="4">  N/A</Cell>
   <Cell columnid="5"> 513</Cell>
   <Cell columnid="6"> N/A</Cell>
   <Cell columnid="7">Access is denied.. </Cell>
  </SectionItem>
  <SectionItem>
   <Cell columnid="1" InSeconds="1495568786">23/05/2017  07:46:26 PM</Cell>
   <Cell columnid="2"> Error</Cell>
   <Cell columnid="3"> Microsoft-Windows-Immersive-Shell</Cell>
   <Cell columnid="4">  N/A</Cell>
   <Cell columnid="5">2484</Cell>
   <Cell columnid="6">SR</Cell>
   <Cell columnid="7">hello</Cell>
  </SectionItem>
   <SectionItem>
   <Cell columnid="1" InSeconds="1496743990">06/06/2017  10:13:10 AM</Cell>
   <Cell columnid="2"> Error</Cell>3
   <Cell columnid="3"> o</Cell>
   <Cell columnid="4"> None</Cell>
   <Cell columnid="5"> 1 </Cell>
   <Cell columnid="6">  N/A </Cell>
   <Cell columnid="7"> ice age</Cell>
  </SectionItem>
</root>

Body:
You really have a datatable and should use mehtod DataTable.ReadXml(), but you didn't posted all the real xml data so I couldn't parse the xml with your input.  Instead I put parsed the xml input a data table using a custom xml linq parser.  It also didn't help that you added extra spaces in the innertex so I had to trim out the spaces.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using System.Data;
using System.Globalization;

namespace ConsoleApplication1
{
    class Program
    {
        const string FILENAME = @"c:\temp\test.xml";
        static void Main(string[] args)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("Time", typeof(DateTime));
            dt.Columns.Add("Results", typeof(string));
            dt.Columns.Add("Name", typeof(string));
            dt.Columns.Add("Col 4", typeof(string));
            dt.Columns.Add("ID", typeof(int));
            dt.Columns.Add("Col 5", typeof(string));
            dt.Columns.Add("Status", typeof(string));

         //<Cell columnid="1" InSeconds="1496227357">31/05/2017  10:42:37 AM</Cell>
         //<Cell columnid="2"> Error</Cell>
         //<Cell columnid="3">  Microsoft-Windows-CAPI2</Cell>
         //<Cell columnid="4">  N/A</Cell>
         //<Cell columnid="5"> 513</Cell>
         //<Cell columnid="6"> N/A</Cell>
         //<Cell columnid="7">Access is denied.. </Cell>

            XDocument doc = XDocument.Load(FILENAME);

            foreach (XElement sectionItem in doc.Descendants("SectionItem"))
            {
                XElement[] cells = sectionItem.Elements("Cell").ToArray();
                DataRow newRow = dt.Rows.Add(new object[] {
                   DateTime.ParseExact( (string)cells[0],"dd/MM/yyyy  hh:mm:ss tt", CultureInfo.InvariantCulture),
                   ((string)cells[1]).Trim(),
                   ((string)cells[2]).Trim(),
                   ((string)cells[3]).Trim(),
                   (int)cells[4],
                   ((string)cells[5]).Trim(),
                   ((string)cells[6]).Trim(),

                });
            }

            dt = dt.AsEnumerable().OrderBy(x => x.Field<string>("Name")).CopyToDataTable();

        }

    }

}


问:
Access volume in docker build
I am using docker compose and i have created a volume. I have mulitple containers. I am facing issue to run commands in the docker container.
I have node js container which have separate frontend and backend folders.  i need to run npm install in both the folders.

```<code>version: '2'

services:

### Applications Code Container #############################

    applications:
      image: tianon/true
      volumes:
        - ${APPLICATION}:/var/www/html

    node:
      build:
        context: ./node
      volumes_from:
        - applications
      ports:
        - "4000:30001"
      networks:
        - frontend
        - backend
</code>```

This is my docker file for node

```<code>FROM node:6.10

MAINTAINER JC Gil <sensukho@gmail.com>

ENV TERM=xterm

ADD script.sh /tmp/
RUN chmod 777 /tmp/script.sh

RUN apt-get update && apt-get install -y netcat-openbsd

WORKDIR /var/www/html/Backend

RUN npm install

EXPOSE 4000
CMD ["/bin/bash", "/tmp/script.sh"]
</code>```

my workdir is empty as location /var/www/html/Backend is not available while building but available when i conainter is up. So my command npm install do not work

答:
The RUN is an image build step, at build time the volume isn't attached yet.
I think you have to execute npm install inside CMD.

You can try to add npm install inside /tmp/script.sh

Let me know

Title: Access volume in docker build

Body:
I am using docker compose and i have created a volume. I have mulitple containers. I am facing issue to run commands in the docker container.
I have node js container which have separate frontend and backend folders.  i need to run npm install in both the folders.

version: '2'

services:

### Applications Code Container #############################

    applications:
      image: tianon/true
      volumes:
        - ${APPLICATION}:/var/www/html

    node:
      build:
        context: ./node
      volumes_from:
        - applications
      ports:
        - "4000:30001"
      networks:
        - frontend
        - backend

This is my docker file for node

FROM node:6.10

MAINTAINER JC Gil <sensukho@gmail.com>

ENV TERM=xterm

ADD script.sh /tmp/
RUN chmod 777 /tmp/script.sh

RUN apt-get update && apt-get install -y netcat-openbsd

WORKDIR /var/www/html/Backend

RUN npm install

EXPOSE 4000
CMD ["/bin/bash", "/tmp/script.sh"]

my workdir is empty as location /var/www/html/Backend is not available while building but available when i conainter is up. So my command npm install do not work


问:
Cloud Functions for Firebase HTTP Request
I want to send an HTTP Request from Android to a cloud function, post some values, then input these values into real time database.

index.js

```<code>const functions = require('firebase-functions');
exports.testPost = functions.https.onRequest((req, res) => {
  console.log(req.body);
});
</code>```

How can I accomplish this?

答:
I see three steps in here:

Calling a Cloud Function from Android.

This is the same as calling any other HTTP URL from Android. See
Calling a Cloud Function from Android through Firebase

Parsing parameters from the call in your Cloud Function

A HTTP triggered Cloud Function is really just an Express handler. So parsing the post works the same as for other Express handlers. The Firebase documentation for HTTP functions has some examples and links to other documentation.

Posting to the database from a Cloud Functions

All the samples in the functions-samples repo include the Firebase Admin SDK. This SDK allows you to access many Firebase features, such as the database, from within your function. But there's also an example in this repo.

Body:
I want to send an HTTP Request from Android to a cloud function, post some values, then input these values into real time database.

index.js

const functions = require('firebase-functions');
exports.testPost = functions.https.onRequest((req, res) => {
  console.log(req.body);
});

How can I accomplish this?


问:
Excel formula returning number values when I want it to return "-"
I am kind of new to this type of Excel formula but from what I can see we want the formula to return "-"if it finds the value "mi adidas" but it seems to be returning a value and doing this across three columns - not the best at excel so any help would be great. Maybe we are missing something easy? </p>

<p>=IFERROR(COUNTIF(PCNS!$J:$J;"mi adidas");"-")</p>

答:
maybe:

```<code>IF(COUNTIF(PCNS!$J:$J;"mi adidas")>0;"-";"")
</code>```

if count of "mi adidas" in J column be greater than 0 formula return "-" in other case formula return "" (nothing - zero-char string)

Body:
I am kind of new to this type of Excel formula but from what I can see we want the formula to return "-"if it finds the value "mi adidas" but it seems to be returning a value and doing this across three columns - not the best at excel so any help would be great. Maybe we are missing something easy?

=IFERROR(COUNTIF(PCNS!$J:$J;"mi adidas");"-")

Body:
maybe:

IF(COUNTIF(PCNS!$J:$J;"mi adidas")>0;"-";"")

if count of "mi adidas" in J column be greater than 0 formula return "-" in other case formula return "" (nothing - zero-char string)


问:
I cant build my project with brunch.io
this is my first question on StackOverflow so excited  !!!
So this morning  i wanted to  make an es6 app  to train myself with es6;

but when i  wrote the brunch command : brunch new -s es6  on my folder

I am Getting  a wierd thing like :

(node:2122) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Path must be a string. Received undefined

where did i go wrong ?

the full error is enter image description here

答:
You need to install git on your computer and make sure git command will work on you CMD。open CMD and type git make sure no error occur.

if you didnt install git ,go the the site below to download git.
git download page

if you using windwos. git command might not work on the CMD. open the Git Bash instead.

Title: I cant build my project with brunch.io


问:
SSL Invalidated by Javascript
I have a webpage that requires SSL, but this one line of Javascript appears to invalidate the SSL encryption. Is there any way to stop this line from executing if the page requires SSL?

```<code>var api_url ="http://books.google.com/books?...";
</code>```

That line is the problem....Google Books does not allow SSL connections.

答:
In your Javascript check document.location.protocol, for example:

```<code>if (document.location.protocol != 'https:')
{
    var api_url ="http://books.google.com/books?
}
</code>```

Title: SSL Invalidated by Javascript

Body:
I have a webpage that requires SSL, but this one line of Javascript appears to invalidate the SSL encryption. Is there any way to stop this line from executing if the page requires SSL?

var api_url ="http://books.google.com/books?...";

That line is the problem....Google Books does not allow SSL connections.

Body:
In your Javascript check document.location.protocol, for example:

if (document.location.protocol != 'https:')
{
    var api_url ="http://books.google.com/books?
}


问:
How can I represent a "many to many" relation with Android Room when column names are same?
How can I represent a "many to many" relation with Room? My column names are also the same.

e.g. I have Guest and Reservation. Reservation can have many Guest's and a Guest can be part of many Reservations.

Here are my entity definitions:

```<code>@Entity data class Reservation(
    @PrimaryKey val id: Long,
    val table: String,
    val guests: List<Guest>
)

@Entity data class Guest(
    @PrimaryKey val id: Long,
    val name: String,
    val email: String
)
</code>```

While looking into docs I came across @Relation. I found it really confusing though.

According to this I would want to create a POJO and add the relationships there. So, with my example I did the following:

```<code>data class ReservationForGuest(
    @Embedded val reservation: Reservation,
    @Relation(
        parentColumn = "reservation.id",
        entityColumn = "id",
        entity = Guest::class
    ) val guestList: List<Guest>
)
</code>```

With above I get the compiler error:

```<code>> Cannot figure out how to read this field from a cursor.
</code>```

I wasn't able to find a working sample of @Relation.

答:
I had a similar issue. Here is my solution.

You can use an extra entity (ReservationGuest) which keeps the relation between Guest and Reservation.

```<code>@Entity data class Guest(
    @PrimaryKey val id: Long,
    val name: String,
    val email: String
)

@Entity data class Reservation(
    @PrimaryKey val id: Long,
    val table: String
)

@Entity data class ReservationGuest(
    @PrimaryKey(autoGenerate = true) val id: Long,
    val reservationId: Long,
    val guestId: Long
)
</code>```

You can get reservations with their list of guestIds. (Not the guest objects)

```<code>data class ReservationWithGuests(
    @Embedded val reservation:Reservation,
    @Relation(
        parentColumn = "id",
        entityColumn = "reservationId",
        entity = ReservationGuest::class,
        projection = "guestId"
    ) val guestIdList: List<Long>
)
</code>```

You can also get guests with their list of reservationIds. (Not the reservation objects)

```<code>data class GuestWithReservations(
    @Embedded val guest:Guest,
    @Relation(
        parentColumn = "id",
        entityColumn = "guestId",
        entity = ReservationGuest::class,
        projection = "reservationId"
   ) val reservationIdList: List<Long>
)
</code>```

Since you can get the guestIds and reservationIds, you can query Reservation and Guest entities with those.

I'll update my answer if I find an easy way to fetch Reservation and Guest object list instead of their ids.

Similar answer

ContentLicense: CC BY-SA 4.0

Body:
How can I represent a "many to many" relation with Room? My column names are also the same.

e.g. I have Guest and Reservation. Reservation can have many Guest's and a Guest can be part of many Reservations.

Here are my entity definitions:

@Entity data class Reservation(
    @PrimaryKey val id: Long,
    val table: String,
    val guests: List<Guest>
)

@Entity data class Guest(
    @PrimaryKey val id: Long,
    val name: String,
    val email: String
)

While looking into docs I came across @Relation. I found it really confusing though.

According to this I would want to create a POJO and add the relationships there. So, with my example I did the following:

data class ReservationForGuest(
    @Embedded val reservation: Reservation,
    @Relation(
        parentColumn = "reservation.id",
        entityColumn = "id",
        entity = Guest::class
    ) val guestList: List<Guest>
)

With above I get the compiler error:

> Cannot figure out how to read this field from a cursor.

I wasn't able to find a working sample of @Relation.

Body:
I had a similar issue. Here is my solution.

You can use an extra entity (ReservationGuest) which keeps the relation between Guest and Reservation.

@Entity data class Guest(
    @PrimaryKey val id: Long,
    val name: String,
    val email: String
)

@Entity data class Reservation(
    @PrimaryKey val id: Long,
    val table: String
)

@Entity data class ReservationGuest(
    @PrimaryKey(autoGenerate = true) val id: Long,
    val reservationId: Long,
    val guestId: Long
)

You can get reservations with their list of guestIds. (Not the guest objects)

data class ReservationWithGuests(
    @Embedded val reservation:Reservation,
    @Relation(
        parentColumn = "id",
        entityColumn = "reservationId",
        entity = ReservationGuest::class,
        projection = "guestId"
    ) val guestIdList: List<Long>
)

You can also get guests with their list of reservationIds. (Not the reservation objects)

data class GuestWithReservations(
    @Embedded val guest:Guest,
    @Relation(
        parentColumn = "id",
        entityColumn = "guestId",
        entity = ReservationGuest::class,
        projection = "reservationId"
   ) val reservationIdList: List<Long>
)

Since you can get the guestIds and reservationIds, you can query Reservation and Guest entities with those.

I'll update my answer if I find an easy way to fetch Reservation and Guest object list instead of their ids.

Similar answer


问:
Join where is not working
Given Below code is not working. we have received ajax for $servid,$appid and

when we $query to print this will us array value but with where it is not give me value.

please check it

```<code>public function editable($servid,$appid) {

        $result = array();
        $this->db->select('s1.*,t4.service_id,t4.appt_id');
        $this->db->from('service s1');
        $this->db->join('appointment_animal_services t4','s1.id=t4.service_id');
        $this->db->where('t4.appt_id', $appid);
        $this->db->where('t4.service_id' ! = 's1.id');
        $this->db->where('t4.service_id' ! = $servid);
        $query = $this->db->get()->result_array();
        e($query);

    }
</code>```

答:
Your JOIN  clause has

```<code>s1.id=t4.service_id
</code>```

But your WHERE clause has

```<code>t4.service_id ! = s1.id
</code>```

Both together will result in 0 records. Comment the 2nd line and see what you get.

Title: Join where is not working

Body:
Given Below code is not working. we have received ajax for $servid,$appid and

when we $query to print this will us array value but with where it is not give me value.

please check it

public function editable($servid,$appid) {

        $result = array();
        $this->db->select('s1.*,t4.service_id,t4.appt_id');
        $this->db->from('service s1');
        $this->db->join('appointment_animal_services t4','s1.id=t4.service_id');
        $this->db->where('t4.appt_id', $appid);
        $this->db->where('t4.service_id' ! = 's1.id');
        $this->db->where('t4.service_id' ! = $servid);
        $query = $this->db->get()->result_array();
        e($query);

    }

Body:
Your JOIN  clause has

s1.id=t4.service_id

But your WHERE clause has

t4.service_id ! = s1.id

Both together will result in 0 records. Comment the 2nd line and see what you get.


问:
Expression result unused when incrementing counter
```<code>void insert(size_t node, queue_t* queue) {
    *queue->count++;
    queue->elements[++(*queue->rear)] = node;
}
void remve(queue_t* queue) {
    *queue->front++;
    *queue->count--;
}
</code>```

<p>I am passing a queue and a node I wish to add to it into these helper functions. However, all the lines which involve an increment throw a "expression result unused" error. I would like to perform operations on this queue in helper functions without this error occuring. </p>

答:
Statement *queue->count++ due to operator precedence actually means *(queue->count++), and I wonder why this code does not give a different error message. I assume that count, front, etc. are integral values; Therefore, *queue->count dereferences an integral value, which is not allowed as only pointers can be dereferenced.

I think, what you actually want is queue->count++.

Body:
void insert(size_t node, queue_t* queue) {
    *queue->count++;
    queue->elements[++(*queue->rear)] = node;
}
void remve(queue_t* queue) {
    *queue->front++;
    *queue->count--;
}

I am passing a queue and a node I wish to add to it into these helper functions. However, all the lines which involve an increment throw a "expression result unused" error. I would like to perform operations on this queue in helper functions without this error occuring.


问:
global tool configurations in jenkins through cli?
Is there a way to add global tool configurations for artifactory and aws in jenkins through cli?

I'm trying to write chef cookbook for automating creation of Jenkins job, but I don't know how to add credentials for tools.

答:
Credentials don't depend on the tools which will use them.

You can register credentials in general through the JENKINS Credentials Plugin API: see for instance

How to create jenkins credentials via the REST API? (similar to jenkins_api_client issue 162)

update Jenkins credentials by script

You can then use those credentials in association with a Jenkins Job.


问:
Sitecore: Value cannot be null. Parameter name: uri
```<code>Exception: System.ArgumentNullException
Message: Value cannot be null.
Parameter name: uri
Source: Sitecore.Kernel
</code>```

I was editing a placeholder item in a local
Sitecore 8.1 (rev. 151207) instance when I got this error. Now I can't edit, delete, or reset it (or its parent folders). I also can't read the item in the content editor as the error pops up when I click on the parent folder. I've tried deleting/editing it and it's parent folder from the content editor, through code, and through PowerShell commands but the same error always shows.

I've also tried replacing my configs and bin folders with my backup copies, clearing cache, restarting IIS and the app pool, but nothing has helped.

I'm completely stuck. Does anyone know how to fix this?

Edit:
The full error in the logs is:

```<code>Exception: System.ArgumentNullException
Message: Value cannot be null.
Parameter name: uri
Source: Sitecore.Kernel
   at Sitecore.Diagnostics.Assert.ArgumentNotNull(Object argument, String argumentName)
   at Sitecore.Data.ItemUri..ctor(ItemUri uri)
   at Sitecore.Data.Items.Item.GetItemUriFromSourceItem()
   at Sitecore.Data.Items.Item.get_SourceUri()
   at Sitecore.Data.Items.Item.get_Source()
   at Sitecore.Data.Fields.Field.GetSourceItem()
   at Sitecore.Data.Fields.Field.GetInheritedValue(Boolean allowStandardValue)
   at Sitecore.Pipelines.GetFieldValue.GetInheritedValue.Process(GetFieldValueArgs args)
   at (Object , Object[] )
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at Sitecore.Data.Fields.Field.GetValue(Boolean allowStandardValue, Boolean allowDefaultValue, Boolean allowFallbackValue, Boolean allowInheritValue, Boolean allowInnerValue)
   at Sitecore.Pipelines.ItemProvider.GetItem.GetLanguageFallbackItem.IsItemFallbackEnabled(Item item)
   at Sitecore.Pipelines.ItemProvider.GetItem.GetLanguageFallbackItem.Process(GetItemArgs args)
   at (Object , Object[] )
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at Sitecore.Data.Managers.PipelineBasedItemProvider.ExecuteAndReturnResult[TArgs,TResult](String pipelineName, String pipelineDomain, Func`1 pipelineArgsCreator, Func`1 fallbackResult)
   at Sitecore.Data.Managers.ItemManager.GetItem(ID itemId, Language language, Version version, Database database, SecurityCheck securityCheck)
   at Sitecore.Nexus.Data.DataCommands.GetChildrenCommand.Execute(Item )
   at Sitecore.Data.Engines.EngineCommand`2.Execute()
   at Sitecore.Data.Managers.ItemProvider.GetChildren(Item item, ChildListOptions options)
   at Sitecore.Data.Managers.ItemProvider.GetChildren(Item item, SecurityCheck securityCheck, ChildListOptions options)
   at Sitecore.Data.Managers.PipelineBasedItemProvider.ExecuteAndReturnResult[TArgs,TResult](String pipelineName, String pipelineDomain, Func`1 pipelineArgsCreator, Func`1 fallbackResult)
   at Sitecore.Data.Managers.PipelineBasedItemProvider.GetChildren(Item item, SecurityCheck securityCheck)
   at Sitecore.Collections.ChildList.Populate(ChildListOptions options)
   at Sitecore.Shell.Framework.Pipelines.DeleteItems.GetItemClones(Item item, Boolean processChildren)
   at Sitecore.Shell.Framework.Pipelines.DeleteItems.GetItemClones(Item item, Boolean processChildren)
   at Sitecore.Shell.Framework.Pipelines.DeleteItems.GetItemClones(List`1 items)
   at Sitecore.Shell.Framework.Pipelines.DeleteItems.GetCheckCloneLinksMessage(List`1 items)
   at Sitecore.Shell.Framework.Pipelines.DeleteItems.CheckCloneLinks(ClientPipelineArgs args)
</code>```

答:
You can try the DB Browser /sitecore/admin/dbbrowser.aspx with this tool you can also delete items.

If this DB Browser admin tools fail, then I'm curious what's in the master database, check directly in sql what make this item special is than an option.

Body:
Exception: System.ArgumentNullException
Message: Value cannot be null.
Parameter name: uri
Source: Sitecore.Kernel

I was editing a placeholder item in a local
Sitecore 8.1 (rev. 151207) instance when I got this error. Now I can't edit, delete, or reset it (or its parent folders). I also can't read the item in the content editor as the error pops up when I click on the parent folder. I've tried deleting/editing it and it's parent folder from the content editor, through code, and through PowerShell commands but the same error always shows.

I've also tried replacing my configs and bin folders with my backup copies, clearing cache, restarting IIS and the app pool, but nothing has helped.

I'm completely stuck. Does anyone know how to fix this?

Edit:
The full error in the logs is:

Exception: System.ArgumentNullException
Message: Value cannot be null.
Parameter name: uri
Source: Sitecore.Kernel
   at Sitecore.Diagnostics.Assert.ArgumentNotNull(Object argument, String argumentName)
   at Sitecore.Data.ItemUri..ctor(ItemUri uri)
   at Sitecore.Data.Items.Item.GetItemUriFromSourceItem()
   at Sitecore.Data.Items.Item.get_SourceUri()
   at Sitecore.Data.Items.Item.get_Source()
   at Sitecore.Data.Fields.Field.GetSourceItem()
   at Sitecore.Data.Fields.Field.GetInheritedValue(Boolean allowStandardValue)
   at Sitecore.Pipelines.GetFieldValue.GetInheritedValue.Process(GetFieldValueArgs args)
   at (Object , Object[] )
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at Sitecore.Data.Fields.Field.GetValue(Boolean allowStandardValue, Boolean allowDefaultValue, Boolean allowFallbackValue, Boolean allowInheritValue, Boolean allowInnerValue)
   at Sitecore.Pipelines.ItemProvider.GetItem.GetLanguageFallbackItem.IsItemFallbackEnabled(Item item)
   at Sitecore.Pipelines.ItemProvider.GetItem.GetLanguageFallbackItem.Process(GetItemArgs args)
   at (Object , Object[] )
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at Sitecore.Data.Managers.PipelineBasedItemProvider.ExecuteAndReturnResult[TArgs,TResult](String pipelineName, String pipelineDomain, Func`1 pipelineArgsCreator, Func`1 fallbackResult)
   at Sitecore.Data.Managers.ItemManager.GetItem(ID itemId, Language language, Version version, Database database, SecurityCheck securityCheck)
   at Sitecore.Nexus.Data.DataCommands.GetChildrenCommand.Execute(Item )
   at Sitecore.Data.Engines.EngineCommand`2.Execute()
   at Sitecore.Data.Managers.ItemProvider.GetChildren(Item item, ChildListOptions options)
   at Sitecore.Data.Managers.ItemProvider.GetChildren(Item item, SecurityCheck securityCheck, ChildListOptions options)
   at Sitecore.Data.Managers.PipelineBasedItemProvider.ExecuteAndReturnResult[TArgs,TResult](String pipelineName, String pipelineDomain, Func`1 pipelineArgsCreator, Func`1 fallbackResult)
   at Sitecore.Data.Managers.PipelineBasedItemProvider.GetChildren(Item item, SecurityCheck securityCheck)
   at Sitecore.Collections.ChildList.Populate(ChildListOptions options)
   at Sitecore.Shell.Framework.Pipelines.DeleteItems.GetItemClones(Item item, Boolean processChildren)
   at Sitecore.Shell.Framework.Pipelines.DeleteItems.GetItemClones(Item item, Boolean processChildren)
   at Sitecore.Shell.Framework.Pipelines.DeleteItems.GetItemClones(List`1 items)
   at Sitecore.Shell.Framework.Pipelines.DeleteItems.GetCheckCloneLinksMessage(List`1 items)
   at Sitecore.Shell.Framework.Pipelines.DeleteItems.CheckCloneLinks(ClientPipelineArgs args)


答:
This will return true if client browser is using SSL on current location, false otherwise:</p>

```<code>document.location.protocol == 'https:'
</code>```

Title: SSL Invalidated by Javascript

Body:
This will return true if client browser is using SSL on current location, false otherwise:

document.location.protocol == 'https:'


问:
TypeError: el.inputmask._valueGet is not a function maskScope@http://localhost:4200
I am using Inputmask package in angular 2.0. I added one date field with mask. When I open that page first time. then no error occur and it is working fine.

But when i re-visit the page then it show me following error:

ERROR
  Error: Uncaught (in promise): TypeError: el.inputmask._valueGet is not a function maskScope@http://localhost:4200/0.chunk.js:1391:91

```<code>import Inputmask from "inputmask";

@Component({
   template: `
     <input type="text" [formControl]="member_since" data-inputmask="'alias':'date'">
   `
})
...
ngOnInit() {
  Inputmask().mask(document.querySelectorAll("input"));
}
</code>```

答:
You should use the ngAfterViewInit life-cycle hook, and not the ngOnInit. After the view initializes, you can be sure that all elements exists:

```<code>ngAfterViewInit() {
    Inputmask().mask(document.querySelectorAll("input"));
}
</code>```

This is obviously not the advised way to do it, using querySelectorAll. This way it's selecting all input elements inside your entire document. Better would be to create a template ref variable, and import this in your component using ViewChild.

```<code>@Component({
    template: `<input type="text" data-inputmask="'alias':'date'" #inputDate>`
})
export class InputDateComponent {

    @ViewChild('inputDate')
    public inputDate: ElementRef;

    ngAfterViewInit() {
        Inputmask().mask(this.inputDate.nativeElement);
    }

}
</code>```

Even better would be to create a directive, but I'll leave that up to you to figure that one out

Body:
I am using Inputmask package in angular 2.0. I added one date field with mask. When I open that page first time. then no error occur and it is working fine.

But when i re-visit the page then it show me following error:

ERROR
  Error: Uncaught (in promise): TypeError: el.inputmask._valueGet is not a function maskScope@http://localhost:4200/0.chunk.js:1391:91

import Inputmask from "inputmask";

@Component({
   template: `
     <input type="text" [formControl]="member_since" data-inputmask="'alias':'date'">
   `
})
...
ngOnInit() {
  Inputmask().mask(document.querySelectorAll("input"));
}

Body:
You should use the ngAfterViewInit life-cycle hook, and not the ngOnInit. After the view initializes, you can be sure that all elements exists:

ngAfterViewInit() {
    Inputmask().mask(document.querySelectorAll("input"));
}

This is obviously not the advised way to do it, using querySelectorAll. This way it's selecting all input elements inside your entire document. Better would be to create a template ref variable, and import this in your component using ViewChild.

@Component({
    template: `<input type="text" data-inputmask="'alias':'date'" #inputDate>`
})
export class InputDateComponent {

    @ViewChild('inputDate')
    public inputDate: ElementRef;

    ngAfterViewInit() {
        Inputmask().mask(this.inputDate.nativeElement);
    }

}

Even better would be to create a directive, but I'll leave that up to you to figure that one out


答:
Countif will always return a value. It will only return an error if there is an error in the range it looks into.

IfError returns the second parameter if the first parameter returns an error.

If you want to return a "-" sign when Countif actually finds something, then try

```<code>=if(COUNTIF(PCNS!$J:$J;"mi adidas");"-";"")
</code>```

In words: if the count of the range for "mi adidas" is greater than 0, return a "-" otherwise return nothing.

A comparison like >0 is not needed, since any number greater than zero will be interpreted as TRUE.

Title: Excel formula returning number values when I want it to return "-"

Body:
Countif will always return a value. It will only return an error if there is an error in the range it looks into.

IfError returns the second parameter if the first parameter returns an error.

If you want to return a "-" sign when Countif actually finds something, then try

=if(COUNTIF(PCNS!$J:$J;"mi adidas");"-";"")

In words: if the count of the range for "mi adidas" is greater than 0, return a "-" otherwise return nothing.

A comparison like >0 is not needed, since any number greater than zero will be interpreted as TRUE.


问:
CSS: style nth sibling
Is it possible to style the nth sibling in pure CSS?

For example, can we style 4-th or 5-th .child when hover on 1-st .child?

```<code><div class="parent">
    <div class="child"> 1 </div>
    <div class="child"> 2 </div>
    <div class="child"> 3 </div>
    <div class="child"> 4 </div>
    <div class="child"> 5 </div>
</div>
</code>```

update I guess my question was not correct a bit. Excuse me for that.

I meant can I style nth sibling of a .child that I hovered on?

I.e. style 4-th .child when hover on 1-st .child; style 5-th .child when hover on 2-nd, etc.

答:
Yes it is possible, you can use "nth-child(index)"

CSS

```<code>.parent .child:nth-child(3):hover{
  background-color:red;
}
</code>```

3 is the index of the child.
Thank Me later.

Title: CSS: style nth sibling

Body:
Is it possible to style the nth sibling in pure CSS?

For example, can we style 4-th or 5-th .child when hover on 1-st .child?

 1

 2

 3

 4

 5

update I guess my question was not correct a bit. Excuse me for that.

I meant can I style nth sibling of a .child that I hovered on?

I.e. style 4-th .child when hover on 1-st .child; style 5-th .child when hover on 2-nd, etc.

Body:
Yes it is possible, you can use "nth-child(index)"

CSS

.parent .child:nth-child(3):hover{
  background-color:red;
}

3 is the index of the child.
Thank Me later.


问:
Angular 2+ - ng-content as an attribute value in the template
I have component that looks something like this:

```<code><text-field name=myusername>Username</text-field>
</code>```

I'd like to place "Username" in the placeholder attribute of an input, kind of like this:

```<code><input name={{name}} placeholder="{{ng-content}}">
</code>```

Of course, the above doesnt work but I was wondering if there is a way to put the ng-content in an attribute?

here is my test plunker:
http://plnkr.co/edit/gk0Y6IQGXyk4gJz5EjV4?p=preview

答:
Of course there are workarounds, like the one I created in an adaptation of your plnkr: http://plnkr.co/edit/c7XEgIDiFchjMjzVmyBF?p=preview

```<code><span style="display: none;" #text><ng-content></ng-content></span>
<input name={{name}} placeholder="{{text.innerHTML}}">
</code>```

Use a hidden span to contain  the content and use that as value for your placeholder.

Body:
I have component that looks something like this:

<text-field name=myusername>Username</text-field>

I'd like to place "Username" in the placeholder attribute of an input, kind of like this:

<input name={{name}} placeholder="{{ng-content}}">

Of course, the above doesnt work but I was wondering if there is a way to put the ng-content in an attribute?

here is my test plunker:
http://plnkr.co/edit/gk0Y6IQGXyk4gJz5EjV4?p=preview

Body:
Of course there are workarounds, like the one I created in an adaptation of your plnkr: http://plnkr.co/edit/c7XEgIDiFchjMjzVmyBF?p=preview

<span style="display: none;" #text><ng-content></ng-content></span>
<input name={{name}} placeholder="{{text.innerHTML}}">

Use a hidden span to contain  the content and use that as value for your placeholder.


问:
WP Pagination Loop not working in custom theme
Pagination loop not working in custom theme Home page template. Shows same content in all pages.

You can also suggest me some other code to fix the issue.

```<code><?php
// clear any other queries that may be in use!
wp_reset_query();
// check for $_GET paged value
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
// setup post arguments
$args = array( 'posts_per_page' => 7, 'paged' => $paged, );
// run our query
query_posts($args);
// start loop
if (have_posts()) : while (have_posts()) : the_post();
  // if you use the <!-- more --> in your posts.
  global $more;
  $more = 0;
?>
   <div class="post">
     <?php the_title(); ?>
   </div>
<?php endwhile; ?>
<div class="navigation">
   <?php next_posts_link('Next'); ?>
   <?php previous_posts_link('Previous'); ?>
</div>
<?php else: ?>
   <div><h2>Nothing found</h2><p>No posts found for that query</p></div>
<?php endif; ?>
</code>```

答:
If above answer wont work for you, use WP_Query instead of query_posts.

```<code><?php
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
  'posts_per_page' => 3,
  'paged'          => $paged
);

$the_query = new WP_Query( $args );
?>
</code>```

If the pagination is broken on a static front page you have to add the "paged" parameter this way:

```<code>if ( get_query_var( 'paged' ) ) { $paged = get_query_var( 'paged' ); }
elseif ( get_query_var( 'page' ) ) { $paged = get_query_var( 'page' ); }
else { $paged = 1; }
</code>```

Body:
Pagination loop not working in custom theme Home page template. Shows same content in all pages.

You can also suggest me some other code to fix the issue.

<?php
// clear any other queries that may be in use!
wp_reset_query();
// check for $_GET paged value
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
// setup post arguments
$args = array( 'posts_per_page' => 7, 'paged' => $paged, );
// run our query
query_posts($args);
// start loop
if (have_posts()) : while (have_posts()) : the_post();
  // if you use the  in your posts.
  global $more;
  $more = 0;
?>

     <?php the_title(); ?>

<?php endwhile; ?>

   <?php next_posts_link('Next'); ?>
   <?php previous_posts_link('Previous'); ?>

<?php else: ?>

Nothing found

No posts found for that query

<?php endif; ?>

Body:
If above answer wont work for you, use WP_Query instead of query_posts.

<?php
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
  'posts_per_page' => 3,
  'paged'          => $paged
);

$the_query = new WP_Query( $args );
?>

If the pagination is broken on a static front page you have to add the "paged" parameter this way:

if ( get_query_var( 'paged' ) ) { $paged = get_query_var( 'paged' ); }
elseif ( get_query_var( 'page' ) ) { $paged = get_query_var( 'page' ); }
else { $paged = 1; }


问:
Multiple websockets onto multiple servers: how do they communicate?
I have a node server accepting websocket connections from the clients. Each client can broadcast a message to all of the other clients.

UPDATE: I am using https://github.com/websockets/ws as my library of choice.

At the moment, the server has an array with all of the connections. Each connection has a tabId. When one of the client emits a message, I go through all of the connections and check: if the connection's tabId doesn't match, I send the message to the client.

For loading issues, I am facing the problem of having to have more than one server. So, there will be say two servers, each one with a number of clients.

How do I make sure that a message gets broadcast to all of the websocket clients, and not only the ones connected to the same server?

One possible solution I thought is to have the connections stored on a database, where each record has the tabId and the serverId. However, even a simple broadcast gets tricky as messages to "local" sockets are easy to broadcast (the socket is local and available) whereas messages to "remote" sockets are tricky, and would imply intra-server communication.

Is there a good pattern to solve this? Surely, this is something that people face every day.

答:
You could use a messagequeue like RabbitMQ.

When a client logs in to your server, create a consumer which listens to a queue which will receive messages directed to that particular client. And when the clients are sending messages, just use a publisher to publish them to the recipients queue.

This way it doesn't matter and you don't need to know on which nodes the clients are on, or if they jump from a node to another.


问:
vb.net key combination
I'm trying to capture two key presses in my VB.net application, for this example CTRL + B, the code below doesn't work but it does for single keys. I have tried setting keypreview as true but this has no effect.

```<code>  Private Sub main_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles mybase.KeyDown
            If e.KeyCode = Keys.ControlKey And e.KeyCode = Keys.B Then
                MsgBox("CTRL + B Pressed !")
            End If
        End Sub
    End Class
</code>```

Thanks

答:
The Control key is a Modifier key. This code tests for Ctrl + B

```<code>e.KeyCode = Keys.B AndAlso e.Modifiers = Keys.Control
</code>```

The key-code is B, but the modifier is Ctrl.

Your code snippet, updated:

```<code>Private Sub main_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles mybase.KeyDown
    If (e.KeyCode = Keys.B AndAlso e.Modifiers = Keys.Control) Then
        MsgBox("CTRL + B Pressed !")
    End If
End Sub
</code>```

Title: vb.net key combination

Body:
I'm trying to capture two key presses in my VB.net application, for this example CTRL + B, the code below doesn't work but it does for single keys. I have tried setting keypreview as true but this has no effect.

  Private Sub main_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles mybase.KeyDown
            If e.KeyCode = Keys.ControlKey And e.KeyCode = Keys.B Then
                MsgBox("CTRL + B Pressed !")
            End If
        End Sub
    End Class

Thanks

Body:
The Control key is a Modifier key. This code tests for Ctrl + B

e.KeyCode = Keys.B AndAlso e.Modifiers = Keys.Control

The key-code is B, but the modifier is Ctrl.

Your code snippet, updated:

Private Sub main_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles mybase.KeyDown
    If (e.KeyCode = Keys.B AndAlso e.Modifiers = Keys.Control) Then
        MsgBox("CTRL + B Pressed !")
    End If
End Sub


问:
Trello API authentication popup not closed
I'm trying to demonstrate the Trello API but i'm having issues with the authentication procedure.

```<code>var ConnectToTrello = function () {
//console.log("Authenticating");
Trello.authorize({
    type: 'popup',
    name: 'Outlook Trello Add-In',
    scope: { read: true, write: true, account: true },
    success: authenticationSuccess,
    error: authenticationError
});};
</code>```

This opens a popup where I can do the authentication, then I get redirected (in the popup) to https://trello.com/1/token/approve and nothing happens. The popup is not closing.

Any help would be appreciated.

download the code here

Body:
I'm trying to demonstrate the Trello API but i'm having issues with the authentication procedure.

var ConnectToTrello = function () {
//console.log("Authenticating");
Trello.authorize({
    type: 'popup',
    name: 'Outlook Trello Add-In',
    scope: { read: true, write: true, account: true },
    success: authenticationSuccess,
    error: authenticationError
});};

This opens a popup where I can do the authentication, then I get redirected (in the popup) to https://trello.com/1/token/approve and nothing happens. The popup is not closing.

Any help would be appreciated.

download the code here

Body:
I had the same issue until I tried running the ConnectToTrello function from a button. If you create a simple page with that javascript snippet being executed in the <script> block it exhibits the behaviour you describe.

However, if you add a simple button with that function as the onclick event handler, then it works just fine.

<button onclick="ConnectToTrello();">press me!</button>


问:
I am getting error Unfortunately app has stopped.Where is the mistake?
These are the sections of code mentioned.As I run these errors pop up in logcat file and the app crashes when opened.There are so many of them that I could not figure out where the actual mistake is.Please Help me out where there is need of modification and replacement as I am trying to build a splash screen.

logcat:

```<code>06-08 11:36:18.203 17265-17265/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                   Process: com.elvero.telecom.voipapp, PID: 17265
                                                   java.lang.RuntimeException: Unable to start activity ComponentInfo{com.elvero.telecom.voipapp/com.elvero.telecom.voipapp.splash}: android.view.InflateException: Binary XML file line #10: Error inflating class ImageView
                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2567)
                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2641)
                                                       at android.app.ActivityThread.access$800(ActivityThread.java:182)
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1515)
                                                       at android.os.Handler.dispatchMessage(Handler.java:111)
                                                       at android.os.Looper.loop(Looper.java:194)
                                                       at android.app.ActivityThread.main(ActivityThread.java:5717)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at java.lang.reflect.Method.invoke(Method.java:372)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
                                                    Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class ImageView
                                                       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
                                                       at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
                                                       at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
                                                       at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                                                       at com.elvero.telecom.voipapp.splash.onCreate(splash.java:13)
                                                       at android.app.Activity.performCreate(Activity.java:6092)
                                                       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)
                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2514)
                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2641)
                                                       at android.app.ActivityThread.access$800(ActivityThread.java:182)
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1515)
                                                       at android.os.Handler.dispatchMessage(Handler.java:111)
                                                       at android.os.Looper.loop(Looper.java:194)
                                                       at android.app.ActivityThread.main(ActivityThread.java:5717)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at java.lang.reflect.Method.invoke(Method.java:372)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
                                                    Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x6
                                                       at android.content.res.TypedArray.getDimensionPixelOffset(TypedArray.java:533)
                                                       at android.view.View.<init>(View.java:3927)
                                                       at android.widget.ImageView.<init>(ImageView.java:139)
                                                       at android.widget.ImageView.<init>(ImageView.java:135)
                                                       at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:60)
                                                       at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:56)
                                                       at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:106)
                                                       at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1029)
                                                       at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1087)
                                                       at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:47)
                                                       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:725)
                                                       at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
                                                       at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
                                                       at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                                                       at com.elvero.telecom.voipapp.splash.onCreate(splash.java:13)
                                                       at android.app.Activity.performCreate(Activity.java:6092)
                                                       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)
                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2514)
                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2641)
                                                       at android.app.ActivityThread.access$800(ActivityThread.java:182)
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1515)
                                                       at android.os.Handler.dispatchMessage(Handler.java:111)
                                                       at android.os.Looper.loop(Looper.java:194)
                                                       at android.app.ActivityThread.main(ActivityThread.java:5717)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at java.lang.reflect.Method.invoke(Method.java:372)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
06-08 11:36:22.207 17265-17265/? I/Process: Sending signal. PID: 17265 SIG: 9
</code>```

MainActivity.java:

```<code>package com.elvero.telecom.voipapp;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.support.v7.app.ActionBarActivity;

public class MainActivity extends AppCompatActivity {
    private Toolbar toolbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        toolbar= (Toolbar)findViewById(R.id.app_bar);
        setSupportActionBar(toolbar);

    }
}
</code>```

AndroidManifest.xml:

```<code><?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.elvero.telecom.voipapp">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">

        </activity>

        <activity android:name=".splash">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
</code>```

splashactivity:

```<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:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="visible"
        tools:context="com.elvero.telecom.voipapp.splash">

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:background="@android:color/holo_blue_light"
            android:elevation="@android:dimen/dialog_min_width_minor"
            android:scaleType="fitCenter"
            android:src="@drawable/logo_elvero"/>
        </RelativeLayout>
</code>```

Splash.java:

```<code>package com.elvero.telecom.voipapp;

import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class splash extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        Handler handler=new Handler();
        handler.postDelayed(new Runnable(){
            @Override
            public void run(){
                startActivity(new Intent(splash.this,MainActivity.class));
                finish();

            }
        },1000);
    }
}
</code>```

答:
You can make separate Activity as a splash screen and use below code in onCreate() to show it for required seconds and then can move to your main landing activity.

```<code>new CountDownTimer(2000, 1000) {
        public void onTick(long millisUntilFinished) {
        }
        public void onFinish() {
            HarmUtils.openActivity(SplashScreenActivity.this, LoginActivity.class, true);
        }
    }.start();
</code>```

here 2000 is waiting time (2000 = 2 seconds) and second parameter is time interval which I set to 1 second.
You can specify your time as per your requirements.

Hope this will help you.

Body:
These are the sections of code mentioned.As I run these errors pop up in logcat file and the app crashes when opened.There are so many of them that I could not figure out where the actual mistake is.Please Help me out where there is need of modification and replacement as I am trying to build a splash screen.

logcat:

06-08 11:36:18.203 17265-17265/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                   Process: com.elvero.telecom.voipapp, PID: 17265
                                                   java.lang.RuntimeException: Unable to start activity ComponentInfo{com.elvero.telecom.voipapp/com.elvero.telecom.voipapp.splash}: android.view.InflateException: Binary XML file line #10: Error inflating class ImageView
                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2567)
                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2641)
                                                       at android.app.ActivityThread.access$800(ActivityThread.java:182)
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1515)
                                                       at android.os.Handler.dispatchMessage(Handler.java:111)
                                                       at android.os.Looper.loop(Looper.java:194)
                                                       at android.app.ActivityThread.main(ActivityThread.java:5717)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at java.lang.reflect.Method.invoke(Method.java:372)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
                                                    Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class ImageView
                                                       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
                                                       at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
                                                       at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
                                                       at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                                                       at com.elvero.telecom.voipapp.splash.onCreate(splash.java:13)
                                                       at android.app.Activity.performCreate(Activity.java:6092)
                                                       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)
                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2514)
                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2641)
                                                       at android.app.ActivityThread.access$800(ActivityThread.java:182)
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1515)
                                                       at android.os.Handler.dispatchMessage(Handler.java:111)
                                                       at android.os.Looper.loop(Looper.java:194)
                                                       at android.app.ActivityThread.main(ActivityThread.java:5717)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at java.lang.reflect.Method.invoke(Method.java:372)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
                                                    Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x6
                                                       at android.content.res.TypedArray.getDimensionPixelOffset(TypedArray.java:533)
                                                       at android.view.View.<init>(View.java:3927)
                                                       at android.widget.ImageView.<init>(ImageView.java:139)
                                                       at android.widget.ImageView.<init>(ImageView.java:135)
                                                       at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:60)
                                                       at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:56)
                                                       at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:106)
                                                       at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1029)
                                                       at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1087)
                                                       at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:47)
                                                       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:725)
                                                       at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
                                                       at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
                                                       at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                                                       at com.elvero.telecom.voipapp.splash.onCreate(splash.java:13)
                                                       at android.app.Activity.performCreate(Activity.java:6092)
                                                       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)
                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2514)
                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2641)
                                                       at android.app.ActivityThread.access$800(ActivityThread.java:182)
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1515)
                                                       at android.os.Handler.dispatchMessage(Handler.java:111)
                                                       at android.os.Looper.loop(Looper.java:194)
                                                       at android.app.ActivityThread.main(ActivityThread.java:5717)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at java.lang.reflect.Method.invoke(Method.java:372)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
06-08 11:36:22.207 17265-17265/? I/Process: Sending signal. PID: 17265 SIG: 9

MainActivity.java:

package com.elvero.telecom.voipapp;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.support.v7.app.ActionBarActivity;

public class MainActivity extends AppCompatActivity {
    private Toolbar toolbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        toolbar= (Toolbar)findViewById(R.id.app_bar);
        setSupportActionBar(toolbar);

    }
}

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.elvero.telecom.voipapp">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">

        </activity>

        <activity android:name=".splash">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

splashactivity:

  <?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:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="visible"
        tools:context="com.elvero.telecom.voipapp.splash">

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:background="@android:color/holo_blue_light"
            android:elevation="@android:dimen/dialog_min_width_minor"
            android:scaleType="fitCenter"
            android:src="@drawable/logo_elvero"/>
        </RelativeLayout>

Splash.java:

package com.elvero.telecom.voipapp;

import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class splash extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        Handler handler=new Handler();
        handler.postDelayed(new Runnable(){
            @Override
            public void run(){
                startActivity(new Intent(splash.this,MainActivity.class));
                finish();

            }
        },1000);
    }
}

Body:
You can make separate Activity as a splash screen and use below code in onCreate() to show it for required seconds and then can move to your main landing activity.

new CountDownTimer(2000, 1000) {
        public void onTick(long millisUntilFinished) {
        }
        public void onFinish() {
            HarmUtils.openActivity(SplashScreenActivity.this, LoginActivity.class, true);
        }
    }.start();

here 2000 is waiting time (2000 = 2 seconds) and second parameter is time interval which I set to 1 second.
You can specify your time as per your requirements.

Hope this will help you.