问:
Nested promoses, not waiting for the result
I have a getProgrammeWrapper method that returns a promise. However in .then method i have few other promises that i will like to execute before returning the programmeWrapper[]

This is service.ts

I am calling the service in ngOnInit

```<code>this.service.getProgrammesByWrapper().then(((res) => {
            this.programmes = res;
            this.result.updateInfo("Sorting classes...")
            this.programmes =this.programmes.sort((a,b) => {
                return b.programme.click - a.programme.click;
            });
            this.result.updateSuccess(true);
        }));
</code>```

I hope i have explained the issue clearly. I have tried using await, but it doesn't work as expected.

getProgrammeWrapper()

```<code>getProgrammesByWrapper(): Promise<ProgrammeWrapper[]> {
        var current = this;
        var programmesDTO = new Array<ProgrammeWrapper>();
        var table = this.client.getTable("programme");
        return new Promise((resolve, reject) => {
            table.read()
                .then(function (modules) {
                    modules.forEach(element => {
                        var newProgDTO = new ProgrammeWrapper(element);
                        current.getLessonsByProgrammeId(element.id).then(lessons => newProgDTO.lesson = lessons).catch(err => console.log(err));
                        current.getUser(element.tutorId).then(user => newProgDTO.tutor = user).catch(err => console.log(err));
                        programmesDTO.push(newProgDTO)
                    });
                    resolve(programmesDTO)
                }, function (error) { reject(error) });
        });
    }
</code>```

答:
I'm not sure it would work, could have bugs too. Try this:</p>

```<code>getProgrammesByWrapper(): Promise<ProgrammeWrapper[]> {
    var current = this;
    var programmesDTO = new Array<ProgrammeWrapper>();
    var table = this.client.getTable("programme");

    return new Promise((resolve, reject) => {
        table.read()
        .then(function (modules) {
            let promises = new Array<Promise<any>>();

            modules.forEach(element => {
                var newProgDTO = new ProgrammeWrapper(element);

                let promise = current.getLessonsByProgrammeId(element.id)
                .then(lessons => newProgDTO.lesson = lessons)
                .catch(err => console.log(err));

                promises.push(promise);

                promise = current.getUser(element.tutorId)
                .then(user => newProgDTO.tutor = user)
                .catch(err => console.log(err));

                promises.push(promise);
                programmesDTO.push(newProgDTO)
            });

            // Wait for all promises to be ready before resolving
            Promise.all(promises).then(function() {
                resolve(programmesDTO);
            });
        }, function (error) { reject(error); });
    });
}
</code>```

Body:
I have a getProgrammeWrapper method that returns a promise. However in .then method i have few other promises that i will like to execute before returning the programmeWrapper[]

This is service.ts

I am calling the service in ngOnInit

this.service.getProgrammesByWrapper().then(((res) => {
            this.programmes = res;
            this.result.updateInfo("Sorting classes...")
            this.programmes =this.programmes.sort((a,b) => {
                return b.programme.click - a.programme.click;
            });
            this.result.updateSuccess(true);
        }));

I hope i have explained the issue clearly. I have tried using await, but it doesn't work as expected.

getProgrammeWrapper()

getProgrammesByWrapper(): Promise<ProgrammeWrapper[]> {
        var current = this;
        var programmesDTO = new Array<ProgrammeWrapper>();
        var table = this.client.getTable("programme");
        return new Promise((resolve, reject) => {
            table.read()
                .then(function (modules) {
                    modules.forEach(element => {
                        var newProgDTO = new ProgrammeWrapper(element);
                        current.getLessonsByProgrammeId(element.id).then(lessons => newProgDTO.lesson = lessons).catch(err => console.log(err));
                        current.getUser(element.tutorId).then(user => newProgDTO.tutor = user).catch(err => console.log(err));
                        programmesDTO.push(newProgDTO)
                    });
                    resolve(programmesDTO)
                }, function (error) { reject(error) });
        });
    }

Body:
I'm not sure it would work, could have bugs too. Try this:

getProgrammesByWrapper(): Promise<ProgrammeWrapper[]> {
    var current = this;
    var programmesDTO = new Array<ProgrammeWrapper>();
    var table = this.client.getTable("programme");

    return new Promise((resolve, reject) => {
        table.read()
        .then(function (modules) {
            let promises = new Array<Promise<any>>();

            modules.forEach(element => {
                var newProgDTO = new ProgrammeWrapper(element);

                let promise = current.getLessonsByProgrammeId(element.id)
                .then(lessons => newProgDTO.lesson = lessons)
                .catch(err => console.log(err));

                promises.push(promise);

                promise = current.getUser(element.tutorId)
                .then(user => newProgDTO.tutor = user)
                .catch(err => console.log(err));

                promises.push(promise);
                programmesDTO.push(newProgDTO)
            });

            // Wait for all promises to be ready before resolving
            Promise.all(promises).then(function() {
                resolve(programmesDTO);
            });
        }, function (error) { reject(error); });
    });
}


来源: stackexchange

问:
Smarty {html_options} in JavaScript string
I am trying to put generated Smarty options list in a JavaScript string but it breaks because of the new lines generated by Smarty. Seems like I cannot filter the html_option after its generation.

Any ideas or solutions, anyone? Thanks!

```<code><script type="text/javascript">
    //Smarty template
    var option_list = '{html_options options=$options_list selected=' + selected_option + '|regex_replace:"/[\r\n]/":""}';
</script>

<script type="text/javascript">
    //Result:
    var option_list = '<option ....></option>   //SyntaxError: unterminated string literal
<option ....></option>
<option ....></option>';
</script>
</code>```

答:
The backtick (`) seems to be changed by TypeScript compilers but fortunately I have finally found some workaround:

```<code><script>
var options = '{html_options|strip ...}';
</script>
</code>```

But we also need to set the selected item afterwards:

```<code>$('#select_id').val(selected_option);
</code>```

ContentLicense: CC BY-SA 3.0

Body:
The backtick (`) seems to be changed by TypeScript compilers but fortunately I have finally found some workaround:

<script>
var options = '{html_options|strip ...}';
</script>

But we also need to set the selected item afterwards:

$('#select_id').val(selected_option);


问:
count of nodes selected for an xpath in chrome console
How to get count of nodes selected for an xpath in chrome console?

I was able to select a set of node with Xpath :

```<code>$x("//*[@rel='noopener noreferrer']")
</code>```

in chrome console. but unable to get the count of number of nodes selected using count function in chrome using

```<code>$x(count("//*[@rel='noopener noreferrer']"))
</code>```

while it is working fine in firefox using count function as

```<code>(//*[@rel='noopener noreferrer'])
</code>```

Please help me to get count using chrome console

答:
you can actually use xPath to tell you directly that count =)

```<code>count(locator)
</code>```

for example

