问:
Modal Not loading in React using materialize css
I am new to React and I am trying to create a modal using materialize.css http://materializecss.com

My Login page looks like this

```<code>import React from 'react';
var Modal=require('Modal');

class login extends React.Component{
constructor(props){
    super(props);
    this.state={
        view: {showModal: false}
    }
    this.handleHideModal=this.handleHideModal.bind(this);
    this.handleShowModal=this.handleShowModal.bind(this);

}
handleHideModal(){
    this.setState({view: {showModal: false}})
}
handleShowModal(){
    $('#modal1').modal('open');
}
componentDidMount(){
    $('#modal1').modal('open');
}
render(){
return(
    <div>
        <div className="login">
            <div className="">
                <div className="input-field col s8">
                    <i className="material-icons prefix">account_circle</i>
                    <input  id="username" type="text" className="validate"/>
                    <label htmlFor="username">User Name</label>
                </div>
                <div className="input-field col s8">
                    <i className="material-icons prefix">vpn_key</i>
                    <input id="password" type="password" className="validate"/>
                    <label htmlFor="password">Password</label>
                </div>
                <div className="center input-field col s6">
                        <input type="checkbox" className="filled-in" id="filled-in-box" defaultChecked="checked" />
                        <label htmlFor="filled-in-box">Remember me</label>
                </div>
                <div className="center input-field col s12">
                    <a className="login-button waves-effect waves-light btn center">Login</a>
                </div>
                <div className="row input-field col s12">
                    <div className="col s6 left-align">
                        <a className="modal-trigger " onClick={this.handleShowModal} >Register Now</a>
                    </div>
                    <div className="col s6 right-align">
                        <a>Forgot Password?</a>
                    </div>
                </div>
            </div>
        </div>
        {this.state.view.showModal ? <Modal handleHideModal={this.handleHideModal}/>:null}
    </div>
);
}
};

module.exports= login;
</code>```

My modal component looks like this.

```<code>import React from 'react';
import ReactDOM from 'react-dom';

class Modal extends React.Component{
componentDidMount(){
    //var modal = new Foundation.Reveal($('#modal1'));
    //modal.open();
    $('#modal1').open();
    $(ReactDOM.findDOMNode('#modal1')).modal('show');
    //$(ReactDOM.findDOMNode(this)).on('hidden.bs.modal', this.props.handleHideModal);
}
render(){
    return(
        <div id="modal1" className="modal">
            <div className="modal-content">
                <h4>Modal Header</h4>
                <p>A bunch of text</p>
            </div>
            <div className="modal-footer">
                <a href="#!" className="modal-action modal-close waves-effect waves-green btn-flat">Agree</a>
            </div>
        </div>
    );
}
propTypes:{
    handleHideModal: React.PropTypes.func.isRequired
}
};

module.exports = Modal;
</code>```

I tried a lot of suggestions found on the internet, nothing worked out. I am not understanding what the issue is.

答:
In React, you should not access elements via document.getElementById or via querySelector (or your jQuery-like $ function) directly. Facebook is addressing this at https://facebook.github.io/react/docs/refs-and-the-dom.html

But to answer your question, I would suggest to change the behaviour to something like this:

```<code>import React from 'react';
var Modal=require('Modal');

class login extends React.Component{
constructor(props){
    super(props);
    this.state={
        view: {showModal: false}
    }
    this.handleHideModal=this.handleHideModal.bind(this);
    this.handleShowModal=this.handleShowModal.bind(this);

}
handleHideModal(){
    this.setState({view: {showModal: false}})
}
handleShowModal(){
    this.setState({view: {showModal: true}})
}

render(){
return(
    <div>
        <div className="login">
            <div className="">
                <div className="input-field col s8">
                    <i className="material-icons prefix">account_circle</i>
                    <input  id="username" type="text" className="validate"/>
                    <label htmlFor="username">User Name</label>
                </div>
                <div className="input-field col s8">
                    <i className="material-icons prefix">vpn_key</i>
                    <input id="password" type="password" className="validate"/>
                    <label htmlFor="password">Password</label>
                </div>
                <div className="center input-field col s6">
                        <input type="checkbox" className="filled-in" id="filled-in-box" defaultChecked="checked" />
                        <label htmlFor="filled-in-box">Remember me</label>
                </div>
                <div className="center input-field col s12">
                    <a className="login-button waves-effect waves-light btn center">Login</a>
                </div>
                <div className="row input-field col s12">
                    <div className="col s6 left-align">
                        <a className="modal-trigger " onClick={this.handleShowModal} >Register Now</a>
                    </div>
                    <div className="col s6 right-align">
                        <a>Forgot Password?</a>
                    </div>
                </div>
            </div>
        </div>
        <Modal handleHideModal={this.handleHideModal} show={this.state.view.showModal}/>
    </div>
);
}
};

module.exports= login;
</code>```

and for the Modal Component you need to react on the show property that we are passing:

```<code>import React from 'react';

class Modal extends React.Component{

render(){
    return(
        <div id="modal1" className={this.props.show ? 'modal open' : 'modal'}>
            <div className="modal-content">
                <h4>Modal Header</h4>
                <p>A bunch of text</p>
            </div>
            <div className="modal-footer">
                <a href="#!" className="modal-action modal-close waves-effect waves-green btn-flat">Agree</a>
            </div>
        </div>
    );
}
propTypes:{
    handleHideModal: React.PropTypes.func.isRequired,
    show: React.PropTypes.bool.isRequired,
}
};

module.exports = Modal;
</code>```

I don't know if the 'modal open' css part in render method of your Modal Component is the correct classname for opening this modal window in your css framework but i think you get the idea.

Edit: If changing the class to open alone does not work you should think of adding a react implementation of materialize css like this one: https://github.com/react-materialize/react-materialize.

Adding a modal there is as simple as this: https://react-materialize.github.io/modals.html

You will just need to put the modal in your modal component:

```<code>import React from 'react';
import { Modal } from 'react-materialize';

class Modal extends React.Component{

render(){
    return(
        <Modal
          header='Modal Header'
          trigger={
            <Button waves='light'>MODAL</Button>
          }>
          <p>Lorem ipsum dolor sit amet</p>
        </Modal>
    );
}
propTypes:{
    handleHideModal: React.PropTypes.func.isRequired,
    show: React.PropTypes.bool.isRequired,
}
};

module.exports = Modal;
</code>```

Body:
I am new to React and I am trying to create a modal using materialize.css http://materializecss.com

My Login page looks like this

import React from 'react';
var Modal=require('Modal');

class login extends React.Component{
constructor(props){
    super(props);
    this.state={
        view: {showModal: false}
    }
    this.handleHideModal=this.handleHideModal.bind(this);
    this.handleShowModal=this.handleShowModal.bind(this);

}
handleHideModal(){
    this.setState({view: {showModal: false}})
}
handleShowModal(){
    $('#modal1').modal('open');
}
componentDidMount(){
    $('#modal1').modal('open');
}
render(){
return(

                    account_circle
                    <input  id="username" type="text" className="validate"/>
                    User Name

                    vpn_key
                    <input id="password" type="password" className="validate"/>
                    Password

                        <input type="checkbox" className="filled-in" id="filled-in-box" defaultChecked="checked" />
                        Remember me

                    Login

                        Register Now

                        Forgot Password?

        {this.state.view.showModal ? <Modal handleHideModal={this.handleHideModal}/>:null}

);
}
};

module.exports= login;

My modal component looks like this.

import React from 'react';
import ReactDOM from 'react-dom';

class Modal extends React.Component{
componentDidMount(){
    //var modal = new Foundation.Reveal($('#modal1'));
    //modal.open();
    $('#modal1').open();
    $(ReactDOM.findDOMNode('#modal1')).modal('show');
    //$(ReactDOM.findDOMNode(this)).on('hidden.bs.modal', this.props.handleHideModal);
}
render(){
    return(

Modal Header

A bunch of text

                Agree

    );
}
propTypes:{
    handleHideModal: React.PropTypes.func.isRequired
}
};

module.exports = Modal;

I tried a lot of suggestions found on the internet, nothing worked out. I am not understanding what the issue is.

Body:
In React, you should not access elements via document.getElementById or via querySelector (or your jQuery-like $ function) directly. Facebook is addressing this at https://facebook.github.io/react/docs/refs-and-the-dom.html

But to answer your question, I would suggest to change the behaviour to something like this:

import React from 'react';
var Modal=require('Modal');

class login extends React.Component{
constructor(props){
    super(props);
    this.state={
        view: {showModal: false}
    }
    this.handleHideModal=this.handleHideModal.bind(this);
    this.handleShowModal=this.handleShowModal.bind(this);

}
handleHideModal(){
    this.setState({view: {showModal: false}})
}
handleShowModal(){
    this.setState({view: {showModal: true}})
}

render(){
return(
    <div>
        <div className="login">
            <div className="">
                <div className="input-field col s8">
                    <i className="material-icons prefix">account_circle</i>
                    <input  id="username" type="text" className="validate"/>
                    <label htmlFor="username">User Name</label>
                </div>
                <div className="input-field col s8">
                    <i className="material-icons prefix">vpn_key</i>
                    <input id="password" type="password" className="validate"/>
                    <label htmlFor="password">Password</label>
                </div>
                <div className="center input-field col s6">
                        <input type="checkbox" className="filled-in" id="filled-in-box" defaultChecked="checked" />
                        <label htmlFor="filled-in-box">Remember me</label>
                </div>
                <div className="center input-field col s12">
                    <a className="login-button waves-effect waves-light btn center">Login</a>
                </div>
                <div className="row input-field col s12">
                    <div className="col s6 left-align">
                        <a className="modal-trigger " onClick={this.handleShowModal} >Register Now</a>
                    </div>
                    <div className="col s6 right-align">
                        <a>Forgot Password?</a>
                    </div>
                </div>
            </div>
        </div>
        <Modal handleHideModal={this.handleHideModal} show={this.state.view.showModal}/>
    </div>
);
}
};

module.exports= login;

and for the Modal Component you need to react on the show property that we are passing:

import React from 'react';

class Modal extends React.Component{

render(){
    return(
        <div id="modal1" className={this.props.show ? 'modal open' : 'modal'}>
            <div className="modal-content">
                <h4>Modal Header</h4>
                <p>A bunch of text</p>
            </div>
            <div className="modal-footer">
                <a href="#!" className="modal-action modal-close waves-effect waves-green btn-flat">Agree</a>
            </div>
        </div>
    );
}
propTypes:{
    handleHideModal: React.PropTypes.func.isRequired,
    show: React.PropTypes.bool.isRequired,
}
};

