问:
Segmentation fault in ld.so, with my build of glibc
I have a local build of glibc.

When I run python from the command-line with it, it is successful:

```<code>LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda-7.5/lib64:/usr/local/cuda-8.0/lib64/cuda/lib64:$HOME/my_libc_env/lib/x86_64-linux-gnu/:$HOME/my_libc_env/usr/lib64/:$HOME/my_libc_env/usr/lib/"  $HOME/my_libc_env/lib/x86_64-linux-gnu/ld-2.17.so $HOME/anaconda2/envs/tf_011g/bin/python2.7
</code>```

When I wrap it inside a bash script, and call it from the command line, it is also successful. (I also replaced the python symbolic link with the bash script)

```<code>#!/bin/bash
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda-7.5/lib64:/usr/local/cuda-8.0/lib64/cuda/lib64:$HOME/my_libc_env/lib/x86_64-linux-gnu/:$HOME/my_libc_env/usr/lib64/:$HOME/my_libc_env/usr/lib/"  $HOME/my_libc_env/lib/x86_64-linux-gnu/ld-2.17.so $HOME/anaconda2/envs/tf_011g/bin/python2.7 "${@}"
</code>```

However, when my IDE debugger calls the bash script, I get Segmentation Fault.
Running it with LD_DEBUG=files,libs yields the output below.

Any idea how to fix that?

```<code>      5705:
      5705: file=libtinfo.so.5 [0];  needed by /bin/bash [0]
      5705: find library=libtinfo.so.5 [0]; searching
      5705:  search cache=/etc/ld.so.cache
      5705:   trying file=/lib64/libtinfo.so.5
      5705:
      5705: file=libtinfo.so.5 [0];  generating link map
      5705:   dynamic: 0x000000308fc1f1e0  base: 0x0000000000000000   size: 0x0000000000220260
      5705:     entry: 0x000000308fa0c840  phdr: 0x000000308fa00040  phnum:                  6
      5705:
      5705:
      5705: file=libdl.so.2 [0];  needed by /bin/bash [0]
      5705: find library=libdl.so.2 [0]; searching
      5705:  search cache=/etc/ld.so.cache
      5705:   trying file=/lib64/libdl.so.2
      5705:
      5705: file=libdl.so.2 [0];  generating link map
      5705:   dynamic: 0x0000003f8d802da0  base: 0x0000000000000000   size: 0x0000000000203100
      5705:     entry: 0x0000003f8d600de0  phdr: 0x0000003f8d600040  phnum:                  9
      5705:
      5705:
      5705: file=libc.so.6 [0];  needed by /bin/bash [0]
      5705: find library=libc.so.6 [0]; searching
      5705:  search cache=/etc/ld.so.cache
      5705:   trying file=/lib64/libc.so.6
      5705:
      5705: file=libc.so.6 [0];  generating link map
      5705:   dynamic: 0x0000003f8dd8db40  base: 0x0000000000000000   size: 0x0000000000393928
      5705:     entry: 0x0000003f8da1ee30  phdr: 0x0000003f8da00040  phnum:                 10
      5705:
      5705:
      5705: prelink checking: ok
      5705:
      5705: calling init: /lib64/libc.so.6
      5705:
      5705:
      5705: calling init: /lib64/libdl.so.2
      5705:
      5705:
      5705: calling init: /lib64/libtinfo.so.5
      5705:
      5705:
      5705: initialize program: /bin/bash
      5705:
      5705:
      5705: transferring control: /bin/bash
      5705:
      5705:
      5705: file=libnss_files.so.2 [0];  needed by /bin/bash [0]
      5705: find library=libnss_files.so.2 [0]; searching
      5705:  search cache=/etc/ld.so.cache
      5705:   trying file=/lib64/libnss_files.so.2
      5705:
      5705: file=libnss_files.so.2 [0];  generating link map
      5705:   dynamic: 0x00007f5963ec5df8  base: 0x00007f5963cb9000   size: 0x000000000020d590
      5705:     entry: 0x00007f5963cbb1f0  phdr: 0x00007f5963cb9040  phnum:                  9
      5705:
      5705:
      5705: calling init: /lib64/libnss_files.so.2
      5705:
      5705: opening file=/lib64/libnss_files.so.2 [0]; direct_opencount=1
      5705:
      5705:
      5705: file=libnss_nis.so.2 [0];  needed by /bin/bash [0]
      5705: find library=libnss_nis.so.2 [0]; searching
      5705:  search cache=/etc/ld.so.cache
      5705:   trying file=/lib64/libnss_nis.so.2
      5705:
      5705: file=libnss_nis.so.2 [0];  generating link map
      5705:   dynamic: 0x00007f5963cb7de0  base: 0x00007f5963aae000   size: 0x000000000020a4b8
      5705:     entry: 0x00007f5963ab0020  phdr: 0x00007f5963aae040  phnum:                  9
      5705:
      5705:
      5705: file=libnsl.so.1 [0];  needed by /lib64/libnss_nis.so.2 [0]
      5705: find library=libnsl.so.1 [0]; searching
      5705:  search cache=/etc/ld.so.cache
      5705:   trying file=/lib64/libnsl.so.1
      5705:
      5705: file=libnsl.so.1 [0];  generating link map
      5705:   dynamic: 0x0000003f9e015da8  base: 0x0000000000000000   size: 0x0000000000218ab0
      5705:     entry: 0x0000003f9de04070  phdr: 0x0000003f9de00040  phnum:                  9
      5705:
      5705:
      5705: calling init: /lib64/libnsl.so.1
      5705:
      5705:
      5705: calling init: /lib64/libnss_nis.so.2
      5705:
      5705: opening file=/lib64/libnss_nis.so.2 [0]; direct_opencount=1
      5705:
      5706: file=/home/user/anaconda2/envs/tf_011g/bin/python2.7 [0];  generating link map
      5706:   dynamic: 0x00000000006009c0  base: 0x0000000000000000   size: 0x0000000000200bf8
      5706:     entry: 0x0000000000400700  phdr: 0x0000000000400040  phnum:                  8
      5706:
      5706:
      5706: file=libpython2.7.so.1.0 [0];  needed by /home/user/anaconda2/envs/tf_011g/bin/python2.7 [0]
      5706: find library=libpython2.7.so.1.0 [0]; searching
      5706:  search path=/home/user/anaconda2/envs/tf_011g/bin/../lib/tls/x86_64:/home/user/anaconda2/envs/tf_011g/bin/../lib/tls:/home/user/anaconda2/envs/tf_011g/bin/../lib/x86_64:/home/user/anaconda2/envs/tf_011g/bin/../lib      (RPATH from file /home/user/anaconda2/envs/tf_011g/bin/python2.7)
      5706:   trying file=/home/user/anaconda2/envs/tf_011g/bin/../lib/tls/x86_64/libpython2.7.so.1.0
      5706:   trying file=/home/user/anaconda2/envs/tf_011g/bin/../lib/tls/libpython2.7.so.1.0
      5706:   trying file=/home/user/anaconda2/envs/tf_011g/bin/../lib/x86_64/libpython2.7.so.1.0
      5706:   trying file=/home/user/anaconda2/envs/tf_011g/bin/../lib/libpython2.7.so.1.0
      5706:
      5706: file=libpython2.7.so.1.0 [0];  generating link map
      5706:   dynamic: 0x00007fa7bcfd2c68  base: 0x00007fa7bcc37000   size: 0x00000000003fb4e0
      5706:     entry: 0x00007fa7bcc78250  phdr: 0x00007fa7bcc37040  phnum:                  5
      5706:
      5706:
      5706: file=libpthread.so.0 [0];  needed by /home/user/anaconda2/envs/tf_011g/bin/python2.7 [0]
      5706: find library=libpthread.so.0 [0]; searching
      5706:  search path=/home/user/anaconda2/envs/tf_011g/bin/../lib       (RPATH from file /home/user/anaconda2/envs/tf_011g/bin/python2.7)
      5706:   trying file=/home/user/anaconda2/envs/tf_011g/bin/../lib/libpthread.so.0
      5706:  search path=tls/x86_64:tls:x86_64::/usr/local/cuda-7.5/lib64/tls/x86_64:/usr/local/cuda-7.5/lib64/tls:/usr/local/cuda-7.5/lib64/x86_64:/usr/local/cuda-7.5/lib64:/usr/local/cuda-8.0/lib64/cuda/lib64/tls/x86_64:/usr/local/cuda-8.0/lib64/cuda/lib64/tls:/usr/local/cuda-8.0/lib64/cuda/lib64/x86_64:/usr/local/cuda-8.0/lib64/cuda/lib64:/my_libc_env/lib/x86_64-linux-gnu/tls/x86_64:/my_libc_env/lib/x86_64-linux-gnu/tls:/my_libc_env/lib/x86_64-linux-gnu/x86_64:/my_libc_env/lib/x86_64-linux-gnu:/my_libc_env/usr/lib64/tls/x86_64:/my_libc_env/usr/lib64/tls:/my_libc_env/usr/lib64/x86_64:/my_libc_env/usr/lib64:/my_libc_env/usr/lib/tls/x86_64:/my_libc_env/usr/lib/tls:/my_libc_env/usr/lib/x86_64:/my_libc_env/usr/lib       (LD_LIBRARY_PATH)
      5706:   trying file=tls/x86_64/libpthread.so.0
      5706:   trying file=tls/libpthread.so.0
      5706:   trying file=x86_64/libpthread.so.0
      5706:   trying file=libpthread.so.0
      5706:   trying file=/usr/local/cuda-7.5/lib64/tls/x86_64/libpthread.so.0
      5706:   trying file=/usr/local/cuda-7.5/lib64/tls/libpthread.so.0
      5706:   trying file=/usr/local/cuda-7.5/lib64/x86_64/libpthread.so.0
      5706:   trying file=/usr/local/cuda-7.5/lib64/libpthread.so.0
      5706:   trying file=/usr/local/cuda-8.0/lib64/cuda/lib64/tls/x86_64/libpthread.so.0
      5706:   trying file=/usr/local/cuda-8.0/lib64/cuda/lib64/tls/libpthread.so.0
      5706:   trying file=/usr/local/cuda-8.0/lib64/cuda/lib64/x86_64/libpthread.so.0
      5706:   trying file=/usr/local/cuda-8.0/lib64/cuda/lib64/libpthread.so.0
      5706:   trying file=/my_libc_env/lib/x86_64-linux-gnu/tls/x86_64/libpthread.so.0
      5706:   trying file=/my_libc_env/lib/x86_64-linux-gnu/tls/libpthread.so.0
      5706:   trying file=/my_libc_env/lib/x86_64-linux-gnu/x86_64/libpthread.so.0
      5706:   trying file=/my_libc_env/lib/x86_64-linux-gnu/libpthread.so.0
      5706:   trying file=/my_libc_env/usr/lib64/tls/x86_64/libpthread.so.0
      5706:   trying file=/my_libc_env/usr/lib64/tls/libpthread.so.0
      5706:   trying file=/my_libc_env/usr/lib64/x86_64/libpthread.so.0
      5706:   trying file=/my_libc_env/usr/lib64/libpthread.so.0
      5706:   trying file=/my_libc_env/usr/lib/tls/x86_64/libpthread.so.0
      5706:   trying file=/my_libc_env/usr/lib/tls/libpthread.so.0
      5706:   trying file=/my_libc_env/usr/lib/x86_64/libpthread.so.0
      5706:   trying file=/my_libc_env/usr/lib/libpthread.so.0
      5706:  search cache=/etc/ld.so.cache
      5706:   trying file=/lib64/libpthread.so.0
      5706:
      5706: file=libpthread.so.0 [0];  generating link map
      5706:   dynamic: 0x0000003f8e017d90  base: 0x0000000000000000   size: 0x000000000021c3f0
      5706:     entry: 0x0000003f8de05e30  phdr: 0x0000003f8de00040  phnum:                  9
      5706:
      5706:
      5706: file=libdl.so.2 [0];  needed by /home/user/anaconda2/envs/tf_011g/bin/python2.7 [0]
      5706: find library=libdl.so.2 [0]; searching
      5706:  search path=/home/user/anaconda2/envs/tf_011g/bin/../lib       (RPATH from file /home/user/anaconda2/envs/tf_011g/bin/python2.7)
      5706:   trying file=/home/user/anaconda2/envs/tf_011g/bin/../lib/libdl.so.2
      5706:  search path=tls/x86_64:tls:x86_64::/usr/local/cuda-7.5/lib64:/usr/local/cuda-8.0/lib64/cuda/lib64      (LD_LIBRARY_PATH)
      5706:   trying file=tls/x86_64/libdl.so.2
      5706:   trying file=tls/libdl.so.2
      5706:   trying file=x86_64/libdl.so.2
      5706:   trying file=libdl.so.2
      5706:   trying file=/usr/local/cuda-7.5/lib64/libdl.so.2
      5706:   trying file=/usr/local/cuda-8.0/lib64/cuda/lib64/libdl.so.2
      5706:  search cache=/etc/ld.so.cache
      5706:   trying file=/lib64/libdl.so.2
      5706:
      5706: file=libdl.so.2 [0];  generating link map
      5706:   dynamic: 0x0000003f8d802da0  base: 0x0000000000000000   size: 0x0000000000203100
      5706:     entry: 0x0000003f8d600de0  phdr: 0x0000003f8d600040  phnum:                  9
      5706:
      5706:
      5706: file=libutil.so.1 [0];  needed by /home/user/anaconda2/envs/tf_011g/bin/python2.7 [0]
      5706: find library=libutil.so.1 [0]; searching
      5706:  search path=/home/user/anaconda2/envs/tf_011g/bin/../lib       (RPATH from file /home/user/anaconda2/envs/tf_011g/bin/python2.7)
      5706:   trying file=/home/user/anaconda2/envs/tf_011g/bin/../lib/libutil.so.1
      5706:  search path=tls/x86_64:tls:x86_64::/usr/local/cuda-7.5/lib64:/usr/local/cuda-8.0/lib64/cuda/lib64      (LD_LIBRARY_PATH)
      5706:   trying file=tls/x86_64/libutil.so.1
      5706:   trying file=tls/libutil.so.1
      5706:   trying file=x86_64/libutil.so.1
      5706:   trying file=libutil.so.1
      5706:   trying file=/usr/local/cuda-7.5/lib64/libutil.so.1
      5706:   trying file=/usr/local/cuda-8.0/lib64/cuda/lib64/libutil.so.1
      5706:  search cache=/etc/ld.so.cache
      5706:   trying file=/lib64/libutil.so.1
      5706:
      5706: file=libutil.so.1 [0];  generating link map
      5706:   dynamic: 0x0000003f9fe01e10  base: 0x0000000000000000   size: 0x0000000000202100
      5706:     entry: 0x0000003f9fc00e10  phdr: 0x0000003f9fc00040  phnum:                  9
      5706:
      5706:
      5706: file=libm.so.6 [0];  needed by /home/user/anaconda2/envs/tf_011g/bin/python2.7 [0]
      5706: find library=libm.so.6 [0]; searching
      5706:  search path=/home/user/anaconda2/envs/tf_011g/bin/../lib       (RPATH from file /home/user/anaconda2/envs/tf_011g/bin/python2.7)
      5706:   trying file=/home/user/anaconda2/envs/tf_011g/bin/../lib/libm.so.6
      5706:  search path=tls/x86_64:tls:x86_64::/usr/local/cuda-7.5/lib64:/usr/local/cuda-8.0/lib64/cuda/lib64      (LD_LIBRARY_PATH)
      5706:   trying file=tls/x86_64/libm.so.6
      5706:   trying file=tls/libm.so.6
      5706:   trying file=x86_64/libm.so.6
      5706:   trying file=libm.so.6
      5706:   trying file=/usr/local/cuda-7.5/lib64/libm.so.6
      5706:   trying file=/usr/local/cuda-8.0/lib64/cuda/lib64/libm.so.6
      5706:  search cache=/etc/ld.so.cache
      5706:   trying file=/lib64/libm.so.6
      5706:
      5706: file=libm.so.6 [0];  generating link map
      5706:   dynamic: 0x0000003f8e882df8  base: 0x0000000000000000   size: 0x00000000002830b8
      5706:     entry: 0x0000003f8e603e70  phdr: 0x0000003f8e600040  phnum:                  9
      5706:
      5706:
      5706: file=libc.so.6 [0];  needed by /home/user/anaconda2/envs/tf_011g/bin/python2.7 [0]
      5706: find library=libc.so.6 [0]; searching
      5706:  search path=/home/user/anaconda2/envs/tf_011g/bin/../lib       (RPATH from file /home/user/anaconda2/envs/tf_011g/bin/python2.7)
      5706:   trying file=/home/user/anaconda2/envs/tf_011g/bin/../lib/libc.so.6
      5706:  search path=tls/x86_64:tls:x86_64::/usr/local/cuda-7.5/lib64:/usr/local/cuda-8.0/lib64/cuda/lib64      (LD_LIBRARY_PATH)
      5706:   trying file=tls/x86_64/libc.so.6
      5706:   trying file=tls/libc.so.6
      5706:   trying file=x86_64/libc.so.6
      5706:   trying file=libc.so.6
      5706:   trying file=/usr/local/cuda-7.5/lib64/libc.so.6
      5706:   trying file=/usr/local/cuda-8.0/lib64/cuda/lib64/libc.so.6
      5706:  search cache=/etc/ld.so.cache
      5706:   trying file=/lib64/libc.so.6
      5706:
      5706: file=libc.so.6 [0];  generating link map
      5706:   dynamic: 0x0000003f8dd8db40  base: 0x0000000000000000   size: 0x0000000000393928
      5706:     entry: 0x0000003f8da1ee30  phdr: 0x0000003f8da00040  phnum:                 10
      5706:
      5706:
      5706: calling init: /lib64/libpthread.so.0
      5706:
      5706:
      5706: calling init: /home/user/my_libc_env/lib/x86_64-linux-gnu/ld-2.17.so
      5706:
      5706:
      5706: calling init: /lib64/libc.so.6
      5706:
/home/user/anaconda2/envs/tf_011g/bin/python: line 12:  5706 Segmentation fault      (core dumped) LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda-7.5/lib64:/usr/local/cuda-8.0/lib64/cuda/lib64:$HOME/my_libc_env/lib/x86_64-linux-gnu/:$HOME/my_libc_env/usr/lib64/:$HOME/my_libc_env/usr/lib/" /home/user/my_libc_env/lib/x86_64-linux-gnu/ld-2.17.so /home/user/anaconda2/envs/tf_011g/bin/python2.7 "${@}"
      5705:
      5705: calling fini: /bin/bash [0]
      5705:
      5705:
      5705: calling fini: /lib64/libtinfo.so.5 [0]
      5705:
      5705:
      5705: calling fini: /lib64/libdl.so.2 [0]
      5705:
      5705:
      5705: calling fini: /lib64/libnss_nis.so.2 [0]
      5705:
      5705:
      5705: calling fini: /lib64/libnss_files.so.2 [0]
      5705:
      5705:
      5705: calling fini: /lib64/libnsl.so.1 [0]
      5705:
      5705:
      5705: calling fini: /lib64/libc.so.6 [0]
      5705:

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)
</code>```