count(//*) -count all elements on the page - $x("count(//*)")

count(//a) - count all a attributes on the page - $x("count(//a)")

using console $x:

```<code>$x("//a").length
</code>```

Actually your locator is almost correct

error -  $x(count("//*[@rel='noopener noreferrer']"))

the problem is that count() is a part of xPath, not a js function, so it should be located inside quotes:

fixed - $x("count(//*[@rel='noopener noreferrer'])")

Body:
How to get count of nodes selected for an xpath in chrome console?

I was able to select a set of node with Xpath :

$x("//*[@rel='noopener noreferrer']")

in chrome console. but unable to get the count of number of nodes selected using count function in chrome using

$x(count("//*[@rel='noopener noreferrer']"))

while it is working fine in firefox using count function as

(//*[@rel='noopener noreferrer'])

Please help me to get count using chrome console

Body:
you can actually use xPath to tell you directly that count =)

count(locator)

for example

count(//*) -count all elements on the page - $x("count(//*)")

count(//a) - count all a attributes on the page - $x("count(//a)")

using console $x:

$x("//a").length

Actually your locator is almost correct

error -  $x(count("//*[@rel='noopener noreferrer']"))

the problem is that count() is a part of xPath, not a js function, so it should be located inside quotes:

fixed - $x("count(//*[@rel='noopener noreferrer'])")


问:
In VSTS, How to constraint/restrict a team member's working capacity in case working in multiple projects
Assume a team member A works with multiple projects/applications(P1,P2,P3). While doing Capacity planning, i'm able to allocate him with 8hrs per day in each project(P1,P2,P3). Is there any availability to freeze/constraint a team member's capacity to 8hrs in all projects combined(capacity should be restricted to 8hrs in combined). Any provision to create such a rule/restriction on account level?</p>

答:
Simple answer: You can't do this by technical means. The capacity per day field is not validated in any way. You can even enter more than 24h as capacity.

The capacity planning has to be done by organizational means.
I our projects it has proven as good practice to not even plan full 8h per day per person. For capacity planning we only assume 6h per developer. The rest is used for meetings, support and other unplanned stuff.


问:
How can I stop web-scraping dataes, when i find the value?
I have got this code, which one i can search the all table called "ctable" on a website with Python 2.7. But i want to stop it, when it is reaching on of this "ctable" with the value XXXX. I need until this value XXXX. So if it is finding this text i want to stop webscraping these tables.

Is it possible?

Here my code:

soup = BeautifulSoup(x, 'lxml')

datatable=[]
for ctable in soup.find_all('table',  "ctable" )[:-1]:
    for record in ctable.find_all('tr'):
        temp_data = []
        for data in record.find_all('td'):
            temp_data.append(data.text.encode('latin-1'))
        datatable.append(temp_data)```
</div>
</div>
</p>

<p>I tried this:
<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>datatable=[]
for ctable in soup.find_all('table',  "ctable" )[:-1]:
    for record in ctable.find_all('tr'):
        temp_data = []
        for data in record.find_all('td'):
            temp_data.append(data.text.encode('latin-1'))
            if 'modul' in data.text:
                break
datatable.append(temp_data)</code>```

答:
Implement a break operator in your code:

```<code>    ...
    (your code above)
datatable=[]
stop = 0
for ctable in soup.find_all('table',  "ctable" )[:-1]:
    if stop == 1:
        break
    for record in ctable.find_all('tr'):
        if stop == 1:
            break
        temp_data = []
        for data in record.find_all('td'):
            temp_data.append(data.text.encode('latin-1'))
            if 'modul' in data.text:
                stop = 1
                break
        datatable.append(temp_data)
</code>```

I didn't pay enough attention that you have a triple for loop. Maybe now it will work?

I added break to every loop.

Alternative if and break:

```<code>datatable=[]
stop = 0
for ctable in soup.find_all('table',  "ctable" )[:-1]:
    for record in ctable.find_all('tr'):
        temp_data = []
        for data in record.find_all('td'):
            temp_data.append(data.text.encode('latin-1'))
            if 'modul' in data.text:
                stop = 1
                break
        datatable.append(temp_data)
        if stop == 1:
            break
    if stop == 1:
        break
</code>```

Body:
I have got this code, which one i can search the all table called "ctable" on a website with Python 2.7. But i want to stop it, when it is reaching on of this "ctable" with the value XXXX. I need until this value XXXX. So if it is finding this text i want to stop webscraping these tables.

Is it possible?

Here my code:

soup = BeautifulSoup(x, 'lxml')

datatable=[]
for ctable in soup.find_all('table',  "ctable" )[:-1]:
    for record in ctable.find_all('tr'):
        temp_data = []
        for data in record.find_all('td'):
            temp_data.append(data.text.encode('latin-1'))
        datatable.append(temp_data)

I tried this:

datatable=[]
for ctable in soup.find_all('table',  "ctable" )[:-1]:
    for record in ctable.find_all('tr'):
        temp_data = []
        for data in record.find_all('td'):
            temp_data.append(data.text.encode('latin-1'))
            if 'modul' in data.text:
                break
datatable.append(temp_data)

Body:
Implement a break operator in your code:

    ...
    (your code above)
datatable=[]
stop = 0
for ctable in soup.find_all('table',  "ctable" )[:-1]:
    if stop == 1:
        break
    for record in ctable.find_all('tr'):
        if stop == 1:
            break
        temp_data = []
        for data in record.find_all('td'):
            temp_data.append(data.text.encode('latin-1'))
            if 'modul' in data.text:
                stop = 1
                break
        datatable.append(temp_data)

I didn't pay enough attention that you have a triple for loop. Maybe now it will work?

I added break to every loop.

Alternative if and break:

datatable=[]
stop = 0
for ctable in soup.find_all('table',  "ctable" )[:-1]:
    for record in ctable.find_all('tr'):
        temp_data = []
        for data in record.find_all('td'):
            temp_data.append(data.text.encode('latin-1'))
            if 'modul' in data.text:
                stop = 1
                break
        datatable.append(temp_data)
        if stop == 1:
            break
    if stop == 1:
        break


问:
Protractor: ENOTFOUND getaddrinfo ENOTFOUND localhost localhost:4444
Protractor doesn't start, it doesn't even open chrome.
it just gives me this error ENOTFOUND localhost localhost:4444 even though I've started webdriver-manager and I can access localhost:4444 in the browser. I'm not sure what to do with this, I've tried reinstalling Chrome, updating protractor & webdriver-manager, upgrading Node.js, flushed my DNS but I'm still having the error.

Error:

```<code>[11:11:21] I/launcher - Running 1 instances of WebDriver
[11:11:21] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[11:11:26] E/launcher - ENOTFOUND getaddrinfo ENOTFOUND localhost localhost:4444
[11:11:26] E/launcher - Error: ENOTFOUND getaddrinfo ENOTFOUND localhost localhost:4444
  at ClientRequest.<anonymous> (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:238:15)
  at emitOne (events.js:115:13)
  at ClientRequest.emit (events.js:210:7)
  at Socket.socketErrorListener (_http_client.js:400:9)
  at emitOne (events.js:115:13)
  at Socket.emit (events.js:210:7)
  at emitErrorNT (internal/streams/destroy.js:62:8)
  at _combinedTickCallback (internal/process/next_tick.js:102:11)
  at process._tickCallback (internal/process/next_tick.js:161:9)
From: Task: WebDriver.createSession()
  at Function.createSession (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:777:24)
  at Function.createSession (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/chrome.js:709:29)
  at createDriver (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/index.js:167:33)
  at Builder.build (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/index.js:623:16)
  at Hosted.getNewDriver (/usr/local/lib/node_modules/protractor/built/driverProviders/driverProvider.js:53:33)
  at Runner.createBrowser (/usr/local/lib/node_modules/protractor/built/runner.js:195:43)
  at q.then.then (/usr/local/lib/node_modules/protractor/built/runner.js:339:29)
  at _fulfilled (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:834:54)
  at self.promiseDispatch.done (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:863:30)
  at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:796:13)
  at /usr/local/lib/node_modules/protractor/node_modules/q/q.js:556:49
  at runSingle (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:137:13)
  at flush (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:125:13)
  at _combinedTickCallback (internal/process/next_tick.js:95:7)
  at process._tickCallback (internal/process/next_tick.js:161:9)
  at Function.Module.runMain (module.js:607:11)
  at startup (bootstrap_node.js:158:16)
  at bootstrap_node.js:575:3
</code>```

This is the log provided by NPM:

```<code>0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/8.1.3/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'run',
1 verbose cli   'tests' ]
2 info using npm@5.0.4
3 info using node@v8.1.3
4 verbose run-script [ 'pretests', 'tests', 'posttests' ]
5 info lifecycle angular-app@1.0.1~pretests: angular-app@1.0.1
6 silly lifecycle angular-app@1.0.1~pretests: no script for pretests, continuing
7 info lifecycle angular-app@1.0.1~tests: angular-app@1.0.1
8 verbose lifecycle angular-app@1.0.1~tests: unsafe-perm in lifecycle true
9 verbose lifecycle angular-app@1.0.1~tests: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/ChrisVillaran/Documents/Projects/angular-app/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/tools:/platform-tools:/Users/ChrisVillaran/.yarn/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/google_appengine/:/usr/local/bin/closure-compiler.jar
10 verbose lifecycle angular-app@1.0.1~tests: CWD: /Users/ChrisVillaran/Documents/Projects/angular-app
11 silly lifecycle angular-app@1.0.1~tests: Args: [ '-c', 'protractor tests/config.js' ]
12 silly lifecycle angular-app@1.0.1~tests: Returned: code: 199  signal: null
13 info lifecycle angular-app@1.0.1~tests: Failed to exec tests script
14 verbose stack Error: angular-app@1.0.1 tests: `protractor tests/config.js`
14 verbose stack Exit status 199
14 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:283:16)
14 verbose stack     at emitTwo (events.js:125:13)
14 verbose stack     at EventEmitter.emit (events.js:213:7)
14 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack     at emitTwo (events.js:125:13)
14 verbose stack     at ChildProcess.emit (events.js:213:7)
14 verbose stack     at maybeClose (internal/child_process.js:897:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:208:5)
15 verbose pkgid angular-app@1.0.1
16 verbose cwd /Users/ChrisVillaran/Documents/Projects/angular-app
17 verbose Darwin 14.5.0
18 verbose argv "/usr/local/Cellar/node/8.1.3/bin/node" "/usr/local/bin/npm" "run" "tests"
19 verbose node v8.1.3
20 verbose npm  v5.0.4
21 error code ELIFECYCLE
22 error errno 199
23 error angular-app@1.0.1 tests: `protractor tests/config.js`
23 error Exit status 199
24 error Failed at the angular-app@1.0.1 tests script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 199, true ]
</code>```

Selenium logs:

```<code>[14:57:32] I/start - java -Dwebdriver.chrome.driver=/usr/local/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.30 -Dwebdriver.gecko.driver=/usr/local/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.17.0 -jar /usr/local/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.4.0.jar -port 4444
[14:57:32] I/start - seleniumProcess.pid: 10704
14:57:33.378 INFO - Selenium build info: version: '3.4.0', revision: 'unknown'
14:57:33.379 INFO - Launching a standalone Selenium Server
2017-07-03 14:57:33.443:INFO::main: Logging initialized @590ms to org.seleniumhq.jetty9.util.log.StdErrLog
14:57:34.065 INFO - Driver provider org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
  registration capabilities Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}] does not match the current platform MAC
14:57:34.065 INFO - Driver provider org.openqa.selenium.edge.EdgeDriver registration is skipped:
  registration capabilities Capabilities [{browserName=MicrosoftEdge, version=, platform=WINDOWS}] does not match the current platform MAC
14:57:34.065 INFO - Driver class not found: com.opera.core.systems.OperaDriver
14:57:34.065 INFO - Driver provider com.opera.core.systems.OperaDriver registration is skipped:
Unable to create new instances on this machine.
14:57:34.066 INFO - Driver class not found: com.opera.core.systems.OperaDriver
14:57:34.066 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
2017-07-03 14:57:34.188:INFO:osjs.Server:main: jetty-9.4.3.v20170317
2017-07-03 14:57:34.256:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@14acaea5{/,null,AVAILABLE}
2017-07-03 14:57:34.321:INFO:osjs.AbstractConnector:main: Started ServerConnector@3bb3f24f{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
2017-07-03 14:57:34.322:INFO:osjs.Server:main: Started @1470ms
14:57:34.322 INFO - Selenium Server is up and running
</code>```

Additional info:

```<code>Machine: OS X 10.10.5
Google Chrome: 59.0.3071.115
Node: 8.1.3
NPM: 5.0.4
Protractor: 5.1.2
Webdriver Manager: 12.0.6
</code>```

My config:

```<code>let SpecReporter = require('jasmine-spec-reporter').SpecReporter;

exports.config = {
  allScriptsTimeout: 1000 * 2500,
  capabilities: {
    'browserName': 'chrome'
  },
  onPrepare: function () {
    jasmine.getEnv().addReporter(new SpecReporter({
      spec: {
        displayStacktrace: true
      }
    }));
  },
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: [
    'tests/specs/login-view/login.js'
  ],
  jasmineNodeOpts: {
    defaultTimeoutInterval: 1000 * 2500,
    print: function() {}
  }
};
</code>```

答:
Try commenting the selenium address, as bellow. It should work.</p>

```<code>//seleniumAddress: 'http://localhost:4444/wd/hub',
</code>```

Body:
Protractor doesn't start, it doesn't even open chrome.
it just gives me this error ENOTFOUND localhost localhost:4444 even though I've started webdriver-manager and I can access localhost:4444 in the browser. I'm not sure what to do with this, I've tried reinstalling Chrome, updating protractor & webdriver-manager, upgrading Node.js, flushed my DNS but I'm still having the error.

Error:

[11:11:21] I/launcher - Running 1 instances of WebDriver
[11:11:21] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[11:11:26] E/launcher - ENOTFOUND getaddrinfo ENOTFOUND localhost localhost:4444
[11:11:26] E/launcher - Error: ENOTFOUND getaddrinfo ENOTFOUND localhost localhost:4444
  at ClientRequest.<anonymous> (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:238:15)
  at emitOne (events.js:115:13)
  at ClientRequest.emit (events.js:210:7)
  at Socket.socketErrorListener (_http_client.js:400:9)
  at emitOne (events.js:115:13)
  at Socket.emit (events.js:210:7)
  at emitErrorNT (internal/streams/destroy.js:62:8)
  at _combinedTickCallback (internal/process/next_tick.js:102:11)
  at process._tickCallback (internal/process/next_tick.js:161:9)
From: Task: WebDriver.createSession()
  at Function.createSession (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:777:24)
  at Function.createSession (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/chrome.js:709:29)
  at createDriver (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/index.js:167:33)
  at Builder.build (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/index.js:623:16)
  at Hosted.getNewDriver (/usr/local/lib/node_modules/protractor/built/driverProviders/driverProvider.js:53:33)
  at Runner.createBrowser (/usr/local/lib/node_modules/protractor/built/runner.js:195:43)
  at q.then.then (/usr/local/lib/node_modules/protractor/built/runner.js:339:29)
  at _fulfilled (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:834:54)
  at self.promiseDispatch.done (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:863:30)
  at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:796:13)
  at /usr/local/lib/node_modules/protractor/node_modules/q/q.js:556:49
  at runSingle (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:137:13)
  at flush (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:125:13)
  at _combinedTickCallback (internal/process/next_tick.js:95:7)
  at process._tickCallback (internal/process/next_tick.js:161:9)
  at Function.Module.runMain (module.js:607:11)
  at startup (bootstrap_node.js:158:16)
  at bootstrap_node.js:575:3

This is the log provided by NPM:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/8.1.3/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'run',
1 verbose cli   'tests' ]
2 info using npm@5.0.4
3 info using node@v8.1.3
4 verbose run-script [ 'pretests', 'tests', 'posttests' ]
5 info lifecycle angular-app@1.0.1~pretests: angular-app@1.0.1
6 silly lifecycle angular-app@1.0.1~pretests: no script for pretests, continuing
7 info lifecycle angular-app@1.0.1~tests: angular-app@1.0.1
8 verbose lifecycle angular-app@1.0.1~tests: unsafe-perm in lifecycle true
9 verbose lifecycle angular-app@1.0.1~tests: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/ChrisVillaran/Documents/Projects/angular-app/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/tools:/platform-tools:/Users/ChrisVillaran/.yarn/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/google_appengine/:/usr/local/bin/closure-compiler.jar
10 verbose lifecycle angular-app@1.0.1~tests: CWD: /Users/ChrisVillaran/Documents/Projects/angular-app
11 silly lifecycle angular-app@1.0.1~tests: Args: [ '-c', 'protractor tests/config.js' ]
12 silly lifecycle angular-app@1.0.1~tests: Returned: code: 199  signal: null
13 info lifecycle angular-app@1.0.1~tests: Failed to exec tests script
14 verbose stack Error: angular-app@1.0.1 tests: `protractor tests/config.js`
14 verbose stack Exit status 199
14 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:283:16)
14 verbose stack     at emitTwo (events.js:125:13)
14 verbose stack     at EventEmitter.emit (events.js:213:7)
14 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack     at emitTwo (events.js:125:13)
14 verbose stack     at ChildProcess.emit (events.js:213:7)
14 verbose stack     at maybeClose (internal/child_process.js:897:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:208:5)
15 verbose pkgid angular-app@1.0.1
16 verbose cwd /Users/ChrisVillaran/Documents/Projects/angular-app
17 verbose Darwin 14.5.0
18 verbose argv "/usr/local/Cellar/node/8.1.3/bin/node" "/usr/local/bin/npm" "run" "tests"
19 verbose node v8.1.3
20 verbose npm  v5.0.4
21 error code ELIFECYCLE
22 error errno 199
23 error angular-app@1.0.1 tests: `protractor tests/config.js`
23 error Exit status 199
24 error Failed at the angular-app@1.0.1 tests script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 199, true ]