module.exports = Modal;

I don't know if the 'modal open' css part in render method of your Modal Component is the correct classname for opening this modal window in your css framework but i think you get the idea.

Edit: If changing the class to open alone does not work you should think of adding a react implementation of materialize css like this one: https://github.com/react-materialize/react-materialize.

Adding a modal there is as simple as this: https://react-materialize.github.io/modals.html

You will just need to put the modal in your modal component:

import React from 'react';
import { Modal } from 'react-materialize';

class Modal extends React.Component{

render(){
    return(
        <Modal
          header='Modal Header'
          trigger={
            <Button waves='light'>MODAL</Button>
          }>
          <p>Lorem ipsum dolor sit amet</p>
        </Modal>
    );
}
propTypes:{
    handleHideModal: React.PropTypes.func.isRequired,
    show: React.PropTypes.bool.isRequired,
}
};

module.exports = Modal;


来源: stackexchange

问:
Creating an ID to go along with my data when querying SQL Server
I have a little problem when querying data. I have a table that looks like this:

```<code>Value1       Value2
--------------------
ABC          123
BCD          123
DCE          123
EFG          123
</code>```

What I'm hoping to do is, basically only select VALUE1 from this table, however, I'd like to assign an ID to go along with each value...

Desired end result

```<code>ID      Value1
--------------
1       ABC
2       BCD
3       DCE
4       EFG
</code>```

Is something like that possible? I'd hope to have the end result to be in alphabetical order and ID's assigned based in ASCENDING order. Also, would hope that this query can be in place even if more VALUE1 values are added in the table (dynamic)

Any ideas?

答:
You can use window function row_number while selecting:

