问:
Angular2 How to pass selected value to other component
Hi I am tryng to pass value selected from one of the options.
I used ngModel to save the value but I can't figure out how to pass it to other component. Since they are connected but not nested, I couldn't use Eventemitter cause I reckon to use Eventemiiter, I should use child component's selector to nest the component in the parent component which I do not want to do.

These two components are seperated and I want to pass selected value to the other component? How can I achieve this?

Below is my code.

Component 1's template

```<code> <div>
    <select (change)="printValue()" formControlName="dogName"
     class="form-control"
     class="selectionbox"
     [(ngModel)]="selected_dog" required>

  <option *ngFor="let d of dogs" [ngValue]="d">
     {{d.dogName}}
  </option>
     </select>
</code>```

Component1's component

```<code>     selected_dog: string;
     printValue () {
     console.log (this.selected_dog)} // checked if the value is properly stored.
</code>```

And now, I want to pass 'selected_dog' value to Component2.
Component2

```<code>     value1: string; //how to pass selected_dog value to component2's value1.
</code>```

I am not sure what to use ( eventEmitter, output/ input? / ng-content?)

I appreciate your help in advance.

答:
I would suggest you to create a service and store the variable value, use the variable across those 2 components.

```<code>@Injectable()
export class AppMessageService {
    value1: string;
   constructor() {
     this.value1="";
   }
}

setValue(data: string) {
 this.value1= data;
}

getValue() {
 return this.value1;
}
</code>```

Inject the above service and use setValue to set the value in 1st component and getValue in the 2nd component.

Body:
Hi I am tryng to pass value selected from one of the options.
I used ngModel to save the value but I can't figure out how to pass it to other component. Since they are connected but not nested, I couldn't use Eventemitter cause I reckon to use Eventemiiter, I should use child component's selector to nest the component in the parent component which I do not want to do.

These two components are seperated and I want to pass selected value to the other component? How can I achieve this?

Below is my code.

Component 1's template

    <select (change)="printValue()" formControlName="dogName"
     class="form-control"
     class="selectionbox"
     [(ngModel)]="selected_dog" required>

  <option *ngFor="let d of dogs" [ngValue]="d">
     {{d.dogName}}
  </option>
     </select>

Component1's component

     selected_dog: string;
     printValue () {
     console.log (this.selected_dog)} // checked if the value is properly stored.

And now, I want to pass 'selected_dog' value to Component2.
Component2

     value1: string; //how to pass selected_dog value to component2's value1.

I am not sure what to use ( eventEmitter, output/ input? / ng-content?)

I appreciate your help in advance.

Body:
I would suggest you to create a service and store the variable value, use the variable across those 2 components.

@Injectable()
export class AppMessageService {
    value1: string;
   constructor() {
     this.value1="";
   }
}

setValue(data: string) {
 this.value1= data;
}

getValue() {
 return this.value1;
}

Inject the above service and use setValue to set the value in 1st component and getValue in the 2nd component.


来源: stackexchange

问:
How can I make a div fade out when it is clicked?
So basically I have a button and when the user clicks it, a div fades in. I would like it to fade out when the user clicks anywhere on the div. (the div takes up the entire screen)

Here is what I have so far, it basically just fades in the div when you click the "about" button. I need it to fade out whenever I click anywhere on the screen.

$(function() {

  $('#fadeContent').click(function(){
    $('#bodyContent').fadeIn(500);
  });

});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body {
  background-color: black;
  font-family: "Source Sans Pro", sans-serif;
  color: #ccc;
  z-index: -100;
  background-color:black;
}

#bodyContent{
  display:none;
  position:absolute;
  top:0;      left;0;
  width:100%; height:100%;
  background:#454545;
  z-index: 100;
}

#home {
    position: absolute;
    width: 16%;
    background-color: transparent;
    border: 2px solid #FFF;
    margin-top: 12%;
    margin-left: 20%;
    height: 3em;
    color: #FFF;
    font-size: 1em;
    cursor: pointer;
    text-transform: uppercase;
    border-radius: 4px;
    animation: fadein 2s;
    -moz-animation: fadein 2s; /* Firefox */
    -webkit-animation: fadein 2s; /* Safari and Chrome */
}

.about {
    position: absolute;
    width: 16%;
    background-color: transparent;
    border: 2px solid #FFF;
    margin-top: 12%;
    margin-left: 37%;
    height: 3em;
    color: #FFF;
    font-size: 1em;
    cursor: pointer;
    text-transform: uppercase;
    border-radius: 4px;
    animation: fadein 2s;
    -moz-animation: fadein 2s; /* Firefox */
    -webkit-animation: fadein 2s; /* Safari and Chrome */
}

#projects {
    position: absolute;
    width: 16%;
    background-color: transparent;
    border: 2px solid #FFF;
    margin-top: 12%;
    margin-left: 54%;
    height: 3em;
    color: #FFF;
    font-size: 1em;
    cursor: pointer;
    text-transform: uppercase;
    border-radius: 4px;
    animation: fadein 2s;
    -moz-animation: fadein 2s; /* Firefox */
    -webkit-animation: fadein 2s; /* Safari and Chrome */
}

#contact {
    position: absolute;
    width: 16%;
    background-color: transparent;
    border: 2px solid #FFF;
    margin-top: 12%;
    margin-left: 71%;
    height: 3em;
    color: #FFF;
    font-size: 1em;
    cursor: pointer;
    text-transform: uppercase;
    border-radius: 4px;
    animation: fadein 2s;
    -moz-animation: fadein 2s; /* Firefox */
    -webkit-animation: fadein 2s; /* Safari and Chrome */
}

#home:hover {
    color: #1dd2e2;
    border: 3px solid #18bdef;
    font-weight: bold;
}

#about:hover {
    color: #1dd2e2;
    border: 3px solid #18bdef;
    font-weight: bold;
}

#projects:hover {
    color: #1dd2e2;
    border: 3px solid #18bdef;
    font-weight: bold;
}

#contact:hover {
    color: #1dd2e2;
    border: 3px solid #18bdef;
    font-weight: bold;
}

@keyframes fadein {
    from {
        opacity:0;
    }
    to {
        opacity:1;
    }
}
@-webkit-keyframes fadein { /* Safari and Chrome */
    from {
        opacity:0;
    }
    to {
        opacity:1;
    }
}</code>```

<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Home</title>

    <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro|Play" rel="stylesheet">

    <link rel='stylesheet prefetch' href='http://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css'>
    <link rel='stylesheet prefetch' href='http://rawgit.com/fralec/elegantShareJS/master/css/elegant.css'>

    <link rel="stylesheet" type="text/css" href="css/style.css">

    <button id="home">Home</button>
    <button id="fadeContent" class="about">About</button>
    <button id="projects">Projects</button>
    <button id="contact">Contact</button>

Page

Content

```

答:
Add a click listener to the body content you just faded in, and then fade it out!

$(function() {

  $('#fadeContent').click(function(){
    var bodyContent = $('#bodyContent')
    bodyContent.fadeIn(500);
    bodyContent.click(function() {
      $(this).fadeOut(500);
    })
  });

});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body {
  background-color: black;
  font-family: "Source Sans Pro", sans-serif;
  color: #ccc;
  z-index: -100;
  background-color:black;
}

#bodyContent{
  display:none;
  position:absolute;
  top:0;      left;0;
  width:100%; height:100%;
  background:#454545;
  z-index: 100;
}

#home {
    position: absolute;
    width: 16%;
    background-color: transparent;
    border: 2px solid #FFF;
    margin-top: 12%;
    margin-left: 20%;
    height: 3em;
    color: #FFF;
    font-size: 1em;
    cursor: pointer;
    text-transform: uppercase;
    border-radius: 4px;
    animation: fadein 2s;
    -moz-animation: fadein 2s; /* Firefox */
    -webkit-animation: fadein 2s; /* Safari and Chrome */
}

.about {
    position: absolute;
    width: 16%;
    background-color: transparent;
    border: 2px solid #FFF;
    margin-top: 12%;
    margin-left: 37%;
    height: 3em;
    color: #FFF;
    font-size: 1em;
    cursor: pointer;
    text-transform: uppercase;
    border-radius: 4px;
    animation: fadein 2s;
    -moz-animation: fadein 2s; /* Firefox */
    -webkit-animation: fadein 2s; /* Safari and Chrome */
}

#projects {
    position: absolute;
    width: 16%;
    background-color: transparent;
    border: 2px solid #FFF;
    margin-top: 12%;
    margin-left: 54%;
    height: 3em;
    color: #FFF;
    font-size: 1em;
    cursor: pointer;
    text-transform: uppercase;
    border-radius: 4px;
    animation: fadein 2s;
    -moz-animation: fadein 2s; /* Firefox */
    -webkit-animation: fadein 2s; /* Safari and Chrome */
}

#contact {
    position: absolute;
    width: 16%;
    background-color: transparent;
    border: 2px solid #FFF;
    margin-top: 12%;
    margin-left: 71%;
    height: 3em;
    color: #FFF;
    font-size: 1em;
    cursor: pointer;
    text-transform: uppercase;
    border-radius: 4px;
    animation: fadein 2s;
    -moz-animation: fadein 2s; /* Firefox */
    -webkit-animation: fadein 2s; /* Safari and Chrome */
}

#home:hover {
    color: #1dd2e2;
    border: 3px solid #18bdef;
    font-weight: bold;
}

#about:hover {
    color: #1dd2e2;
    border: 3px solid #18bdef;
    font-weight: bold;
}

#projects:hover {
    color: #1dd2e2;
    border: 3px solid #18bdef;
    font-weight: bold;
}

#contact:hover {
    color: #1dd2e2;
    border: 3px solid #18bdef;
    font-weight: bold;
}

@keyframes fadein {
    from {
        opacity:0;
    }
    to {
        opacity:1;
    }
}
@-webkit-keyframes fadein { /* Safari and Chrome */
    from {
        opacity:0;
    }
    to {
        opacity:1;
    }
}</code>```

<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Home</title>

    <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro|Play" rel="stylesheet">

    <link rel='stylesheet prefetch' href='http://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css'>
    <link rel='stylesheet prefetch' href='http://rawgit.com/fralec/elegantShareJS/master/css/elegant.css'>

    <link rel="stylesheet" type="text/css" href="css/style.css">

    <button id="home">Home</button>
    <button id="fadeContent" class="about">About</button>
    <button id="projects">Projects</button>
    <button id="contact">Contact</button>

Page

Content

```

ContentLicense: CC BY-SA 3.0

Body:
So basically I have a button and when the user clicks it, a div fades in. I would like it to fade out when the user clicks anywhere on the div. (the div takes up the entire screen)

Here is what I have so far, it basically just fades in the div when you click the "about" button. I need it to fade out whenever I click anywhere on the screen.

$(function() {

  $('#fadeContent').click(function(){
    $('#bodyContent').fadeIn(500);
  });

});

