问:
Issue when building JHipster with Angular4 on Linux
I am trying to build my application in server-side with Jenkins. When running the command:
**sudo ./mvnw -Pprod package*
I have the following error message:

```<code>[INFO] --- frontend-maven-plugin:1.6:yarn (webpack build prod) @ timetrack ---
[INFO] Running 'yarn run webpack:prod' in /var/lib/jenkins/workspace/timetrack-jh
[INFO] yarn run v1.2.1
[INFO] $ yarn run cleanup && yarn run webpack:prod:main && yarn run clean-www
[ERROR] warning From Yarn 1.0 onwards, scripts don't require "--" for options to be forwarded. In a future version, any explicit "--" will be forwarded as-is to the scripts.
[ERROR] module.js:471
[ERROR]     throw err;
[ERROR]     ^
[ERROR]
[ERROR] Error: Cannot find module '/var/lib/jenkins/workspace/timetrack-jh/webpack/webpack.prod.js'
[ERROR]     at Function.Module._resolveFilename (module.js:469:15)
[ERROR]     at Function.Module._load (module.js:417:25)
[ERROR]     at Module.require (module.js:497:17)
[ERROR]     at require (internal/module.js:20:19)
[ERROR]     at requireConfig (/var/lib/jenkins/workspace/timetrack-jh/node_modules/webpack/bin/convert-argv.js:97:18)
[ERROR]     at /var/lib/jenkins/workspace/timetrack-jh/node_modules/webpack/bin/convert-argv.js:104:17
[ERROR]     at Array.forEach (native)
[ERROR]     at module.exports (/var/lib/jenkins/workspace/timetrack-jh/node_modules/webpack/bin/convert-argv.js:102:15)
[ERROR]     at yargs.parse (/var/lib/jenkins/workspace/timetrack-jh/node_modules/webpack/bin/webpack.js:171:41)
[ERROR]     at Object.Yargs.self.parse (/var/lib/jenkins/workspace/timetrack-jh/node_modules/webpack/node_modules/yargs/yargs.js:533:18)
[ERROR] error Command failed with exit code 1.
[ERROR] error Command failed with exit code 1.
[ERROR] error Command failed with exit code 1.
[INFO] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------*
</code>```

I have done the same building on my Windows machine and that is working correctly. Could some one help me on what is happening on Linux system?

Linux version: Linux version 4.10.0-37-generic (buildd@lgw01-amd64-022) (gcc version 6.3.0 20170406 (Ubuntu 6.3.0-12ubuntu2) ) #41-Ubuntu SMP Fri Oct 6 20:20:00 UTC 2017

Thanks in advance,

-Rod

After some dealing I solved the problem above, but it persists having a new error message that follows (only on Linux, Windows is running well):

```<code>[INFO] Installed Yarn locally.
[INFO]
[INFO] --- frontend-maven-plugin:1.6:yarn (yarn install) @ timetrack ---
[INFO] Running 'yarn install' in /home/rodrigo/test/TimeTrack
[INFO] yarn install v1.2.1
[INFO] [1/5] Validating package.json...
[INFO] [2/5] Resolving packages...
[INFO] [3/5] Fetching packages...
[INFO] info fsevents@1.1.2: The platform "linux" is incompatible with this modul                       e.
[INFO] info "fsevents@1.1.2" is an optional dependency and failed compatibility                        check. Excluding it from installation.
[INFO] [4/5] Linking dependencies...
[ERROR] warning "bootstrap@4.0.0-beta" has unmet peer dependency "popper.js@^1.1                       1.0".
[ERROR] warning "@schematics/angular@0.0.49" has incorrect peer dependency "@ang                       ular-devkit/schematics@0.0.34".
[ERROR] warning "license-webpack-plugin@1.1.1" has unmet peer dependency "webpac                       k-sources@>=1.0.0".
[INFO] [5/5] Building fresh packages...
[INFO] Done in 40.25s.
[INFO]
[INFO] --- frontend-maven-plugin:1.6:yarn (webpack build prod) @ timetrack ---
[INFO] Running 'yarn run webpack:prod' in /home/rodrigo/test/TimeTrack
[INFO] yarn run v1.2.1
[INFO] $ yarn run cleanup && yarn run webpack:prod:main && yarn run clean-www
[ERROR] warning From Yarn 1.0 onwards, scripts don't require "--" for options to                        be forwarded. In a future version, any explicit "--" will be forwarded as-is to                        the scripts.
[INFO]
[INFO] <--- Last few GCs --->
[INFO]
[INFO]       28 ms: Mark-sweep 1.4 (5.5) -> 1.3 (5.5) MB, 1.2 / 0.0 ms [allocati                       on failure] [GC in old space requested].
[INFO]       29 ms: Mark-sweep 1.3 (5.5) -> 1.3 (5.5) MB, 1.2 / 0.0 ms [allocati                       on failure] [GC in old space requested].
[INFO]       30 ms: Mark-sweep 1.3 (5.5) -> 1.3 (5.5) MB, 1.2 / 0.0 ms [allocati                       on failure] [GC in old space requested].
[INFO]       32 ms: Mark-sweep 1.3 (5.5) -> 1.3 (4.5) MB, 1.2 / 0.0 ms [last res                       ort gc].
[INFO]       33 ms: Mark-sweep 1.3 (4.5) -> 1.3 (4.5) MB, 1.2 / 0.0 ms [last res                       ort gc].
[INFO]
[INFO]
[INFO] <--- JS stacktrace --->
[INFO]
[INFO] ==== JS stack trace =========================================
[INFO]
[INFO] Security context: 0x3957b609 <JS Object>
[INFO]     1: /* anonymous */(aka /* anonymous */) [fs.js:10] [pc=0x29d1d25d] (t                       his=0x395081d9 <undefined>,exports=0x3d777f45 <an Object with map 0x4e409cad>,re                       quire=0x39585bf1 <JS Function NativeModule.require (SharedFunctionInfo 0x3958425                       d)>,module=0x3d777f11 <a NativeModule with map 0x4e40e2a1>,__filename=0x3d777f31                        <String[5]: fs.js>,__dirname=0x395081d9 <undefined>)
[INFO]     2: arguments adaptor frame: 4-...
[INFO]
[ERROR] FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out                        of memory
[ERROR]  1: node::Abort() [node]
[ERROR]  2: 0x8c80076 [node]
[ERROR]  3: v8::Utils::ReportApiFailure(char const*, char const*) [node]
[ERROR]  4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [node]
[ERROR]  5: v8::internal::Factory::NewMap(v8::internal::InstanceType, int, v8::i                       nternal::ElementsKind) [node]
[ERROR]  6: v8::internal::Map::RawCopy(v8::internal::Handle<v8::internal::Map>,                        int) [node]
[ERROR]  7: v8::internal::Map::CopyDropDescriptors(v8::internal::Handle<v8::inte                       rnal::Map>) [node]
[ERROR]  8: v8::internal::Map::CopyReplaceDescriptors(v8::internal::Handle<v8::i                       nternal::Map>, v8::internal::Handle<v8::internal::DescriptorArray>, v8::internal                       ::Handle<v8::internal::LayoutDescriptor>, v8::internal::TransitionFlag, v8::inte                       rnal::MaybeHandle<v8::internal::Name>, char const*, v8::internal::SimpleTransiti                       onFlag) [node]
[ERROR]  9: v8::internal::Map::CopyAddDescriptor(v8::internal::Handle<v8::intern                       al::Map>, v8::internal::Descriptor*, v8::internal::TransitionFlag) [node]
[ERROR] 10: v8::internal::Map::CopyWithConstant(v8::internal::Handle<v8::interna                       l::Map>, v8::internal::Handle<v8::internal::Name>, v8::internal::Handle<v8::inte                       rnal::Object>, v8::internal::PropertyAttributes, v8::internal::TransitionFlag) [                       node]
[ERROR] 11: v8::internal::Map::TransitionToDataProperty(v8::internal::Handle<v8:                       :internal::Map>, v8::internal::Handle<v8::internal::Name>, v8::internal::Handle<                       v8::internal::Object>, v8::internal::PropertyAttributes, v8::internal::Object::S                       toreFromKeyed) [node]
[ERROR] 12: v8::internal::LookupIterator::PrepareTransitionToDataProperty(v8::in                       ternal::Handle<v8::internal::JSObject>, v8::internal::Handle<v8::internal::Objec                       t>, v8::internal::PropertyAttributes, v8::internal::Object::StoreFromKeyed) [nod                       e]
[ERROR] 13: v8::internal::Object::AddDataProperty(v8::internal::LookupIterator*,                        v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyAttributes, v                       8::internal::Object::ShouldThrow, v8::internal::Object::StoreFromKeyed) [node]
[ERROR] 14: v8::internal::JSObject::AddProperty(v8::internal::Handle<v8::interna                       l::JSObject>, v8::internal::Handle<v8::internal::Name>, v8::internal::Handle<v8:                       :internal::Object>, v8::internal::PropertyAttributes) [node]
[ERROR] 15: v8::internal::Factory::NewFunction(v8::internal::Handle<v8::internal                       ::String>, v8::internal::Handle<v8::internal::Code>, v8::internal::Handle<v8::in                       ternal::Object>, v8::internal::InstanceType, int, bool, bool, bool) [node]
[ERROR] 16: v8::internal::ApiNatives::CreateApiFunction(v8::internal::Isolate*,                        v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v                       8::internal::Object>, v8::internal::ApiNatives::ApiInstanceType) [node]
[ERROR] 17: 0x8554502 [node]
[ERROR] 18: v8::internal::ApiNatives::InstantiateFunction(v8::internal::Handle<v                       8::internal::FunctionTemplateInfo>) [node]
[ERROR] 19: v8::FunctionTemplate::GetFunction(v8::Local<v8::Context>) [node]
[ERROR] 20: v8::FunctionTemplate::GetFunction() [node]
[ERROR] 21: node::InitFs(v8::Local<v8::Object>, v8::Local<v8::Value>, v8::Local<                       v8::Context>, void*) [node]
[ERROR] 22: 0x8c858a0 [node]
[ERROR] 23: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionC                       allbackInfo<v8::Value> const&)) [node]
[ERROR] 24: 0x85b3630 [node]
[ERROR] 25: 0x85b3dd0 [node]
[ERROR] 26: 0x4890a0fe
[ERROR] 27: 0x29d1d25d
[ERROR] 28: 0x4890b616
[ERROR] 29: 0x489384a8
[ERROR] 30: 0x48937d7f
[ERROR] 31: 0x29d1b14f
[ERROR] 32: 0x4890b616
[ERROR] 33: 0x489384a8
[ERROR] 34: 0x48937d7f
[ERROR] 35: 0x48937411
[ERROR] 36: 0x48936335
[ERROR] 37: 0x4893153e
[ERROR] 38: 0x48920a43
[ERROR] 39: v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::                       Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v                       8::internal::Handle<v8::internal::Object>*) [node]
[ERROR] 40: v8::Function::Call(v8::Local<v8::Context>, v8::Local<v8::Value>, int                       , v8::Local<v8::Value>*) [node]
[ERROR] 41: v8::Function::Call(v8::Local<v8::Value>, int, v8::Local<v8::Value>*)                        [node]
[ERROR] 42: node::LoadEnvironment(node::Environment*) [node]
[ERROR] 43: node::Start(int, char**) [node]
[ERROR] 44: main [node]
[ERROR] 45: __libc_start_main [/lib/i386-linux-gnu/libc.so.6]
[ERROR] Aborted (core dumped)
[ERROR] error Command failed with exit code 134.
[ERROR] error Command failed with exit code 1.
[ERROR] error Command failed with exit code 1.
[INFO] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about th                       is command.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 03:09 min
[INFO] Finished at: 2017-11-14T19:58:35+13:00
[INFO] Final Memory: 31M/74M
[INFO] ------------------------------------------------------------------------
</code>```