```<code>select row_number() over (
        order by value1
        ) as id,
    value1
from your_table;
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I have a little problem when querying data. I have a table that looks like this:

Value1       Value2
--------------------
ABC          123
BCD          123
DCE          123
EFG          123

What I'm hoping to do is, basically only select VALUE1 from this table, however, I'd like to assign an ID to go along with each value...

Desired end result

ID      Value1
--------------
1       ABC
2       BCD
3       DCE
4       EFG

Is something like that possible? I'd hope to have the end result to be in alphabetical order and ID's assigned based in ASCENDING order. Also, would hope that this query can be in place even if more VALUE1 values are added in the table (dynamic)

Any ideas?

Body:
You can use window function row_number while selecting:

select row_number() over (
        order by value1
        ) as id,
    value1
from your_table;


问:
Opening new activities with different combination of check boxes checked?
I want to make an app which has checkboxes, so what i basically want to do is that if certain checkboxes are check i want to open a certain activity. For ex; there is a question whats your gender the checkboxes available are male and female the other question is what do eat the check boxes available are pizza and burger so if male and pizza are chosen i want to open a certain activity, i want to open different activities with different combinations.how should i do this?   </p>

答:
```<code>if(checkBoxPizza.isChecked()){
   if(checkBoxMale.isChecked()){//launch activity1}
   if(checkBoxFemale.isChecked()){//launch activity2}
}

if(checkBoxBurger.isChecked()){
   if(checkBoxMale.isChecked()){//launch activity3}
   if(checkBoxFemale.isChecked()){//launch activity4}
}
</code>```

Use a system of this sort to determine which result you need.

Body:
if(checkBoxPizza.isChecked()){
   if(checkBoxMale.isChecked()){//launch activity1}
   if(checkBoxFemale.isChecked()){//launch activity2}
}

if(checkBoxBurger.isChecked()){
   if(checkBoxMale.isChecked()){//launch activity3}
   if(checkBoxFemale.isChecked()){//launch activity4}
}

Use a system of this sort to determine which result you need.


问:
plaid connect to client with node error
I'm using node backend and am trying to connect to plaid.
My code:

```<code>var plaid = require('plaid');

var clientID = "bla";
var secretID = "bla";
var publicKey = "bla";

var client = new plaid.Client(
    clientID,
    secretID,
    publicKey,
    plaid.environments.sandbox

);
</code>```

However I am getting this error in my console:

```<code>    throw new Error('Invalid Plaid environment');
    ^

Error: Invalid Plaid environment
    at new Plaid.Client (C:\Users\me\Documents\found\SPA\node_modules\plaid\index.js:26:11)
    at module.exports (C:\Users\me\Documents\found\SPA\app\routes.js:48:22)
    at Object.<anonymous> (C:\Users\me\Documents\found\SPA\server.js:48:24)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
</code>```

I have tried using each of these with no luck:

```<code>plaid.environments.sandbox
plaid.environments.development
plaid.environments.tartan
</code>```

What's going on?

Ref: https://plaid.com/docs/quickstart/#accessing-item-data

UPDATE:
I've gotten this code below to work in another part of my app:

```<code>var plaidClient = new plaid.Client(clientID, secretID, plaid.environments.tartan);
</code>```

However I am trying to use client.getTransactions() and it is required to have var plaidClient = new plaid.Client(clientID, secretID, publicID, plaid.environments.sandbox);
in order for client.getTransactions() to work.

UPDATE?

答: For some reason I had the wrong version of plaid installed. I needed to uninstall and reinstall to fix. Works now. </p>

Title: plaid connect to client with node error

Body:
I'm using node backend and am trying to connect to plaid.
My code:

var plaid = require('plaid');

var clientID = "bla";
var secretID = "bla";
var publicKey = "bla";

var client = new plaid.Client(
    clientID,
    secretID,
    publicKey,
    plaid.environments.sandbox

);

However I am getting this error in my console:

    throw new Error('Invalid Plaid environment');
    ^

Error: Invalid Plaid environment
    at new Plaid.Client (C:\Users\me\Documents\found\SPA\node_modules\plaid\index.js:26:11)
    at module.exports (C:\Users\me\Documents\found\SPA\app\routes.js:48:22)
    at Object.<anonymous> (C:\Users\me\Documents\found\SPA\server.js:48:24)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)

I have tried using each of these with no luck:

plaid.environments.sandbox
plaid.environments.development
plaid.environments.tartan

What's going on?

Ref: https://plaid.com/docs/quickstart/#accessing-item-data

UPDATE:
I've gotten this code below to work in another part of my app:

var plaidClient = new plaid.Client(clientID, secretID, plaid.environments.tartan);

However I am trying to use client.getTransactions() and it is required to have var plaidClient = new plaid.Client(clientID, secretID, publicID, plaid.environments.sandbox);
in order for client.getTransactions() to work.

UPDATE?


问:
YII2 : and Nginx server
i have create a project in yii2 advanced and its work fine in localhost in xampp
and i have webhost in Nginx server ..  I delete all the files in public_html folder in my website and  after that i upload my project in that website  when i try it it gives me

The MYDOAMIN.com page isn’t working

MYDOAMIN.com is currently unable to handle this request.

HTTP ERROR 500

So is there any configuration or did i forget something to do ?

答:
You have to conf the nginx as well... </p>

<p>From github </p>

```<code>server {
    listen       80; # listen for IPv4
    #listen       [::]:80 ipv6only=on; # listen for IPv6
    server_name  advanced.local;
    root         /path/to/advanced;

    #access_log   off;
    #error_log    /dev/null crit;
    charset      utf-8;
    client_max_body_size  100M;

    location / {
        root  /path/to/advanced/frontend/web;
        try_files  $uri /frontend/web/index.php?$args;
    }

    location ~* \.php$ {
        try_files  $uri /frontend/web$uri =404;
        # check the www.conf file to see if PHP-FPM is listening on a socket or a port
         fastcgi_pass  unix:/run/php-fpm/php-fpm.sock; # listen for socket
         #fastcgi_pass  127.0.0.1:9000; # listen for port
         include  /etc/nginx/fastcgi_params;
         fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
     }

     location ~* \.(htaccess|htpasswd|svn|git) {
        deny all;
     }

     location /admin {
         alias  /path/to/advanced/backend/web;
         try_files  $uri /backend/web/index.php?$args;
    }
}
</code>```

Title: YII2 : and Nginx server

Body:
You have to conf the nginx as well...

From github

server {
    listen       80; # listen for IPv4
    #listen       [::]:80 ipv6only=on; # listen for IPv6
    server_name  advanced.local;
    root         /path/to/advanced;

    #access_log   off;
    #error_log    /dev/null crit;
    charset      utf-8;
    client_max_body_size  100M;

    location / {
        root  /path/to/advanced/frontend/web;
        try_files  $uri /frontend/web/index.php?$args;
    }

    location ~* \.php$ {
        try_files  $uri /frontend/web$uri =404;
        # check the www.conf file to see if PHP-FPM is listening on a socket or a port
         fastcgi_pass  unix:/run/php-fpm/php-fpm.sock; # listen for socket
         #fastcgi_pass  127.0.0.1:9000; # listen for port
         include  /etc/nginx/fastcgi_params;
         fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
     }

     location ~* \.(htaccess|htpasswd|svn|git) {
        deny all;
     }

     location /admin {
         alias  /path/to/advanced/backend/web;
         try_files  $uri /backend/web/index.php?$args;
    }
}


问:
Want Eclipse to use a specific config.ini, but set a different configuration area
So my problem in short is this:

I want to run my eclipse based program with a specific config.ini file which is not in the default dir, i.e it is not in ../eclipse/configuration/config.ini but at the same time I want the configuration area to be in a different location, the users home directory.

The reasons have to do with using several different config.ini files and the configuration area where the files are saved is readonly.

When starting up the tool with

```<code>${JAVA_HOME}/bin/java
-Dosgi.baseConfiguration.area=$INSTALLATION/$CONFIGURATION/eclipse/configuration\
-jar $INSTALLATION/eclipse/plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar \
</code>```

and this in my config.ini (amongst other things):

```<code> osgi.configuration.area=@user.home/tmp/eclipse_data/
</code>```

I get almost everything I want: The right config.ini file is used, the tool starts to cache data to the right place and only there. But with the little downside that the tool doesnt start up... I get the error message:

!ENTRY org.eclipse.osgi 4 0 2010-11-29 19:17:06.914
!MESSAGE Application error
!STACK 1
java.lang.IllegalStateException: Unable to acquire application service. Ensure that the org.eclipse.core.runtime bundle is resolved and started (see config.ini).
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:74)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)

If I change to

```<code>${JAVA_HOME}/bin/java -Dawt.toolkit=sun.awt.X11.XToolkit \
-Dosgi.configuration.area=$INSTALLATION/$CONFIGURATION/eclipse/configuration \
-jar $INSTALLATION/eclipse/plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar \
</code>```

the tool works, but starts to save data into my writeprotected area.

It is not an issue with the bundle definition in my config.ini file, since they work in the second scenario.

There are several workarounds for this, but first I'm gonna try to see if there is a way to make this work like we want to first.

Update: Following Kanes suggestion below, I found that only one bundle was being loaded, org.eclipse.osgi_3.6.0.v20100517. When I examined the eclipse code in grepcode that throws the exception I found this line:

```<code>if (failOnNoDefault && runnable == null)
throw new IllegalStateException(EclipseAdaptorMsg.ECLIPSE_STARTUP_ERROR_NO_APPLICATION);
</code>```

So my runnable is null. Not sure why, but I think it's a sign that I got to use some workaround.

答:
In first way, you have to add 'osgi.bundles' as your vm argument. The error message is caused by the bundles aren't installed into the OSGi framework that is responsibility of bundle 'org.eclipse.equinox.simpleconfigurator' since eclipse 3.4. </p>

```<code>-Dosgi.bundles=file/<eclipsedir>/plugins/org.eclipse.equinox.simpleconfigurator_1.0.200.v20100503.jar@1\:start
</code>```

ContentLicense: CC BY-SA 2.5

Body:
So my problem in short is this:

I want to run my eclipse based program with a specific config.ini file which is not in the default dir, i.e it is not in ../eclipse/configuration/config.ini but at the same time I want the configuration area to be in a different location, the users home directory.

The reasons have to do with using several different config.ini files and the configuration area where the files are saved is readonly.

When starting up the tool with

${JAVA_HOME}/bin/java
-Dosgi.baseConfiguration.area=$INSTALLATION/$CONFIGURATION/eclipse/configuration\
-jar $INSTALLATION/eclipse/plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar \

and this in my config.ini (amongst other things):

 osgi.configuration.area=@user.home/tmp/eclipse_data/

I get almost everything I want: The right config.ini file is used, the tool starts to cache data to the right place and only there. But with the little downside that the tool doesnt start up... I get the error message:

!ENTRY org.eclipse.osgi 4 0 2010-11-29 19:17:06.914
!MESSAGE Application error
!STACK 1
java.lang.IllegalStateException: Unable to acquire application service. Ensure that the org.eclipse.core.runtime bundle is resolved and started (see config.ini).
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:74)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)

If I change to

${JAVA_HOME}/bin/java -Dawt.toolkit=sun.awt.X11.XToolkit \
-Dosgi.configuration.area=$INSTALLATION/$CONFIGURATION/eclipse/configuration \
-jar $INSTALLATION/eclipse/plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar \

the tool works, but starts to save data into my writeprotected area.

It is not an issue with the bundle definition in my config.ini file, since they work in the second scenario.

There are several workarounds for this, but first I'm gonna try to see if there is a way to make this work like we want to first.

Update: Following Kanes suggestion below, I found that only one bundle was being loaded, org.eclipse.osgi_3.6.0.v20100517. When I examined the eclipse code in grepcode that throws the exception I found this line:

if (failOnNoDefault && runnable == null)
throw new IllegalStateException(EclipseAdaptorMsg.ECLIPSE_STARTUP_ERROR_NO_APPLICATION);

So my runnable is null. Not sure why, but I think it's a sign that I got to use some workaround.

Body:
In first way, you have to add 'osgi.bundles' as your vm argument. The error message is caused by the bundles aren't installed into the OSGi framework that is responsibility of bundle 'org.eclipse.equinox.simpleconfigurator' since eclipse 3.4.

-Dosgi.bundles=file/<eclipsedir>/plugins/org.eclipse.equinox.simpleconfigurator_1.0.200.v20100503.jar@1\:start


问:
How get the value of multiple checkbox
I retrieve some data from a database, put it into a table view

```<code>if (isset($_POST['user_id'])) {
            foreach ($_POST['user_id'] as $value) {
                $user = User::find($value);
                $id = Some::create([
                            'user_id'                   => $user->id,
                            'user_email'                => $user->email,
                            'user_name'                 => $user->name,
                            'location'                  => $user->location,
                            'user_phone'                => $user->phone,
                            'created_at'                => \Carbon\Carbon::now()->subDays(3),
                            ]);
                          $id->update(['created_at' => \Carbon\Carbon::now()->subDays(3)]);
                          $id->created_at =  \Carbon\Carbon::now()->subDays(3);
                          $id->save();
                    if ($id)
                    {
                        // delete user from PH table
                        $deleteUser = ProvideHelp::where('user_id', $id->user_id)->delete();
                        if ($deleteUser) {
                            return redirect('home')->with('success', 'Your Addition was successful');
                        }

                    }
            }
        }

        return redirect('home')->with('error', 'Inter Error Please try again Later');
</code>```

The loop only works for the first data and rest doesn't work. I want to use the values for each loop to query the database. Only the first query works - the second or third do not work.

答:
It's possible that you need to place a "[]" after the name values of your checkboxes so they look like this in your HTML:

name='user_id[]'

otherwise, when you pass the checkbox values to your PHP it will only pass the first value.

Title: How get the value of multiple checkbox

Body:
I retrieve some data from a database, put it into a table view

if (isset($_POST['user_id'])) {
            foreach ($_POST['user_id'] as $value) {
                $user = User::find($value);
                $id = Some::create([
                            'user_id'                   => $user->id,
                            'user_email'                => $user->email,
                            'user_name'                 => $user->name,
                            'location'                  => $user->location,
                            'user_phone'                => $user->phone,
                            'created_at'                => \Carbon\Carbon::now()->subDays(3),
                            ]);
                          $id->update(['created_at' => \Carbon\Carbon::now()->subDays(3)]);
                          $id->created_at =  \Carbon\Carbon::now()->subDays(3);
                          $id->save();
                    if ($id)
                    {
                        // delete user from PH table
                        $deleteUser = ProvideHelp::where('user_id', $id->user_id)->delete();
                        if ($deleteUser) {
                            return redirect('home')->with('success', 'Your Addition was successful');
                        }

                    }
            }
        }

        return redirect('home')->with('error', 'Inter Error Please try again Later');

The loop only works for the first data and rest doesn't work. I want to use the values for each loop to query the database. Only the first query works - the second or third do not work.


问:
-bash: sequelize: command not found
I just ran npm install --save sequelize pg pg-hstore in my project root directory and now I am unable to invoke sequelize init. I get the error: -bash: sequelize: command not found. What am I doing wrong?</p>

答:
I would like to answer my own question. The global npm install path was wrong for my computer.

npm config get prefix

Then I ran to put the path where it should be. This problem gave me a lot of head aches. Hope it helps someone.

npm config set prefix /usr/local

Title: -bash: sequelize: command not found


问:
Animation then transform, two successive animations
I'm trying to make a div bounce (1st animation), then come up (2nd animation). So, there are two animations. The first one is ok, but the div doesn't go to the last position.

$(window).scroll(function(){

if($(document).scrollTop() > $(document).height() - $(window).height() - $('.link').height()){
    $('.link').addClass('boom');
}
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.link {
  height: 250px;
  max-width: 900px;
  margin: auto;
  padding: 20px;
  background: lightblue;
  border-radius: 7px;
  box-shadow: 0px 2px 10px rgba(0, 30, 50, 0.4);

  transform: translateY(300px);

  animation: bounce 0.5s cubic-bezier(0.63, 0.09, 0.75, 0.46) 0s alternate 9;

  transition: transform 300ms cubic-bezier(0, 0.47, 0.32, 1);
  transition-delay: 10s;
}

@keyframes bounce {
  0% {
    transform: translateY(230px);
  }
  100% {
    transform: translateY(170px);
  }
}

.link.boom {
  transform: translateY(100px);
}</code>```

```

How could it be done?

Thanks!

答:
Well, I've got the answer, and there's no need for JS:

.link {
  height: 250px;
  max-width: 900px;
  margin: auto;
  padding: 20px;
  align-items: center;
  transform: translateY(90px);
  border-radius: 7px;
  box-shadow: 0px 2px 10px rgba(0, 30, 50, 0.4);
  animation: breathing 3s ease-in-out alternate infinite, bounce 500ms cubic-bezier(0.63, 0.09, 0.75, 0.46) 0s alternate 9, boom 600ms ease-out 4.5s;
}

@keyframes breathing {
  0% {
    background-color: lightblue;
  }
  100% {
    background-color: black;
  }
}

@keyframes bounce {
  0% {
    transform: translateY(230px);
  }
  100% {
    transform: translateY(170px);
  }
}

@keyframes boom {
  0% {
    transform: translateY(170px);
  }
  100% {
    transform: translateY(90px);
  }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code>There's a little glitch that is not on my website… Weird…
<div class="link"></div></code>```

Body:
I'm trying to make a div bounce (1st animation), then come up (2nd animation). So, there are two animations. The first one is ok, but the div doesn't go to the last position.

$(window).scroll(function(){

if($(document).scrollTop() > $(document).height() - $(window).height() - $('.link').height()){
    $('.link').addClass('boom');
}
});

.link {
  height: 250px;
  max-width: 900px;
  margin: auto;
  padding: 20px;
  background: lightblue;
  border-radius: 7px;
  box-shadow: 0px 2px 10px rgba(0, 30, 50, 0.4);

  transform: translateY(300px);

  animation: bounce 0.5s cubic-bezier(0.63, 0.09, 0.75, 0.46) 0s alternate 9;

  transition: transform 300ms cubic-bezier(0, 0.47, 0.32, 1);
  transition-delay: 10s;
}

@keyframes bounce {
  0% {
    transform: translateY(230px);
  }
  100% {
    transform: translateY(170px);
  }
}

.link.boom {
  transform: translateY(100px);
}

How could it be done?

Thanks!

Body:
Well, I've got the answer, and there's no need for JS:

.link {
  height: 250px;
  max-width: 900px;
  margin: auto;
  padding: 20px;
  align-items: center;
  transform: translateY(90px);
  border-radius: 7px;
  box-shadow: 0px 2px 10px rgba(0, 30, 50, 0.4);
  animation: breathing 3s ease-in-out alternate infinite, bounce 500ms cubic-bezier(0.63, 0.09, 0.75, 0.46) 0s alternate 9, boom 600ms ease-out 4.5s;
}

@keyframes breathing {
  0% {
    background-color: lightblue;
  }
  100% {
    background-color: black;
  }
}

@keyframes bounce {
  0% {
    transform: translateY(230px);
  }
  100% {
    transform: translateY(170px);
  }
}

@keyframes boom {
  0% {
    transform: translateY(170px);
  }
  100% {
    transform: translateY(90px);
  }
}

There's a little glitch that is not on my website… Weird…
<div class="link"></div>


问:
Podio::authenticate_with_app($app_id, $app_token); is not working
My client has a site on 'ideacontainer.net/real_coffee/'. Now I guess he has accidentally deleted the app then recovered it. But from that time he is not able to access his site.

This is the code in his index file

```<code>require_once 'podio-php-master/PodioAPI.php';
$client_id = "some-client-id";
$client_secret = "3zLcr...";
$app_id = "17373109";
$app_token = "48148cfca3c...";
Podio::setup($client_id, $client_secret);
Podio::authenticate_with_app($app_id, $app_token);
</code>```

When I am commenting it line by line it is working till "Podio::authenticate_with_app($app_id, $app_token);" line. So I think the problem is in this line.

Please let me know the solution.

Thanks

Shashank Kumar

答: You need to create new client (the one mentioned in your code as client_id), also you will have to re-generate app token and re-check app_id. If it still doesn't work, please provide full error message returned from Podio API.

Body:
My client has a site on 'ideacontainer.net/real_coffee/'. Now I guess he has accidentally deleted the app then recovered it. But from that time he is not able to access his site.

This is the code in his index file

require_once 'podio-php-master/PodioAPI.php';
$client_id = "some-client-id";
$client_secret = "3zLcr...";
$app_id = "17373109";
$app_token = "48148cfca3c...";
Podio::setup($client_id, $client_secret);
Podio::authenticate_with_app($app_id, $app_token);

When I am commenting it line by line it is working till "Podio::authenticate_with_app($app_id, $app_token);" line. So I think the problem is in this line.

Please let me know the solution.

Thanks

Shashank Kumar


问:
Hibernate Criteria join two tables
I've 3 table:
PERSON: ID, NAME, SURNAME
TEAM: ID, NAME, PERSON, ROLE
ROLE: ID, POSITION
where TEAM could have a list of PERSON

I need to create a query, with Hibernate Criteria, like this:
select * from PERSON p, TEAM t
    where t.ROLE = "myRole" and t.PERSON = p.id

I want to get the list of PERSON in TEAM with a given ROLE.
Can you help me? Thanks

答:
Team has a list of person. Therefore instead of having Person column in Team table, you should have team_id column in Person table. And I assume Role is associated with Person.Thus your tables should be like the following:

Person: ID, NAME, SURNAME, TEAM_ID, ROLE_ID
Team: ID, NAME
Role:ID, POSITION

Then the query for getting list of Person in a given Team with a given role is:

Select * from Person p, Team t, Role r where p.team_id=t.id and p.role_id=r.id and r.position = givenPosition and t.name=givenTeam

In Criteria

```<code>`Criteria c = session.createCriteria(Person.class, "p");
c.createAlias("p.team", "t");
c.createAlias("p.role", "r");
c.add(Restrictions.eq("t.name", givenTeam));
c.add(Restrictions.eq("r.position", givenPosition ));`
</code>```

Title: Hibernate Criteria join two tables

Body:
Team has a list of person. Therefore instead of having Person column in Team table, you should have team_id column in Person table. And I assume Role is associated with Person.Thus your tables should be like the following:

Person: ID, NAME, SURNAME, TEAM_ID, ROLE_ID
Team: ID, NAME
Role:ID, POSITION

Then the query for getting list of Person in a given Team with a given role is:

Select * from Person p, Team t, Role r where p.team_id=t.id and p.role_id=r.id and r.position = givenPosition and t.name=givenTeam

In Criteria

`Criteria c = session.createCriteria(Person.class, "p");
c.createAlias("p.team", "t");
c.createAlias("p.role", "r");
c.add(Restrictions.eq("t.name", givenTeam));
c.add(Restrictions.eq("r.position", givenPosition ));`


问:
Saving a loop's output in a vector in R
I have a .cvs file which consists of 4 columns and 120 rows.
I'm attempting to go through every row and where ever i see a "1" in the third column (which here is called "Dam") , i want to save that row in a matrix called "Dam.one"

Here's my code so far:

```<code>DamType = c( "Dam.one", "Dam.two", "Dam.three", "NoDam.one", "NoDam.two", "NoDam.three")

for (i in 1:120) {
    if (mercury.raw[i,]["Dam"] == 1) {
        if (mercury.raw[i,]["Type"] == 1){
            DamType["Dam.one"] <-  mercury.raw[i,]
}}}
</code>```

This is the first 6 entries of the data set:`

```<code>> mercury.raw
                    Lake Mercury Dam Type
1                ALLEN.P   1.080   1    1
2            ALLIGATOR.P   0.025   1    1
3        A.SAGUNTICOOK.L   0.570   0    2
4      BALCH&STUMP.PONDS   0.770   0    2
5           BASKAHEGAN.L   0.790   1    2
6          BAUNEAG.BEG.L   0.750   0    2
</code>```

I want DamType["Dam.one"]to be equal to:

```<code>                 Lake Mercury Dam Type
1                ALLEN.P   1.080   1    1
2            ALLIGATOR.P   0.025   1    1
</code>```

I don't know what is wrong with it.
Any help is appreciated.

答:
A matrix cannot be stored in a vector.  A list can store multiple matrices (or data frames in this case).  This looks like you are trying to subset your data and a for loop is not required.

```<code>DamType <- list()
DamType[["Dam.one"]] <- mercury.raw[mercury.raw$Dam == 1 & mercury.raw$Type == 1, ]

> DamType$Dam.one
         Lake Mercury Dam Type
1     ALLEN.P   1.080   1    1
2 ALLIGATOR.P   0.025   1    1
</code>```

Title: Saving a loop's output in a vector in R

Body:
I have a .cvs file which consists of 4 columns and 120 rows.
I'm attempting to go through every row and where ever i see a "1" in the third column (which here is called "Dam") , i want to save that row in a matrix called "Dam.one"

Here's my code so far:

DamType = c( "Dam.one", "Dam.two", "Dam.three", "NoDam.one", "NoDam.two", "NoDam.three")

for (i in 1:120) {
    if (mercury.raw[i,]["Dam"] == 1) {
        if (mercury.raw[i,]["Type"] == 1){
            DamType["Dam.one"] <-  mercury.raw[i,]
}}}

This is the first 6 entries of the data set:`

> mercury.raw
                    Lake Mercury Dam Type
1                ALLEN.P   1.080   1    1
2            ALLIGATOR.P   0.025   1    1
3        A.SAGUNTICOOK.L   0.570   0    2
4      BALCH&STUMP.PONDS   0.770   0    2
5           BASKAHEGAN.L   0.790   1    2
6          BAUNEAG.BEG.L   0.750   0    2

I want DamType["Dam.one"]to be equal to:

                 Lake Mercury Dam Type
1                ALLEN.P   1.080   1    1
2            ALLIGATOR.P   0.025   1    1

I don't know what is wrong with it.
Any help is appreciated.

Body:
A matrix cannot be stored in a vector.  A list can store multiple matrices (or data frames in this case).  This looks like you are trying to subset your data and a for loop is not required.

DamType <- list()
DamType[["Dam.one"]] <- mercury.raw[mercury.raw$Dam == 1 & mercury.raw$Type == 1, ]

> DamType$Dam.one
         Lake Mercury Dam Type
1     ALLEN.P   1.080   1    1
2 ALLIGATOR.P   0.025   1    1


问:
i try to read integer values form txt file using eclipes but its give me some error java.lang.NumberFormatException
my code is based on gui, i try run on gui but i didnt make it.
public class SecondFrame extends JFrame {

```<code>private JPanel contentPane;

/**
 * Launch the application.
 */
public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                SecondFrame frame = new SecondFrame();
                frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

/**
 * Create the frame.
 */
public SecondFrame() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 612, 469);
    contentPane = new JPanel();
    contentPane.setBackground(Color.BLUE);
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);

    JLabel lblNewLabel = new JLabel("Success !");
    lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 38));
    lblNewLabel.setBounds(201, 120, 233, 74);
    contentPane.add(lblNewLabel);

    JButton btnGenerateGraph = new JButton("GENERATE GRAPH");
    btnGenerateGraph.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                FileReader reader = new FileReader("rn.txt");
                BufferedReader bufferedReader = new BufferedReader(reader);

                String line;
                **here i try to convert line that i has read to integer**
                while ((line = bufferedReader.readLine()) != null) {
                    System.out.println(Integer.parseInt(line));
                }
                reader.close();

            } catch (IOException e) {
                e.printStackTrace();
            }

        }
    });
    btnGenerateGraph.setFont(new Font("Tahoma", Font.BOLD, 21));
    btnGenerateGraph.setBounds(168, 221, 245, 59);
    contentPane.add(btnGenerateGraph);
}
</code>```

}

this is the error:
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "/"

my rn.txt file:

29
44
15
17

答:
It looks like there are new line character in your file, due to which it is giving error while converting it into Integer as it cannot convert special characters into string.

One method to actually find out what is happening is to first just print the line content and check if it contains a blank or special character in the end of line.
So you will be able to identify at what point it is giving error.

```<code>String line;
**here i try to convert line that i has read to integer**
while ((line = bufferedReader.readLine()) != null) {
    System.out.println(line); //Print Content as it is to check at which character you are getting error.
    System.out.println(Integer.parseInt(line));
}
</code>```

Similarly you can find this by using debugger in the IDE.

If you actually contains special character or new line character in the line then you can use below code to remove those characters.

```<code>String line;
**here i try to convert line that i has read to integer**
while ((line = bufferedReader.readLine()) != null) {
    line = replaceAll("(\n)+", "");
    line = replaceAll("(\r)+", "");
    if(line != "" && line!= null){
        System.out.println(line); //Print Content as it is to check at which character you are getting error.
        System.out.println(Integer.parseInt(line));
    }
}
</code>```

Body:
my code is based on gui, i try run on gui but i didnt make it.
public class SecondFrame extends JFrame {

private JPanel contentPane;

/**
 * Launch the application.
 */
public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                SecondFrame frame = new SecondFrame();
                frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

/**
 * Create the frame.
 */
public SecondFrame() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 612, 469);
    contentPane = new JPanel();
    contentPane.setBackground(Color.BLUE);
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);

    JLabel lblNewLabel = new JLabel("Success !");
    lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 38));
    lblNewLabel.setBounds(201, 120, 233, 74);
    contentPane.add(lblNewLabel);

    JButton btnGenerateGraph = new JButton("GENERATE GRAPH");
    btnGenerateGraph.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                FileReader reader = new FileReader("rn.txt");
                BufferedReader bufferedReader = new BufferedReader(reader);

                String line;
                **here i try to convert line that i has read to integer**
                while ((line = bufferedReader.readLine()) != null) {
                    System.out.println(Integer.parseInt(line));
                }
                reader.close();

            } catch (IOException e) {
                e.printStackTrace();
            }

        }
    });
    btnGenerateGraph.setFont(new Font("Tahoma", Font.BOLD, 21));
    btnGenerateGraph.setBounds(168, 221, 245, 59);
    contentPane.add(btnGenerateGraph);
}

}

