问:
Unable to install an npm package
I tried many different ways to install this package:
npm install cloud-print
npm install https://github.com/postmen/node-cloud-print.git
and so on...

And every time i get the following output:

`npm WARN addRemoteGit Error: Command failed: git -c core.longpaths=true config --get remote.origin.url
npm WARN addRemoteGit
npm WARN addRemoteGit     at ChildProcess.exithandler (child_process.js:211:12)
npm WARN addRemoteGit     at emitTwo (events.js:106:13)
npm WARN addRemoteGit     at ChildProcess.emit (events.js:191:7)
npm WARN addRemoteGit     at maybeClose (internal/child_process.js:885:16)
npm WARN addRemoteGit     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
npm WARN addRemoteGit  git+ssh://git@github.com/postmen/google-api-nodejs-client.git resetting remote C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46 because of error: { Error: Command failed: git -c core.longpaths=true config --get remote.origin.url
npm WARN addRemoteGit
npm WARN addRemoteGit     at ChildProcess.exithandler (child_process.js:211:12)
npm WARN addRemoteGit     at emitTwo (events.js:106:13)
npm WARN addRemoteGit     at ChildProcess.emit (events.js:191:7)
npm WARN addRemoteGit     at maybeClose (internal/child_process.js:885:16)
npm WARN addRemoteGit     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
npm WARN addRemoteGit   killed: false,
npm WARN addRemoteGit   code: 1,
npm WARN addRemoteGit   signal: null,
npm WARN addRemoteGit   cmd: 'git -c core.longpaths=true config --get remote.origin.url' }
npm ERR! git clone --template=C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror ssh://git@github.com/postmen/google-api-nodejs-client.git C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46: Cloning into bare repository 'C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46'...
npm ERR! git clone --template=C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror ssh://git@github.com/postmen/google-api-nodejs-client.git C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46: Host key verification failed.
npm ERR! git clone --template=C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror ssh://git@github.com/postmen/google-api-nodejs-client.git C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46: fatal: Could not read from remote repository.
npm ERR! git clone --template=C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror ssh://git@github.com/postmen/google-api-nodejs-client.git C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46:
npm ERR! git clone --template=C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror ssh://git@github.com/postmen/google-api-nodejs-client.git C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46: Please make sure you have the correct access rights
npm ERR! git clone --template=C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror ssh://git@github.com/postmen/google-api-nodejs-client.git C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46: and the repository exists.
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "cloud-print"
npm ERR! node v7.4.0
npm ERR! npm  v4.0.5
npm ERR! code 128
npm ERR! Command failed: git -c core.longpaths=true clone --template=C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror ssh://git@github.com/postmen/google-api-nodejs-client.git C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46
npm ERR! Cloning into bare repository 'C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46'...
npm ERR! Host key verification failed.
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR!     D:\Tmunot\npm-debug.log````

I also tried to download the directory to node_modules and configure it manually in package.json, but i didn't have success doing that.

Any ideas?

答:
I think problem is in your npm version. The npm version is too new for this package. Package cloud-print is outdated. Nobody supports the package. Maybe be npm will support that type of packages in 5.1 version.

JFYI: npm i cloud-print result on different node+npm versions:

node v8.1.3 npm v5.0.3 errors

node v7.10.0 npm v4.2.0 work

node v6.11.0 npm v3.10.10 work

node v4.4.7 npm v2.15.8 work

Solution use Node.js v.6

Could you use Node.js v6? On this the latest support version you can work this package.

Title: Unable to install an npm package

Body:
I tried many different ways to install this package:
npm install cloud-print
npm install https://github.com/postmen/node-cloud-print.git
and so on...

And every time i get the following output:

`npm WARN addRemoteGit Error: Command failed: git -c core.longpaths=true config --get remote.origin.url
npm WARN addRemoteGit
npm WARN addRemoteGit     at ChildProcess.exithandler (child_process.js:211:12)
npm WARN addRemoteGit     at emitTwo (events.js:106:13)
npm WARN addRemoteGit     at ChildProcess.emit (events.js:191:7)
npm WARN addRemoteGit     at maybeClose (internal/child_process.js:885:16)
npm WARN addRemoteGit     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
npm WARN addRemoteGit  git+ssh://git@github.com/postmen/google-api-nodejs-client.git resetting remote C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46 because of error: { Error: Command failed: git -c core.longpaths=true config --get remote.origin.url
npm WARN addRemoteGit
npm WARN addRemoteGit     at ChildProcess.exithandler (child_process.js:211:12)
npm WARN addRemoteGit     at emitTwo (events.js:106:13)
npm WARN addRemoteGit     at ChildProcess.emit (events.js:191:7)
npm WARN addRemoteGit     at maybeClose (internal/child_process.js:885:16)
npm WARN addRemoteGit     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
npm WARN addRemoteGit   killed: false,
npm WARN addRemoteGit   code: 1,
npm WARN addRemoteGit   signal: null,
npm WARN addRemoteGit   cmd: 'git -c core.longpaths=true config --get remote.origin.url' }
npm ERR! git clone --template=C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror ssh://git@github.com/postmen/google-api-nodejs-client.git C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46: Cloning into bare repository 'C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46'...
npm ERR! git clone --template=C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror ssh://git@github.com/postmen/google-api-nodejs-client.git C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46: Host key verification failed.
npm ERR! git clone --template=C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror ssh://git@github.com/postmen/google-api-nodejs-client.git C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46: fatal: Could not read from remote repository.
npm ERR! git clone --template=C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror ssh://git@github.com/postmen/google-api-nodejs-client.git C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46:
npm ERR! git clone --template=C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror ssh://git@github.com/postmen/google-api-nodejs-client.git C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46: Please make sure you have the correct access rights
npm ERR! git clone --template=C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror ssh://git@github.com/postmen/google-api-nodejs-client.git C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46: and the repository exists.
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "cloud-print"
npm ERR! node v7.4.0
npm ERR! npm  v4.0.5
npm ERR! code 128
npm ERR! Command failed: git -c core.longpaths=true clone --template=C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror ssh://git@github.com/postmen/google-api-nodejs-client.git C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46
npm ERR! Cloning into bare repository 'C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46'...
npm ERR! Host key verification failed.
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR!     D:\Tmunot\npm-debug.log`

I also tried to download the directory to node_modules and configure it manually in package.json, but i didn't have success doing that.

Any ideas?


来源: stackexchange

问:
Angular 2 custom form validation working only after user clear the textbox value
I'm trying to validate my input box immediately after the input box gets blur. But some how the validation message only appears when i write something in textbox and than delete it.

Here's my HTML template;

<input type="text"
placeholder="First Name"
class="form-control"
name="firstName"
id="firstName"
[ngModel]="typeValidation.firstName"
#firstName="ngModel"
(blur)="firstNameBlur(firstName.value)"
autofocus
required>

     First Name is required.
```
</div>
</div>
</p>

<p>Here's my typescript;</p>

```firstNameBlur(value:string) {

    if (value == "" || value == undefined) {
        return false;
    }
    else {
        return true;
    }

}
```

Please help me out.
Thanks in advance!

答:
To make it working as you expected, you should use untouched instead of pristine, like this:

```<code><small [hidden]="firstName.valid || (firstName.untouched && !f2.submitted)"
       class="text-danger">
  First Name is required.
</small>
</code>```