body {
  background-color: black;
  font-family: "Source Sans Pro", sans-serif;
  color: #ccc;
  z-index: -100;
  background-color:black;
}

#bodyContent{
  display:none;
  position:absolute;
  top:0;      left;0;
  width:100%; height:100%;
  background:#454545;
  z-index: 100;
}

#home {
    position: absolute;
    width: 16%;
    background-color: transparent;
    border: 2px solid #FFF;
    margin-top: 12%;
    margin-left: 20%;
    height: 3em;
    color: #FFF;
    font-size: 1em;
    cursor: pointer;
    text-transform: uppercase;
    border-radius: 4px;
    animation: fadein 2s;
    -moz-animation: fadein 2s; /* Firefox */
    -webkit-animation: fadein 2s; /* Safari and Chrome */
}

.about {
    position: absolute;
    width: 16%;
    background-color: transparent;
    border: 2px solid #FFF;
    margin-top: 12%;
    margin-left: 37%;
    height: 3em;
    color: #FFF;
    font-size: 1em;
    cursor: pointer;
    text-transform: uppercase;
    border-radius: 4px;
    animation: fadein 2s;
    -moz-animation: fadein 2s; /* Firefox */
    -webkit-animation: fadein 2s; /* Safari and Chrome */
}

#projects {
    position: absolute;
    width: 16%;
    background-color: transparent;
    border: 2px solid #FFF;
    margin-top: 12%;
    margin-left: 54%;
    height: 3em;
    color: #FFF;
    font-size: 1em;
    cursor: pointer;
    text-transform: uppercase;
    border-radius: 4px;
    animation: fadein 2s;
    -moz-animation: fadein 2s; /* Firefox */
    -webkit-animation: fadein 2s; /* Safari and Chrome */
}

#contact {
    position: absolute;
    width: 16%;
    background-color: transparent;
    border: 2px solid #FFF;
    margin-top: 12%;
    margin-left: 71%;
    height: 3em;
    color: #FFF;
    font-size: 1em;
    cursor: pointer;
    text-transform: uppercase;
    border-radius: 4px;
    animation: fadein 2s;
    -moz-animation: fadein 2s; /* Firefox */
    -webkit-animation: fadein 2s; /* Safari and Chrome */
}

#home:hover {
    color: #1dd2e2;
    border: 3px solid #18bdef;
    font-weight: bold;
}

#about:hover {
    color: #1dd2e2;
    border: 3px solid #18bdef;
    font-weight: bold;
}

#projects:hover {
    color: #1dd2e2;
    border: 3px solid #18bdef;
    font-weight: bold;
}

#contact:hover {
    color: #1dd2e2;
    border: 3px solid #18bdef;
    font-weight: bold;
}

@keyframes fadein {
    from {
        opacity:0;
    }
    to {
        opacity:1;
    }
}
@-webkit-keyframes fadein { /* Safari and Chrome */
    from {
        opacity:0;
    }
    to {
        opacity:1;
    }
}

<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Home</title>

    <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro|Play" rel="stylesheet">

    <link rel='stylesheet prefetch' href='http://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css'>
    <link rel='stylesheet prefetch' href='http://rawgit.com/fralec/elegantShareJS/master/css/elegant.css'>

    <link rel="stylesheet" type="text/css" href="css/style.css">

    <button id="home">Home</button>
    <button id="fadeContent" class="about">About</button>
    <button id="projects">Projects</button>
    <button id="contact">Contact</button>

Page

Content

Body:
Add a click listener to the body content you just faded in, and then fade it out!

$(function() {

  $('#fadeContent').click(function(){
    var bodyContent = $('#bodyContent')
    bodyContent.fadeIn(500);
    bodyContent.click(function() {
      $(this).fadeOut(500);
    })
  });

});

body {
  background-color: black;
  font-family: "Source Sans Pro", sans-serif;
  color: #ccc;
  z-index: -100;
  background-color:black;
}

#bodyContent{
  display:none;
  position:absolute;
  top:0;      left;0;
  width:100%; height:100%;
  background:#454545;
  z-index: 100;
}

#home {
    position: absolute;
    width: 16%;
    background-color: transparent;
    border: 2px solid #FFF;
    margin-top: 12%;
    margin-left: 20%;
    height: 3em;
    color: #FFF;
    font-size: 1em;
    cursor: pointer;
    text-transform: uppercase;
    border-radius: 4px;
    animation: fadein 2s;
    -moz-animation: fadein 2s; /* Firefox */
    -webkit-animation: fadein 2s; /* Safari and Chrome */
}

.about {
    position: absolute;
    width: 16%;
    background-color: transparent;
    border: 2px solid #FFF;
    margin-top: 12%;
    margin-left: 37%;
    height: 3em;
    color: #FFF;
    font-size: 1em;
    cursor: pointer;
    text-transform: uppercase;
    border-radius: 4px;
    animation: fadein 2s;
    -moz-animation: fadein 2s; /* Firefox */
    -webkit-animation: fadein 2s; /* Safari and Chrome */
}

#projects {
    position: absolute;
    width: 16%;
    background-color: transparent;
    border: 2px solid #FFF;
    margin-top: 12%;
    margin-left: 54%;
    height: 3em;
    color: #FFF;
    font-size: 1em;
    cursor: pointer;
    text-transform: uppercase;
    border-radius: 4px;
    animation: fadein 2s;
    -moz-animation: fadein 2s; /* Firefox */
    -webkit-animation: fadein 2s; /* Safari and Chrome */
}

#contact {
    position: absolute;
    width: 16%;
    background-color: transparent;
    border: 2px solid #FFF;
    margin-top: 12%;
    margin-left: 71%;
    height: 3em;
    color: #FFF;
    font-size: 1em;
    cursor: pointer;
    text-transform: uppercase;
    border-radius: 4px;
    animation: fadein 2s;
    -moz-animation: fadein 2s; /* Firefox */
    -webkit-animation: fadein 2s; /* Safari and Chrome */
}

#home:hover {
    color: #1dd2e2;
    border: 3px solid #18bdef;
    font-weight: bold;
}

#about:hover {
    color: #1dd2e2;
    border: 3px solid #18bdef;
    font-weight: bold;
}

#projects:hover {
    color: #1dd2e2;
    border: 3px solid #18bdef;
    font-weight: bold;
}

#contact:hover {
    color: #1dd2e2;
    border: 3px solid #18bdef;
    font-weight: bold;
}

@keyframes fadein {
    from {
        opacity:0;
    }
    to {
        opacity:1;
    }
}
@-webkit-keyframes fadein { /* Safari and Chrome */
    from {
        opacity:0;
    }
    to {
        opacity:1;
    }
}

<!DOCTYPE html>

<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Home</title>

    <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro|Play" rel="stylesheet">

    <link rel='stylesheet prefetch' href='http://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css'>
    <link rel='stylesheet prefetch' href='http://rawgit.com/fralec/elegantShareJS/master/css/elegant.css'>

    <link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>

    <button id="home">Home</button>
    <button id="fadeContent" class="about">About</button>
    <button id="projects">Projects</button>
    <button id="contact">Contact</button>

      <div id="bodyContent">
            <h1>Page</h1>
            <p>Content</p>
      </div>

    <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
    <script src='http://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js'></script>
    <script type="text/javascript" src="js/elegant.js"></script>

    <script type="text/javascript" src="js/transition.js"></script>
    <script type="text/javascript" src="js/index.js"></script>
    <script type="text/javascript" src="js/background.js"></script>
</body>
</html>


问:
How to use CTE recursion to get a running total of a column
I have been researching CTE recursion, but I still seem to be confused.

I have table: utb(date, b_id, v_id, b_vol)

I need to get the running total of the column: b_vol.

The catch is that I need to divide if the row_number is even, and multiply if it is odd, so essentially:

P1= b_vol1, P2 = b_vol1/b_vol2, P3= b_vol1/b_vol2*b_vol3,
  P4= b_vol1/b_vol2*b_vol3/b_vol4

So, it is basically P(n)= (P(n-1)(*OR/(b_vol(n))

I can't seem to figure out how to put that into a query.

Thanks for taking the time to read this. I hope you can help.

答:
First, a CTE is not the best way to solve this problem.  But . . .</p>

```<code>with u as (
      select u.*, row_number() over (order by date) - 1 as seqnum
      from utb u
     ),
     cte as (
      select seqnum, b_vol as result
      from u
      union all
      select cte.seqnum, cte.result * (case when seqnum % 2 = 1 then 1.0 / b_vol else b_vol end) as result
      from cte join
           u
           on u.seqnum = cte.seqnum + 1
     )
select *
from cte;
</code>```

Body:
First, a CTE is not the best way to solve this problem.  But . . .

with u as (
      select u.*, row_number() over (order by date) - 1 as seqnum
      from utb u
     ),
     cte as (
      select seqnum, b_vol as result
      from u
      union all
      select cte.seqnum, cte.result * (case when seqnum % 2 = 1 then 1.0 / b_vol else b_vol end) as result
      from cte join
           u
           on u.seqnum = cte.seqnum + 1
     )
select *
from cte;


问:
HTTP/2 Server pushed but it's reloaded the pushed file on Apache2.4
I just setup a Apache 2.4 server and using http/2.
I configured Server push in the server :

```<code>Protocols h2 http/1.1
            DocumentRoot /var/www/html/
                    <Location /index.html>
              Header add Link "</img/2.jpg>; rel=preload"
             </Location>
</code>```

But the server pushed it but it still load this image,
  enter image description here

Hope someone could help me :). many thanks

答:
I just found the reason make it not work, when we use server push something like css, image, js...

We need identified the file we push.

```<code>Protocols h2 http/1.1
        DocumentRoot /var/www/html/
                <Location /index.html>
          Header add Link "</img/2.jpg>; rel=preload; as=image"
         </Location>
</code>```

Body:
I just setup a Apache 2.4 server and using http/2.
I configured Server push in the server :

Protocols h2 http/1.1
            DocumentRoot /var/www/html/
                    <Location /index.html>
              Header add Link "; rel=preload"
             </Location>

But the server pushed it but it still load this image,
  enter image description here

Hope someone could help me :). many thanks

Body:
I just found the reason make it not work, when we use server push something like css, image, js...

We need identified the file we push.

Protocols h2 http/1.1
        DocumentRoot /var/www/html/
                <Location /index.html>
          Header add Link "</img/2.jpg>; rel=preload; as=image"
         </Location>


问:
Pythonic way to check if: all elements evaluate to False -OR- all elements evaluate to True
I want the results of the function to be:

All values evaluate to False (None, 0, empty string) -> True

All values evaluate to True -> True

Every other case -> False

This is my try at it:

```<code>>>> def consistent(x):
...  x_filtered = filter(None, x)
...  return len(x_filtered) in (0, len(x))
...
>>> consistent((0,1))
False
>>> consistent((1,1))
True
>>> consistent((0,0))
True
</code>```

[Bonus]

What should this function be named?