this is the error:
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "/"

my rn.txt file:

29
44
15
17

Body:
It looks like there are new line character in your file, due to which it is giving error while converting it into Integer as it cannot convert special characters into string.

One method to actually find out what is happening is to first just print the line content and check if it contains a blank or special character in the end of line.
So you will be able to identify at what point it is giving error.

String line;
**here i try to convert line that i has read to integer**
while ((line = bufferedReader.readLine()) != null) {
    System.out.println(line); //Print Content as it is to check at which character you are getting error.
    System.out.println(Integer.parseInt(line));
}

Similarly you can find this by using debugger in the IDE.

If you actually contains special character or new line character in the line then you can use below code to remove those characters.

String line;
**here i try to convert line that i has read to integer**
while ((line = bufferedReader.readLine()) != null) {
    line = replaceAll("(\n)+", "");
    line = replaceAll("(\r)+", "");
    if(line != "" && line!= null){
        System.out.println(line); //Print Content as it is to check at which character you are getting error.
        System.out.println(Integer.parseInt(line));
    }
}


问:
TensorFlow: How do I restore one model's trainable variables into another?
I trained an autoencoder and saved the session using the Saver. Now I want to train a separate model, that will use a bunch of the trained variables that I have to encode the input and pass it along a MLP. The thing is that I'm having trouble loading the autoencoder model into my new model, even with the Saver's export/import functions.