Someone has any help?

Regards,

-Rod

答:
I again figured out the issue. When building on Linux machine and have out of heap memory on Javascript. Need to change that lines on package.json (only happened using JHipster with Angular 4):

"webpack-dev-server": "node --max_old_space_size=5120 node_modules/webpack-dev-server/bin/webpack-dev-server.js",
"webpack": "node --max_old_space_size=5120 node_modules/webpack/bin/webpack.js"

I updated the --max_old_space_size from 4096 to 5120 (1GB more).

That was it folks!

Thanks anyway for the good guys that helped me,

Best regards,

-Rod

Body:
I am trying to build my application in server-side with Jenkins. When running the command:
**sudo ./mvnw -Pprod package*
I have the following error message:

[INFO] --- frontend-maven-plugin:1.6:yarn (webpack build prod) @ timetrack ---
[INFO] Running 'yarn run webpack:prod' in /var/lib/jenkins/workspace/timetrack-jh
[INFO] yarn run v1.2.1
[INFO] $ yarn run cleanup && yarn run webpack:prod:main && yarn run clean-www
[ERROR] warning From Yarn 1.0 onwards, scripts don't require "--" for options to be forwarded. In a future version, any explicit "--" will be forwarded as-is to the scripts.
[ERROR] module.js:471
[ERROR]     throw err;
[ERROR]     ^
[ERROR]
[ERROR] Error: Cannot find module '/var/lib/jenkins/workspace/timetrack-jh/webpack/webpack.prod.js'
[ERROR]     at Function.Module._resolveFilename (module.js:469:15)
[ERROR]     at Function.Module._load (module.js:417:25)
[ERROR]     at Module.require (module.js:497:17)
[ERROR]     at require (internal/module.js:20:19)
[ERROR]     at requireConfig (/var/lib/jenkins/workspace/timetrack-jh/node_modules/webpack/bin/convert-argv.js:97:18)
[ERROR]     at /var/lib/jenkins/workspace/timetrack-jh/node_modules/webpack/bin/convert-argv.js:104:17
[ERROR]     at Array.forEach (native)
[ERROR]     at module.exports (/var/lib/jenkins/workspace/timetrack-jh/node_modules/webpack/bin/convert-argv.js:102:15)
[ERROR]     at yargs.parse (/var/lib/jenkins/workspace/timetrack-jh/node_modules/webpack/bin/webpack.js:171:41)
[ERROR]     at Object.Yargs.self.parse (/var/lib/jenkins/workspace/timetrack-jh/node_modules/webpack/node_modules/yargs/yargs.js:533:18)
[ERROR] error Command failed with exit code 1.
[ERROR] error Command failed with exit code 1.
[ERROR] error Command failed with exit code 1.
[INFO] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------*

I have done the same building on my Windows machine and that is working correctly. Could some one help me on what is happening on Linux system?

Linux version: Linux version 4.10.0-37-generic (buildd@lgw01-amd64-022) (gcc version 6.3.0 20170406 (Ubuntu 6.3.0-12ubuntu2) ) #41-Ubuntu SMP Fri Oct 6 20:20:00 UTC 2017

Thanks in advance,

-Rod

After some dealing I solved the problem above, but it persists having a new error message that follows (only on Linux, Windows is running well):

[INFO] Installed Yarn locally.
[INFO]
[INFO] --- frontend-maven-plugin:1.6:yarn (yarn install) @ timetrack ---
[INFO] Running 'yarn install' in /home/rodrigo/test/TimeTrack
[INFO] yarn install v1.2.1
[INFO] [1/5] Validating package.json...
[INFO] [2/5] Resolving packages...
[INFO] [3/5] Fetching packages...
[INFO] info fsevents@1.1.2: The platform "linux" is incompatible with this modul                       e.
[INFO] info "fsevents@1.1.2" is an optional dependency and failed compatibility                        check. Excluding it from installation.
[INFO] [4/5] Linking dependencies...
[ERROR] warning "bootstrap@4.0.0-beta" has unmet peer dependency "popper.js@^1.1                       1.0".
[ERROR] warning "@schematics/angular@0.0.49" has incorrect peer dependency "@ang                       ular-devkit/schematics@0.0.34".
[ERROR] warning "license-webpack-plugin@1.1.1" has unmet peer dependency "webpac                       k-sources@>=1.0.0".
[INFO] [5/5] Building fresh packages...
[INFO] Done in 40.25s.
[INFO]
[INFO] --- frontend-maven-plugin:1.6:yarn (webpack build prod) @ timetrack ---
[INFO] Running 'yarn run webpack:prod' in /home/rodrigo/test/TimeTrack
[INFO] yarn run v1.2.1
[INFO] $ yarn run cleanup && yarn run webpack:prod:main && yarn run clean-www
[ERROR] warning From Yarn 1.0 onwards, scripts don't require "--" for options to                        be forwarded. In a future version, any explicit "--" will be forwarded as-is to                        the scripts.
[INFO]
[INFO] <--- Last few GCs --->
[INFO]
[INFO]       28 ms: Mark-sweep 1.4 (5.5) -> 1.3 (5.5) MB, 1.2 / 0.0 ms [allocati                       on failure] [GC in old space requested].
[INFO]       29 ms: Mark-sweep 1.3 (5.5) -> 1.3 (5.5) MB, 1.2 / 0.0 ms [allocati                       on failure] [GC in old space requested].
[INFO]       30 ms: Mark-sweep 1.3 (5.5) -> 1.3 (5.5) MB, 1.2 / 0.0 ms [allocati                       on failure] [GC in old space requested].
[INFO]       32 ms: Mark-sweep 1.3 (5.5) -> 1.3 (4.5) MB, 1.2 / 0.0 ms [last res                       ort gc].
[INFO]       33 ms: Mark-sweep 1.3 (4.5) -> 1.3 (4.5) MB, 1.2 / 0.0 ms [last res                       ort gc].
[INFO]
[INFO]
[INFO] <--- JS stacktrace --->
[INFO]
[INFO] ==== JS stack trace =========================================
[INFO]
[INFO] Security context: 0x3957b609 <JS Object>
[INFO]     1: /* anonymous */(aka /* anonymous */) [fs.js:10] [pc=0x29d1d25d] (t                       his=0x395081d9 <undefined>,exports=0x3d777f45 <an Object with map 0x4e409cad>,re                       quire=0x39585bf1 <JS Function NativeModule.require (SharedFunctionInfo 0x3958425                       d)>,module=0x3d777f11 ,__filename=0x3d777f31                        <String[5]: fs.js>,__dirname=0x395081d9 <undefined>)
[INFO]     2: arguments adaptor frame: 4-...
[INFO]
[ERROR] FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out                        of memory
[ERROR]  1: node::Abort() [node]
[ERROR]  2: 0x8c80076 [node]
[ERROR]  3: v8::Utils::ReportApiFailure(char const*, char const*) [node]
[ERROR]  4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [node]
[ERROR]  5: v8::internal::Factory::NewMap(v8::internal::InstanceType, int, v8::i                       nternal::ElementsKind) [node]
[ERROR]  6: v8::internal::Map::RawCopy(v8::internal::Handle<v8::internal::Map>,                        int) [node]
[ERROR]  7: v8::internal::Map::CopyDropDescriptors(v8::internal::Handle<v8::inte                       rnal::Map>) [node]
[ERROR]  8: v8::internal::Map::CopyReplaceDescriptors(v8::internal::Handle<v8::i                       nternal::Map>, v8::internal::Handle<v8::internal::DescriptorArray>, v8::internal                       ::Handle<v8::internal::LayoutDescriptor>, v8::internal::TransitionFlag, v8::inte                       rnal::MaybeHandle<v8::internal::Name>, char const*, v8::internal::SimpleTransiti                       onFlag) [node]
[ERROR]  9: v8::internal::Map::CopyAddDescriptor(v8::internal::Handle<v8::intern                       al::Map>, v8::internal::Descriptor*, v8::internal::TransitionFlag) [node]
[ERROR] 10: v8::internal::Map::CopyWithConstant(v8::internal::Handle<v8::interna                       l::Map>, v8::internal::Handle<v8::internal::Name>, v8::internal::Handle<v8::inte                       rnal::Object>, v8::internal::PropertyAttributes, v8::internal::TransitionFlag) [                       node]
[ERROR] 11: v8::internal::Map::TransitionToDataProperty(v8::internal::Handle<v8:                       :internal::Map>, v8::internal::Handle<v8::internal::Name>, v8::internal::Handle<                       v8::internal::Object>, v8::internal::PropertyAttributes, v8::internal::Object::S                       toreFromKeyed) [node]
[ERROR] 12: v8::internal::LookupIterator::PrepareTransitionToDataProperty(v8::in                       ternal::Handle<v8::internal::JSObject>, v8::internal::Handle<v8::internal::Objec                       t>, v8::internal::PropertyAttributes, v8::internal::Object::StoreFromKeyed) [nod                       e]
[ERROR] 13: v8::internal::Object::AddDataProperty(v8::internal::LookupIterator*,                        v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyAttributes, v                       8::internal::Object::ShouldThrow, v8::internal::Object::StoreFromKeyed) [node]
[ERROR] 14: v8::internal::JSObject::AddProperty(v8::internal::Handle<v8::interna                       l::JSObject>, v8::internal::Handle<v8::internal::Name>, v8::internal::Handle<v8:                       :internal::Object>, v8::internal::PropertyAttributes) [node]
[ERROR] 15: v8::internal::Factory::NewFunction(v8::internal::Handle<v8::internal                       ::String>, v8::internal::Handle<v8::internal::Code>, v8::internal::Handle<v8::in                       ternal::Object>, v8::internal::InstanceType, int, bool, bool, bool) [node]
[ERROR] 16: v8::internal::ApiNatives::CreateApiFunction(v8::internal::Isolate*,                        v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v                       8::internal::Object>, v8::internal::ApiNatives::ApiInstanceType) [node]
[ERROR] 17: 0x8554502 [node]
[ERROR] 18: v8::internal::ApiNatives::InstantiateFunction(v8::internal::Handle<v                       8::internal::FunctionTemplateInfo>) [node]
[ERROR] 19: v8::FunctionTemplate::GetFunction(v8::Local<v8::Context>) [node]
[ERROR] 20: v8::FunctionTemplate::GetFunction() [node]
[ERROR] 21: node::InitFs(v8::Local<v8::Object>, v8::Local<v8::Value>, v8::Local<                       v8::Context>, void*) [node]
[ERROR] 22: 0x8c858a0 [node]
[ERROR] 23: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionC                       allbackInfo<v8::Value> const&)) [node]
[ERROR] 24: 0x85b3630 [node]
[ERROR] 25: 0x85b3dd0 [node]
[ERROR] 26: 0x4890a0fe
[ERROR] 27: 0x29d1d25d
[ERROR] 28: 0x4890b616
[ERROR] 29: 0x489384a8
[ERROR] 30: 0x48937d7f
[ERROR] 31: 0x29d1b14f
[ERROR] 32: 0x4890b616
[ERROR] 33: 0x489384a8
[ERROR] 34: 0x48937d7f
[ERROR] 35: 0x48937411
[ERROR] 36: 0x48936335
[ERROR] 37: 0x4893153e
[ERROR] 38: 0x48920a43
[ERROR] 39: v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::                       Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v                       8::internal::Handle<v8::internal::Object>*) [node]
[ERROR] 40: v8::Function::Call(v8::Local<v8::Context>, v8::Local<v8::Value>, int                       , v8::Local<v8::Value>*) [node]
[ERROR] 41: v8::Function::Call(v8::Local<v8::Value>, int, v8::Local<v8::Value>*)                        [node]
[ERROR] 42: node::LoadEnvironment(node::Environment*) [node]
[ERROR] 43: node::Start(int, char**) [node]
[ERROR] 44: main [node]
[ERROR] 45: __libc_start_main [/lib/i386-linux-gnu/libc.so.6]
[ERROR] Aborted (core dumped)
[ERROR] error Command failed with exit code 134.
[ERROR] error Command failed with exit code 1.
[ERROR] error Command failed with exit code 1.
[INFO] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about th                       is command.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 03:09 min
[INFO] Finished at: 2017-11-14T19:58:35+13:00
[INFO] Final Memory: 31M/74M
[INFO] ------------------------------------------------------------------------