答:
```<code>def unanimous(it):
  it1, it2 = itertools.tee(it)
  return all(it1) or not any(it2)
</code>```

ContentLicense: CC BY-SA 2.5

Body:
I want the results of the function to be:

All values evaluate to False (None, 0, empty string) -> True

All values evaluate to True -> True

Every other case -> False

This is my try at it:

>>> def consistent(x):
...  x_filtered = filter(None, x)
...  return len(x_filtered) in (0, len(x))
...
>>> consistent((0,1))
False
>>> consistent((1,1))
True
>>> consistent((0,0))
True

[Bonus]

What should this function be named?


问:
Retrieving data from array of array objects
In my application i am trying to return javascript object of employee who works in all projects. My array of data is like:

```<code>   var data = [
{
    projectName: "project1", projectId: 1,
    employees: [
        {fullName: "John Doe", employeeId: 1},
        {fullName: "Jane Smith", employeeId: 2}
    ]
},

{
    projectName: "project2", projectId: 2,
    employees: [
        {fullName: "John Doe", employeeId: 1},
        {fullName: "Mary Jones", employeeId: 3},
        {fullName: "Bill Evans", employeeId: 4}
    ]
}
</code>```

];

I need to search for employeeid 1 and return both projects. How do i search it.

答:
It can be as simple as this. Just iterate and compare.
https://jsfiddle.net/</p>

```<code>for( i=0;i<data.length;i++)
{
    for( j=0;j<data[i].employees.length;j++)
  {
     if (data[i].employees[j].employeeId == 1)
      console.log(data[i].projectId);
  }
}
</code>```

Body:
In my application i am trying to return javascript object of employee who works in all projects. My array of data is like:

   var data = [
{
    projectName: "project1", projectId: 1,
    employees: [
        {fullName: "John Doe", employeeId: 1},
        {fullName: "Jane Smith", employeeId: 2}
    ]
},

{
    projectName: "project2", projectId: 2,
    employees: [
        {fullName: "John Doe", employeeId: 1},
        {fullName: "Mary Jones", employeeId: 3},
        {fullName: "Bill Evans", employeeId: 4}
    ]
}

];

I need to search for employeeid 1 and return both projects. How do i search it.

Body:
It can be as simple as this. Just iterate and compare.
https://jsfiddle.net/

for( i=0;i<data.length;i++)
{
    for( j=0;j<data[i].employees.length;j++)
  {
     if (data[i].employees[j].employeeId == 1)
      console.log(data[i].projectId);
  }
}


问:
How to unmount an Azure File Share
I've got a Windows Server VM on Azure. I also have a File Share. According to the MS documentation, one can mount the drive using the following command:

```<code>net use <drive-letter>: \\<storage-account-name>.file.core.windows.net\<share-name>
</code>```

This does indeed work.

Unfortunately, the documentation makes no mention of how to unmount the storage...

Does anyone know how to do this?

答:
To unmount a File Share drive, simply use:

```<code>net use <drive-letter> /delete
</code>```

This will detach the drive.

ContentLicense: CC BY-SA 4.0

Title: How to unmount an Azure File Share

Body:
I've got a Windows Server VM on Azure. I also have a File Share. According to the MS documentation, one can mount the drive using the following command:

net use <drive-letter>: \\<storage-account-name>.file.core.windows.net\<share-name>

This does indeed work.

Unfortunately, the documentation makes no mention of how to unmount the storage...

Does anyone know how to do this?

Body:
To unmount a File Share drive, simply use:

net use <drive-letter> /delete

This will detach the drive.


问:
Batch Mode and Custom Error Handling in Spring Cloud Stream
Before I started to use Spring Cloud Stream, I was using Spring-Kafka and its support for batch consumption and custom error handling. Notice the last two lines of this snippet:

```<code>        ConcurrentKafkaListenerContainerFactory<String, byte[]> factory = new ConcurrentKafkaListenerContainerFactory<>();
    factory.setConcurrency(this.consumerConfigurationProperties.getConsumer().get(TOPIC_AG_TASK_EMPP).getConcurrency());
    factory.setConsumerFactory(consumerFactory);
    factory.setMessageConverter(avroMessageConverter);
    factory.getContainerProperties().setPollTimeout(this.consumerConfigurationProperties.getConsumer().get(TOPIC_AG_TASK_EMPP).getPollTimeout());
    factory.getContainerProperties().setPauseEnabled(true);
    factory.getContainerProperties().setAckMode(AbstractMessageListenerContainer.AckMode.BATCH);
    factory.getContainerProperties().setErrorHandler(dlqAGTaskErrorHandler);
</code>```

However, with Spring Cloud Stream I cannot find how to configure this. I can only find these configuration properties:

spring.cloud.stream.kafka.bindings.input.consumer.autoCommitOffset, enableDlq

Therefore, is it (would it be) possible to register a custom error handler and also set the AckMode to BATCH in Spring Cloud Stream?

Thanks for your support.

答:
Currently we don't support these options yet at Spring Cloud Stream Level. The following issues should provide equivalent options once implemented (possibly as soon as Chelsea.RC1):

https://github.com/spring-cloud/spring-cloud-stream-binder-kafka/issues/70

https://github.com/spring-cloud/spring-cloud-stream/issues/538

Body:
Before I started to use Spring Cloud Stream, I was using Spring-Kafka and its support for batch consumption and custom error handling. Notice the last two lines of this snippet:

        ConcurrentKafkaListenerContainerFactory<String, byte[]> factory = new ConcurrentKafkaListenerContainerFactory<>();
    factory.setConcurrency(this.consumerConfigurationProperties.getConsumer().get(TOPIC_AG_TASK_EMPP).getConcurrency());
    factory.setConsumerFactory(consumerFactory);
    factory.setMessageConverter(avroMessageConverter);
    factory.getContainerProperties().setPollTimeout(this.consumerConfigurationProperties.getConsumer().get(TOPIC_AG_TASK_EMPP).getPollTimeout());
    factory.getContainerProperties().setPauseEnabled(true);
    factory.getContainerProperties().setAckMode(AbstractMessageListenerContainer.AckMode.BATCH);
    factory.getContainerProperties().setErrorHandler(dlqAGTaskErrorHandler);

However, with Spring Cloud Stream I cannot find how to configure this. I can only find these configuration properties:

spring.cloud.stream.kafka.bindings.input.consumer.autoCommitOffset, enableDlq

Therefore, is it (would it be) possible to register a custom error handler and also set the AckMode to BATCH in Spring Cloud Stream?

Thanks for your support.


问:
ReplayKit crashes app on an iOS 8 phone
I incorporated ReplayKit in my app with Xcode 7. When I tried to overwrite an existing version of my app on an iOS 8 mobile phone (developed with Xcode 6), it hanged with the following error.

dyld: Library not loaded: /System/Library/Frameworks/ReplayKit.framework/ReplayKit
    Referenced from: /private/var/mobile/Containers/Bundle/Application/6F141C8C-AFB3-41B7-8C27-68CD00E7786F/xxx.app/xxx
    Reason: image not found

May I know if it is because I can only import ReplayKit for iOS 9? If so, what should I do? Currently, I just

```<code>import ReplayKit
</code>```

Thank you in advance.

答: You need to open Build Phases for your target change the Link Binary with Libraries status to Optional for ReplayKit. This allows the app to run even when the ReplayKit framework is unavailable.

Title: ReplayKit crashes app on an iOS 8 phone

Body:
I incorporated ReplayKit in my app with Xcode 7. When I tried to overwrite an existing version of my app on an iOS 8 mobile phone (developed with Xcode 6), it hanged with the following error.

dyld: Library not loaded: /System/Library/Frameworks/ReplayKit.framework/ReplayKit
    Referenced from: /private/var/mobile/Containers/Bundle/Application/6F141C8C-AFB3-41B7-8C27-68CD00E7786F/xxx.app/xxx
    Reason: image not found

May I know if it is because I can only import ReplayKit for iOS 9? If so, what should I do? Currently, I just

import ReplayKit

Thank you in advance.


问:
Field data type / validations questions
I have few questions on what data types to use and how to define some fields from my site. My current schema is in MySQL but in process of changing to PostregSQL.

First & Last name -> Since I have multi-lang, tables all support UTF-8, but do i need to declare them as nvarchar in-case a user enters a Chinese name? If so, how do i enforce field validation if it is set to accept alphabets only as i assume those are English alphabets and not validating for valid chinese or arabic alphabets? And i don't think PostregSQL supports nvarchar anyways?

To store current time line - > Example I work in company A from Jan 2009 to Present. So i assume there will be 3 field for this: timeline_to, timeline_from, time_line present where to & from are month/year varchars and present is just a flag to set the current date?

User passwords. i am using SHA 256 + salting. so i have 2 fields declared as follows:

password_hash - varchar (64)

password_salt-  varchar (64)

Does this work if the user password needs to be between 8 and 32 chars long?

birth time -> I need to record birth time for the application to calculate some astrological values. so that means hour, minute and am/pm. So best to store these are 3 separate single select lists with varchar or use a time data type in the back end and allow users to use single select list in front end?

Lastly for birth month and year only, are these int or varchar if i store them in separate rows? They all have primary keys of int for reporting purposes so int makes more sense? or should i store them in 1 field only as date type?

答:
NCHAR, not NVARCHAR.

Never make anything variable that you can make fixed; it is an added burden to pack/unpack on every access.  Which means never, ever use var for indexed columns, you will have a very sluggish index.  Disk space is cheap these days.

you need a Language column at the Person level that tells you what language to use in your various parsing and validation requirements.

Let's say you have Person, Employer, and Employment tables.  The columns you discuss are in Employment.

you need a StartDate column and EndDate column, they are DATETIME datatype.

You do not need "present" as a separate column. "Present" is always the value of the newest Employment row, unless set to something different.  Set a Default of the highest date the db can handle, eg. 9999-12-31; which can be overridden by an explicit entry.

No.  You only need one CHAR(256) column.  Hank has explained it.

For any component of a date or time, use the DATETIME datatype.  That is what it is there for.  The database handles it consistently, and indexes it perfectly.  You perform DATE arithmetic on it, using db various functions().  And you avoid all the problems of coding it as INTs, etc (no invalid dates or times allowed).

BirthDateTime is one DATETIME column.

Title: Field data type / validations questions


答:
Just hookup the fadeOut into the click event when you are calling fadeIn.

```<code>$('#fadeContent').click(function(){
    $('#bodyContent').click(function() {
       $(this).fadeOut(500);
    }).fadeIn(500);
});
</code>```

EDIT

The code above will keeping connecting the event handler every time you click the button. On the assumption that all your buttons will load and show content and clicking the content should always return to the buttons consider;

```<code>var $content = $('#bodyContent');
$('body').on('click','button', function() {
    $content.fadeIn(500);
});
$content.on('click', function() {
   $content.fadeOut(500);
});
</code>```