答:
Your shell script contains:

```<code>LD_LIBRARY_PATH="...:$HOME/my_libc_env/lib/x86_64-linux-gnu/:..."
</code>```

and

```<code>$HOME/anaconda2/envs/tf_011g/bin/python2.7
</code>```

Your trace contains:

```<code>file=libpython2.7.so.1.0 [0];  needed by /home/user/anaconda2/envs/tf_011g/bin/python2.7
</code>```

and

```<code> trying file=/my_libc_env/lib/x86_64-linux-gnu/tls/x86_64/libpthread.so.0
  5706:   trying file=/my_libc_env/lib/x86_64-linux-gnu/tls/libpthread.so.0
  5706:   trying file=/my_libc_env/lib/x86_64-linux-gnu/x86_64/libpthread.so.0
</code>```

It appears that one expansion of $HOME produced /home/user, while another expansion of $HOME in the same shell script produced empty string.

That seems to be exceedingly unlikely to happen, so I suspect you've actually edited one or the other, and aren't telling us the whole truth, and nothing but the truth.

Anyway, it seems possible for $HOME to not be set when running from within IDE, and that would certainly explain both the search path observed, and the crash (the binary ended up loading /lib64/libpthread.so.0, which is not compatible with the ld-linux you are running it with).

Body:
I have a local build of glibc.

When I run python from the command-line with it, it is successful:

LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda-7.5/lib64:/usr/local/cuda-8.0/lib64/cuda/lib64:$HOME/my_libc_env/lib/x86_64-linux-gnu/:$HOME/my_libc_env/usr/lib64/:$HOME/my_libc_env/usr/lib/"  $HOME/my_libc_env/lib/x86_64-linux-gnu/ld-2.17.so $HOME/anaconda2/envs/tf_011g/bin/python2.7

When I wrap it inside a bash script, and call it from the command line, it is also successful. (I also replaced the python symbolic link with the bash script)

#!/bin/bash
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda-7.5/lib64:/usr/local/cuda-8.0/lib64/cuda/lib64:$HOME/my_libc_env/lib/x86_64-linux-gnu/:$HOME/my_libc_env/usr/lib64/:$HOME/my_libc_env/usr/lib/"  $HOME/my_libc_env/lib/x86_64-linux-gnu/ld-2.17.so $HOME/anaconda2/envs/tf_011g/bin/python2.7 "${@}"

However, when my IDE debugger calls the bash script, I get Segmentation Fault.
Running it with LD_DEBUG=files,libs yields the output below.