Someone has any help?

Regards,

-Rod


来源: stackexchange

问:
Extension method to exclude records whose id exists anywhere in another field
I have a requirement to get the data from a table.

This is the structure of the table:

ID      PackageID     DESC  OriginalPackageID    Status
-------------------------------------------------------
1          00A        Test        Null             P

2          00B        xxxx        Null             P

3          00A        test1        1               W
```

I want to write a linq query using the extension method to fetch the records with Status = P but whose ID doesn't exist in any of the records' OriginalPackageID.

For example, the record with ID = 1 has Status = P, but 1 is the third record's OriginalPackageID. So the first record should be excluded. Only the second record should be returned.

答:
So you want all records from your table that have a Status equal to P and of which there is not any element in the table that has a value of OriginalPackageId equal to the ID of the record.

This description already says how to do this, although I'm not sure whether it is efficient:

```<code>IEnumerable<MyClass> table = ...
var result = table
    .Where(record => record.Status == P
       && !table.Any(item => item.OriginalPackageId == record.Id));
</code>```

This is not efficient, befause for every record it will potentially have to check the complete table to check that its ID is not used as OriginalPackageId.

Luckily you don't care which record has a value of OriginalPackageId that equals your record's ID. Therefore you don't have to remember which record has this OriginalPackageId value.

You only need to remember that any record uses this OriginalPackageId value.

So let's first put the used OriginalPackageIds in a HashSet<int> object. This will cost you one pass on the elements of the table:

```<code>IEnumerable<int> allOriginalPackageIds = table
   .Select(record => record.OriginalPackageId);
HashSet<int> usedPackageIds = new HashSet<int>(allOriginalPackageIds);
</code>```

The constructor of the HashSet will remove duplicates.

Now you can use HashSet.Contains to lookup if the ID is used in any OriginalPackageID. This is a very fast function.

Your extension function will be like:

```<code>public static IEnumerable<MyClass> ExtractOriginalItems(
    this IEnumerable<MyClass> table)
{
    IEnumerable<int> allOriginalPackageIds = table
       .Select(record => record.OriginalPackageId);
    HashSet<int> usedPackageIds = new HashSet<int>(allOriginalPackageIds);

    foreach(var record in table)
    {
        // return elements with status P and not ID in hashset:
        if (record.Status == P && !usedPackageIds.Contains(record.Id))
        {
            yield return record;
        }
    }
}
</code>```

Creating the HashSet is O(1)
ForEach is O(1)

ContentLicense: CC BY-SA 3.0

Body:
I have a requirement to get the data from a table.

This is the structure of the table:

ID      PackageID     DESC  OriginalPackageID    Status
-------------------------------------------------------
1          00A        Test        Null             P

2          00B        xxxx        Null             P

3          00A        test1        1               W

I want to write a linq query using the extension method to fetch the records with Status = P but whose ID doesn't exist in any of the records' OriginalPackageID.

For example, the record with ID = 1 has Status = P, but 1 is the third record's OriginalPackageID. So the first record should be excluded. Only the second record should be returned.

Body:
So you want all records from your table that have a Status equal to P and of which there is not any element in the table that has a value of OriginalPackageId equal to the ID of the record.

This description already says how to do this, although I'm not sure whether it is efficient:

IEnumerable<MyClass> table = ...
var result = table
    .Where(record => record.Status == P
       && !table.Any(item => item.OriginalPackageId == record.Id));

This is not efficient, befause for every record it will potentially have to check the complete table to check that its ID is not used as OriginalPackageId.

Luckily you don't care which record has a value of OriginalPackageId that equals your record's ID. Therefore you don't have to remember which record has this OriginalPackageId value.

You only need to remember that any record uses this OriginalPackageId value.

So let's first put the used OriginalPackageIds in a HashSet<int> object. This will cost you one pass on the elements of the table:

IEnumerable<int> allOriginalPackageIds = table
   .Select(record => record.OriginalPackageId);
HashSet<int> usedPackageIds = new HashSet<int>(allOriginalPackageIds);

The constructor of the HashSet will remove duplicates.

Now you can use HashSet.Contains to lookup if the ID is used in any OriginalPackageID. This is a very fast function.

Your extension function will be like:

public static IEnumerable<MyClass> ExtractOriginalItems(
    this IEnumerable<MyClass> table)
{
    IEnumerable<int> allOriginalPackageIds = table
       .Select(record => record.OriginalPackageId);
    HashSet<int> usedPackageIds = new HashSet<int>(allOriginalPackageIds);

    foreach(var record in table)
    {
        // return elements with status P and not ID in hashset:
        if (record.Status == P && !usedPackageIds.Contains(record.Id))
        {
            yield return record;
        }
    }
}

Creating the HashSet is O(1)
ForEach is O(1)


问:
Pass a render function via property definition of custom control
I have built a custom control which renders an arraylist of java objects via a repeat control. Via the property definition I can provide which fields from the underlying java object I want to display. In the back-end I read this value e.g. via

```<code>obj[compositeData.columnField1]
</code>```

This works well with static data, but sometimes I want to format the before rendering e.g. when the field contains a notesname and I only want to display the commonname.

I am wondering how I could set up something like that.

Now I am only passing the field name, which will be picked up by the cc to read the value.

E.g. for the jQuery DataTables plugin you can define a render function for a column and use the data variable of that column within that render function (e.g. build an anchor link or button in that column).

Can I provide something similar for SSJS e.g. I pass the render function as text (or object?) and in the back-end it will be transformed to ssjs.

答:
Considering you would likely want to re-use the component in many contexts of your app I would approach the problem with an helper class and interface

```<code>public class FieldManager {

  public static interface FieldDetail {
     String getName();
     void getAction();
  }

  private List<FieldDetail> fieldDetails = new List<FieldDetail>();

  public FieldManager() {

  }

  public FieldManager(List<FieldDetail> fieldDetails) {
    this.fieldDetails.addAll(fieldDetails);
  }

  public void addFieldDetail(FieldDetail fieldDetail) {
    this.fieldDetails.add(fieldDetail);
  }

  public List<FieldDetail> getFieldDetails() {
    return fieldDetails;
  }

}
</code>```

With this succinct definition you could now be able to implement the FieldDetail interface with a generic class or alternative specialized classes.

Then in the custom control you set a property as value or whatever, the <property-class> tag will be FieldManager and in the custom control you would know how everything plays out because the class FieldManager and the FieldDetail are the contract for you.

```<code><xp:repeat disableOutputTag="true"
        value="#{compositeData.value.fieldDetails}" var="fieldDetail">
    <xp:link text="#{fieldDetail.name}">
        <xp:eventHandler event="onclick" submit="true"
                refreshMode="partial" refreshId="pnlContainer"
                action="#{fieldDetail.action}">
        </xp:eventHandler>
    </xp:link>
</xp:repeat>
</code>```

Or whatever your code might be. Anyway, that's the gist of it.

Body:
I have built a custom control which renders an arraylist of java objects via a repeat control. Via the property definition I can provide which fields from the underlying java object I want to display. In the back-end I read this value e.g. via

obj[compositeData.columnField1]

This works well with static data, but sometimes I want to format the before rendering e.g. when the field contains a notesname and I only want to display the commonname.

I am wondering how I could set up something like that.

Now I am only passing the field name, which will be picked up by the cc to read the value.

E.g. for the jQuery DataTables plugin you can define a render function for a column and use the data variable of that column within that render function (e.g. build an anchor link or button in that column).

Can I provide something similar for SSJS e.g. I pass the render function as text (or object?) and in the back-end it will be transformed to ssjs.

Body:
Considering you would likely want to re-use the component in many contexts of your app I would approach the problem with an helper class and interface

public class FieldManager {

  public static interface FieldDetail {
     String getName();
     void getAction();
  }

  private List<FieldDetail> fieldDetails = new List<FieldDetail>();

  public FieldManager() {

  }

  public FieldManager(List<FieldDetail> fieldDetails) {
    this.fieldDetails.addAll(fieldDetails);
  }

  public void addFieldDetail(FieldDetail fieldDetail) {
    this.fieldDetails.add(fieldDetail);
  }

  public List<FieldDetail> getFieldDetails() {
    return fieldDetails;
  }

}

With this succinct definition you could now be able to implement the FieldDetail interface with a generic class or alternative specialized classes.

Then in the custom control you set a property as value or whatever, the <property-class> tag will be FieldManager and in the custom control you would know how everything plays out because the class FieldManager and the FieldDetail are the contract for you.

<xp:repeat disableOutputTag="true"
        value="#{compositeData.value.fieldDetails}" var="fieldDetail">
    <xp:link text="#{fieldDetail.name}">
        <xp:eventHandler event="onclick" submit="true"
                refreshMode="partial" refreshId="pnlContainer"
                action="#{fieldDetail.action}">
        </xp:eventHandler>
    </xp:link>
</xp:repeat>

Or whatever your code might be. Anyway, that's the gist of it.


问:
Elixir Get Map containing maximum values of specific field
I'm a beginner in Elixir programming language.

I have an object something like this:

```<code>{
  id: uuid,
  created_at: DateTime.t,
  updated_at: DateTime.t,
  type: my_type
}
</code>```

let's say my_type is one of ~w[A B C D]

I want to write a function which takes a list of these objects and returns a following map:

```<code>%{
  A: 120,
  B: 220,
  C: 560,
  D: 0,
  any: 560
}
</code>```

The values here has to be the MAXIMUM difference between updated_at and created_at columns(Timex.diff(updated_at, created_at, :seconds)) per my_type + any in addition.
In case of any the my_type is not considered and takes the maximum among all objects in the list.

What is the best way to do it in Elixir? Thanks.

答:
I am posting this here for the sake of formatting and diversity. The answer by @Dogbert is likely better fit, although this approach could be more straightforward and arguably flexible.

list = [%{type: :a, v1: 10, v2: 20},
        %{type: :a, v1: 10, v2: 30},
        %{type: :b, v1: 10, v2: 20},
        %{type: :c, v1: 10, v2: 20}]

kw = for %{type: t, v1: v1, v2: v2} <- list,
       do: {t, v2 - v1}, into: []
#⇒ [a: 10, a: 20, b: 10, c: 10]

kw
|> Enum.sort_by(fn {_, v} -> v end, &>=/2)
|> Enum.uniq_by(fn {k, _} -> k end)
#⇒ [a: 20, b: 10, c: 10]
```