Is this even possible?
I keep getting
'Could not open encoder.ckpt: Data loss: not an sstable (bad magic number) perhaps your file is in a different format and you need to use a different restore operator?

Any help would be appreciated!

答:
This should probably be a comment, but as @Alexandre Passos mentioned, saver.restore(encoder.ckpt) should work if you have defined all of the variables/operations before. If you have not, you will need to load the stored graph as

```<code>saver = tf.train.import_meta_graph(encoder.ckpt.meta)
saver.restore(encoder.ckpt)
</code>```

Then if you only want to grab some of the variables from that model, you can do so by

```<code>graph = tf.get_default()
restored_var = graph.get_tensor_by_name(restored_var_name)
</code>```

You also may want to check your checkpoint file to make sure you have the write path to you encoder.ckpt file.

Body:
This should probably be a comment, but as @Alexandre Passos mentioned, saver.restore(encoder.ckpt) should work if you have defined all of the variables/operations before. If you have not, you will need to load the stored graph as

saver = tf.train.import_meta_graph(encoder.ckpt.meta)
saver.restore(encoder.ckpt)

Then if you only want to grab some of the variables from that model, you can do so by

graph = tf.get_default()
restored_var = graph.get_tensor_by_name(restored_var_name)

You also may want to check your checkpoint file to make sure you have the write path to you encoder.ckpt file.


问:
Convert RAML Data Types XSD
Raml website states that I can convert RAML 1.0 data types to XML Schema:

Data Types can be used in place of schemas and examples, letting you define one Data Type that can then be converted into an XML or JSON Schema on the fly - letting you simply define your data model, and letting RAML take care of the REST.

How can I do that? And what is the level of support for complex types with inheritance and string patterns?

答:
The statement implies that you can use a XML data type to define a complex structure. This definition is logical and does not specify the physical format like a XML or JSON.

This is a definition of a Album Type:

```<code>#%RAML 1.0 DataType
type: AlbumSimple
displayName: Full Album Object
properties:
  artists: ArtistSimple[]  # would pull in ArtistSimple DataType
  copyrights: Copyright[]  # would pull in Copyright DataType
  external_ids: ExternalId  # would pull in ExternalId DataType
  genres:
    type: string[]
    description: |
      A list of the genres used to classify the album. If not yet classified,
      the array is empty.
    example: ["Prog Rock", "Post-Grunge"]
  popularity:
    type: integer
    description: |
      The popularity of the album. The value will be between 0 and 100,
      with 100 being the most popular. The popularity is calculated from
      the popularity of the album's individual tracks.
  tracks:
    type: Page  # would pull in Page DataType
    (pagedObject): TrackSimple
    description: The tracks of the album.
</code>```

That definition does not imply the physical format. You have to define in the body content-type:

```<code>get:
      is: [ drm ]
      responses:
        201:
          body:
            application/json:
              type: AlbumSimple
</code>```

Title: Convert RAML Data Types XSD

Body:
The statement implies that you can use a XML data type to define a complex structure. This definition is logical and does not specify the physical format like a XML or JSON.

This is a definition of a Album Type:

#%RAML 1.0 DataType
type: AlbumSimple
displayName: Full Album Object
properties:
  artists: ArtistSimple[]  # would pull in ArtistSimple DataType
  copyrights: Copyright[]  # would pull in Copyright DataType
  external_ids: ExternalId  # would pull in ExternalId DataType
  genres:
    type: string[]
    description: |
      A list of the genres used to classify the album. If not yet classified,
      the array is empty.
    example: ["Prog Rock", "Post-Grunge"]
  popularity:
    type: integer
    description: |
      The popularity of the album. The value will be between 0 and 100,
      with 100 being the most popular. The popularity is calculated from
      the popularity of the album's individual tracks.
  tracks:
    type: Page  # would pull in Page DataType
    (pagedObject): TrackSimple
    description: The tracks of the album.

That definition does not imply the physical format. You have to define in the body content-type:

get:
      is: [ drm ]
      responses:
        201:
          body:
            application/json:
              type: AlbumSimple


问:
Call to undefined function oci_connect() in Heroku app
I have a problem in my code. I need to push code to Heroku (running on Ubuntu 14.04); my code is PHP and Oracle database. oci_connect() works perfectly in localhost and connect successfully to the Oracle database but when I push to Heroku it's returning "Call to undefined function oci_connect()". I tried to install bitbucket-heroku like Ruby and Java, but nothing has worked for me yet.

Image: Heroku error app

This is my link in Heroku: https://serene-anchorage-79470.herokuapp.com/home.php?language=en

My config code:

```<code>$conn = oci_connect('username', 'pass','(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST =myhost )(PORT =port )) (CONNECT_DATA =  (SID =sid )))');
if($conn)
{
    echo "Successfully connected to Oracle.\n";

}
else
{
    $err = OCIError();
    echo "Connection failed." . $err[text];
}
</code>```

答:
The reason you are getting this error is because you are missing the OCI8 PHP extension which is needed in order to connect to Oracle database using PHP.

If your Oracle database is not hosted on the same server, you will also need to install Oracle Instant Client on the linux server.

Body:
I have a problem in my code. I need to push code to Heroku (running on Ubuntu 14.04); my code is PHP and Oracle database. oci_connect() works perfectly in localhost and connect successfully to the Oracle database but when I push to Heroku it's returning "Call to undefined function oci_connect()". I tried to install bitbucket-heroku like Ruby and Java, but nothing has worked for me yet.

Image: Heroku error app

This is my link in Heroku: https://serene-anchorage-79470.herokuapp.com/home.php?language=en

My config code:

$conn = oci_connect('username', 'pass','(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST =myhost )(PORT =port )) (CONNECT_DATA =  (SID =sid )))');
if($conn)
{
    echo "Successfully connected to Oracle.\n";

}
else
{
    $err = OCIError();
    echo "Connection failed." . $err[text];
}


问:
PHP / MySQL - Need help with simple query
I need to write a query but am a newbie to writing querys that involve 2 tables.

the first table 'clients' has the following columns "id, archive_reason, name, phone" .. the second table, 'archive' has the following columns "id, archive_reason".

What i need to do is get the archive reason based on the archive_reason in the clients table if that makes sense ... and then return * from the clients table, including the archive reason from the arhive table.

Cheers,

答: This page should get you started: http://www.w3schools.com/Sql/sql_join_inner.asp.</p>


问:
Return type required/ Cannot return a value from a method with a void result type
Im a beginner, can you tell me what am i doing wrong? Why can't i use those methods properly?

IDE shows: Return type required/ Cannot return a value from a method with a void result type

`        public class Human

```<code>{
    public int Age = 0;
    public int Weight = 0;
    public int Height = 0;
    private String name = "";
    boolean isMale;
}

public getAge()
{
    return Age;
}
public getWeight()
{
    return Weight;
}
public getHeight()
{
    return Height;
}
public Human(int Age, int Weight, int Height, String name, boolean
isMale)
{

}      `
</code>```

答:
You need to have a return type for each function from where you want to return a value.
ex:</p>

```<code>public int getAge()
{
    return Age;
}
public int getWeight()
{
    return Weight;
}
public int getHeight()
{
    return Height;
}
</code>```

Body:
Im a beginner, can you tell me what am i doing wrong? Why can't i use those methods properly?

IDE shows: Return type required/ Cannot return a value from a method with a void result type

`        public class Human

{
    public int Age = 0;
    public int Weight = 0;
    public int Height = 0;
    private String name = "";
    boolean isMale;
}

public getAge()
{
    return Age;
}
public getWeight()
{
    return Weight;
}
public getHeight()
{
    return Height;
}
public Human(int Age, int Weight, int Height, String name, boolean
isMale)
{

}      `

Body:
You need to have a return type for each function from where you want to return a value.
ex:

public int getAge()
{
    return Age;
}
public int getWeight()
{
    return Weight;
}
public int getHeight()
{
    return Height;
}


问:
Why doesn't my paintbox image appear when the form activates
I'm attempting to write an analog VU meter. I use a bitmap of a VU meter and draw the needle on to the bitmap. I am using a trackbar and it's onChange event to test the meter:

```<code>procedure TForm1.TrackBar1Change(Sender: TObject);
var
  angle : integer;
  x,y : integer;
  Peaked : boolean;
begin
   Angle := 120 - Round(sTrackBar1.Position / sTrackBar1.Max * 100 )+20;
   Peaked := Angle < PeakVol;
   if Peaked then
    Buffer.Picture := VUImagePeaked.Picture
   else
    buffer.picture := VUImage.Picture;
   buffer.Picture.Bitmap.Canvas.Pen.Color := clSilver;
   buffer.Picture.Bitmap.Canvas.Pen.Width:=2;
   buffer.Canvas.MoveTo(pivot.x,Pivot.y);
   x := 150 + Round(Cos(DegToRad(Angle)) * NeedleLen);
   y := PaintBox1.Height - Round(Sin(DegToRad(Angle)) *NeedleLen);
   buffer.Canvas.LineTo(x,y);
   PaintBox1.Canvas.Draw(0,0,buffer.Picture.Bitmap)
end;
</code>```

