问:
Route Model Binding multiple types of Models to the same Controller method in Laravel
I am trying to figure out the correct way to implement a polymorphic relationship in Laravel using the example case of allowing the same "Comment" model to have a relationship with both "Posts" and "Videos".

This is the same example as in the Laravel docs, as follows:

```<code>posts
    id - integer
    title - string
    body - text

videos
    id - integer
    title - string
    url - string

comments
    id - integer
    body - text
    commentable_id - integer
    commentable_type - string
</code>```

I have the models set up with the relationships back and forth - no issue there. My question is how to make most efficient use of the CommentsController? I would like to be able to use the same CommentsController@store method to store any type of comment, whether it be for a post or a video.

This, rather than the alternative of having a CommentsController@storePostComment and a CommentsController@storeVideoComment.

I have my routes set up as follows:

```<code>Route::post('/posts/{post}/comments', 'CommentsController@store');
Route::post('/videos/{video}/comments', 'CommentsController@store');
</code>```

I have my CommentsController@store method set up as follows, currently for Posts only:

```<code>class CommentsController extends Controller
{

    public function store(Post $post)
    {
        $post->addComment(request('body'));

        return back();
    }
}
</code>```

Laravel's route model binding grabs the correct Post and the addComment() method saves the comment.

My question is how can I modify this to accept either a Post or a Video to the same method? I am sure this is the correct way to do it rather than creating separate methods for each, but not sure how to go about it.

答:
Try Using SEGMENT</p>

```<code>public function store($data)  //{post} or {video} comes here
{
   if(Request::segment(1) == 'posts'){
       $post = new Post;
       $post->addComment(request('body'));
   }else if(Request::segment(1) == 'videos'){
       $video = new Video;
       $video->addComment(request('url'));
   }
   return back();
}
</code>```

Body:
I am trying to figure out the correct way to implement a polymorphic relationship in Laravel using the example case of allowing the same "Comment" model to have a relationship with both "Posts" and "Videos".

This is the same example as in the Laravel docs, as follows:

posts
    id - integer
    title - string
    body - text

videos
    id - integer
    title - string
    url - string

comments
    id - integer
    body - text
    commentable_id - integer
    commentable_type - string

I have the models set up with the relationships back and forth - no issue there. My question is how to make most efficient use of the CommentsController? I would like to be able to use the same CommentsController@store method to store any type of comment, whether it be for a post or a video.

This, rather than the alternative of having a CommentsController@storePostComment and a CommentsController@storeVideoComment.

I have my routes set up as follows:

Route::post('/posts/{post}/comments', 'CommentsController@store');
Route::post('/videos/{video}/comments', 'CommentsController@store');

I have my CommentsController@store method set up as follows, currently for Posts only:

class CommentsController extends Controller
{

    public function store(Post $post)
    {
        $post->addComment(request('body'));

        return back();
    }
}

Laravel's route model binding grabs the correct Post and the addComment() method saves the comment.

My question is how can I modify this to accept either a Post or a Video to the same method? I am sure this is the correct way to do it rather than creating separate methods for each, but not sure how to go about it.

Body:
Try Using SEGMENT

public function store($data)  //{post} or {video} comes here
{
   if(Request::segment(1) == 'posts'){
       $post = new Post;
       $post->addComment(request('body'));
   }else if(Request::segment(1) == 'videos'){
       $video = new Video;
       $video->addComment(request('url'));
   }
   return back();
}


来源: stackexchange

问:
How to use renderAjax() directly?
I create helper without extends controller, like this

```<code>class SomeClass{
public function static SomeMethod(){

//this function for send email

$controller = new \yii\web\Controller();
$controller->renderAjax("template", "array");
}

}
</code>```

how ever the above code generate Missing argument 1 for yii\base\Controller::__construct(), called in common\component\BeoHelper.php on line 1715 and defined

How I can fix it?

答:
Try this:</p>

```<code>\Yii::$app->controller->renderAjax(...);
</code>```

ContentLicense: CC BY-SA 3.0

Title: How to use renderAjax() directly?

Body:
I create helper without extends controller, like this

class SomeClass{
public function static SomeMethod(){

//this function for send email

$controller = new \yii\web\Controller();
$controller->renderAjax("template", "array");
}

}

how ever the above code generate Missing argument 1 for yii\base\Controller::__construct(), called in common\component\BeoHelper.php on line 1715 and defined

How I can fix it?

Body:
Try this:

\Yii::$app->controller->renderAjax(...);


问:
Why does firebase not work on my nodejs server?
You will see I have this code

```<code>var email = req.body.correo;
var pass = req.body.pass;
var firebase = require("firebase-admin");
var serviceAccount = require("./prueba-064cb79dba28.json");

firebase.initializeApp({
credential: firebase.credential.cert(serviceAccount),
databaseURL: "https://prueba-b81ec.firebaseio.com"
});

firebase.auth().createUserWithEmailAndPassword(email,pass).catch(function(error){

var errorCode = error.code;
var errorMessage = error.message;

});

}
</code>```

I have been browsing the documentation, first I had a deprecated method error  with the firebase library, the server sent me an error message telling me to use this one, however it does not work, it does not create the user, I already verified that the email and key are sent

答:
You are requiring firebase-admin when you seem to be using the firebase client node.js. The client library is used for createUserWithEmailAndPassword.
Replace with the following:</p>

```<code>var firebase = require("firebase");
var config = {
  apiKey: "AIza...",
  authDomain: "...",
  databaseURL: "...",
  ..
};
firebase.initializeApp(config);
</code>```

Body:
You will see I have this code

var email = req.body.correo;
var pass = req.body.pass;
var firebase = require("firebase-admin");
var serviceAccount = require("./prueba-064cb79dba28.json");

firebase.initializeApp({
credential: firebase.credential.cert(serviceAccount),
databaseURL: "https://prueba-b81ec.firebaseio.com"
});

firebase.auth().createUserWithEmailAndPassword(email,pass).catch(function(error){

var errorCode = error.code;
var errorMessage = error.message;

});

}

I have been browsing the documentation, first I had a deprecated method error  with the firebase library, the server sent me an error message telling me to use this one, however it does not work, it does not create the user, I already verified that the email and key are sent

Body:
You are requiring firebase-admin when you seem to be using the firebase client node.js. The client library is used for createUserWithEmailAndPassword.
Replace with the following:

var firebase = require("firebase");
var config = {
  apiKey: "AIza...",
  authDomain: "...",
  databaseURL: "...",
  ..
};
firebase.initializeApp(config);


问:
Anybody interested in possible operation/use of quantum computers?
I went through a period of being interested in how quantum computers work and what they might be good for if they ever become practical. I know they are talked about for code-breaking. I was interested is using them for validating software by essentially trying all possible inputs (in parallel) and seeing if any error states are reached.

I know it's a bit of a blue-sky question, but I wonder if others are interested in quantum computers, how they might work, and what they would be useful for.

Added: Just for fun, let me throw out a mini-tutorial:

Suppose you've got N bits of memory to play with. Suppose you can load those bits (or some of them) with your input data. Then suppose there is a finite sequence of operations you can do on them (without using any additional memory) leaving the answer in them.