Body:
I'm a beginner in Elixir programming language.

I have an object something like this:

{
  id: uuid,
  created_at: DateTime.t,
  updated_at: DateTime.t,
  type: my_type
}

let's say my_type is one of ~w[A B C D]

I want to write a function which takes a list of these objects and returns a following map:

%{
  A: 120,
  B: 220,
  C: 560,
  D: 0,
  any: 560
}

The values here has to be the MAXIMUM difference between updated_at and created_at columns(Timex.diff(updated_at, created_at, :seconds)) per my_type + any in addition.
In case of any the my_type is not considered and takes the maximum among all objects in the list.

What is the best way to do it in Elixir? Thanks.


问:
Implement glitter effect in iOS Camera?
I have implement glitter effect for capture camera photo and recored videos in iOS devices.

.

I have prefer many links for implement glitter effect in photo, but I have implement in active camera in capture photo or recored video times.

.

Give some suggestion and library for implement glitter effect in active camera in iOS devices....

答:
You might use Twinkle. Twinkle is available and recommended for installation using the Cocoa dependency manager CocoaPods. You can also simply copy the Twinkle.swift file into your Xcode project.

```<code>import Twinkle
import UIKit

// UIView extension
let view: UIView = UIView(frame: CGRect(x: 0, y: 0, width: 640, height: 480))
self.view.addSubview(view)
view.twinkle()

// class function
Twinkle.twinkle(myView)
</code>```

Here's a github link for downloading: https://github.com/piemonte/Twinkle

This library creates several CAEmitterLayers and animates them generating a sparkle (aka glitter) effect.

```<code>let emitterCells: [CAEmitterCell] = [CAEmitterCell(), CAEmitterCell()]

for cell in emitterCells {

    cell.birthRate = 8
    cell.lifetime = 1.25
    cell.lifetimeRange = 0
    cell.emissionRange = (.pi / 4)
    cell.velocity = 2
    cell.velocityRange = 18
    cell.scale = 0.65
    cell.scaleRange = 0.7
    cell.scaleSpeed = 0.6
    cell.spin = 0.9
    cell.spinRange = .pi
    cell.color = UIColor(white: 1.0, alpha: 0.3).cgColor
    cell.alphaSpeed = -0.8
    cell.contents = twinkleImage?.cgImage
    cell.magnificationFilter = TwinkleLayerMagnificationFilter
    cell.minificationFilter = TwinkleLayerMinificationFilter
    cell.isEnabled = true
}
</code>```

Title: Implement glitter effect in iOS Camera?

Body:
You might use Twinkle. Twinkle is available and recommended for installation using the Cocoa dependency manager CocoaPods. You can also simply copy the Twinkle.swift file into your Xcode project.

import Twinkle
import UIKit

// UIView extension
let view: UIView = UIView(frame: CGRect(x: 0, y: 0, width: 640, height: 480))
self.view.addSubview(view)
view.twinkle()

// class function
Twinkle.twinkle(myView)

Here's a github link for downloading: https://github.com/piemonte/Twinkle

This library creates several CAEmitterLayers and animates them generating a sparkle (aka glitter) effect.

let emitterCells: [CAEmitterCell] = [CAEmitterCell(), CAEmitterCell()]

for cell in emitterCells {

    cell.birthRate = 8
    cell.lifetime = 1.25
    cell.lifetimeRange = 0
    cell.emissionRange = (.pi / 4)
    cell.velocity = 2
    cell.velocityRange = 18
    cell.scale = 0.65
    cell.scaleRange = 0.7
    cell.scaleSpeed = 0.6
    cell.spin = 0.9
    cell.spinRange = .pi
    cell.color = UIColor(white: 1.0, alpha: 0.3).cgColor
    cell.alphaSpeed = -0.8
    cell.contents = twinkleImage?.cgImage
    cell.magnificationFilter = TwinkleLayerMagnificationFilter
    cell.minificationFilter = TwinkleLayerMinificationFilter
    cell.isEnabled = true
}

ContentLicense: CC BY-SA 4.0


问:
convert list of lists with time strings to seconds and find count times between
I have a list of lists with time strings in them (this format "17:04:20"). I want to iterate through the list and count the times with a gap of 5 minutes or greater.

```<code>Eg. [[],[],["17:03:22","17:08:54","17:50:33","17:55:20"],[]]
</code>```

In this case the gap would be from 17:08:54 + 5 minutes until 17:50:33.

I've been trying to do this by replacing the : in  the time strings and then turning the value into seconds and putting them sorted into a list of lists. Then I wanted to go through the list and if the next value is more than 300 seconds record this value.

Im having trouble even changing the strings to second can anyone help ?

答:
Searching arbitrary nested lists can be done with a recursive function

```<code>def gap_count(lst):

    count = 0
    timetag_pair = []

    for elem in lst:

        if isinstance(elem, list):

            # Recursive use of gap_count when a nested list is encountered.
            count += gap_count(elem)

        elif isinstance(elem, str):

            timetag_pair.append(datetime.strptime(elem, '%H:%M:%S'))

        if len(timetag_pair) == 2:

            if abs((timetag_pair[0].minute + timetag_pair[0].second / 60.0) -
                   (timetag_pair[1].minute + timetag_pair[1].second / 60.0)) >= 5:

                count += 1

            timetag_pair = []

    return count
</code>```

If you call gap_count with your test list it should return 1.

```<code>lst = [[],[],["17:03:22","17:08:54","17:50:33","17:55:20"],[]]
gap_count(lst)
> 1
</code>```

Body:
I have a list of lists with time strings in them (this format "17:04:20"). I want to iterate through the list and count the times with a gap of 5 minutes or greater.

Eg. [[],[],["17:03:22","17:08:54","17:50:33","17:55:20"],[]]

In this case the gap would be from 17:08:54 + 5 minutes until 17:50:33.

I've been trying to do this by replacing the : in  the time strings and then turning the value into seconds and putting them sorted into a list of lists. Then I wanted to go through the list and if the next value is more than 300 seconds record this value.

Im having trouble even changing the strings to second can anyone help ?

Body:
Searching arbitrary nested lists can be done with a recursive function

def gap_count(lst):

    count = 0
    timetag_pair = []

    for elem in lst:

        if isinstance(elem, list):

            # Recursive use of gap_count when a nested list is encountered.
            count += gap_count(elem)

        elif isinstance(elem, str):

            timetag_pair.append(datetime.strptime(elem, '%H:%M:%S'))

        if len(timetag_pair) == 2:

            if abs((timetag_pair[0].minute + timetag_pair[0].second / 60.0) -
                   (timetag_pair[1].minute + timetag_pair[1].second / 60.0)) >= 5:

                count += 1

            timetag_pair = []

    return count

If you call gap_count with your test list it should return 1.

lst = [[],[],["17:03:22","17:08:54","17:50:33","17:55:20"],[]]
gap_count(lst)
> 1


问:
Merging PDF's using Ghostscript outputs as grayscale / loses color
I have a script which takes a base64 string and converts it into a png image. I then use Imagick to to convert the png into a pdf which uses a AdobeRGB1998 icc profile. This all works as expected and creates a color pdf.

```<code>$data = str_replace("data:image/png;base64,","",$_POST["rsa"]);
$save = $path.$_POST["pdfname"].".png";

$imagick = new Imagick();
$decoded = base64_decode($data);
$imagick->readimageblob($decoded);
$imagick->writeImage($save);
$imagick->clear();
$imagick->destroy();

    exec("convert $path.$_POST["pdfname"].".png -profile AdobeRGB1998.icc -density 300 ".$path.".$_POST["pdfname"].".pdf", $array);
</code>```

However, when I then use Ghostscript to merge a bunch of these PDFs together using the below code it outputs in grayscale and I'm not sure why.

```<code>function getPDFs($e)
{
return $path.$e['pdffilename'].".pdf ";
}
$fileArray = array_map("getPDFs(", $_POST['item']);
$outputName = $path."LatestDispatch.pdf";
$cmd = "gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$outputName ";
foreach($fileArray as $file) {
    $cmd .= $file." ";
}
$result = shell_exec($cmd);
</code>```

I switched to using Ghostscript as opposed to imagick to merge pdfs. Imagick returned a merged color pdf but seemed to hit a limit as to how many PDF's imagick was able to merge at once. Ghostscript doesn't have any problems or limits as to how many PDFs it merges so would like to continue with this method as opposed to Imagick, however I need to resolve this issue of PDF's outputting in grayscale, not color. Can anyone help please?

Thanks!

答:
First; Ghostscript doesn't 'merge' PDF files. When you present it with a list of PDF files as input, and use the pdfwrite device to output a single PDF file, it isn't 'merging' the PDF files.

What happens is that each PDF file is fully interpreted to produce a sequence of marking operations, these operations are then passed to the device. For rendering devices they render a bitmap. For PDF output, they are emitted as PDF equivalent operations.

So the content of the output PDF file bears no relation to the content of the input files. The appearance should be the same, but its not 'merging'.

You haven't said what version of Ghostscript you are using, or where you sourced it from (or even what OS you are using, but I guess some flavour of Linux). There's nothing obviously wrong with the command line, but if I were you I'd start by not using a script. Just use Ghostscript manually from the shell to see what happens. If that works, ans the script doesn't, then there's something wrong with the script, and you aren't mimicking it properly from teh shell. Have the script print out the precise command line and try to see if there's some difference in what you typed at the shell.

If it behaves the same, then its puzzling. But without some example to look at, there's little I can advise.

Body:
I have a script which takes a base64 string and converts it into a png image. I then use Imagick to to convert the png into a pdf which uses a AdobeRGB1998 icc profile. This all works as expected and creates a color pdf.

$data = str_replace("data:image/png;base64,","",$_POST["rsa"]);
$save = $path.$_POST["pdfname"].".png";

$imagick = new Imagick();
$decoded = base64_decode($data);
$imagick->readimageblob($decoded);
$imagick->writeImage($save);
$imagick->clear();
$imagick->destroy();

    exec("convert $path.$_POST["pdfname"].".png -profile AdobeRGB1998.icc -density 300 ".$path.".$_POST["pdfname"].".pdf", $array);