or using *ngIf (IMHO, it's really better):

```<code><small *ngIf="firstName.invalid && (firstName.touched || f2.submitted)"
       class="text-danger">
  First Name is required.
</small>
</code>```

WORKING DEMO

Note that you don't need (blur).

ContentLicense: CC BY-SA 3.0

Body:
I'm trying to validate my input box immediately after the input box gets blur. But some how the validation message only appears when i write something in textbox and than delete it.

Here's my HTML template;

<input type="text"
placeholder="First Name"
class="form-control"
name="firstName"
id="firstName"
[ngModel]="typeValidation.firstName"
#firstName="ngModel"
(blur)="firstNameBlur(firstName.value)"
autofocus
required>

     First Name is required.

Here's my typescript;

firstNameBlur(value:string) {

    if (value == "" || value == undefined) {
        return false;
    }
    else {
        return true;
    }

}

Please help me out.
Thanks in advance!

Body:
To make it working as you expected, you should use untouched instead of pristine, like this:

<small [hidden]="firstName.valid || (firstName.untouched && !f2.submitted)"
       class="text-danger">
  First Name is required.
</small>

or using *ngIf (IMHO, it's really better):

<small *ngIf="firstName.invalid && (firstName.touched || f2.submitted)"
       class="text-danger">
  First Name is required.
</small>

WORKING DEMO

Note that you don't need (blur).


问:
Serialize into native memory buffer from C# using flatbuffers
Is it possible with flatbuffers in C# to serialize objects to native (unmanaged) memory buffer?
So I want to do these steps:

Allocate a native memory buffer from native memory

Create objects in C# and serialize them into the allocated buffer

Send this memory buffer to C++ for deserialization

I'm thinking either of some custom memory buffer allocator in C#, or of some way of transferring ownership of a memory buffer form C# to C++.

In general I want to avoid copying memory when sending data from C# to C++ and vice versa. I want this memory buffer to be shared between C# and C++.

How do I do that?

答:
Yes, if you use C++/CLI.  Basic data types such as bool, 32-bit int, short, etc are same.  For other types check it out msclr::interop::marshal_as<>.

Similar post: C++/CLI Converting from System::String^ to std::string


问:
Passing function object as a parameter to another function
I am trying to understand the flow of the following code snippet -

```<code>var inner = function (a){
    console.log("a is -- ", 9);
}

var outer = function(b){
    console.log("Executing outer()");
    b();
}

outer(inner(5));
</code>```

The output currently is -

```<code>a is --  9
Executing outer()
app.js:6 Uncaught TypeError: b is not a function
at outer (app.js:6)
at app.js:9
</code>```

I am expecting the following -

```<code>Executing outer()
a is --  9
</code>```

I understand that in the statement outer(inner(9)) : inner(9) is a function call that evaluates (runs the code contained within the inner() function), but i want the code inside the outer() function to evaluate the code within inner(). Basically, i want to pass 9 as a variable to outer() so that it can pass it to inner()

Please point me to any online resource that will help me understand this concept better. Also, please mark this question as duplicate if already answered. Thanks!

答:
Can return a function from inner and all the rest stays the same

var inner = function(a) {
  return function() {
    console.log("a is -- ", a);
  }
}

var outer = function(b) {
  console.log("Executing outer()");
  b();
}

outer(inner(5));```

Body:
I am trying to understand the flow of the following code snippet -

var inner = function (a){
    console.log("a is -- ", 9);
}

var outer = function(b){
    console.log("Executing outer()");
    b();
}

outer(inner(5));

The output currently is -

a is --  9
Executing outer()
app.js:6 Uncaught TypeError: b is not a function
at outer (app.js:6)
at app.js:9

I am expecting the following -

Executing outer()
a is --  9

I understand that in the statement outer(inner(9)) : inner(9) is a function call that evaluates (runs the code contained within the inner() function), but i want the code inside the outer() function to evaluate the code within inner(). Basically, i want to pass 9 as a variable to outer() so that it can pass it to inner()

Please point me to any online resource that will help me understand this concept better. Also, please mark this question as duplicate if already answered. Thanks!


问:
Wordpress have_posts() doesn't work in loop
I created a custom post type in my functions.php:

```<code>add_action( 'init', 'create_post_type' );
function create_post_type() {
    register_post_type(
       'specialities',
        array(
            'labels' => array(
                'name' => __( 'Besonderheiten' ),
                'singular_name' => __( 'Besonderheit' )
            ),
            'public' => true,
            'has_archive' => true,
            'supports' => array('title', 'editor', 'thumbnail')
        )
    );
}
</code>```

then i added some posts in the wp-admin section.

I queried all posts:

```<code>$args = query_posts( array(
        'post_type'  => 'specialities',
        'posts_per_page' => -1
    ));
$query = new WP_Query($args);
</code>```

To make sure that $query isn't empty i var_dumped the whole thing -> It isn't empty. The var_dump showed all my posts.

So i tried to loop this query:

```<code><?php if(!empty($query)){ ?>
    <div class="slideshow clearfix">
        <?php while ( $query->have_posts() ) : $query->the_post(); ?>
            <div class="specialities clearfix"><?php echo the_title(); ?></div>
        <?php endwhile; ?>
    </div>
<?php } ?>
</code>```

In the web inspector i can see the div (slideshow clearfix) but no child divs (specialities clearfix).. Why???

So in case here's the var_dump:

object(WP_Query)#6956 (48) { ["query"]=> array(5) { [0]=> object(WP_Post)#6961 (24) { ["ID"]=> int(59) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2017-07-07 21:03:19" ["post_date_gmt"]=> string(19) "2017-07-07 19:03:19" ["post_content"]=> string(591) "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." ["post_title"]=> string(8) "Beispiel" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(8) "beispiel" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2017-07-07 21:03:42" ["post_modified_gmt"]=> string(19) "2017-07-07 19:03:42" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(57) "" ["menu_order"]=> int(0) ["post_type"]=> string(12) "specialities" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } [1]=> object(WP_Post)#6923 (24) { ["ID"]=> int(57) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2017-07-07 21:01:06" ["post_date_gmt"]=> string(19) "2017-07-07 19:01:06" ["post_content"]=> string(591) "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." ["post_title"]=> string(8) "Spaetzle" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(8) "spaetzle" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2017-07-07 21:01:06" ["post_modified_gmt"]=> string(19) "2017-07-07 19:01:06" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(57) "" ["menu_order"]=> int(0) ["post_type"]=> string(12) "specialities" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } [2]=> object(WP_Post)#6960 (24) { ["ID"]=> int(55) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2017-07-07 21:00:11" ["post_date_gmt"]=> string(19) "2017-07-07 19:00:11" ["post_content"]=> string(591) "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." ["post_title"]=> string(14) "Pasta Pomodoro" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(14) "pasta-pomodoro" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2017-07-07 21:00:11" ["post_modified_gmt"]=> string(19) "2017-07-07 19:00:11" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(57) "" ["menu_order"]=> int(0) ["post_type"]=> string(12) "specialities" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } [3]=> object(WP_Post)#6998 (24) { ["ID"]=> int(53) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2017-07-07 20:57:49" ["post_date_gmt"]=> string(19) "2017-07-07 18:57:49" ["post_content"]=> string(591) "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." ["post_title"]=> string(24) "Pasta Tomaten Mozzarella" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(2) "53" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2017-07-07 20:59:08" ["post_modified_gmt"]=> string(19) "2017-07-07 18:59:08" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(57) "" ["menu_order"]=> int(0) ["post_type"]=> string(12) "specialities" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } [4]=> object(WP_Post)#6995 (24) { ["ID"]=> int(51) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2017-07-07 20:56:44" ["post_date_gmt"]=> string(19) "2017-07-07 18:56:44" ["post_content"]=> string(591) "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." ["post_title"]=> string(9) "Hamburger" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(9) "hamburger" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2017-07-07 20:56:44" ["post_modified_gmt"]=> string(19) "2017-07-07 18:56:44" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(57) "" ["menu_order"]=> int(0) ["post_type"]=> string(12) "specialities" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } } ["query_vars"]=> array(69) { [0]=> object(WP_Post)#6961 (24) { ["ID"]=> int(59) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2017-07-07 21:03:19" ["post_date_gmt"]=> string(19) "2017-07-07 19:03:19" ["post_content"]=> string(591) "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." ["post_title"]=> string(8) "Beispiel" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(8) "beispiel" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2017-07-07 21:03:42" ["post_modified_gmt"]=> string(19) "2017-07-07 19:03:42" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(57) "" ["menu_order"]=> int(0) ["post_type"]=> string(12) "specialities" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } [1]=> object(WP_Post)#6923 (24) { ["ID"]=> int(57) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2017-07-07 21:01:06" ["post_date_gmt"]=> string(19) "2017-07-07 19:01:06" ["post_content"]=> string(591) "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." ["post_title"]=> string(8) "Spaetzle" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(8) "spaetzle" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2017-07-07 21:01:06" ["post_modified_gmt"]=> string(19) "2017-07-07 19:01:06" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(57) "" ["menu_order"]=> int(0) ["post_type"]=> string(12) "specialities" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } [2]=> object(WP_Post)#6960 (24) { ["ID"]=> int(55) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2017-07-07 21:00:11" ["post_date_gmt"]=> string(19) "2017-07-07 19:00:11" ["post_content"]=> string(591) "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." ["post_title"]=> string(14) "Pasta Pomodoro" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(14) "pasta-pomodoro" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2017-07-07 21:00:11" ["post_modified_gmt"]=> string(19) "2017-07-07 19:00:11" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(57) "" ["menu_order"]=> int(0) ["post_type"]=> string(12) "specialities" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } [3]=> object(WP_Post)#6998 (24) { ["ID"]=> int(53) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2017-07-07 20:57:49" ["post_date_gmt"]=> string(19) "2017-07-07 18:57:49" ["post_content"]=> string(591) "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." ["post_title"]=> string(24) "Pasta Tomaten Mozzarella" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(2) "53" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2017-07-07 20:59:08" ["post_modified_gmt"]=> string(19) "2017-07-07 18:59:08" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(57) "" ["menu_order"]=> int(0) ["post_type"]=> string(12) "specialities" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } [4]=> object(WP_Post)#6995 (24) { ["ID"]=> int(51) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2017-07-07 20:56:44" ["post_date_gmt"]=> string(19) "2017-07-07 18:56:44" ["post_content"]=> string(591) "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." ["post_title"]=> string(9) "Hamburger" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(9) "hamburger" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2017-07-07 20:56:44" ["post_modified_gmt"]=> string(19) "2017-07-07 18:56:44" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(57) "" ["menu_order"]=> int(0) ["post_type"]=> string(12) "specialities" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } ["error"]=> string(0) "" ["m"]=> string(0) "" ["p"]=> int(0) ["post_parent"]=> string(0) "" ["subpost"]=> string(0) "" ["subpost_id"]=> string(0) "" ["attachment"]=> string(0) "" ["attachment_id"]=> int(0) ["name"]=> string(0) "" ["static"]=> string(0) "" ["pagename"]=> string(0) "" ["page_id"]=> int(0) ["second"]=> string(0) "" ["minute"]=> string(0) "" ["hour"]=> string(0) "" ["day"]=> int(0) ["monthnum"]=> int(0) ["year"]=> int(0) ["w"]=> int(0) ["category_name"]=> string(0) "" ["tag"]=> string(0) "" ["cat"]=> string(0) "" ["tag_id"]=> string(0) "" ["author"]=> string(0) "" ["author_name"]=> string(0) "" ["feed"]=> string(0) "" ["tb"]=> string(0) "" ["paged"]=> int(0) ["meta_key"]=> string(0) "" ["meta_value"]=> string(0) "" ["preview"]=> string(0) "" ["s"]=> string(0) "" ["sentence"]=> string(0) "" ["title"]=> string(0) "" ["fields"]=> string(0) "" ["menu_order"]=> string(0) "" ["embed"]=> string(0) "" ["category__in"]=> array(0) { } ["category__not_in"]=> array(0) { } ["category__and"]=> array(0) { } ["post__in"]=> array(0) { } ["post__not_in"]=> array(0) { } ["post_name__in"]=> array(0) { } ["tag__in"]=> array(0) { } ["tag__not_in"]=> array(0) { } ["tag__and"]=> array(0) { } ["tag_slug__in"]=> array(0) { } ["tag_slug__and"]=> array(0) { } ["post_parent__in"]=> array(0) { } ["post_parent__not_in"]=> array(0) { } ["author__in"]=> array(0) { } ["author__not_in"]=> array(0) { } ["ignore_sticky_posts"]=> bool(false) ["suppress_filters"]=> bool(false) ["cache_results"]=> bool(true) ["update_post_term_cache"]=> bool(true) ["lazy_load_term_meta"]=> bool(true) ["update_post_meta_cache"]=> bool(true) ["post_type"]=> string(0) "" ["posts_per_page"]=> int(10) ["nopaging"]=> bool(false) ["comments_per_page"]=> string(2) "50" ["no_found_rows"]=> bool(false) ["order"]=> string(4) "DESC" } ["tax_query"]=> object(WP_Tax_Query)#7005 (6) { ["queries"]=> array(0) { } ["relation"]=> string(3) "AND" ["table_aliases":protected]=> array(0) { } ["queried_terms"]=> array(0) { } ["primary_table"]=> string(8) "wp_posts" ["primary_id_column"]=> string(2) "ID" } ["meta_query"]=> object(WP_Meta_Query)#7004 (9) { ["queries"]=> array(0) { } ["relation"]=> NULL ["meta_table"]=> NULL ["meta_id_column"]=> NULL ["primary_table"]=> NULL ["primary_id_column"]=> NULL ["table_aliases":protected]=> array(0) { } ["clauses":protected]=> array(0) { } ["has_or_relation":protected]=> bool(false) } ["date_query"]=> bool(false) ["request"]=> string(259) "SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled' OR wp_posts.post_status = 'private') ORDER BY wp_posts.post_date DESC LIMIT 0, 10" ["posts"]=> array(0) { } ["post_count"]=> int(0) ["current_post"]=> int(-1) ["in_the_loop"]=> bool(false) ["comment_count"]=> int(0) ["current_comment"]=> int(-1) ["found_posts"]=> int(0) ["max_num_pages"]=> int(0) ["max_num_comment_pages"]=> int(0) ["is_single"]=> bool(false) ["is_preview"]=> bool(false) ["is_page"]=> bool(false) ["is_archive"]=> bool(false) ["is_date"]=> bool(false) ["is_year"]=> bool(false) ["is_month"]=> bool(false) ["is_day"]=> bool(false) ["is_time"]=> bool(false) ["is_author"]=> bool(false) ["is_category"]=> bool(false) ["is_tag"]=> bool(false) ["is_tax"]=> bool(false) ["is_search"]=> bool(false) ["is_feed"]=> bool(false) ["is_comment_feed"]=> bool(false) ["is_trackback"]=> bool(false) ["is_home"]=> bool(true) ["is_404"]=> bool(false) ["is_embed"]=> bool(false) ["is_paged"]=> bool(false) ["is_admin"]=> bool(false) ["is_attachment"]=> bool(false) ["is_singular"]=> bool(false) ["is_robots"]=> bool(false) ["is_posts_page"]=> bool(false) ["is_post_type_archive"]=> bool(false) ["query_vars_hash":"WP_Query":private]=> string(32) "efaea6907a432061160b874915d6ab95" ["query_vars_changed":"WP_Query":private]=> bool(false) ["thumbnails_cached"]=> bool(false) ["stopwords":"WP_Query":private]=> NULL ["compat_fields":"WP_Query":private]=> array(2) { [0]=> string(15) "query_vars_hash" [1]=> string(18) "query_vars_changed" } ["compat_methods":"WP_Query":private]=> array(2) { [0]=> string(16) "init_query_flags" [1]=> string(15) "parse_tax_query" } }

答:
query_posts() creates a global $wp_query. Your $query is a different WP_Query object. Also, the constructor argument seems wrong to me.

I think I understand you have a malformed $query object. The posts in the var_dump of $query are not the results of the query but the wrong arguments you passed in the constructor. You don't need query_posts() just feed the args directly into new WP_Query.

```<code>$args = array(
    'post_type'  => 'specialities',
    'posts_per_page' => -1
);
$query = new WP_Query($args);
</code>```

Body:
I created a custom post type in my functions.php:

add_action( 'init', 'create_post_type' );
function create_post_type() {
    register_post_type(
       'specialities',
        array(
            'labels' => array(
                'name' => __( 'Besonderheiten' ),
                'singular_name' => __( 'Besonderheit' )
            ),
            'public' => true,
            'has_archive' => true,
            'supports' => array('title', 'editor', 'thumbnail')
        )
    );
}

then i added some posts in the wp-admin section.

I queried all posts:

$args = query_posts( array(
        'post_type'  => 'specialities',
        'posts_per_page' => -1
    ));
$query = new WP_Query($args);

To make sure that $query isn't empty i var_dumped the whole thing -> It isn't empty. The var_dump showed all my posts.

So i tried to loop this query:

<?php if(!empty($query)){ ?>

        <?php while ( $query->have_posts() ) : $query->the_post(); ?>

<?php echo the_title(); ?>

        <?php endwhile; ?>

<?php } ?>

In the web inspector i can see the div (slideshow clearfix) but no child divs (specialities clearfix).. Why???

So in case here's the var_dump:

object(WP_Query)#6956 (48) { ["query"]=> array(5) { [0]=> object(WP_Post)#6961 (24) { ["ID"]=> int(59) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2017-07-07 21:03:19" ["post_date_gmt"]=> string(19) "2017-07-07 19:03:19" ["post_content"]=> string(591) "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." ["post_title"]=> string(8) "Beispiel" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(8) "beispiel" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2017-07-07 21:03:42" ["post_modified_gmt"]=> string(19) "2017-07-07 19:03:42" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(57) "" ["menu_order"]=> int(0) ["post_type"]=> string(12) "specialities" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } [1]=> object(WP_Post)#6923 (24) { ["ID"]=> int(57) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2017-07-07 21:01:06" ["post_date_gmt"]=> string(19) "2017-07-07 19:01:06" ["post_content"]=> string(591) "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." ["post_title"]=> string(8) "Spaetzle" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(8) "spaetzle" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2017-07-07 21:01:06" ["post_modified_gmt"]=> string(19) "2017-07-07 19:01:06" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(57) "" ["menu_order"]=> int(0) ["post_type"]=> string(12) "specialities" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } [2]=> object(WP_Post)#6960 (24) { ["ID"]=> int(55) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2017-07-07 21:00:11" ["post_date_gmt"]=> string(19) "2017-07-07 19:00:11" ["post_content"]=> string(591) "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." ["post_title"]=> string(14) "Pasta Pomodoro" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(14) "pasta-pomodoro" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2017-07-07 21:00:11" ["post_modified_gmt"]=> string(19) "2017-07-07 19:00:11" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(57) "" ["menu_order"]=> int(0) ["post_type"]=> string(12) "specialities" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } [3]=> object(WP_Post)#6998 (24) { ["ID"]=> int(53) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2017-07-07 20:57:49" ["post_date_gmt"]=> string(19) "2017-07-07 18:57:49" ["post_content"]=> string(591) "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." ["post_title"]=> string(24) "Pasta Tomaten Mozzarella" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(2) "53" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2017-07-07 20:59:08" ["post_modified_gmt"]=> string(19) "2017-07-07 18:59:08" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(57) "" ["menu_order"]=> int(0) ["post_type"]=> string(12) "specialities" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } [4]=> object(WP_Post)#6995 (24) { ["ID"]=> int(51) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2017-07-07 20:56:44" ["post_date_gmt"]=> string(19) "2017-07-07 18:56:44" ["post_content"]=> string(591) "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." ["post_title"]=> string(9) "Hamburger" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(9) "hamburger" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2017-07-07 20:56:44" ["post_modified_gmt"]=> string(19) "2017-07-07 18:56:44" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(57) "" ["menu_order"]=> int(0) ["post_type"]=> string(12) "specialities" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } } ["query_vars"]=> array(69) { [0]=> object(WP_Post)#6961 (24) { ["ID"]=> int(59) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2017-07-07 21:03:19" ["post_date_gmt"]=> string(19) "2017-07-07 19:03:19" ["post_content"]=> string(591) "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." ["post_title"]=> string(8) "Beispiel" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(8) "beispiel" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2017-07-07 21:03:42" ["post_modified_gmt"]=> string(19) "2017-07-07 19:03:42" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(57) "" ["menu_order"]=> int(0) ["post_type"]=> string(12) "specialities" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } [1]=> object(WP_Post)#6923 (24) { ["ID"]=> int(57) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2017-07-07 21:01:06" ["post_date_gmt"]=> string(19) "2017-07-07 19:01:06" ["post_content"]=> string(591) "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." ["post_title"]=> string(8) "Spaetzle" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(8) "spaetzle" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2017-07-07 21:01:06" ["post_modified_gmt"]=> string(19) "2017-07-07 19:01:06" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(57) "" ["menu_order"]=> int(0) ["post_type"]=> string(12) "specialities" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } [2]=> object(WP_Post)#6960 (24) { ["ID"]=> int(55) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2017-07-07 21:00:11" ["post_date_gmt"]=> string(19) "2017-07-07 19:00:11" ["post_content"]=> string(591) "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." ["post_title"]=> string(14) "Pasta Pomodoro" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(14) "pasta-pomodoro" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2017-07-07 21:00:11" ["post_modified_gmt"]=> string(19) "2017-07-07 19:00:11" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(57) "" ["menu_order"]=> int(0) ["post_type"]=> string(12) "specialities" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } [3]=> object(WP_Post)#6998 (24) { ["ID"]=> int(53) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2017-07-07 20:57:49" ["post_date_gmt"]=> string(19) "2017-07-07 18:57:49" ["post_content"]=> string(591) "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." ["post_title"]=> string(24) "Pasta Tomaten Mozzarella" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(2) "53" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2017-07-07 20:59:08" ["post_modified_gmt"]=> string(19) "2017-07-07 18:59:08" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(57) "" ["menu_order"]=> int(0) ["post_type"]=> string(12) "specialities" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } [4]=> object(WP_Post)#6995 (24) { ["ID"]=> int(51) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2017-07-07 20:56:44" ["post_date_gmt"]=> string(19) "2017-07-07 18:56:44" ["post_content"]=> string(591) "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." ["post_title"]=> string(9) "Hamburger" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(9) "hamburger" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2017-07-07 20:56:44" ["post_modified_gmt"]=> string(19) "2017-07-07 18:56:44" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(57) "" ["menu_order"]=> int(0) ["post_type"]=> string(12) "specialities" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } ["error"]=> string(0) "" ["m"]=> string(0) "" ["p"]=> int(0) ["post_parent"]=> string(0) "" ["subpost"]=> string(0) "" ["subpost_id"]=> string(0) "" ["attachment"]=> string(0) "" ["attachment_id"]=> int(0) ["name"]=> string(0) "" ["static"]=> string(0) "" ["pagename"]=> string(0) "" ["page_id"]=> int(0) ["second"]=> string(0) "" ["minute"]=> string(0) "" ["hour"]=> string(0) "" ["day"]=> int(0) ["monthnum"]=> int(0) ["year"]=> int(0) ["w"]=> int(0) ["category_name"]=> string(0) "" ["tag"]=> string(0) "" ["cat"]=> string(0) "" ["tag_id"]=> string(0) "" ["author"]=> string(0) "" ["author_name"]=> string(0) "" ["feed"]=> string(0) "" ["tb"]=> string(0) "" ["paged"]=> int(0) ["meta_key"]=> string(0) "" ["meta_value"]=> string(0) "" ["preview"]=> string(0) "" ["s"]=> string(0) "" ["sentence"]=> string(0) "" ["title"]=> string(0) "" ["fields"]=> string(0) "" ["menu_order"]=> string(0) "" ["embed"]=> string(0) "" ["category__in"]=> array(0) { } ["category__not_in"]=> array(0) { } ["category__and"]=> array(0) { } ["post__in"]=> array(0) { } ["post__not_in"]=> array(0) { } ["post_name__in"]=> array(0) { } ["tag__in"]=> array(0) { } ["tag__not_in"]=> array(0) { } ["tag__and"]=> array(0) { } ["tag_slug__in"]=> array(0) { } ["tag_slug__and"]=> array(0) { } ["post_parent__in"]=> array(0) { } ["post_parent__not_in"]=> array(0) { } ["author__in"]=> array(0) { } ["author__not_in"]=> array(0) { } ["ignore_sticky_posts"]=> bool(false) ["suppress_filters"]=> bool(false) ["cache_results"]=> bool(true) ["update_post_term_cache"]=> bool(true) ["lazy_load_term_meta"]=> bool(true) ["update_post_meta_cache"]=> bool(true) ["post_type"]=> string(0) "" ["posts_per_page"]=> int(10) ["nopaging"]=> bool(false) ["comments_per_page"]=> string(2) "50" ["no_found_rows"]=> bool(false) ["order"]=> string(4) "DESC" } ["tax_query"]=> object(WP_Tax_Query)#7005 (6) { ["queries"]=> array(0) { } ["relation"]=> string(3) "AND" ["table_aliases":protected]=> array(0) { } ["queried_terms"]=> array(0) { } ["primary_table"]=> string(8) "wp_posts" ["primary_id_column"]=> string(2) "ID" } ["meta_query"]=> object(WP_Meta_Query)#7004 (9) { ["queries"]=> array(0) { } ["relation"]=> NULL ["meta_table"]=> NULL ["meta_id_column"]=> NULL ["primary_table"]=> NULL ["primary_id_column"]=> NULL ["table_aliases":protected]=> array(0) { } ["clauses":protected]=> array(0) { } ["has_or_relation":protected]=> bool(false) } ["date_query"]=> bool(false) ["request"]=> string(259) "SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled' OR wp_posts.post_status = 'private') ORDER BY wp_posts.post_date DESC LIMIT 0, 10" ["posts"]=> array(0) { } ["post_count"]=> int(0) ["current_post"]=> int(-1) ["in_the_loop"]=> bool(false) ["comment_count"]=> int(0) ["current_comment"]=> int(-1) ["found_posts"]=> int(0) ["max_num_pages"]=> int(0) ["max_num_comment_pages"]=> int(0) ["is_single"]=> bool(false) ["is_preview"]=> bool(false) ["is_page"]=> bool(false) ["is_archive"]=> bool(false) ["is_date"]=> bool(false) ["is_year"]=> bool(false) ["is_month"]=> bool(false) ["is_day"]=> bool(false) ["is_time"]=> bool(false) ["is_author"]=> bool(false) ["is_category"]=> bool(false) ["is_tag"]=> bool(false) ["is_tax"]=> bool(false) ["is_search"]=> bool(false) ["is_feed"]=> bool(false) ["is_comment_feed"]=> bool(false) ["is_trackback"]=> bool(false) ["is_home"]=> bool(true) ["is_404"]=> bool(false) ["is_embed"]=> bool(false) ["is_paged"]=> bool(false) ["is_admin"]=> bool(false) ["is_attachment"]=> bool(false) ["is_singular"]=> bool(false) ["is_robots"]=> bool(false) ["is_posts_page"]=> bool(false) ["is_post_type_archive"]=> bool(false) ["query_vars_hash":"WP_Query":private]=> string(32) "efaea6907a432061160b874915d6ab95" ["query_vars_changed":"WP_Query":private]=> bool(false) ["thumbnails_cached"]=> bool(false) ["stopwords":"WP_Query":private]=> NULL ["compat_fields":"WP_Query":private]=> array(2) { [0]=> string(15) "query_vars_hash" [1]=> string(18) "query_vars_changed" } ["compat_methods":"WP_Query":private]=> array(2) { [0]=> string(16) "init_query_flags" [1]=> string(15) "parse_tax_query" } }

Body:
query_posts() creates a global $wp_query. Your $query is a different WP_Query object. Also, the constructor argument seems wrong to me.

I think I understand you have a malformed $query object. The posts in the var_dump of $query are not the results of the query but the wrong arguments you passed in the constructor. You don't need query_posts() just feed the args directly into new WP_Query.

$args = array(
    'post_type'  => 'specialities',
    'posts_per_page' => -1
);
$query = new WP_Query($args);


问:
Force Python2 with spark-submit
I am creating a Spark application with AWS EMR but spark-submit runs with Python 3 instead of Python 2.
But when I run pyspark instead, it is Python 2.

How can I force spark-submit to use Python 2?

I tried to do

```<code>export PYSPARK_PYTHON=/usr/bin/python2
</code>```

but it didn't work.

Thanks

答:
Have you tried to insert the

```<code>PYSPARK_PYTHON=/usr/bin/python2
</code>```

statement into the spark-env.sh file?

Title: Force Python2 with spark-submit

Body:
I am creating a Spark application with AWS EMR but spark-submit runs with Python 3 instead of Python 2.
But when I run pyspark instead, it is Python 2.

How can I force spark-submit to use Python 2?

I tried to do

export PYSPARK_PYTHON=/usr/bin/python2

but it didn't work.

Thanks

Body:
Have you tried to insert the

PYSPARK_PYTHON=/usr/bin/python2

statement into the spark-env.sh file?


问:
convert set to map of string with count
My original data is stream of string like

```<code>correctname
abc,def,ghi,jol
abc
def,ghi
zzzzzzzzzz
myname
pppppppppp
jkl
</code>```

Converting it set:

```<code>{correct}
{abc, def,ghi,jkl}
{abc}
{def,ghi}
{invalid}
{correct}
{invalid}
{jkl}
</code>```

I have some Stream.map(…) which is returning me above result

Map<String,Long> answer = Stream.map(...).collect(groupingby??)

Now I want to collect it (collect or map or groupingby) and return result as Map such that my answer should be

Map>
{correct: 2
invalid: 2
others: 8}

答:
The trick here is to flatMap each set to the strings that are in it. Once you've done that, you can use map to transform the values to the values you're interested in and count them. E.g.:

```<code>Set<String> allowed = new HashSet<>(Arrays.asList("correct", "invalid"));
Map<String, Long> result =
    values.flatMap(Set::stream)
          .map(s -> allowed.contains(s) ? s : "other")
          .collect(Collectors.groupingBy(Function.identity(),
                                         Collectors.counting()));
</code>```

Title: convert set to map of string with count

Body:
My original data is stream of string like

correctname
abc,def,ghi,jol
abc
def,ghi
zzzzzzzzzz
myname
pppppppppp
jkl

Converting it set:

{correct}
{abc, def,ghi,jkl}
{abc}
{def,ghi}
{invalid}
{correct}
{invalid}
{jkl}

I have some Stream.map(…) which is returning me above result

Map<String,Long> answer = Stream.map(...).collect(groupingby??)

Now I want to collect it (collect or map or groupingby) and return result as Map such that my answer should be

Map>
{correct: 2
invalid: 2
others: 8}

Body:
The trick here is to flatMap each set to the strings that are in it. Once you've done that, you can use map to transform the values to the values you're interested in and count them. E.g.:

Set<String> allowed = new HashSet<>(Arrays.asList("correct", "invalid"));
Map<String, Long> result =
    values.flatMap(Set::stream)
          .map(s -> allowed.contains(s) ? s : "other")
          .collect(Collectors.groupingBy(Function.identity(),
                                         Collectors.counting()));


问:
how to calculate p-value for 48 columns and save the results
I have two 18-by-48 datasets. One for died people and the other for survived. Both have the same column names(CNP1,CNP2,...,CNP48). I would like to calculate the P-value of each CNP.
The function that I am using is the following:

t.test(died_CNP$CNP1,survived_CNP$CNP1)[3]
  - How can I use this function for the 48 columns at one go and save the results in variables ( p1,p2,...,p48)?

答:
You can just loop over the columns.

```<code> pVals <- numeric()
 for(i in 1:ncol(died_CNP))
   pVals[i] <- t.test(died_CNP[,i],survived_CNP[,i])$p.value
</code>```

The resulting pVals will be a numeric vector of length 48. It is recommended to adjust your p-values using p.adjust to avoid the  multiple comparisons problem

```<code> pValsAdjusted <- p.adjust(pVals)
</code>```

Body:
You can just loop over the columns.

 pVals <- numeric()
 for(i in 1:ncol(died_CNP))
   pVals[i] <- t.test(died_CNP[,i],survived_CNP[,i])$p.value

The resulting pVals will be a numeric vector of length 48. It is recommended to adjust your p-values using p.adjust to avoid the  multiple comparisons problem

 pValsAdjusted <- p.adjust(pVals)


问:
Copying textbox values between excel userforms using FOR/NEXT and IF/THEN statements
Disclaimer: I'm still new to Excel VBA.

I've searched around a lot but can't seem to find a solution to my problem.

I'm attempting to streamline a data entry process with the use of a couple userforms and macros that will automate a majority of the process. I've gotten very far with a lot of help from just searching this site but I think it's come time to submit a question.

Essentially what I want this piece of code to do is loop through textboxes and check their values in one userform(QAResults) against certain criteria, when the criteria is satisfied I want it to compare that textbox with another textbox in the second userform(NewEntryUserForm) and copy some textbox values from QAResults to NewEntryUserForm. I think the problem lies in how I'm trying to use FOR and NEXT to cycle through the userform textboxes.

I'm not sure if my explanation makes sense but maybe the code will help show what I'm trying to do. I don't get any errors but it's not doing what I think it should be doing. Any suggestions would be appreciated.

```<code>Private Sub RetrieveLabComments_Click()

Dim i As Integer
Dim y As Integer
Dim ufm As UserForm
Dim qa As UserForm

For i = 1 To 3

Set qa = QAResults
    If qa.Controls("TC" & i & "_DN_FQA").Value <> "" And _
        qa.Controls("TC" & i & "_RLOG_FQA").Value <> "NA" And _
        qa.Controls("TC" & i & "_RLOG_FQA").Value > qa.Controls("TC" & i & _
              "_327_FQA").Value Then

        For y = 1 To 14
        Set ufm = NewEntryUserForm
        Set qa = QAResults
            If qa.Controls("TC" & i & "_DN_FQA").Value = ufm.Controls("CN" _
                & y).Value Then
                    If ufm.Controls("DT" & y).Value = "LD" Then
                        ufm.Controls("QAY" & y & "A").Value = "ILN"
                            If ufm.Controls("DT " & y).Value = "FD" Then
                                ufm.Controls("QAYF" & y & "B").Value =
                                qa.Controls("TC" & i & "_RLOG_FQA").Value _
                                & ">" & qa.Controls("TC" & i & _
                                "_327_FQA").Value
                            End If
                    End If
           End If
        Next y
    End If

Next i

If MsgBox("Data retrieved!", vbOKOnly, "Incoming Message...") Then
End If

End Sub
</code>```

答:
I looked at using the For Each for this problem but I couldn't figure out how to make it work with the number of textboxes I have in my userform.

After messing more with my code I realized that the error was not in my code but in the contents of the textboxes. In other words, it was a dumb mistake on my part and the code was working just fine. So if someone comes across this in the future, this code is a way to loop through specific textboxes on multiple userforms with nested If Then statements. I'm sure there are better ways to write this code but in the end it worked for me.

Body:
Disclaimer: I'm still new to Excel VBA.

I've searched around a lot but can't seem to find a solution to my problem.

I'm attempting to streamline a data entry process with the use of a couple userforms and macros that will automate a majority of the process. I've gotten very far with a lot of help from just searching this site but I think it's come time to submit a question.

Essentially what I want this piece of code to do is loop through textboxes and check their values in one userform(QAResults) against certain criteria, when the criteria is satisfied I want it to compare that textbox with another textbox in the second userform(NewEntryUserForm) and copy some textbox values from QAResults to NewEntryUserForm. I think the problem lies in how I'm trying to use FOR and NEXT to cycle through the userform textboxes.

I'm not sure if my explanation makes sense but maybe the code will help show what I'm trying to do. I don't get any errors but it's not doing what I think it should be doing. Any suggestions would be appreciated.

Private Sub RetrieveLabComments_Click()

Dim i As Integer
Dim y As Integer
Dim ufm As UserForm
Dim qa As UserForm

For i = 1 To 3

Set qa = QAResults
    If qa.Controls("TC" & i & "_DN_FQA").Value <> "" And _
        qa.Controls("TC" & i & "_RLOG_FQA").Value <> "NA" And _
        qa.Controls("TC" & i & "_RLOG_FQA").Value > qa.Controls("TC" & i & _
              "_327_FQA").Value Then

        For y = 1 To 14
        Set ufm = NewEntryUserForm
        Set qa = QAResults
            If qa.Controls("TC" & i & "_DN_FQA").Value = ufm.Controls("CN" _
                & y).Value Then
                    If ufm.Controls("DT" & y).Value = "LD" Then
                        ufm.Controls("QAY" & y & "A").Value = "ILN"
                            If ufm.Controls("DT " & y).Value = "FD" Then
                                ufm.Controls("QAYF" & y & "B").Value =
                                qa.Controls("TC" & i & "_RLOG_FQA").Value _
                                & ">" & qa.Controls("TC" & i & _
                                "_327_FQA").Value
                            End If
                    End If
           End If
        Next y
    End If

Next i

If MsgBox("Data retrieved!", vbOKOnly, "Incoming Message...") Then
End If

End Sub


问:
Dynamic column creation in react js
I have the following data in my code:

```<code>this.state.data = [
                   {"col0":"Service Port","col1":80,"col2":8080}
                   {"col0":"Service Name","col1":"--","col2":"--"}
                  ]
</code>```

render function:

```<code>............
............
<div className="row">
                    <div className="col-lg-12">
                        <CollapsiblePanel name="Services"
                                          bsStyle="info"
                                          open>
                            <BootstrapTable data={this.state.data}
                                            striped
                                            hover>
                                {/*{
                                    for(var i = 0; i < this.state.data.length; i++) {
                                        var col = 0;
                                        for(var j = 0; j < this.state.data[i].length; j)
                                        <TableHeaderColumn
                                            className="tableHeader"
                                            dataField={this.state.col++}
                                    }
                                }*/}
                                <TableHeaderColumn
                                    className="tableHeader"
                                    dataField="col0"
                                    isKey
                                    width="40%"></TableHeaderColumn>
                                <TableHeaderColumn
                                    className="tableHeader"
                                    dataField="col1"
                                    width="40%"></TableHeaderColumn>
                                <TableHeaderColumn
                                    className="tableHeader"
                                    dataField="col2"
                                    width="40%"></TableHeaderColumn>
                            </BootstrapTable>
                        </CollapsiblePanel>
                    </div>
                </div>
</code>```

What i want to do is to dynamically create the TableHeaderColumns because there could be more or less col keys in my data array, such as col3, col4, etc. I tried to integrate a for-loop inside render but it didn't do the work (im not sure how to do that in react).

Could anyone suggest how to do that dynamically? Thanks!

答:
Use Array.prototype.map

```<code><BootstrapTable data={this.state.data}
  striped
  hover>
  {
    this.state.data.map((item) => {
      return (
        <TableHeaderColumn
          className="tableHeader"
          dataField={item.col0}
          isKey
          width="40%" />
      );
    }
  }
</BootstrapTable>
</code>```

Title: Dynamic column creation in react js

Body:
I have the following data in my code:

this.state.data = [
                   {"col0":"Service Port","col1":80,"col2":8080}
                   {"col0":"Service Name","col1":"--","col2":"--"}
                  ]

render function:

............
............

                        <CollapsiblePanel name="Services"
                                          bsStyle="info"
                                          open>
                            <BootstrapTable data={this.state.data}
                                            striped
                                            hover>
                                {/*{
                                    for(var i = 0; i < this.state.data.length; i++) {
                                        var col = 0;
                                        for(var j = 0; j < this.state.data[i].length; j)
                                        <TableHeaderColumn
                                            className="tableHeader"
                                            dataField={this.state.col++}
                                    }
                                }*/}
                                <TableHeaderColumn
                                    className="tableHeader"
                                    dataField="col0"
                                    isKey
                                    width="40%"></TableHeaderColumn>
                                <TableHeaderColumn
                                    className="tableHeader"
                                    dataField="col1"
                                    width="40%"></TableHeaderColumn>
                                <TableHeaderColumn
                                    className="tableHeader"
                                    dataField="col2"
                                    width="40%"></TableHeaderColumn>
                            </BootstrapTable>
                        </CollapsiblePanel>

What i want to do is to dynamically create the TableHeaderColumns because there could be more or less col keys in my data array, such as col3, col4, etc. I tried to integrate a for-loop inside render but it didn't do the work (im not sure how to do that in react).

Could anyone suggest how to do that dynamically? Thanks!

Body:
Use Array.prototype.map

<BootstrapTable data={this.state.data}
  striped
  hover>
  {
    this.state.data.map((item) => {
      return (
        <TableHeaderColumn
          className="tableHeader"
          dataField={item.col0}
          isKey
          width="40%" />
      );
    }
  }
</BootstrapTable>


问:
How do you manage databases in development, test, and production?
I've had a hard time trying to find good examples of how to manage database schemas and data between development, test, and production servers.

Here's our setup. Each developer has a virtual machine running our app and the MySQL database. It is their personal sandbox to do whatever they want. Currently, developers will make a change to the SQL schema and do a dump of the database to a text file that they commit into SVN.

We're wanting to deploy a continuous integration development server that will always be running the latest committed code. If we do that now, it will reload the database from SVN for each build.

We have a test (virtual) server that runs "release candidates." Deploying to the test server is currently a very manual process, and usually involves me loading the latest SQL from SVN and tweaking it. Also, the data on the test server is inconsistent. You end up with whatever test data the last developer to commit had on his sandbox server.

Where everything breaks down is the deployment to production. Since we can't overwrite the live data with test data, this involves manually re-creating all the schema changes. If there were a large number of schema changes or conversion scripts to manipulate the data, this can get really hairy.

If the problem was just the schema, It'd be an easier problem, but there is "base" data in the database that is updated during development as well, such as meta-data in security and permissions tables.

This is the biggest barrier I see in moving toward continuous integration and one-step-builds. How do you solve it?

A follow-up question: how do you track database versions so you know which scripts to run to upgrade a given database instance? Is a version table like Lance mentions below the standard procedure?

Thanks for the reference to Tarantino. I'm not in a .NET environment, but I found their DataBaseChangeMangement wiki page to be very helpful. Especially this Powerpoint Presentation (.ppt)

I'm going to write a Python script that checks the names of *.sql scripts in a given directory against a table in the database and runs the ones that aren't there in order based on a integer that forms the first part of the filename. If it is a pretty simple solution, as I suspect it will be, then I'll post it here.

I've got a working script for this. It handles initializing the DB if it doesn't exist and running upgrade scripts as necessary. There are also switches for wiping an existing database and importing test data from a file. It's about 200 lines, so I won't post it (though I might put it on pastebin if there's interest).

答: You could also look at using  a tool like SQL Compare to script the difference between various versions of a database, allowing you to quickly migrate between versions</p>

LastEditorDisplayName: Matt Miller

OwnerDisplayName: Conrad

ContentLicense: CC BY-SA 2.5


问:
Who can tell me what's wrong with this RPGLE-array?
In have a printer file that looks somewhat like this:

```<code>Customer-data                 Units01 Units02 ....... Units11
-------------------------------------------------------------
Name/address/zip/....         Count01 Count02 ....... Count11
Name/address/zip/....         Count01 Count02 ....... Count11
:    :       :   :            :       :       :       :
Name/address/zip/....         Count01 Count02 ....... Count11
                              ------- ------- ------- -------
Totals                        Total01 Total02 ....... Total11
</code>```

The Units, Count and Total fields are mapped into data structures overlayed with an array definition like this:

```<code>0014.00 D UNITSDS         DS
0015.00 D   UNITS01
0016.00 D   UNITS02
:       :   :
0024.00 D   UNITS10
0025.00 D   UNITS11
0026.00 D  UNITSAR                            LIKE(UNITS) DIM(11)
0026.00 D                                     OVERLAY(UNITSDS)
:       D*-------------------------------------------------------
0034.00 D COUNTDS         DS
0035.00 D   COUNT01
0036.00 D   COUNT02
:       :   :
0044.00 D   COUNT10
0045.00 D   COUNT11
0046.00 D  COUNTAR                            LIKE(COUNT) DIM(11)
0046.00 D                                     OVERLAY(COUNTDS)
:       D*-------------------------------------------------------
0054.00 D TOTALDS         DS
0055.00 D   TOTAL01
0056.00 D   TOTAL02
:       :   :
0064.00 D   TOTAL10
0065.00 D   TOTAL11
0066.00 D  TOTALAR                            LIKE(TOTAL) DIM(11)
0066.00 D                                     OVERLAY(TOTALDS)
</code>```

When I process a WRITE on the details line in the printer file after some processing I get a "Decimal data error".

I was very much surprised that it appears that the arrays COUNTAR and TOTALAR have data type "Packed" although all previous defined variables COUNT, COUNTnn, TOTAL and TOTALnn are "Zoned" and the data structures COUNTDS and TOTALDS are "Char".

Packed data was mapped in the output buffer for the printer file causing the "Decimal data error".

Why are these arrays suddenly in "Packed" data format?

Body:
In have a printer file that looks somewhat like this:

Customer-data                 Units01 Units02 ....... Units11
-------------------------------------------------------------
Name/address/zip/....         Count01 Count02 ....... Count11
Name/address/zip/....         Count01 Count02 ....... Count11
:    :       :   :            :       :       :       :
Name/address/zip/....         Count01 Count02 ....... Count11
                              ------- ------- ------- -------
Totals                        Total01 Total02 ....... Total11

The Units, Count and Total fields are mapped into data structures overlayed with an array definition like this:

0014.00 D UNITSDS         DS
0015.00 D   UNITS01
0016.00 D   UNITS02
:       :   :
0024.00 D   UNITS10
0025.00 D   UNITS11
0026.00 D  UNITSAR                            LIKE(UNITS) DIM(11)
0026.00 D                                     OVERLAY(UNITSDS)
:       D*-------------------------------------------------------
0034.00 D COUNTDS         DS
0035.00 D   COUNT01
0036.00 D   COUNT02
:       :   :
0044.00 D   COUNT10
0045.00 D   COUNT11
0046.00 D  COUNTAR                            LIKE(COUNT) DIM(11)
0046.00 D                                     OVERLAY(COUNTDS)
:       D*-------------------------------------------------------
0054.00 D TOTALDS         DS
0055.00 D   TOTAL01
0056.00 D   TOTAL02
:       :   :
0064.00 D   TOTAL10
0065.00 D   TOTAL11
0066.00 D  TOTALAR                            LIKE(TOTAL) DIM(11)
0066.00 D                                     OVERLAY(TOTALDS)

When I process a WRITE on the details line in the printer file after some processing I get a "Decimal data error".

I was very much surprised that it appears that the arrays COUNTAR and TOTALAR have data type "Packed" although all previous defined variables COUNT, COUNTnn, TOTAL and TOTALnn are "Zoned" and the data structures COUNTDS and TOTALDS are "Char".

Packed data was mapped in the output buffer for the printer file causing the "Decimal data error".

Why are these arrays suddenly in "Packed" data format?

Body:
I would code this

0014.00 D UNITSDS         DS
0015.00 D   UNITS01
0016.00 D   UNITS02
:       :   :
0024.00 D   UNITS10
0025.00 D   UNITS11
0026.00 D  UNITSAR                            LIKE(UNITS01) DIM(11)
0026.00 D                                     OVERLAY(UNITSDS)
:       D*-------------------------------------------------------
0034.00 D COUNTDS         DS
0035.00 D   COUNT01
0036.00 D   COUNT02
:       :   :
0044.00 D   COUNT10
0045.00 D   COUNT11
0046.00 D  COUNTAR                            LIKE(COUNT01) DIM(11)
0046.00 D                                     OVERLAY(COUNTDS)
:       D*-------------------------------------------------------
0054.00 D TOTALDS         DS
0055.00 D   TOTAL01
0056.00 D   TOTAL02
:       :   :
0064.00 D   TOTAL10
0065.00 D   TOTAL11
0066.00 D  TOTALAR                            LIKE(TOTAL01) DIM(11)
0066.00 D                                     OVERLAY(TOTALDS)


问:
Update method behaving different according to Entity array size.
I am making a college project and I am having trouble with my EntiyManager update method. This update system for some reason is making my bullets move faster according to my entity array size, if this array size is bigger than 1 the bullet will move faster if not the bullet will move normally.

I would like to have all my bullets moving normally.

note: b.getVel() and vel are always 2.

EntityManager methods:

```<code>public void update()
{
    if(!handler.getPaused())
    {
        for(int i = 0; i < creatures.size(); i++)
        {
            //entities[i]       at
            Creatures c = creatures.get(i);
            c.update();

            if(!bullets.isEmpty())
            {
                for (int j = 0; j < bullets.size(); j++)
                {
                    Bullet b = bullets.get(j);
                    //Hit detection;
                    if(c.getCollisionBounds(b.getVel(), 0).intersects(b.getCollisionBounds(0, 0)))
                    {
                        c.HP -= 5;
                        removeBullet(b);
                    }
                    System.out.println(b.getVel());
                    b.update();
                }
            }
            else System.out.println("empty");
        }

    }

}

public void draw(Graphics g)
{

    for(Entity se : staticEntities)
    {
        se.draw(g);
    }

    for(Bullet b : bullets)
    {
        b.draw(g);
    }

    for(Creatures c : creatures)
    {
        c.draw(g);
    }
}
</code>```

Bullet methods:

```<code>@Override
public void update()
{
    if(vel > 0)
    {
       txRight = (int) (x + vel + bounds.x + bounds.width) / Tile.TILESIZE;
    }
    else
    {
       txLeft = (int) (x + vel + bounds.x) / Tile.TILESIZE;
    }

    if(collisionWithTile(txRight, (int) (y + bounds.y) / Tile.TILESIZE) ||
       collisionWithTile(txRight, (int) (y + bounds.y + bounds.height) / Tile.TILESIZE) ||
       collisionWithTile(txLeft, (int) (y + bounds.y) / Tile.TILESIZE)  ||
       collisionWithTile(txLeft, (int) (y + bounds.y + bounds.height) / Tile.TILESIZE))
    {
        handler.getLevel().getEntityManager().removeBullet(this);
    }

    x += vel;
}

@Override
public void draw(Graphics g)
{
    g.setColor(Color.yellow);
    g.fillRect((int) x, (int) y, width, height);
}
</code>```

答: I now know why this is happening. It is updating twice the bullet.</p>

Body:
I am making a college project and I am having trouble with my EntiyManager update method. This update system for some reason is making my bullets move faster according to my entity array size, if this array size is bigger than 1 the bullet will move faster if not the bullet will move normally.

I would like to have all my bullets moving normally.

note: b.getVel() and vel are always 2.

EntityManager methods:

public void update()
{
    if(!handler.getPaused())
    {
        for(int i = 0; i < creatures.size(); i++)
        {
            //entities[i]       at
            Creatures c = creatures.get(i);
            c.update();

            if(!bullets.isEmpty())
            {
                for (int j = 0; j < bullets.size(); j++)
                {
                    Bullet b = bullets.get(j);
                    //Hit detection;
                    if(c.getCollisionBounds(b.getVel(), 0).intersects(b.getCollisionBounds(0, 0)))
                    {
                        c.HP -= 5;
                        removeBullet(b);
                    }
                    System.out.println(b.getVel());
                    b.update();
                }
            }
            else System.out.println("empty");
        }

    }

}

public void draw(Graphics g)
{

    for(Entity se : staticEntities)
    {
        se.draw(g);
    }

    for(Bullet b : bullets)
    {
        b.draw(g);
    }

    for(Creatures c : creatures)
    {
        c.draw(g);
    }
}

Bullet methods:

@Override
public void update()
{
    if(vel > 0)
    {
       txRight = (int) (x + vel + bounds.x + bounds.width) / Tile.TILESIZE;
    }
    else
    {
       txLeft = (int) (x + vel + bounds.x) / Tile.TILESIZE;
    }

    if(collisionWithTile(txRight, (int) (y + bounds.y) / Tile.TILESIZE) ||
       collisionWithTile(txRight, (int) (y + bounds.y + bounds.height) / Tile.TILESIZE) ||
       collisionWithTile(txLeft, (int) (y + bounds.y) / Tile.TILESIZE)  ||
       collisionWithTile(txLeft, (int) (y + bounds.y + bounds.height) / Tile.TILESIZE))
    {
        handler.getLevel().getEntityManager().removeBullet(this);
    }

    x += vel;
}

@Override
public void draw(Graphics g)
{
    g.setColor(Color.yellow);
    g.fillRect((int) x, (int) y, width, height);
}


问:
Set version to latest version including prereleases in Gemfile
How do I specify a version constraint in a Gemfile, such that it always take the latest release including pre-releases of a gem.

Currently the library I work with has the latest stable release 2.0.0, and the latest pre-release 2.1.0.alpha.pre.171.

I could set the version constraint to >=2.1.0.alpha.pre.171 or just >=2.1.0.a, as I understand it. But would that also include future pre releases such as >=2.2.0.alpha.pre.1 or even >=3.0.0.alpha.pre.1 as well as future stable versions such as 3.0.0? And would that always resolve to the latest version?

Disclaimer:
To not be misunderstood, this is not for any productive dependency management. The idea is to have a demo up an running, which should always include the latest features and as well should crash if the latest pre-release is broken.

答:
You'll want to do two things:

Specify >= 2.1.0.alpha.pre.171 in your Gemfile. The important thing here is that the specified constraint is itself a pre-release, which is the only way to make Bundler will pick up that you want pre-releases1. All future releases, including pre-releases and major releases, will then be included when Bundler looks for updates.

Use an automated tool to regularly update the Gemfile.lock. Any of Dependabot, Depfu or Deppbot would work. (Disclosure: I wrote Dependabot.)

Surprisingly, as of Bundler 1.15.1, there's no option that can be passed to bundle update that replicates the behaviour created by (1).

https://github.com/bundler/bundler/blob/v1.15.1/lib/bundler/index.rb#L194-L200


问:
C - int and malloc
Okay, I'm pretty new to those things. From what I've learned:

an int (signed int) is in range [−32,767; 32,767]

and a long long int (signed) is in range [-9,223,372,036,854,775,807; 9,223,372,036,854,775,807].

I also learnt that with malloc() function I can temporarily allocate memory for a variable.

I was thinking: if I use malloc() to allocate memory for a long long int, but with a larger size, can I store values bigger than 9,223,372,036,854,775,807 and smaller than -9,223,372,036,854,775,807?

答:
Sort of. The problem you're going to run into is that you don't have a type that fits the space. That means that your programming language doesn't have instructions on how to operate on numbers that large. Which means that you'll have to teach the language how to handle such a number, and you'll have to handle the fact that your CPU won't be able to handle the object natively.

To do so would require a lot of work on your part. This is a very simplified concept of what BigNum library is.

Title: C - int and malloc


问:
How to Mock HttpResponse for the Web Service (Using JavaHttpClient)?
I have WebService Call using Java Http Client. Need to do Junit testing using Mockito for the Response of WebService (HttpResponse).

```<code>Gson gson = new Gson();
HttpResponse httpResponse= JavaHttpClient.callWebService("URL",object);
String json = EntityUtils.toString(httpResponse.getEntity());
response = gson.fromJson(json, ClassName.class);
log.info("Response: " + new Gson().toJson(response));
</code>```

How to set the mock values for httpResponse.getEntity() ? and this should be convert to JSON as above

Thanks
Nithyanandan K

答:
Here is some sample MockServer. Modify it for your requirement. </p>

```<code>import static org.mockserver.integration.ClientAndServer.startClientAndServer;
import static org.mockserver.model.HttpRequest.request;
import static org.mockserver.model.HttpResponse.response;

import org.mockserver.client.server.MockServerClient;
import org.mockserver.initialize.ExpectationInitializer;
import org.mockserver.model.Header;
import org.mockserver.model.HttpStatusCode;

public class MockServerInitializer implements ExpectationInitializer {

  /**
   * Standalone mock server
   *
   * @param args
   */
  public static void main(String[] args) {
    MockServerClient mockServerClient = startClientAndServer(9999);
    defineMockServerBehaviour(mockServerClient);
  }

  @Override
  public void initializeExpectations(MockServerClient mockServerClient) {
    defineMockServerBehaviour(mockServerClient);
  }

  public static void defineMockServerBehaviour(MockServerClient mockServer) {

    mockServer.when(
      request()
        .withMethod("POST")
        .withPath("/Sample")
    ).respond(
      response()
        .withStatusCode(HttpStatusCode.OK_200.code())
        .withHeader(Header.header("Content-Type", "application/xml"))
        .withBody("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" +
          "<Response>\n" +
          "    <responseStatus>OK</responseStatus>\n" +
          "</Response>"));
  }
}
</code>```

Body:
I have WebService Call using Java Http Client. Need to do Junit testing using Mockito for the Response of WebService (HttpResponse).

Gson gson = new Gson();
HttpResponse httpResponse= JavaHttpClient.callWebService("URL",object);
String json = EntityUtils.toString(httpResponse.getEntity());
response = gson.fromJson(json, ClassName.class);
log.info("Response: " + new Gson().toJson(response));

How to set the mock values for httpResponse.getEntity() ? and this should be convert to JSON as above

Thanks
Nithyanandan K

Body:
Here is some sample MockServer. Modify it for your requirement.

import static org.mockserver.integration.ClientAndServer.startClientAndServer;
import static org.mockserver.model.HttpRequest.request;
import static org.mockserver.model.HttpResponse.response;

import org.mockserver.client.server.MockServerClient;
import org.mockserver.initialize.ExpectationInitializer;
import org.mockserver.model.Header;
import org.mockserver.model.HttpStatusCode;

public class MockServerInitializer implements ExpectationInitializer {

  /**
   * Standalone mock server
   *
   * @param args
   */
  public static void main(String[] args) {
    MockServerClient mockServerClient = startClientAndServer(9999);
    defineMockServerBehaviour(mockServerClient);
  }

  @Override
  public void initializeExpectations(MockServerClient mockServerClient) {
    defineMockServerBehaviour(mockServerClient);
  }

  public static void defineMockServerBehaviour(MockServerClient mockServer) {

    mockServer.when(
      request()
        .withMethod("POST")
        .withPath("/Sample")
    ).respond(
      response()
        .withStatusCode(HttpStatusCode.OK_200.code())
        .withHeader(Header.header("Content-Type", "application/xml"))
        .withBody("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" +
          "<Response>\n" +
          "    <responseStatus>OK</responseStatus>\n" +
          "</Response>"));
  }
}


问:
Android Pie Chart Legend
I can draw a pie chart using this:

http://blog.gafmediastudio.com/2010/04/01/draw-a-pie-chart-with-android/comment-page-1/#comment-1340

But now I want to show pie chart legend in pie chart view. Can anybody help?

答:
So, you'd like to place the legend to the left or right of the chart? Why don't you add the necessary stuff in the

```<code>onDraw(Canvas canvas)
</code>```

method? E.g. draw a rectangle with some strings in it.

Title: Android Pie Chart Legend

Body:
So, you'd like to place the legend to the left or right of the chart? Why don't you add the necessary stuff in the

onDraw(Canvas canvas)

method? E.g. draw a rectangle with some strings in it.


答:
What your looking for would work in a sample like this:

```<code>var inner = function(a) {
  return function() {
    console.log("a is -- ", a);
  }
}

var outer = function(b) {
  console.log("Executing outer()");
  b();
}

outer(inner(9));
</code>```

Though you might want to look at Javascript Promises for something like this.

https://developers.google.com/web/fundamentals/getting-started/primers/promises

This way, you can chain together functions to do something like:

```<code>outer(9).then(inner())
</code>```

You can have the function outer return something that then gets passed into inner.

Title: Passing function object as a parameter to another function

Body:
I am trying to understand the flow of the following code snippet -

var inner = function (a){
    console.log("a is -- ", 9);
}

var outer = function(b){
    console.log("Executing outer()");
    b();
}

outer(inner(5));

The output currently is -

a is --  9
Executing outer()
app.js:6 Uncaught TypeError: b is not a function
at outer (app.js:6)
at app.js:9

I am expecting the following -

Executing outer()
a is --  9

I understand that in the statement outer(inner(9)) : inner(9) is a function call that evaluates (runs the code contained within the inner() function), but i want the code inside the outer() function to evaluate the code within inner(). Basically, i want to pass 9 as a variable to outer() so that it can pass it to inner()

Please point me to any online resource that will help me understand this concept better. Also, please mark this question as duplicate if already answered. Thanks!

Body:
What your looking for would work in a sample like this:

var inner = function(a) {
  return function() {
    console.log("a is -- ", a);
  }
}

var outer = function(b) {
  console.log("Executing outer()");
  b();
}

outer(inner(9));

Though you might want to look at Javascript Promises for something like this.

https://developers.google.com/web/fundamentals/getting-started/primers/promises

This way, you can chain together functions to do something like:

outer(9).then(inner())

You can have the function outer return something that then gets passed into inner.


问:
Decentralized chat application using IPFS
I am writing a decentralized chat application using nodejs, expressjs, angularjs, socket.io and ipfs.I am using libp2p to form the nodes that will communicate with each other over an open connection. Libp2p is a networking stack modularized out of IPFS project.

Libp2p allows me to build nodes which are capable of hosting a swarm or listening/ dialing to one. I have developed to the point where several nodes can communicate with each other via inputs in angularjs (supplemented by socket.io) webpage but their IP addresses and tcp ports need to be hard coded.

The problem I am facing is, if an unknown number of users join this system and set up their nodes, how do I handle the scenario. I have done lot of research into DHT specifically into its application with torrents but am no where close to actually applying it.

I do not want to run a central system that keeps track of the users as a tracker keeps track of seeders and leachers in torrents (now somewhat redundant due to DHT)

In a centralized chat application, every time a user enters or leaves, I can send an emit event from the server to all peers using socket.io signaling the same. But the equivalent in a decentralized chat app is something I am struggling with greatly.

I need some guidance please.

答:
You won't have to worry about that issue specifically as libp2p will handle the discovery and connection of the nodes. In the end you get a primitive for process addressing which will always dial to the process if it is accessible in the network.

I've been working recently in better documentation and tutorials for libp2p, please go to https://github.com/libp2p/js-libp2p/tree/master/examples and https://github.com/libp2p/js-libp2p. More examples to come next week, including Peer Routing + Content Routing (aka DHT).

Cheers!