Any idea how to fix that?

      5705:
      5705: file=libtinfo.so.5 [0];  needed by /bin/bash [0]
      5705: find library=libtinfo.so.5 [0]; searching
      5705:  search cache=/etc/ld.so.cache
      5705:   trying file=/lib64/libtinfo.so.5
      5705:
      5705: file=libtinfo.so.5 [0];  generating link map
      5705:   dynamic: 0x000000308fc1f1e0  base: 0x0000000000000000   size: 0x0000000000220260
      5705:     entry: 0x000000308fa0c840  phdr: 0x000000308fa00040  phnum:                  6
      5705:
      5705:
      5705: file=libdl.so.2 [0];  needed by /bin/bash [0]
      5705: find library=libdl.so.2 [0]; searching
      5705:  search cache=/etc/ld.so.cache
      5705:   trying file=/lib64/libdl.so.2
      5705:
      5705: file=libdl.so.2 [0];  generating link map
      5705:   dynamic: 0x0000003f8d802da0  base: 0x0000000000000000   size: 0x0000000000203100
      5705:     entry: 0x0000003f8d600de0  phdr: 0x0000003f8d600040  phnum:                  9
      5705:
      5705:
      5705: file=libc.so.6 [0];  needed by /bin/bash [0]
      5705: find library=libc.so.6 [0]; searching
      5705:  search cache=/etc/ld.so.cache
      5705:   trying file=/lib64/libc.so.6
      5705:
      5705: file=libc.so.6 [0];  generating link map
      5705:   dynamic: 0x0000003f8dd8db40  base: 0x0000000000000000   size: 0x0000000000393928
      5705:     entry: 0x0000003f8da1ee30  phdr: 0x0000003f8da00040  phnum:                 10
      5705:
      5705:
      5705: prelink checking: ok
      5705:
      5705: calling init: /lib64/libc.so.6
      5705:
      5705:
      5705: calling init: /lib64/libdl.so.2
      5705:
      5705:
      5705: calling init: /lib64/libtinfo.so.5
      5705:
      5705:
      5705: initialize program: /bin/bash
      5705:
      5705:
      5705: transferring control: /bin/bash
      5705:
      5705:
      5705: file=libnss_files.so.2 [0];  needed by /bin/bash [0]
      5705: find library=libnss_files.so.2 [0]; searching
      5705:  search cache=/etc/ld.so.cache
      5705:   trying file=/lib64/libnss_files.so.2
      5705:
      5705: file=libnss_files.so.2 [0];  generating link map
      5705:   dynamic: 0x00007f5963ec5df8  base: 0x00007f5963cb9000   size: 0x000000000020d590
      5705:     entry: 0x00007f5963cbb1f0  phdr: 0x00007f5963cb9040  phnum:                  9
      5705:
      5705:
      5705: calling init: /lib64/libnss_files.so.2
      5705:
      5705: opening file=/lib64/libnss_files.so.2 [0]; direct_opencount=1
      5705:
      5705:
      5705: file=libnss_nis.so.2 [0];  needed by /bin/bash [0]
      5705: find library=libnss_nis.so.2 [0]; searching
      5705:  search cache=/etc/ld.so.cache
      5705:   trying file=/lib64/libnss_nis.so.2
      5705:
      5705: file=libnss_nis.so.2 [0];  generating link map
      5705:   dynamic: 0x00007f5963cb7de0  base: 0x00007f5963aae000   size: 0x000000000020a4b8
      5705:     entry: 0x00007f5963ab0020  phdr: 0x00007f5963aae040  phnum:                  9
      5705:
      5705:
      5705: file=libnsl.so.1 [0];  needed by /lib64/libnss_nis.so.2 [0]
      5705: find library=libnsl.so.1 [0]; searching
      5705:  search cache=/etc/ld.so.cache
      5705:   trying file=/lib64/libnsl.so.1
      5705:
      5705: file=libnsl.so.1 [0];  generating link map
      5705:   dynamic: 0x0000003f9e015da8  base: 0x0000000000000000   size: 0x0000000000218ab0
      5705:     entry: 0x0000003f9de04070  phdr: 0x0000003f9de00040  phnum:                  9
      5705:
      5705:
      5705: calling init: /lib64/libnsl.so.1
      5705:
      5705:
      5705: calling init: /lib64/libnss_nis.so.2
      5705:
      5705: opening file=/lib64/libnss_nis.so.2 [0]; direct_opencount=1
      5705:
      5706: file=/home/user/anaconda2/envs/tf_011g/bin/python2.7 [0];  generating link map
      5706:   dynamic: 0x00000000006009c0  base: 0x0000000000000000   size: 0x0000000000200bf8
      5706:     entry: 0x0000000000400700  phdr: 0x0000000000400040  phnum:                  8
      5706:
      5706:
      5706: file=libpython2.7.so.1.0 [0];  needed by /home/user/anaconda2/envs/tf_011g/bin/python2.7 [0]
      5706: find library=libpython2.7.so.1.0 [0]; searching
      5706:  search path=/home/user/anaconda2/envs/tf_011g/bin/../lib/tls/x86_64:/home/user/anaconda2/envs/tf_011g/bin/../lib/tls:/home/user/anaconda2/envs/tf_011g/bin/../lib/x86_64:/home/user/anaconda2/envs/tf_011g/bin/../lib      (RPATH from file /home/user/anaconda2/envs/tf_011g/bin/python2.7)
      5706:   trying file=/home/user/anaconda2/envs/tf_011g/bin/../lib/tls/x86_64/libpython2.7.so.1.0
      5706:   trying file=/home/user/anaconda2/envs/tf_011g/bin/../lib/tls/libpython2.7.so.1.0
      5706:   trying file=/home/user/anaconda2/envs/tf_011g/bin/../lib/x86_64/libpython2.7.so.1.0
      5706:   trying file=/home/user/anaconda2/envs/tf_011g/bin/../lib/libpython2.7.so.1.0
      5706:
      5706: file=libpython2.7.so.1.0 [0];  generating link map
      5706:   dynamic: 0x00007fa7bcfd2c68  base: 0x00007fa7bcc37000   size: 0x00000000003fb4e0
      5706:     entry: 0x00007fa7bcc78250  phdr: 0x00007fa7bcc37040  phnum:                  5
      5706:
      5706:
      5706: file=libpthread.so.0 [0];  needed by /home/user/anaconda2/envs/tf_011g/bin/python2.7 [0]
      5706: find library=libpthread.so.0 [0]; searching
      5706:  search path=/home/user/anaconda2/envs/tf_011g/bin/../lib       (RPATH from file /home/user/anaconda2/envs/tf_011g/bin/python2.7)
      5706:   trying file=/home/user/anaconda2/envs/tf_011g/bin/../lib/libpthread.so.0
      5706:  search path=tls/x86_64:tls:x86_64::/usr/local/cuda-7.5/lib64/tls/x86_64:/usr/local/cuda-7.5/lib64/tls:/usr/local/cuda-7.5/lib64/x86_64:/usr/local/cuda-7.5/lib64:/usr/local/cuda-8.0/lib64/cuda/lib64/tls/x86_64:/usr/local/cuda-8.0/lib64/cuda/lib64/tls:/usr/local/cuda-8.0/lib64/cuda/lib64/x86_64:/usr/local/cuda-8.0/lib64/cuda/lib64:/my_libc_env/lib/x86_64-linux-gnu/tls/x86_64:/my_libc_env/lib/x86_64-linux-gnu/tls:/my_libc_env/lib/x86_64-linux-gnu/x86_64:/my_libc_env/lib/x86_64-linux-gnu:/my_libc_env/usr/lib64/tls/x86_64:/my_libc_env/usr/lib64/tls:/my_libc_env/usr/lib64/x86_64:/my_libc_env/usr/lib64:/my_libc_env/usr/lib/tls/x86_64:/my_libc_env/usr/lib/tls:/my_libc_env/usr/lib/x86_64:/my_libc_env/usr/lib       (LD_LIBRARY_PATH)
      5706:   trying file=tls/x86_64/libpthread.so.0
      5706:   trying file=tls/libpthread.so.0
      5706:   trying file=x86_64/libpthread.so.0
      5706:   trying file=libpthread.so.0
      5706:   trying file=/usr/local/cuda-7.5/lib64/tls/x86_64/libpthread.so.0
      5706:   trying file=/usr/local/cuda-7.5/lib64/tls/libpthread.so.0
      5706:   trying file=/usr/local/cuda-7.5/lib64/x86_64/libpthread.so.0
      5706:   trying file=/usr/local/cuda-7.5/lib64/libpthread.so.0
      5706:   trying file=/usr/local/cuda-8.0/lib64/cuda/lib64/tls/x86_64/libpthread.so.0
      5706:   trying file=/usr/local/cuda-8.0/lib64/cuda/lib64/tls/libpthread.so.0
      5706:   trying file=/usr/local/cuda-8.0/lib64/cuda/lib64/x86_64/libpthread.so.0
      5706:   trying file=/usr/local/cuda-8.0/lib64/cuda/lib64/libpthread.so.0
      5706:   trying file=/my_libc_env/lib/x86_64-linux-gnu/tls/x86_64/libpthread.so.0
      5706:   trying file=/my_libc_env/lib/x86_64-linux-gnu/tls/libpthread.so.0
      5706:   trying file=/my_libc_env/lib/x86_64-linux-gnu/x86_64/libpthread.so.0
      5706:   trying file=/my_libc_env/lib/x86_64-linux-gnu/libpthread.so.0
      5706:   trying file=/my_libc_env/usr/lib64/tls/x86_64/libpthread.so.0
      5706:   trying file=/my_libc_env/usr/lib64/tls/libpthread.so.0
      5706:   trying file=/my_libc_env/usr/lib64/x86_64/libpthread.so.0
      5706:   trying file=/my_libc_env/usr/lib64/libpthread.so.0
      5706:   trying file=/my_libc_env/usr/lib/tls/x86_64/libpthread.so.0
      5706:   trying file=/my_libc_env/usr/lib/tls/libpthread.so.0
      5706:   trying file=/my_libc_env/usr/lib/x86_64/libpthread.so.0
      5706:   trying file=/my_libc_env/usr/lib/libpthread.so.0
      5706:  search cache=/etc/ld.so.cache
      5706:   trying file=/lib64/libpthread.so.0
      5706:
      5706: file=libpthread.so.0 [0];  generating link map
      5706:   dynamic: 0x0000003f8e017d90  base: 0x0000000000000000   size: 0x000000000021c3f0
      5706:     entry: 0x0000003f8de05e30  phdr: 0x0000003f8de00040  phnum:                  9
      5706:
      5706:
      5706: file=libdl.so.2 [0];  needed by /home/user/anaconda2/envs/tf_011g/bin/python2.7 [0]
      5706: find library=libdl.so.2 [0]; searching
      5706:  search path=/home/user/anaconda2/envs/tf_011g/bin/../lib       (RPATH from file /home/user/anaconda2/envs/tf_011g/bin/python2.7)
      5706:   trying file=/home/user/anaconda2/envs/tf_011g/bin/../lib/libdl.so.2
      5706:  search path=tls/x86_64:tls:x86_64::/usr/local/cuda-7.5/lib64:/usr/local/cuda-8.0/lib64/cuda/lib64      (LD_LIBRARY_PATH)
      5706:   trying file=tls/x86_64/libdl.so.2
      5706:   trying file=tls/libdl.so.2
      5706:   trying file=x86_64/libdl.so.2
      5706:   trying file=libdl.so.2
      5706:   trying file=/usr/local/cuda-7.5/lib64/libdl.so.2
      5706:   trying file=/usr/local/cuda-8.0/lib64/cuda/lib64/libdl.so.2
      5706:  search cache=/etc/ld.so.cache
      5706:   trying file=/lib64/libdl.so.2
      5706:
      5706: file=libdl.so.2 [0];  generating link map
      5706:   dynamic: 0x0000003f8d802da0  base: 0x0000000000000000   size: 0x0000000000203100
      5706:     entry: 0x0000003f8d600de0  phdr: 0x0000003f8d600040  phnum:                  9
      5706:
      5706:
      5706: file=libutil.so.1 [0];  needed by /home/user/anaconda2/envs/tf_011g/bin/python2.7 [0]
      5706: find library=libutil.so.1 [0]; searching
      5706:  search path=/home/user/anaconda2/envs/tf_011g/bin/../lib       (RPATH from file /home/user/anaconda2/envs/tf_011g/bin/python2.7)
      5706:   trying file=/home/user/anaconda2/envs/tf_011g/bin/../lib/libutil.so.1
      5706:  search path=tls/x86_64:tls:x86_64::/usr/local/cuda-7.5/lib64:/usr/local/cuda-8.0/lib64/cuda/lib64      (LD_LIBRARY_PATH)
      5706:   trying file=tls/x86_64/libutil.so.1
      5706:   trying file=tls/libutil.so.1
      5706:   trying file=x86_64/libutil.so.1
      5706:   trying file=libutil.so.1
      5706:   trying file=/usr/local/cuda-7.5/lib64/libutil.so.1
      5706:   trying file=/usr/local/cuda-8.0/lib64/cuda/lib64/libutil.so.1
      5706:  search cache=/etc/ld.so.cache
      5706:   trying file=/lib64/libutil.so.1
      5706:
      5706: file=libutil.so.1 [0];  generating link map
      5706:   dynamic: 0x0000003f9fe01e10  base: 0x0000000000000000   size: 0x0000000000202100
      5706:     entry: 0x0000003f9fc00e10  phdr: 0x0000003f9fc00040  phnum:                  9
      5706:
      5706:
      5706: file=libm.so.6 [0];  needed by /home/user/anaconda2/envs/tf_011g/bin/python2.7 [0]
      5706: find library=libm.so.6 [0]; searching
      5706:  search path=/home/user/anaconda2/envs/tf_011g/bin/../lib       (RPATH from file /home/user/anaconda2/envs/tf_011g/bin/python2.7)
      5706:   trying file=/home/user/anaconda2/envs/tf_011g/bin/../lib/libm.so.6
      5706:  search path=tls/x86_64:tls:x86_64::/usr/local/cuda-7.5/lib64:/usr/local/cuda-8.0/lib64/cuda/lib64      (LD_LIBRARY_PATH)
      5706:   trying file=tls/x86_64/libm.so.6
      5706:   trying file=tls/libm.so.6
      5706:   trying file=x86_64/libm.so.6
      5706:   trying file=libm.so.6
      5706:   trying file=/usr/local/cuda-7.5/lib64/libm.so.6
      5706:   trying file=/usr/local/cuda-8.0/lib64/cuda/lib64/libm.so.6
      5706:  search cache=/etc/ld.so.cache
      5706:   trying file=/lib64/libm.so.6
      5706:
      5706: file=libm.so.6 [0];  generating link map
      5706:   dynamic: 0x0000003f8e882df8  base: 0x0000000000000000   size: 0x00000000002830b8
      5706:     entry: 0x0000003f8e603e70  phdr: 0x0000003f8e600040  phnum:                  9
      5706:
      5706:
      5706: file=libc.so.6 [0];  needed by /home/user/anaconda2/envs/tf_011g/bin/python2.7 [0]
      5706: find library=libc.so.6 [0]; searching
      5706:  search path=/home/user/anaconda2/envs/tf_011g/bin/../lib       (RPATH from file /home/user/anaconda2/envs/tf_011g/bin/python2.7)
      5706:   trying file=/home/user/anaconda2/envs/tf_011g/bin/../lib/libc.so.6
      5706:  search path=tls/x86_64:tls:x86_64::/usr/local/cuda-7.5/lib64:/usr/local/cuda-8.0/lib64/cuda/lib64      (LD_LIBRARY_PATH)
      5706:   trying file=tls/x86_64/libc.so.6
      5706:   trying file=tls/libc.so.6
      5706:   trying file=x86_64/libc.so.6
      5706:   trying file=libc.so.6
      5706:   trying file=/usr/local/cuda-7.5/lib64/libc.so.6
      5706:   trying file=/usr/local/cuda-8.0/lib64/cuda/lib64/libc.so.6
      5706:  search cache=/etc/ld.so.cache
      5706:   trying file=/lib64/libc.so.6
      5706:
      5706: file=libc.so.6 [0];  generating link map
      5706:   dynamic: 0x0000003f8dd8db40  base: 0x0000000000000000   size: 0x0000000000393928
      5706:     entry: 0x0000003f8da1ee30  phdr: 0x0000003f8da00040  phnum:                 10
      5706:
      5706:
      5706: calling init: /lib64/libpthread.so.0
      5706:
      5706:
      5706: calling init: /home/user/my_libc_env/lib/x86_64-linux-gnu/ld-2.17.so
      5706:
      5706:
      5706: calling init: /lib64/libc.so.6
      5706:
/home/user/anaconda2/envs/tf_011g/bin/python: line 12:  5706 Segmentation fault      (core dumped) LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda-7.5/lib64:/usr/local/cuda-8.0/lib64/cuda/lib64:$HOME/my_libc_env/lib/x86_64-linux-gnu/:$HOME/my_libc_env/usr/lib64/:$HOME/my_libc_env/usr/lib/" /home/user/my_libc_env/lib/x86_64-linux-gnu/ld-2.17.so /home/user/anaconda2/envs/tf_011g/bin/python2.7 "${@}"
      5705:
      5705: calling fini: /bin/bash [0]
      5705:
      5705:
      5705: calling fini: /lib64/libtinfo.so.5 [0]
      5705:
      5705:
      5705: calling fini: /lib64/libdl.so.2 [0]
      5705:
      5705:
      5705: calling fini: /lib64/libnss_nis.so.2 [0]
      5705:
      5705:
      5705: calling fini: /lib64/libnss_files.so.2 [0]
      5705:
      5705:
      5705: calling fini: /lib64/libnsl.so.1 [0]
      5705:
      5705:
      5705: calling fini: /lib64/libc.so.6 [0]
      5705:

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

Body:
Your shell script contains:

LD_LIBRARY_PATH="...:$HOME/my_libc_env/lib/x86_64-linux-gnu/:..."

and

$HOME/anaconda2/envs/tf_011g/bin/python2.7

Your trace contains:

file=libpython2.7.so.1.0 [0];  needed by /home/user/anaconda2/envs/tf_011g/bin/python2.7

and

 trying file=/my_libc_env/lib/x86_64-linux-gnu/tls/x86_64/libpthread.so.0
  5706:   trying file=/my_libc_env/lib/x86_64-linux-gnu/tls/libpthread.so.0
  5706:   trying file=/my_libc_env/lib/x86_64-linux-gnu/x86_64/libpthread.so.0

It appears that one expansion of $HOME produced /home/user, while another expansion of $HOME in the same shell script produced empty string.

That seems to be exceedingly unlikely to happen, so I suspect you've actually edited one or the other, and aren't telling us the whole truth, and nothing but the truth.

Anyway, it seems possible for $HOME to not be set when running from within IDE, and that would certainly explain both the search path observed, and the crash (the binary ended up loading /lib64/libpthread.so.0, which is not compatible with the ld-linux you are running it with).


来源: stackexchange

问:
Error when using a facts counter library Countup.js?
So, i wanted to make fact counter for a theme i am developing. I decided to go with Countup.js. I loaded in my Index.html and everthyinh properly and tried to execute a basic function but it shows that CountUp is not defined in developer console in chrome. Here is the error.
Uncaught ReferenceError: countUp is not defined
    at custom.js:9
(anonymous) @ custom.js:9

My js code---

```<code> var numAmin = new CountUp("counter1", 0, 500);
 numAmin.start();
</code>```

My HTML code  ---

```<code> <i class="fa fa-desktop fa-5x fa-inverse targetone" id="counter1"></i>
</code>```

答:
Make sure to place jquery before countup.js and run script after document loads.

and add class="countupthis" and attribute numx="" to all elements you want to count up.

Set numx attribute to the number you want to count to.

.facthold {text-align:center; display:inline-block; border:1px solid black; padding:10px;}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><head>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
</head>
<body>
<div class="facthold"><i class="fa fa-desktop fa-3" aria-hidden="true"></i><br>
  <span class="countupthis" numx="28">2</span><div>Desktop users</div>
  </div>
<div class="facthold"><i class="fa fa-mobile fa-2" aria-hidden="true"></i><br>
  <span class="countupthis" numx="70">23</span><div>Mobile users</div>
  </div>

  <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script>
  <script src='https://cdnjs.cloudflare.com/ajax/libs/countup.js/1.8.2/countUp.min.js'></script>
  <script>
    $(document).ready(function() {
      var options = {
        useEasing: true,
          useGrouping: true,
          separator: ',',
          decimal: '.',
          prefix: '',
          suffix: ''
      };
      $('.countupthis').each(function() {
        var num = $(this).attr('numx'); //end count
        var nuen = $(this).text();
        if (nuen === "") {
          nuen = 0;
        }
        var counts = new CountUp(this, nuen, num, 0, 1.5, options);
        counts.start();
      });

    });
  </script>
</body></code>```

ContentLicense: CC BY-SA 3.0

Body:
So, i wanted to make fact counter for a theme i am developing. I decided to go with Countup.js. I loaded in my Index.html and everthyinh properly and tried to execute a basic function but it shows that CountUp is not defined in developer console in chrome. Here is the error.
Uncaught ReferenceError: countUp is not defined
    at custom.js:9
(anonymous) @ custom.js:9

My js code---

 var numAmin = new CountUp("counter1", 0, 500);
 numAmin.start();

My HTML code  ---

Body:
Make sure to place jquery before countup.js and run script after document loads.

and add class="countupthis" and attribute numx="" to all elements you want to count up.

Set numx attribute to the number you want to count to.

.facthold {text-align:center; display:inline-block; border:1px solid black; padding:10px;}

<head>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
</head>
<body>
<div class="facthold"><i class="fa fa-desktop fa-3" aria-hidden="true"></i><br>
  <span class="countupthis" numx="28">2</span><div>Desktop users</div>
  </div>
<div class="facthold"><i class="fa fa-mobile fa-2" aria-hidden="true"></i><br>
  <span class="countupthis" numx="70">23</span><div>Mobile users</div>
  </div>

  <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script>
  <script src='https://cdnjs.cloudflare.com/ajax/libs/countup.js/1.8.2/countUp.min.js'></script>
  <script>
    $(document).ready(function() {
      var options = {
        useEasing: true,
          useGrouping: true,
          separator: ',',
          decimal: '.',
          prefix: '',
          suffix: ''
      };
      $('.countupthis').each(function() {
        var num = $(this).attr('numx'); //end count
        var nuen = $(this).text();
        if (nuen === "") {
          nuen = 0;
        }
        var counts = new CountUp(this, nuen, num, 0, 1.5, options);
        counts.start();
      });

    });
  </script>
</body>


问:
Externalizing a module in Angular 2
So, i was working on my application and i realized that several modules could be extracted to separate libraries, that could be installed via NPM and reused across other applications. The current structure looks like this:

```<code>app/
    search/
        component1/
        component2/
        component3/
        search.module.ts
        search.service.ts
    login/
    register/
</code>```

Let's say i want to extract search, what's the first step? How do i organize this separate repository? Does it also have a src dir and a package.json? Is there any specific documentation on this topic?

答:
maybe this repo could help you

https://github.com/preboot/angular-library-seed

and this blog post:

http://blog.mgechev.com/2017/01/21/distributing-an-angular-library-aot-ngc-types/

or clone this repo, and custom as you need

https://github.com/ngx-translate/core

Title: Externalizing a module in Angular 2

Body:
So, i was working on my application and i realized that several modules could be extracted to separate libraries, that could be installed via NPM and reused across other applications. The current structure looks like this:

app/
    search/
        component1/
        component2/
        component3/
        search.module.ts
        search.service.ts
    login/
    register/

Let's say i want to extract search, what's the first step? How do i organize this separate repository? Does it also have a src dir and a package.json? Is there any specific documentation on this topic?


问:
JSON encode in as3
Can any one provide me with an example of how to encode data and pass it to a php file using JSON and flash?</p>

答:
You can use fast actionjson library for it. And vote for native encoder/decoder in ActionScript (FP-1631)

Now you can use native JSON with Flash Player 11

ContentLicense: CC BY-SA 2.5

Title: JSON encode in as3


问:
Cant get bourbon files imported in my site (show tree in post)
I believe a picture best describes my issue

https://postimg.org/gallery/37bdm2lp8/

Please see img for tree document

https://postimg.org/image/qsmm9rdx1/

My issue is a simple one, but I am not getting my main.sass which imports all the other sass files to for compiling to display the bourbon assets, so   my site isnt rendering the bourbon assets

I have tried the basic @import ../css/1-tools/bourbon but that doesnt work

Any help appreciated as the css isnt working now :(

答:
Since you are all ready using gulp, try using the actual Bourbon NPM package. You can add it to your package.json file and require it via your gulpfile.

How to: https://github.com/thoughtbot/bourbon#installing-with-npm-and-using-a-node-based-asset-pipeline

Here is the page for the Bourbon package: https://www.npmjs.com/package/bourbon

Here is an example gulpfile that uses bourbon (with some other stuff you can probably ignore): https://github.com/thoughtbot/bitters/blob/master/Gulpfile.js

The main parts of this example gulpfile that you would need to add are the require on line 1 and adding bourbon to your Sass includePaths on line 17.

edit ⤵

Once this is set up you'll want to change your sass import to the following:

```<code>@import "bourbon";
</code>```

Because of the addition to includePaths, gulp-sass will know where to look.

Body:
Since you are all ready using gulp, try using the actual Bourbon NPM package. You can add it to your package.json file and require it via your gulpfile.

How to: https://github.com/thoughtbot/bourbon#installing-with-npm-and-using-a-node-based-asset-pipeline

Here is the page for the Bourbon package: https://www.npmjs.com/package/bourbon

Here is an example gulpfile that uses bourbon (with some other stuff you can probably ignore): https://github.com/thoughtbot/bitters/blob/master/Gulpfile.js

The main parts of this example gulpfile that you would need to add are the require on line 1 and adding bourbon to your Sass includePaths on line 17.

edit ⤵

Once this is set up you'll want to change your sass import to the following:

@import "bourbon";

Because of the addition to includePaths, gulp-sass will know where to look.


问:
Delete "Reply to this comment" line: Word
I'm attempting to write a macro to automatically delete all "Reply to this comment" lines in a Word doc.

I can't figure out how to Find-Replace the entire line (including the paragraph mark).

The ASCII code for the paragraph mark is ^013.

The source text is typically copied from a blog post into Word similar to below.

答:
The solution is below. It counts occurrences, then loops through the text deleting the phrase and paragraph mark as it goes:</p>

```<code>Sub DeleteReplyComments()
  ' loop through lines to count Replies
    Selection.Find.ClearFormatting
    MyDoc = ActiveDocument.Range.Text
    txt = "Reply to this comment"
    t = Replace(MyDoc, txt, "")
    nCount = (Len(MyDoc) - Len(t)) / Len(txt)
  ' delete Replies and ^p's
    For i = 1 To nCount
        With Selection.Find
            .Text = "Reply to this comment"
            .Replacement.Text = ""
            .Forward = True
            .Wrap = wdFindContinue
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        Selection.Find.Execute
        Selection.MoveEnd Unit:=wdParagraph
        Selection.Delete Unit:=wdCharacter, Count:=1
    Next i