To do this with a quantum computer, it is only necessary that you make sure that the entire computation is reversible, by reserving some of the bits to record branches you took, so you can undo them. If you do that, then all the operations can be written as simple unitary matrix transformations on the N bits. (A unitary transform is a pure rotation in the N-dimensional coordinate system.) So performing the computation consists of applying a succession of pure rotations on the bit-vector.

If you do this, then if the N-bit vector is in a quantum computer, it can be initialized into a state where all 2^N (or fewer) possible inputs are superimposed at the same time in "parallel universes". Then if you do the computation, it is doing them all at the same time.

Now all you have to do to see if one of the inputs gives you a particular answer is to let it run to a particular state. If you halt it and examine the state, what it does is choose one of the universes at random and throw away all the rest. So what the Grover algorithm lets you do is, without halting it, accentuate the probability of the universes with the answer state. Then you run it forward, then backward, then forward, and so on for a number of iterations until the answer universe has very high probability. Then if you examine it, you have a high probability of seeing the answer you want.

Whew...

答:
I'm mildly interested, as I am in all science, but honestly I haven't spent a moment investigating them very deeply or thought about how they could be applied to problems that I work on.   There's still so much for me to learn about how we apply the von Neumann-esque architectures that we use today.

Maybe multiple cores and massive parallelization is a half-step towards those kinds of problems.  But I'm only crawling in that direction.

I have no idea how I'd program them for anything useful.

Danny Hillis, of Connection Machine and Long Now fame, used a machine to write a sorting algorithm that was optimized using genetic techniques.  I wonder if revisiting something like that would be a worthwhile problem?  Or perhaps a stable, faster linear algebra solution?

Is yours a rhetorical question?  Do you have access to such a machine, with near-term plans to try your idea?

OwnerDisplayName: Mike Dunlavey

ContentLicense: CC BY-SA 2.5

LastEditorDisplayName: Mike Dunlavey


问:
ssh localhost still needs password for Mac OS, how to deal with?
when ssh localhost still needs password, how to do?

ssh -vvv localhost

```<code>Last login: Fri Mar 31 12:51:03 on ttys000
chendeMacBook-Pro:~ chen$ ssh -vvv localhost
OpenSSH_7.4p1, LibreSSL 2.5.0
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolving "localhost" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to localhost [::1] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /Users/chen/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/chen/.ssh/id_rsa-cert type -1
debug1: identity file /Users/chen/.ssh/id_dsa type 2
debug1: key_load_public: No such file or directory
debug1: identity file /Users/chen/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/chen/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/chen/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/chen/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/chen/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: match: OpenSSH_7.4 pat OpenSSH* compat 0x04000000
debug2: fd 5 setting O_NONBLOCK
debug1: Authenticating to localhost:22 as 'chen'
debug3: hostkeys_foreach: reading file "/Users/chen/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /Users/chen/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from localhost
debug3: order_hostkeyalgs: prefer hostkeyalgs: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,ext-info-c
debug2: host key algorithms: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib@openssh.com,zlib
debug2: compression stoc: none,zlib@openssh.com,zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1
debug2: host key algorithms: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib@openssh.com
debug2: compression stoc: none,zlib@openssh.com
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:oLpgYaEG7m2RJpeirxitnwrvjOo55nfEvLhriphbO8Q
debug3: hostkeys_foreach: reading file "/Users/chen/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /Users/chen/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from localhost
debug1: Host 'localhost' is known and matches the ECDSA host key.
debug1: Found key in /Users/chen/.ssh/known_hosts:1
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey after 134217728 blocks
debug1: Skipping ssh-dss key /Users/chen/.ssh/id_dsa - not in PubkeyAcceptedKeyTypes
debug2: key: /Users/chen/.ssh/github_rsa (0x7ffbb2d00cd0), agent
debug2: key: /Users/chen/.ssh/id_rsa (0x0)
debug2: key: /Users/chen/.ssh/id_ecdsa (0x0)
debug2: key: /Users/chen/.ssh/id_ed25519 (0x0)
debug3: send packet: type 5
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug3: start over, passed a different list publickey,password,keyboard-interactive
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/chen/.ssh/github_rsa
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Trying private key: /Users/chen/.ssh/id_rsa
debug3: no such identity: /Users/chen/.ssh/id_rsa: No such file or directory
debug1: Trying private key: /Users/chen/.ssh/id_ecdsa
debug3: no such identity: /Users/chen/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /Users/chen/.ssh/id_ed25519
debug3: no such identity: /Users/chen/.ssh/id_ed25519: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup keyboard-interactive
debug3: remaining preferred: password
debug3: authmethod_is_enabled keyboard-interactive
debug1: Next authentication method: keyboard-interactive
debug2: userauth_kbdint
debug3: send packet: type 50
debug2: we sent a keyboard-interactive packet, wait for reply
debug3: receive packet: type 60
debug2: input_userauth_info_req
debug2: input_userauth_info_req: num_prompts 1
Password:
</code>```

答:
Since you didn't mention the steps you followed for password-less authentication i am not so sure about the problem.

Anyways give a try with the following

```<code>ssh-keygen -t rsa
</code>```

hit enter to all the prompt questions.

```<code>cd ~/.ssh
cat id_rsa.pub >> authorized_keys
</code>```

Body:
when ssh localhost still needs password, how to do?

ssh -vvv localhost

Last login: Fri Mar 31 12:51:03 on ttys000
chendeMacBook-Pro:~ chen$ ssh -vvv localhost
OpenSSH_7.4p1, LibreSSL 2.5.0
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolving "localhost" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to localhost [::1] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /Users/chen/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/chen/.ssh/id_rsa-cert type -1
debug1: identity file /Users/chen/.ssh/id_dsa type 2
debug1: key_load_public: No such file or directory
debug1: identity file /Users/chen/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/chen/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/chen/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/chen/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/chen/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: match: OpenSSH_7.4 pat OpenSSH* compat 0x04000000
debug2: fd 5 setting O_NONBLOCK
debug1: Authenticating to localhost:22 as 'chen'
debug3: hostkeys_foreach: reading file "/Users/chen/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /Users/chen/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from localhost
debug3: order_hostkeyalgs: prefer hostkeyalgs: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,ext-info-c
debug2: host key algorithms: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib@openssh.com,zlib
debug2: compression stoc: none,zlib@openssh.com,zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1
debug2: host key algorithms: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib@openssh.com
debug2: compression stoc: none,zlib@openssh.com
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:oLpgYaEG7m2RJpeirxitnwrvjOo55nfEvLhriphbO8Q
debug3: hostkeys_foreach: reading file "/Users/chen/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /Users/chen/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from localhost
debug1: Host 'localhost' is known and matches the ECDSA host key.
debug1: Found key in /Users/chen/.ssh/known_hosts:1
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey after 134217728 blocks
debug1: Skipping ssh-dss key /Users/chen/.ssh/id_dsa - not in PubkeyAcceptedKeyTypes
debug2: key: /Users/chen/.ssh/github_rsa (0x7ffbb2d00cd0), agent
debug2: key: /Users/chen/.ssh/id_rsa (0x0)
debug2: key: /Users/chen/.ssh/id_ecdsa (0x0)
debug2: key: /Users/chen/.ssh/id_ed25519 (0x0)
debug3: send packet: type 5
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug3: start over, passed a different list publickey,password,keyboard-interactive
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/chen/.ssh/github_rsa
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Trying private key: /Users/chen/.ssh/id_rsa
debug3: no such identity: /Users/chen/.ssh/id_rsa: No such file or directory
debug1: Trying private key: /Users/chen/.ssh/id_ecdsa
debug3: no such identity: /Users/chen/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /Users/chen/.ssh/id_ed25519
debug3: no such identity: /Users/chen/.ssh/id_ed25519: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup keyboard-interactive
debug3: remaining preferred: password
debug3: authmethod_is_enabled keyboard-interactive
debug1: Next authentication method: keyboard-interactive
debug2: userauth_kbdint
debug3: send packet: type 50
debug2: we sent a keyboard-interactive packet, wait for reply
debug3: receive packet: type 60
debug2: input_userauth_info_req
debug2: input_userauth_info_req: num_prompts 1
Password:

Body:
Since you didn't mention the steps you followed for password-less authentication i am not so sure about the problem.

Anyways give a try with the following

ssh-keygen -t rsa

hit enter to all the prompt questions.

cd ~/.ssh
cat id_rsa.pub >> authorized_keys


问:
VoIP certificate doesn't work
My iOS app wants to use VoIP, therefore I created VoIP certificate as described in Apple documentation. But, notifications don't work. I thought, that problem is in code, but when I substituted bundle id in Xcode and created new VoIP certificate - notifications got work. Why my previous bundle with certificate don't work? P.S. I uploaded my app to iTunes Connect, does it matter?</p>

答:
If your app uploaded on App store with normal push notification certificate then yes it will matter a lot.

Because certificate and token differ for normal push notification and push kit silent notification.

Integrating push kit step by step.

Certificate process is there.

Payload form is there.

iOS ( Swift/Objective C code is there)

Debug methond are there

Please do refer.

https://github.com/hasyapanchasara/PushKit_SilentPushNotification

Title: VoIP certificate doesn't work


问:
Google datastore - index a date created field without having a hotspot
I am using Google Datastore and will need to query it to retrieve some entities. These entities will need to be sorted by newest to oldest. My first thought was to have a date_created property which contains a timestamp. I would then index this field and sort on this field. The problem with this approach is it will cause hotspots in the database (https://cloud.google.com/datastore/docs/best-practices).

Do not index properties with monotonically increasing values (such as a NOW() timestamp). Maintaining such an index could lead to hotspots that impact Cloud Datastore latency for applications with high read and write rates.

Obviously sorting data on dates is properly the most common sorting performed on a database. If I can't index timestamps, is there another way I can accomplish being able to sort my queires from newest to oldest without hotspots?

答:
As you note, indexing monotonically changed values doesn't scale and can lead to hotspots. Whether you are potentially impacted by this depends on your particular usage.

As a general rule, the hotspotting point of this pattern is 500 writes per second. If you know you're definitely going to stay under that you probably don't need to worry.

If you do need higher than 500 writes per second, but have a upper limit in mind, you could attempt a sharded approach. Basically, if you upper on writes per second is x, then n = ceiling(x/500), where n is the number of shards. When you write your timestamp, prepend random(1, n) at the start. This creates n random key ranges that each can perform up to 500 writes per second. When you query your data, you'll need to issue n queries and do some client side merging of the result streams.


问:
Azure web service is not working properly
For several days I am experiencing that Azure Web Services is receiving many requests in seconds. Due to this Website is not able to load.</p>

答:
Since many days I am experiencing that Azure Web Services is receiving many requests in seconds.

You could check the request logs by enable Web Server Logging in Azure Portal. By researching the log, you could know whether the requests are from legitimate users or programs. If they are from trusted users or programs, you could scale up or out your web app to meet the large number of requests.

If the requests are from attackers, you could block these kinds of requests by configuring Dynamic IP Address Restrictions(DIPR). The DIPR feature provides two main protections for developers:

Blocking of IP addresses based on number of concurrent requests

Blocking of IP addresses based on number of requests over a period of time

For more information, link below is for your reference.

Configuring Dynamic IP Address Restrictions in Windows Azure Web Sites

If IP addresses of the requests are stable, you can also block these addresses or a range of IP addresses using ipSecurity configuration. For more information, link below is for your reference.

IP and Domain Restrictions for Windows Azure Web Sites


问:
When Managed Bean creates and property of the beans creates?
In our application we use jsf,we have
to redirect the user to home page
 after their session will be expired.For that i need a  path of the home page which i kept in my logout managed bean as a managed bean property.But after session expired if i try to access that it  will arise null pointer exception(managed bean becomes null).Then
i have decide to try alternative (i.e)create logout class manually and try to access the property, at that time the property which i wants to access is become null.How can i access
that property?
Please help me.
Thanks in advance.</p>

答:
In addition to the previous answer:

You could use (in web.xml)

```<code><error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>viewexpired.jsp</location>
</error-page>
</code>```

Or Context Parameters instead of Session Attributes. See:

http://tomcat.apache.org/tomcat-5.5-doc/config/context.html

http://safebox.guisho.com/jsf-how-to-get-webxml-parameters

Or use (in faces-context.xml)

```<code><managed-bean-scope>application</managed-bean-scope>
</code>```

for your bean, so it will stay independent from the session.

Body:
In addition to the previous answer:

You could use (in web.xml)

<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>viewexpired.jsp</location>
</error-page>

Or Context Parameters instead of Session Attributes. See:

http://tomcat.apache.org/tomcat-5.5-doc/config/context.html

http://safebox.guisho.com/jsf-how-to-get-webxml-parameters

Or use (in faces-context.xml)

<managed-bean-scope>application</managed-bean-scope>

for your bean, so it will stay independent from the session.


问:
How to get label in cells in table to go on to next line instead of getting cut off screen? (xcode 8)
So basically I am loading text from an array into cells in a table view, but instead of going on to the next line like I want, the inputted text labels get cut off the screen in the single cell. I looked online and it said to set numberOfLines to 0 and lineBreakMode to NSLineBreakingByWordWrapping, but it isn't working. What am I doing wrong? Thanks!</p>

```<code>override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "homeSeries", for: indexPath)

    // Configure the cell...

    cell.textLabel?.text = dataArrayRelease[indexPath.row] + " " + dataArraySeries[indexPath.row] + " by " + dataArrayGroup[indexPath.row]
    cell.textLabel?.numberOfLines = 0
    cell.textLabel.lineBreakMode = NSLineBreakByWordWrapping

    return cell
}
</code>```

答:
Your cellForRowAt method code is proper. you need to do some stuff related row height.
Set up your tableview row height as UITableViewAutomaticDimension in viewDidLoad() method.

```<code>yourTableview.rowHeight = UITableViewAutomaticDimension
yourTableview.estimatedRowHeight = 44
</code>```

OR

you can add Bellow UITableViewDelegate method in your Controller

```<code> func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
        return 44
    }

    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return UITableViewAutomaticDimension
    }
</code>```

Body:
So basically I am loading text from an array into cells in a table view, but instead of going on to the next line like I want, the inputted text labels get cut off the screen in the single cell. I looked online and it said to set numberOfLines to 0 and lineBreakMode to NSLineBreakingByWordWrapping, but it isn't working. What am I doing wrong? Thanks!

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "homeSeries", for: indexPath)

    // Configure the cell...

    cell.textLabel?.text = dataArrayRelease[indexPath.row] + " " + dataArraySeries[indexPath.row] + " by " + dataArrayGroup[indexPath.row]
    cell.textLabel?.numberOfLines = 0
    cell.textLabel.lineBreakMode = NSLineBreakByWordWrapping

    return cell
}