You can then attach click events for the individual buttons to retrieve and assign the specific content into #bodyContent without also having to hook in the fadeIn/fadeOut.

Title: How can I make a div fade out when it is clicked?

Body:
Just hookup the fadeOut into the click event when you are calling fadeIn.

$('#fadeContent').click(function(){
    $('#bodyContent').click(function() {
       $(this).fadeOut(500);
    }).fadeIn(500);
});

EDIT

The code above will keeping connecting the event handler every time you click the button. On the assumption that all your buttons will load and show content and clicking the content should always return to the buttons consider;

var $content = $('#bodyContent');
$('body').on('click','button', function() {
    $content.fadeIn(500);
});
$content.on('click', function() {
   $content.fadeOut(500);
});

You can then attach click events for the individual buttons to retrieve and assign the specific content into #bodyContent without also having to hook in the fadeIn/fadeOut.


问:
Exception in spark java
I am reading a directory of text files from my local machine in spark. I am getting the following exception when I run it using spark-submit

```<code>Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
17/03/30 01:15:22 INFO SparkContext: Running Spark version 2.1.0
17/03/30 01:15:23 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
17/03/30 01:15:23 WARN Utils: Your hostname, Inspiron-N4050 resolves to a loopback address: 127.0.1.1; using 192.168.43.249 instead (on interface wlp9s0)
17/03/30 01:15:23 WARN Utils: Set SPARK_LOCAL_IP if you need to bind to another address
17/03/30 01:15:23 INFO SecurityManager: Changing view acls to: shakeel
17/03/30 01:15:23 INFO SecurityManager: Changing modify acls to: shakeel
17/03/30 01:15:23 INFO SecurityManager: Changing view acls groups to:
17/03/30 01:15:23 INFO SecurityManager: Changing modify acls groups to:
17/03/30 01:15:23 INFO SecurityManager: SecurityManager: authentication disabled; ui acls disabled; users  with view permissions: Set(shakeel); groups with view permissions: Set(); users  with modify permissions: Set(shakeel); groups with modify permissions: Set()
17/03/30 01:15:23 INFO Utils: Successfully started service 'sparkDriver' on port 35160.
17/03/30 01:15:23 INFO SparkEnv: Registering MapOutputTracker
17/03/30 01:15:23 INFO SparkEnv: Registering BlockManagerMaster
17/03/30 01:15:23 INFO BlockManagerMasterEndpoint: Using org.apache.spark.storage.DefaultTopologyMapper for getting topology information
17/03/30 01:15:23 INFO BlockManagerMasterEndpoint: BlockManagerMasterEndpoint up
17/03/30 01:15:23 INFO DiskBlockManager: Created local directory at /tmp/blockmgr-ea876e3a-fd03-47df-b492-b6deccffe77d
17/03/30 01:15:23 INFO MemoryStore: MemoryStore started with capacity 366.3 MB
17/03/30 01:15:23 INFO SparkEnv: Registering OutputCommitCoordinator
17/03/30 01:15:24 INFO Utils: Successfully started service 'SparkUI' on port 4040.
17/03/30 01:15:24 INFO SparkUI: Bound SparkUI to 0.0.0.0, and started at http://192.168.43.249:4040
17/03/30 01:15:24 INFO SparkContext: Added JAR file:/home/shakeel/workspace/geneselection/target/geneselection-0.0.1-SNAPSHOT.jar at spark://192.168.43.249:35160/jars/geneselection-0.0.1-SNAPSHOT.jar with timestamp 1490816724265
17/03/30 01:15:24 INFO Executor: Starting executor ID driver on host localhost
17/03/30 01:15:24 INFO Utils: Successfully started service 'org.apache.spark.network.netty.NettyBlockTransferService' on port 40585.
17/03/30 01:15:24 INFO NettyBlockTransferService: Server created on 192.168.43.249:40585
17/03/30 01:15:24 INFO BlockManager: Using org.apache.spark.storage.RandomBlockReplicationPolicy for block replication policy
17/03/30 01:15:24 INFO BlockManagerMaster: Registering BlockManager BlockManagerId(driver, 192.168.43.249, 40585, None)
17/03/30 01:15:24 INFO BlockManagerMasterEndpoint: Registering block manager 192.168.43.249:40585 with 366.3 MB RAM, BlockManagerId(driver, 192.168.43.249, 40585, None)
17/03/30 01:15:24 INFO BlockManagerMaster: Registered BlockManager BlockManagerId(driver, 192.168.43.249, 40585, None)
17/03/30 01:15:24 INFO BlockManager: Initialized BlockManager: BlockManagerId(driver, 192.168.43.249, 40585, None)
Exception in thread "main" java.lang.ExceptionInInitializerError
    at org.apache.spark.SparkContext.withScope(SparkContext.scala:701)
    at org.apache.spark.SparkContext.wholeTextFiles(SparkContext.scala:858)
    at org.apache.spark.api.java.JavaSparkContext.wholeTextFiles(JavaSparkContext.scala:224)
    at geneselection.AttributeSelector.run(AttributeSelector.java:229)
    at geneselection.AttributeSelector.main(AttributeSelector.java:213)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:738)
    at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:187)
    at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:212)
    at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:126)
    at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Incompatible Jackson version: 2.7.5
    at com.fasterxml.jackson.module.scala.JacksonModule$class.setupModule(JacksonModule.scala:64)
    at com.fasterxml.jackson.module.scala.DefaultScalaModule.setupModule(DefaultScalaModule.scala:19)
    at com.fasterxml.jackson.databind.ObjectMapper.registerModule(ObjectMapper.java:730)
    at org.apache.spark.rdd.RDDOperationScope$.<init>(RDDOperationScope.scala:82)
    at org.apache.spark.rdd.RDDOperationScope$.<clinit>(RDDOperationScope.scala)
    ... 14 more
17/03/30 01:15:24 INFO SparkContext: Invoking stop() from shutdown hook
17/03/30 01:15:24 INFO SparkUI: Stopped Spark web UI at http://192.168.43.249:4040
17/03/30 01:15:24 INFO MapOutputTrackerMasterEndpoint: MapOutputTrackerMasterEndpoint stopped!
17/03/30 01:15:24 INFO MemoryStore: MemoryStore cleared
17/03/30 01:15:24 INFO BlockManager: BlockManager stopped
17/03/30 01:15:24 INFO BlockManagerMaster: BlockManagerMaster stopped
17/03/30 01:15:24 INFO OutputCommitCoordinator$OutputCommitCoordinatorEndpoint: OutputCommitCoordinator stopped!
17/03/30 01:15:24 INFO SparkContext: Successfully stopped SparkContext
17/03/30 01:15:24 INFO ShutdownHookManager: Shutdown hook called
17/03/30 01:15:24 INFO ShutdownHookManager: Deleting directory /tmp/spark-966721ae-388b-476b-972e-8e108c1454d9
</code>```

I have no idea why this occurs. There are some csv files in a directory in my computer. The code the produces this exception is

```<code>public void run(String path){
        String master = "local[*]";
        SparkConf conf = new SparkConf().setAppName(AttributeSelector.class.getName()).setMaster(master);
        JavaSparkContext context = new JavaSparkContext(conf);
        try {

            context.wholeTextFiles("/home/shakeel/Parts/");
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("Loaded files");
        context.close();
    }
</code>```

I want to read the csv files and perform feature selection on each file and store the result from each file in a queue for further processing. Why am I getting this exception?

I tried running a sample word count application the same way and it works perfectly. Does this have something to do with the fact that the files are not plain text files but are csv files?

Any help is appreciated

答:
You're hitting Jackson version collisions.  In order to see where the incompatible version is coming from, run the following from the top level directory of your maven project (YOUR SCALA VERSION will be either 2.10 or 2.11).

```<code>mvn dependency:tree -Dverbose -Dincludes=com.fasterxml.jackson.module
</code>```

Then once you've found the dependency causing the issue, put this into your pom inside the dependency markers of the artifact in question.

```<code><exclusions>
    <exclusion>
      <groupId>com.fasterxml.jackson.module</groupId>
      <artifactId>jackson-module-scala_(YOUR SCALA VERSION)</artifactId>
    </exclusion>
</exclusions>
</code>```

Title: Exception in spark java

Body:
I am reading a directory of text files from my local machine in spark. I am getting the following exception when I run it using spark-submit

Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
17/03/30 01:15:22 INFO SparkContext: Running Spark version 2.1.0
17/03/30 01:15:23 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
17/03/30 01:15:23 WARN Utils: Your hostname, Inspiron-N4050 resolves to a loopback address: 127.0.1.1; using 192.168.43.249 instead (on interface wlp9s0)
17/03/30 01:15:23 WARN Utils: Set SPARK_LOCAL_IP if you need to bind to another address
17/03/30 01:15:23 INFO SecurityManager: Changing view acls to: shakeel
17/03/30 01:15:23 INFO SecurityManager: Changing modify acls to: shakeel
17/03/30 01:15:23 INFO SecurityManager: Changing view acls groups to:
17/03/30 01:15:23 INFO SecurityManager: Changing modify acls groups to:
17/03/30 01:15:23 INFO SecurityManager: SecurityManager: authentication disabled; ui acls disabled; users  with view permissions: Set(shakeel); groups with view permissions: Set(); users  with modify permissions: Set(shakeel); groups with modify permissions: Set()
17/03/30 01:15:23 INFO Utils: Successfully started service 'sparkDriver' on port 35160.
17/03/30 01:15:23 INFO SparkEnv: Registering MapOutputTracker
17/03/30 01:15:23 INFO SparkEnv: Registering BlockManagerMaster
17/03/30 01:15:23 INFO BlockManagerMasterEndpoint: Using org.apache.spark.storage.DefaultTopologyMapper for getting topology information
17/03/30 01:15:23 INFO BlockManagerMasterEndpoint: BlockManagerMasterEndpoint up
17/03/30 01:15:23 INFO DiskBlockManager: Created local directory at /tmp/blockmgr-ea876e3a-fd03-47df-b492-b6deccffe77d
17/03/30 01:15:23 INFO MemoryStore: MemoryStore started with capacity 366.3 MB
17/03/30 01:15:23 INFO SparkEnv: Registering OutputCommitCoordinator
17/03/30 01:15:24 INFO Utils: Successfully started service 'SparkUI' on port 4040.
17/03/30 01:15:24 INFO SparkUI: Bound SparkUI to 0.0.0.0, and started at http://192.168.43.249:4040
17/03/30 01:15:24 INFO SparkContext: Added JAR file:/home/shakeel/workspace/geneselection/target/geneselection-0.0.1-SNAPSHOT.jar at spark://192.168.43.249:35160/jars/geneselection-0.0.1-SNAPSHOT.jar with timestamp 1490816724265
17/03/30 01:15:24 INFO Executor: Starting executor ID driver on host localhost
17/03/30 01:15:24 INFO Utils: Successfully started service 'org.apache.spark.network.netty.NettyBlockTransferService' on port 40585.
17/03/30 01:15:24 INFO NettyBlockTransferService: Server created on 192.168.43.249:40585
17/03/30 01:15:24 INFO BlockManager: Using org.apache.spark.storage.RandomBlockReplicationPolicy for block replication policy
17/03/30 01:15:24 INFO BlockManagerMaster: Registering BlockManager BlockManagerId(driver, 192.168.43.249, 40585, None)
17/03/30 01:15:24 INFO BlockManagerMasterEndpoint: Registering block manager 192.168.43.249:40585 with 366.3 MB RAM, BlockManagerId(driver, 192.168.43.249, 40585, None)
17/03/30 01:15:24 INFO BlockManagerMaster: Registered BlockManager BlockManagerId(driver, 192.168.43.249, 40585, None)
17/03/30 01:15:24 INFO BlockManager: Initialized BlockManager: BlockManagerId(driver, 192.168.43.249, 40585, None)
Exception in thread "main" java.lang.ExceptionInInitializerError
    at org.apache.spark.SparkContext.withScope(SparkContext.scala:701)
    at org.apache.spark.SparkContext.wholeTextFiles(SparkContext.scala:858)
    at org.apache.spark.api.java.JavaSparkContext.wholeTextFiles(JavaSparkContext.scala:224)
    at geneselection.AttributeSelector.run(AttributeSelector.java:229)
    at geneselection.AttributeSelector.main(AttributeSelector.java:213)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:738)
    at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:187)
    at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:212)
    at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:126)
    at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Incompatible Jackson version: 2.7.5
    at com.fasterxml.jackson.module.scala.JacksonModule$class.setupModule(JacksonModule.scala:64)
    at com.fasterxml.jackson.module.scala.DefaultScalaModule.setupModule(DefaultScalaModule.scala:19)
    at com.fasterxml.jackson.databind.ObjectMapper.registerModule(ObjectMapper.java:730)
    at org.apache.spark.rdd.RDDOperationScope$.<init>(RDDOperationScope.scala:82)
    at org.apache.spark.rdd.RDDOperationScope$.<clinit>(RDDOperationScope.scala)
    ... 14 more