However, when I then use Ghostscript to merge a bunch of these PDFs together using the below code it outputs in grayscale and I'm not sure why.

function getPDFs($e)
{
return $path.$e['pdffilename'].".pdf ";
}
$fileArray = array_map("getPDFs(", $_POST['item']);
$outputName = $path."LatestDispatch.pdf";
$cmd = "gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$outputName ";
foreach($fileArray as $file) {
    $cmd .= $file." ";
}
$result = shell_exec($cmd);

I switched to using Ghostscript as opposed to imagick to merge pdfs. Imagick returned a merged color pdf but seemed to hit a limit as to how many PDF's imagick was able to merge at once. Ghostscript doesn't have any problems or limits as to how many PDFs it merges so would like to continue with this method as opposed to Imagick, however I need to resolve this issue of PDF's outputting in grayscale, not color. Can anyone help please?

Thanks!


问:
SQL Maintenance Cleanup task not deleting any files, SQL installed on a DC
The generic problem is as listed here SQL Maintenance Cleanup Task Working but Not Deleting but no solutions applicable. Environment: Windows Server 2012R2, AD DS (with policies of course), RDSH/TS Licensing, 1C-server. The primary problem is SQL Server generating insane amount of events per backup plan run, recording a pair of 18456+17052 errors per file to delete. Errors are as follows:

17052: [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'DOMAIN\mssql_srv'

18456: Reason: Could not find a login matching the name provided. [CLIENT: 192.168.x.x] (matches localhost)

Given that each pair of errors appears once per file to delete (there are about 6000 files already!), the algorithm looks like this:

First, backup plan task runs xp_delete_file, it enumerates all the files in target folder;

Second, each file is deleted by creating a separate connection to machine with service's credentials;

Each connection fails due to whatever restrictions default DC policy applies, generating the pair of events. Of course the file remains in place.

The workaround is of course assign file delete task to a local script run as system, for example, but the very reason of why does SQL server fail to delete a file remains unknown. Permissions have been checked and verified that both SQL Server Agent and SQL Server service accounts have full control to the folder.

答:
It turned out that this "login missing" is not a Windows login, but rather SQL "login" which was not present for the service account. So I needed to create a "DOMAIN\mssql_srv" login in SSMS, give it "public" access rights and voila, files started to get deleted properly. The reason is explained in comment:

If it's T-SQL step and job owner is member of sysadmin server role, the step is executed under service account.


问:
Where can I find the graph of TeX's error log?
In Donald Knuth's Literate Programming, there was if I remember correctly a graph showing the evolution of TeX's number of bugs over time. This graph has remained flat for the past decade or so, suggesting that TeX might now be bug-free.

I would like to use this graph to illustrate the importance of bug-tracking software. Is it downloadable from somewhere?

答:
Side Note:
Code is never 'bug free'. There are only "Expected quirks" and "Bugs yet to be discovered". </p>

OwnerDisplayName: lindelof

ContentLicense: CC BY-SA 2.5

OwnerDisplayName: Kent Fredric


问:
Change value of a segmented control?
How do i change the value of a segmented control through code?</p>

答:
```<code>UISegmentedControl *cont;
.....
cont.selectedSegmentIndex = 4; //Selected index you want;
</code>```

Title: Change value of a segmented control?


问:
How to give boolean value to html in angular?
How do i give the showProduct:boolean = false; value to the app-product html selector so it will be false at start?

showProduct:boolean = false;```
<pre class="snippet-code-html lang-html prettyprint-override"><code><button (click)="showProduct=!showProduct">Show Product</button>
<div *ngIf="!showProduct">
    <app-product></app-product>
</div></code>```

答:
I think you need
,

```<code><button (click)="showProduct=!showProduct">Show Product</button>
<div *ngIf="showProduct">
    <app-product></app-product>
</div>
</code>```

Body:
How do i give the showProduct:boolean = false; value to the app-product html selector so it will be false at start?

showProduct:boolean = false;

<button (click)="showProduct=!showProduct">Show Product</button>

    <app-product></app-product>

Body:
I think you need <div *ngIf="showProduct">,

<button (click)="showProduct=!showProduct">Show Product</button>
<div *ngIf="showProduct">
    <app-product></app-product>
</div>


问:
Excel-VBA: Change the Filter of only one Pivot-Table
i'm searching for a soluton for this:

I have a wookbook, in which are multiple sheets, in which are multiple pivot-tables. I simply want to change the Filter of only one specific pivot-table.

If I use the ActiveSheet-Method this seems to work but this Sheet is not active when I start this code, so I try to change this filter by adressing it:

```<code>Sub Jahresübergang2()

Dim Jahresuebergang2 As Worksheet
    Set Jahresuebergang2 = Worksheets(11)

Jahresuebergang2.PivotTables("Name of Pivot Table").PivotFields("[Incident resolved].[Period].[Year]").VisibleItemsList = Array("[Incident resolved].[Period].[Year].&[2017]")

End Sub
</code>```

I get Runtime-Error 1004: Run-time error '1004': Method 'PivotTables' of object '_worksheet' failed

It's like I am doint the wrong object-syntax to change filters of only one table.

Here is what the makro recorder is doing:

```<code>Sub Makro1()
'
' Makro1 Makro
'

'
    ActiveSheet.PivotTables("Name of Pivot Table").PivotFields( _
        "[Incident resolved].[Year].[Year]").ClearAllFilters
    ActiveSheet.PivotTables("Name of Pivot Table").PivotFields( _
        "[Incident resolved].[Year].[Year]").CurrentPageName = _
        "[Incident resolved].[Year].&[2017]"
End Sub
</code>```

You see: I don't want to use the activesheet method, due this sheet isn't active when I want to perform this makro.

Thanks a lot for your help!

PS: I use Excel 365

答:
Here my Solution:

TabelleX.Activate (X for the Number of the Sheet)

to activate the sheet. The only problem may be that this sheet will be active on the monitor during the makro-process. I solved this with:

Application.ScreenUpdating = False
(Code)
Application.ScreenUpdating = True

so activation won't be updated on the screen.

Body:
i'm searching for a soluton for this:

I have a wookbook, in which are multiple sheets, in which are multiple pivot-tables. I simply want to change the Filter of only one specific pivot-table.

If I use the ActiveSheet-Method this seems to work but this Sheet is not active when I start this code, so I try to change this filter by adressing it:

Sub Jahresübergang2()

Dim Jahresuebergang2 As Worksheet
    Set Jahresuebergang2 = Worksheets(11)

Jahresuebergang2.PivotTables("Name of Pivot Table").PivotFields("[Incident resolved].[Period].[Year]").VisibleItemsList = Array("[Incident resolved].[Period].[Year].&[2017]")

End Sub

I get Runtime-Error 1004: Run-time error '1004': Method 'PivotTables' of object '_worksheet' failed

It's like I am doint the wrong object-syntax to change filters of only one table.

Here is what the makro recorder is doing:

Sub Makro1()
'
' Makro1 Makro
'

'
    ActiveSheet.PivotTables("Name of Pivot Table").PivotFields( _
        "[Incident resolved].[Year].[Year]").ClearAllFilters
    ActiveSheet.PivotTables("Name of Pivot Table").PivotFields( _
        "[Incident resolved].[Year].[Year]").CurrentPageName = _
        "[Incident resolved].[Year].&[2017]"
End Sub

You see: I don't want to use the activesheet method, due this sheet isn't active when I want to perform this makro.

Thanks a lot for your help!

PS: I use Excel 365


问:
increase speed for MySQL JOIN for two large tables
I have to JOIN to large tables in a MySQL query and it takes really long - approximately 180 seconds.  Are there any tips for optimizing a merge?

My table has 10 fields.  I am only using 4 in the query - all strings.  Table has about 600,000 rows and the result should have about 50 rows.

The four used rows are: Title, Variables, Location, Date

Here is my query:

```<code>SELECT DISTINCT t1.Title, t1.Variables FROM `MyTABLE` t1 JOIN `MyTABLE` t2
USING (Title,  Variables)
WHERE (t1.Location, t1.Date) = ('Location1', 'Date1')
AND (t2.Location, t2.Date) = ('Location2', 'Date2')
</code>```

答:
I did two separate joins and combined result using the union operator. I was getting good improvements in time.

SELECT t1.Title, t1.Variables FROMMyTABLE
t1 JOINMyTABLEt2  on (t1.Location, t1.Date) = ('Location1', 'Date1')
UNION
SELECT t1.Title, t1.Variables FROMMyTABLE
t1 JOINMyTABLEt2  on (t2.Location, t2.Date) = ('Location2', 'Date2');

Make sure that both queries have the same number of column and same data type for each column. Also, check the order of select clause.

Body:
I have to JOIN to large tables in a MySQL query and it takes really long - approximately 180 seconds.  Are there any tips for optimizing a merge?

My table has 10 fields.  I am only using 4 in the query - all strings.  Table has about 600,000 rows and the result should have about 50 rows.

The four used rows are: Title, Variables, Location, Date

Here is my query:

SELECT DISTINCT t1.Title, t1.Variables FROM `MyTABLE` t1 JOIN `MyTABLE` t2
USING (Title,  Variables)
WHERE (t1.Location, t1.Date) = ('Location1', 'Date1')
AND (t2.Location, t2.Date) = ('Location2', 'Date2')


问:
How to change shortcuts for coverage navigation in IntelliJ IDEA?
In IntelliJ IDEA, when running tests with code coverage in tracing mode, you can see if lines are fully or just partially covered. Clicking on a fully or partially covered indicator, you can see which conditions are covered and which are not.

After doing so, it is not possible to move lines in code with the "Move Line Up"/"Move Line Down" shortcuts (Shift+Alt + ↑/↓) anymore. That is because the actions "Next Fully Covered" and "Previous Fully Covered" (depicted in this image) use the same shortcuts.

I can't happen to find these actions in the IntelliJ IDEA keymap settings. Is there any way to change the shortcuts for those coverage navigation actions?

答:
Find Setting-Keymap  top-right Magnifying Glass

and press real key in "Find shortcut"

and change key


问:
Select nested sublist of a list based on condition in R
I do have the following simple example of a nested list:

```<code>list(list(structure(list(group = "a", def = "control"), .Names =  c("group",
"def"))), list(structure(list(group = "b", def = "disease1"), .Names = c("group",
"def"))))
</code>```

The structure is as follows:

```<code>str(t1)
List of 2
$ :List of 1
..$ :List of 2
.. ..$ group: chr "a"
.. ..$ def  : chr "control"
$ :List of 1
..$ :List of 2
.. ..$ group: chr "b"
.. ..$ def  : chr "disease1"
</code>```

Is there an easy way of getting only the nested list that satisfies a specific condition. As an example, if I knew only the name of the group, e.g., "a", how would I get the according sublist; in the example, this would be the first nested list:

```<code>[[1]]
[[1]]$group
[1] "a"

[[1]]$def
[1] "control"
</code>```

So essentially I am looking for a way to apply group == "a" in this nested list structure.

答:
On top of the answers already provided, I have also managed to get the correct results using "keep" from the "purrr" library: </p>

```<code>library(purrr)
get_sublist <- function(group_name) {
keep(l, function(x) x[[1]][[1]] == group_name)
}
get_sublist("b")
</code>```

Body:
I do have the following simple example of a nested list:

list(list(structure(list(group = "a", def = "control"), .Names =  c("group",
"def"))), list(structure(list(group = "b", def = "disease1"), .Names = c("group",
"def"))))

The structure is as follows:

str(t1)
List of 2
$ :List of 1
..$ :List of 2
.. ..$ group: chr "a"
.. ..$ def  : chr "control"
$ :List of 1
..$ :List of 2
.. ..$ group: chr "b"
.. ..$ def  : chr "disease1"

Is there an easy way of getting only the nested list that satisfies a specific condition. As an example, if I knew only the name of the group, e.g., "a", how would I get the according sublist; in the example, this would be the first nested list:

[[1]]
[[1]]$group
[1] "a"

[[1]]$def
[1] "control"

So essentially I am looking for a way to apply group == "a" in this nested list structure.

Body:
On top of the answers already provided, I have also managed to get the correct results using "keep" from the "purrr" library:

library(purrr)
get_sublist <- function(group_name) {
keep(l, function(x) x[[1]][[1]] == group_name)
}
get_sublist("b")


问:
AES Encryption Issue between Java and C# .Net
I've looked at countless examples on the web and in this forum and I can't find my answer.

I have a Java client that successfully encrypts and decrypts data.
I have a .Net client that successfully encrypts and decrypts data.

I put the .Net version up as a web service.  I encrypt some data in the java client and send it to the .Net web service.  I get:
--Padding is invalid and cannot be removed.--

So I make sure I'm using the same encoding, IV, Key, everything.  The only think I can figure is that I'm sending a byte array to the service.  When I spit out the array from the java client and compare it to the array that arrives at the service, as you would expect, the array at the service is different in that it's cast as an unsigned byte array.  Here are the two arrays:

[-47 17 -27 -32 -101 54 -93 47 85 -83 -31 -102 53 -125 115 -14]

[209 17 229 224 155 54 163 47 85 173 225 154 53 131 115 242]

So I'm guessing that this is causing the issue.  How can I get around this?  None of the Rijndael implementations accept signed byte arrays.  Is there a conversion I'm missing?

Thanks for any help.  I'm ready to gouge my brain out through my arse.
ST

EDIT -
After reviewing the code I found my error.  I had to copy some data and started at the wrong index.  Arrrgggghhhhhhh!

Sorry to trouble.

答:
You've got the same actual data in both cases - it's just that Java doesn't support unsigned bytes. If each platform can decrypt its own data, and you've got the same data generated by both platforms, it's hard to see how they could tell the difference.

My guess is that you're doing something differently on the .NET side. We'll need to see code to know for sure.

What happens if you try to decrypt the exact same data in the .NET client which can decrypt data? I suggest you create a small console app which just tries to decrypt a file. Make your .NET server save whatever data it's given to the file and then try to decrypt it as normal. Then run the console app on the file. Report the results here, and we'll try to help you make sense of them.


问:
"Cannot create directory" while building app post AS 3.0 upgrade
While running the build via ./gradlew check the build fails with the below stack trace. I have updated gradle to 4.1 and AS to 3.0 post which facing this issue.

What went wrong:
Execution failed for task ':app:packageDefaultGlobalIndiaOnlyDebug'.

Cannot create directory C:\Users\<>\<>\<>\app\build\outputs\apk\defaultGlobalIndiaOnly\debug\C:\Users\<>\<>\<>\app\build\outputs\apk\defaultGlobalIndiaOnly\debug\C:\Users\<>\<>\<>\app\build\outputs\apk\defaultGlobalIndiaOnly\debug

Try: Run with --info or --debug option to get more log output.

Exception is:

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:packageDefaultGlobalIndiaOnlyDebug'.
          at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
          at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
          at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
          at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
          at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
          at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
          at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
          at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
          at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
          at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
          at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
          at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
          at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
          at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
          at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
          at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
          at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
          at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
          at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124)
          at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
          at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
          at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
          at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
          at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
          at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
          at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
          at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
          at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
  Caused by: org.gradle.tooling.BuildException: Cannot create directory C:\Users\<>\<>\<>\app\build\outputs\apk\defaultGlobalIndiaOnly\debug\C:\Users\<>\<>\<>\app\build\outputs\ap
  k\defaultGlobalIndiaOnly\debug\C:\Users\<>\<>\<>\app\build\outputs\apk\defaultGlobalIndiaOnly\debug
          at com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$10(OutputScope.java:241)
          at com.android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.java:236)
          at com.android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.java:197)
          at com.android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.java:181)
          at com.android.build.gradle.tasks.PackageAndroidArtifact.doFullTaskAction(PackageAndroidArtifact.java:471)
          at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:109)
          at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
          at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:173)
          at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
          at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
          at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
          at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
          at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
          at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
          at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
          at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
          at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
          ... 27 more
  Caused by: java.lang.RuntimeException: Cannot create directory C:\Users\<>\<>\<>\app\build\outputs\apk\defaultGlobalIndiaOnly\debug\C:\Users\<>\<>\<>\app\build\outputs\apk\defau
  ltGlobalIndiaOnly\debug\C:\Users\<>\<>\<>\app\build\outputs\apk\defaultGlobalIndiaOnly\debug
          at com.android.utils.FileUtils.mkdirs(FileUtils.java:215)
          at com.android.build.gradle.tasks.PackageAndroidArtifact.doTask(PackageAndroidArtifact.java:664)
          at com.android.build.gradle.tasks.PackageAndroidArtifact.splitFullAction(PackageAndroidArtifact.java:522)
          at com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$6(OutputScope.java:186)
          at com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$7(OutputScope.java:203)
          at com.android.build.gradle.internal.scope.OutputScope.lambda$null$8(OutputScope.java:225)
          at com.android.ide.common.internal.WaitableExecutor.waitForAllTasks(WaitableExecutor.java:215)
          at com.android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.java:235)
          ... 42 more