Body:
Your cellForRowAt method code is proper. you need to do some stuff related row height.
Set up your tableview row height as UITableViewAutomaticDimension in viewDidLoad() method.

yourTableview.rowHeight = UITableViewAutomaticDimension
yourTableview.estimatedRowHeight = 44

OR

you can add Bellow UITableViewDelegate method in your Controller

 func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
        return 44
    }

    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return UITableViewAutomaticDimension
    }


问:
how can I validate whether values entered in a new form is reflected correctly in edit form
I am trying to automate a website which is mainly dealing with Forms. I have entered values in new form and I need to validate whether it is reflected back correctly in edit form.
In New form I have tried like :

```<code> WebElement FN = driver.findElement(By.id("ctl00_ctl41_g_1fc852c8_32cb_4220_80ee_2af21b671f9e_ff21_ctl00_ctl00_TextField"));
 FN.click();
 FN.sendKeys("abc");
</code>```

In the edit form code:

```<code> if(FN.getAttribute("value").equals("abc"))
    System.out.println("First Name is matching with new form");
 else
    System.out.println("First Name is not matching with new form");
</code>```

and I am getting error like

```<code> Exception in thread "main" org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document(Session info: chrome=57.0.2987.110)
</code>```

Thanks in advance .

答:
Possibly, you are having exception at FN.sendKeys("abc");. When you click on the element before going to edit mode, the element is also changing. That's why you are having that exception.

I suggest, after clicking on the FN element have locator for textfield afresh and use sendkeys() method on it.

To know about this type of exception this might help you:

http://darrellgrainger.blogspot.com/2012/06/staleelementexception.html

Body:
I am trying to automate a website which is mainly dealing with Forms. I have entered values in new form and I need to validate whether it is reflected back correctly in edit form.
In New form I have tried like :

 WebElement FN = driver.findElement(By.id("ctl00_ctl41_g_1fc852c8_32cb_4220_80ee_2af21b671f9e_ff21_ctl00_ctl00_TextField"));
 FN.click();
 FN.sendKeys("abc");

In the edit form code:

 if(FN.getAttribute("value").equals("abc"))
    System.out.println("First Name is matching with new form");
 else
    System.out.println("First Name is not matching with new form");

and I am getting error like

 Exception in thread "main" org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document(Session info: chrome=57.0.2987.110)

Thanks in advance .


问:
Properly formatted multiplication table
How would I make a multiplication table that's organized into a neat table? My current code is:

```<code>n=int(input('Please enter a positive integer between 1 and 15: '))
for row in range(1,n+1):
    for col in range(1,n+1):
        print(row*col)
    print()
</code>```

This correctly multiplies everything but has it in list form. I know I need to nest it and space properly, but I'm not sure where that goes?

答:
Creating Arithmetic table is much simpler but i thought i should post my answer despite the fact there are so many answers to this question because no one talked about limit of table.

Taking input from user as an integer

```<code>num = int(raw_input("Enter your number"))
</code>```

Set limit of table, to which extent we wish to calculate table for desired number

```<code>lim = int(raw_input("Enter limit of table"))
</code>```

Iterative Calculation starting from index 1

In this, i've make use of slicing with format to adjust whitespace between number i.e., {:2} for two space adjust.

```<code>for b in range(1, lim+1):
    print'{:2} * {:2} = {:2}'.format(a, b, a*b)
</code>```

Final CODE:

```<code>num = int(raw_input("Enter your number"))
lim = int(raw_input("Enter limit of table"))
for b in range(1, lim+1):
    print'{:2} * {:2} = {:2}'.format(a, b, a*b)
</code>```

OUTPUT:

```<code>Enter your number 2
Enter limit of table 20
 2 *  1 =  2
 2 *  2 =  4
 2 *  3 =  6
 2 *  4 =  8
 2 *  5 = 10
 2 *  6 = 12
 2 *  7 = 14
 2 *  8 = 16
 2 *  9 = 18
 2 * 10 = 20
 2 * 11 = 22
 2 * 12 = 24
 2 * 13 = 26
 2 * 14 = 28
 2 * 15 = 30
 2 * 16 = 32
 2 * 17 = 34
 2 * 18 = 36
 2 * 19 = 38
 2 * 20 = 40
</code>```

Title: Properly formatted multiplication table

Body:
How would I make a multiplication table that's organized into a neat table? My current code is:

n=int(input('Please enter a positive integer between 1 and 15: '))
for row in range(1,n+1):
    for col in range(1,n+1):
        print(row*col)
    print()

This correctly multiplies everything but has it in list form. I know I need to nest it and space properly, but I'm not sure where that goes?

Body:
Creating Arithmetic table is much simpler but i thought i should post my answer despite the fact there are so many answers to this question because no one talked about limit of table.

Taking input from user as an integer

num = int(raw_input("Enter your number"))

Set limit of table, to which extent we wish to calculate table for desired number

lim = int(raw_input("Enter limit of table"))

Iterative Calculation starting from index 1

In this, i've make use of slicing with format to adjust whitespace between number i.e., {:2} for two space adjust.

for b in range(1, lim+1):
    print'{:2} * {:2} = {:2}'.format(a, b, a*b)

Final CODE:

num = int(raw_input("Enter your number"))
lim = int(raw_input("Enter limit of table"))
for b in range(1, lim+1):
    print'{:2} * {:2} = {:2}'.format(a, b, a*b)

OUTPUT:

Enter your number 2
Enter limit of table 20
 2 *  1 =  2
 2 *  2 =  4
 2 *  3 =  6
 2 *  4 =  8
 2 *  5 = 10
 2 *  6 = 12
 2 *  7 = 14
 2 *  8 = 16
 2 *  9 = 18
 2 * 10 = 20
 2 * 11 = 22
 2 * 12 = 24
 2 * 13 = 26
 2 * 14 = 28
 2 * 15 = 30
 2 * 16 = 32
 2 * 17 = 34
 2 * 18 = 36
 2 * 19 = 38
 2 * 20 = 40


问:
How to detect user has clicked Don't Allow access to camera
I am using a UIImagePicker to present the users with camera to take photos which will be used in the app.

My problem is that on the first time a user opens the image picker they are presented with a prompt saying: '"my App" Would like to Access your Camera' with two options, Don't allow and OK.

My requirement is that when the user clicks Don't Allow, the Image picker gets dismissed leaving a black view. Is there a way to detect that the user has chosen Don't allow?

Here is my code to present UIImagePicker:

```<code>var PhotoPicker:UIImagePickerController = UIImagePickerController()
PhotoPicker.delegate = self
PhotoPicker.sourceType = .Camera
PhotoPicker.cameraFlashMode = .Off
PhotoPicker.showsCameraControls = false
PhotoPicker.cameraDevice = .Rear
self.presentViewController(PhotoPicker, animated: false, completion: nil)
</code>```

答:
In iOS 10, use:</p>

```<code>import Photos

let authStatus = PHPhotoLibrary.authorizationStatus()
if authStatus == .notDetermined || authStatus == .denied {
    PHPhotoLibrary.requestAuthorization({ (status) in
        if status == PHAuthorizationStatus.authorized {

        } else {
            imagePickerController.dismissViewControllerAnimated(true, completion: nil)
        }
    })
}
</code>```

Body:
I am using a UIImagePicker to present the users with camera to take photos which will be used in the app.

My problem is that on the first time a user opens the image picker they are presented with a prompt saying: '"my App" Would like to Access your Camera' with two options, Don't allow and OK.

My requirement is that when the user clicks Don't Allow, the Image picker gets dismissed leaving a black view. Is there a way to detect that the user has chosen Don't allow?

Here is my code to present UIImagePicker:

var PhotoPicker:UIImagePickerController = UIImagePickerController()
PhotoPicker.delegate = self
PhotoPicker.sourceType = .Camera
PhotoPicker.cameraFlashMode = .Off
PhotoPicker.showsCameraControls = false
PhotoPicker.cameraDevice = .Rear
self.presentViewController(PhotoPicker, animated: false, completion: nil)

Body:
In iOS 10, use:

import Photos

let authStatus = PHPhotoLibrary.authorizationStatus()
if authStatus == .notDetermined || authStatus == .denied {
    PHPhotoLibrary.requestAuthorization({ (status) in
        if status == PHAuthorizationStatus.authorized {

        } else {
            imagePickerController.dismissViewControllerAnimated(true, completion: nil)
        }
    })
}


问:
How many times does curl_multi_exec have to be called?
I'm using curl_multi with multi to upload files to different servers. Each server has multiple files that need uploading, so I have a curl_multi request for each server. When I execute the curl_multi handles, I just execute all the curl_multi handles in the same loop, like so:

```<code><?php
do {

 $continue_running=false;

 foreach($handles as $host => $handle) {

  if(!is_resource($handle[0])) {
   die("\nHandle is not a resource!\n");
  }

  if($running_{$host}) {
   if(curl_multi_exec($handles[$host][0], $running_{$host}) != CURLM_OK) {
    die("\ncurl_multi_exec failed!\n");
   }
   $continue_running=true;
  }

  if(!$running_{$host} && !$done_{$host}) {
   echo "$host finished in ".(microtime(1)-$start)." seconds\n";
   $done_{$host}=true;
  }
 }

} while ($continue_running);
?>
</code>```

What I'm wondering is, how many times does curl_multi_exec actually have to be called in a curl request? Does it need to be called for each little bit of data transfered? Its using a lot of cpu and I'm thinking that its because its "busy looping" too much. So can I add sleep(5); at the end of each loop to make it use less cpu cycles, or will this slow down the requests majorly?

I would use curl_multi_select, but I cant because theres multiple curl_multi_execs being processed.

答:
curl_multi_exec() reads and writes data to the socket. It stops when it cannot write or read.
So the number of needed calls depends on the amount of data to be transfered and the speed of the network. curl_multi_select() waits till a socket becomes readable or writable.

You should use the curl_multi_select() and have all hosts inside one multi-handle.
Check curl_getinfo() or curl_multi_info_read() if you need to know the duration of the individual requests.

Body:
I'm using curl_multi with multi to upload files to different servers. Each server has multiple files that need uploading, so I have a curl_multi request for each server. When I execute the curl_multi handles, I just execute all the curl_multi handles in the same loop, like so:

<?php
do {

 $continue_running=false;

 foreach($handles as $host => $handle) {

  if(!is_resource($handle[0])) {
   die("\nHandle is not a resource!\n");
  }

  if($running_{$host}) {
   if(curl_multi_exec($handles[$host][0], $running_{$host}) != CURLM_OK) {
    die("\ncurl_multi_exec failed!\n");
   }
   $continue_running=true;
  }

  if(!$running_{$host} && !$done_{$host}) {
   echo "$host finished in ".(microtime(1)-$start)." seconds\n";
   $done_{$host}=true;
  }
 }

} while ($continue_running);
?>

What I'm wondering is, how many times does curl_multi_exec actually have to be called in a curl request? Does it need to be called for each little bit of data transfered? Its using a lot of cpu and I'm thinking that its because its "busy looping" too much. So can I add sleep(5); at the end of each loop to make it use less cpu cycles, or will this slow down the requests majorly?

I would use curl_multi_select, but I cant because theres multiple curl_multi_execs being processed.


问:
Jsonified Response from server
I was trying to make a get request and obtain a jsonified response. But when i try this the request never gets completed. The browsers keeps on loading status only</p>

```<code>@app.route('/user/json')
def json():
    users = User.query.all()
    list_serialized = [user.serialize() for user in users]
    return jsonify(list_serialized)

@app.route('/recieve')
def recieve():
    headers = {'content-type': 'application/json'}
    users = requests.get('http://127.0.0.1:5000/user/json', headers=headers).json()
    print users
    return users
</code>```

答: use app.run(threaded=True) for running app in main function.

Title: Jsonified Response from server

Body:
I was trying to make a get request and obtain a jsonified response. But when i try this the request never gets completed. The browsers keeps on loading status only

@app.route('/user/json')
def json():
    users = User.query.all()
    list_serialized = [user.serialize() for user in users]
    return jsonify(list_serialized)

@app.route('/recieve')
def recieve():
    headers = {'content-type': 'application/json'}
    users = requests.get('http://127.0.0.1:5000/user/json', headers=headers).json()
    print users
    return users


问:
Unable to acquire lock on the view to recompile it
Created a view VW on base tables A and B. There is an ETL process which loads data into T_A and T_B. After data loading is complete, the job triggers rename procedure. This procedure renames T_A as A and table A is renamed as T_A. Similarly T_B table is renamed as B and table B is renamed to T_B.

When this renaming happens the view is becoming invalid and to make it valid have to compile it again.

To fix this, added view compilation statement at the end in rename procedure. It works fine but the problem is let's say user A is accessing the view data and at the same time my rename procedure is triggered. Now the rename procedure is not able to compile the view as long as user A is accessing the view.

Please share your thoughts on how to overcome this problem.

Dex.

答:
While dependant view is invalidated when a change is made to the underlying table, Oracle will automatically recompile the view when it is accessed.

So in your example, VW is INVALID when Table A is dropped,
it is still INVALID when T_A is renamed to A, but as soon as someone queries the view, it is automatically recompiled, the query works correctly, and the view becomes VALID.

So there is no need to explicitly recompile your views in your script.


问:
Show video on two screens with VLC
I want to set up a video client based on Ubuntu 16.04/Gnome/VLC 2.2.2. It should play a single video in fullscreen directly after boot on two screens. The video is controlled via VLCs web interface.