End Sub
</code>```

Body:
The solution is below. It counts occurrences, then loops through the text deleting the phrase and paragraph mark as it goes:

Sub DeleteReplyComments()
  ' loop through lines to count Replies
    Selection.Find.ClearFormatting
    MyDoc = ActiveDocument.Range.Text
    txt = "Reply to this comment"
    t = Replace(MyDoc, txt, "")
    nCount = (Len(MyDoc) - Len(t)) / Len(txt)
  ' delete Replies and ^p's
    For i = 1 To nCount
        With Selection.Find
            .Text = "Reply to this comment"
            .Replacement.Text = ""
            .Forward = True
            .Wrap = wdFindContinue
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        Selection.Find.Execute
        Selection.MoveEnd Unit:=wdParagraph
        Selection.Delete Unit:=wdCharacter, Count:=1
    Next i
End Sub


问:
How to implement the await keyword?
I have written a code to get the projects from the TFS 2013 server using the tfs web api. As the methord is taking too long to execute i.e like 1.5 minutes, so i wanted to make this methord as async. So i added the async and task in the return type. When i see in visual studio is shows a message that the methord does not have await keyword. where should i add the await keyword. I am very new to async programming.  </p>

```<code> public override async Task<List<Project>> GetProjects()
        {

        List<Project> retunResult = new List<Project>();

        using (var http = new HttpClient(GetHttpHandler()))
            {
            var response = http.GetAsync(_baseUrl + "_apis/projectCollections?" + tfsWebApiVersionSring).Result;
            if (response.IsSuccessStatusCode)
                {
                response.EnsureSuccessStatusCode();
                TFS2013TeamProjectCollection.Rootobject obj = JsonConvert.DeserializeObject<TFS2013TeamProjectCollection.Rootobject>(response.Content.ReadAsStringAsync().Result);
                if (obj != null)
                    {
                    foreach (TFS2013TeamProjectCollection.Value projColl in obj.value)
                        {

                        if (projColl.state == "Started")
                            {
                            var responseProj = http.GetAsync(_baseUrl + projColl.name + "/_apis/projects?" + tfsWebApiVersionSring).Result;
                            if (responseProj.IsSuccessStatusCode)
                                {
                                responseProj.EnsureSuccessStatusCode();
                                TFS2013TeamProject.Rootobject obj1 = JsonConvert.DeserializeObject<TFS2013TeamProject.Rootobject>(responseProj.Content.ReadAsStringAsync().Result);
                                if (obj1 != null)
                                    {
                                    Project p;
                                    foreach (TFS2013TeamProject.Value TeamProj in obj1.value)
                                        {
                                        p = new Project();
                                        p.collectionName = TeamProj.collection.name;
                                        p.description = TeamProj.description;
                                        p.id = TeamProj.id;
                                        p.name = TeamProj.name;
                                        p.collectionName = TeamProj.collection.name;
                                        p.url = TeamProj.url;

                                        retunResult.Add(p);
                                        }
                                    }
                                }
                            }
                        }
                    return retunResult;
                    }
                }
            }
        return null;
        }