Get more help at https://help.gradle.org

答:
Found this @ https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html

Modifying variant outputs at build time may not work

Using the Variant API to manipulate variant outputs is broken with the new plugin. It still works for simple tasks, such as changing the APK name during build time, as shown below:

```<code>// If you use each() to iterate through the variant objects,
// you need to start using all(). That's because each() iterates
// through only the objects that already exist during configuration time—
// but those object don't exist at configuration time with the new model.
// However, all() adapts to the new model by picking up object as they are
// added during execution.

    android.applicationVariants.all { variant ->
        variant.outputs.all {
            outputFileName = "${variant.name}-${variant.versionName}.apk"
        }
    }
</code>```

However, more complicated tasks that involve accessing outputFile objects no longer work. That's because variant-specific tasks are no longer created during the configuration stage. This results in the plugin not knowing all of its outputs up front, but it also means faster configuration times.

Body:
Found this @ https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html

Modifying variant outputs at build time may not work

Using the Variant API to manipulate variant outputs is broken with the new plugin. It still works for simple tasks, such as changing the APK name during build time, as shown below:

// If you use each() to iterate through the variant objects,
// you need to start using all(). That's because each() iterates
// through only the objects that already exist during configuration time—
// but those object don't exist at configuration time with the new model.
// However, all() adapts to the new model by picking up object as they are
// added during execution.

    android.applicationVariants.all { variant ->
        variant.outputs.all {
            outputFileName = "${variant.name}-${variant.versionName}.apk"
        }
    }

However, more complicated tasks that involve accessing outputFile objects no longer work. That's because variant-specific tasks are no longer created during the configuration stage. This results in the plugin not knowing all of its outputs up front, but it also means faster configuration times.


问:
Project into a (list of) concrete object instead of an (list of) anonymous object
The problem simplified is as follows: in Entity Framework i am doing a join involving 3 tables, and returning the joined result set, which involves (some) fields from the 3 tables.

```<code>var query = (
        from t1 in dbCtx.TB_Entity1
        from t2 in dbCtx.TB_Entity2
             .Where(p => p.someCol  == t1.someCol && t.IsActive == true)
             .DefaultIfEmpty() //LEFT JOIN
        from t3 in dbCtx.TB_Entity3
             .Where(q => q.someCol == t2.someCol)
        where t1.IsLatest == true
        && (t1.istatus == 2
            || t1.istatus == 3
        )
        select new {
            t1.col100,
            t1.col101,
            t2.col200,
            t2.col201,
            t3.col300,
            t3.col301
        }).OrderByDescending(t1 => t1.ID);

var anonObjList = query.ToList();
</code>```

Thus, at the end of the query I write a projection to select the fields i want.

Finally i run the query with .ToList() and get a list of Anonymous objects.

How do i modify the query to project into a List of MyConcreteClass

i.e. i want to be able to write something similar to

```<code>List<MyConcreteClass> myObjList = query.ToList();
</code>```

You may assume my concrete class looks like

```<code>public class MyConcreteClass
{
    public string Col100 { get; set; }
    public string Col101 { get; set; }
    public string Col200 { get; set; }
    public string Col201 { get; set; }
    public string Col300 { get; set; }
    public string Col301 { get; set; }
}
</code>```

答:
You just use the object initializer syntax:</p>

```<code>new MyConcreteClass
{
    Col100 = t1.col100,
    Col101 = t1.col101,
    Col200 = t2.col200,
    Col201 = t2.col201,
    Col300 = t3.col300,
    Col301 = t3.col301
}
</code>```

Body:
The problem simplified is as follows: in Entity Framework i am doing a join involving 3 tables, and returning the joined result set, which involves (some) fields from the 3 tables.

var query = (
        from t1 in dbCtx.TB_Entity1
        from t2 in dbCtx.TB_Entity2
             .Where(p => p.someCol  == t1.someCol && t.IsActive == true)
             .DefaultIfEmpty() //LEFT JOIN
        from t3 in dbCtx.TB_Entity3
             .Where(q => q.someCol == t2.someCol)
        where t1.IsLatest == true
        && (t1.istatus == 2
            || t1.istatus == 3
        )
        select new {
            t1.col100,
            t1.col101,
            t2.col200,
            t2.col201,
            t3.col300,
            t3.col301
        }).OrderByDescending(t1 => t1.ID);

var anonObjList = query.ToList();

Thus, at the end of the query I write a projection to select the fields i want.

Finally i run the query with .ToList() and get a list of Anonymous objects.

How do i modify the query to project into a List of MyConcreteClass

i.e. i want to be able to write something similar to

List<MyConcreteClass> myObjList = query.ToList();

You may assume my concrete class looks like

public class MyConcreteClass
{
    public string Col100 { get; set; }
    public string Col101 { get; set; }
    public string Col200 { get; set; }
    public string Col201 { get; set; }
    public string Col300 { get; set; }
    public string Col301 { get; set; }
}

Body:
You just use the object initializer syntax:

new MyConcreteClass
{
    Col100 = t1.col100,
    Col101 = t1.col101,
    Col200 = t2.col200,
    Col201 = t2.col201,
    Col300 = t3.col300,
    Col301 = t3.col301
}


问:
Would this std::vector push_back in OpenMP parallel region result in false-sharing?
The sample code below is a simplified version of my working code. In this code, writing to shared variable is done only at the last line where std::vector::push_back is called.