Everything is running fine on a single screen. However, with multiple screens I run into the problem that fullscreen mode only gets displayed on one of them.

There are several ways I tried to fix it:

1) Use normal fullscreen mode.
Only shows the video on one screen

2) Use Wall Video filter as described here: http://windows7themes.net/en-us/stretch-videomovie-across-2-monitors/
This has multiple problems. More often than not, it does not show the video correctly. There is an output error in one of the windows. I also don't know how to automatically position these windows and get them into (pseudo) fullscreen mode. Reading some threads about this feature makes me think it is currently broken.

3) Resize the window to fill the whole screen (manually)
This works in general. However, it still shows a window around the video and the desktop elements of Gnome. Is it possible to fix this and to size/position the video automatically on startup?

How can I get this to work?

答:
After trying several ways, this is the solution I ended up with:

Split the video in two parts

Start two instances of vlc

Make each fullscreen on one of the screens

Give each vlc instance a different http port for controlling it

Copy the web interface of vlc into my own website (some javascript, images, css and html files)

Handle calls to "/requests/status.xml" on my webserver. This is what the vlc webinterface calls for getting the current status of the player and sending commands.

Forward the plain status.xml requests to one of the instances, forward everything with a command to both instances of vlc.

This is for starting two vlc instances in fullscreen:

```<code>vlc --http-port 8080 --http-password vlc123 --loop --video-x=0 --video-y==100 --fullscreen --qt-fullscreen-screennumber=1 '/path/to/my/video1' &

vlc --http-port 8090 --http-password vlc123 --loop --video-x=2000 --video-y==100 --fullscreen --qt-fullscreen-screennumber=2 '/path/to/my/video2' &
</code>```

And here the CherryPy proxy:

```<code>class VlcProxy(object):
    @cherrypy.expose
    def index(self, **args):
        command_parameter = ""
        if args.has_key("command"):
            command_parameter = "?command=" + args["command"]
            if args.has_key("val"):
                command_parameter += "&val=" + args["val"]
            # if there is a command, send it to both running vlc instances
            url = videoclient_baseurl + ":8090/requests/status.xml" + command_parameter
            thread.start_new_thread(self.request, (url, "", "vlc123"))

        # if it is only a status, then one response is enough
        response = self.request(videoclient_baseurl + ":8080/requests/status.xml" + command_parameter, "", "vlc123")
        return response
</code>```

It is not the clean & easy solution I expected, but it works fine so far. The downside is that you need to proxy the vlc calls and the videos could (in theory) run out of sync. However, in my scenario this never happened.

The good part is that the vlc webinterface is now part of my application. I don't need to update vlc if I just want to reposition a button.

Title: Show video on two screens with VLC

Body:
After trying several ways, this is the solution I ended up with:

Split the video in two parts

Start two instances of vlc

Make each fullscreen on one of the screens

Give each vlc instance a different http port for controlling it

Copy the web interface of vlc into my own website (some javascript, images, css and html files)

Handle calls to "/requests/status.xml" on my webserver. This is what the vlc webinterface calls for getting the current status of the player and sending commands.

Forward the plain status.xml requests to one of the instances, forward everything with a command to both instances of vlc.

This is for starting two vlc instances in fullscreen:

vlc --http-port 8080 --http-password vlc123 --loop --video-x=0 --video-y==100 --fullscreen --qt-fullscreen-screennumber=1 '/path/to/my/video1' &

vlc --http-port 8090 --http-password vlc123 --loop --video-x=2000 --video-y==100 --fullscreen --qt-fullscreen-screennumber=2 '/path/to/my/video2' &

And here the CherryPy proxy:

class VlcProxy(object):
    @cherrypy.expose
    def index(self, **args):
        command_parameter = ""
        if args.has_key("command"):
            command_parameter = "?command=" + args["command"]
            if args.has_key("val"):
                command_parameter += "&val=" + args["val"]
            # if there is a command, send it to both running vlc instances
            url = videoclient_baseurl + ":8090/requests/status.xml" + command_parameter
            thread.start_new_thread(self.request, (url, "", "vlc123"))

        # if it is only a status, then one response is enough
        response = self.request(videoclient_baseurl + ":8080/requests/status.xml" + command_parameter, "", "vlc123")
        return response

It is not the clean & easy solution I expected, but it works fine so far. The downside is that you need to proxy the vlc calls and the videos could (in theory) run out of sync. However, in my scenario this never happened.

The good part is that the vlc webinterface is now part of my application. I don't need to update vlc if I just want to reposition a button.


问:
How can I create a table as displayed in the below screen shot
Please help me on how can I create a table as mentioned in the below screen shot

https://i.stack.imgur.com/zgf2Z.png

Thank you in advance!!

    Duration
    Topic

    10 min
     Recap of FY17 CSP Incentives

     20 min
     Partner Incentive Experience Onboarding

     15 min
     Updating Banking Details/Partner Requirements

     10 min
     Understanding MPN IDs

     5 min
     Q&A and Closing Session Survey

```

答:
You can add the following to css:

```<code>tr {
  border: 1px solid black;
}

th {
  border: 0;
  width: 100px;
  text-align: left;
}
</code>```

Here is the snippet:

tr {
  border: 1px solid black;
}

th {
  border: 0;
  width: 100px;
  text-align: left;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><table border=1px solid; style="border-collapse:collapse;" RULES=COLS>
  <tr>
    <th>Duration </th>
    <th>Topic</th>
  </tr>
  <tr>
    <td>10 min </td>
    <td> Recap of FY17 CSP Incentives </td>
  </tr>
  <tr>
    <td> 20 min </td>
    <td> Partner Incentive Experience Onboarding </td>
  </tr>
  <tr>
    <td> 15 min </td>
    <td> Updating Banking Details/Partner Requirements </td>
  </tr>
  <tr>
    <td> 10 min </td>
    <td> Understanding MPN IDs </td>
  </tr>
  <tr>
    <td> 5 min </td>
    <td> Q&A and Closing Session Survey </td>
  </tr>
</table></code>```

Body:
You can add the following to css:

tr {
  border: 1px solid black;
}

th {
  border: 0;
  width: 100px;
  text-align: left;
}

Here is the snippet:

tr {
  border: 1px solid black;
}

th {
  border: 0;
  width: 100px;
  text-align: left;
}

<table border=1px solid; style="border-collapse:collapse;" RULES=COLS>
  <tr>
    <th>Duration </th>
    <th>Topic</th>
  </tr>
  <tr>
    <td>10 min </td>
    <td> Recap of FY17 CSP Incentives </td>
  </tr>
  <tr>
    <td> 20 min </td>
    <td> Partner Incentive Experience Onboarding </td>
  </tr>
  <tr>
    <td> 15 min </td>
    <td> Updating Banking Details/Partner Requirements </td>
  </tr>
  <tr>
    <td> 10 min </td>
    <td> Understanding MPN IDs </td>
  </tr>
  <tr>
    <td> 5 min </td>
    <td> Q&A and Closing Session Survey </td>
  </tr>
</table>


