问:
cpanm perl module installation failed on 'make' and 'make test'
I asked a question regarding configure does not generate makefile while building perl from source. While awaiting for a solution, here is another (possibly relevant) question. When I install perl modules for the system perl via something like sudo cpanm Try::Tiny it fails with following log:

```<code>cpanm (App::cpanminus) 1.7040 on perl 5.018002 built for x86_64-linux-gnu-thread-multi
Work directory is /home/zxu/.cpanm/work/1462290395.17141
You have make /usr/bin/make
You have LWP 6.05
You have /bin/tar: tar (GNU tar) 1.27.1
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.
You have /usr/bin/unzip
Searching Try::Tiny () on cpanmetadb ...
--> Working on Try::Tiny
Fetching http://www.cpan.org/authors/id/E/ET/ETHER/Try-Tiny-0.24.tar.gz
-> OK
Unpacking Try-Tiny-0.24.tar.gz
Entering Try-Tiny-0.24
Checking configure dependencies from META.json
Checking if you have ExtUtils::MakeMaker 6.58 ... Yes (6.66)
Configuring Try-Tiny-0.24
Running Makefile.PL
Checking if your kit is complete...
Warning: the following files are missing in your kit:
        lib/Try/Tiny.pm
        maint/bench.pl
        t/00-report-prereqs.dd
        t/00-report-prereqs.t
        t/basic.t
        t/context.t
        t/erroneous_usage.t
        t/finally.t
        t/given_when.t
        t/global_destruction_forked.t
        t/global_destruction_load.t
        t/lib/TryUser.pm
        t/named.t
        t/when.t
        xt/author/00-compile.t
        xt/author/eol.t
        xt/author/kwalitee.t
        xt/author/mojibake.t
        xt/author/no-tabs.t
        xt/author/pod-coverage.t
        xt/author/pod-spell.t
        xt/author/pod-syntax.t
        xt/release/changes_has_content.t
        xt/release/cpan-changes.t
        xt/release/distmeta.t
        xt/release/pod-no404s.t
        xt/release/portability.t
Please inform the author.
Wide character in print at /usr/share/perl/5.18/ExtUtils/MakeMaker.pm line 1034.
Wide character in print at /usr/share/perl/5.18/ExtUtils/MakeMaker.pm line 1034.
Wide character in print at /usr/share/perl/5.18/ExtUtils/MakeMaker.pm line 1034.
Writing Makefile for Try::Tiny
Writing MYMETA.yml and MYMETA.json
-> OK
Checking dependencies from MYMETA.json ...
Checking if you have warnings 0 ... Yes (1.18)
Checking if you have constant 0 ... Yes (1.27)
Checking if you have ExtUtils::MakeMaker 0 ... Yes (6.66)
Checking if you have if 0 ... Yes (0.0602)
Checking if you have strict 0 ... Yes (1.07)
Checking if you have Exporter 5.57 ... Yes (5.68)
Checking if you have File::Spec 0 ... Yes (3.40)
Checking if you have Carp 0 ... Yes (1.29)
Checking if you have Test::More 0 ... Yes (1.001014)
Building and testing Try-Tiny-0.24
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
#
# Versions for all modules listed in MYMETA.json (including optional ones):
#
# === Configure Requires ===
#
#     Module              Want Have
#     ------------------- ---- ----
#     ExtUtils::MakeMaker  any 6.66
#
# === Build Requires ===
#
#     Module              Want Have
#     ------------------- ---- ----
#     ExtUtils::MakeMaker  any 6.66
#
# === Test Requires ===
#
#     Module              Want     Have
#     ------------------- ---- --------
#     ExtUtils::MakeMaker  any     6.66
#     File::Spec           any     3.40
#     Test::More           any 1.001014
#     if                   any   0.0602
#
# === Test Recommends ===
#
#     Module            Want     Have
#     ------------- -------- --------
#     CPAN::Meta    2.120900 2.133380
#     Capture::Tiny     0.12  missing
#
# === Test Suggests ===
#
#     Module    Want    Have
#     --------- ---- -------
#     Sub::Util  any missing
#
# === Runtime Requires ===
#
#     Module   Want Have
#     -------- ---- ----
#     Carp      any 1.29
#     Exporter 5.57 5.68
#     constant  any 1.27
#     strict    any 1.07
#     warnings  any 1.18
#
# === Other Modules ===
#
#     Module           Have
#     ------------- -------
#     Pod::Coverage missing
#
t/00-report-prereqs.t .......... ok
Can't locate Try/Tiny.pm in @INC (you may need to install the Try::Tiny module) (@INC contains: /home/zxu/.cpanm/work/1462290395.17141/Try-Tiny-0.24/blib/lib /home/zxu/.cpanm/work/1462290395.17141/Try-Tin
y-0.24/blib/arch /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at t/basic.t line 8.
BEGIN failed--compilation aborted at t/basic.t line 8.
# Looks like your test exited with 2 before it could output anything.
t/basic.t ......................
Dubious, test returned 2 (wstat 512, 0x200)
Failed 25/25 subtests
Can't locate Try/Tiny.pm in @INC (you may need to install the Try::Tiny module) (@INC contains: /home/zxu/.cpanm/work/1462290395.17141/Try-Tiny-0.24/blib/lib /home/zxu/.cpanm/work/1462290395.17141/Try-Tiny-0.24/blib/arch /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at t/context.t line 6.
BEGIN failed--compilation aborted at t/context.t line 6.
... ... ##more tests failure
Test Summary Report
-------------------
t/basic.t                    (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: Bad plan.  You planned 25 tests but ran 0.
t/context.t                  (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: No plan found in TAP output
t/erroneous_usage.t          (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: Bad plan.  You planned 8 tests but ran 0.
t/finally.t                  (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: Bad plan.  You planned 27 tests but ran 0.
t/given_when.t               (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: Bad plan.  You planned 2 tests but ran 0.
t/global_destruction_forked.t (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: Bad plan.  You planned 3 tests but ran 0.
t/when.t                     (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: Bad plan.  You planned 5 tests but ran 0.
Files=10, Tests=1,  0 wallclock secs ( 0.02 usr  0.01 sys +  0.23 cusr  0.02 csys =  0.28 CPU)
Result: FAIL
Failed 7/10 test programs. 0/1 subtests failed.
make: *** [test_dynamic] Error 2
-> FAIL Installing Try::Tiny failed. See /home/zxu/.cpanm/work/1462290395.17141/build.log for details. Retry with --force to force install it.
</code>```

, and if I run sudo -s, cd to the downloaded module directory and run perl Makefile.PL && make && make test, the tests fail again (compared with the cpanm log, no missing file warnings anymore):

```<code>Writing Makefile for Try::Tiny
Wide character in print at /usr/share/perl/5.18/ExtUtils/MakeMaker.pm line 1034.
Wide character in print at /usr/share/perl/5.18/ExtUtils/MakeMaker.pm line 1034.
Wide character in print at /usr/share/perl/5.18/ExtUtils/MakeMaker.pm line 1034.
Writing MYMETA.yml and MYMETA.json
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00-report-prereqs.t .......... #
# Versions for all modules listed in MYMETA.json (including optional ones):
#
# === Configure Requires ===
#
#     Module              Want Have
#     ------------------- ---- ----
#     ExtUtils::MakeMaker  any 6.66
#
# === Build Requires ===
#
#     Module              Want Have
#     ------------------- ---- ----
#     ExtUtils::MakeMaker  any 6.66
#
# === Test Requires ===
#
#     Module              Want     Have
#     ------------------- ---- --------
#     ExtUtils::MakeMaker  any     6.66
#     File::Spec           any     3.40
#     Test::More           any 1.001014
#     if                   any   0.0602
#
# === Test Recommends ===
#
#     Module            Want     Have
#     ------------- -------- --------
#     CPAN::Meta    2.120900 2.133380
#     Capture::Tiny     0.12  missing
#
# === Test Suggests ===
#
#     Module    Want    Have
#     --------- ---- -------
#     Sub::Util  any missing
#
# === Runtime Requires ===
#
#     Module   Want Have
#     -------- ---- ----
#     Carp      any 1.29
#     Exporter 5.57 5.68
#     constant  any 1.27
#     strict    any 1.07
#     warnings  any 1.18
#
# === Other Modules ===
#
#     Module           Have
#     ------------- -------
#     Pod::Coverage missing
#
t/00-report-prereqs.t .......... ok
t/basic.t ...................... Can't locate Try/Tiny.pm in @INC (you may need to install the Try::Tiny module) (@INC contains: /home/zxu/.cpanm/work/1462290395.17141/Try-Tiny-0.24/blib/lib /home/zxu/.cp
anm/work/1462290395.17141/Try-Tiny-0.24/blib/arch /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/s
ite_perl .) at t/basic.t line 8.
BEGIN failed--compilation aborted at t/basic.t line 8.
# Looks like your test exited with 2 before it could output anything.
t/basic.t ...................... Dubious, test returned 2 (wstat 512, 0x200)
Failed 25/25 subtests
t/context.t .................... Can't locate Try/Tiny.pm in @INC (you may need to install the Try::Tiny module) (@INC contains: /home/zxu/.cpanm/work/1462290395.17141/Try-Tiny-0.24/blib/lib /home/zxu/.cp
anm/work/1462290395.17141/Try-Tiny-0.24/blib/arch /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/s
ite_perl .) at t/context.t line 6.
BEGIN failed--compilation aborted at t/context.t line 6.
... ... ##more tests failure
</code>```

It seems the module Try::Tiny is not installed successfully since make didn't spit out any log message and the test couldn't locate the module in @INC. I am on Ubuntu 14.04 (kernel 3.13.0-24-generic), and using apt-get install for module installation is ok. The output from perl -V is:

```<code>Summary of my perl5 (revision 5 version 18 subversion 2) configuration:

  Platform:
    osname=linux, osvers=3.13.0-79-generic, archname=x86_64-linux-gnu-thread-multi
    uname='linux lgw01-37 3.13.0-79-generic #123-ubuntu smp fri feb 19 14:27:58 utc 2016 x86_64 x86_64 x86_64 gnulinux '
    config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Dldflags= -Wl,-Bsymbolic-functions
 -Wl,-z,relro -Dlddlflags=-shared -Wl,-Bsymbolic-functions -Wl,-z,relro -Dcccdlflags=-fPIC -Darchname=x86_64-linux-gnu -Dprefix=/usr -Dprivlib=/usr/share/perl/5.18 -Darchlib=/usr/lib/perl/5.18 -Dvendorpre
fix=/usr -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.18.2 -Dsitearch=/usr/local/lib/perl/5.18.2 -Dman1dir=/usr/share/man/man1 -Dman3d
ir=/usr/share/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Dsiteman3dir=/usr/local/man/man3 -Duse64bitint -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Ud_ualarm -Uusesfio -Uus
enm -Ui_libutil -Uversiononly -DDEBUGGING=-g -Doptimize=-O2 -Duseshrplib -Dlibperl=libperl.so.5.18.2 -des'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fstack-protector -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -g',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fstack-protector -fno-strict-aliasing -pipe -I/usr/local/include'
    ccversion='', gccversion='4.8.2', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib /usr/lib
    libs=-lgdbm -lgdbm_compat -ldb -ldl -lm -lpthread -lc -lcrypt
    perllibs=-ldl -lm -lpthread -lc -lcrypt
    libc=, so=so, useshrplib=true, libperl=libperl.so.5.18.2
    gnulibc_version='2.19'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib -fstack-protector'

Characteristics of this binary (from libperl):
  Compile-time options: HAS_TIMES MULTIPLICITY PERLIO_LAYERS
                        PERL_DONT_CREATE_GVSV
                        PERL_HASH_FUNC_ONE_AT_A_TIME_HARD
                        PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP
                        PERL_PRESERVE_IVUV PERL_SAWAMPERSAND USE_64_BIT_ALL
                        USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES
                        USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE
                        USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF
                        USE_REENTRANT_API
  Locally applied patches:
        DEBPKG:debian/cpan_definstalldirs - Provide a sensible INSTALLDIRS default for modules installed from CPAN.
        DEBPKG:debian/db_file_ver - http://bugs.debian.org/340047 Remove overly restrictive DB_File version check.
        DEBPKG:debian/doc_info - Replace generic man(1) instructions with Debian-specific information.
        DEBPKG:debian/enc2xs_inc - http://bugs.debian.org/290336 Tweak enc2xs to follow symlinks and ignore missing @INC directories.
        DEBPKG:debian/errno_ver - http://bugs.debian.org/343351 Remove Errno version check due to upgrade problems with long-running processes.
        DEBPKG:debian/libperl_embed_doc - http://bugs.debian.org/186778 Note that libperl-dev package is required for embedded linking
        DEBPKG:fixes/respect_umask - Respect umask during installation
        DEBPKG:debian/writable_site_dirs - Set umask approproately for site install directories
        DEBPKG:debian/extutils_set_libperl_path - EU:MM: Set location of libperl.a to /usr/lib
        DEBPKG:debian/no_packlist_perllocal - Don't install .packlist or perllocal.pod for perl or vendor
        DEBPKG:debian/prefix_changes - Fiddle with *PREFIX and variables written to the makefile
        DEBPKG:debian/fakeroot - Postpone LD_LIBRARY_PATH evaluation to the binary targets.
        DEBPKG:debian/instmodsh_doc - Debian policy doesn't install .packlist files for core or vendor.
        DEBPKG:debian/ld_run_path - Remove standard libs from LD_RUN_PATH as per Debian policy.
        DEBPKG:debian/libnet_config_path - Set location of libnet.cfg to /etc/perl/Net as /usr may not be writable.
        DEBPKG:debian/mod_paths - Tweak @INC ordering for Debian
        DEBPKG:debian/module_build_man_extensions - http://bugs.debian.org/479460 Adjust Module::Build manual page extensions for the Debian Perl policy
        DEBPKG:debian/prune_libs - http://bugs.debian.org/128355 Prune the list of libraries wanted to what we actually need.
        DEBPKG:fixes/net_smtp_docs - [rt.cpan.org #36038] http://bugs.debian.org/100195 Document the Net::SMTP 'Port' option
        DEBPKG:debian/perlivp - http://bugs.debian.org/510895 Make perlivp skip include directories in /usr/local
        DEBPKG:debian/cpanplus_definstalldirs - http://bugs.debian.org/533707 Configure CPANPLUS to use the site directories by default.
        DEBPKG:debian/cpanplus_config_path - Save local versions of CPANPLUS::Config::System into /etc/perl.
        DEBPKG:debian/deprecate-with-apt - http://bugs.debian.org/702096 Point users to Debian packages of deprecated core modules
        DEBPKG:debian/squelch-locale-warnings - http://bugs.debian.org/508764 Squelch locale warnings in Debian package maintainer scripts
        DEBPKG:debian/skip-upstream-git-tests - Skip tests specific to the upstream Git repository
        DEBPKG:debian/patchlevel - http://bugs.debian.org/567489 List packaged patches for 5.18.2-2ubuntu1.1 in patchlevel.h
        DEBPKG:debian/skip-kfreebsd-crash - http://bugs.debian.org/628493 [perl #96272] Skip a crashing test case in t/op/threads.t on GNU/kFreeBSD
        DEBPKG:fixes/document_makemaker_ccflags - http://bugs.debian.org/628522 [rt.cpan.org #68613] Document that CCFLAGS should include $Config{ccflags}
        DEBPKG:debian/find_html2text - http://bugs.debian.org/640479 Configure CPAN::Distribution with correct name of html2text
        DEBPKG:debian/hurd_test_skip_stack - http://bugs.debian.org/650175 Disable failing GNU/Hurd tests dist/threads/t/stack.t
        DEBPKG:fixes/manpage_name_Test-Harness - http://bugs.debian.org/650451 [rt.cpan.org #73399] cpan/Test-Harness: add NAME headings in modules with POD
        DEBPKG:debian/makemaker-pasthru - http://bugs.debian.org/660195 [rt.cpan.org #28632] Make EU::MM pass LD through to recursive Makefile.PL invocations
        DEBPKG:debian/perl5db-x-terminal-emulator.patch - http://bugs.debian.org/668490 Invoke x-terminal-emulator rather than xterm in perl5db.pl
        DEBPKG:debian/cpan-missing-site-dirs - http://bugs.debian.org/688842 Fix CPAN::FirstTime defaults with nonexisting site dirs if a parent is writable
        DEBPKG:fixes/memoize_storable_nstore - [rt.cpan.org #77790] http://bugs.debian.org/587650 Memoize::Storable: respect 'nstore' option not respected
        DEBPKG:fixes/net_ftp_failed_command - [rt.cpan.org #37700] http://bugs.debian.org/491062 Net::FTP: cope gracefully with a failed command
        DEBPKG:fixes/perlbug-patchlist - [3541c11] http://bugs.debian.org/710842 [perl #118433] Make perlbug look up the list of local patches at run time
        DEBPKG:fixes/module_metadata_security_doc - [68cdd4b] CVE-2013-1437 documentation fix
        DEBPKG:fixes/module_metadata_taint_fix - [bff978f] http://bugs.debian.org/722210 [rt.cpan.org #88576] untaint version, if needed, in Module::Metadata
        DEBPKG:fixes/IPC-SysV-spelling - http://bugs.debian.org/730558 [rt.cpan.org #86736] Fix spelling of IPC_CREAT in IPC-SysV documentation
        DEBPKG:fixes/fix-undef-source -
        DEBPKG:fixes/CVE-2013-7422.patch - [PATCH] [perl #119505] Segfault from bad backreference
        DEBPKG:fixes/CVE-2014-4330.patch - [PATCH] don't recurse infinitely in Data::Dumper
        DEBPKG:fixes/CVE-2016-2381.patch - [PATCH 1/2] remove duplicate environment variables from environ
  Built under linux
  Compiled at Mar  1 2016 17:15:04
  @INC:
    /etc/perl
    /usr/local/lib/perl/5.18.2
    /usr/local/share/perl/5.18.2
    /usr/lib/perl5
    /usr/share/perl5
    /usr/lib/perl/5.18
    /usr/share/perl/5.18
    /usr/local/lib/site_perl
    .
</code>```

It seems the system perl was built against a different kernel version 3.13.0-79-generic. Could this be the problem? Plz help! Let me know if you need any more info. Thanks.

答: Based on this mailing list thread, the third post in particular, I would suggest editing '/usr/lib/perl//Config.pm' so that dont_use_nlink is set to 'define' instead of undef. This solution worked for me.</p>

Body:
I asked a question regarding configure does not generate makefile while building perl from source. While awaiting for a solution, here is another (possibly relevant) question. When I install perl modules for the system perl via something like sudo cpanm Try::Tiny it fails with following log:

cpanm (App::cpanminus) 1.7040 on perl 5.018002 built for x86_64-linux-gnu-thread-multi
Work directory is /home/zxu/.cpanm/work/1462290395.17141
You have make /usr/bin/make
You have LWP 6.05
You have /bin/tar: tar (GNU tar) 1.27.1
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.
You have /usr/bin/unzip
Searching Try::Tiny () on cpanmetadb ...
--> Working on Try::Tiny
Fetching http://www.cpan.org/authors/id/E/ET/ETHER/Try-Tiny-0.24.tar.gz
-> OK
Unpacking Try-Tiny-0.24.tar.gz
Entering Try-Tiny-0.24
Checking configure dependencies from META.json
Checking if you have ExtUtils::MakeMaker 6.58 ... Yes (6.66)
Configuring Try-Tiny-0.24
Running Makefile.PL
Checking if your kit is complete...
Warning: the following files are missing in your kit:
        lib/Try/Tiny.pm
        maint/bench.pl
        t/00-report-prereqs.dd
        t/00-report-prereqs.t
        t/basic.t
        t/context.t
        t/erroneous_usage.t
        t/finally.t
        t/given_when.t
        t/global_destruction_forked.t
        t/global_destruction_load.t
        t/lib/TryUser.pm
        t/named.t
        t/when.t
        xt/author/00-compile.t
        xt/author/eol.t
        xt/author/kwalitee.t
        xt/author/mojibake.t
        xt/author/no-tabs.t
        xt/author/pod-coverage.t
        xt/author/pod-spell.t
        xt/author/pod-syntax.t
        xt/release/changes_has_content.t
        xt/release/cpan-changes.t
        xt/release/distmeta.t
        xt/release/pod-no404s.t
        xt/release/portability.t