```<code>std::vector<struct FortyByteStruct> results;

#pragma omp parallel for num_threads(8)
for (int i = 0; i < 250; i++)
{
    struct FortyByteStruct result = some_heavy_work(i);

    #pragma omp critical
    {
        results.push_back(result);
    }
}
</code>```

I was wondering if this push_back operation would result in false-sharing, giving me some chance to optimize further by getting rid of it. I've decided to do some bench tests first, before digging into this issue.

With chrono, I've measured the wall clock execution time of some_heavy_work() and the critical section separately. The latter took about 10^(-4) times of execution time of the former, so I've concluded that there would be almost no benefit from optimizing this part whether false-sharing is involved or not.

Anyway, I'm still curious whether false-sharing is an issue here. Do I have to look at the internal implementation of std::vector? Any enlightment would be greatly appreciated. (I'm on VS2015)

答:
I am not an expert in std::vector implementation but I am pretty sure that it will not check if another process is writing at the same time.

Nevertheless, here is two advises:

Yes, the critical operation has a small overhead but it is negligible compared to the gain of performing 'some_heavy_work' in parallel (I guess...). So, in doubt, I would keep it there

You should check the difference between critical and atomic (openMP, atomic vs critical?).

Hope it helps

Body:
The sample code below is a simplified version of my working code. In this code, writing to shared variable is done only at the last line where std::vector::push_back is called.

std::vector<struct FortyByteStruct> results;

#pragma omp parallel for num_threads(8)
for (int i = 0; i < 250; i++)
{
    struct FortyByteStruct result = some_heavy_work(i);

    #pragma omp critical
    {
        results.push_back(result);
    }
}

I was wondering if this push_back operation would result in false-sharing, giving me some chance to optimize further by getting rid of it. I've decided to do some bench tests first, before digging into this issue.

With chrono, I've measured the wall clock execution time of some_heavy_work() and the critical section separately. The latter took about 10^(-4) times of execution time of the former, so I've concluded that there would be almost no benefit from optimizing this part whether false-sharing is involved or not.

Anyway, I'm still curious whether false-sharing is an issue here. Do I have to look at the internal implementation of std::vector? Any enlightment would be greatly appreciated. (I'm on VS2015)


问:
Pentaho Spoon Data Integration, Merge two csv
I want to merge two csv files.
The first looks like that:
url;name;api. url fields contain 50 times the same url, name is empty and api fields contain 50 times the same api key.
The second csv looks like that:
url;name;api. url is empty, name contains 50 different names, api is empty.

I want to create one csv file: url;name;api with the information from both csv, so url and api contains the value from the first and name from the second csv.

so far i just create two csv input and hooked them with one csv output. The resulting csv has 100 records, 50 with null as name and 50 with null in url and api.

.
enter image description here

enter image description here

enter image description here

答:
If you want to increase the number of columns, you need a Lookup or a Join.

You have a main stream and for each row of the stream, you fetch one row (Lookup) or many rows (Join) in the secondary stream.

In your case, I would first remove all the unnecessary field (the name in the first csv file, and the url and api in the second), and unnecessary rows (keep only one row in the first csv file). Then drop both flows in a Join Rows steps.

And, if I do understand your use case, you did probably over complicated the case, because to direct the flow in the same step (here the Text output 2) needs the columns to be the same, so that they can add the rows of the input one after the other.


问:
Aws Athena - Create external table skipping first row
I'm trying to create an external table on csv files with Aws Athena with the code below but the line TBLPROPERTIES ("skip.header.line.count"="1") doesn't work: it doesn't skip the first line (header) of the csv file.

```<code>CREATE EXTERNAL TABLE mytable
(
  colA string,
  colB int
  )

 ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'
 WITH SERDEPROPERTIES (
   'separatorChar' = ',',
   'quoteChar' = '\"',
   'escapeChar' = '\\'
   )
STORED AS TEXTFILE
LOCATION 's3://mybucket/mylocation/'
TBLPROPERTIES (
  "skip.header.line.count"="1")
</code>```

Any advise?

答: Just tried the "skip.header.line.count"="1" and seems to be working fine now.

Body:
I'm trying to create an external table on csv files with Aws Athena with the code below but the line TBLPROPERTIES ("skip.header.line.count"="1") doesn't work: it doesn't skip the first line (header) of the csv file.

CREATE EXTERNAL TABLE mytable
(
  colA string,
  colB int
  )

 ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'
 WITH SERDEPROPERTIES (
   'separatorChar' = ',',
   'quoteChar' = '\"',
   'escapeChar' = '\\'
   )
STORED AS TEXTFILE
LOCATION 's3://mybucket/mylocation/'
TBLPROPERTIES (
  "skip.header.line.count"="1")

Any advise?


问:
How to draw a box around a third party window using c#?
How to draw a rectangle around a third party window? I have got the handle to that window and have the size of window. I am  drawing a rectangle around window but that is not attached to the window when I open some other application the same rectangle appears on the top of that application. How to keep it in the background or attached with my window

Code which I am using now

```<code>IntPtr desktop = GetDC(IntPtr.Zero);
while (true)
{
  using (Graphics g = Graphics.FromHdc(desktop))
  {
    RECT rct = new RECT();
    GetWindowRect(wnd.hWnd, ref rct);
    Rectangle rect = new Rectangle(rct.Left - 2, rct.Top - 2, (rct.Right - rct.Left) + 2, (rct.Bottom - rct.Top) + 2);
    Pen myPen = new Pen(System.Drawing.Color.Red, 5);
    g.DrawRectangle(myPen, rect);
    g.Dispose();
  }
}
</code>```

Thanks

答: Handle of Main window of process wont help you always, as some application, like yahoo messenger shows secondary window. Probably you want to highlight the active window. You can get the handle of active window, once you have it, get the region it is covering, you can show your overlay at that location. </p>

Body:
How to draw a rectangle around a third party window? I have got the handle to that window and have the size of window. I am  drawing a rectangle around window but that is not attached to the window when I open some other application the same rectangle appears on the top of that application. How to keep it in the background or attached with my window

Code which I am using now

IntPtr desktop = GetDC(IntPtr.Zero);
while (true)
{
  using (Graphics g = Graphics.FromHdc(desktop))
  {
    RECT rct = new RECT();
    GetWindowRect(wnd.hWnd, ref rct);
    Rectangle rect = new Rectangle(rct.Left - 2, rct.Top - 2, (rct.Right - rct.Left) + 2, (rct.Bottom - rct.Top) + 2);
    Pen myPen = new Pen(System.Drawing.Color.Red, 5);
    g.DrawRectangle(myPen, rect);
    g.Dispose();
  }
}

Thanks


问:
Is there a way to make inline-block elements behave like table cells?
I am trying to mimic an HTML table with css classes, but the last "cell" element always gets pushed to the next line.

The way I am currently getting around this is to decrease the width of the last element by a few percent, so that the total width of the elements adds up to ~ 97%. This protects the last element from being pushed to the next line, but it doesn't look as nice because there's unused space at the end.

Is there a way to get the table cells to line up nicely and use 100% of the containing width?