问:
counter is not incremented in setTimeout in node.js?
In the below program in Node.js loop is executed many times but why control is not coming out from loop. I did not forgot to do i++ in for, I incremented the value of i in setTimeout.</p>

```<code>function abc () {
  for(var i=0;i<5;) {
    console.log("executes loop");
    setTimeout(function(){
      console.log(i++);
    },0)
  }
}

abc();
</code>```

答:
You forgot to put i++ in loop.

Try this

```
</div>
</div>
</p>

<p>Due to timeout it is going out of the loop, so that when it will return on that value of <code>i</code> will be 5, so it will print after 5.</p>

<p><strong>Edited</strong></p>

<p>If you want to increment value inside <code>timeout</code></p>

<p>Try this</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><html>
<body>

 <script>
  window.onload = function function_name(argument) {
   // body...

  var j = 0;

  function abc () {
   for(var i=0;i<5;i++) {
    console.log("executes loop");
    setTimeout(function(){
     i++;
     j = i-6;
     console.log(j);
    },0)
   }
  }

  abc();
  }

 </script>
</body>
</html></code>```

Body:
In the below program in Node.js loop is executed many times but why control is not coming out from loop. I did not forgot to do i++ in for, I incremented the value of i in setTimeout.

function abc () {
  for(var i=0;i<5;) {
    console.log("executes loop");
    setTimeout(function(){
      console.log(i++);
    },0)
  }
}

abc();

Body:
You forgot to put i++ in loop.

Try this

<html>
<body>

 <script>
  window.onload = function function_name(argument) {
   // body...

  function abc () {
   for(var i=0;i<5;i++) {
    console.log("executes loop");
    setTimeout(function(){
     console.log(i++);
    },0)
   }
  }

  abc();
  }

 </script>
</body>
</html>

Due to timeout it is going out of the loop, so that when it will return on that value of i will be 5, so it will print after 5.

Edited

If you want to increment value inside timeout

Try this

<html>
<body>

 <script>
  window.onload = function function_name(argument) {
   // body...

  var j = 0;

  function abc () {
   for(var i=0;i<5;i++) {
    console.log("executes loop");
    setTimeout(function(){
     i++;
     j = i-6;
     console.log(j);
    },0)
   }
  }

  abc();
  }

 </script>
</body>
</html>


问:
How can I replace %20 with - from url using php?
code:

```<code> <?php
    $query = "select * from latest_news limit 0,10";
    $fet = mysqli_query($link,$query);
    while ($fetch = mysqli_fetch_array($fet))
    {
 ?>
 <p id="news-h3"><?php echo $fetch['news_title']; ?>...<a href="news-details.php?news_tags=<?php echo $fetch['news_tags']; ?>" style="color:red;">[Read More]</a></p>
 <?php
     }
 ?>
</code>```

When I click on link i.e.

```<code><a href="news-details.php?news_tags=<?php echo $fetch['news_tags']; ?>" style="color:red;">[Read More]</a>
</code>```

It show

```<code>best%20engineering%20college%20in%20India
</code>```

Here, I want to replace %20 with (-) from url and get result like

```<code>best-engineering-college-in-India
</code>```

how can I fix this problem please help.

Thank you

答:
Basically you want to decode the URL. You can decode it using </p>

```<code>echo utf8_decode(urldecode($input));
</code>```

Body:
code:

 <?php
    $query = "select * from latest_news limit 0,10";
    $fet = mysqli_query($link,$query);
    while ($fetch = mysqli_fetch_array($fet))
    {
 ?>

<?php echo $fetch['news_title']; ?>...<a href="news-details.php?news_tags=<?php echo $fetch['news_tags']; ?>" style="color:red;">[Read More]

 <?php
     }
 ?>

When I click on link i.e.

<a href="news-details.php?news_tags=<?php echo $fetch['news_tags']; ?>" style="color:red;">[Read More]

It show

best%20engineering%20college%20in%20India

Here, I want to replace %20 with (-) from url and get result like

best-engineering-college-in-India

how can I fix this problem please help.

Thank you

Body:
Basically you want to decode the URL. You can decode it using

echo utf8_decode(urldecode($input));