Seems to work but what I can't get is to display the bitmap of the meter when the program starts. I have even resorted to copying the above code to both the Form.Create and Form.Activate event handlers but no joy. I created a button and added the following code to trigger the onChange event handler for the trackbar. This works and displays the meter.

```<code>procedure TForm1.Button1Click(Sender: TObject);
begin
  TrackBar1.Position := 1;
end;
</code>```

When I copied this to the Form.Activate handler it doesn't. Can anyone please tell me what I'm doing wrong? I'm using Delphi Berlin starter edition. Thanks

答:
A TPaintBox must be painted using its OnPaint event. This event is triggered every time Windows needs you to redraw the control. You can't simply draw to the control's Canvas at any time, because it will just be drawn over the next time the control is repainted.

In your particular case, you don't need to move your entire block of code to the OnPaint event handler. Instead, all you need is:

```<code>procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
  PaintBox1.Canvas.Draw(0,0,buffer.Picture.Bitmap)
end;
</code>```

Body:
I'm attempting to write an analog VU meter. I use a bitmap of a VU meter and draw the needle on to the bitmap. I am using a trackbar and it's onChange event to test the meter:

procedure TForm1.TrackBar1Change(Sender: TObject);
var
  angle : integer;
  x,y : integer;
  Peaked : boolean;
begin
   Angle := 120 - Round(sTrackBar1.Position / sTrackBar1.Max * 100 )+20;
   Peaked := Angle < PeakVol;
   if Peaked then
    Buffer.Picture := VUImagePeaked.Picture
   else
    buffer.picture := VUImage.Picture;
   buffer.Picture.Bitmap.Canvas.Pen.Color := clSilver;
   buffer.Picture.Bitmap.Canvas.Pen.Width:=2;
   buffer.Canvas.MoveTo(pivot.x,Pivot.y);
   x := 150 + Round(Cos(DegToRad(Angle)) * NeedleLen);
   y := PaintBox1.Height - Round(Sin(DegToRad(Angle)) *NeedleLen);
   buffer.Canvas.LineTo(x,y);
   PaintBox1.Canvas.Draw(0,0,buffer.Picture.Bitmap)
end;

Seems to work but what I can't get is to display the bitmap of the meter when the program starts. I have even resorted to copying the above code to both the Form.Create and Form.Activate event handlers but no joy. I created a button and added the following code to trigger the onChange event handler for the trackbar. This works and displays the meter.

procedure TForm1.Button1Click(Sender: TObject);
begin
  TrackBar1.Position := 1;
end;

When I copied this to the Form.Activate handler it doesn't. Can anyone please tell me what I'm doing wrong? I'm using Delphi Berlin starter edition. Thanks

Body:
A TPaintBox must be painted using its OnPaint event. This event is triggered every time Windows needs you to redraw the control. You can't simply draw to the control's Canvas at any time, because it will just be drawn over the next time the control is repainted.

In your particular case, you don't need to move your entire block of code to the OnPaint event handler. Instead, all you need is:

procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
  PaintBox1.Canvas.Draw(0,0,buffer.Picture.Bitmap)
end;


问:
Django admin dashboard, not able to "select all" records
I have a weird issue were I am not able to "select all" records for any model in my Django admin dashboard.

This is using Django 1.10.1

It is a small issue, but I still rather have it solved. Appreciate any help!

答:
I know this is an old post, but I just had the same problem. I ran

```<code>python manage.py collectstatic
</code>```

Then I cleared my cached images and files in chrome. This solved the problem.

Body:
I know this is an old post, but I just had the same problem. I ran

python manage.py collectstatic

Then I cleared my cached images and files in chrome. This solved the problem.


问:
IntelliJ 14 keyboard shortcuts are QWERTY though keyboard is DVORAK
I'm

running IntelliJ 14

using Mac OS X layout

running on OS X (Yosemite)

IntelliJ is using DVORAK in general but not for keyboard shortcuts.
keyboard shortcuts are in QWERTY. As if they were scancode based instead of the key value after mapping.

Ideas?

edit 1
@gabriel hard to tell but here are some examples...
note: m, a and 0-9 are same on DVORAK and QWERTY

```<code>cmd+/     'comment line' flashes code menu and sometimes moves to a brace (/ == {)
cmd+b      works, goes to definition  (b == n)
cmd+opt+l 'reformat' flashes code menu  (l == p)
</code>```

答:
This problem is (finally!) fixed in IntelliJ IDEA 2017.1. See JetBrains issue JRE-172, “Wrong keys are picked up on dvorak layout in Mac OSX 10.6.2”.

It also seems to be fixed in other JetBrains tools. I tested that it's fixed in PyCharm 2017.1, CLion 2017.1, and AppCode 2017.1.

Body:
I'm

running IntelliJ 14

using Mac OS X layout

running on OS X (Yosemite)

IntelliJ is using DVORAK in general but not for keyboard shortcuts.
keyboard shortcuts are in QWERTY. As if they were scancode based instead of the key value after mapping.

Ideas?

edit 1
@gabriel hard to tell but here are some examples...
note: m, a and 0-9 are same on DVORAK and QWERTY