17/03/30 01:15:24 INFO SparkContext: Invoking stop() from shutdown hook
17/03/30 01:15:24 INFO SparkUI: Stopped Spark web UI at http://192.168.43.249:4040
17/03/30 01:15:24 INFO MapOutputTrackerMasterEndpoint: MapOutputTrackerMasterEndpoint stopped!
17/03/30 01:15:24 INFO MemoryStore: MemoryStore cleared
17/03/30 01:15:24 INFO BlockManager: BlockManager stopped
17/03/30 01:15:24 INFO BlockManagerMaster: BlockManagerMaster stopped
17/03/30 01:15:24 INFO OutputCommitCoordinator$OutputCommitCoordinatorEndpoint: OutputCommitCoordinator stopped!
17/03/30 01:15:24 INFO SparkContext: Successfully stopped SparkContext
17/03/30 01:15:24 INFO ShutdownHookManager: Shutdown hook called
17/03/30 01:15:24 INFO ShutdownHookManager: Deleting directory /tmp/spark-966721ae-388b-476b-972e-8e108c1454d9

I have no idea why this occurs. There are some csv files in a directory in my computer. The code the produces this exception is

public void run(String path){
        String master = "local[*]";
        SparkConf conf = new SparkConf().setAppName(AttributeSelector.class.getName()).setMaster(master);
        JavaSparkContext context = new JavaSparkContext(conf);
        try {

            context.wholeTextFiles("/home/shakeel/Parts/");
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("Loaded files");
        context.close();
    }

I want to read the csv files and perform feature selection on each file and store the result from each file in a queue for further processing. Why am I getting this exception?

I tried running a sample word count application the same way and it works perfectly. Does this have something to do with the fact that the files are not plain text files but are csv files?

Any help is appreciated

Body:
You're hitting Jackson version collisions.  In order to see where the incompatible version is coming from, run the following from the top level directory of your maven project (YOUR SCALA VERSION will be either 2.10 or 2.11).

mvn dependency:tree -Dverbose -Dincludes=com.fasterxml.jackson.module

Then once you've found the dependency causing the issue, put this into your pom inside the dependency markers of the artifact in question.

<exclusions>
    <exclusion>
      <groupId>com.fasterxml.jackson.module</groupId>
      <artifactId>jackson-module-scala_(YOUR SCALA VERSION)</artifactId>
    </exclusion>
</exclusions>


问:
Function vs Method for map, filter, reduce
What are the advantages of one over the other?

Why languages like Swift and JavaScript decided to go with the method route?

I know I can do like Haskell and only have functions with operators to make it as readable as methods (when chaining), so why those languages went with methods?

EDIT: To clarify what I mean by "method route"

Collections in those languages have methods like map, filter and reduce, rather than having those as separate functions.

i.e., you'd use it like this:

[1, 2, 3].map(...) rather than map(...)([1, 2, 3])

答:
I think one of the reason could be that languages like Swift and JavaScript are object-oriented languages. And object has methods, otherwise, there are no reasons to use objects at all. Languages like Haskell are functional programming languages, and they rely less on objects (some of them does not have objects at all, like clojure). So the question is why some of them are OO languages, and some are functional programming languages. I think because OO language and functional programming language both have their plus sides. Like in OO languages, you can achieve good design principle. And functional programming language is very good for multi-threading problems. So some choose this route and some choose the other.

But what's more important, languages are trying to be both object-oriented and functional. For example, both Swift and Javascript, they have closure, lambda, functions-as-first-class-object, immutability, etc. I think the border between oo language and functional language will become more and more blur. Even Java, which many people believe is one of the most object-oriented (Java has less functional language feature supported), has lambda now.

So it doesn't matter which route a language goes as it doesn't matter which language you uses (sometimes it does matter, especially one has higher performance demand).

I try to comment my thought here, but obviously, I exceed the maximum character limit. This won't be the only answer but hope it helps.


问:
Using salesforce metadata api with C#
How can I create salesforce metadata connection using C#?
Thanks in advance.</p>

答:
A Metadata API example using Enterprise API. The trick is to change the login session header using Enterprise API to MetaAPI client

```<code>        string username = "username";
        string password = "password";

        // Create a SoapClient specifically for logging in
        loginClient = new SoapClient();

        LoginResult lr = null;
        try
        {
            Console.WriteLine("\nLogging in...\n");
            lr = loginClient.login(null, username, password);
        }
        catch (Exception e)
        {
            // Write the fault message to the console
            Console.WriteLine("An unexpected error has occurred: " + e.Message);

            // Write the stack trace to the console
            Console.WriteLine(e.StackTrace);
        }

        // Check if the password has expired
        if (lr.passwordExpired)
        {
            Console.WriteLine("An error has occurred. Your password has expired.");
        }

        // end point
        endpoint = new EndpointAddress(lr.metadataServerUrl);
        Console.WriteLine("End point: " + endpoint.Uri);

        // session header
        Metadata.SessionHeader metaSession = new Metadata.SessionHeader();
        metaSession.sessionId = lr.sessionId;

        MetadataPortTypeClient client = new MetadataPortTypeClient("Metadata", endpoint);
        CallOptions callOptions = new CallOptions();
        callOptions.client = lr.userId;

        ListMetadataQuery q = new ListMetadataQuery();
        q.type = "CustomObject";
        FileProperties[] fs = client.listMetadata(metaSession, callOptions, new []{ q} , 39.0);
        foreach (FileProperties f in fs)
        {
            Console.WriteLine("response with message: " + f.fileName);
            Console.WriteLine("response with message: " + f.fullName);
        }
</code>```

Title: Using salesforce metadata api with C#

Body:
A Metadata API example using Enterprise API. The trick is to change the login session header using Enterprise API to MetaAPI client

        string username = "username";
        string password = "password";

        // Create a SoapClient specifically for logging in
        loginClient = new SoapClient();

        LoginResult lr = null;
        try
        {
            Console.WriteLine("\nLogging in...\n");
            lr = loginClient.login(null, username, password);
        }
        catch (Exception e)
        {
            // Write the fault message to the console
            Console.WriteLine("An unexpected error has occurred: " + e.Message);

            // Write the stack trace to the console
            Console.WriteLine(e.StackTrace);
        }

        // Check if the password has expired
        if (lr.passwordExpired)
        {
            Console.WriteLine("An error has occurred. Your password has expired.");
        }

        // end point
        endpoint = new EndpointAddress(lr.metadataServerUrl);
        Console.WriteLine("End point: " + endpoint.Uri);

        // session header
        Metadata.SessionHeader metaSession = new Metadata.SessionHeader();
        metaSession.sessionId = lr.sessionId;

        MetadataPortTypeClient client = new MetadataPortTypeClient("Metadata", endpoint);
        CallOptions callOptions = new CallOptions();
        callOptions.client = lr.userId;

        ListMetadataQuery q = new ListMetadataQuery();
        q.type = "CustomObject";
        FileProperties[] fs = client.listMetadata(metaSession, callOptions, new []{ q} , 39.0);
        foreach (FileProperties f in fs)
        {
            Console.WriteLine("response with message: " + f.fileName);
            Console.WriteLine("response with message: " + f.fullName);
        }


问:
Galen Framework for Windows 7
I'm pretty novice to galen framework, and the guy (developer) of it explains everything indistinctly so I can't understand anything. I'm a Windows(7) man, so where do I create the file so called home-spec? Is it notepad++? Or Office Word file? And how I integrate it with Selenium? Thanks for response in advance.  </p>

答:
use npm:

1) npm install -g galenframework-cli

2) then galen config

3) adjust the config to match your drivers etc

4) then run galen home-spec

but seriously if you asking about whether to create the file in notepad++ or word, spend at least a night learning about IDEs.

Title: Galen Framework for Windows 7


问:
I'm having issues with this code its for a card game called war
I'm having issues with this code its for a card game called war, the error says "Line: 53: setText() text parameter value (undefined) is not a uistring"
and I tried editing the code in a whole new way and it's keeps saying it.  </p>