</code>```

答:
You could refer to this code snippet about using TFS REST API to get something in async way.

```<code>public static async void RESTAPIMethod()
    {
        HttpClientHandler authtHandler = new HttpClientHandler()
        {
            Credentials = CredentialCache.DefaultNetworkCredentials
        };

        using (HttpClient client = new HttpClient(authtHandler))
        {
            client.DefaultRequestHeaders.Accept.Add(
                new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

            using (HttpResponseMessage response = client.GetAsync(
                "Put the REST API URL here").Result)
            {
                response.EnsureSuccessStatusCode();
                var responseBody = await response.Content.ReadAsStringAsync();

            }
        }
    }
</code>```

Another method about using TFS REST API:

You could also install this Nuget package for your project. Then using these assemblies in this package to run a REST API with C#. This is different with the method above, it's much more convenient. Here is an example about get a build information using Microsoft.TeamFoundation.Build.WebApi assembly in Async method.
Example:
What object returns from TFS2015 RestAPI

Title: How to implement the await keyword?

Body:
I have written a code to get the projects from the TFS 2013 server using the tfs web api. As the methord is taking too long to execute i.e like 1.5 minutes, so i wanted to make this methord as async. So i added the async and task in the return type. When i see in visual studio is shows a message that the methord does not have await keyword. where should i add the await keyword. I am very new to async programming.

 public override async Task<List<Project>> GetProjects()
        {

        List<Project> retunResult = new List<Project>();

        using (var http = new HttpClient(GetHttpHandler()))
            {
            var response = http.GetAsync(_baseUrl + "_apis/projectCollections?" + tfsWebApiVersionSring).Result;
            if (response.IsSuccessStatusCode)
                {
                response.EnsureSuccessStatusCode();
                TFS2013TeamProjectCollection.Rootobject obj = JsonConvert.DeserializeObject<TFS2013TeamProjectCollection.Rootobject>(response.Content.ReadAsStringAsync().Result);
                if (obj != null)
                    {
                    foreach (TFS2013TeamProjectCollection.Value projColl in obj.value)
                        {

                        if (projColl.state == "Started")
                            {
                            var responseProj = http.GetAsync(_baseUrl + projColl.name + "/_apis/projects?" + tfsWebApiVersionSring).Result;
                            if (responseProj.IsSuccessStatusCode)
                                {
                                responseProj.EnsureSuccessStatusCode();
                                TFS2013TeamProject.Rootobject obj1 = JsonConvert.DeserializeObject<TFS2013TeamProject.Rootobject>(responseProj.Content.ReadAsStringAsync().Result);
                                if (obj1 != null)
                                    {
                                    Project p;
                                    foreach (TFS2013TeamProject.Value TeamProj in obj1.value)
                                        {
                                        p = new Project();
                                        p.collectionName = TeamProj.collection.name;
                                        p.description = TeamProj.description;
                                        p.id = TeamProj.id;
                                        p.name = TeamProj.name;
                                        p.collectionName = TeamProj.collection.name;
                                        p.url = TeamProj.url;

                                        retunResult.Add(p);
                                        }
                                    }
                                }
                            }
                        }
                    return retunResult;
                    }
                }
            }
        return null;
        }

Body:
You could refer to this code snippet about using TFS REST API to get something in async way.

public static async void RESTAPIMethod()
    {
        HttpClientHandler authtHandler = new HttpClientHandler()
        {
            Credentials = CredentialCache.DefaultNetworkCredentials
        };

        using (HttpClient client = new HttpClient(authtHandler))
        {
            client.DefaultRequestHeaders.Accept.Add(
                new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

            using (HttpResponseMessage response = client.GetAsync(
                "Put the REST API URL here").Result)
            {
                response.EnsureSuccessStatusCode();
                var responseBody = await response.Content.ReadAsStringAsync();

            }
        }
    }

Another method about using TFS REST API:

You could also install this Nuget package for your project. Then using these assemblies in this package to run a REST API with C#. This is different with the method above, it's much more convenient. Here is an example about get a build information using Microsoft.TeamFoundation.Build.WebApi assembly in Async method.
Example:
What object returns from TFS2015 RestAPI


问:
How to distinguish int from int pointer in C?
I got a scenario in which I want to distinguish these two types.
It is easy to make it in other language such as python, C++, java. But it is
hard in C. Maybe I am not good at the basics. I have no idea how to achieve this.

Let's say: [1,2,3,[34,45],45]. The internal array exists as an elements in other array. How can I tell them ordinary element from the array.

I just think this is interesting so that I can know more about the property of C.

答:
The answer is very simple: your array is impossible in C. Unlike Python and other high-level languages, C has a rather down-to-the-metal approach: all array elements must have the same type, otherwise your program is not going to compile.

In order to make an array that may have ints mixed with other arrays you need to do the following:

Make a union that mixes an int and int*

Put the union inside a struct, along with a flag that distinguishes between an int and an array

Make an array of the structs defined above

Here is a short example:

```<code>enum val_type {
    num
,   array
};

struct vect {
    int *arr;
    size_t size;
};

struct mix {
    union {
        int val;
        struct vect vect;
    } v;
    enum val_type type;
};

int arr1[] = {4, 5};

struct mix data[] = {
    {.v = {.val = 1}, .type = num}
,   {.v = {.val = 2}, .type = num}
,   {.v = {.val = 3}, .type = num}
,   {.v = {.vect = {.arr = arr1, .size = 2}}, .type = array}
,   {.v = {.val = 6}, .type = num}
};
</code>```

Yes, you need all this for something that can be expressed as [1,2,3,[34,45],45] in some other languages. In return for all this code you get a program that has much higher efficiency than its counterparts written in higher-level languages.

Body:
The answer is very simple: your array is impossible in C. Unlike Python and other high-level languages, C has a rather down-to-the-metal approach: all array elements must have the same type, otherwise your program is not going to compile.

In order to make an array that may have ints mixed with other arrays you need to do the following:

Make a union that mixes an int and int*

Put the union inside a struct, along with a flag that distinguishes between an int and an array

Make an array of the structs defined above

Here is a short example:

enum val_type {
    num
,   array
};

struct vect {
    int *arr;
    size_t size;
};

struct mix {
    union {
        int val;
        struct vect vect;
    } v;
    enum val_type type;
};

int arr1[] = {4, 5};

struct mix data[] = {
    {.v = {.val = 1}, .type = num}
,   {.v = {.val = 2}, .type = num}
,   {.v = {.val = 3}, .type = num}
,   {.v = {.vect = {.arr = arr1, .size = 2}}, .type = array}
,   {.v = {.val = 6}, .type = num}
};

Yes, you need all this for something that can be expressed as [1,2,3,[34,45],45] in some other languages. In return for all this code you get a program that has much higher efficiency than its counterparts written in higher-level languages.


问:
Howto delete every second and third element from an array?
I want to delete every second and third element from an array in Javascript.

My array looks like this:

```<code>var fruits = ["Banana", "yellow", "23", "Orange", "orange", "12", "Apple", "green", "10"];
</code>```

Now I want to delete every second and third element. The result would look like this:

```<code>["Banana", "Orange", "Apple"]
</code>```

I tried to use a for-loop and splice:

```<code>for (var i = 0; fruits.length; i = i+3) {
    fruits.splice(i+1,0);
    fruits.splice(i+2,0);
};
</code>```

Of course this returns an empty array because the elements are removed while the loop is still executed.

How can I do this correctly?

答: Have you considered just copying the first, fourth, and seventh elements to a new array? It isn't very memory efficient but it'll still work fine.</p>

ContentLicense: CC BY-SA 4.0

Body:
I want to delete every second and third element from an array in Javascript.

My array looks like this:

var fruits = ["Banana", "yellow", "23", "Orange", "orange", "12", "Apple", "green", "10"];

Now I want to delete every second and third element. The result would look like this:

["Banana", "Orange", "Apple"]

I tried to use a for-loop and splice:

for (var i = 0; fruits.length; i = i+3) {
    fruits.splice(i+1,0);
    fruits.splice(i+2,0);
};

Of course this returns an empty array because the elements are removed while the loop is still executed.

How can I do this correctly?


问:
How can i make drop-down list using multiple attribute in HTML
I am trying use multiple attributes where I make the dropdown list, however it is working but default browser changing. Is there any way I can make it drop-down. Please see the code..

```<code>    <select name="cars" multiple>
       <option value="volvo">Volvo</option>
       <option value="saab">Saab</option>
       <option value="opel">Opel</option>
       <option value="audi">Audi</option>
    </select>
</code>```

But if I remove multiple attribute, I can see only drop-down list. Why is it showing different HTML control when I use multiple. I circled correct control with blue that's how I want to use multiple. Is there any suggestion or any ideas.

答:
You Can go to web  [http://getbootstrap.com/components/#navbar]

Copy code and it have Css and HTML

or u can go see in Youtube how to use Bootstrap

Body:
I am trying use multiple attributes where I make the dropdown list, however it is working but default browser changing. Is there any way I can make it drop-down. Please see the code..

    <select name="cars" multiple>
       <option value="volvo">Volvo</option>
       <option value="saab">Saab</option>
       <option value="opel">Opel</option>
       <option value="audi">Audi</option>
    </select>

But if I remove multiple attribute, I can see only drop-down list. Why is it showing different HTML control when I use multiple. I circled correct control with blue that's how I want to use multiple. Is there any suggestion or any ideas.


问:
Simulating data using existing data and probability
I have measured multiple attributes (height, species, crown width, condition etc) for about 1500 trees in a city.  Using remote sensing techniques I also have the heights for the rest of the 9000 trees in the city.  I want to simulate/generate/estimate the missing attributes for these unmeasured trees by using their heights.

From the measured data I can obtain proportion of each species in the measured population (and thus a rough probability), height distributions for each species, height-crown width relationships for the species, species-condition relationship and so on.  I want to use the height data for the unmeasured trees to first estimate the species and then estimate the rest of the attributes too using probability theory.  So for a height of say 25m its more likely to be a Cedar (height range 5 - 30 m) rather than a Mulberry tree (height range 2 -8 m) and more likely to be a cedar (50% of population) than an oak (same height range but 2% of population) and hence will have a crown width of 10m and have a health condition of 95% (based on the distributions for cedar trees in my measured data).  But also I am expecting some of the other trees of 25m to be given oak, just less frequently than cedar based on the proportion in population.

Is there a way to do this using probability theory in R preferably utilising Bayesian or machine learning methods?

Im not asking for someone to write the code for me - I am fairly experienced with R.  I just want to be pointed in the right direction i.e. a package that does this kind of thing neatly.

Thanks!

答:
Because you want to predict a categorical variable, i.e. the species, you should consider using a tree regression, a method which can be found in the R packages rpart and RandomForest. These models excel when you have a discrete number of categories and you need to slot your observations into those categories. I think those packages would work in your application. As a comparison, you can also look at multinomial regression (mnlogit, nnet, maxent) which can also predict categorical outcomes; unfortunately multinomial regression can get unwieldy with large numbers of outcomes and/or large datasets.

If you want to then predict the individual values for individual trees in your species, first run a regression of all of your measured variables, including species type, on the measured trees. Then take the categorical labels that you predicted and predict out-of-sample for the unmeasured trees where you use the categorical labels as predictors for the unmeasured variable of interest, say tree height. That way the regression will predict the average height for that species/dummy variable, plus some error and incorporating any other information you have on that out-of-sample tree.

If you want to use a Bayesian method, you consider using a hierarchical regression to model these out-of-sample predictions. Sometimes hierarchical models do better at predicting as they tend to be fairly conservative. Consider looking at the package Rstanarm for some examples.


问:
Using aldeed:autoform with iron:router
I added aldeed:autoform for my meteor project by including following packages.

```<code>aldeed:collection2
aldeed:autoform
</code>```

After the inclusion, the routing of the application is crashed. For every route it says that the routes are not defined.

And after I remove the above aldeed:autoform packages from the project, the routing worked as expected. I want to know whether these two packages are incompatible or how to get the project working with these packages?

答: there should be more than 'no routes defined' error. any js error will break the routing. can you paste the whole console messages here?</p>

Title: Using aldeed:autoform with iron:router

Body:
I added aldeed:autoform for my meteor project by including following packages.

aldeed:collection2
aldeed:autoform

After the inclusion, the routing of the application is crashed. For every route it says that the routes are not defined.

And after I remove the above aldeed:autoform packages from the project, the routing worked as expected. I want to know whether these two packages are incompatible or how to get the project working with these packages?


问:
Click event added to parent iframe(body) not working in child iframe(body)
I have requirement where I need to detect inactivity of web page and if user is inactive for more than 15 min then user should be logged out.For this purpose I am trying to detect inactivity of user by attaching click/keypress events to whole whole page and also for the main iframe.

The problem here is I am able to detect keypress / click event on the main page (main iframe) but wherever showDialoge(another iframe), I am not able to detect this event. Even though this events are being added to body of main iframe and also to whole web page, somehow i am not able to detect the same.Please help.

I am using OpenText Cordys framework XFORMs / JavaScript.

No jquery as of now but if required I can used.

答:
If I understand your issue it has to do with event propagation. I'll admit though that I am less familiar with iframes. See this other post.
What is event bubbling and capturing?

Aside from your question, ideally you should manage this via sessions. Expire the session after 15min. If the user is not authorized, aka not logged in, send them to the main page.


问:
Does perforce track deltas unique to a changeset or does it just store the whole file?
I tried to merge some work that a developer did in a working branch to a stable branch.  The files a, b, and c had been changed by at least a dozen changesets since the common ancestor of STABLE and HEAD branches were separated.

I expected that since this developer changed five lines in each of file a, b, and c, that when I integrated from the HEAD to the STABLE branch, I would get his changes in my pending changset, which I could then review and commit.

Instead, it seems that it has taken every change that happened to file A, since the two were branched, and applied all of those changes that also existed in my colleague's working copy.

In other words, there seems to be no record in a perforce changeset, of what my colleague actually changed, versus what the file before contained.

If I browse the submitted changesets, I can see the difference between my colleague's version of the file, and the immediately preceding version.   But then, that does not, it seems, determine what goes into the merge.

Doesn't a changeset mean, "a set of changes made between rev X and revision X+1 of a file"?
Can anybody help me understand what it means to "integrate a changeset" when in fact, what it seems is that Perforce doesn't track changes, it tracks files.

It is entirely possible that I am doing everything wrong, and would appreciate any pointer as to how it is that you can can merge accurately and safely between Perforce working branches and stable branches, without stuff that you don't want to get integrated to the stable branch getting integrated.  It seems that no matter how simple the changes that actually get made in the product, the merge does not actually work for me.

答:
Perforce does save changes to text files as deltas (binary files get saved in their entirety every time a change is submitted).  It sounds like you're not properly restricting the revision range during your integration.

You say the working branch has "...been changed by at least a dozen changesets since the ...branches were separated."  Let's call them changelists 1-12.  If I understand you correctly you are trying to integrate the modifications made in just one of those changelists, not all of them.

During a simple integration operation Perforce will assume you want to integrate all of the changes that have been submitted since the branch was made.  If you only want a subset of these changes, you have to specify a revision range.  So, if you just want to integrate the changes that occurred between changelist 11 and 12, you would specify that revision range as shown in the screen capture.  (Note: the revision range is inclusive, so specifying a range of 11-12, as I do in this screen shot will actually include changes in changelists 11 and 12.  If you just want to integrate the changes made in changelist 12, enter 12 in both fields of the revision range.)

Just be aware that the inevitable conflicts that arise may be difficult to resolve, depending upon how far the branches have diverged and the nature of the changes.


答:
If your files are on same server, you can call parent window's function from child iframe like

parent.html

```<code><script>
window.whichKey = function(keycode) {
    console.log("I'm called from child frame, you pressed " + keycode);
}
</script>
</code>```

child.html

```<code><script>
window.onkeypress = function(event) {
    window.parent.window.whichKey(event.keyCode);
}
</script>
</code>```

The other possible solution for your case is passing a variable in the url of parent from your child iframe. For example window.top.location.href = "parent.html?inactive=true"; and in the parent window you can check for this variable and perform required action.

This is how you can bind an event from parent to child frame's body for listening keypress using jQuery

```<code>$("#child-frame").bind("load", function(){
    $(this).contents().find("body").on('keypress', function(e) {
        console.log(e.keyCode);
    });
});
</code>```

Title: Click event added to parent iframe(body) not working in child iframe(body)

Body:
I have requirement where I need to detect inactivity of web page and if user is inactive for more than 15 min then user should be logged out.For this purpose I am trying to detect inactivity of user by attaching click/keypress events to whole whole page and also for the main iframe.

The problem here is I am able to detect keypress / click event on the main page (main iframe) but wherever showDialoge(another iframe), I am not able to detect this event. Even though this events are being added to body of main iframe and also to whole web page, somehow i am not able to detect the same.Please help.

I am using OpenText Cordys framework XFORMs / JavaScript.

No jquery as of now but if required I can used.

Body:
If your files are on same server, you can call parent window's function from child iframe like

parent.html

<script>
window.whichKey = function(keycode) {
    console.log("I'm called from child frame, you pressed " + keycode);
}
</script>

child.html

<script>
window.onkeypress = function(event) {
    window.parent.window.whichKey(event.keyCode);
}
</script>

The other possible solution for your case is passing a variable in the url of parent from your child iframe. For example window.top.location.href = "parent.html?inactive=true"; and in the parent window you can check for this variable and perform required action.

This is how you can bind an event from parent to child frame's body for listening keypress using jQuery

$("#child-frame").bind("load", function(){
    $(this).contents().find("body").on('keypress', function(e) {
        console.log(e.keyCode);
    });
});


问:
Convert Javascript regex to PHP regex?
I'm using the following regex from emailregex.com to validate emails on my site. It's working like a charm in JS but I'm unable to get it working within PHP.

/^(([^<>()[]\.,;:\s@"]+(.[^<>()[]\.,;:\s@"]+)*)|(".+"))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}))$/

The issue from what I'm seeing is the backslashes, when adding it in quotes it keeps trying to escape it. Regex101 shows that it is working, it's just a matter of how to get it into PHP.

Any help would be great, thanks!

PHP Code:

```<code>$emailRegex = "/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/"
</code>```

答:
Don't use a regular exprssion.

Use PHP's filter_var functions:

```<code>if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
    echo "This ($email) email address is considered valid.\n";
}
</code>```

Ref: http://php.net/manual/en/filter.examples.validation.php

You may choose to use a type="email" input on the client side.  Disabling validation with the novalidate attribute on the form prevents the browser from changing the appearance of inputs based on the validity of their contents, but still allows you to use JavaScript to test.

var statusDiv = document.getElementById("status");
document.getElementById("email").addEventListener("change", function(evt) {
  statusDiv.textContent = this.checkValidity() ? "Valid" : "Not valid";
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><form novalidate>
  <label for="email">Email</label>
  <input type="email" autocomplete="email" id="email">
</form>
<div id="status"></div></code>```

Title: Convert Javascript regex to PHP regex?

Body:
I'm using the following regex from emailregex.com to validate emails on my site. It's working like a charm in JS but I'm unable to get it working within PHP.

/^(([^<>()[]\.,;:\s@"]+(.[^<>()[]\.,;:\s@"]+)*)|(".+"))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}))$/

The issue from what I'm seeing is the backslashes, when adding it in quotes it keeps trying to escape it. Regex101 shows that it is working, it's just a matter of how to get it into PHP.

Any help would be great, thanks!

PHP Code:

$emailRegex = "/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/"

Body:
Don't use a regular exprssion.

Use PHP's filter_var functions:

if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
    echo "This ($email) email address is considered valid.\n";
}

Ref: http://php.net/manual/en/filter.examples.validation.php

You may choose to use a type="email" input on the client side.  Disabling validation with the novalidate attribute on the form prevents the browser from changing the appearance of inputs based on the validity of their contents, but still allows you to use JavaScript to test.

var statusDiv = document.getElementById("status");
document.getElementById("email").addEventListener("change", function(evt) {
  statusDiv.textContent = this.checkValidity() ? "Valid" : "Not valid";
});

<form novalidate>
  <label for="email">Email</label>
  <input type="email" autocomplete="email" id="email">
</form>
<div id="status"></div>


问:
Run CMD as process in the background and starting external program. How do I know, if external program has exited
I start the CMD in the background as a process. With the process I start external programs. How do I know, if the external program has exited?</p>