Please inform the author.
Wide character in print at /usr/share/perl/5.18/ExtUtils/MakeMaker.pm line 1034.
Wide character in print at /usr/share/perl/5.18/ExtUtils/MakeMaker.pm line 1034.
Wide character in print at /usr/share/perl/5.18/ExtUtils/MakeMaker.pm line 1034.
Writing Makefile for Try::Tiny
Writing MYMETA.yml and MYMETA.json
-> OK
Checking dependencies from MYMETA.json ...
Checking if you have warnings 0 ... Yes (1.18)
Checking if you have constant 0 ... Yes (1.27)
Checking if you have ExtUtils::MakeMaker 0 ... Yes (6.66)
Checking if you have if 0 ... Yes (0.0602)
Checking if you have strict 0 ... Yes (1.07)
Checking if you have Exporter 5.57 ... Yes (5.68)
Checking if you have File::Spec 0 ... Yes (3.40)
Checking if you have Carp 0 ... Yes (1.29)
Checking if you have Test::More 0 ... Yes (1.001014)
Building and testing Try-Tiny-0.24
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
#
# Versions for all modules listed in MYMETA.json (including optional ones):
#
# === Configure Requires ===
#
#     Module              Want Have
#     ------------------- ---- ----
#     ExtUtils::MakeMaker  any 6.66
#
# === Build Requires ===
#
#     Module              Want Have
#     ------------------- ---- ----
#     ExtUtils::MakeMaker  any 6.66
#
# === Test Requires ===
#
#     Module              Want     Have
#     ------------------- ---- --------
#     ExtUtils::MakeMaker  any     6.66
#     File::Spec           any     3.40
#     Test::More           any 1.001014
#     if                   any   0.0602
#
# === Test Recommends ===
#
#     Module            Want     Have
#     ------------- -------- --------
#     CPAN::Meta    2.120900 2.133380
#     Capture::Tiny     0.12  missing
#
# === Test Suggests ===
#
#     Module    Want    Have
#     --------- ---- -------
#     Sub::Util  any missing
#
# === Runtime Requires ===
#
#     Module   Want Have
#     -------- ---- ----
#     Carp      any 1.29
#     Exporter 5.57 5.68
#     constant  any 1.27
#     strict    any 1.07
#     warnings  any 1.18
#
# === Other Modules ===
#
#     Module           Have
#     ------------- -------
#     Pod::Coverage missing
#
t/00-report-prereqs.t .......... ok
Can't locate Try/Tiny.pm in @INC (you may need to install the Try::Tiny module) (@INC contains: /home/zxu/.cpanm/work/1462290395.17141/Try-Tiny-0.24/blib/lib /home/zxu/.cpanm/work/1462290395.17141/Try-Tin
y-0.24/blib/arch /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at t/basic.t line 8.
BEGIN failed--compilation aborted at t/basic.t line 8.
# Looks like your test exited with 2 before it could output anything.
t/basic.t ......................
Dubious, test returned 2 (wstat 512, 0x200)
Failed 25/25 subtests
Can't locate Try/Tiny.pm in @INC (you may need to install the Try::Tiny module) (@INC contains: /home/zxu/.cpanm/work/1462290395.17141/Try-Tiny-0.24/blib/lib /home/zxu/.cpanm/work/1462290395.17141/Try-Tiny-0.24/blib/arch /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at t/context.t line 6.
BEGIN failed--compilation aborted at t/context.t line 6.
... ... ##more tests failure
Test Summary Report
-------------------
t/basic.t                    (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: Bad plan.  You planned 25 tests but ran 0.
t/context.t                  (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: No plan found in TAP output
t/erroneous_usage.t          (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: Bad plan.  You planned 8 tests but ran 0.
t/finally.t                  (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: Bad plan.  You planned 27 tests but ran 0.
t/given_when.t               (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: Bad plan.  You planned 2 tests but ran 0.
t/global_destruction_forked.t (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: Bad plan.  You planned 3 tests but ran 0.
t/when.t                     (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: Bad plan.  You planned 5 tests but ran 0.
Files=10, Tests=1,  0 wallclock secs ( 0.02 usr  0.01 sys +  0.23 cusr  0.02 csys =  0.28 CPU)
Result: FAIL
Failed 7/10 test programs. 0/1 subtests failed.
make: *** [test_dynamic] Error 2
-> FAIL Installing Try::Tiny failed. See /home/zxu/.cpanm/work/1462290395.17141/build.log for details. Retry with --force to force install it.

, and if I run sudo -s, cd to the downloaded module directory and run perl Makefile.PL && make && make test, the tests fail again (compared with the cpanm log, no missing file warnings anymore):

Writing Makefile for Try::Tiny
Wide character in print at /usr/share/perl/5.18/ExtUtils/MakeMaker.pm line 1034.
Wide character in print at /usr/share/perl/5.18/ExtUtils/MakeMaker.pm line 1034.
Wide character in print at /usr/share/perl/5.18/ExtUtils/MakeMaker.pm line 1034.
Writing MYMETA.yml and MYMETA.json
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00-report-prereqs.t .......... #
# Versions for all modules listed in MYMETA.json (including optional ones):
#
# === Configure Requires ===
#
#     Module              Want Have
#     ------------------- ---- ----
#     ExtUtils::MakeMaker  any 6.66
#
# === Build Requires ===
#
#     Module              Want Have
#     ------------------- ---- ----
#     ExtUtils::MakeMaker  any 6.66
#
# === Test Requires ===
#
#     Module              Want     Have
#     ------------------- ---- --------
#     ExtUtils::MakeMaker  any     6.66
#     File::Spec           any     3.40
#     Test::More           any 1.001014
#     if                   any   0.0602
#
# === Test Recommends ===
#
#     Module            Want     Have
#     ------------- -------- --------
#     CPAN::Meta    2.120900 2.133380
#     Capture::Tiny     0.12  missing
#
# === Test Suggests ===
#
#     Module    Want    Have
#     --------- ---- -------
#     Sub::Util  any missing
#
# === Runtime Requires ===
#
#     Module   Want Have
#     -------- ---- ----
#     Carp      any 1.29
#     Exporter 5.57 5.68
#     constant  any 1.27
#     strict    any 1.07
#     warnings  any 1.18
#
# === Other Modules ===
#
#     Module           Have
#     ------------- -------
#     Pod::Coverage missing
#
t/00-report-prereqs.t .......... ok
t/basic.t ...................... Can't locate Try/Tiny.pm in @INC (you may need to install the Try::Tiny module) (@INC contains: /home/zxu/.cpanm/work/1462290395.17141/Try-Tiny-0.24/blib/lib /home/zxu/.cp
anm/work/1462290395.17141/Try-Tiny-0.24/blib/arch /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/s
ite_perl .) at t/basic.t line 8.
BEGIN failed--compilation aborted at t/basic.t line 8.
# Looks like your test exited with 2 before it could output anything.
t/basic.t ...................... Dubious, test returned 2 (wstat 512, 0x200)
Failed 25/25 subtests
t/context.t .................... Can't locate Try/Tiny.pm in @INC (you may need to install the Try::Tiny module) (@INC contains: /home/zxu/.cpanm/work/1462290395.17141/Try-Tiny-0.24/blib/lib /home/zxu/.cp
anm/work/1462290395.17141/Try-Tiny-0.24/blib/arch /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/s
ite_perl .) at t/context.t line 6.
BEGIN failed--compilation aborted at t/context.t line 6.
... ... ##more tests failure

It seems the module Try::Tiny is not installed successfully since make didn't spit out any log message and the test couldn't locate the module in @INC. I am on Ubuntu 14.04 (kernel 3.13.0-24-generic), and using apt-get install for module installation is ok. The output from perl -V is:

Summary of my perl5 (revision 5 version 18 subversion 2) configuration:

  Platform:
    osname=linux, osvers=3.13.0-79-generic, archname=x86_64-linux-gnu-thread-multi
    uname='linux lgw01-37 3.13.0-79-generic #123-ubuntu smp fri feb 19 14:27:58 utc 2016 x86_64 x86_64 x86_64 gnulinux '
    config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Dldflags= -Wl,-Bsymbolic-functions
 -Wl,-z,relro -Dlddlflags=-shared -Wl,-Bsymbolic-functions -Wl,-z,relro -Dcccdlflags=-fPIC -Darchname=x86_64-linux-gnu -Dprefix=/usr -Dprivlib=/usr/share/perl/5.18 -Darchlib=/usr/lib/perl/5.18 -Dvendorpre
fix=/usr -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.18.2 -Dsitearch=/usr/local/lib/perl/5.18.2 -Dman1dir=/usr/share/man/man1 -Dman3d
ir=/usr/share/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Dsiteman3dir=/usr/local/man/man3 -Duse64bitint -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Ud_ualarm -Uusesfio -Uus
enm -Ui_libutil -Uversiononly -DDEBUGGING=-g -Doptimize=-O2 -Duseshrplib -Dlibperl=libperl.so.5.18.2 -des'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fstack-protector -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -g',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fstack-protector -fno-strict-aliasing -pipe -I/usr/local/include'
    ccversion='', gccversion='4.8.2', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib /usr/lib
    libs=-lgdbm -lgdbm_compat -ldb -ldl -lm -lpthread -lc -lcrypt
    perllibs=-ldl -lm -lpthread -lc -lcrypt
    libc=, so=so, useshrplib=true, libperl=libperl.so.5.18.2
    gnulibc_version='2.19'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib -fstack-protector'

Characteristics of this binary (from libperl):
  Compile-time options: HAS_TIMES MULTIPLICITY PERLIO_LAYERS
                        PERL_DONT_CREATE_GVSV
                        PERL_HASH_FUNC_ONE_AT_A_TIME_HARD
                        PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP
                        PERL_PRESERVE_IVUV PERL_SAWAMPERSAND USE_64_BIT_ALL
                        USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES
                        USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE
                        USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF
                        USE_REENTRANT_API
  Locally applied patches:
        DEBPKG:debian/cpan_definstalldirs - Provide a sensible INSTALLDIRS default for modules installed from CPAN.
        DEBPKG:debian/db_file_ver - http://bugs.debian.org/340047 Remove overly restrictive DB_File version check.
        DEBPKG:debian/doc_info - Replace generic man(1) instructions with Debian-specific information.
        DEBPKG:debian/enc2xs_inc - http://bugs.debian.org/290336 Tweak enc2xs to follow symlinks and ignore missing @INC directories.
        DEBPKG:debian/errno_ver - http://bugs.debian.org/343351 Remove Errno version check due to upgrade problems with long-running processes.
        DEBPKG:debian/libperl_embed_doc - http://bugs.debian.org/186778 Note that libperl-dev package is required for embedded linking
        DEBPKG:fixes/respect_umask - Respect umask during installation
        DEBPKG:debian/writable_site_dirs - Set umask approproately for site install directories
        DEBPKG:debian/extutils_set_libperl_path - EU:MM: Set location of libperl.a to /usr/lib
        DEBPKG:debian/no_packlist_perllocal - Don't install .packlist or perllocal.pod for perl or vendor
        DEBPKG:debian/prefix_changes - Fiddle with *PREFIX and variables written to the makefile
        DEBPKG:debian/fakeroot - Postpone LD_LIBRARY_PATH evaluation to the binary targets.
        DEBPKG:debian/instmodsh_doc - Debian policy doesn't install .packlist files for core or vendor.
        DEBPKG:debian/ld_run_path - Remove standard libs from LD_RUN_PATH as per Debian policy.
        DEBPKG:debian/libnet_config_path - Set location of libnet.cfg to /etc/perl/Net as /usr may not be writable.
        DEBPKG:debian/mod_paths - Tweak @INC ordering for Debian
        DEBPKG:debian/module_build_man_extensions - http://bugs.debian.org/479460 Adjust Module::Build manual page extensions for the Debian Perl policy
        DEBPKG:debian/prune_libs - http://bugs.debian.org/128355 Prune the list of libraries wanted to what we actually need.
        DEBPKG:fixes/net_smtp_docs - [rt.cpan.org #36038] http://bugs.debian.org/100195 Document the Net::SMTP 'Port' option
        DEBPKG:debian/perlivp - http://bugs.debian.org/510895 Make perlivp skip include directories in /usr/local
        DEBPKG:debian/cpanplus_definstalldirs - http://bugs.debian.org/533707 Configure CPANPLUS to use the site directories by default.
        DEBPKG:debian/cpanplus_config_path - Save local versions of CPANPLUS::Config::System into /etc/perl.
        DEBPKG:debian/deprecate-with-apt - http://bugs.debian.org/702096 Point users to Debian packages of deprecated core modules
        DEBPKG:debian/squelch-locale-warnings - http://bugs.debian.org/508764 Squelch locale warnings in Debian package maintainer scripts
        DEBPKG:debian/skip-upstream-git-tests - Skip tests specific to the upstream Git repository
        DEBPKG:debian/patchlevel - http://bugs.debian.org/567489 List packaged patches for 5.18.2-2ubuntu1.1 in patchlevel.h
        DEBPKG:debian/skip-kfreebsd-crash - http://bugs.debian.org/628493 [perl #96272] Skip a crashing test case in t/op/threads.t on GNU/kFreeBSD
        DEBPKG:fixes/document_makemaker_ccflags - http://bugs.debian.org/628522 [rt.cpan.org #68613] Document that CCFLAGS should include $Config{ccflags}
        DEBPKG:debian/find_html2text - http://bugs.debian.org/640479 Configure CPAN::Distribution with correct name of html2text
        DEBPKG:debian/hurd_test_skip_stack - http://bugs.debian.org/650175 Disable failing GNU/Hurd tests dist/threads/t/stack.t
        DEBPKG:fixes/manpage_name_Test-Harness - http://bugs.debian.org/650451 [rt.cpan.org #73399] cpan/Test-Harness: add NAME headings in modules with POD
        DEBPKG:debian/makemaker-pasthru - http://bugs.debian.org/660195 [rt.cpan.org #28632] Make EU::MM pass LD through to recursive Makefile.PL invocations
        DEBPKG:debian/perl5db-x-terminal-emulator.patch - http://bugs.debian.org/668490 Invoke x-terminal-emulator rather than xterm in perl5db.pl
        DEBPKG:debian/cpan-missing-site-dirs - http://bugs.debian.org/688842 Fix CPAN::FirstTime defaults with nonexisting site dirs if a parent is writable
        DEBPKG:fixes/memoize_storable_nstore - [rt.cpan.org #77790] http://bugs.debian.org/587650 Memoize::Storable: respect 'nstore' option not respected
        DEBPKG:fixes/net_ftp_failed_command - [rt.cpan.org #37700] http://bugs.debian.org/491062 Net::FTP: cope gracefully with a failed command
        DEBPKG:fixes/perlbug-patchlist - [3541c11] http://bugs.debian.org/710842 [perl #118433] Make perlbug look up the list of local patches at run time
        DEBPKG:fixes/module_metadata_security_doc - [68cdd4b] CVE-2013-1437 documentation fix
        DEBPKG:fixes/module_metadata_taint_fix - [bff978f] http://bugs.debian.org/722210 [rt.cpan.org #88576] untaint version, if needed, in Module::Metadata
        DEBPKG:fixes/IPC-SysV-spelling - http://bugs.debian.org/730558 [rt.cpan.org #86736] Fix spelling of IPC_CREAT in IPC-SysV documentation
        DEBPKG:fixes/fix-undef-source -
        DEBPKG:fixes/CVE-2013-7422.patch - [PATCH] [perl #119505] Segfault from bad backreference
        DEBPKG:fixes/CVE-2014-4330.patch - [PATCH] don't recurse infinitely in Data::Dumper
        DEBPKG:fixes/CVE-2016-2381.patch - [PATCH 1/2] remove duplicate environment variables from environ
  Built under linux
  Compiled at Mar  1 2016 17:15:04
  @INC:
    /etc/perl
    /usr/local/lib/perl/5.18.2
    /usr/local/share/perl/5.18.2
    /usr/lib/perl5
    /usr/share/perl5
    /usr/lib/perl/5.18
    /usr/share/perl/5.18
    /usr/local/lib/site_perl
    .

It seems the system perl was built against a different kernel version 3.13.0-79-generic. Could this be the problem? Plz help! Let me know if you need any more info. Thanks.


来源: stackexchange

问:
Delphi Printing Techniques
Where can I find a good resource for adding print capabilities to my program?

I found this page: http://efg2.com/Lab/Library/Delphi/Printing/index.html but it hasn't been updated in 5 years, and I'd like to know if, with Delphi 2009, StretchDIBits is still preferred to StretchDrawMap, how to best support pagination, preview, etc.

To date, I've cheated by creating html or pdf documents than printing those, but it is a bit onerous to go this far for all print tasks.

答: ReportBuilder Pro is a very good report generator for adding printing capabilities to your program.</p>

OwnerDisplayName: Zartog

ContentLicense: CC BY-SA 2.5

Title: Delphi Printing Techniques

OwnerDisplayName: Lars Truijens


问:
Mixed project solutions in VS2010- managed and native
I've been writing a program that serves in two primary parts- managed UI and native back-end (C# and C++). However, suddenly, Visual Studio thinks that when I try to run the solution, I'm tryng to run the native back-end (a DLL) and throws an error. When I start the exe manually, it won't break on my breakpoints, and suchlike - even though I've enabled mixed debugging. How can I set it back to the original settings- mixed mode debugging and start the managed .exe when launching? I'm in Visual Studio 2010.

I think that this is probably caused because I had a blue-screen in the middle yesterday, and this is the first serious work I've done on it since.

答:
It sounds like you just need to set the managed project as the startup project in Visual Studio.

Open Solution Explorer

Right click on the project and select "Startup Project"


问:
Jest fails to transpile import from npm linked module
I have a project with multiple modules (using Lerna) and I want to use Jest to run tests. However, when I test code that uses a shared module (npm linked module via Lerna) it seems that Babel is not correctly applied and I get the following error:

```<code>SyntaxError: Unexpected token import
</code>```

The structure of my project is like this:

```<code>- my-project
|- shared
|- native
|- web
</code>```

web and native require the shared module. When I go into the shared directory and run the local tests in Jest everything works fine. If I run Jest tests in the web directory the above error occurs as soon as I include something from shared.

Here is a super simple test that causes the error:

```<code>import { util } from 'shared';

it('returns false if not prod', () => {
    expect(util.isProd()).toBe(false);
});
</code>```

My .babelrc looks like this:

```<code>{
    "presets": [
        "env",
        "flow",
        "react"
        ],
    "plugins": [
        "flow-react-proptypes",
        "transform-object-rest-spread",
        "transform-class-properties"
    ]
}
</code>```

I tried everything I could find, including:

Different Babel configs, including one with the es2015 preset and enabling modules for the test environment

Manually setting the transform option for babel-jest

As mentioned, Jest can be executed in the shared module, thus, Jest and babel-jest are installed there as well.

答:
I had to change the transformIgnorePatterns configuration option of Jest in the package.json of the web module.

```<code>{
    "jest": {
        "transformIgnorePatterns": [
            "<rootDir>/node_modules/(?!shared|another)"
        ]
    },
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I have a project with multiple modules (using Lerna) and I want to use Jest to run tests. However, when I test code that uses a shared module (npm linked module via Lerna) it seems that Babel is not correctly applied and I get the following error:

SyntaxError: Unexpected token import

The structure of my project is like this:

- my-project
|- shared
|- native
|- web

web and native require the shared module. When I go into the shared directory and run the local tests in Jest everything works fine. If I run Jest tests in the web directory the above error occurs as soon as I include something from shared.

Here is a super simple test that causes the error:

import { util } from 'shared';

it('returns false if not prod', () => {
    expect(util.isProd()).toBe(false);
});

My .babelrc looks like this:

{
    "presets": [
        "env",
        "flow",
        "react"
        ],
    "plugins": [
        "flow-react-proptypes",
        "transform-object-rest-spread",
        "transform-class-properties"
    ]
}

I tried everything I could find, including:

Different Babel configs, including one with the es2015 preset and enabling modules for the test environment

Manually setting the transform option for babel-jest

As mentioned, Jest can be executed in the shared module, thus, Jest and babel-jest are installed there as well.

Body:
I had to change the transformIgnorePatterns configuration option of Jest in the package.json of the web module.

{
    "jest": {
        "transformIgnorePatterns": [
            "<rootDir>/node_modules/(?!shared|another)"
        ]
    },
}


问:
Demuxing audio tracks from .mp4 using mp4box
I have an .mp4 file that contains multiple audio tracks. The audio tracks are encoded using the ALAC codec. I want to extract those using mp4box.

What I've tryed so far for extracting a track is this:

```<code>mp4box -single 1 "inputfile.mp4" -out "outputfile.m4a"
</code>```

What happens is, it works as that a outputfile.m4a is created, but something with the header/codec/file info seems to be malformated. I can open and play the file in VLC, but it fails to open with Windows Media Player/Windows Media Foundation (which I need). So either I am doing something wrong during the extraction or mp4box puts the file in a weird format.

The output of mp4box -info -v "outputfile.mp4" looks like this:

[iso file] Current top box start before parsing 0
[iso file] Read Box type ftyp size 20 start 0
[iso file] Current top box start before parsing 20
[iso file] Read Box type mdat size 8555577 start 20
[iso file] Current top box start before parsing 8555597
[iso file] Read Box type free size 75 start 8555597
[iso file] Current top box start before parsing 8555672
[iso file] Read Box type moov size 4895 start 8555672
[iso file] Read Box type mvhd size 108 start 8555680
[iso file] Read Box type trak size 4779 start 8555788
[iso file] Read Box type tkhd size 92 start 8555796
[iso file] Read Box type mdia size 4679 start 8555888
[iso file] Read Box type mdhd size 32 start 8555896
[iso file] Read Box type hdlr size 55 start 8555928
[iso file] Read Box type minf size 4584 start 8555983
[iso file] Read Box type smhd size 16 start 8555991
[iso file] Read Box type dinf size 36 start 8556007
[iso file] Read Box type dref size 28 start 8556015
[iso file] Read Box type url  size 12 start 8556031
[iso file] Read Box type stbl size 4524 start 8556043
[iso file] Read Box type stsd size 108 start 8556051
[iso file] Read Box type alac size 92 start 8556067
[iso file] Read Box type stts size 24 start 8556159
[iso file] Read Box type stsc size 40 start 8556183
[iso file] Read Box type stsz size 3936 start 8556223
[iso file] Read Box type stco size 408 start 8560159
[iso file] Read Box type alac size 36 start 28
[iso file] Read Box type btrt size 20 start 64
* Movie Info *
        Timescale 600 - 1 track
        Computed Duration 00:01:30.928 - Indicated Duration 00:01:30.928
        Fragmented File: no
        File Brand isom - version 1
        Created: GMT Thu Dec 17 14:35:48 2015
        Modified: GMT Thu Dec 17 14:35:48 2015

File has no MPEG4 IOD/OD

Track # 1 Info - TrackID 1 - TimeScale 44100
Media Duration 00:01:30.929 - Indicated Duration 00:01:30.929
Media Info: Language "und (und)" - Type "soun:alac" - 979 samples
Audio Track - Sample Rate 44100 - 2 channel(s)
[ISOM Tools] codec parameters not known - setting codecs string to default value "alac"
        RFC6381 Codec Parameters: alac
        All samples are sync```
</div>
</div>
</p>

<p>I also tryed extracting the audio tracks using the <code>-raw</code> flag like this:</p>

```mp4box -raw 1 "inputfile.mp4"
```

It creates a inputfile.mp4_track1.alac file, which I can't open in any player (not even VLC). Looking at it in a HEX editor it looks like the raw data segment (which makes sense I guess), but I can't get mp4box to put it back into a .m4a which I can play.

So I guess the question is has anybody experience with mp4box? Am I maybe missing some flag while extracting? Or is mp4box simply producing wrong results? I hope somebody can point me in the right direction. Thanks in advance!

答:
mp4box has extracted the raw audio stream to the file inputfile.mp4_track1.alac.

I can see two reasons why Windows Media Player cannot play it whereas VLC does :
- WMP does not support raw stream and and can only play audio stream encapsulated/muxed into a file container (e.g. : .MP4, .MKV, .AVI) ;
and/or
- WMP does not support natively ALAC format and you don't have this audio codec installed on your machine (try FFDShow).

Body:
I have an .mp4 file that contains multiple audio tracks. The audio tracks are encoded using the ALAC codec. I want to extract those using mp4box.

What I've tryed so far for extracting a track is this:

mp4box -single 1 "inputfile.mp4" -out "outputfile.m4a"

What happens is, it works as that a outputfile.m4a is created, but something with the header/codec/file info seems to be malformated. I can open and play the file in VLC, but it fails to open with Windows Media Player/Windows Media Foundation (which I need). So either I am doing something wrong during the extraction or mp4box puts the file in a weird format.

The output of mp4box -info -v "outputfile.mp4" looks like this:

[iso file] Current top box start before parsing 0
[iso file] Read Box type ftyp size 20 start 0
[iso file] Current top box start before parsing 20
[iso file] Read Box type mdat size 8555577 start 20
[iso file] Current top box start before parsing 8555597
[iso file] Read Box type free size 75 start 8555597
[iso file] Current top box start before parsing 8555672
[iso file] Read Box type moov size 4895 start 8555672
[iso file] Read Box type mvhd size 108 start 8555680
[iso file] Read Box type trak size 4779 start 8555788
[iso file] Read Box type tkhd size 92 start 8555796
[iso file] Read Box type mdia size 4679 start 8555888
[iso file] Read Box type mdhd size 32 start 8555896
[iso file] Read Box type hdlr size 55 start 8555928
[iso file] Read Box type minf size 4584 start 8555983
[iso file] Read Box type smhd size 16 start 8555991
[iso file] Read Box type dinf size 36 start 8556007
[iso file] Read Box type dref size 28 start 8556015
[iso file] Read Box type url  size 12 start 8556031
[iso file] Read Box type stbl size 4524 start 8556043
[iso file] Read Box type stsd size 108 start 8556051
[iso file] Read Box type alac size 92 start 8556067
[iso file] Read Box type stts size 24 start 8556159
[iso file] Read Box type stsc size 40 start 8556183
[iso file] Read Box type stsz size 3936 start 8556223
[iso file] Read Box type stco size 408 start 8560159
[iso file] Read Box type alac size 36 start 28
[iso file] Read Box type btrt size 20 start 64
* Movie Info *
        Timescale 600 - 1 track
        Computed Duration 00:01:30.928 - Indicated Duration 00:01:30.928
        Fragmented File: no
        File Brand isom - version 1
        Created: GMT Thu Dec 17 14:35:48 2015
        Modified: GMT Thu Dec 17 14:35:48 2015

File has no MPEG4 IOD/OD

Track # 1 Info - TrackID 1 - TimeScale 44100
Media Duration 00:01:30.929 - Indicated Duration 00:01:30.929
Media Info: Language "und (und)" - Type "soun:alac" - 979 samples
Audio Track - Sample Rate 44100 - 2 channel(s)
[ISOM Tools] codec parameters not known - setting codecs string to default value "alac"
        RFC6381 Codec Parameters: alac
        All samples are sync

I also tryed extracting the audio tracks using the -raw flag like this:

mp4box -raw 1 "inputfile.mp4"

It creates a inputfile.mp4_track1.alac file, which I can't open in any player (not even VLC). Looking at it in a HEX editor it looks like the raw data segment (which makes sense I guess), but I can't get mp4box to put it back into a .m4a which I can play.

So I guess the question is has anybody experience with mp4box? Am I maybe missing some flag while extracting? Or is mp4box simply producing wrong results? I hope somebody can point me in the right direction. Thanks in advance!


问:
Creating D2D1 Factory and Hwnd Render Target
I successfully created an empty window that would open and sit there until I closed it. Next, I wanted to try using Direct 2-D to draw something simple to that window. I created a class that would initialize Direct 2-D and then draw to the window, but after I added this class, my window would no longer open. After fiddling around with it a bit, it is now opening but then freezing and I get a message saying "a problem occurred causing the program to misbehave," and a button to "close program."

The window went from not opening to opening and then giving me the error after I added the return false if not s_ok seen below

```<code>//creating factory
HRESULT d2dFactHRes = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &Direct2DFactory);
    if (!S_OK)
        return false;

    //creating render target.
    HRESULT RenTargHRes = Direct2DFactory->CreateHwndRenderTarget(D2D1::RenderTargetProperties(D2D1_RENDER_TARGET_TYPE_DEFAULT, D2D1::PixelFormat(), 0.0F, 0.0F, D2D1_RENDER_TARGET_USAGE_NONE, D2D1_FEATURE_LEVEL_DEFAULT), D2D1_HWND_RENDER_TARGET_PROPERTIES(), &pRT);
    if (!S_OK)
        return false;
</code>```

I put a break point to try and check the return value of the EndDraw() function, and when I started the debugger, I got an error saying "unhandled exception occured at 0x00E4264F, an access violation occurred while reading 0x00000000 from location 0xC0000005"

I think this error occurred in the BeginDraw function before it got to the break point.

```<code>void Graphics::BeginDraw()
{
    pRT->BeginDraw(); //pRT is pointer to render target.
}
</code>```

I have no idea what this means. I assume something wasn't in memory that it was trying to read?

I'd appreciate any advice. Thanks.

答:
The issue is that (presumably) your initialization code never runs to completion. It's the if (!S_OK) return false; statement that bails out early, right after creating the device factory. S_OK is defined as 0, !0 is always true (as your compiler warned you, in vain).

The net effect is, that pRT never gets a pointer assigned, and the first time you dereference it, the system pops up the access violation dialog.

What you need to do instead is evaluate the return values (HRESULT's). In COM programming it is common to use the SUCCEEDED, and FAILED macros, e.g.:

```<code>if ( FAILED( d2dFactHRes ) )
    return false;
</code>```

Body:
I successfully created an empty window that would open and sit there until I closed it. Next, I wanted to try using Direct 2-D to draw something simple to that window. I created a class that would initialize Direct 2-D and then draw to the window, but after I added this class, my window would no longer open. After fiddling around with it a bit, it is now opening but then freezing and I get a message saying "a problem occurred causing the program to misbehave," and a button to "close program."

The window went from not opening to opening and then giving me the error after I added the return false if not s_ok seen below

//creating factory
HRESULT d2dFactHRes = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &Direct2DFactory);
    if (!S_OK)
        return false;

    //creating render target.
    HRESULT RenTargHRes = Direct2DFactory->CreateHwndRenderTarget(D2D1::RenderTargetProperties(D2D1_RENDER_TARGET_TYPE_DEFAULT, D2D1::PixelFormat(), 0.0F, 0.0F, D2D1_RENDER_TARGET_USAGE_NONE, D2D1_FEATURE_LEVEL_DEFAULT), D2D1_HWND_RENDER_TARGET_PROPERTIES(), &pRT);
    if (!S_OK)
        return false;

I put a break point to try and check the return value of the EndDraw() function, and when I started the debugger, I got an error saying "unhandled exception occured at 0x00E4264F, an access violation occurred while reading 0x00000000 from location 0xC0000005"

I think this error occurred in the BeginDraw function before it got to the break point.

void Graphics::BeginDraw()
{
    pRT->BeginDraw(); //pRT is pointer to render target.
}

I have no idea what this means. I assume something wasn't in memory that it was trying to read?

I'd appreciate any advice. Thanks.

Body:
The issue is that (presumably) your initialization code never runs to completion. It's the if (!S_OK) return false; statement that bails out early, right after creating the device factory. S_OK is defined as 0, !0 is always true (as your compiler warned you, in vain).

The net effect is, that pRT never gets a pointer assigned, and the first time you dereference it, the system pops up the access violation dialog.

What you need to do instead is evaluate the return values (HRESULT's). In COM programming it is common to use the SUCCEEDED, and FAILED macros, e.g.:

if ( FAILED( d2dFactHRes ) )
    return false;


问:
Setting a variable equal to the data attribute of the current selected link
I need to set the variable current equal to the data attribute for the link which has been selected how can I do this. I know there are easier ways of doing what im trying to do but I need to do it this way.

I tried to create it but I can't do it.

$(".links").click(function(){
  var current = $(this).getAttribute("data-cat");
  $(current).addClass('hide');
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>ul{
  list-style-type: none;
}

ul li{
  display: inline-block;
}

ul li a{
  font-size: 20px;
  padding: 10px;
  background-color: yellow;
}

.change{
  background-color: red;
}

.hide{
  display: none;
}

.print{
  height: 100px;
  width: 100px;
  background-color: blue;
}</code>```

link1

link2

link3

```

答:
Use $.attr() and put a . in front of the cat name to create a class selector from current so you can target it. You could also put a . at the beginning of the data-cat values in your HTML.

$(".links").click(function(){
  var current = $(this).attr("data-cat");
  $('.' + current).addClass('hide');
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>ul{
  list-style-type: none;
}

ul li{
  display: inline-block;
}

ul li a{
  font-size: 20px;
  padding: 10px;
  background-color: yellow;
}

.change{
  background-color: red;
}

.hide{
  display: none;
}

.print{
  height: 100px;
  width: 100px;
  background-color: blue;
}</code>```

link1

link2

link3

```

Body:
I need to set the variable current equal to the data attribute for the link which has been selected how can I do this. I know there are easier ways of doing what im trying to do but I need to do it this way.

I tried to create it but I can't do it.

$(".links").click(function(){
  var current = $(this).getAttribute("data-cat");
  $(current).addClass('hide');
});

ul{
  list-style-type: none;
}

ul li{
  display: inline-block;
}

ul li a{
  font-size: 20px;
  padding: 10px;
  background-color: yellow;
}

.change{
  background-color: red;
}

.hide{
  display: none;
}

.print{
  height: 100px;
  width: 100px;
  background-color: blue;
}

link1

link2

link3

Body:
Use $.attr() and put a . in front of the cat name to create a class selector from current so you can target it. You could also put a . at the beginning of the data-cat values in your HTML.

$(".links").click(function(){
  var current = $(this).attr("data-cat");
  $('.' + current).addClass('hide');
});

ul{
  list-style-type: none;
}

ul li{
  display: inline-block;
}

ul li a{
  font-size: 20px;
  padding: 10px;
  background-color: yellow;
}

.change{
  background-color: red;
}

.hide{
  display: none;
}

.print{
  height: 100px;
  width: 100px;
  background-color: blue;
}

<ul>
  <li><a id="hi" class="links" data-cat="print" href="#">link1</a></li>
  <li><a class="links" data-cat="porfolio" href="#">link2</a></li>
  <li><a class="links" data-cat="print" href="#">link3</a></li>
</ul>

<div class="print">

</div>

<div class="porfolio">

</div>

<div class="print">

</div>

<script
  src="https://code.jquery.com/jquery-3.2.1.js"
  integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE="
  crossorigin="anonymous"></script>


问:
How to modify ckeditor placeholder plugin
I would like to modify the rendered result of ckeditor placeholder plugin and here s the  different manipulations i ve tried:

I added another element to placeholder dialog (manipulating dialog/placeholder.js file) and it s working fine

but for plugin.js file, all changes are not implemented. I even deleted the file, but nothing actually happened.

I need to display the cke_placeholder class and a data-type attribute to the source code of the placeholder rendered (example below)

```<code><span class="cke_placeholder" data-type=1>[[content]]</span>)
</code>```

答:
Eventually, it worked by only manipulating plugin.js file.
I suppose it was a cache problem</p>

Body:
I would like to modify the rendered result of ckeditor placeholder plugin and here s the  different manipulations i ve tried:

I added another element to placeholder dialog (manipulating dialog/placeholder.js file) and it s working fine

but for plugin.js file, all changes are not implemented. I even deleted the file, but nothing actually happened.

I need to display the cke_placeholder class and a data-type attribute to the source code of the placeholder rendered (example below)

[[content]])


问:
Two names for a C# static class
It's extremely lazy, but I'm wondering if it's possible to have two names point to the same static class in essence.

I have a long and descriptive static class name BusinessLogicServiceUtility (as example) and it's looking rather long-winded in code.

I'd love to use BLSU as an alternative, so I tried extending the long class with my short class name:

```<code>public static class BLSU : BusinessLogicServiceUtility
{
}
</code>```

Which probably looks noob but as it turns out, it doesn't work.

It looks as though I could wrap each method in the long class with a method inside the short class, but there's a lot of methods, which makes maintaining it a pain and circumvents the whole laziness goal.

Is there a way of assigning two names to one static class, or some other method simply "extending" a static class?

答:
You can create an alias for a type:

```<code>using BLSU = Your.Namespace.BusinessLogicServiceUtility;
</code>```

Accessing members of type:

```<code>BLSU.SomeStaticMethod();
</code>```

With C# 6 you can even go further - access static members of a type without having to qualify type name at all:

```<code>using static Your.Namespace.BusinessLogicServiceUtility;
</code>```

Accessing members of type:

```<code>SomeStaticMethod();
</code>```

Further reading: using Directive (C# Reference)

Title: Two names for a C# static class

Body:
It's extremely lazy, but I'm wondering if it's possible to have two names point to the same static class in essence.

I have a long and descriptive static class name BusinessLogicServiceUtility (as example) and it's looking rather long-winded in code.

I'd love to use BLSU as an alternative, so I tried extending the long class with my short class name:

public static class BLSU : BusinessLogicServiceUtility
{
}

Which probably looks noob but as it turns out, it doesn't work.

It looks as though I could wrap each method in the long class with a method inside the short class, but there's a lot of methods, which makes maintaining it a pain and circumvents the whole laziness goal.

Is there a way of assigning two names to one static class, or some other method simply "extending" a static class?

Body:
You can create an alias for a type:

using BLSU = Your.Namespace.BusinessLogicServiceUtility;

Accessing members of type:

BLSU.SomeStaticMethod();

With C# 6 you can even go further - access static members of a type without having to qualify type name at all:

using static Your.Namespace.BusinessLogicServiceUtility;

Accessing members of type:

SomeStaticMethod();

Further reading: using Directive (C# Reference)


问:
Check whether a String is not Null and not Empty
How can I check whether a string is not null and not empty?

```<code>public void doStuff(String str)
{
    if (str != null && str != "**here I want to check the 'str' is empty or not**")
    {
        /* handle empty string */
    }
    /* ... */
}
</code>```

答:
You can use the functional style of checking:</p>
```<code>Optional.ofNullable(str)
    .filter(s -> !(s.trim().isEmpty()))
    .ifPresent(result -> {
       // your query setup goes here
    });
</code>```

ContentLicense: CC BY-SA 4.0

Body:
How can I check whether a string is not null and not empty?

public void doStuff(String str)
{
    if (str != null && str != "**here I want to check the 'str' is empty or not**")
    {
        /* handle empty string */
    }
    /* ... */
}

Body:
You can use the functional style of checking:

Optional.ofNullable(str)
    .filter(s -> !(s.trim().isEmpty()))
    .ifPresent(result -> {
       // your query setup goes here
    });


问:
How to properly put a Uri from a local file into a Intent
I want my local image file (located at res/drawable) to be converted to a Uri, so I can put it into a Intent to start an Activity.

This is what I got until now:

```<code>    Intent sendIntent = new Intent();
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent.setType("image/*");

    Uri uri = Uri.fromFile(new File("/res/drawable/photo.jpg"));
    sendIntent.putExtra(Intent.EXTRA_STREAM, uri);

    startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.share)));
</code>```

Then, the activity that receives this intent, displays the image in a ImageView. Something like this:

```<code>    Uri imageUri = (Uri) getIntent().getParcelableExtra(Intent.EXTRA_STREAM);
    Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), imageUri);
    ImageView myImage = (ImageView) findViewById(R.id.imageView_receive);
    myImage.setImageBitmap(bitmap);
</code>```

But instead of displaying the image, it throws an java.io.FileNotFoundException

```<code>java.io.FileNotFoundException: No resource found for: android.resource://com.my.package/drawable/photo.jpg
</code>```

I searched and tried other ways to get a Uri through my file:

```<code>    Uri uri = Uri.parse("file:///res/drawable/photo.jpg");
    Uri uri = Uri.parse("android.resource://com.my.package/drawable/photo.jpg");
</code>```

But all of them returned the same error for me.

Why is my image not being recognized?

答:
You should create ContentProvider for your application, which will allow you to share resources.

Try this lib, it works awesome.
https://github.com/commonsguy/cwac-provider

Body:
I want my local image file (located at res/drawable) to be converted to a Uri, so I can put it into a Intent to start an Activity.

This is what I got until now:

    Intent sendIntent = new Intent();
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent.setType("image/*");

    Uri uri = Uri.fromFile(new File("/res/drawable/photo.jpg"));
    sendIntent.putExtra(Intent.EXTRA_STREAM, uri);

    startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.share)));

Then, the activity that receives this intent, displays the image in a ImageView. Something like this:

    Uri imageUri = (Uri) getIntent().getParcelableExtra(Intent.EXTRA_STREAM);
    Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), imageUri);
    ImageView myImage = (ImageView) findViewById(R.id.imageView_receive);
    myImage.setImageBitmap(bitmap);

But instead of displaying the image, it throws an java.io.FileNotFoundException

java.io.FileNotFoundException: No resource found for: android.resource://com.my.package/drawable/photo.jpg

I searched and tried other ways to get a Uri through my file:

    Uri uri = Uri.parse("file:///res/drawable/photo.jpg");
    Uri uri = Uri.parse("android.resource://com.my.package/drawable/photo.jpg");

But all of them returned the same error for me.

Why is my image not being recognized?


问:
AngularJS combining objects in array on properties
I have a large array of objects (1500+) and the objects match on one of the properties. So the overall number of objects could be reduced e.g. for better performance in ng-repeat.
I'm kind of new to AngularJS and JS itself, so help is much appreciated!

my Array of Objects (simplified)

```<code>myArray = [
    {
        "role": "user111",
        "operation": "create",
        "concept": "folder"
    },
    {
        "role": "user111",
        "operation": "create",
        "concept": "task"
    },
    {
        "role": "user111",
        "operation": "delete",
        "concept": "task"
    },
    {
        "role": "user222",
        "operation": "create",
        "concept": "folder"
    },
    {
        "role": "user222",
        "operation": "create",
        "concept": "task"
    },
    {
        "role": "user222",
        "operation": "delete",
        "concept": "task"
    }
]
</code>```

desired Output

```<code>dreamArray = [
    {
        "role": "user111",
        "operation": {
               "create": ["folder", "task"],
               "delete": ["task"]
                      }
    },
    {
        "role": "user222",
        "operation": {
                   "create": ["folder", "task"],
                   "delete": ["task"]
                      }
    }
]
</code>```

答:
Using reduce() and find()

```<code>var myArray = [{ role: "user111", operation: "create", concept: "folder" }, { role: "user111", operation: "create", concept: "task" }, { role: "user111", operation: "delete", concept: "task" }, { role: "user222", operation: "create", concept: "folder" }, { role: "user222", operation: "create", concept: "task" }, { role: "user222", operation: "delete", concept: "task" }],

const dreamArray = myArray.reduce((acc, item) => {
    let obj = acc.find(e => e.role === item.role);
  if(!obj){
    obj = {"role" : item.role, "operation": {[item.operation]: [item.concept]}};
    acc.push(obj);
  }else{
    obj.operation[item.operation] = obj.operation[item.operation] || [];
    obj.operation[item.operation].push(item.concept);
  }
  return acc;
}, []);

console.log(dreamArray);
</code>```

Body:
I have a large array of objects (1500+) and the objects match on one of the properties. So the overall number of objects could be reduced e.g. for better performance in ng-repeat.
I'm kind of new to AngularJS and JS itself, so help is much appreciated!

my Array of Objects (simplified)

myArray = [
    {
        "role": "user111",
        "operation": "create",
        "concept": "folder"
    },
    {
        "role": "user111",
        "operation": "create",
        "concept": "task"
    },
    {
        "role": "user111",
        "operation": "delete",
        "concept": "task"
    },
    {
        "role": "user222",
        "operation": "create",
        "concept": "folder"
    },
    {
        "role": "user222",
        "operation": "create",
        "concept": "task"
    },
    {
        "role": "user222",
        "operation": "delete",
        "concept": "task"
    }
]

desired Output

dreamArray = [
    {
        "role": "user111",
        "operation": {
               "create": ["folder", "task"],
               "delete": ["task"]
                      }
    },
    {
        "role": "user222",
        "operation": {
                   "create": ["folder", "task"],
                   "delete": ["task"]
                      }
    }
]

Body:
Using reduce() and find()

var myArray = [{ role: "user111", operation: "create", concept: "folder" }, { role: "user111", operation: "create", concept: "task" }, { role: "user111", operation: "delete", concept: "task" }, { role: "user222", operation: "create", concept: "folder" }, { role: "user222", operation: "create", concept: "task" }, { role: "user222", operation: "delete", concept: "task" }],

const dreamArray = myArray.reduce((acc, item) => {
    let obj = acc.find(e => e.role === item.role);
  if(!obj){
    obj = {"role" : item.role, "operation": {[item.operation]: [item.concept]}};
    acc.push(obj);
  }else{
    obj.operation[item.operation] = obj.operation[item.operation] || [];
    obj.operation[item.operation].push(item.concept);
  }
  return acc;
}, []);

console.log(dreamArray);


问:
Deferred binding failed
My application is throwing:

```<code>java.lang.RuntimeException: Deferred binding failed for 'com.mygwtapp.client.gin.ClientAppGinjector' (did you forget to inherit a required module?)
</code>```

on this code inside the EntryPoint:

```<code>private final ClientAppGinjector injector = GWT.create(ClientAppGinjector.class);
</code>```

What could be the problem?

Here's the full error Log:

```<code>java.lang.RuntimeException: Deferred binding failed for 'com.mygwtapp.client.gin.ClientAppGinjector' (did you forget to inherit a required module?)
    at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:53)
    at com.google.gwt.core.client.GWT.create(GWT.java:97)
    at com.mygwtapp.client.MainEntryPoint.<init>(MainEntryPoint.java:79)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:465)
    at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:375)
    at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
    at java.lang.Thread.run(Thread.java:722)
</code>```

答: I had the same problem. My getter method of Boolean object called getBooleanObject() instead of isBooleanObject(). Class JsonEncoderDecoder looked for method called isBooleanObject(), didn't find him, compilation failed. (gwt 2.8.0)

Title: Deferred binding failed

Body:
My application is throwing:

java.lang.RuntimeException: Deferred binding failed for 'com.mygwtapp.client.gin.ClientAppGinjector' (did you forget to inherit a required module?)

on this code inside the EntryPoint:

private final ClientAppGinjector injector = GWT.create(ClientAppGinjector.class);

What could be the problem?

Here's the full error Log:

java.lang.RuntimeException: Deferred binding failed for 'com.mygwtapp.client.gin.ClientAppGinjector' (did you forget to inherit a required module?)
    at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:53)
    at com.google.gwt.core.client.GWT.create(GWT.java:97)
    at com.mygwtapp.client.MainEntryPoint.<init>(MainEntryPoint.java:79)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:465)
    at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:375)
    at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
    at java.lang.Thread.run(Thread.java:722)


问:
dynamic button width in collection view cell
my collection view cell is full size..i have collection view cell and it contains button..i successfully display all button with it's title in collection view cell. but i am having one issue that some button title is too large..i want to change it's widht based on text...how to set button width based on text..i have vertical collection view

my array is

```<code>var arr = ["butto1 butto1 butto1","butto1 butto1butto1butto1","butto1","butto1 butto1butto1butto1"]
</code>```

I have searched so many time but still i haven't point out
...any on help me..Thank you

答:
You haven't given much information that would help in diagnosing your problem.

The button should automatically resize to fit the text unless you have set constraints that stop it from growing.

If you have set a left and a right constraint to equal a constant then it will not be able to grow.

As far as I can tell, you have two options.

Only set 3 out of 4 constraints. For example the following image has 3 constraints set which allow the button to grow downwards.

Set the right constraint to "Greater than or equal to" instead of "equal" in the interface builder. This will allow the button to grow to a maximum size which is specified by the constraints.

Also make sure to set your button to word wrap so that text continues on the next line.

Body:
my collection view cell is full size..i have collection view cell and it contains button..i successfully display all button with it's title in collection view cell. but i am having one issue that some button title is too large..i want to change it's widht based on text...how to set button width based on text..i have vertical collection view

my array is

var arr = ["butto1 butto1 butto1","butto1 butto1butto1butto1","butto1","butto1 butto1butto1butto1"]

I have searched so many time but still i haven't point out
...any on help me..Thank you


问:
Change value of a xml field based on condition using xslt
I need to change value of a field in xml based on some condition using xslt.

My input xml:

```<code><?xml version="1.0" encoding="UTF-8"?>
<rows>
    <item>
        <Name>ABC</Name>
        <ID>1234</ID>
    </item>
    <item>
        <Name>XYX</Name>
        <ID>234</ID>
    </item>
    <item>
        <Name>PXC</Name>
        <ID>456</ID>
    </item>
</rows>
</code>```

My XSL code:

```<code><?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
    <xsl:variable name="ID" select="/rows/item/ID"/>
    <xsl:template match="/rows/item/ID">
        <xsl:choose>
            <xsl:when test="$ID = '1234'">1001</xsl:when>
            <xsl:when test="$ID = '234'">1002</xsl:when>
            <xsl:when test="$ID = '456'">1003</xsl:when>
            <xsl:when test="$ID = '789'">1004</xsl:when>
            <xsl:when test="$ID = '1903'">1005</xsl:when>
            <xsl:otherwise>
                <xsl:message terminate="no">SEVERE: No ID Mapping is found <xsl:value-of select="$ID"/>
                </xsl:message>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
</xsl:stylesheet>
</code>```

Output xml:

```<code><rows>
    <item>
        <Name>ABC</Name>
        1001
    </item>
    <item>
        <Name>XYX</Name>
        1001
    </item>
    <item>
        <Name>PXC</Name>
        1001
    </item>
</rows>
</code>```

i am expecting the value of ID field to change based on my choose condition. And if a value that is not maintained in the choose condition comes then it should throw error.

But the output xml is missing the xml tag for ID field and also the first choose condition value is applied to below items. Kindly help me in correcting the code.

答:
To add the missing tags, place the contents of your template inside a xsl:copy instruction. Or change the template to match only the text node within ID.

I suspect you have another problem here, though. An XSLT variable stores a value, not an expression. In your example, the ID variable stores the value of 1001 (the first item's ID), and it will be replicated to all items alike - as your output shows. If you want the actual output to be determined by each ID individual value, you cannot use a global variable.

Try the following approach instead:

XSLT 1.0

```<code><xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>

<!-- identity transform -->
<xsl:template match="@*|node()">
    <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
</xsl:template>

<xsl:template match="ID">
    <xsl:copy>
        <xsl:choose>
            <xsl:when test=". = '1234'">1001</xsl:when>
            <xsl:when test=". = '234'">1002</xsl:when>
            <xsl:when test=". = '456'">1003</xsl:when>
            <xsl:when test=". = '789'">1004</xsl:when>
            <xsl:when test=". = '1903'">1005</xsl:when>
            <xsl:otherwise>
                <xsl:message terminate="no">SEVERE: No ID Mapping is found <xsl:value-of select="."/></xsl:message>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:copy>
</xsl:template>

</xsl:stylesheet>
</code>```

Body:
I need to change value of a field in xml based on some condition using xslt.

My input xml:

<?xml version="1.0" encoding="UTF-8"?>
<rows>
    <item>
        <Name>ABC</Name>
        <ID>1234</ID>
    </item>
    <item>
        <Name>XYX</Name>
        <ID>234</ID>
    </item>
    <item>
        <Name>PXC</Name>
        <ID>456</ID>
    </item>
</rows>

My XSL code:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
    <xsl:variable name="ID" select="/rows/item/ID"/>
    <xsl:template match="/rows/item/ID">
        <xsl:choose>
            <xsl:when test="$ID = '1234'">1001</xsl:when>
            <xsl:when test="$ID = '234'">1002</xsl:when>
            <xsl:when test="$ID = '456'">1003</xsl:when>
            <xsl:when test="$ID = '789'">1004</xsl:when>
            <xsl:when test="$ID = '1903'">1005</xsl:when>
            <xsl:otherwise>
                <xsl:message terminate="no">SEVERE: No ID Mapping is found <xsl:value-of select="$ID"/>
                </xsl:message>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
</xsl:stylesheet>

Output xml:

<rows>
    <item>
        <Name>ABC</Name>
        1001
    </item>
    <item>
        <Name>XYX</Name>
        1001
    </item>
    <item>
        <Name>PXC</Name>
        1001
    </item>
</rows>

i am expecting the value of ID field to change based on my choose condition. And if a value that is not maintained in the choose condition comes then it should throw error.

But the output xml is missing the xml tag for ID field and also the first choose condition value is applied to below items. Kindly help me in correcting the code.

Body:
To add the missing tags, place the contents of your template inside a xsl:copy instruction. Or change the template to match only the text node within ID.

I suspect you have another problem here, though. An XSLT variable stores a value, not an expression. In your example, the ID variable stores the value of 1001 (the first item's ID), and it will be replicated to all items alike - as your output shows. If you want the actual output to be determined by each ID individual value, you cannot use a global variable.

Try the following approach instead:

XSLT 1.0

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>

<!-- identity transform -->
<xsl:template match="@*|node()">
    <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
</xsl:template>

<xsl:template match="ID">
    <xsl:copy>
        <xsl:choose>
            <xsl:when test=". = '1234'">1001</xsl:when>
            <xsl:when test=". = '234'">1002</xsl:when>
            <xsl:when test=". = '456'">1003</xsl:when>
            <xsl:when test=". = '789'">1004</xsl:when>
            <xsl:when test=". = '1903'">1005</xsl:when>
            <xsl:otherwise>
                <xsl:message terminate="no">SEVERE: No ID Mapping is found <xsl:value-of select="."/></xsl:message>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:copy>
</xsl:template>

</xsl:stylesheet>


问:
Java : Interface in a class is not accessible while importing

I am using the maven dependency hive-hcatalog-core in my program

and this jar present in the project maven dependencies, with the interface (as in the image-top).

The interface ICacheableMetaStoreClient , though present the class, is NOT  resolvable from import org.apache.hive.hcatalog.common. (image -bottom)

consequently, while doing a spark-submit,  I am getting the exception :

com.google.common.util.concurrent.UncheckedExecutionException:
  java.lang.IllegalArgumentException: interface
  org.apache.hive.hcatalog.common.HiveClientCache$ICacheableMetaStoreClient
  is  not visible from class loader

What do I need to do for this to be visible from the program class path.

答:
Lets look at the code:

```<code>class HiveClientCache {..}
</code>```

The HiveClientCache has only package level visibility and it along with ICacheableMetaStoreClientwont wont be available for import outside of that package (this includes in your code).

Now lets look at ICacheableMetaStoreClient:

```<code>@InterfaceAudience.Private
public interface ICacheableMetaStoreClient extends IMetaStoreClient {....}
</code>```

The interface is public but has annotation on it that makes the Hive/Hadoop additional preprocessing to check object type and throw IllegalArgumentException.

Here is the JavaDoc for InterfaceAudience:

Annotation to inform users of a package, class or method's intended
  audience. Currently the audience can be InterfaceAudience.Public,
  InterfaceAudience.LimitedPrivate or InterfaceAudience.Private. All
  public classes must have InterfaceAudience annotation.

Public classes that are not marked with this annotation must be considered by default as InterfaceAudience.Private.

External applications must only use classes that are marked InterfaceAudience.Public. Avoid using non public classes as these
  classes could be removed or change in incompatible ways.

Hadoop projects must only use classes that are marked InterfaceAudience.LimitedPrivate or InterfaceAudience.Public

Methods may have a different annotation that it is more restrictive compared to the audience classification of the class. Example: A class
  might be InterfaceAudience.Public, but a method may be
  InterfaceAudience.LimitedPrivate

Body:
Lets look at the code:

class HiveClientCache {..}

The HiveClientCache has only package level visibility and it along with ICacheableMetaStoreClientwont wont be available for import outside of that package (this includes in your code).

Now lets look at ICacheableMetaStoreClient:

@InterfaceAudience.Private
public interface ICacheableMetaStoreClient extends IMetaStoreClient {....}

The interface is public but has annotation on it that makes the Hive/Hadoop additional preprocessing to check object type and throw IllegalArgumentException.

Here is the JavaDoc for InterfaceAudience:

Annotation to inform users of a package, class or method's intended
  audience. Currently the audience can be InterfaceAudience.Public,
  InterfaceAudience.LimitedPrivate or InterfaceAudience.Private. All
  public classes must have InterfaceAudience annotation.

Public classes that are not marked with this annotation must be considered by default as InterfaceAudience.Private.

External applications must only use classes that are marked InterfaceAudience.Public. Avoid using non public classes as these
  classes could be removed or change in incompatible ways.

Hadoop projects must only use classes that are marked InterfaceAudience.LimitedPrivate or InterfaceAudience.Public

Methods may have a different annotation that it is more restrictive compared to the audience classification of the class. Example: A class
  might be InterfaceAudience.Public, but a method may be
  InterfaceAudience.LimitedPrivate