cmd+/     'comment line' flashes code menu and sometimes moves to a brace (/ == {)
cmd+b      works, goes to definition  (b == n)
cmd+opt+l 'reformat' flashes code menu  (l == p)


问:
Renaming a React Native project?
Are there instructions for what needs to be changed in order to rename a React Native project? I have an app called something along the lines of MyAppIOS and I want to rename it to simply MyApp (now that Android support is out)</p>

答: I am probably a bit late, but for the people looking for a solid solution, there is a react-native-rename npm package which can do the magic.</p>

Title: Renaming a React Native project?


问:
Can I use another port other than 443 for HTTPS/SSL communication?
443 port is typically used for HTTPS/SSL. But is it the only option we can choose for HTTPS/SSL communication. If not, why?</p>

答: We can use any available port for HTTPS, however, for the sake of convention, 443 and 8443 are assigned for HTTPS (browsers automatically prefix with https when these port numbers are used), but we can even run HTTPS on port 80. In this case it is our responsibility to use https (if we don't indicate it, the browser will consider it a http link).</p>


问:
How can a vector be both dynamic and known at compile time in Rust?
I'm confused by what seem to be conflicting statements in the documentation for vectors in Rust:

A ‘vector’ is a dynamic or ‘growable’ array, implemented as the standard library type Vec<T>.

and

Vectors store their contents as contiguous arrays of T on the heap. This means that they must be able to know the size of T at compile time (that is, how many bytes are needed to store a T?). The size of some things can't be known at compile time. For these you'll have to store a pointer to that thing: thankfully, the Box type works perfectly for this.

Rust vectors are dynamically growable, but I don't see how that fits with the statement that their size must be known at compile time.

It's been a while since I've worked with a lower-level language where I have to think about memory allocation so I'm probably missing something obvious.

答:
Note the wording:

they must be able to know the size of T

This says that the size of an individual element must be known. The total count of elements, and thus the total amount of memory allocated, is not known.

When the vector allocates memory, it says "I want to store 12 FooBar structs. One FooBar is 24 bytes, therefore I need to allocate 288 bytes total".

The 12 is the dynamic capacity of the vector, the 24 is the static size of one element (the T).


问:
fetching data and show in view page

when i execute while loop in view page this below error show
  Message: mysql_fetch_array() expects parameter 1 to be resource, array given

my model

```<code>function get_row($id) {
    $this->db->select("*");
    $this->db->from('pending_list');
    $this->db->where('id',$id);
    $query = $this->db->get();
    return $query->result_array();
}
</code>```

my controller

```<code>public function pass_print() {
    $id = $this->uri->segment(3);

    $data['h'] = $this->admin_model->get_row($id);
    $this->load->view('header');
    $this->load->view('sidebar');
    $this->load->view('print_pass',$data);
    $this->load->view('footer');
}
</code>```

my view

```<code><?php while($rows= mysql_fetch_array($h)){?>
                                        <div class="form-group">
                                            <label for="inputEmail3" class="col-sm-3 control-label">
                                                Visitors Name</label>
                                            <div class="col-sm-9">
                                                <input type="text" class="form-control" id="inputEmail3" value="<?php $rows['visitor_name']?>" name="visitor" placeholder="Visitors Name">
                                            </div>
                                        </div>
<?php}?>
</code>```

答:
For model, you can write this instead:

```<code>$this->db->get_where('pending_list', array('id'=>$id))->row();
</code>```

And for view, use this code to get its value:

```<code>echo $h->visitor_name;
</code>```

Title: fetching data and show in view page

Body:
when i execute while loop in view page this below error show
  Message: mysql_fetch_array() expects parameter 1 to be resource, array given

my model

function get_row($id) {
    $this->db->select("*");
    $this->db->from('pending_list');
    $this->db->where('id',$id);
    $query = $this->db->get();
    return $query->result_array();
}

my controller

public function pass_print() {
    $id = $this->uri->segment(3);

    $data['h'] = $this->admin_model->get_row($id);
    $this->load->view('header');
    $this->load->view('sidebar');
    $this->load->view('print_pass',$data);
    $this->load->view('footer');
}

my view

<?php while($rows= mysql_fetch_array($h)){?>

                                                Visitors Name

                                                <input type="text" class="form-control" id="inputEmail3" value="<?php $rows['visitor_name']?>" name="visitor" placeholder="Visitors Name">

<?php}?>

Body:
For model, you can write this instead:

$this->db->get_where('pending_list', array('id'=>$id))->row();

And for view, use this code to get its value:

echo $h->visitor_name;


问:
Change JavaScript variable depending on selected DropDownList
I have a table that has a lot of DropDownList that i had change each of the class name depending on the iteration :

```<code><table id="categoryTable" class="table table-striped table-hover">
    <tr class="header">
        <th>
            @Html.DisplayNameFor(model => model.Category)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.SubCategory)
        </th>
        <th>New Category</th>
        <th>New Subcategory</th>
        <th></th>
    </tr>

    @if (Model != null) { int i = 1; foreach (var item in Model) {

    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Category)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.SubCategory)
        </td>

        <td>
            <input type="hidden" class="varIteration" value="@i" /> @Html.DropDownList("CategoryId", null, "Select Your Category", htmlAttributes: new { @class = "form-control Category" + i })
        </td>
        <td>
            <input type="hidden" class=@( "SubCategoryID_CategoryID_initial"+@i) value="@i" /> @Html.DropDownList("SubCategoryId", null, "Select Your Subcategory", htmlAttributes: new { @class = "form-control SubCategory" + i })
        </td>
        <td>
            <button type="submit" class="btn">
                <i class="fa fa-check"> Update</i>
            </button>
            @*
            <input type="submit" value="Save" class="fa fa-check" />*@
        </td>
    </tr>
    i++; } }

</table>
</code>```

I need to change the subcategory values depending on the selected value in the Category using the next script below that doesn't work only on time with the first category drop down list:

```<code>$(document).ready(function(e) {
    var iteration = $(".varIteration").val(); // iteration = 1 only
    getSubCat(true, $(".SubCategoryID_CategoryID_initial" + iteration).val(), iteration);
    $(document).on("change", ".Category" + iteration, function(event) {
        getSubCat(false, $(".Category" + iteration).val(), iteration);
    });

    function getSubCat(load, changed, iteration) {
        alert(iteration)
        var url = "/auc.accesscontrol/profiles/GetSubCatIDByCatID";
        var initialSubCat = $(".SubCategoryID_CategoryID_initial").val();
        var initialCat = $(".SubCategoryID_SubCategoryID_initial").val();
        if (load) {
            $('.Category' + iteration + ' option[value="' + initialCat + '"]').prop("selected", true);
        }
        if (initialCat == null) {
            changed = $(".Category" + iteration).val();
        }
        $.getJSON(url, {
            id: changed
        }, function(data) {
            alert(changed);
            $(".SubCategory" + iteration).empty();
            $(".SubCategory" + iteration).append("<option value= '0'>Select Your Subcategory</option>");
            $.each(data, function(index, item) {
                $(".SubCategory" + iteration).append("<option value='" + item.SubCategoryId + "'>" + item.Name + "</option>");
                $('.SubCategory' + iteration + ' option[value="' + initialSubCat + '"]').prop("selected", true);
            });
        });
    };
});
</code>```

When I check the view class names will find that drop down list for categories like : Category1, Category2 ,...etc
and the Subcategory : SubCategory1, Subcategory2, ....etc
hidden input values : will changed depending on the last i.
Need a help to change the iteration variable depending on the selected category drop down list.

EDIT :
This is the JsonResult function:

```<code>public JsonResult GetSubCatIDByCatID(int id)
    {
        db.Configuration.ProxyCreationEnabled = false;
        var subCategoryList = db.SubCategory.Where(m => m.CategoryId == id).ToList();
        return Json(subCategoryList, JsonRequestBehavior.AllowGet);
    }
</code>```

答:
When you do this:

```<code>$(".varIteration").val()
</code>```

If there are multiple matching elements (and in this case there are), what do you expect the single value to be?  From the description of the behavior it sounds like it's the value from the first matching element.

Get the iteration value in the event, not at the page level.  So first change your event handler creation to something like this:

```<code>$(document).on("change", "[class^=Category]", function(event) {
    //...
});
</code>```

This will find all elements where class "starts with" "Category", regardless of what the rest of the class name is.

Then, inside that event handler, you can dynamically navigate the DOM to find the specific iteration value you want.  For the HTML you show, that would look something like this:

```<code>var iteration = $(this).closest("td").find(".varIteration").val();
</code>```

Which basically means:

Starting from the element which raised the change event, navigate up the DOM to the first  element, then within that element find any matching .varIteration elements.

Since within that scope there's only one .varIteration element, it'll have the value you're looking for.

You'll still need to adjust the call to getSubCat(), since that also tries to use that one value.  It's not clear to me what that function is supposed to actually do, so there's only so much I can advise on that.  If it does need to be called for each possible value of iteration then you could perhaps put that range of values in a variable somewhere and call getSubCat() in a loop.  Though a loop of AJAX calls to the same resource seems pretty inefficient.  I suspect there's a better way to do whatever it is you're trying to do with that function.

But at least for the problems you describe in your comments above:

iteration variable always equal 1

That's because you only ever get one value for it, and it's the first matching value.

Nothings happen when click on any other drop down list

That's because you only ever create a change handler for that one matching value.

Create a single change handler for all matching elements and dynamically get the value you need in that change handler instead.

Body:
I have a table that has a lot of DropDownList that i had change each of the class name depending on the iteration :

            @Html.DisplayNameFor(model => model.Category)

            @Html.DisplayNameFor(model => model.SubCategory)

        New Category
        New Subcategory

    @if (Model != null) { int i = 1; foreach (var item in Model) {

            @Html.DisplayFor(modelItem => item.Category)

            @Html.DisplayFor(modelItem => item.SubCategory)

            <input type="hidden" class="varIteration" value="@i" /> @Html.DropDownList("CategoryId", null, "Select Your Category", htmlAttributes: new { @class = "form-control Category" + i })

            <input type="hidden" class=@( "SubCategoryID_CategoryID_initial"+@i) value="@i" /> @Html.DropDownList("SubCategoryId", null, "Select Your Subcategory", htmlAttributes: new { @class = "form-control SubCategory" + i })

            <button type="submit" class="btn">
                 Update
            </button>
            @*
            <input type="submit" value="Save" class="fa fa-check" />*@

    i++; } }

I need to change the subcategory values depending on the selected value in the Category using the next script below that doesn't work only on time with the first category drop down list:

$(document).ready(function(e) {
    var iteration = $(".varIteration").val(); // iteration = 1 only
    getSubCat(true, $(".SubCategoryID_CategoryID_initial" + iteration).val(), iteration);
    $(document).on("change", ".Category" + iteration, function(event) {
        getSubCat(false, $(".Category" + iteration).val(), iteration);
    });

    function getSubCat(load, changed, iteration) {
        alert(iteration)
        var url = "/auc.accesscontrol/profiles/GetSubCatIDByCatID";
        var initialSubCat = $(".SubCategoryID_CategoryID_initial").val();
        var initialCat = $(".SubCategoryID_SubCategoryID_initial").val();
        if (load) {
            $('.Category' + iteration + ' option[value="' + initialCat + '"]').prop("selected", true);
        }
        if (initialCat == null) {
            changed = $(".Category" + iteration).val();
        }
        $.getJSON(url, {
            id: changed
        }, function(data) {
            alert(changed);
            $(".SubCategory" + iteration).empty();
            $(".SubCategory" + iteration).append("<option value= '0'>Select Your Subcategory</option>");
            $.each(data, function(index, item) {
                $(".SubCategory" + iteration).append("<option value='" + item.SubCategoryId + "'>" + item.Name + "</option>");
                $('.SubCategory' + iteration + ' option[value="' + initialSubCat + '"]').prop("selected", true);
            });
        });
    };
});

When I check the view class names will find that drop down list for categories like : Category1, Category2 ,...etc
and the Subcategory : SubCategory1, Subcategory2, ....etc
hidden input values : will changed depending on the last i.
Need a help to change the iteration variable depending on the selected category drop down list.

EDIT :
This is the JsonResult function:

public JsonResult GetSubCatIDByCatID(int id)
    {
        db.Configuration.ProxyCreationEnabled = false;
        var subCategoryList = db.SubCategory.Where(m => m.CategoryId == id).ToList();
        return Json(subCategoryList, JsonRequestBehavior.AllowGet);
    }

Body:
When you do this:

$(".varIteration").val()

If there are multiple matching elements (and in this case there are), what do you expect the single value to be?  From the description of the behavior it sounds like it's the value from the first matching element.

Get the iteration value in the event, not at the page level.  So first change your event handler creation to something like this:

$(document).on("change", "[class^=Category]", function(event) {
    //...
});

This will find all elements where class "starts with" "Category", regardless of what the rest of the class name is.

Then, inside that event handler, you can dynamically navigate the DOM to find the specific iteration value you want.  For the HTML you show, that would look something like this:

var iteration = $(this).closest("td").find(".varIteration").val();

Which basically means:

Starting from the element which raised the change event, navigate up the DOM to the first <td> element, then within that element find any matching .varIteration elements.

Since within that scope there's only one .varIteration element, it'll have the value you're looking for.

You'll still need to adjust the call to getSubCat(), since that also tries to use that one value.  It's not clear to me what that function is supposed to actually do, so there's only so much I can advise on that.  If it does need to be called for each possible value of iteration then you could perhaps put that range of values in a variable somewhere and call getSubCat() in a loop.  Though a loop of AJAX calls to the same resource seems pretty inefficient.  I suspect there's a better way to do whatever it is you're trying to do with that function.

But at least for the problems you describe in your comments above:

iteration variable always equal 1

That's because you only ever get one value for it, and it's the first matching value.

Nothings happen when click on any other drop down list

That's because you only ever create a change handler for that one matching value.

Create a single change handler for all matching elements and dynamically get the value you need in that change handler instead.


问:
How to call custom proptype function with ES6 React class
How to call a custom proptype function with an ES6 react class ?

```<code>export default class MyComponent extends Component {
    validate(props, propName, componentName) {
        ...
    );
    ...
}

MyComponent.propTypes = {
    children: validate
};
</code>```

I have try many ways (MyComponent.validate, this.validate, with a bind) but nothing works.

答:
If I understand you correctly, you are trying to write a custom prop validation for a component, and you want this validation function to be inside the component class.

To call a function in a class without instantiating the class, the function needs to be static.

This will work:

class SomeClass {
  static func() {
    console.log('in here');
  }
}

SomeClass.func();```

However, I do not think it is right to keep the validation function for the component in the component class itself. I believe it'd be best to keep that function outside.

Body:
How to call a custom proptype function with an ES6 react class ?

export default class MyComponent extends Component {
    validate(props, propName, componentName) {
        ...
    );
    ...
}

MyComponent.propTypes = {
    children: validate
};

I have try many ways (MyComponent.validate, this.validate, with a bind) but nothing works.

Body:
If I understand you correctly, you are trying to write a custom prop validation for a component, and you want this validation function to be inside the component class.

To call a function in a class without instantiating the class, the function needs to be static.

This will work:

class SomeClass {
  static func() {
    console.log('in here');
  }
}

SomeClass.func();

However, I do not think it is right to keep the validation function for the component in the component class itself. I believe it'd be best to keep that function outside.


问:
R: Extract first and last names only from a list of names
I am using R for data manipulation. I have a very long list of names that looks like this:

```<code>"names"

[1] ""
[2] "Victoria Marie"
[3] "Ori Mann"
[4] "Lina Pearl Right"
[5] "David Berg"
[6] "Anthony Lee"
[7] "Brian Michael Ingraham"
[8] "Jay Ling"
</code>```

I want to extract only the first and last names of the whole list into new columns and discard any middle names. How do I do this?
I used the following code:

```<code>mat  = matrix(unlist(names), ncol=2, byrow=TRUE)
</code>```

this just runs through all the names in each entry and throws all them into columns in order.

Any help would be greatly appreciated.

答:
Here's a way to do this in base R that also deals with the possibility of suffixes. If you discover additional suffixes (e.g., 'II'), you can add them to the vector that follows %in%.

```<code># some representative data
names <- list("", "Ed Smith", "Jennifer Jason Leigh", "Ed Begley, Jr.")

# use strsplit to get a list of vectors of each name broken into its parts,
# keying off the space between names
names.split <- strsplit(unlist(names), " ")

# make new vectors with the first and last names, based on their position in
# those vectors. for last names, make the result conditional on whether or
# not a recognized suffix is in the last spot, and get rid of any
# punctuation attached to the last name if there was a suffix.
name.first <- sapply(names.split, function(x) x[1])
name.last <- sapply(names.split, function(x)

  # this deals with empty name slots in your original list, returning NA
  if(length(x) == 0) {

    NA

  # now check for a suffix; if one is there, use the penultimate item
  # after stripping it of any punctuation
  } else if (x[length(x)] %in% c("Jr.", "Jr", "Sr.", "Sr")) {

    gsub("[[:punct:]]", "", x[length(x) - 1])

  } else {

    x[length(x)]

})
</code>```

Results:

```<code>> name.first
[1] NA         "Ed"       "Jennifer" "Ed"
> name.last
[1] NA       "Smith"  "Leigh"  "Begley"
</code>```

Body:
I am using R for data manipulation. I have a very long list of names that looks like this:

"names"

[1] ""
[2] "Victoria Marie"
[3] "Ori Mann"
[4] "Lina Pearl Right"
[5] "David Berg"
[6] "Anthony Lee"
[7] "Brian Michael Ingraham"
[8] "Jay Ling"

I want to extract only the first and last names of the whole list into new columns and discard any middle names. How do I do this?
I used the following code:

mat  = matrix(unlist(names), ncol=2, byrow=TRUE)

this just runs through all the names in each entry and throws all them into columns in order.

Any help would be greatly appreciated.

Body:
Here's a way to do this in base R that also deals with the possibility of suffixes. If you discover additional suffixes (e.g., 'II'), you can add them to the vector that follows %in%.

# some representative data
names <- list("", "Ed Smith", "Jennifer Jason Leigh", "Ed Begley, Jr.")

# use strsplit to get a list of vectors of each name broken into its parts,
# keying off the space between names
names.split <- strsplit(unlist(names), " ")

# make new vectors with the first and last names, based on their position in
# those vectors. for last names, make the result conditional on whether or
# not a recognized suffix is in the last spot, and get rid of any
# punctuation attached to the last name if there was a suffix.
name.first <- sapply(names.split, function(x) x[1])
name.last <- sapply(names.split, function(x)

  # this deals with empty name slots in your original list, returning NA
  if(length(x) == 0) {

    NA

  # now check for a suffix; if one is there, use the penultimate item
  # after stripping it of any punctuation
  } else if (x[length(x)] %in% c("Jr.", "Jr", "Sr.", "Sr")) {

    gsub("[[:punct:]]", "", x[length(x) - 1])

  } else {

    x[length(x)]

})

Results:

> name.first
[1] NA         "Ed"       "Jennifer" "Ed"
> name.last
[1] NA       "Smith"  "Leigh"  "Begley"


问:
How to make cgdb show assembly code?
I can't find a way for cgdb to disassemble a binary and show the assembly code with the current instruction in the code window. Is this possible and what command should I use? I'm using Mac OS X and got cgdb from the homebrew repository. </p>

答:
A recent update (Feb 2017) to cgdb makes it possible to do this. You will need cgdb version 0.7.0 or newer. (At the time of writing this is the latest release). You may need to compile this from source yourself given how recent it is.

More details on adding disassembly support can be found here:
https://github.com/cgdb/cgdb/issues/44

To view the disassembly in cgdb hit esc and type :set disenter.

To go back to the source (if available), repeat this, except type :set nodis.

Title: How to make cgdb show assembly code?


问:
Does Lucene.Net allow searching and indexing at the same time?
When my collection of files is updated then I want to search the newest data...

Like windows Advance search option.

答:
The book, "Lucene in Action, Second edition" has a section on near real-time searching.  Basically, you get the IndexReader by calling the IndexWriter.GetReader() method and save it.  When starting a search, call the IndexWriter.GetReader() and compare the returned reader with the saved value.  If it is the same, just use the existing reader.  Multiple threads can share the same reader.

If it is different, close the old reader and save the new one.  Use the saved value for the search.

Behind the scene, the new reader includes all the pending (uncommitted) documents in the index.  Pending changes are flushed to disk (or RamDirectory), but not committed.


问:
Command Line Arguments and Chars
What is the proper way to receive a command line argument from the user and compare it to a single char? For example if the user typed "Y" for yes run some function and "N" for no would run another function.

My main error is "comparison between ptr and integer" & "too few arguments to function call, expected 3 have 1"

```<code>#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void calculate();
void verify();

int main (int argc, char *argv[]) {
   if(argc < 2){
        printf("Please enter a mode of operation.\n");
        return 0;
    }
    else if(argc > 2){
        printf("Too many arguments supplied. Please try again.\n");
        return 0;
    }
    else if(strncmp(argv[1] == 'c') == 0)
        calculate();

    else if(strncmp(argv[1] == 'v') == 0)
        verify();

return 0;
}

void calculate(){
}

void verify(){
}
</code>```

答:
This

```<code>strncmp(argv[1] == 'c') == 0
</code>```

just is incorrect syntax. For starters the function strncmp requires three arguments and it deals with strings while in the avove call of the function there is supplied only one argument of type int. because the wrong expression argv[1] == 'c' has type int and is equal to 0.

I can suggest the following solution

```<code>else if ( argc > 2 || strlen( argv[1] ) != 1 ){
    printf("Too many arguments supplied. Please try again.\n");
    return 0;
}
else if ( argv[1][0] == 'c' )
    calculateCRC();

else if ( argv[1][0] == 'v' )
    verifyCRC();
</code>```

Title: Command Line Arguments and Chars

Body:
What is the proper way to receive a command line argument from the user and compare it to a single char? For example if the user typed "Y" for yes run some function and "N" for no would run another function.

My main error is "comparison between ptr and integer" & "too few arguments to function call, expected 3 have 1"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void calculate();
void verify();

int main (int argc, char *argv[]) {
   if(argc < 2){
        printf("Please enter a mode of operation.\n");
        return 0;
    }
    else if(argc > 2){
        printf("Too many arguments supplied. Please try again.\n");
        return 0;
    }
    else if(strncmp(argv[1] == 'c') == 0)
        calculate();

    else if(strncmp(argv[1] == 'v') == 0)
        verify();

return 0;
}

void calculate(){
}

void verify(){
}

Body:
This

strncmp(argv[1] == 'c') == 0

just is incorrect syntax. For starters the function strncmp requires three arguments and it deals with strings while in the avove call of the function there is supplied only one argument of type int. because the wrong expression argv[1] == 'c' has type int and is equal to 0.

I can suggest the following solution

else if ( argc > 2 || strlen( argv[1] ) != 1 ){
    printf("Too many arguments supplied. Please try again.\n");
    return 0;
}
else if ( argv[1][0] == 'c' )
    calculateCRC();

else if ( argv[1][0] == 'v' )
    verifyCRC();


问:
Search sibling of by another child's value in XML
I have a question regarding the processing of an XML file using DomDocument in PHP.

```<code><managedObject class="class1" version="version1" distName="distName1" id="id1">
    <p name="a">Data I have</p>
    <p name="b">Some data</p>
    <p name="c">Some data</p>
    <p name="d">Data I need</p>
    <p name="e">Some data</p>
</managedObject>

<managedObject class="class2" version="version2" distName="distName2" id="id2">
    <p name="a">Some data</p>
    <p name="b">Some data</p>
    <p name="c">Some data</p>
    <p name="d">Some data</p>
    <p name="e">Some data</p>
</managedObject>
</code>```

By only knowing the "a" element, could I get the "d" element, but only if the parent have a certain class and version?

So far I've had a few tries, most recent being:

```<code>$nodes = $finder->query("//*[contains(@class, 'class1')][contains(@version, 'version1')]/*[contains(@name, 'a')]");
foreach ($nodes as $node) {
            $Array[$i] = $node;
        }
</code>```

I used this to see at least some properties of the node but it doesn't return anything.

Any help would be appreciated.

答:
You can use following xpath to locate
Data I need

```<code>//managedobject[@class='class1'][@version='version1']/p[@name='a']/following-sibling::p[@name='d']
</code>```

//managedobject[@class='class1'][@version='version1']/p[@name='a'] will specify your parent element with specific class and version and a element

And /following-sibling::p[@name='d'] will locate your d element which is sibling of a

Body:
I have a question regarding the processing of an XML file using DomDocument in PHP.

<managedObject class="class1" version="version1" distName="distName1" id="id1">

Data I have

Some data

Some data

Data I need

Some data

</managedObject>

<managedObject class="class2" version="version2" distName="distName2" id="id2">

Some data

Some data

Some data

Some data

Some data

</managedObject>

By only knowing the "a" element, could I get the "d" element, but only if the parent have a certain class and version?

So far I've had a few tries, most recent being:

$nodes = $finder->query("//*[contains(@class, 'class1')][contains(@version, 'version1')]/*[contains(@name, 'a')]");
foreach ($nodes as $node) {
            $Array[$i] = $node;
        }

I used this to see at least some properties of the node but it doesn't return anything.

Any help would be appreciated.

Body:
You can use following xpath to locate <p name="d">Data I need</p>

//managedobject[@class='class1'][@version='version1']/p[@name='a']/following-sibling::p[@name='d']

//managedobject[@class='class1'][@version='version1']/p[@name='a'] will specify your parent element with specific class and version and a element

And /following-sibling::p[@name='d'] will locate your d element which is sibling of a


问:
Kendo Angular 2 Grid Filter not available
I am using the Kendo Grid with Angular 2 using this http://www.telerik.com/kendo-angular-ui/components/grid/data-binding/ tutorial but I didn't find filtering in the grid. How can I filter my Kendo Grid with Angular 2?</p>

答:
I was just checking possible ways to enable filter in Kendo Angular 2 Grid and found that Telerik has enabled it. Please check following link.

http://www.telerik.com/kendo-angular-ui/components/grid/filtering/