```<code>var A=14;
var J=11;
var Q=12;
var K=13;
var cards = [A, "2", "3","4","5","6","7","8","9","10",J,Q,K ,A, "2", "3","4","5","6","7","8","9","10",J,Q,K,A, "2", "3","4","5","6","7","8","9","10",J,Q,K,A, "2", "3","4","5","6","7","8","9","10",J,Q,K,];
var PlayerCards=[];
var AICards = [];
var playerScore = 0;
var AIScore = 0;
var aArr =0 ;
var pArr = 0;
cards = shuffle(cards);
dealPlayerCards();
dealAICards();
onEvent("War", "click", function(event) {
 setScreen("gameGrounds");
 });
onEvent("flipcard","click",function(event){
game();
playerScore= playerScore;
AIScore= AIScore;
aArr = aArr +1;
pArr = pArr +1;
winLose();
});
function shuffle(array) {
  var currentIndex = array.length, temporaryValue, randomIndex;
  while (0 !== currentIndex) {
    randomIndex = Math.floor(Math.random() * currentIndex);
    currentIndex -= 1;
    temporaryValue = array[currentIndex];
    array[currentIndex] = array[randomIndex];
    array[randomIndex] = temporaryValue;
  }
  return array;
}
function dealPlayerCards(){
for (var i = 0; i<= 25; i++) {
var chooseCard = randomNumber(0,cards.length-1);
appendItem(PlayerCards,cards[chooseCard]);
removeItem(cards,chooseCard);
  }
}
function dealAICards(){
for (var i = 0; i<= 25; i++) {
var chooseCard = randomNumber(0,cards.length-1);
appendItem(AICards,cards[chooseCard]);
removeItem(cards,chooseCard);
  }
}
function game(){
setText("playerCard", PlayerCards[pArr]);
setText("aICards", AICards[aArr]);
if (PlayerCards[pArr] > AICards[aArr]){
     playerScore =playerScore+1;
  setText("playersScore",playerScore);
}
    else{
      AIScore =AIScore+1;
  setText("AIsScore", AIScore);
}
return;
}
function winLose(){
  if(playerScore >= 17){
  setScreen("win");
}
if(AIScore >=17 ){
  setScreen("lost");
}
}
</code>```

答:
```<code>var A = 14;
var J = 11;
var Q = 12;
var K = 13;
var cards = [A, "2", "3", "4", "5", "6", "7", "8", "9", "10", J, Q, K, A, "2", "3", "4", "5", "6", "7", "8", "9", "10", J, Q, K, A, "2", "3", "4", "5", "6", "7", "8", "9", "10", J, Q, K, A, "2", "3", "4", "5", "6", "7", "8", "9", "10", J, Q, K,];
</code>```

A, J, Q, and K are numbers. Putting them in the array cards doesn't make them into strings. you need to declare them in quotes (e.g. var A = "14").

You get the error on line 53 because you assign cards to the AI, some of which are numbers, and then try to output the values form the AI's hand... and at this point you still have numbers, not strings.

Body:
I'm having issues with this code its for a card game called war, the error says "Line: 53: setText() text parameter value (undefined) is not a uistring"
and I tried editing the code in a whole new way and it's keeps saying it.

var A=14;
var J=11;
var Q=12;
var K=13;
var cards = [A, "2", "3","4","5","6","7","8","9","10",J,Q,K ,A, "2", "3","4","5","6","7","8","9","10",J,Q,K,A, "2", "3","4","5","6","7","8","9","10",J,Q,K,A, "2", "3","4","5","6","7","8","9","10",J,Q,K,];
var PlayerCards=[];
var AICards = [];
var playerScore = 0;
var AIScore = 0;
var aArr =0 ;
var pArr = 0;
cards = shuffle(cards);
dealPlayerCards();
dealAICards();
onEvent("War", "click", function(event) {
 setScreen("gameGrounds");
 });
onEvent("flipcard","click",function(event){
game();
playerScore= playerScore;
AIScore= AIScore;
aArr = aArr +1;
pArr = pArr +1;
winLose();
});
function shuffle(array) {
  var currentIndex = array.length, temporaryValue, randomIndex;
  while (0 !== currentIndex) {
    randomIndex = Math.floor(Math.random() * currentIndex);
    currentIndex -= 1;
    temporaryValue = array[currentIndex];
    array[currentIndex] = array[randomIndex];
    array[randomIndex] = temporaryValue;
  }
  return array;
}
function dealPlayerCards(){
for (var i = 0; i<= 25; i++) {
var chooseCard = randomNumber(0,cards.length-1);
appendItem(PlayerCards,cards[chooseCard]);
removeItem(cards,chooseCard);
  }
}
function dealAICards(){
for (var i = 0; i<= 25; i++) {
var chooseCard = randomNumber(0,cards.length-1);
appendItem(AICards,cards[chooseCard]);
removeItem(cards,chooseCard);
  }
}
function game(){
setText("playerCard", PlayerCards[pArr]);
setText("aICards", AICards[aArr]);
if (PlayerCards[pArr] > AICards[aArr]){
     playerScore =playerScore+1;
  setText("playersScore",playerScore);
}
    else{
      AIScore =AIScore+1;
  setText("AIsScore", AIScore);
}
return;
}
function winLose(){
  if(playerScore >= 17){
  setScreen("win");
}
if(AIScore >=17 ){
  setScreen("lost");
}
}

Body:
var A = 14;
var J = 11;
var Q = 12;
var K = 13;
var cards = [A, "2", "3", "4", "5", "6", "7", "8", "9", "10", J, Q, K, A, "2", "3", "4", "5", "6", "7", "8", "9", "10", J, Q, K, A, "2", "3", "4", "5", "6", "7", "8", "9", "10", J, Q, K, A, "2", "3", "4", "5", "6", "7", "8", "9", "10", J, Q, K,];

A, J, Q, and K are numbers. Putting them in the array cards doesn't make them into strings. you need to declare them in quotes (e.g. var A = "14").

You get the error on line 53 because you assign cards to the AI, some of which are numbers, and then try to output the values form the AI's hand... and at this point you still have numbers, not strings.


问:
Detecting If Object and Object From ArrayList Collide
I am in the process of writing a program for a java mini-game. I need to determine if two objects collide. One of the object is just of type Player (one single object) with the name of player and the other is part of an arrayList of object type Enemy with the name of the arrayList being enemies. I know that I can use the intersect() function because they both extend Rectangle. However, I am wondering what exactly the syntax of this statement would be? i.e. - player.intersect(enemies). However, this does not seem to be correct?

答:
Because enemies is a list, you can't directly call intersect on the list. What you can do instead is loop through the list:

```<code>static boolean anyEnemyCollides(Player player, List<Enemy> enemies) {
    for  (Enemy enemy : enemies) {
        if  (player.intersect(enemy)) {
            return true;
        }
    }
    return false;
}
</code>```

Edit:

I should also mention that if you're using guava, you can do:

```<code>Iterables.any(enemies, (enemy) -> player.intersect(enemy));
</code>```

Body:
Because enemies is a list, you can't directly call intersect on the list. What you can do instead is loop through the list:

static boolean anyEnemyCollides(Player player, List<Enemy> enemies) {
    for  (Enemy enemy : enemies) {
        if  (player.intersect(enemy)) {
            return true;
        }
    }
    return false;
}

Edit:

I should also mention that if you're using guava, you can do:

Iterables.any(enemies, (enemy) -> player.intersect(enemy));


问:
oozie 4.3.0 build failed
I need to use sqoop-1.4.6 arguments to export hive table to mysql, where the hive table has two partitionings. but I found out that the oozie share lib on my hadoop cluster only supports sqoop-1.4.3.  So I try to build and create share lib fits our version specs.

I modified the oozie pom.xml as the case of our cluster master node, but build failed if I made the following two changes:

If I change the hive version, Ln 92, from <hive.version>1.2.0</hive.version> to <hive.version>2.1.0</hive.version>, I get the following error:

Blockquote

```<code>[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Apache Oozie Main .................................. SUCCESS [  0.991 s]
[INFO] Apache Oozie Hadoop Utils hadoop-2-4.3.0 ........... SUCCESS [  1.843 s]
[INFO] Apache Oozie Hadoop Distcp hadoop-2-4.3.0 .......... SUCCESS [  0.215 s]
[INFO] Apache Oozie Hadoop Auth hadoop-2-4.3.0 Test ....... SUCCESS [  0.432 s]
[INFO] Apache Oozie Hadoop Libs ........................... SUCCESS [  0.017 s]
[INFO] Apache Oozie Client ................................ SUCCESS [ 12.492 s]
[INFO] Apache Oozie Share Lib Oozie ....................... SUCCESS [  1.868 s]
[INFO] Apache Oozie Share Lib HCatalog .................... SUCCESS [  8.001 s]
[INFO] Apache Oozie Share Lib Distcp ...................... SUCCESS [  0.733 s]
[INFO] Apache Oozie Core .................................. FAILURE [ 16.672 s]
[INFO] Apache Oozie Share Lib Streaming ................... SKIPPED
[INFO] Apache Oozie Share Lib Pig ......................... SKIPPED
[INFO] Apache Oozie Share Lib Hive ........................ SKIPPED
[INFO] Apache Oozie Share Lib Hive 2 ...................... SKIPPED
[INFO] Apache Oozie Share Lib Sqoop ....................... SKIPPED
[INFO] Apache Oozie Examples .............................. SKIPPED
[INFO] Apache Oozie Share Lib Spark ....................... SKIPPED
[INFO] Apache Oozie Share Lib ............................. SKIPPED
[INFO] Apache Oozie Docs .................................. SKIPPED
[INFO] Apache Oozie WebApp ................................ SKIPPED
[INFO] Apache Oozie Tools ................................. SKIPPED
[INFO] Apache Oozie MiniOozie ............................. SKIPPED
[INFO] Apache Oozie Distro ................................ SKIPPED
[INFO] Apache Oozie ZooKeeper Security Tests .............. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 44.067 s
[INFO] Finished at: 2017-03-27T17:36:56+08:00
[INFO] Final Memory: 193M/1464M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:testCompile (default-testCompile) on project oozie-core: Compilation failure: Compilation failure:
[ERROR] /tmp/oozie-4.3.0/core/src/test/java/org/apache/oozie/sla/TestSLACalculatorMemory.java:[817,47] error: cannot find symbol
[ERROR] variable firstLogEntry of type LoggingEvent
[ERROR] /tmp/oozie-4.3.0/core/src/test/java/org/apache/oozie/sla/TestSLACalculatorMemory.java:[818,32] error: cannot find symbol
[ERROR] variable firstLogEntry of type LoggingEvent
[ERROR] /tmp/oozie-4.3.0/core/src/test/java/org/apache/oozie/sla/TestSLACalculatorMemory.java:[819,78] error: cannot find symbol
[ERROR] variable firstLogEntry of type LoggingEvent
[ERROR] /tmp/oozie-4.3.0/core/src/test/java/org/apache/oozie/service/TestEventHandlerService.java:[213,46] error: cannot find symbol
[ERROR] variable logEntry of type LoggingEvent
[ERROR] /tmp/oozie-4.3.0/core/src/test/java/org/apache/oozie/service/TestEventHandlerService.java:[214,31] error: cannot find symbol
[ERROR] variable logEntry of type LoggingEvent
[ERROR] /tmp/oozie-4.3.0/core/src/test/java/org/apache/oozie/service/TestEventHandlerService.java:[215,81] error: cannot find symbol
[ERROR] variable logEntry of type LoggingEvent
[ERROR] /tmp/oozie-4.3.0/core/src/test/java/org/apache/oozie/service/TestEventHandlerService.java:[221,46] error: cannot find symbol
[ERROR] variable logEntry of type LoggingEvent
[ERROR] /tmp/oozie-4.3.0/core/src/test/java/org/apache/oozie/service/TestEventHandlerService.java:[222,31] error: cannot find symbol
[ERROR] variable logEntry of type LoggingEvent
[ERROR] /tmp/oozie-4.3.0/core/src/test/java/org/apache/oozie/service/TestEventHandlerService.java:[231,31] error: cannot find symbol
[ERROR] variable logEntry of type LoggingEvent
[ERROR] /tmp/oozie-4.3.0/core/src/test/java/org/apache/oozie/service/TestEventHandlerService.java:[239,31] error: cannot find symbol
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :oozie-core
</code>```