问:
tableviewcontroller not working when called from other viewcontroller
I have two tableViewControllers created in storyboard:
categories and stores.
When I select a category, it's supposed to show all stores that are in that category.
(I'm getting stores data from server, but I set a fixed category in the url so it should fetch the same two stores no matter what.)

The weird thing is that when I choose a category, storesController shows up empty,
but if I set it as initial controller, it works.

StoreTableViewController_as_initial.png

StoreTableViewController_from_categories.png

this is how I setup the cells in storeController.

```<code>   - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
StoresCell *cell = [tableView dequeueReusableCellWithIdentifier:@"storetile"];
if(cell == nil){
    cell = [[StoresCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"storetile"];
}

cell.storelabel.text = [[_results objectAtIndex:[indexPath row]]objectForKey:@"name"];
[cell.storelabel sizeToFit];
cell.subtitleOneLabel.text=[[_results objectAtIndex:[indexPath row]]objectForKey:@"neighborhood"];
cell.subtitleTwoLabel.text = [[_results objectAtIndex:[indexPath row]]objectForKey:@"city"];
NSString *distance = [NSString stringWithFormat:@"~%@ km",[[_results objectAtIndex:[indexPath row]]objectForKey:@"distance"]];
cell.distanceLabel.text = distance;
NSString *imgPath = [[_results objectAtIndex:[indexPath row]]objectForKey:@"imgUrl"];
UIImage *thumb = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://andrafterdevelopment.com.br/apps/buscaabc/img/%@",imgPath]]]];

[cell.thumbImage setImage:thumb];
return cell;
}
</code>```

I break at the return, the method is always called but when it's from categoriesController all labels in my cell are nil.

this is how I call storeController from categoriesController

```<code>-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:
    (NSIndexPath *)indexPath{

NSDictionary *item = [_results objectAtIndex:[indexPath row]];
BOOL hasSub = [[item objectForKey:@"hasSub"] boolValue];

    StoreTableViewController *storesTableViewController = [[StoreTableViewController alloc]init];

    //storesTableViewController.title = [item valueForKey:@"name"];
    //storesTableViewController.category = (int)[item valueForKey:@"id"];
    [storesTableViewController.tableView registerClass:[StoresCell class] forCellReuseIdentifier:@"storetile"];
    [self.navigationController pushViewController:storesTableViewController animated:YES];
}
</code>```

I'm guessing this has to do with custom cell or maybe I'm doing it wrong by calling it this way.

答:
If you use Storyboard, you should create your controller via Storyboard.
Set Storyboard ID in Identity inspector for your StoreTableViewController and change your method on:

```<code>-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:
    (NSIndexPath *)indexPath{

NSDictionary *item = [_results objectAtIndex:[indexPath row]];
BOOL hasSub = [[item objectForKey:@"hasSub"] boolValue];

    StoreTableViewController *storesTableViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"storyboard id"];
    storesTableViewController.title = [item valueForKey:@"name"];
    storesTableViewController.category = (int)[item valueForKey:@"id"];

    [self.navigationController pushViewController:storesTableViewController animated:YES];
}
</code>```

Or you can use segues and configure your StoreTableViewController in prepareForSegue method:

```<code>- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 if ([segue.identifier isEqualToString:@"StoreTableViewControllerSegureIdentifier"]) {
    StoreTableViewController *storesTableViewController = segue.destinationViewController;
    storesTableViewController.title = _selectedItem.title;
    storesTableViewController.category = _selectedItem.identifier;
  }
}
</code>```

Body:
I have two tableViewControllers created in storyboard:
categories and stores.
When I select a category, it's supposed to show all stores that are in that category.
(I'm getting stores data from server, but I set a fixed category in the url so it should fetch the same two stores no matter what.)

The weird thing is that when I choose a category, storesController shows up empty,
but if I set it as initial controller, it works.

StoreTableViewController_as_initial.png

StoreTableViewController_from_categories.png

this is how I setup the cells in storeController.

   - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
StoresCell *cell = [tableView dequeueReusableCellWithIdentifier:@"storetile"];
if(cell == nil){
    cell = [[StoresCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"storetile"];
}

cell.storelabel.text = [[_results objectAtIndex:[indexPath row]]objectForKey:@"name"];
[cell.storelabel sizeToFit];
cell.subtitleOneLabel.text=[[_results objectAtIndex:[indexPath row]]objectForKey:@"neighborhood"];
cell.subtitleTwoLabel.text = [[_results objectAtIndex:[indexPath row]]objectForKey:@"city"];
NSString *distance = [NSString stringWithFormat:@"~%@ km",[[_results objectAtIndex:[indexPath row]]objectForKey:@"distance"]];
cell.distanceLabel.text = distance;
NSString *imgPath = [[_results objectAtIndex:[indexPath row]]objectForKey:@"imgUrl"];
UIImage *thumb = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://andrafterdevelopment.com.br/apps/buscaabc/img/%@",imgPath]]]];

[cell.thumbImage setImage:thumb];
return cell;
}

I break at the return, the method is always called but when it's from categoriesController all labels in my cell are nil.

this is how I call storeController from categoriesController

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:
    (NSIndexPath *)indexPath{

NSDictionary *item = [_results objectAtIndex:[indexPath row]];
BOOL hasSub = [[item objectForKey:@"hasSub"] boolValue];

    StoreTableViewController *storesTableViewController = [[StoreTableViewController alloc]init];

    //storesTableViewController.title = [item valueForKey:@"name"];
    //storesTableViewController.category = (int)[item valueForKey:@"id"];
    [storesTableViewController.tableView registerClass:[StoresCell class] forCellReuseIdentifier:@"storetile"];
    [self.navigationController pushViewController:storesTableViewController animated:YES];
}

I'm guessing this has to do with custom cell or maybe I'm doing it wrong by calling it this way.

Body:
If you use Storyboard, you should create your controller via Storyboard.
Set Storyboard ID in Identity inspector for your StoreTableViewController and change your method on:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:
    (NSIndexPath *)indexPath{

NSDictionary *item = [_results objectAtIndex:[indexPath row]];
BOOL hasSub = [[item objectForKey:@"hasSub"] boolValue];

    StoreTableViewController *storesTableViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"storyboard id"];
    storesTableViewController.title = [item valueForKey:@"name"];
    storesTableViewController.category = (int)[item valueForKey:@"id"];

    [self.navigationController pushViewController:storesTableViewController animated:YES];
}

Or you can use segues and configure your StoreTableViewController in prepareForSegue method:

- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 if ([segue.identifier isEqualToString:@"StoreTableViewControllerSegureIdentifier"]) {
    StoreTableViewController *storesTableViewController = segue.destinationViewController;
    storesTableViewController.title = _selectedItem.title;
    storesTableViewController.category = _selectedItem.identifier;
  }
}


问:
UnknownHostException: email.us-west-1.amazonaws.com with Amazon SES
Writing a trivial Spring Boot app that uses Amazon Simple Email Service (SES). The sending fails with an UnknownHostException regarding the us-west-1 endpoint.

```<code>Caused by: java.net.UnknownHostException: email.us-west-1.amazonaws.com
at java.net.InetAddress.getAllByName0(InetAddress.java:1280)
at java.net.InetAddress.getAllByName(InetAddress.java:1192)
at java.net.InetAddress.getAllByName(InetAddress.java:1126)
at com.amazonaws.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:27)
at com.amazonaws.http.DelegatingDnsResolver.resolve(DelegatingDnsResolver.java:38)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:112)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:359)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.amazonaws.http.conn.ClientConnectionManagerFactory$Handler.invoke(ClientConnectionManagerFactory.java:76)
at com.amazonaws.http.conn.$Proxy49.connect(Unknown Source)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
at com.amazonaws.http.apache.client.impl.SdkHttpClient.execute(SdkHttpClient.java:72)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1181)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1030)
... 93 more
</code>```

Any ideas?

答: US-WEST-1 does not have an SES endpoint address, nor has it ever.</p>

Body:
Writing a trivial Spring Boot app that uses Amazon Simple Email Service (SES). The sending fails with an UnknownHostException regarding the us-west-1 endpoint.

Caused by: java.net.UnknownHostException: email.us-west-1.amazonaws.com
at java.net.InetAddress.getAllByName0(InetAddress.java:1280)
at java.net.InetAddress.getAllByName(InetAddress.java:1192)
at java.net.InetAddress.getAllByName(InetAddress.java:1126)
at com.amazonaws.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:27)
at com.amazonaws.http.DelegatingDnsResolver.resolve(DelegatingDnsResolver.java:38)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:112)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:359)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.amazonaws.http.conn.ClientConnectionManagerFactory$Handler.invoke(ClientConnectionManagerFactory.java:76)
at com.amazonaws.http.conn.$Proxy49.connect(Unknown Source)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
at com.amazonaws.http.apache.client.impl.SdkHttpClient.execute(SdkHttpClient.java:72)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1181)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1030)
... 93 more

Any ideas?


问:
How to keep merging data frames using a function in R?
I have six data frames ie df1,df2,df3,df4,df5 and df6. I want merge them using function in the following manner:

df1<-data.frame(c(1:1000))

df2<-data.frame(c(1:10000))

df3<-data.frame(c(1:50000))

df4<-data.frame(c(1:3000))

df5<-data.frame(c(1:70000))

df6<-data.frame(c(1:90000))

First the function will merge df1 with df2 and it will create a data frame with the merged values of df1 & df2, then it will do the same for df1 and df3 and df1 and df4, and so on. Once this process is over it repeats the same process for df2,df3,df4,df5,df6.  Please help.

答:
We can use Reduce with merge.  In the OP's post, by variable is not mentioned, so it is also showed in the code below

```<code>v1 <- paste0("df", 1:6)
res <- lapply(seq_along(v1), function(i) Reduce(function(...)
           merge(...), mget(v1[i:length(v1)], envir = .GlobalEnv)))
</code>```

Body:
We can use Reduce with merge.  In the OP's post, by variable is not mentioned, so it is also showed in the code below

v1 <- paste0("df", 1:6)
res <- lapply(seq_along(v1), function(i) Reduce(function(...)
           merge(...), mget(v1[i:length(v1)], envir = .GlobalEnv)))