Selenium logs:

[14:57:32] I/start - java -Dwebdriver.chrome.driver=/usr/local/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.30 -Dwebdriver.gecko.driver=/usr/local/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.17.0 -jar /usr/local/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.4.0.jar -port 4444
[14:57:32] I/start - seleniumProcess.pid: 10704
14:57:33.378 INFO - Selenium build info: version: '3.4.0', revision: 'unknown'
14:57:33.379 INFO - Launching a standalone Selenium Server
2017-07-03 14:57:33.443:INFO::main: Logging initialized @590ms to org.seleniumhq.jetty9.util.log.StdErrLog
14:57:34.065 INFO - Driver provider org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
  registration capabilities Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}] does not match the current platform MAC
14:57:34.065 INFO - Driver provider org.openqa.selenium.edge.EdgeDriver registration is skipped:
  registration capabilities Capabilities [{browserName=MicrosoftEdge, version=, platform=WINDOWS}] does not match the current platform MAC
14:57:34.065 INFO - Driver class not found: com.opera.core.systems.OperaDriver
14:57:34.065 INFO - Driver provider com.opera.core.systems.OperaDriver registration is skipped:
Unable to create new instances on this machine.
14:57:34.066 INFO - Driver class not found: com.opera.core.systems.OperaDriver
14:57:34.066 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
2017-07-03 14:57:34.188:INFO:osjs.Server:main: jetty-9.4.3.v20170317
2017-07-03 14:57:34.256:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@14acaea5{/,null,AVAILABLE}
2017-07-03 14:57:34.321:INFO:osjs.AbstractConnector:main: Started ServerConnector@3bb3f24f{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
2017-07-03 14:57:34.322:INFO:osjs.Server:main: Started @1470ms
14:57:34.322 INFO - Selenium Server is up and running

Additional info:

Machine: OS X 10.10.5
Google Chrome: 59.0.3071.115
Node: 8.1.3
NPM: 5.0.4
Protractor: 5.1.2
Webdriver Manager: 12.0.6

My config:

let SpecReporter = require('jasmine-spec-reporter').SpecReporter;

exports.config = {
  allScriptsTimeout: 1000 * 2500,
  capabilities: {
    'browserName': 'chrome'
  },
  onPrepare: function () {
    jasmine.getEnv().addReporter(new SpecReporter({
      spec: {
        displayStacktrace: true
      }
    }));
  },
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: [
    'tests/specs/login-view/login.js'
  ],
  jasmineNodeOpts: {
    defaultTimeoutInterval: 1000 * 2500,
    print: function() {}
  }
};

Body:
Try commenting the selenium address, as bellow. It should work.

//seleniumAddress: 'http://localhost:4444/wd/hub',


问:
Flex applications on Azure
I plan to deploy my Flex Application on the web using MS Azure. Has anyone done this?
If yes, can you please provide pointers, reference links etc?

Regards
Aparna

答:
If it's only the static content, html/swf/... then I suggest you use blob storage to put them in instead of using compute power of several instances as these are not needed. This will cut down on your costs as blob storage is publicly accessible but is very cheap.

If your Flex application needs integration with services then you need to host them in a compute environment like an instance.

ContentLicense: CC BY-SA 2.5

Title: Flex applications on Azure


问:
How can I execute an "Explain" statement with a prepared query in PostgrSQL that has bind parameters?
I would like to be able to execute an explain statement on a query that has bind parameters. For example:

```<code>EXPLAIN SELECT * FROM metasyntax WHERE id = $1;
</code>```

When I attempt to execute this, I get the following error:

```<code>ERROR: bind message supplies 0 parameters, but prepared statement "" requires 1
</code>```

I understand it's telling me that it wants me to supply a value for the query. However, I may not necessarily know the answer to that. In other SQL dialects such as Oracle, it will generate an explain plan without needing me to supply a value for the parameter.

Is it possible to get an explain plan without binding to an actual value? Thanks!

答:
Assuming the parameter is an integer:

```<code>PREPARE x(integer) AS SELECT * FROM metasyntax WHERE id = $1;
</code>```

Then run the following six times, where “42” is a representative value:

```<code>EXPLAIN (ANALYZE, BUFFERS) EXECUTE x(42);
</code>```

Normally PostgreSQL will switch to a generic plan for the sixth run, and you will see a plan that contains the placeholder $1.

Body:
I would like to be able to execute an explain statement on a query that has bind parameters. For example:

EXPLAIN SELECT * FROM metasyntax WHERE id = $1;

When I attempt to execute this, I get the following error:

ERROR: bind message supplies 0 parameters, but prepared statement "" requires 1

I understand it's telling me that it wants me to supply a value for the query. However, I may not necessarily know the answer to that. In other SQL dialects such as Oracle, it will generate an explain plan without needing me to supply a value for the parameter.

Is it possible to get an explain plan without binding to an actual value? Thanks!

Body:
Assuming the parameter is an integer:

PREPARE x(integer) AS SELECT * FROM metasyntax WHERE id = $1;

Then run the following six times, where “42” is a representative value:

EXPLAIN (ANALYZE, BUFFERS) EXECUTE x(42);

Normally PostgreSQL will switch to a generic plan for the sixth run, and you will see a plan that contains the placeholder $1.


问:
When should I use namespaces in PHP?
In most small projects and tutorials i don't see a use of namespaces, but they are present, for example, everywhere in Laravel framework. My question is: should i use namespaces pretty much always, or there's some sort of "algorithm" to evaluate if I need them or not?</p>

答:
The main objective of namespaces is to prevent name collisions, more over they are used to group classes, methods. As you mentioned there are a lot of classes within a Laravel project so namespaces would have to be used to prevent collisions which will happen in big projects.

You can 'nest' namespaces as you desire, this is usually paired to your folder structure and is relevant if you are using PSR-4 autoloading standard which laravel uses.

For example you may a User class (Model) and a User class (Repository). Putting them under

namespace Model

and

namespace Repository

will make a lot of sense to you, PHP and the autoloader.

Title: When should I use namespaces in PHP?


问:
react-d3-component implement in create-react-app
I'm new to react.
By my research, I figured out that React-D3-component can serve my purpose.

I'm looking for an example of a Multi-series Line chart with tooltip and zoomable function. Basic line chart would also make this trick for my first steps.

I've a create-react-app, boilerplate ready. I need to put up this graph into a create-react-app project.

Please guide me through an example, which explains step by step how to implement this kind of graph.

答:
Here are a few steps to do in order to make your app work:

Config your create-react-app boiler plate with Webpack and make sure you can run it without React-D3-component module.

Find the homepage component (normally main.js) try to modify some basic HTML elements and see if you can see the changes on page with hot-reloading. For instance, adding a H1 red tag.

Install React-D3-component module with npm command:

```<code>npm install react-d3-components --save
</code>```

Start adding React-D3-component into your homepage component you just modified by importing the module:

```<code>import ReactD3 from 'react-d3-components'
</code>```

Follow the example here, and create your chart components in your homepage.

This workflow should work for any React modules for testing purposes.

Body:
Here are a few steps to do in order to make your app work:

Config your create-react-app boiler plate with Webpack and make sure you can run it without React-D3-component module.

Find the homepage component (normally main.js) try to modify some basic HTML elements and see if you can see the changes on page with hot-reloading. For instance, adding a H1 red tag.

Install React-D3-component module with npm command:

npm install react-d3-components --save

Start adding React-D3-component into your homepage component you just modified by importing the module:

import ReactD3 from 'react-d3-components'

Follow the example here, and create your chart components in your homepage.

This workflow should work for any React modules for testing purposes.


问:
How to go the respective activity after clicking option in slide menu
ppl am trying to do menu option...and i got it,but after clicking the option in the slide menu...the control should go the respective page..i tried ..but its not working..please help me    </p>

```<code>    switch(position){
        case '0': {
            startActivity(new Intent(home.this, home.class));
            finish();
        }
        case '1':
        {
            startActivity(new Intent(home.this, info_values.class));
            finish();
        }
    }
</code>```

答:
You should try like this</p>

```<code>switch(position){
    case 0:
        startActivity(new Intent(home.this, home.class));
        finish();
        break;
    case 1:

        startActivity(new Intent(home.this, info_values.class));
        finish();
        break;
    default:
        break;

}
</code>```

Body:
ppl am trying to do menu option...and i got it,but after clicking the option in the slide menu...the control should go the respective page..i tried ..but its not working..please help me

    switch(position){
        case '0': {
            startActivity(new Intent(home.this, home.class));
            finish();
        }
        case '1':
        {
            startActivity(new Intent(home.this, info_values.class));
            finish();
        }
    }

Body:
You should try like this

switch(position){
    case 0:
        startActivity(new Intent(home.this, home.class));
        finish();
        break;
    case 1:

        startActivity(new Intent(home.this, info_values.class));
        finish();
        break;
    default:
        break;

}


问:
ArrayList, LinkedList and Vector which one is the best for adding or removing the element from the list
I appeared for an interview where interviewer asked me about ArrayList, Linked list and Vector. His question was

ArrayList, LinkedList, and Vector are all implementations of the List interface. Which of them is most efficient for adding and removing elements from the list ? And I was supposed to answer including any other alternatives I may be aware of.

I answered him but he seems little not impressed by my answer.

Can someone tell me more about this ?

Thank you

答:
Choose LinkedList if you have a lot of data to adding and removing from list but be careful if you wish to get element from your list than this will be not right Data Structure.</p>

```<code>List<T> list = new LinkedList<T>();
</code>```

Body:
Choose LinkedList if you have a lot of data to adding and removing from list but be careful if you wish to get element from your list than this will be not right Data Structure.

List<T> list = new LinkedList<T>();


问:
scala foreach of a 2-D List/Array in chisel with types issue
Can "foreach" can be used for each element of the 2-D List/Array?
I tried the code:

```<code>val n_vec = (0 to 2).map(i=>
              (0 to 2).map(j=>
                Wire(UInt(3.W))
              )
            )
n_vec.foreach((i:Int)=>(
  n_vec(i).foreach((j:Int)=>{
    n_vec(i)(j) := i.U + j.U
  })
))
</code>```

the error message is

```<code>top.scala:24: error: type mismatch;
 found   : Int => Unit
 required: chisel3.core.UInt => ?
      n_vec(i).foreach((j:Int)=>{
                              ^
</code>```

Could you enlight me whether it can be used in such a way, even how?

答:
It would be cleaner to write like this:

```<code>n_vec.foreach { i=>
  i.foreach { j=>
    j := x.U + y.U
    y = y + 1
  }
  y = 0
  x = x + 1
}
</code>```

But you don't need to increment x and y manually, just iterate over indices instead:

```<code>n_vec.indices.foreach { x =>
  n_vec(x).indices.foreach { y =>
    n_vec(x)(y) := x.U + y.U
  }
}
</code>```

or better (and this translates exactly to the above)

```<code>for {
  x <- n_vec.indices
  y <- n_vec(x).indices
} {
  n_vec(x)(y) := x.U + y.U
}
</code>```

Body:
Can "foreach" can be used for each element of the 2-D List/Array?
I tried the code:

val n_vec = (0 to 2).map(i=>
              (0 to 2).map(j=>
                Wire(UInt(3.W))
              )
            )
n_vec.foreach((i:Int)=>(
  n_vec(i).foreach((j:Int)=>{
    n_vec(i)(j) := i.U + j.U
  })
))

the error message is

top.scala:24: error: type mismatch;
 found   : Int => Unit
 required: chisel3.core.UInt => ?
      n_vec(i).foreach((j:Int)=>{
                              ^

Could you enlight me whether it can be used in such a way, even how?

Body:
It would be cleaner to write like this:

n_vec.foreach { i=>
  i.foreach { j=>
    j := x.U + y.U
    y = y + 1
  }
  y = 0
  x = x + 1
}

But you don't need to increment x and y manually, just iterate over indices instead:

n_vec.indices.foreach { x =>
  n_vec(x).indices.foreach { y =>
    n_vec(x)(y) := x.U + y.U
  }
}

or better (and this translates exactly to the above)

for {
  x <- n_vec.indices
  y <- n_vec(x).indices
} {
  n_vec(x)(y) := x.U + y.U
}


问:
Merging 2 dataframes on Pandas
Sorry I have a very simple question. So I have two dataframes that look like
Dataframe 1:
columns: a b c d e f g h

Dataframe 2:
columns: e ef

I'm trying to join Dataframe 2 on Dataframe 1 at column e, which should yield
columns: a b c d e ef g h
or
columns: a b c d e f g h ef

However:
df1.merge(df2, how = 'inner', on = 'e') yields a blank dataframe when I print it out.

'outer' merge only extends the dataframe vertically (like using an append function).

Would appreciate some help thank you!

Title: Merging 2 dataframes on Pandas

Body:
You need same dtypes of columns for join, so need converting:

#convert string column to int
df1['e'] = df1['e'].astype(int)
#inner is default value, so can be omit
df1.merge(df2, on = 'e')

Sample:

df1 = pd.DataFrame({'a':list('abcdef'),
                   'b':[4,5,4,5,5,4],
                   'c':[7,8,9,4,2,3],
                   'd':[1,3,5,7,1,0],
                   'e':['5','3','6','9','2','4'],
                   'f':list('aaabbb'),
                   'g':[1,3,5,7,1,0]})

print (df1)
   a  b  c  d  e  f  g
0  a  4  7  1  5  a  1
1  b  5  8  3  3  a  3
2  c  4  9  5  6  a  5
3  d  5  4  7  9  b  7
4  e  5  2  1  2  b  1
5  f  4  3  0  4  b  0

df2 = pd.DataFrame({'ef':[10,30,50,70,10,100],
                   'e':[5,3,6,9,0,7]})
print (df2)
   e   ef
0  5   10
1  3   30
2  6   50
3  9   70
4  0   10
5  7  100

df1['e'] = df1['e'].astype(int)
df = df1.merge(df2, on = 'e')
print (df)
   a  b  c  d  e  f  g  ef
0  a  4  7  1  5  a  1  10
1  b  5  8  3  3  a  3  30
2  c  4  9  5  6  a  5  50
3  d  5  4  7  9  b  7  70


问:
R 3.4.1 "Single Candle" Personal Library Path Error: unable to create ‘NA’
I just updated to R (3.4.1 "Single Candle") on my Linux Mint 18.1 Cinnamon machine and I attempted to install a package. R returned the following:

```<code>> install.packages('ggplot2')
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning in install.packages("ggplot2") :
  'lib = "/usr/local/lib/R/site-library"' is not writable
Would you like to use a personal library instead?  (y/n) y
Would you like to create a personal library
NA
to install packages into?  (y/n) y
Error in install.packages("ggplot2") : unable to create ‘NA’
</code>```

I have encountered the 'lib not writable' output before but typically it offers a solution like this one:

```<code>Would you like to create a personal library
~/R/x86_64-pc-linux-gnu-library/3.4
to install packages into?  (y/n) y
</code>```

Any ideas why the personal library is suggesting NA? Is there a way to manually override this?

答:
May be this is a bug of R 3.4.1, and my solution is change the line of

```<code>R_LIBS_SITE=${R_LIBS_SITE-'/usr/local/lib/R/site-library:/usr/lib/R/site-library:/usr/lib/R/library'}
</code>```

in /etc/R/Renviron file into

```<code>R_LIBS_SITE=${R_LIBS_SITE-'~/R/x86_64-pc-linux-gnu-library/3.4.1:/usr/local/lib/R/site-library:/usr/lib/R/site-library:/usr/lib/R/library'}
</code>```

Body:
I just updated to R (3.4.1 "Single Candle") on my Linux Mint 18.1 Cinnamon machine and I attempted to install a package. R returned the following:

> install.packages('ggplot2')
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning in install.packages("ggplot2") :
  'lib = "/usr/local/lib/R/site-library"' is not writable
Would you like to use a personal library instead?  (y/n) y
Would you like to create a personal library
NA
to install packages into?  (y/n) y
Error in install.packages("ggplot2") : unable to create ‘NA’

I have encountered the 'lib not writable' output before but typically it offers a solution like this one:

Would you like to create a personal library
~/R/x86_64-pc-linux-gnu-library/3.4
to install packages into?  (y/n) y

Any ideas why the personal library is suggesting NA? Is there a way to manually override this?

Body:
May be this is a bug of R 3.4.1, and my solution is change the line of

R_LIBS_SITE=${R_LIBS_SITE-'/usr/local/lib/R/site-library:/usr/lib/R/site-library:/usr/lib/R/library'}

in /etc/R/Renviron file into

R_LIBS_SITE=${R_LIBS_SITE-'~/R/x86_64-pc-linux-gnu-library/3.4.1:/usr/local/lib/R/site-library:/usr/lib/R/site-library:/usr/lib/R/library'}


问:
z order in issue in ConstraintLayout Android
I am trying to design a Signup screen using ConstraintLayout everything went smooth except the Z order. When the user clicks on Signup I need to show a FrameLayout on top of everything but it is not working. Please check the screenshot.

```<code><ImageView
    android:id="@+id/background_image"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:scaleType="centerCrop"
    android:tint="#80000000"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<ImageView
    android:id="@+id/logo"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginEnd="32dp"
    android:layout_marginLeft="32dp"
    android:layout_marginRight="32dp"
    android:layout_marginStart="32dp"
    android:layout_marginTop="24dp"
    android:src="@drawable/logo"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="@+id/background_image"
    app:layout_constraintVertical_bias="0.049"
    tools:layout_constraintLeft_creator="1"
    tools:layout_constraintRight_creator="1" />

<TextView
    android:id="@+id/text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="8dp"
    android:layout_marginEnd="7dp"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="7dp"
    android:layout_marginStart="8dp"
    android:layout_marginTop="8dp"
    android:fontFamily="sans-serif-light"
    android:text="There is More"
    android:textColor="@android:color/white"
    app:layout_constraintBottom_toTopOf="@+id/scrollView2"
    app:layout_constraintHorizontal_bias="1.0"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="@+id/logo"
    app:layout_constraintTop_toTopOf="@+id/logo"
    app:layout_constraintVertical_bias="1.0"
    tools:ignore="HardcodedText" />

<ScrollView
    android:id="@+id/scrollView2"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginBottom="8dp"
    android:layout_marginEnd="32dp"
    android:layout_marginLeft="32dp"
    android:layout_marginRight="32dp"
    android:layout_marginStart="32dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/logo"
    app:layout_constraintVertical_bias="0.050000012">

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

        <android.support.design.widget.TextInputLayout
            android:id="@+id/input_layout_first_name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeEditTextLight">

            <EditText
                android:id="@+id/input_name"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Name"
                android:inputType="textPersonName"
                android:theme="@style/ThemeEditTextLight" />

        </android.support.design.widget.TextInputLayout>

        <android.support.design.widget.TextInputLayout
            android:id="@+id/input_layout_email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeEditTextLight">

            <EditText
                android:id="@+id/input_email"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Email"
                android:inputType="textEmailAddress"
                android:theme="@style/ThemeEditTextLight" />

        </android.support.design.widget.TextInputLayout>

        <android.support.design.widget.TextInputLayout
            android:id="@+id/input_layout_phone"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeEditTextLight">

            <EditText
                android:id="@+id/input_phone"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Phone"
                android:inputType="phone"
                android:theme="@style/ThemeEditTextLight" />

        </android.support.design.widget.TextInputLayout>

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

            <android.support.design.widget.TextInputLayout
                android:id="@+id/input_layout_password"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:theme="@style/ThemeEditTextLight">

                <EditText
                    android:id="@+id/input_password"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Password"
                    android:inputType="textPassword"
                    android:theme="@style/ThemeEditTextLight" />

            </android.support.design.widget.TextInputLayout>

        </LinearLayout>

    </LinearLayout>
</ScrollView>

<android.support.v7.widget.AppCompatButton
    android:id="@+id/sign_up_button"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginBottom="8dp"
    android:layout_marginEnd="32dp"
    android:layout_marginLeft="32dp"
    android:layout_marginRight="32dp"
    android:layout_marginStart="32dp"
    android:layout_marginTop="16dp"
    android:backgroundTint="#2a98f0"
    android:elevation="0dp"
    android:paddingBottom="16dp"
    android:paddingTop="16dp"
    android:text="Sign up"
    android:textColor="@android:color/white"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/scrollView2"
    app:layout_constraintVertical_bias="0.100000024" />

<TextView
    android:id="@+id/or_tv"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    android:layout_marginStart="8dp"
    android:fontFamily="sans-serif-light"
    android:gravity="center"
    android:text="or\nSign up with social sites"
    android:textColor="@color/white"
    app:layout_constraintBottom_toTopOf="@+id/imageView6"
    app:layout_constraintHorizontal_bias="0.501"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent" />

<ImageView
    android:id="@+id/imageView6"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    android:layout_marginStart="8dp"
    android:layout_marginTop="8dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintHorizontal_bias="0.501"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="@+id/or_tv"
    app:layout_constraintVertical_bias="0.8"
    app:srcCompat="@drawable/ic_google_plus" />

<FrameLayout
    android:id="@+id/progressBar"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:background="@color/red"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <ProgressBar
        android:id="@+id/progressBarChild"
        style="?android:attr/progressBarStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center" />
</FrameLayout>
</code>```

答:
Try to set android:stateListAnimator="@null" to the Button/AppCompatButton

In Lollipop (Android 5.0 (API 21)) and above, Buttons have a default elevation which causes them to always draw on top.

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

    <ImageView
        android:id="@+id/background_image"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:scaleType="centerCrop"
        android:tint="#80000000"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <ImageView
        android:id="@+id/logo"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="32dp"
        android:layout_marginLeft="32dp"
        android:layout_marginRight="32dp"
        android:layout_marginStart="32dp"
        android:layout_marginTop="24dp"
        android:src="@drawable/logo"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="@+id/background_image"
        app:layout_constraintVertical_bias="0.049"
        tools:layout_constraintLeft_creator="1"
        tools:layout_constraintRight_creator="1" />

    <TextView
        android:id="@+id/text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="7dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="7dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:fontFamily="sans-serif-light"
        android:text="There is More"
        android:textColor="@android:color/white"
        app:layout_constraintBottom_toTopOf="@+id/scrollView2"
        app:layout_constraintHorizontal_bias="1.0"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="@+id/logo"
        app:layout_constraintTop_toTopOf="@+id/logo"
        app:layout_constraintVertical_bias="1.0"
        tools:ignore="HardcodedText" />

    <ScrollView
        android:id="@+id/scrollView2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="32dp"
        android:layout_marginLeft="32dp"
        android:layout_marginRight="32dp"
        android:layout_marginStart="32dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/logo"
        app:layout_constraintVertical_bias="0.050000012">

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

            <android.support.design.widget.TextInputLayout
                android:id="@+id/input_layout_first_name"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:theme="@style/ThemeEditTextLight">

                <EditText
                    android:id="@+id/input_name"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Name"
                    android:inputType="textPersonName"
                    android:theme="@style/ThemeEditTextLight" />

            </android.support.design.widget.TextInputLayout>

            <android.support.design.widget.TextInputLayout
                android:id="@+id/input_layout_email"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:theme="@style/ThemeEditTextLight">

                <EditText
                    android:id="@+id/input_email"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Email"
                    android:inputType="textEmailAddress"
                    android:theme="@style/ThemeEditTextLight" />

            </android.support.design.widget.TextInputLayout>

            <android.support.design.widget.TextInputLayout
                android:id="@+id/input_layout_phone"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:theme="@style/ThemeEditTextLight">

                <EditText
                    android:id="@+id/input_phone"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Phone"
                    android:inputType="phone"
                    android:theme="@style/ThemeEditTextLight" />

            </android.support.design.widget.TextInputLayout>

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

                <android.support.design.widget.TextInputLayout
                    android:id="@+id/input_layout_password"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:theme="@style/ThemeEditTextLight">

                    <EditText
                        android:id="@+id/input_password"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="Password"
                        android:inputType="textPassword"
                        android:theme="@style/ThemeEditTextLight" />

                </android.support.design.widget.TextInputLayout>

            </LinearLayout>

        </LinearLayout>
    </ScrollView>

    <android.support.v7.widget.AppCompatButton
        android:id="@+id/sign_up_button"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="32dp"
        android:layout_marginLeft="32dp"
        android:layout_marginRight="32dp"
        android:layout_marginStart="32dp"
        android:layout_marginTop="16dp"
        android:backgroundTint="#2a98f0"
        android:stateListAnimator="@null"
        android:elevation="0dp"
        android:paddingBottom="16dp"
        android:paddingTop="16dp"
        android:text="Sign up"
        android:textColor="@android:color/white"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/scrollView2"
        app:layout_constraintVertical_bias="0.100000024" />

    <TextView
        android:id="@+id/or_tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginStart="8dp"
        android:fontFamily="sans-serif-light"
        android:gravity="center"
        android:text="or\nSign up with social sites"
        android:textColor="@color/white"
        app:layout_constraintBottom_toTopOf="@+id/imageView6"
        app:layout_constraintHorizontal_bias="0.501"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent" />

    <ImageView
        android:id="@+id/imageView6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.501"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="@+id/or_tv"
        app:layout_constraintVertical_bias="0.8"
        app:srcCompat="@drawable/ic_google_plus" />

    <FrameLayout
        android:id="@+id/progressBar"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="@color/red"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <ProgressBar
            android:id="@+id/progressBarChild"
            style="?android:attr/progressBarStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center" />
    </FrameLayout>

</android.support.constraint.ConstraintLayout>
</code>```

This worked for me.

Body:
I am trying to design a Signup screen using ConstraintLayout everything went smooth except the Z order. When the user clicks on Signup I need to show a FrameLayout on top of everything but it is not working. Please check the screenshot.

<ImageView
    android:id="@+id/background_image"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:scaleType="centerCrop"
    android:tint="#80000000"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<ImageView
    android:id="@+id/logo"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginEnd="32dp"
    android:layout_marginLeft="32dp"
    android:layout_marginRight="32dp"
    android:layout_marginStart="32dp"
    android:layout_marginTop="24dp"
    android:src="@drawable/logo"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="@+id/background_image"
    app:layout_constraintVertical_bias="0.049"
    tools:layout_constraintLeft_creator="1"
    tools:layout_constraintRight_creator="1" />

<TextView
    android:id="@+id/text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="8dp"
    android:layout_marginEnd="7dp"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="7dp"
    android:layout_marginStart="8dp"
    android:layout_marginTop="8dp"
    android:fontFamily="sans-serif-light"
    android:text="There is More"
    android:textColor="@android:color/white"
    app:layout_constraintBottom_toTopOf="@+id/scrollView2"
    app:layout_constraintHorizontal_bias="1.0"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="@+id/logo"
    app:layout_constraintTop_toTopOf="@+id/logo"
    app:layout_constraintVertical_bias="1.0"
    tools:ignore="HardcodedText" />

<ScrollView
    android:id="@+id/scrollView2"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginBottom="8dp"
    android:layout_marginEnd="32dp"
    android:layout_marginLeft="32dp"
    android:layout_marginRight="32dp"
    android:layout_marginStart="32dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/logo"
    app:layout_constraintVertical_bias="0.050000012">

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

        <android.support.design.widget.TextInputLayout
            android:id="@+id/input_layout_first_name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeEditTextLight">

            <EditText
                android:id="@+id/input_name"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Name"
                android:inputType="textPersonName"
                android:theme="@style/ThemeEditTextLight" />

        </android.support.design.widget.TextInputLayout>

        <android.support.design.widget.TextInputLayout
            android:id="@+id/input_layout_email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeEditTextLight">

            <EditText
                android:id="@+id/input_email"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Email"
                android:inputType="textEmailAddress"
                android:theme="@style/ThemeEditTextLight" />

        </android.support.design.widget.TextInputLayout>

        <android.support.design.widget.TextInputLayout
            android:id="@+id/input_layout_phone"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeEditTextLight">

            <EditText
                android:id="@+id/input_phone"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Phone"
                android:inputType="phone"
                android:theme="@style/ThemeEditTextLight" />

        </android.support.design.widget.TextInputLayout>

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

            <android.support.design.widget.TextInputLayout
                android:id="@+id/input_layout_password"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:theme="@style/ThemeEditTextLight">

                <EditText
                    android:id="@+id/input_password"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Password"
                    android:inputType="textPassword"
                    android:theme="@style/ThemeEditTextLight" />

            </android.support.design.widget.TextInputLayout>

        </LinearLayout>

    </LinearLayout>
</ScrollView>

<android.support.v7.widget.AppCompatButton
    android:id="@+id/sign_up_button"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginBottom="8dp"
    android:layout_marginEnd="32dp"
    android:layout_marginLeft="32dp"
    android:layout_marginRight="32dp"
    android:layout_marginStart="32dp"
    android:layout_marginTop="16dp"
    android:backgroundTint="#2a98f0"
    android:elevation="0dp"
    android:paddingBottom="16dp"
    android:paddingTop="16dp"
    android:text="Sign up"
    android:textColor="@android:color/white"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/scrollView2"
    app:layout_constraintVertical_bias="0.100000024" />

<TextView
    android:id="@+id/or_tv"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    android:layout_marginStart="8dp"
    android:fontFamily="sans-serif-light"
    android:gravity="center"
    android:text="or\nSign up with social sites"
    android:textColor="@color/white"
    app:layout_constraintBottom_toTopOf="@+id/imageView6"
    app:layout_constraintHorizontal_bias="0.501"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent" />

<ImageView
    android:id="@+id/imageView6"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    android:layout_marginStart="8dp"
    android:layout_marginTop="8dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintHorizontal_bias="0.501"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="@+id/or_tv"
    app:layout_constraintVertical_bias="0.8"
    app:srcCompat="@drawable/ic_google_plus" />

<FrameLayout
    android:id="@+id/progressBar"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:background="@color/red"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <ProgressBar
        android:id="@+id/progressBarChild"
        style="?android:attr/progressBarStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center" />
</FrameLayout>

Body:
Try to set android:stateListAnimator="@null" to the Button/AppCompatButton

In Lollipop (Android 5.0 (API 21)) and above, Buttons have a default elevation which causes them to always draw on top.

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

    <ImageView
        android:id="@+id/background_image"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:scaleType="centerCrop"
        android:tint="#80000000"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <ImageView
        android:id="@+id/logo"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="32dp"
        android:layout_marginLeft="32dp"
        android:layout_marginRight="32dp"
        android:layout_marginStart="32dp"
        android:layout_marginTop="24dp"
        android:src="@drawable/logo"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="@+id/background_image"
        app:layout_constraintVertical_bias="0.049"
        tools:layout_constraintLeft_creator="1"
        tools:layout_constraintRight_creator="1" />

    <TextView
        android:id="@+id/text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="7dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="7dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:fontFamily="sans-serif-light"
        android:text="There is More"
        android:textColor="@android:color/white"
        app:layout_constraintBottom_toTopOf="@+id/scrollView2"
        app:layout_constraintHorizontal_bias="1.0"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="@+id/logo"
        app:layout_constraintTop_toTopOf="@+id/logo"
        app:layout_constraintVertical_bias="1.0"
        tools:ignore="HardcodedText" />

    <ScrollView
        android:id="@+id/scrollView2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="32dp"
        android:layout_marginLeft="32dp"
        android:layout_marginRight="32dp"
        android:layout_marginStart="32dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/logo"
        app:layout_constraintVertical_bias="0.050000012">

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

            <android.support.design.widget.TextInputLayout
                android:id="@+id/input_layout_first_name"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:theme="@style/ThemeEditTextLight">

                <EditText
                    android:id="@+id/input_name"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Name"
                    android:inputType="textPersonName"
                    android:theme="@style/ThemeEditTextLight" />

            </android.support.design.widget.TextInputLayout>

            <android.support.design.widget.TextInputLayout
                android:id="@+id/input_layout_email"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:theme="@style/ThemeEditTextLight">

                <EditText
                    android:id="@+id/input_email"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Email"
                    android:inputType="textEmailAddress"
                    android:theme="@style/ThemeEditTextLight" />

            </android.support.design.widget.TextInputLayout>

            <android.support.design.widget.TextInputLayout
                android:id="@+id/input_layout_phone"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:theme="@style/ThemeEditTextLight">

                <EditText
                    android:id="@+id/input_phone"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Phone"
                    android:inputType="phone"
                    android:theme="@style/ThemeEditTextLight" />

            </android.support.design.widget.TextInputLayout>

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

                <android.support.design.widget.TextInputLayout
                    android:id="@+id/input_layout_password"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:theme="@style/ThemeEditTextLight">

                    <EditText
                        android:id="@+id/input_password"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="Password"
                        android:inputType="textPassword"
                        android:theme="@style/ThemeEditTextLight" />

                </android.support.design.widget.TextInputLayout>

            </LinearLayout>

        </LinearLayout>
    </ScrollView>

    <android.support.v7.widget.AppCompatButton
        android:id="@+id/sign_up_button"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="32dp"
        android:layout_marginLeft="32dp"
        android:layout_marginRight="32dp"
        android:layout_marginStart="32dp"
        android:layout_marginTop="16dp"
        android:backgroundTint="#2a98f0"
        android:stateListAnimator="@null"
        android:elevation="0dp"
        android:paddingBottom="16dp"
        android:paddingTop="16dp"
        android:text="Sign up"
        android:textColor="@android:color/white"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/scrollView2"
        app:layout_constraintVertical_bias="0.100000024" />

    <TextView
        android:id="@+id/or_tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginStart="8dp"
        android:fontFamily="sans-serif-light"
        android:gravity="center"
        android:text="or\nSign up with social sites"
        android:textColor="@color/white"
        app:layout_constraintBottom_toTopOf="@+id/imageView6"
        app:layout_constraintHorizontal_bias="0.501"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent" />

    <ImageView
        android:id="@+id/imageView6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.501"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="@+id/or_tv"
        app:layout_constraintVertical_bias="0.8"
        app:srcCompat="@drawable/ic_google_plus" />

    <FrameLayout
        android:id="@+id/progressBar"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="@color/red"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <ProgressBar
            android:id="@+id/progressBarChild"
            style="?android:attr/progressBarStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center" />
    </FrameLayout>

</android.support.constraint.ConstraintLayout>

This worked for me.


问:
Rails: Password can't be blank with has_secure_password
I am trying to follow this tutorial (Rails Tutorial by Michael Hartl) to create a valid user. Filling in the password fields still gives me the error "Password cannot be blank" and "Password has to be longer thank 6 letters". I tried creating a user through the rails console, and that worked fine. It is only when I try doing it through the website itself.

My user model looks like this:

```<code>class User < ApplicationRecord
  #before saving, make sure the email is in downcase
  before_save { self.email = email.downcase }

  validates :name,  presence: true, length: { maximum: 50 }
  VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
  validates :email, presence: true, length: { maximum: 255 },
                format: { with: VALID_EMAIL_REGEX },
                uniqueness: {case_sensitive: false}

  has_secure_password
  validates :password, presence: true, length: { minimum: 6 }
end
</code>```

My user_controller looks like this:

```<code>class UsersController < ApplicationController
before_action :set_user, only: [:show, :edit, :update, :destroy]
#wrap_parameters :user, include: [:name, :email, :password, :password_confirmation]

def index
  @users = User.all
end

def show
  @user = User.find(params[:id])
  #debugger
end
def new
  @user = User.new
end

# GET /users/1/edit
def edit
end

#POST /users
#POST /users.json
def create
  @user = User.new(user_params) #params[:user])#user_params)

  respond_to do |format|
    if @user.save
      #flash[:success] = "Welcome to CourseBuddies!"

      format.html { redirect_to @user, notice: 'User was successfully created.' }
      format.json { render :show, status: :created, location: @user }
      redirect_to @user
    else
      #render 'new'
      format.html { render :new }
      format.json { render json: @user.errors, status: :unprocessable_entity }
    end
  end
end

# PATCH/PUT /users/1
# PATCH/PUT /users/1.json
def update
  respond_to do |format|
    if @user.update(user_params)
      format.html { redirect_to @user, notice: 'User was successfully updated.' }
      format.json { render :show, status: :ok, location: @user }
    else
      format.html { render :edit }
      format.json { render json: @user.errors, status: :unprocessable_entity }
    end
  end
end

# DELETE /users/1
# DELETE /users/1.json
def destroy
  @user.destroy
  respond_to do |format|
    format.html { redirect_to users_url, notice: 'User was successfully destroyed.' }
    format.json { head :no_content }
  end
end

private
  # Use callbacks to share common setup or constraints between actions.
  def set_user
    @user = User.find(params[:id])
  end

  # Never trust parameters from the scary internet, only allow the white list through.
  def user_params
    params.require(:user).permit(:name, :email, :pasword, :password_confirmation)
  end
end
</code>```

This is my Migration file create_user:

```<code>class CreateUsers < ActiveRecord::Migration[5.0]
 def change
   create_table :users do |t|
     t.string :name
     t.string :email
     t.string :password
     t.string :password_confirmation

     t.timestamps
   end
 end
</code>```

end

I've tried different solutions found online like using "wrap_parameters" and such it doesn't seem to do anything for me.

My Gemfile looks like this:

```<code># Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.1'
gem 'bootstrap-sass', '3.3.7'
# make pw digest "has_secure_password" use a stateofart hash function (bcrypt)
gem 'bcrypt', '3.1.11'
# Use postgresql as the database for Active Record
gem 'pg', '~> 0.18.4'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more:     https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  gem 'sqlite3', '1.3.13' #railsTuto said to get this, but already use postgresql
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platform: :mri
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '~> 3.0.5'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

group :test do
  gem 'rails-controller-testing', '1.0.2'
  gem 'minitest-reporters',       '1.1.14'
  gem 'guard',                    '2.13.0'
  gem 'guard-minitest',           '2.4.4'
end

group :production do
  gem 'pg', '~>0.18.4'
  gem 'rails_12factor'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
</code>```

EDIT: My FORM

```<code><%- #FIELDS FOR THE FORM %>
<div class="row">
  <div class="col-md-6 col-md-offset-3">
    <%= form_for(@user, url: signup_path) do |f| %>

    <%- #ERROR MESSAGES %>
    <%= render 'shared/error_messages' %>

    <%= f.label :name %>
    <%= f.text_field :name, class: 'form-control' %>

    <br>
    <%= f.label :email %>
    <%= f.email_field :email, class: 'form-control' %>

    <br>
    <%= f.label :password %>
    <%= f.password_field :password, class: 'form-control' %>

    <br>
    <%= f.label :password_confirmation, "Confirmation" %>
    <%= f.password_field :password_confirmation, class: 'form-control' %>

    <br><br>
    <%= f.submit "Create my account", class: "btn btn-primary" %>
  <% end %>
</div>
</code>```

I would appreciate any kind of help or clarification. Thanks!

答:
I think you need to add  allow_nil: true in validation

```<code>validates :password, presence: true, length: { minimum: 6 }, allow_nil: true
</code>```

As allow_nil: true will not allows to create empty string.

Body:
I am trying to follow this tutorial (Rails Tutorial by Michael Hartl) to create a valid user. Filling in the password fields still gives me the error "Password cannot be blank" and "Password has to be longer thank 6 letters". I tried creating a user through the rails console, and that worked fine. It is only when I try doing it through the website itself.

My user model looks like this:

class User < ApplicationRecord
  #before saving, make sure the email is in downcase
  before_save { self.email = email.downcase }

  validates :name,  presence: true, length: { maximum: 50 }
  VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
  validates :email, presence: true, length: { maximum: 255 },
                format: { with: VALID_EMAIL_REGEX },
                uniqueness: {case_sensitive: false}

  has_secure_password
  validates :password, presence: true, length: { minimum: 6 }
end

My user_controller looks like this:

class UsersController < ApplicationController
before_action :set_user, only: [:show, :edit, :update, :destroy]
#wrap_parameters :user, include: [:name, :email, :password, :password_confirmation]

def index
  @users = User.all
end

def show
  @user = User.find(params[:id])
  #debugger
end
def new
  @user = User.new
end

# GET /users/1/edit
def edit
end

#POST /users
#POST /users.json
def create
  @user = User.new(user_params) #params[:user])#user_params)

  respond_to do |format|
    if @user.save
      #flash[:success] = "Welcome to CourseBuddies!"

      format.html { redirect_to @user, notice: 'User was successfully created.' }
      format.json { render :show, status: :created, location: @user }
      redirect_to @user
    else
      #render 'new'
      format.html { render :new }
      format.json { render json: @user.errors, status: :unprocessable_entity }
    end
  end
end

# PATCH/PUT /users/1
# PATCH/PUT /users/1.json
def update
  respond_to do |format|
    if @user.update(user_params)
      format.html { redirect_to @user, notice: 'User was successfully updated.' }
      format.json { render :show, status: :ok, location: @user }
    else
      format.html { render :edit }
      format.json { render json: @user.errors, status: :unprocessable_entity }
    end
  end
end

# DELETE /users/1
# DELETE /users/1.json
def destroy
  @user.destroy
  respond_to do |format|
    format.html { redirect_to users_url, notice: 'User was successfully destroyed.' }
    format.json { head :no_content }
  end
end

private
  # Use callbacks to share common setup or constraints between actions.
  def set_user
    @user = User.find(params[:id])
  end

  # Never trust parameters from the scary internet, only allow the white list through.
  def user_params
    params.require(:user).permit(:name, :email, :pasword, :password_confirmation)
  end
end

This is my Migration file create_user:

class CreateUsers < ActiveRecord::Migration[5.0]
 def change
   create_table :users do |t|
     t.string :name
     t.string :email
     t.string :password
     t.string :password_confirmation

     t.timestamps
   end
 end

end

I've tried different solutions found online like using "wrap_parameters" and such it doesn't seem to do anything for me.

My Gemfile looks like this:

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.1'
gem 'bootstrap-sass', '3.3.7'
# make pw digest "has_secure_password" use a stateofart hash function (bcrypt)
gem 'bcrypt', '3.1.11'
# Use postgresql as the database for Active Record
gem 'pg', '~> 0.18.4'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more:     https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  gem 'sqlite3', '1.3.13' #railsTuto said to get this, but already use postgresql
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platform: :mri
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '~> 3.0.5'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

group :test do
  gem 'rails-controller-testing', '1.0.2'
  gem 'minitest-reporters',       '1.1.14'
  gem 'guard',                    '2.13.0'
  gem 'guard-minitest',           '2.4.4'
end

group :production do
  gem 'pg', '~>0.18.4'
  gem 'rails_12factor'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

EDIT: My FORM

<%- #FIELDS FOR THE FORM %>

    <%= form_for(@user, url: signup_path) do |f| %>

    <%- #ERROR MESSAGES %>
    <%= render 'shared/error_messages' %>

    <%= f.label :name %>
    <%= f.text_field :name, class: 'form-control' %>

    <%= f.label :email %>
    <%= f.email_field :email, class: 'form-control' %>

    <%= f.label :password %>
    <%= f.password_field :password, class: 'form-control' %>

    <%= f.label :password_confirmation, "Confirmation" %>
    <%= f.password_field :password_confirmation, class: 'form-control' %>

    <%= f.submit "Create my account", class: "btn btn-primary" %>
  <% end %>

I would appreciate any kind of help or clarification. Thanks!

Body:
I think you need to add  allow_nil: true in validation

validates :password, presence: true, length: { minimum: 6 }, allow_nil: true

As allow_nil: true will not allows to create empty string.


问:
drop down list appears in front of my calender in asp.net
Drop Down list comes in front of all the controls. I have a calander extender for the text box which is right above(top) the drop down. when the calender pop's out it goes under i.e behind the drop down. Any solution friends.</p>

答:
It wont like it via the google intellisense but you need to add the following to your DropDownList markup:

```<code><asp:TextBox runat="server" id="TextBox1" autocomplete="off" />
</code>```

By default if asp.net finds an attribute that it doesnt recognise then it simply passes it through into the underlying html that is generated.

Note 1: There is some kind of AutoComplete setting for this control but this doesnt do what you need it to do, you need the lowercase version like I have stated above.

Note 2: This is a non-standard attribute. It works in FF and IE but it will cause your validation to fail if you run it through the w3c checker.

Body:
It wont like it via the google intellisense but you need to add the following to your DropDownList markup:

<asp:TextBox runat="server" id="TextBox1" autocomplete="off" />

By default if asp.net finds an attribute that it doesnt recognise then it simply passes it through into the underlying html that is generated.

Note 1: There is some kind of AutoComplete setting for this control but this doesnt do what you need it to do, you need the lowercase version like I have stated above.

Note 2: This is a non-standard attribute. It works in FF and IE but it will cause your validation to fail if you run it through the w3c checker.


问:
Reportlab: adding image as background
i'm building an easy pdf document as linked in the following tutorial: LINK, but i have the problem of place a background image into the document, creating something like a watermark.

How i can do this without using Canvas?

Thanks

答: At the end, for this complex operations, i've used the Canvas document object, and on that i've placed the background image as "Watermark"</p>

Title: Reportlab: adding image as background


问:
Good languages to write a compiler for
I'm thinking of writing a compiler in haskell, and just to gain some knowledge and experience, I will try to implement compilers for existing languages. Could someone give me a list of languages which are suitable for this?

Thanks in advance

答:
Oberon-2. Like Lua has short context-free grammar.

P.S. Here you can find Oberon-2 compiler written in Objective Caml.

Title: Good languages to write a compiler for