If I change the hbase version, Ln 85, from <hbase.version>0.94.27</hbase.version> to <hbase.version>1.1.1</hbase.version>, I get the following error:

Blockquote

```<code>[INFO] ------------------------------------------------------------------------
[INFO] Building Apache Oozie Core 4.3.0
[INFO] ------------------------------------------------------------------------
Downloading: http://maven.aliyun.com/nexus/content/repositories/central/org/apache/hbase/hbase/1.1.1/hbase-1.1.1.jar
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Apache Oozie Main .................................. SUCCESS [  1.008 s]
[INFO] Apache Oozie Hadoop Utils hadoop-2-4.3.0 ........... SUCCESS [  1.869 s]
[INFO] Apache Oozie Hadoop Distcp hadoop-2-4.3.0 .......... SUCCESS [  0.094 s]
[INFO] Apache Oozie Hadoop Auth hadoop-2-4.3.0 Test ....... SUCCESS [  0.287 s]
[INFO] Apache Oozie Hadoop Libs ........................... SUCCESS [  0.026 s]
[INFO] Apache Oozie Client ................................ SUCCESS [ 14.418 s]
[INFO] Apache Oozie Share Lib Oozie ....................... SUCCESS [  2.331 s]
[INFO] Apache Oozie Share Lib HCatalog .................... SUCCESS [  2.478 s]
[INFO] Apache Oozie Share Lib Distcp ...................... SUCCESS [  0.728 s]
[INFO] Apache Oozie Core .................................. FAILURE [  0.755 s]
[INFO] Apache Oozie Share Lib Streaming ................... SKIPPED
[INFO] Apache Oozie Share Lib Pig ......................... SKIPPED
[INFO] Apache Oozie Share Lib Hive ........................ SKIPPED
[INFO] Apache Oozie Share Lib Hive 2 ...................... SKIPPED
[INFO] Apache Oozie Share Lib Sqoop ....................... SKIPPED
[INFO] Apache Oozie Examples .............................. SKIPPED
[INFO] Apache Oozie Share Lib Spark ....................... SKIPPED
[INFO] Apache Oozie Share Lib ............................. SKIPPED
[INFO] Apache Oozie Docs .................................. SKIPPED
[INFO] Apache Oozie WebApp ................................ SKIPPED
[INFO] Apache Oozie Tools ................................. SKIPPED
[INFO] Apache Oozie MiniOozie ............................. SKIPPED
[INFO] Apache Oozie Distro ................................ SKIPPED
[INFO] Apache Oozie ZooKeeper Security Tests .............. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 24.879 s
[INFO] Finished at: 2017-03-27T18:01:13+08:00
[INFO] Final Memory: 110M/1420M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project oozie-core: Could not resolve dependencies for project org.apache.oozie:oozie-core:jar:4.3.0: Could not find artifact org.apache.hbase:hbase:jar:1.1.1 in alimaven (http://maven.aliyun.com/nexus/content/repositories/central/) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :oozie-core
</code>```

I am using a near by maven central mirror with a proxy, but that shouldn't be the problem because I also tried the US mirror, result's the same.  And I've done my best to look up documentations, related posts, with no luck so far.

Please, some one, enlighten me please.

答:
I couldn't find a proper solution to the build problem, so I used an ugly workaround.  First untar oozie-sharelib-4.3.0.tar.gz, replace the libs causing problems for my application, then use oozie-setup.sh sharelib create -fs hdfs://<HDFS master node>:9000 -locallib oozie-sharelib-4.3.0.tar.gz to update share lib.

However this is also not the proper way, because then oozie asks for a seemingly endless list of jars.

I finally went back to using shell action to execute sqoop from bash, I had to solve a very strange jar version collision problem, which is by all means out of the scope of this quetion.

I hope the ugly workaroud may help someone in urgent situation.

Title: oozie 4.3.0 build failed

Body:
I need to use sqoop-1.4.6 arguments to export hive table to mysql, where the hive table has two partitionings. but I found out that the oozie share lib on my hadoop cluster only supports sqoop-1.4.3.  So I try to build and create share lib fits our version specs.

I modified the oozie pom.xml as the case of our cluster master node, but build failed if I made the following two changes:

If I change the hive version, Ln 92, from <hive.version>1.2.0</hive.version> to <hive.version>2.1.0</hive.version>, I get the following error:

Blockquote

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Apache Oozie Main .................................. SUCCESS [  0.991 s]
[INFO] Apache Oozie Hadoop Utils hadoop-2-4.3.0 ........... SUCCESS [  1.843 s]
[INFO] Apache Oozie Hadoop Distcp hadoop-2-4.3.0 .......... SUCCESS [  0.215 s]
[INFO] Apache Oozie Hadoop Auth hadoop-2-4.3.0 Test ....... SUCCESS [  0.432 s]
[INFO] Apache Oozie Hadoop Libs ........................... SUCCESS [  0.017 s]
[INFO] Apache Oozie Client ................................ SUCCESS [ 12.492 s]
[INFO] Apache Oozie Share Lib Oozie ....................... SUCCESS [  1.868 s]
[INFO] Apache Oozie Share Lib HCatalog .................... SUCCESS [  8.001 s]
[INFO] Apache Oozie Share Lib Distcp ...................... SUCCESS [  0.733 s]
[INFO] Apache Oozie Core .................................. FAILURE [ 16.672 s]
[INFO] Apache Oozie Share Lib Streaming ................... SKIPPED
[INFO] Apache Oozie Share Lib Pig ......................... SKIPPED
[INFO] Apache Oozie Share Lib Hive ........................ SKIPPED
[INFO] Apache Oozie Share Lib Hive 2 ...................... SKIPPED
[INFO] Apache Oozie Share Lib Sqoop ....................... SKIPPED
[INFO] Apache Oozie Examples .............................. SKIPPED
[INFO] Apache Oozie Share Lib Spark ....................... SKIPPED
[INFO] Apache Oozie Share Lib ............................. SKIPPED
[INFO] Apache Oozie Docs .................................. SKIPPED
[INFO] Apache Oozie WebApp ................................ SKIPPED
[INFO] Apache Oozie Tools ................................. SKIPPED
[INFO] Apache Oozie MiniOozie ............................. SKIPPED
[INFO] Apache Oozie Distro ................................ SKIPPED
[INFO] Apache Oozie ZooKeeper Security Tests .............. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 44.067 s
[INFO] Finished at: 2017-03-27T17:36:56+08:00
[INFO] Final Memory: 193M/1464M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:testCompile (default-testCompile) on project oozie-core: Compilation failure: Compilation failure:
[ERROR] /tmp/oozie-4.3.0/core/src/test/java/org/apache/oozie/sla/TestSLACalculatorMemory.java:[817,47] error: cannot find symbol
[ERROR] variable firstLogEntry of type LoggingEvent
[ERROR] /tmp/oozie-4.3.0/core/src/test/java/org/apache/oozie/sla/TestSLACalculatorMemory.java:[818,32] error: cannot find symbol
[ERROR] variable firstLogEntry of type LoggingEvent
[ERROR] /tmp/oozie-4.3.0/core/src/test/java/org/apache/oozie/sla/TestSLACalculatorMemory.java:[819,78] error: cannot find symbol
[ERROR] variable firstLogEntry of type LoggingEvent
[ERROR] /tmp/oozie-4.3.0/core/src/test/java/org/apache/oozie/service/TestEventHandlerService.java:[213,46] error: cannot find symbol
[ERROR] variable logEntry of type LoggingEvent
[ERROR] /tmp/oozie-4.3.0/core/src/test/java/org/apache/oozie/service/TestEventHandlerService.java:[214,31] error: cannot find symbol
[ERROR] variable logEntry of type LoggingEvent
[ERROR] /tmp/oozie-4.3.0/core/src/test/java/org/apache/oozie/service/TestEventHandlerService.java:[215,81] error: cannot find symbol
[ERROR] variable logEntry of type LoggingEvent
[ERROR] /tmp/oozie-4.3.0/core/src/test/java/org/apache/oozie/service/TestEventHandlerService.java:[221,46] error: cannot find symbol
[ERROR] variable logEntry of type LoggingEvent
[ERROR] /tmp/oozie-4.3.0/core/src/test/java/org/apache/oozie/service/TestEventHandlerService.java:[222,31] error: cannot find symbol
[ERROR] variable logEntry of type LoggingEvent
[ERROR] /tmp/oozie-4.3.0/core/src/test/java/org/apache/oozie/service/TestEventHandlerService.java:[231,31] error: cannot find symbol
[ERROR] variable logEntry of type LoggingEvent
[ERROR] /tmp/oozie-4.3.0/core/src/test/java/org/apache/oozie/service/TestEventHandlerService.java:[239,31] error: cannot find symbol
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :oozie-core

If I change the hbase version, Ln 85, from <hbase.version>0.94.27</hbase.version> to <hbase.version>1.1.1</hbase.version>, I get the following error:

Blockquote