答:
If you only run the external program in the batch file you can use Process.Exited event.

```<code>process.Exited += Process_Exited;
</code>```

If not, you can try to find the external process by name to know whether it has exited.

```<code>var processes = Process.GetProcessesByName(ExternalProcessName);
bool exited = processes.Length < 1;
</code>```

Body:
If you only run the external program in the batch file you can use Process.Exited event.

process.Exited += Process_Exited;

If not, you can try to find the external process by name to know whether it has exited.

var processes = Process.GetProcessesByName(ExternalProcessName);
bool exited = processes.Length < 1;


问:
Logging messages in Hive .hql file
I have some insert statements to run in Hive. I am planning to put them in .hql file and run it through beeline -f option. Is there a way I can echo some log messages in between inserts so that I know the progress. Like :

echo "Starting the inserts ........."
   insert1

echo "Insert 1 complete"

insert2

echo "Insert script is complete"

I tried putting echo statements by using linux shell command echo as
!echo ""

But it's not recognizing echo as a command

答:
```<code>set msg = "Starting Insert";
set msg;

insert into .... ;

set msg = "Insert complete";
set msg;
</code>```

Title: Logging messages in Hive .hql file


问:
2 single digit lottery game, can't find where I went wrong
I am trying to design a lottery game where you choose 2 single digit numbers and they are compared to random numbers. I am going off of a code example given to me by my professor and have tried to tweak it to use it. I am stuck in figuring out how to get it to run or what I have wrong.</p>

```<code>import java.util.Scanner;

public class Lottery {

    private static Scanner input;

    public static void main(String[] args) {
        String lottery = "" + (int) (Math.random() * 10);
        String lottery1 = "" + (int) (Math.random() * 10);

        input = new Scanner(System.in);
        System.out.print("Enter your first single digit guess: ");
        String guess = input.nextLine();
        System.out.print("Enter your second single digit guess: ");
        String guess1 = input.nextLine();

        int lotteryDigit1 = lottery.charAt(0);
        int lottery1Digit1 = lottery.charAt(1);

        int guessDigit1 = guess.charAt(0);
        int guess1Digit1 = guess1.charAt(1);

        System.out.println("The lottery number is " + lottery);

        if (guess.equals(lottery))
            System.out.println("Exact match: you win $10,000");
        else if (guess1Digit1 == lotteryDigit1
                && guessDigit1 == lottery1Digit1)
            System.out.println("Match all digits: you win $3,000");
        else if (guessDigit1 == lotteryDigit1
                || guessDigit1 == lottery1Digit1
                || guess1Digit1 == lotteryDigit1
                || guess1Digit1 == lottery1Digit1)
            System.out.println("Match one digit: you win $1,000");
        else
            System.out.println("Sorry, no matches");
    }
}
</code>```

答:
Consider this code which is rather simplified

```<code>    // uses java.util.Random
    Random rand = new Random ();
    Scanner scan = new Scanner (System.in);

    int guess1 = rand.nextInt(10);
    int guess2 = rand.nextInt(10);

    System.out.println("Enter number 1");
    int myGuess1 = scan.nextInt();
    System.out.println("Enter number 2");
    int myGuess2 = scan.nextInt();

    System.out.printf("Random1 %d Random2 %d Guess1 %d Guess2 %d",
                                      guess1, guess2, myGuess1, myGuess2);
</code>```

I will leave the comparison to you

Body:
I am trying to design a lottery game where you choose 2 single digit numbers and they are compared to random numbers. I am going off of a code example given to me by my professor and have tried to tweak it to use it. I am stuck in figuring out how to get it to run or what I have wrong.

import java.util.Scanner;

public class Lottery {

    private static Scanner input;

    public static void main(String[] args) {
        String lottery = "" + (int) (Math.random() * 10);
        String lottery1 = "" + (int) (Math.random() * 10);

        input = new Scanner(System.in);
        System.out.print("Enter your first single digit guess: ");
        String guess = input.nextLine();
        System.out.print("Enter your second single digit guess: ");
        String guess1 = input.nextLine();

        int lotteryDigit1 = lottery.charAt(0);
        int lottery1Digit1 = lottery.charAt(1);

        int guessDigit1 = guess.charAt(0);
        int guess1Digit1 = guess1.charAt(1);

        System.out.println("The lottery number is " + lottery);

        if (guess.equals(lottery))
            System.out.println("Exact match: you win $10,000");
        else if (guess1Digit1 == lotteryDigit1
                && guessDigit1 == lottery1Digit1)
            System.out.println("Match all digits: you win $3,000");
        else if (guessDigit1 == lotteryDigit1
                || guessDigit1 == lottery1Digit1
                || guess1Digit1 == lotteryDigit1
                || guess1Digit1 == lottery1Digit1)
            System.out.println("Match one digit: you win $1,000");
        else
            System.out.println("Sorry, no matches");
    }
}

Body:
Consider this code which is rather simplified

    // uses java.util.Random
    Random rand = new Random ();
    Scanner scan = new Scanner (System.in);

    int guess1 = rand.nextInt(10);
    int guess2 = rand.nextInt(10);

    System.out.println("Enter number 1");
    int myGuess1 = scan.nextInt();
    System.out.println("Enter number 2");
    int myGuess2 = scan.nextInt();

    System.out.printf("Random1 %d Random2 %d Guess1 %d Guess2 %d",
                                      guess1, guess2, myGuess1, myGuess2);

I will leave the comparison to you


问:
How to setup GIT for a GWT project
Which files and folders of a GWT project have to be tracked, which can I ignore?

I think ./src, ./test have to be tracked. I found out ./war is also important, but I've red, that it contains generated files.

I also found out that ./test-classes must be tracked, but I don't understand why.

答:
Usually folders and files for git to version control GWT projects including:

```<code>.settings
 war
.classpath
.project
</code>```

Usually files and folders ignored by git as (you can find here):

```<code>*.class

# Package Files #
*.jar
*.war

# gwt caches and compiled units #
war/gwt_bree/
gwt-unitCache/

# boilerplate generated classes #
.apt_generated/

# more caches and things from deploy #
war/WEB-INF/deploy/
war/WEB-INF/classes/

#compilation logs
.gwt/

#caching for already compiled files
gwt-unitCache/

#gwt junit compilation files
www-test/

#old GWT (1.5) created this dir
.gwt-tmp/
</code>```

In a word, files changes have impact for your project should be version controlled. And output files/folders or files have no impact for you project can be ignored by git.

Title: How to setup GIT for a GWT project

Body:
Usually folders and files for git to version control GWT projects including:

.settings
 war
.classpath
.project

Usually files and folders ignored by git as (you can find here):

*.class

# Package Files #
*.jar
*.war

# gwt caches and compiled units #
war/gwt_bree/
gwt-unitCache/

# boilerplate generated classes #
.apt_generated/

# more caches and things from deploy #
war/WEB-INF/deploy/
war/WEB-INF/classes/

#compilation logs
.gwt/

#caching for already compiled files
gwt-unitCache/

#gwt junit compilation files
www-test/

#old GWT (1.5) created this dir
.gwt-tmp/

In a word, files changes have impact for your project should be version controlled. And output files/folders or files have no impact for you project can be ignored by git.


问:
XML attributes function error say Called on a non-object
I have XML file I want to retrieve the attribute names from it by using this code below. the code work and retrieve all attribute names but under the last attribute names also show this error</p>

```<code> Fatal error: Call to a member function attributes() on a non-object in C:\wamp\www\php\xml\EnglishArabic\new.php on line 13

 <?php
    $en = simplexml_load_file('ENstrings.xml');
    $enlen = sizeof($en->string);
    for ($i=0; $i<=$enlen ; $i++) {
        foreach ($en->string[$i]->attributes() as $key => $value) {
           echo $value. '<br \>';
        }
    }
?>
</code>```

答:
That's because the index ($en->string[$i]) starts from 0 to length-1, so your loop supposed to stop just before $i reaches the length :

```<code>for ($i=0; $i<$enlen ; $i++) {
</code>```

Body:
I have XML file I want to retrieve the attribute names from it by using this code below. the code work and retrieve all attribute names but under the last attribute names also show this error

 Fatal error: Call to a member function attributes() on a non-object in C:\wamp\www\php\xml\EnglishArabic\new.php on line 13

 <?php
    $en = simplexml_load_file('ENstrings.xml');
    $enlen = sizeof($en->string);
    for ($i=0; $i<=$enlen ; $i++) {
        foreach ($en->string[$i]->attributes() as $key => $value) {
           echo $value. '
';
        }
    }
?>

Body:
That's because the index ($en->string[$i]) starts from 0 to length-1, so your loop supposed to stop just before $i reaches the length :