.cell {
  display: inline-block;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="table" style="width: 100%">
  <div class="row" style="width: 100%">
    <div class="cell" style="width:40%">Last Name</div>
    <div class="cell" style="width:40%">First Name</div>
    <div class="cell" style="width:20%">Age</div>
  </div>
</div></code>```

答: Whilst I applaud you for using semantically correct markup, if you are displaying tabular type data, then this should be using a table.</p>

Body:
I am trying to mimic an HTML table with css classes, but the last "cell" element always gets pushed to the next line.

The way I am currently getting around this is to decrease the width of the last element by a few percent, so that the total width of the elements adds up to ~ 97%. This protects the last element from being pushed to the next line, but it doesn't look as nice because there's unused space at the end.

Is there a way to get the table cells to line up nicely and use 100% of the containing width?

.cell {
  display: inline-block;
}

Last Name

First Name

Age


问:
Oracle can't use value default if parameter is null
I have Stored Procedure

```<code>create or replace PROCEDURE  TestApi  (
     p_Contract IN varchar2,
     p_ObjID IN INT DEFAULT 0, ------ This Question
     p_Result OUT SYS_REFCURSOR
     --p_Message OUT varchar2
) IS
    p_Message varchar2(500);
Begin
    IF p_ObjID =0 THEN p_Message:= `Null`;
    ELSE  p_Message:=`Not Null`;
    END IF;
    Open p_Result For
         Select ID as "SupportListID",
                p_ObjID as "ObjID"
         FROM SupportList
         where rownum<=5 ;
End ;
</code>```

To run:

```<code> VARIABLE p_Result REFCURSOR;
 EXEC PAR.TESTAPI('PPHP0001',null,:p_Result);
 -- If i don't set Parameter with NUll , execute will cause an error
 print p_Result;
</code>```

Result:

```<code> SupportListID ObjID
------------- ---------------------------------------
107*******
107*******
107*******
107*******
107*******
</code>```

My Question : I execute SP with 1 parameter NULL , SP can get DEFAULT VALUE
NOTE : IF i  use any type data except REFCURSOR , i can get DEFAULT VALUE . Tell me how to do that  . I use OracleCommandBuilder.DeriveParameters C# to get parameter from SP Oracle

Update : I finished, use BybindNameof OracleCommand, Thanks so much everybody

答:
Simply use named parameters and omit p_ObjID:

```<code>VARIABLE p_Result REFCURSOR;
EXEC PAR.TESTAPI(p_Contract => 'PPHP0001', p_Result =>:p_Result);
</code>```

Body:
I have Stored Procedure

create or replace PROCEDURE  TestApi  (
     p_Contract IN varchar2,
     p_ObjID IN INT DEFAULT 0, ------ This Question
     p_Result OUT SYS_REFCURSOR
     --p_Message OUT varchar2
) IS
    p_Message varchar2(500);
Begin
    IF p_ObjID =0 THEN p_Message:= `Null`;
    ELSE  p_Message:=`Not Null`;
    END IF;
    Open p_Result For
         Select ID as "SupportListID",
                p_ObjID as "ObjID"
         FROM SupportList
         where rownum<=5 ;
End ;

To run:

 VARIABLE p_Result REFCURSOR;
 EXEC PAR.TESTAPI('PPHP0001',null,:p_Result);
 -- If i don't set Parameter with NUll , execute will cause an error
 print p_Result;

Result:

 SupportListID ObjID
------------- ---------------------------------------
107*******
107*******
107*******
107*******
107*******

My Question : I execute SP with 1 parameter NULL , SP can get DEFAULT VALUE
NOTE : IF i  use any type data except REFCURSOR , i can get DEFAULT VALUE . Tell me how to do that  . I use OracleCommandBuilder.DeriveParameters C# to get parameter from SP Oracle

Update : I finished, use BybindNameof OracleCommand, Thanks so much everybody

Body:
Simply use named parameters and omit p_ObjID:

VARIABLE p_Result REFCURSOR;
EXEC PAR.TESTAPI(p_Contract => 'PPHP0001', p_Result =>:p_Result);


问:
Xamarin Forms IOS open PDF
I need to open pdf file from file system.
I know how to get path to the file, but my IPhone does not open it.

I use the following code renderer:

```<code>using Xamarin.Forms;
using IdokladX.Services;
using UIKit;
using Foundation;
[assembly: Dependency(typeof(IdokladX.iOS.Services.PdfViewer))]
namespace IdokladX.iOS.Services {
public class PdfViewer:IPdfViewer {

    public void OpenPdf(string filename)
    {
        FileWorker fl = new FileWorker();

        if (fl.Exists(filename))
        {
            string strPfad = fl.GetFilePath(filename);

            var viewer = UIDocumentInteractionController.FromUrl(NSUrl.FromFilename(strPfad));
            var controller = GetVisibleViewController();
            viewer.PresentOpenInMenu(controller.View.Frame, controller.View, true);
        }
    }
    private UIViewController GetVisibleViewController(UIViewController controller = null)
    {
        controller = controller ?? UIApplication.SharedApplication.KeyWindow.RootViewController;

        if (controller.PresentedViewController == null)
            return controller;

        if (controller.PresentedViewController is UINavigationController)
        {
            return ((UINavigationController)controller.PresentedViewController).VisibleViewController;
        }

        if (controller.PresentedViewController is UITabBarController)
        {
            return ((UITabBarController)controller.PresentedViewController).SelectedViewController;
        }

        return GetVisibleViewController(controller.PresentedViewController);
    }
    }
}
</code>```

Here FileWorker is a class which contains methods to save/delete/check file if it exists.
What is wrong? I have also added the file type PDF in my Info.plist file.

What is wrong ? Don't advice me to use WebView, I need to open pdf file via another program.

答:
Reference:

See the documentation for presentOpenInMenu(from:in:animated:):

If there are no registered apps that support opening the document, the document interaction controller does not display a menu.

Solution:

Test the "Open in ..." on your device and make sure there's some app can open the pdf file (such as iBooks, Notes, Chrome and so on). Otherwise, the menu will not show.

Notice：

You don't need add the Document Type for PDF, if you just need other apps to open your file. Document Type is used to show your app in the "Open in ..." menu to open other apps' file when some other apps trigger presentOpenInMenu.

Title: Xamarin Forms IOS open PDF

Body:
I need to open pdf file from file system.
I know how to get path to the file, but my IPhone does not open it.

I use the following code renderer:

using Xamarin.Forms;
using IdokladX.Services;
using UIKit;
using Foundation;
[assembly: Dependency(typeof(IdokladX.iOS.Services.PdfViewer))]
namespace IdokladX.iOS.Services {
public class PdfViewer:IPdfViewer {

    public void OpenPdf(string filename)
    {
        FileWorker fl = new FileWorker();

        if (fl.Exists(filename))
        {
            string strPfad = fl.GetFilePath(filename);

            var viewer = UIDocumentInteractionController.FromUrl(NSUrl.FromFilename(strPfad));
            var controller = GetVisibleViewController();
            viewer.PresentOpenInMenu(controller.View.Frame, controller.View, true);
        }
    }
    private UIViewController GetVisibleViewController(UIViewController controller = null)
    {
        controller = controller ?? UIApplication.SharedApplication.KeyWindow.RootViewController;

        if (controller.PresentedViewController == null)
            return controller;

        if (controller.PresentedViewController is UINavigationController)
        {
            return ((UINavigationController)controller.PresentedViewController).VisibleViewController;
        }

        if (controller.PresentedViewController is UITabBarController)
        {
            return ((UITabBarController)controller.PresentedViewController).SelectedViewController;
        }

        return GetVisibleViewController(controller.PresentedViewController);
    }
    }
}

Here FileWorker is a class which contains methods to save/delete/check file if it exists.
What is wrong? I have also added the file type PDF in my Info.plist file.

What is wrong ? Don't advice me to use WebView, I need to open pdf file via another program.


问:
Zero all filesize in a large directory tree (delete file content, keep files)
How can I delete the content (zero the filesize) of a large directory tree (10 GB, 1K files) but keep the entire tree structure, filenames, extensions. (If I can keep the original last write time [last content modification time] that's a bonus).

I have seen several suggestions for individual files, but can not figure out the way to make this work for the entire CWD.

```<code>def deleteContent(fName):
    with open(fName, "w"):
        pass
</code>```

答:
Running following as administrator should reset all content to an empty file and retain the lastwritetime's of the files</p>

```<code>gci c:\temp\test\*.* -recurse | % {
    $LastWriteTime = $PSItem.LastWriteTime
    clear-content $PSItem;
    $PSItem.LastWriteTime = $LastWriteTime
}
</code>```

Body:
How can I delete the content (zero the filesize) of a large directory tree (10 GB, 1K files) but keep the entire tree structure, filenames, extensions. (If I can keep the original last write time [last content modification time] that's a bonus).

I have seen several suggestions for individual files, but can not figure out the way to make this work for the entire CWD.

def deleteContent(fName):
    with open(fName, "w"):
        pass

Body:
Running following as administrator should reset all content to an empty file and retain the lastwritetime's of the files

gci c:\temp\test\*.* -recurse | % {
    $LastWriteTime = $PSItem.LastWriteTime
    clear-content $PSItem;
    $PSItem.LastWriteTime = $LastWriteTime
}


问:
If I wanted to change $_GET to $_POST in this code What would I do?
I can't seem to figure out how to post this instead of using get, I've found that you have to use a form but that's about it.
If anyone is willing to provide an answer that'd be awesome!
Thank you!!!!
.............................................................................................................................................................</p>

```<code><!DOCTYPE html>
<html>
<head>
 <meta charset="UTF-8">
<title>Portfolio Max</title>

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

  <div class= "header">
    <h1 id= "textinheader">Portfolio</h1></div>
    <div class= "portfolio text"> </div>

    <div class="menu">
        <a href="?page=1">pagina 1</a>
        <a href="?page=2">pagina2</a>
        <div class="dropdown">
          <button class="dropbutton">Meer
            <i class="down"></i>
          </button>
          <div class="dropdown-content">
            <a href="?page=3">pagina 3</a>
            <a href="?page=4">pagina 4</a>
            <a href="?page=5">pagina 5</a>
          </div>
        </div>
      </div>

    <?php  echo date("Y/M/D h:i:sa");?>

    </div>

   <?php

   /*
   if( $_GET ['page'] == '1')
   include 'page1.php';
   else
   include 'page2.php';
   */
  if (! isset($_GET ['page']))
  $_GET = array_merge( $_GET, array('page'=>1));

  include 'page'.$_GET ['page'].'.php';

   ?>

    </div>

 </body>
</html>c
</code>```

答:
https://jsfiddle.net/t5r16qoe/

```<code><form id="formId" action="dataPost.php" title="" method="post">
    <div><label class="title">Name</label><input type="text" id="name" name="name" ></div>
<div><label class="title">Age</label><input type="text" id="age2" name="age" ></div>
<div><input type="submit" id="submitButton"  name="submitButton" value="Submit"></div>
</form>
</code>```

in JS:

```<code>$("#formId").submit(function(event) {

  event.preventDefault();

    var $form = $( this ),
      url = $form.attr( 'action' );

  var posting = $.post( url, { name: $('#name').val(), age: $('#age').val() } );

  posting.done(function( data ) {
    alert('Saved!');
  });
});
</code>```

in dataPost.php you can get the posted value like

```<code>echo $_POST['name'];
echo $_POST['age'];
</code>```

Body:
I can't seem to figure out how to post this instead of using get, I've found that you have to use a form but that's about it.
If anyone is willing to provide an answer that'd be awesome!
Thank you!!!!
.............................................................................................................................................................

<!DOCTYPE html>

 <meta charset="UTF-8">
<title>Portfolio Max</title>

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

Portfolio

        pagina 1
        pagina2

          <button class="dropbutton">Meer

          </button>

            pagina 3
            pagina 4
            pagina 5

    <?php  echo date("Y/M/D h:i:sa");?>

   <?php

   /*
   if( $_GET ['page'] == '1')
   include 'page1.php';
   else
   include 'page2.php';
   */
  if (! isset($_GET ['page']))
  $_GET = array_merge( $_GET, array('page'=>1));

  include 'page'.$_GET ['page'].'.php';

   ?>

c

Body:
https://jsfiddle.net/t5r16qoe/

<form id="formId" action="dataPost.php" title="" method="post">
    <div><label class="title">Name</label><input type="text" id="name" name="name" ></div>
<div><label class="title">Age</label><input type="text" id="age2" name="age" ></div>
<div><input type="submit" id="submitButton"  name="submitButton" value="Submit"></div>
</form>

in JS:

$("#formId").submit(function(event) {

  event.preventDefault();

    var $form = $( this ),
      url = $form.attr( 'action' );

  var posting = $.post( url, { name: $('#name').val(), age: $('#age').val() } );

  posting.done(function( data ) {
    alert('Saved!');
  });
});

in dataPost.php you can get the posted value like

echo $_POST['name'];
echo $_POST['age'];


问:
first_name user property is not logged, is it reserved in firebase analytics?
I integrated firebase analytics in my app. Have set some User Properties too. I have registered those properties in console and it works fine but except for now property. Name of that beautiful property is first_name. :).

I don't find it in Automatically collected user properties.

I can't see first_name property logged in 'Debug View'. I see all properties I added along with them though.

Any clues ?

答: It did not require any fix but just that it was not logged in Debug View for some reason. But I could see it in Events. Click on Events on on left pane -> Add Filter -> User Property -> first_name.</p>


问:
( was unexpected at this time - batch script
I'm using the batch script below and get an error

( was unexpected at this time.

I know that the problem is in the first line but I don't understand what is wrong.
Any ideas ?

script:

```<code>IF [%1]==[] (
    :LOOP1
    SET /P isDefault=Value Missing, do you want to use default values [1,1,10,Local      Area Connection 2]?[y/n]
    IF %isDefault%==y (
        SET from=1
        SET step=1
        SET to=10
        SET lan="Local Area Connection 2"
        GOTO :USERLOOP
    )
    IF %isDefault%==n GOTO :END
    GOTO :LOOP1
)
</code>```

答:
I had a very similar problem and code construct that was causing me a lot of pain to resolve. My error message was ". was unexpected at this time"...

It took me a couple long days to figure out another similar consideration due to this problem... Please take a look a the following problem and subsequent solution here: ". was unexpected at this time" generated from batch script line 'if exist [file] (...

The solution was simply the treatment of '(' and ')' on ECHO lines inside an IF statement block.

The point is, do consider treatment of special characters as a possible source of a problem when troubleshooting IF (and possibly FOR) statements.

HTH someone...

Body:
I'm using the batch script below and get an error

( was unexpected at this time.

I know that the problem is in the first line but I don't understand what is wrong.
Any ideas ?

script:

IF [%1]==[] (
    :LOOP1
    SET /P isDefault=Value Missing, do you want to use default values [1,1,10,Local      Area Connection 2]?[y/n]
    IF %isDefault%==y (
        SET from=1
        SET step=1
        SET to=10
        SET lan="Local Area Connection 2"
        GOTO :USERLOOP
    )
    IF %isDefault%==n GOTO :END
    GOTO :LOOP1
)