[INFO] ------------------------------------------------------------------------
[INFO] Building Apache Oozie Core 4.3.0
[INFO] ------------------------------------------------------------------------
Downloading: http://maven.aliyun.com/nexus/content/repositories/central/org/apache/hbase/hbase/1.1.1/hbase-1.1.1.jar
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Apache Oozie Main .................................. SUCCESS [  1.008 s]
[INFO] Apache Oozie Hadoop Utils hadoop-2-4.3.0 ........... SUCCESS [  1.869 s]
[INFO] Apache Oozie Hadoop Distcp hadoop-2-4.3.0 .......... SUCCESS [  0.094 s]
[INFO] Apache Oozie Hadoop Auth hadoop-2-4.3.0 Test ....... SUCCESS [  0.287 s]
[INFO] Apache Oozie Hadoop Libs ........................... SUCCESS [  0.026 s]
[INFO] Apache Oozie Client ................................ SUCCESS [ 14.418 s]
[INFO] Apache Oozie Share Lib Oozie ....................... SUCCESS [  2.331 s]
[INFO] Apache Oozie Share Lib HCatalog .................... SUCCESS [  2.478 s]
[INFO] Apache Oozie Share Lib Distcp ...................... SUCCESS [  0.728 s]
[INFO] Apache Oozie Core .................................. FAILURE [  0.755 s]
[INFO] Apache Oozie Share Lib Streaming ................... SKIPPED
[INFO] Apache Oozie Share Lib Pig ......................... SKIPPED
[INFO] Apache Oozie Share Lib Hive ........................ SKIPPED
[INFO] Apache Oozie Share Lib Hive 2 ...................... SKIPPED
[INFO] Apache Oozie Share Lib Sqoop ....................... SKIPPED
[INFO] Apache Oozie Examples .............................. SKIPPED
[INFO] Apache Oozie Share Lib Spark ....................... SKIPPED
[INFO] Apache Oozie Share Lib ............................. SKIPPED
[INFO] Apache Oozie Docs .................................. SKIPPED
[INFO] Apache Oozie WebApp ................................ SKIPPED
[INFO] Apache Oozie Tools ................................. SKIPPED
[INFO] Apache Oozie MiniOozie ............................. SKIPPED
[INFO] Apache Oozie Distro ................................ SKIPPED
[INFO] Apache Oozie ZooKeeper Security Tests .............. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 24.879 s
[INFO] Finished at: 2017-03-27T18:01:13+08:00
[INFO] Final Memory: 110M/1420M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project oozie-core: Could not resolve dependencies for project org.apache.oozie:oozie-core:jar:4.3.0: Could not find artifact org.apache.hbase:hbase:jar:1.1.1 in alimaven (http://maven.aliyun.com/nexus/content/repositories/central/) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :oozie-core

I am using a near by maven central mirror with a proxy, but that shouldn't be the problem because I also tried the US mirror, result's the same.  And I've done my best to look up documentations, related posts, with no luck so far.

Please, some one, enlighten me please.


问:
Implementing next button which will notify thread
I know that there is some questions about this but it seems like I did not understand the concept or there is something wrong with it.

Basically, what I am trying to do is, there is a algorithm which will proceed as;

```<code>for(step=0;step<value;step++){
//Do something;
}
</code>```

But it should be an option so user can see how it perform algorithm each step if he check the isStepped checkbox;
So what I came up with is

```<code> public void run() {
for (int step = 0; step < f; step++) {
        if (isStepped) {
            try {
                wait();//Here is the problem
            } catch (InterruptedException ex) {
                Logger.getLogger(MainThread.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        }
</code>```

And on the Menuside;

```<code>private void nextButtonActionPerformed(java.awt.event.ActionEvent evt) {

    MyThread.notify();

}
</code>```

So when a nextbuttonclicked, thread should wake up but it seems it wont...
What causes this problem, and how can I overcome?

答:
With that for-loop you are trying to force linear console code to do event-driven processing, basically trying to shove a square peg into a round hole, and this simply isn't going to work. The proper solution is to not use threading, wait or even a for loop but rather to simplify all this and instead use a counter that increments every time the user presses the button -- change the object's state in response to an event.

For example:

```<code>import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagLayout;

import javax.swing.*;

public class SimpleStepProcessing extends JPanel {
    public static final String[] STEPS = { "Step One", "Step Two", "Step Three", "Step Four",
            "Step Five", "Step Six", "Step Seven", "Step Eight", "Step Nine", "Step Ten" };
    private JLabel stepLabel = new JLabel("");
    private int stepCounter = 0;
    private JButton nextButton = new JButton("Next");

    public SimpleStepProcessing() {
        nextButton.addActionListener(e -> {
            stepCounter++;
            if (stepCounter < STEPS.length) {
                // advance program to the next step
                stepLabel.setText(STEPS[stepCounter]);
            }
        });

        stepLabel.setText(STEPS[stepCounter]);

        JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 4, 4));
        topPanel.add(new JLabel("Current Step:"));
        topPanel.add(stepLabel);

        JPanel middlePanel = new JPanel(new GridBagLayout());
        middlePanel.add(nextButton);

        setLayout(new BorderLayout());
        add(topPanel, BorderLayout.PAGE_START);
        add(middlePanel, BorderLayout.CENTER);

        setPreferredSize(new Dimension(200, 100));
    }

    private static void createAndShowGui() {
        SimpleStepProcessing mainPanel = new SimpleStepProcessing();

        JFrame frame = new JFrame("SimpleStepProcessing");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(mainPanel);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> createAndShowGui());
    }
}
</code>```

Body:
I know that there is some questions about this but it seems like I did not understand the concept or there is something wrong with it.

Basically, what I am trying to do is, there is a algorithm which will proceed as;

for(step=0;step<value;step++){
//Do something;
}

But it should be an option so user can see how it perform algorithm each step if he check the isStepped checkbox;
So what I came up with is

 public void run() {
for (int step = 0; step < f; step++) {
        if (isStepped) {
            try {
                wait();//Here is the problem
            } catch (InterruptedException ex) {
                Logger.getLogger(MainThread.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        }

And on the Menuside;

private void nextButtonActionPerformed(java.awt.event.ActionEvent evt) {

    MyThread.notify();

}

So when a nextbuttonclicked, thread should wake up but it seems it wont...
What causes this problem, and how can I overcome?

Body:
With that for-loop you are trying to force linear console code to do event-driven processing, basically trying to shove a square peg into a round hole, and this simply isn't going to work. The proper solution is to not use threading, wait or even a for loop but rather to simplify all this and instead use a counter that increments every time the user presses the button -- change the object's state in response to an event.

For example:

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagLayout;

import javax.swing.*;

public class SimpleStepProcessing extends JPanel {
    public static final String[] STEPS = { "Step One", "Step Two", "Step Three", "Step Four",
            "Step Five", "Step Six", "Step Seven", "Step Eight", "Step Nine", "Step Ten" };
    private JLabel stepLabel = new JLabel("");
    private int stepCounter = 0;
    private JButton nextButton = new JButton("Next");

    public SimpleStepProcessing() {
        nextButton.addActionListener(e -> {
            stepCounter++;
            if (stepCounter < STEPS.length) {
                // advance program to the next step
                stepLabel.setText(STEPS[stepCounter]);
            }
        });

        stepLabel.setText(STEPS[stepCounter]);

        JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 4, 4));
        topPanel.add(new JLabel("Current Step:"));
        topPanel.add(stepLabel);

        JPanel middlePanel = new JPanel(new GridBagLayout());
        middlePanel.add(nextButton);

        setLayout(new BorderLayout());
        add(topPanel, BorderLayout.PAGE_START);
        add(middlePanel, BorderLayout.CENTER);

        setPreferredSize(new Dimension(200, 100));
    }

    private static void createAndShowGui() {
        SimpleStepProcessing mainPanel = new SimpleStepProcessing();

        JFrame frame = new JFrame("SimpleStepProcessing");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(mainPanel);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> createAndShowGui());
    }
}


问:
how to display two home pages for two different users using php
i'm new for web developing and i have a question regarding user login. I have two types of users and I need to link them for two different home pages when they log in. for an example the user whose user id is M00001 should get the home page MemberHome.php and the user whose user id is G00001 should get the home page called GuestHome.php.
Please tell me how should i create my web pages according to above requirement using PHP and MySql.</p>

答:
Do you use template for each user's role? try this:

```<code><?php
/*I assumed that you already have the variables which retrieved from MYSQL and saved it in $role */
if($role == 'M00001' ){
  include 'MemberHome.php';
}else if($role == 'G00001'}{
  include 'GuestHome.php';
}
?>
</code>```

But I suggest that you should use some framework like Laravel or Yii to easily maintain and help you very much in routing

Body:
Do you use template for each user's role? try this:

<?php
/*I assumed that you already have the variables which retrieved from MYSQL and saved it in $role */
if($role == 'M00001' ){
  include 'MemberHome.php';
}else if($role == 'G00001'}{
  include 'GuestHome.php';
}
?>

But I suggest that you should use some framework like Laravel or Yii to easily maintain and help you very much in routing


问:
error when apply plugin: 'com.google.gms.google-services'
I followed google documentation to integrate my app to Google Analytics.
But when adding

```<code>apply plugin: 'com.google.gms.google-services'
</code>```

and building my app, I encountered this error:

```<code>Error:(49, 0) For input string: "+"
</code>```

These are the settings I used in the build.gradle of my application:

```<code>apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"
    defaultConfig {
        applicationId "com.myapp.xyz"
        manifestPlaceholders = [
            manifestApplicationId : "${applicationId}",
            onesignal_app_id : "ccd48c54-2069-41f9-8ff7-54c7a12f2d18a",
            onesignal_google_project_number: "306632981237"
        ]
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
            'proguard-rules.pro'
        }
    }
}

repositories {
    mavenCentral()
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    // compile 'com.android.support:appcompat-v7:22.2.1'
    compile project(':facebook')
    compile 'com.android.support:design:22.2.1'
    compile 'com.android.support:palette-v7:22.2.1'
    compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.android.support:support-v4:22.2.1'
    compile 'com.onesignal:OneSignal:1.+@aar'
    compile 'com.google.android.gms:play-services-gcm:+'
    compile 'com.google.android.gms:play-services:8.4.0'
    compile 'com.google.android.gms:play-services-analytics:8.4.0'
}
apply plugin: 'com.google.gms.google-services'
</code>```

These are the setting in build.gradle application:

```<code>buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
        classpath 'com.google.gms:google-services:2.0.0-alpha6'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        jcenter()
    }
}
</code>```

答:
Add the following to the @project level gradle file:</p>

```<code>    classpath 'com.android.tools.build:gradle:2.3.0'
    classpath 'com.google.gms:google-services:3.0.0'
</code>```

Body:
I followed google documentation to integrate my app to Google Analytics.
But when adding

apply plugin: 'com.google.gms.google-services'

and building my app, I encountered this error:

Error:(49, 0) For input string: "+"

These are the settings I used in the build.gradle of my application:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"
    defaultConfig {
        applicationId "com.myapp.xyz"
        manifestPlaceholders = [
            manifestApplicationId : "${applicationId}",
            onesignal_app_id : "ccd48c54-2069-41f9-8ff7-54c7a12f2d18a",
            onesignal_google_project_number: "306632981237"
        ]
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
            'proguard-rules.pro'
        }
    }
}

repositories {
    mavenCentral()
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    // compile 'com.android.support:appcompat-v7:22.2.1'
    compile project(':facebook')
    compile 'com.android.support:design:22.2.1'
    compile 'com.android.support:palette-v7:22.2.1'
    compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.android.support:support-v4:22.2.1'
    compile 'com.onesignal:OneSignal:1.+@aar'
    compile 'com.google.android.gms:play-services-gcm:+'
    compile 'com.google.android.gms:play-services:8.4.0'
    compile 'com.google.android.gms:play-services-analytics:8.4.0'
}
apply plugin: 'com.google.gms.google-services'

These are the setting in build.gradle application:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
        classpath 'com.google.gms:google-services:2.0.0-alpha6'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        jcenter()
    }
}

Body:
Add the following to the @project level gradle file:

    classpath 'com.android.tools.build:gradle:2.3.0'
    classpath 'com.google.gms:google-services:3.0.0'