for ($i=0; $i<$enlen ; $i++) {


问:
How to create breadcrumb shape
I've been trying to create a breadcrumb in the shape of an arrow that has a point on one end and a tail at the other.

Basically, the layout is:  [tail][body][point], where tail & point are just triangles.

I managed to create [body][point] using css, but i'm stuck trying to make the tail to work. Can this also be done with css?

DEMO: https://plnkr.co/edit/mQELiNgVCe6ZoTepCtr9?p=preview

The HTML:

```<code><div style="font-size:0">
    <div class="arrow-tail"></div>
    <div class="arrow-body">HELLO WORLD!</div>
    <div class="arrow-point"></div>
</div>
</code>```

The CSS:

```<code>    .arrow-point {
    display: inline-block;
    width: 0;
    height: 0;
    border-top: 12px solid transparent;
    border-bottom: 12px solid transparent;
    border-left: 15px solid #777777;
}
.arrow-body {
    font-family: verdana;
    font-size:15px;
    display: inline-block;
    background-color: #777777;
    color:white;
    padding:2px 6px 2px 16px;
    height:20px;
    vertical-align:top;
}
.arrow-tail {
    float:left;
    display: inline-block;
    width: 0;
    height: 0;
    border-top: 12px solid transparent;
    border-bottom: 12px solid transparent;
    border-left: 15px solid #EEEEEE;
}
</code>```

答:
Its a bit difficult to understand how you want the final result to look like based on the information you provided in the original post. But I make some guesses and I believe that you want it to look like this:

You can achieve this by setting the tail to position: absolute.

The final CSS of the tail would be this:

```<code>.arrow-tail {
    position: absolute;
    border-top: 12px solid transparent;
    border-bottom: 12px solid transparent;
    border-left: 15px solid #fff;
}
</code>```

Also note that if you want to move around your tail with the top:, right:, bottom:, left: attributes then you need to make sure that the container div is set to position: relative.

Title: How to create breadcrumb shape

Body:
I've been trying to create a breadcrumb in the shape of an arrow that has a point on one end and a tail at the other.

Basically, the layout is:  [tail][body][point], where tail & point are just triangles.

I managed to create [body][point] using css, but i'm stuck trying to make the tail to work. Can this also be done with css?

DEMO: https://plnkr.co/edit/mQELiNgVCe6ZoTepCtr9?p=preview

The HTML:

HELLO WORLD!

The CSS:

    .arrow-point {
    display: inline-block;
    width: 0;
    height: 0;
    border-top: 12px solid transparent;
    border-bottom: 12px solid transparent;
    border-left: 15px solid #777777;
}
.arrow-body {
    font-family: verdana;
    font-size:15px;
    display: inline-block;
    background-color: #777777;
    color:white;
    padding:2px 6px 2px 16px;
    height:20px;
    vertical-align:top;
}
.arrow-tail {
    float:left;
    display: inline-block;
    width: 0;
    height: 0;
    border-top: 12px solid transparent;
    border-bottom: 12px solid transparent;
    border-left: 15px solid #EEEEEE;
}

Body:
Its a bit difficult to understand how you want the final result to look like based on the information you provided in the original post. But I make some guesses and I believe that you want it to look like this:

You can achieve this by setting the tail to position: absolute.

The final CSS of the tail would be this:

.arrow-tail {
    position: absolute;
    border-top: 12px solid transparent;
    border-bottom: 12px solid transparent;
    border-left: 15px solid #fff;
}

Also note that if you want to move around your tail with the top:, right:, bottom:, left: attributes then you need to make sure that the container div is set to position: relative.


问:
REST interface for finding average
Suppose I want to create a REST interface to find the average of a list of numbers. Assume that the numbers are submitted one at a time. How would you do this?

POST a number to https://example.com/api/average

If this is the first number a hash will be returned

POST a number to https://example.com/api/average/hash
....

GET https://example.com/api/average/hash to find the average

DELETE https://example.com/api/average/hash since we don't need it any more

Is this the right way to do it? Any suggestions?

答:
To maximize REST philosophies I would do the following

Do a PUT this to indicate a new structure that would generate a hash, that is not based on the number passed. Just a "random" hash. Then each subsequent post would include the id-hash with returned result hash of the numbers sent. Then when a get is presented on that you can cache the results.

```<code>1. PUT    /api/average/{number} //return id-hash
2. POST   /api/average/{id-hash}/{number} // return average-hash
3. GET    /api/average/{average-hash}
4. DELETE /api/average/{id-hash}
</code>```

Then you can cache the get of the average hash, even when you may get to the result in a different way, or different servers get that same average.

OwnerDisplayName: Guruk

Title: REST interface for finding average

Body:
To maximize REST philosophies I would do the following

Do a PUT this to indicate a new structure that would generate a hash, that is not based on the number passed. Just a "random" hash. Then each subsequent post would include the id-hash with returned result hash of the numbers sent. Then when a get is presented on that you can cache the results.

1. PUT    /api/average/{number} //return id-hash
2. POST   /api/average/{id-hash}/{number} // return average-hash
3. GET    /api/average/{average-hash}
4. DELETE /api/average/{id-hash}

Then you can cache the get of the average hash, even when you may get to the result in a different way, or different servers get that same average.


问:
meta_search wrong number of arguments
I am using meta_search plugin with my rails3 app for search functionality. When I want to try the search method of meta_search plugin on my model in console, it gives me this error. I am not able to figure the error from the plugin source code.

```<code>Listing.search(:address1_starts_with => ["lucky"])
ArgumentError: wrong number of arguments (1 for 2)
</code>```

please help

答:
A little late to this party but you shouldn't be supplying the parameter as an array.

```<code>Listing.search(:address1_starts_with => "lucky")
</code>```

should do the trick.

Title: meta_search wrong number of arguments

Body:
I am using meta_search plugin with my rails3 app for search functionality. When I want to try the search method of meta_search plugin on my model in console, it gives me this error. I am not able to figure the error from the plugin source code.

Listing.search(:address1_starts_with => ["lucky"])
ArgumentError: wrong number of arguments (1 for 2)

please help

Body:
A little late to this party but you shouldn't be supplying the parameter as an array.

Listing.search(:address1_starts_with => "lucky")

should do the trick.


问:
Copy Row over to another sheet with multiple criteria in multiple ranges VBA Excel
I am trying to copy rows from one sheet to another using VBA, I need it to check cell in column a if it contains value X and if column C excludes Value Y.

I have come as far to copy it with the first criteria, but not the second.

This is what I have and it won't work...

```<code>Sub Copy_2016()
'
'Run Sub Copy_2016()
'
Sheets("Working - 2016").Select
Range("A3:AO6304").ClearContents

For Each Cell In Sheets("Working - Data").Range("A1:A6304,C3:C6304")
    If Cell.Value = "2016" And If Not Cell.Value = "HI" Then
         matchRow = Cell.Row
         Rows(matchRow & ":" & matchRow).Select
         Selection.Copy

         Sheets("Working - 2016").Select
         ActiveSheet.Rows(matchRow).Select
         ActiveSheet.Paste
         Sheets("Working - Data").Select
    End If
Next

End Sub
</code>```

答:
I think you need something like this</p>

```<code>Sub Copy_2016()
    Dim Cell As Range
    Worksheets("Working - 2016").Range("A3:AO6304").ClearContents

    For Each Cell In Worksheets("Working - Data").Range("A1:A6304")
        If Cell.Value = "2016" And Not Cell.Offset(0, 2).Value = "HI" Then
            Cell.EntireRow.Copy
            Worksheets("Working - 2016").Rows(Cell.Row).PasteSpecial Paste:=xlPasteValues
        End If
    Next
End Sub
</code>```

Body:
I am trying to copy rows from one sheet to another using VBA, I need it to check cell in column a if it contains value X and if column C excludes Value Y.

I have come as far to copy it with the first criteria, but not the second.

This is what I have and it won't work...

Sub Copy_2016()
'
'Run Sub Copy_2016()
'
Sheets("Working - 2016").Select
Range("A3:AO6304").ClearContents

For Each Cell In Sheets("Working - Data").Range("A1:A6304,C3:C6304")
    If Cell.Value = "2016" And If Not Cell.Value = "HI" Then
         matchRow = Cell.Row
         Rows(matchRow & ":" & matchRow).Select
         Selection.Copy

         Sheets("Working - 2016").Select
         ActiveSheet.Rows(matchRow).Select
         ActiveSheet.Paste
         Sheets("Working - Data").Select
    End If
Next

End Sub

Body:
I think you need something like this

Sub Copy_2016()
    Dim Cell As Range
    Worksheets("Working - 2016").Range("A3:AO6304").ClearContents

    For Each Cell In Worksheets("Working - Data").Range("A1:A6304")
        If Cell.Value = "2016" And Not Cell.Offset(0, 2).Value = "HI" Then
            Cell.EntireRow.Copy
            Worksheets("Working - 2016").Rows(Cell.Row).PasteSpecial Paste:=xlPasteValues
        End If
    Next
End Sub


问:
Display firebase notification data-message on Android tray
I need to use non-collapsible notification by Firebase. For that I am using data-message like this:

```<code>{
 "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
 "data" : {
   "Nick" : "Mario",
   "body" : "great match!",
   "Room" : "PortugalVSDenmark"
  },
}
</code>```

This message is interpreted in the onMessageReceived() method.
I still want to display this data-message in the tray just like notification-messages are displayed by the system automatically.

How to I achieve this? I cannot find documentation on this.

Thanks!

答:
You can retrieve the values from your data payload in onMessageReceived() by calling RemoteMessage.getData(), then .get("<KEY_HERE>"). Like so:

```<code>public void onMessageReceived(RemoteMessage remoteMessage) {
        super.onMessageReceived(remoteMessage);
        Log.d(TAG, "onMessageReceived()");

        // Check if message contains a data payload.
        if (remoteMessage.getData().size() > 0) {
            Log.d(TAG, "Message data payload: " + remoteMessage.getData());

            String dataTitle = remoteMessage.getData().get("data_title");
            String dataBody = remoteMessage.getData().get("data_body");

            sendNotification(dataTitle, dataBody);
}
</code>```

You have to then build and display the Notification yourself. Like so:

```<code>private void sendNotification(String title, String body) {
        Notification notif = new NotificationCompat.Builder(this)
                .setSmallIcon(R.mipmap.ic_launcher)
                .setContentTitle(title)
                .setContentText(body)
                .build();

        NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
        notificationManager.notify(0, notif);
}
</code>```

Body:
I need to use non-collapsible notification by Firebase. For that I am using data-message like this:

{
 "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
 "data" : {
   "Nick" : "Mario",
   "body" : "great match!",
   "Room" : "PortugalVSDenmark"
  },
}

This message is interpreted in the onMessageReceived() method.
I still want to display this data-message in the tray just like notification-messages are displayed by the system automatically.

How to I achieve this? I cannot find documentation on this.

Thanks!

Body:
You can retrieve the values from your data payload in onMessageReceived() by calling RemoteMessage.getData(), then .get("<KEY_HERE>"). Like so:

public void onMessageReceived(RemoteMessage remoteMessage) {
        super.onMessageReceived(remoteMessage);
        Log.d(TAG, "onMessageReceived()");

        // Check if message contains a data payload.
        if (remoteMessage.getData().size() > 0) {
            Log.d(TAG, "Message data payload: " + remoteMessage.getData());

            String dataTitle = remoteMessage.getData().get("data_title");
            String dataBody = remoteMessage.getData().get("data_body");

            sendNotification(dataTitle, dataBody);
}

You have to then build and display the Notification yourself. Like so:

private void sendNotification(String title, String body) {
        Notification notif = new NotificationCompat.Builder(this)
                .setSmallIcon(R.mipmap.ic_launcher)
                .setContentTitle(title)
                .setContentText(body)
                .build();

        NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
        notificationManager.notify(0, notif);
}


问:
Program that asks user how many times it wants to loop for (java)
// Create a full program in eclipse that will ask the user how  times would you like to loop for. It will ask in the for loop for a rate in double value and a time in integer value. It will calculate the distance for each of the times you enter in the rate and the time.//

my current output gives me the correct answer if i only want to put in once, as it only has to run the program once. Whenever i input more than 1, It starts acting weird and thats the best way i can explain it because i don't know whats wrong with it.

Here is one random output

```<code>How many times would you like to calculate the distance.
12
Enter rate
2
Enter time
13
The distance is 26.0
Enter rate
12
Enter time
12
The distance is 144.0
How many times would you like to calculate the distance.
1
Enter rate
12
Enter time
1
The distance is 12.0
</code>```

// my actual code

```<code>import java.util.Scanner;

 public class NTC {
 public static void main(String[] args){

Scanner kb=new Scanner(System.in);
    int loop = 10;
    double rate=0;
    int time=0;
    int count;
    double distance = rate*time;

 for (count = 0; count <= loop; count++) {

 System.out.println("How many times would you like to calculate the distance.");
 loop = kb.nextInt();

for(rate=0; rate <loop;rate++)
{
System.out.println("Enter rate");
rate = kb.nextDouble();

for(time=0; time <loop;time++)
{
     System.out.println("Enter time");
    time = kb.nextInt();
 System.out.println("The distance is "+rate*time);

}
</code>```

答:
You need to have only one for loop:

```<code>import java.util.Scanner;

public class NTC
{

public static void main(String[] args)
{
Scanner kb=new Scanner(System.in);
int loop = 10;
double rate=0;
int time=0;
int count;
double distance = rate*time;
System.out.println("How many times would you like to calculate the distance.");
loop = kb.nextInt();
for (count = 0; count < loop; count++)
{
 System.out.println("Enter rate");
 rate = kb.nextDouble();
 System.out.println("Enter time");
 time = kb.nextInt();
 System.out.println("The distance is "+(rate*time));
}
}
}
</code>```

Body:
// Create a full program in eclipse that will ask the user how  times would you like to loop for. It will ask in the for loop for a rate in double value and a time in integer value. It will calculate the distance for each of the times you enter in the rate and the time.//

my current output gives me the correct answer if i only want to put in once, as it only has to run the program once. Whenever i input more than 1, It starts acting weird and thats the best way i can explain it because i don't know whats wrong with it.

Here is one random output

How many times would you like to calculate the distance.
12
Enter rate
2
Enter time
13
The distance is 26.0
Enter rate
12
Enter time
12
The distance is 144.0
How many times would you like to calculate the distance.
1
Enter rate
12
Enter time
1
The distance is 12.0

// my actual code

import java.util.Scanner;

 public class NTC {
 public static void main(String[] args){

Scanner kb=new Scanner(System.in);
    int loop = 10;
    double rate=0;
    int time=0;
    int count;
    double distance = rate*time;

 for (count = 0; count <= loop; count++) {

 System.out.println("How many times would you like to calculate the distance.");
 loop = kb.nextInt();

for(rate=0; rate <loop;rate++)
{
System.out.println("Enter rate");
rate = kb.nextDouble();

for(time=0; time <loop;time++)
{
     System.out.println("Enter time");
    time = kb.nextInt();
 System.out.println("The distance is "+rate*time);

}

Body:
You need to have only one for loop:

import java.util.Scanner;

public class NTC
{

public static void main(String[] args)
{
Scanner kb=new Scanner(System.in);
int loop = 10;
double rate=0;
int time=0;
int count;
double distance = rate*time;
System.out.println("How many times would you like to calculate the distance.");
loop = kb.nextInt();
for (count = 0; count < loop; count++)
{
 System.out.println("Enter rate");
 rate = kb.nextDouble();
 System.out.println("Enter time");
 time = kb.nextInt();
 System.out.println("The distance is "+(rate*time));
}
}
}