问:
OpenCV build from source Windows make error "RC Object"
I downloaded the latest source from github and configured opencv and the contrib modules. I can seem to build. I already turned off FFMPEG, which I manually downloaded the .dll previously, i know that has been a recent problem. I have succeeded in the past. But now i'm getting to

```<code>[ 50%] Building RC object modules/core/CMakeFiles/opencv_core.dir/vs_version.rc.obj
C:\mingw\bin\windres.exe: invalid option -- W
Usage: C:\mingw\bin\windres.exe [option(s)] [input-file] [output-file]
 The options are:
  -i --input=<file>            Name input file
  -o --output=<file>           Name output file
  -J --input-format=<format>   Specify input format
  -O --output-format=<format>  Specify output format
  -F --target=<target>         Specify COFF target
     --preprocessor=<program>  Program to use to preprocess rc file
     --preprocessor-arg=<arg>  Additional preprocessor argument
  -I --include-dir=<dir>       Include directory when preprocessing rc file
  -D --define <sym>[=<val>]    Define SYM when preprocessing rc file
  -U --undefine <sym>          Undefine SYM when preprocessing rc file
  -v --verbose                 Verbose - tells you what it's doing
  -c --codepage=<codepage>     Specify default codepage
  -l --language=<val>          Set language when reading rc file
     --use-temp-file           Use a temporary file instead of popen to read
                               the preprocessor output
     --no-use-temp-file        Use popen (default)
  -r                           Ignored for compatibility with rc
  @<file>                      Read options from <file>
  -h --help                    Print this help message
  -V --version                 Print version information
FORMAT is one of rc, res, or coff, and is deduced from the file name
extension if not specified.  A single file name is an input file.
No input-file is stdin, default rc.  No output-file is stdout, default rc.
C:\mingw\bin\windres.exe: supported targets: pe-i386 pei-i386 elf32-i386 elf32-little elf32-big srec symbolsrec verilog tekhex binary ihex
make[2]: *** [modules\core\CMakeFiles\opencv_core.dir\build.make:1517: modules/core/CMakeFiles/opencv_core.dir/vs_version.rc.obj] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles\Makefile2:2363: modules/core/CMakeFiles/opencv_core.dir/all] Error 2
make: *** [Makefile:160: all] Error 2
</code>```

cmake gui options

```<code>Detected version of GNU GCC: 47 (407)
Could NOT find PythonInterp: Found unsuitable version "2.7.11", but required is at least "3.4" (found C:/Python27/python.exe)
Could NOT find PythonInterp: Found unsuitable version "2.7.11", but required is at least "3.2" (found C:/Python27/python.exe)
Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
A library with BLAS API not found. Please specify library location.
LAPACK requires BLAS
A library with LAPACK API not found. Please specify library location.
Could NOT find Doxygen (missing:  DOXYGEN_EXECUTABLE)
Could NOT find JNI (missing:  JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
Could NOT find Matlab (missing:  MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIRS MATLAB_ROOT_DIR MATLAB_LIBRARIES MATLAB_LIBRARY_DIRS MATLAB_MEXEXT MATLAB_ARCH MATLAB_BIN)
VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
Caffe:   NO
Protobuf:   NO
Glog:   NO
Looking for tiny_dnn.h
Looking for tiny_dnn.h - found
Found tiny-dnn in: C:/Users/Ben/Documents/opencv/build/3rdparty/tinydnn/tiny-dnn-1.0.0a3
The protocol buffer compiler is not found (PROTOBUF_PROTOC_EXECUTABLE='PROTOBUF_PROTOC_EXECUTABLE-NOTFOUND')
freetype2:   NO
harfbuzz:    NO
No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
Failed to find installed gflags CMake configuration, searching for gflags build directories exported with CMake.
Failed to find gflags - Failed to find an installed/exported CMake configuration for gflags, will perform search for installed gflags components.
Failed to find gflags - Could not find gflags include directory, set GFLAGS_INCLUDE_DIR to directory containing gflags/gflags.h
Failed to find glog - Could not find glog include directory, set GLOG_INCLUDE_DIR to directory containing glog/logging.h
Module opencv_sfm disabled because the following dependencies are not found: Eigen Glog/Gflags
Torch importer has been enabled. To run the tests you have to install Torch ('th' executable should be available) and generate testdata using opencv_extra/testdata/dnn/generate_torch_models.py script.
Tesseract:   NO

General configuration for OpenCV 3.3.0-rc =====================================
  Version control:               f670a99

  Extra modules:
    Location (extra):            C:/Users/Ben/Documents/opencv_contrib/modules
    Version control (extra):     3.3.0-rc

  Platform:
    Timestamp:                   2017-07-04T19:39:34Z
    Host:                        Windows 10.0.14393 AMD64
    CMake:                       3.5.0-rc3
    CMake generator:             MinGW Makefiles
    CMake build tool:            C:/mingw/bin/mingw32-make.exe
    Configuration:               Release

  CPU/HW features:
    Baseline:                    SSE SSE2
      requested:                 SSE2
    Dispatched code generation:  SSE4_1 FP16 AVX AVX2
      requested:                 SSE4_1 AVX FP16 AVX2
      SSE4_1 (0 files):          + SSE3 SSSE3 SSE4_1
      FP16 (1 files):            + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
      AVX (1 files):             + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 AVX
      AVX2 (2 files):            + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2

  C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                C:/mingw/bin/g++.exe  (ver 4.7.2)
    C++ flags (Release):         -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -march=i686 -fomit-frame-pointer -ffunction-sections  -msse -msse2 -mfpmath=sse -fvisibility=hidden -fvisibility-inlines-hidden -O2 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -march=i686 -fomit-frame-pointer -ffunction-sections  -msse -msse2 -mfpmath=sse -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  C:/mingw/bin/gcc.exe
    C flags (Release):           -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -march=i686 -fomit-frame-pointer -ffunction-sections  -msse -msse2 -mfpmath=sse -fvisibility=hidden -O2 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -march=i686 -fomit-frame-pointer -ffunction-sections  -msse -msse2 -mfpmath=sse -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):
    Linker flags (Debug):
    ccache:                      NO
    Precompiled headers:         YES
    Extra dependencies:          comctl32 gdi32 ole32 setupapi ws2_32 vfw32 winmm
    3rdparty dependencies:

  OpenCV modules:
    To be built:                 core flann imgproc ml objdetect phase_unwrapping photo plot reg surface_matching video xphoto bgsegm dnn face fuzzy img_hash imgcodecs shape videoio xobjdetect highgui superres ts bioinspired dpm features2d line_descriptor saliency text calib3d ccalib datasets rgbd stereo tracking videostab xfeatures2d ximgproc aruco optflow python2
    Disabled:                    stitching world contrib_world structured_light
    Disabled by dependency:      -
    Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python3 viz cnn_3dobj cvv dnn_modern freetype hdf matlab sfm

  Windows RT support:            NO

  GUI:
    QT:                          NO
    Win32 UI:                    YES
    OpenGL support:              NO
    VTK support:                 NO

  Media I/O:
    ZLib:                        build (ver 1.2.8)
    JPEG:                        build (ver 90)
    WEBP:                        build (ver encoder: 0x020e)
    PNG:                         build (ver 1.6.24)
    TIFF:                        build (ver 42 - 4.0.2)
    JPEG 2000:                   build (ver 1.900.1)
    OpenEXR:                     build (ver 1.7.1)
    GDAL:                        NO
    GDCM:                        NO

  Video I/O:
    Video for Windows:           YES
    DC1394 1.x:                  NO
    DC1394 2.x:                  NO
    FFMPEG:                      NO
      avcodec:                   NO
      avformat:                  NO
      avutil:                    NO
      swscale:                   NO
      avresample:                NO
    GStreamer:                   NO
    OpenNI:                      NO
    OpenNI PrimeSensor Modules:  NO
    OpenNI2:                     NO
    PvAPI:                       NO
    GigEVisionSDK:               NO
    DirectShow:                  YES
    Media Foundation:            NO
    XIMEA:                       NO
    Intel PerC:                  NO

  Parallel framework:            none

  Trace:                         YES ()

  Other third-party libraries:
    Use Intel IPP:               NO
    Use Intel IPP IW:            NO
    Use Intel IPP Async:         NO
    Use Lapack:                  NO
    Use Eigen:                   NO
    Use Cuda:                    NO
    Use OpenCL:                  NO
    Use OpenVX:                  NO
    Use custom HAL:              NO

  Python 2:
    Interpreter:                 C:/Python27/python.exe (ver 2.7.11)
    Libraries:                   C:/Python27/libs/libpython27.a (ver 2.7.11)
    numpy:                       C:/Python27/lib/site-packages/numpy/core/include (ver 1.11.3)
    packages path:               C:/Python27/Lib/site-packages

  Python 3:
    Interpreter:                 NO

  Python (for build):            C:/Python27/python.exe

  Java:
    ant:                         NO
    JNI:                         NO
    Java wrappers:               NO
    Java tests:                  NO

  Matlab:                        Matlab not found or implicitly disabled

  Documentation:
    Doxygen:                     NO

  Tests and samples:
    Tests:                       YES
    Performance tests:           YES
    C/C++ Examples:              NO

  Install path:                  C:/Users/Ben/Documents/opencv/build/install

  cvconfig.h is in:              C:/Users/Ben/Documents/opencv/build
-----------------------------------------------------------------

Configuring done
Generating done
</code>```

Is there a cmake flag that gets around this? opencv_core sounds pretty crucial...

答:
I think this might be it:
https://github.com/opencv/opencv/issues/9100

The work around is at the bottom

Workaround is to turn off CMake option: ENABLE_PRECOMPILED_HEADERS=OFF

Body:
I downloaded the latest source from github and configured opencv and the contrib modules. I can seem to build. I already turned off FFMPEG, which I manually downloaded the .dll previously, i know that has been a recent problem. I have succeeded in the past. But now i'm getting to

[ 50%] Building RC object modules/core/CMakeFiles/opencv_core.dir/vs_version.rc.obj
C:\mingw\bin\windres.exe: invalid option -- W
Usage: C:\mingw\bin\windres.exe [option(s)] [input-file] [output-file]
 The options are:
  -i --input=<file>            Name input file
  -o --output=<file>           Name output file
  -J --input-format=<format>   Specify input format
  -O --output-format=<format>  Specify output format
  -F --target=<target>         Specify COFF target
     --preprocessor=<program>  Program to use to preprocess rc file
     --preprocessor-arg=<arg>  Additional preprocessor argument
  -I --include-dir=<dir>       Include directory when preprocessing rc file
  -D --define <sym>[=<val>]    Define SYM when preprocessing rc file
  -U --undefine <sym>          Undefine SYM when preprocessing rc file
  -v --verbose                 Verbose - tells you what it's doing
  -c --codepage=<codepage>     Specify default codepage
  -l --language=<val>          Set language when reading rc file
     --use-temp-file           Use a temporary file instead of popen to read
                               the preprocessor output
     --no-use-temp-file        Use popen (default)
  -r                           Ignored for compatibility with rc
  @<file>                      Read options from <file>
  -h --help                    Print this help message
  -V --version                 Print version information
FORMAT is one of rc, res, or coff, and is deduced from the file name
extension if not specified.  A single file name is an input file.
No input-file is stdin, default rc.  No output-file is stdout, default rc.
C:\mingw\bin\windres.exe: supported targets: pe-i386 pei-i386 elf32-i386 elf32-little elf32-big srec symbolsrec verilog tekhex binary ihex
make[2]: *** [modules\core\CMakeFiles\opencv_core.dir\build.make:1517: modules/core/CMakeFiles/opencv_core.dir/vs_version.rc.obj] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles\Makefile2:2363: modules/core/CMakeFiles/opencv_core.dir/all] Error 2
make: *** [Makefile:160: all] Error 2

cmake gui options

Detected version of GNU GCC: 47 (407)
Could NOT find PythonInterp: Found unsuitable version "2.7.11", but required is at least "3.4" (found C:/Python27/python.exe)
Could NOT find PythonInterp: Found unsuitable version "2.7.11", but required is at least "3.2" (found C:/Python27/python.exe)
Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
A library with BLAS API not found. Please specify library location.
LAPACK requires BLAS
A library with LAPACK API not found. Please specify library location.
Could NOT find Doxygen (missing:  DOXYGEN_EXECUTABLE)
Could NOT find JNI (missing:  JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
Could NOT find Matlab (missing:  MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIRS MATLAB_ROOT_DIR MATLAB_LIBRARIES MATLAB_LIBRARY_DIRS MATLAB_MEXEXT MATLAB_ARCH MATLAB_BIN)
VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
Caffe:   NO
Protobuf:   NO
Glog:   NO
Looking for tiny_dnn.h
Looking for tiny_dnn.h - found
Found tiny-dnn in: C:/Users/Ben/Documents/opencv/build/3rdparty/tinydnn/tiny-dnn-1.0.0a3
The protocol buffer compiler is not found (PROTOBUF_PROTOC_EXECUTABLE='PROTOBUF_PROTOC_EXECUTABLE-NOTFOUND')
freetype2:   NO
harfbuzz:    NO
No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
Failed to find installed gflags CMake configuration, searching for gflags build directories exported with CMake.
Failed to find gflags - Failed to find an installed/exported CMake configuration for gflags, will perform search for installed gflags components.
Failed to find gflags - Could not find gflags include directory, set GFLAGS_INCLUDE_DIR to directory containing gflags/gflags.h
Failed to find glog - Could not find glog include directory, set GLOG_INCLUDE_DIR to directory containing glog/logging.h
Module opencv_sfm disabled because the following dependencies are not found: Eigen Glog/Gflags
Torch importer has been enabled. To run the tests you have to install Torch ('th' executable should be available) and generate testdata using opencv_extra/testdata/dnn/generate_torch_models.py script.
Tesseract:   NO

General configuration for OpenCV 3.3.0-rc =====================================
  Version control:               f670a99

  Extra modules:
    Location (extra):            C:/Users/Ben/Documents/opencv_contrib/modules
    Version control (extra):     3.3.0-rc

  Platform:
    Timestamp:                   2017-07-04T19:39:34Z
    Host:                        Windows 10.0.14393 AMD64
    CMake:                       3.5.0-rc3
    CMake generator:             MinGW Makefiles
    CMake build tool:            C:/mingw/bin/mingw32-make.exe
    Configuration:               Release

  CPU/HW features:
    Baseline:                    SSE SSE2
      requested:                 SSE2
    Dispatched code generation:  SSE4_1 FP16 AVX AVX2
      requested:                 SSE4_1 AVX FP16 AVX2
      SSE4_1 (0 files):          + SSE3 SSSE3 SSE4_1
      FP16 (1 files):            + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
      AVX (1 files):             + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 AVX
      AVX2 (2 files):            + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2

  C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                C:/mingw/bin/g++.exe  (ver 4.7.2)
    C++ flags (Release):         -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -march=i686 -fomit-frame-pointer -ffunction-sections  -msse -msse2 -mfpmath=sse -fvisibility=hidden -fvisibility-inlines-hidden -O2 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -march=i686 -fomit-frame-pointer -ffunction-sections  -msse -msse2 -mfpmath=sse -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  C:/mingw/bin/gcc.exe
    C flags (Release):           -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -march=i686 -fomit-frame-pointer -ffunction-sections  -msse -msse2 -mfpmath=sse -fvisibility=hidden -O2 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -march=i686 -fomit-frame-pointer -ffunction-sections  -msse -msse2 -mfpmath=sse -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):
    Linker flags (Debug):
    ccache:                      NO
    Precompiled headers:         YES
    Extra dependencies:          comctl32 gdi32 ole32 setupapi ws2_32 vfw32 winmm
    3rdparty dependencies:

  OpenCV modules:
    To be built:                 core flann imgproc ml objdetect phase_unwrapping photo plot reg surface_matching video xphoto bgsegm dnn face fuzzy img_hash imgcodecs shape videoio xobjdetect highgui superres ts bioinspired dpm features2d line_descriptor saliency text calib3d ccalib datasets rgbd stereo tracking videostab xfeatures2d ximgproc aruco optflow python2
    Disabled:                    stitching world contrib_world structured_light
    Disabled by dependency:      -
    Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python3 viz cnn_3dobj cvv dnn_modern freetype hdf matlab sfm

  Windows RT support:            NO

  GUI:
    QT:                          NO
    Win32 UI:                    YES
    OpenGL support:              NO
    VTK support:                 NO

  Media I/O:
    ZLib:                        build (ver 1.2.8)
    JPEG:                        build (ver 90)
    WEBP:                        build (ver encoder: 0x020e)
    PNG:                         build (ver 1.6.24)
    TIFF:                        build (ver 42 - 4.0.2)
    JPEG 2000:                   build (ver 1.900.1)
    OpenEXR:                     build (ver 1.7.1)
    GDAL:                        NO
    GDCM:                        NO

  Video I/O:
    Video for Windows:           YES
    DC1394 1.x:                  NO
    DC1394 2.x:                  NO
    FFMPEG:                      NO
      avcodec:                   NO
      avformat:                  NO
      avutil:                    NO
      swscale:                   NO
      avresample:                NO
    GStreamer:                   NO
    OpenNI:                      NO
    OpenNI PrimeSensor Modules:  NO
    OpenNI2:                     NO
    PvAPI:                       NO
    GigEVisionSDK:               NO
    DirectShow:                  YES
    Media Foundation:            NO
    XIMEA:                       NO
    Intel PerC:                  NO

  Parallel framework:            none

  Trace:                         YES ()

  Other third-party libraries:
    Use Intel IPP:               NO
    Use Intel IPP IW:            NO
    Use Intel IPP Async:         NO
    Use Lapack:                  NO
    Use Eigen:                   NO
    Use Cuda:                    NO
    Use OpenCL:                  NO
    Use OpenVX:                  NO
    Use custom HAL:              NO

  Python 2:
    Interpreter:                 C:/Python27/python.exe (ver 2.7.11)
    Libraries:                   C:/Python27/libs/libpython27.a (ver 2.7.11)
    numpy:                       C:/Python27/lib/site-packages/numpy/core/include (ver 1.11.3)
    packages path:               C:/Python27/Lib/site-packages

  Python 3:
    Interpreter:                 NO

  Python (for build):            C:/Python27/python.exe

  Java:
    ant:                         NO
    JNI:                         NO
    Java wrappers:               NO
    Java tests:                  NO

  Matlab:                        Matlab not found or implicitly disabled

  Documentation:
    Doxygen:                     NO

  Tests and samples:
    Tests:                       YES
    Performance tests:           YES
    C/C++ Examples:              NO

  Install path:                  C:/Users/Ben/Documents/opencv/build/install

  cvconfig.h is in:              C:/Users/Ben/Documents/opencv/build
-----------------------------------------------------------------

Configuring done
Generating done

Is there a cmake flag that gets around this? opencv_core sounds pretty crucial...


来源: stackexchange

问:
My segue goes too far back
This is how my story board currently looks

When I click the buttons on the view with the buttons placed vertically, I can open up the correct corresponding view, however, when I unwind back I end up going all the way back to the sign in page, not the page with the buttons. I have the unwind segue in the right place, just don't know why it's going that far back.

This is the code for the view controller with the buttons

```<code>@IBOutlet weak var menuButton: UIButton!

@IBOutlet weak var clubButton: UIButton!

@IBOutlet weak var announcemnetsButton: UIButton!

@IBOutlet weak var eventButton: UIButton!

var transition = QZCircleSegue()

override func viewDidLoad() {
    super.viewDidLoad()

    menuButton.layer.cornerRadius = menuButton.frame.size.width / 2
    clubButton.layer.cornerRadius = menuButton.frame.size.width / 2
    announcemnetsButton.layer.cornerRadius = menuButton.frame.size.width / 2
    eventButton.layer.cornerRadius = menuButton.frame.size.width / 2

    menuButton.layer.masksToBounds = true
    clubButton.layer.masksToBounds = true
    announcemnetsButton.layer.masksToBounds = true
    eventButton.layer.masksToBounds = true

}
override var prefersStatusBarHidden : Bool {
    return true;

}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if (segue.identifier == "NewVC") {
        self.transition.animationChild = menuButton
        self.transition.animationColor = UIColor(red: 255/255, green: 0/255, blue: 0/255, alpha: 1.0)
    } else if (segue.identifier == "ClubVC") {
        self.transition.animationChild = clubButton
        self.transition.animationColor = UIColor(red: 81/255, green: 172/255, blue: 246/255, alpha: 1.0)
    } else if (segue.identifier == "AnnouncementVC") {
        self.transition.animationChild = announcemnetsButton
        self.transition.animationColor = UIColor(red: 255/255, green: 179/255, blue: 109/255, alpha: 1.0)
    } else if segue.identifier == "EventVC" {
        self.transition.animationChild = eventButton
        self.transition.animationColor = UIColor(red: 63/255, green: 255/255, blue: 176/255, alpha: 1.0)
    }
    let toViewController = segue.destination as! NewViewController
    /* Set both, the origin and destination to your transition manager*/
    self.transition.fromViewController = self
    self.transition.toViewController = toViewController
    /* Add the transition manager to your transitioningDelegate View Controller*/
    toViewController.transitioningDelegate = transition
}

/* Specify the destination view controller to enable the unwind segue*/
@IBAction func unwindToMainViewController (sender: UIStoryboardSegue){
    self.dismiss(animated: true, completion: nil)
</code>```

}
}

答:
The comment that iOS made is right on the money.  Just because you used a segue to get to a view controller doesn't mean you have to use one to leave.  Assuming you want to go back to the view controller you were just displaying, there are a couple of possibilities.  What you want to do is pop the current view controller off the stack. If you're using a navigation controller (most likely you are), then this is how to do that:

```<code> self.navigationController?.dismiss(animated: true, completion: nil)
</code>```

You might be able to simplify it to this:

```<code> dismiss(animated: true, completion: nil)
</code>```

since view controllers have a self.dismiss() method.  Give it a try and let me know whether this works for you.

ContentLicense: CC BY-SA 3.0

Title: My segue goes too far back

Body:
This is how my story board currently looks

When I click the buttons on the view with the buttons placed vertically, I can open up the correct corresponding view, however, when I unwind back I end up going all the way back to the sign in page, not the page with the buttons. I have the unwind segue in the right place, just don't know why it's going that far back.

This is the code for the view controller with the buttons

@IBOutlet weak var menuButton: UIButton!

@IBOutlet weak var clubButton: UIButton!

@IBOutlet weak var announcemnetsButton: UIButton!

@IBOutlet weak var eventButton: UIButton!

var transition = QZCircleSegue()

override func viewDidLoad() {
    super.viewDidLoad()

    menuButton.layer.cornerRadius = menuButton.frame.size.width / 2
    clubButton.layer.cornerRadius = menuButton.frame.size.width / 2
    announcemnetsButton.layer.cornerRadius = menuButton.frame.size.width / 2
    eventButton.layer.cornerRadius = menuButton.frame.size.width / 2

    menuButton.layer.masksToBounds = true
    clubButton.layer.masksToBounds = true
    announcemnetsButton.layer.masksToBounds = true
    eventButton.layer.masksToBounds = true

}
override var prefersStatusBarHidden : Bool {
    return true;

}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if (segue.identifier == "NewVC") {
        self.transition.animationChild = menuButton
        self.transition.animationColor = UIColor(red: 255/255, green: 0/255, blue: 0/255, alpha: 1.0)
    } else if (segue.identifier == "ClubVC") {
        self.transition.animationChild = clubButton
        self.transition.animationColor = UIColor(red: 81/255, green: 172/255, blue: 246/255, alpha: 1.0)
    } else if (segue.identifier == "AnnouncementVC") {
        self.transition.animationChild = announcemnetsButton
        self.transition.animationColor = UIColor(red: 255/255, green: 179/255, blue: 109/255, alpha: 1.0)
    } else if segue.identifier == "EventVC" {
        self.transition.animationChild = eventButton
        self.transition.animationColor = UIColor(red: 63/255, green: 255/255, blue: 176/255, alpha: 1.0)
    }
    let toViewController = segue.destination as! NewViewController
    /* Set both, the origin and destination to your transition manager*/
    self.transition.fromViewController = self
    self.transition.toViewController = toViewController
    /* Add the transition manager to your transitioningDelegate View Controller*/
    toViewController.transitioningDelegate = transition
}

/* Specify the destination view controller to enable the unwind segue*/
@IBAction func unwindToMainViewController (sender: UIStoryboardSegue){
    self.dismiss(animated: true, completion: nil)

}
}

Body:
The comment that iOS made is right on the money.  Just because you used a segue to get to a view controller doesn't mean you have to use one to leave.  Assuming you want to go back to the view controller you were just displaying, there are a couple of possibilities.  What you want to do is pop the current view controller off the stack. If you're using a navigation controller (most likely you are), then this is how to do that:

 self.navigationController?.dismiss(animated: true, completion: nil)

You might be able to simplify it to this:

 dismiss(animated: true, completion: nil)

since view controllers have a self.dismiss() method.  Give it a try and let me know whether this works for you.


问:
Collecting results from python coroutines before loop finishes
I have a python discord bot built with discord.py, meaning the entire program runs inside an event loop.

The function I'm working on involves making several hundred HTTP requests and add the results to a final list.  It takes about two minutes to do these in order, so I'm using aiohttp to make them async.  The related parts of my code are identical to the quickstart example in the aiohttp docs, but it's throwing a RuntimeError: Session is closed.  The methodology was taken from an example at https://pawelmhm.github.io/asyncio/python/aiohttp/2016/04/22/asyncio-aiohttp.html under 'Fetch multiple URLs'.

```<code>async def searchPostList(postUrls, searchString)
    futures = []
    async with aiohttp.ClientSession() as session:
        for url in postUrls:
            task = asyncio.ensure_future(searchPost(url,searchString,session))
            futures.append(task)

    return await asyncio.gather(*futures)

async def searchPost(url,searchString,session)):
    async with session.get(url) as response:
        page = await response.text()

    #Assorted verification and parsing
    Return data
</code>```

I don't know why this error turns up since my code is so similar to two presumably functional examples.  The event loop itself is working fine.  It runs forever, since this is a bot application.

答:
In the example you linked, the gathering of results was within the async with block. If you do it outside, there's no guarantee that the session won't close before the requests are even made!

Moving your return statement inside the block should work:

```<code>async with aiohttp.ClientSession() as session:
        for url in postUrls:
            task = asyncio.ensure_future(searchPost(url,searchString,session))
            futures.append(task)

        return await asyncio.gather(*futures)
</code>```

Body:
I have a python discord bot built with discord.py, meaning the entire program runs inside an event loop.

The function I'm working on involves making several hundred HTTP requests and add the results to a final list.  It takes about two minutes to do these in order, so I'm using aiohttp to make them async.  The related parts of my code are identical to the quickstart example in the aiohttp docs, but it's throwing a RuntimeError: Session is closed.  The methodology was taken from an example at https://pawelmhm.github.io/asyncio/python/aiohttp/2016/04/22/asyncio-aiohttp.html under 'Fetch multiple URLs'.

async def searchPostList(postUrls, searchString)
    futures = []
    async with aiohttp.ClientSession() as session:
        for url in postUrls:
            task = asyncio.ensure_future(searchPost(url,searchString,session))
            futures.append(task)

    return await asyncio.gather(*futures)

async def searchPost(url,searchString,session)):
    async with session.get(url) as response:
        page = await response.text()

    #Assorted verification and parsing
    Return data

I don't know why this error turns up since my code is so similar to two presumably functional examples.  The event loop itself is working fine.  It runs forever, since this is a bot application.

Body:
In the example you linked, the gathering of results was within the async with block. If you do it outside, there's no guarantee that the session won't close before the requests are even made!

Moving your return statement inside the block should work:

async with aiohttp.ClientSession() as session:
        for url in postUrls:
            task = asyncio.ensure_future(searchPost(url,searchString,session))
            futures.append(task)

        return await asyncio.gather(*futures)


问:
'flow property not found in props of react element' when is present for enzyme rendering of component
My Component:

```<code>// @flow
import React from 'react'

type Props = {
  close: Function,
  name: string
}

const MyComponent = ({ close, name }: Props) => (
  <div className='click' onClick={close}>
    {name}
  </div>
)

export default MyComponent
</code>```

My Enzyme Test:

```<code>// @flow
import React from 'react'
import assert from 'assert'
import { shallow } from 'enzyme'
import sinon from 'sinon'

import MyComponent from 'client/apps/spaces/components/slideouts/record-settings/myc'

const defaultProps = {
  close: () => {},
  name: 'My Name'
}

const render = (props) => shallow(<MyComponent {...defaultProps} {...props} />)

describe('<MyComponent />', () => {
  it('renders the name', () => {
    const component = render()

    assert.equal(component.find('.click').text(), 'My Name')
  })

  it('calls close on Click', () => {
    const close = sinon.spy()
    const component = render({ close })
    const clickableDiv = component.find('.click')
    clickableDiv.simulate('click')

    assert(close.calledOnce)
  })
})
</code>```

The tests pass, but it is giving me the following flow error on my 'MyComponent' declaration which refers to the rendering line in my test, despite name definitely being passed in as part of the defaultProps object that is passed into the component:

property 'name' Property not found in props of react element
  'MyComponent'

答:
So, if I completely removed the second test, there was no flow error in the above as written.

I think the problem was that whenever I was passing something to the render() in my test file, flow only checked the overriding props on the component instead of all of them.

Rewriting my test render function like so solved my problem:

```<code>const render = (overrideProps) => {
  const props = {
    ...defaultProps,
    ...overrideProps
  }

  return shallow(<MyComponent {...props} />)
}
</code>```

Body:
My Component:

// @flow
import React from 'react'

type Props = {
  close: Function,
  name: string
}

const MyComponent = ({ close, name }: Props) => (

    {name}

)

export default MyComponent

My Enzyme Test:

// @flow
import React from 'react'
import assert from 'assert'
import { shallow } from 'enzyme'
import sinon from 'sinon'

import MyComponent from 'client/apps/spaces/components/slideouts/record-settings/myc'

const defaultProps = {
  close: () => {},
  name: 'My Name'
}

const render = (props) => shallow(<MyComponent {...defaultProps} {...props} />)

describe('<MyComponent />', () => {
  it('renders the name', () => {
    const component = render()

    assert.equal(component.find('.click').text(), 'My Name')
  })

  it('calls close on Click', () => {
    const close = sinon.spy()
    const component = render({ close })
    const clickableDiv = component.find('.click')
    clickableDiv.simulate('click')

    assert(close.calledOnce)
  })
})

The tests pass, but it is giving me the following flow error on my 'MyComponent' declaration which refers to the rendering line in my test, despite name definitely being passed in as part of the defaultProps object that is passed into the component:

property 'name' Property not found in props of react element
  'MyComponent'

Body:
So, if I completely removed the second test, there was no flow error in the above as written.

I think the problem was that whenever I was passing something to the render() in my test file, flow only checked the overriding props on the component instead of all of them.

Rewriting my test render function like so solved my problem:

const render = (overrideProps) => {
  const props = {
    ...defaultProps,
    ...overrideProps
  }

  return shallow(<MyComponent {...props} />)
}


问:
JSF cannot resolve font resources for @font-face
I'm currently trying to a) add some non-standard fonts and b) the font-awsome icon library to my project. I've donwloaded the the newest version of FA 4.7.0 on their website.

My project structure is like this:

```<code>web
   ----resources
         ---- css
                ---- default.css
         ---- fonts

                ---- Raleway-Regular.ttf
                ---- Roboto-Regular.ttf
                ---- Questrial-Regular.ttf
                ---- Poppins-Regular.ttf

         ---- font-awesome-4.7.0
                ---- css

                       ---- font-awesome.css
                       ---- font-awesome.min.css

                ---- fonts

                       ---- fontawesome-webfont.eot
                       ---- fontawesome-webfont.woff
                       ---- fontawesome-webfont.woff2
                       ---- fontawesome-webfont.svg
                       ---- fontawesome-webfont.ttf
         ---- js

                ---- default.js
</code>```

Both fontawesome.css and my default.css file define fonts via @font-face.
Knowing that JSF cannot handle the fonts as a resource without the use of EL, I changed the code of the stylesheet:

font-awesome.css

```<code>@font-face {
 font-family: 'FontAwesome';
 src: url("#{resource['font-awesome-4.7.0:fonts/fontawesome-webfont.eot']}&v=4.7.0");
 src: url("#{resource['font-awesome-4.7.0:fonts/fontawesome-webfont.eot']}&#iefix&v=4.7.0") format('embedded-opentype'), url("#{resource['font-awesome-4.7.0:fonts/fontawesome-webfont.woff2']}&v=4.7.0") format('woff2'), url("#{resource['font-awesome-4.7.0:fonts/fontawesome-webfont.woff']}&v=4.7.0") format('woff'), url("#{resource['font-awesome-4.7.0:fonts/fontawesome-webfont.ttf']}&v=4.7.0") format('truetype'), url("#{resource['font-awesome-4.7.0:fonts/fontawesome-webfont.svg']}&v=4.7.0#fontawesomeregular") format('svg');
 font-weight: normal;
 font-style: normal;
</code>```

}

My css file is referencing the fonts as below:

```<code>@font-face {
font-family: Railway;
src: url("#{resource['fonts:Raleway-Regular.ttf']}") format("truetype");
}

@font-face {
font-family: Questrial;
src: url("#{resource['fonts/Questrial-Regular.ttf']}") format("truetype");
}

@font-face {
font-family: Poppins;
src: url("#{resource['fonts/Poppins-Regular.ttf']}") format("truetype");
}

@font-face {
font-family: "Roboto";
src: url("#{resource['fonts:Roboto-Regular.ttf']}") format("truetype");
}
</code>```

The fact that I'm using both the ":" and "/" seperator is to test which one's working... apparently none :)

I also added all necessarry MIME type mappings in my web.xml.

In the home.xhtml file, I use these resources like that:

```<code><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://xmlns.jcp.org/jsf/html"
  xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
  xmlns:f="http://xmlns.jcp.org/jsf/core">

  <h:head>
  <h:outputStylesheet library="font-awesome-4.7.0" name="css/font-awesome.css" />
  <h:outputStylesheet name="css/default.css" />
  <h:outputScript name="js/default.js" />
  </h:head>
</code>```

Now after all these configurations, it seems as if the resource handler is not able to load the fonts (my costum and the FA ones) as well as the JavaScript file. The interesting part is that all other styles of the css file are imported correctly. Also it's strange that it worked the exact same way when I booted the server for the first time today - after adding a favicon to the page, it didn't work anymore.

I'm getting notified of the following errors in my browser:

Uncaught TypeError: Cannot read property 'children' of null(…)
  http://localhost:8080/$root/javax.faces.resource/css/resources/fonts/Questrial-Regular.ttf

Failed to load resource: the server responded with a status of 404 (Not Found)

  http://localhost:8080/$root/javax.faces.resource/css/resources/fonts/Raleway-Regular.ttf

Failed to load resource: the server responded with a status of 404 (Not Found)

  http://localhost:8080/$root/javax.faces.resource/fonts/fontawesome-webfont.woff2?v=4.7.0
Failed to load resource: the server responded with a status of 404 (Not Found)

  http://localhost:8080/$root/javax.faces.resource/css/resources/fonts/Poppins-Regular.ttf
Failed to load resource: the server responded with a status of 404 (Not Found)

  http://localhost:8080/$root/javax.faces.resource/css/resources/fonts/Roboto-Regular.ttf
Failed to load resource: the server responded with a status of 404 (Not Found)

  http://localhost:8080/$root/javax.faces.resource/fonts/fontawesome-webfont.woff?v=4.7.0
Failed to load resource: the server responded with a status of 404 (Not Found)

  http://localhost:8080/$root/javax.faces.resource/fonts/fontawesome-webfont.ttf?v=4.7.0
Failed to load resource: the server responded with a status of 404 (Not Found)

I'd be grateful for any help

Server: Glassfish 4.1.1

答:
Disappointing as this may sound, it was just my browser caching all resources.

After using Ctrl + F5, the browser reloaded the page and all according stylesheets

Generally it turned out to be beneficial to turn off the browser cache while doing web development :-).

Body:
I'm currently trying to a) add some non-standard fonts and b) the font-awsome icon library to my project. I've donwloaded the the newest version of FA 4.7.0 on their website.

My project structure is like this:

web
   ----resources
         ---- css
                ---- default.css
         ---- fonts

                ---- Raleway-Regular.ttf
                ---- Roboto-Regular.ttf
                ---- Questrial-Regular.ttf
                ---- Poppins-Regular.ttf

         ---- font-awesome-4.7.0
                ---- css

                       ---- font-awesome.css
                       ---- font-awesome.min.css

                ---- fonts

                       ---- fontawesome-webfont.eot
                       ---- fontawesome-webfont.woff
                       ---- fontawesome-webfont.woff2
                       ---- fontawesome-webfont.svg
                       ---- fontawesome-webfont.ttf
         ---- js

                ---- default.js

Both fontawesome.css and my default.css file define fonts via @font-face.
Knowing that JSF cannot handle the fonts as a resource without the use of EL, I changed the code of the stylesheet:

font-awesome.css

@font-face {
 font-family: 'FontAwesome';
 src: url("#{resource['font-awesome-4.7.0:fonts/fontawesome-webfont.eot']}&v=4.7.0");
 src: url("#{resource['font-awesome-4.7.0:fonts/fontawesome-webfont.eot']}&#iefix&v=4.7.0") format('embedded-opentype'), url("#{resource['font-awesome-4.7.0:fonts/fontawesome-webfont.woff2']}&v=4.7.0") format('woff2'), url("#{resource['font-awesome-4.7.0:fonts/fontawesome-webfont.woff']}&v=4.7.0") format('woff'), url("#{resource['font-awesome-4.7.0:fonts/fontawesome-webfont.ttf']}&v=4.7.0") format('truetype'), url("#{resource['font-awesome-4.7.0:fonts/fontawesome-webfont.svg']}&v=4.7.0#fontawesomeregular") format('svg');
 font-weight: normal;
 font-style: normal;

}

My css file is referencing the fonts as below:

@font-face {
font-family: Railway;
src: url("#{resource['fonts:Raleway-Regular.ttf']}") format("truetype");
}

@font-face {
font-family: Questrial;
src: url("#{resource['fonts/Questrial-Regular.ttf']}") format("truetype");
}

@font-face {
font-family: Poppins;
src: url("#{resource['fonts/Poppins-Regular.ttf']}") format("truetype");
}

@font-face {
font-family: "Roboto";
src: url("#{resource['fonts:Roboto-Regular.ttf']}") format("truetype");
}

The fact that I'm using both the ":" and "/" seperator is to test which one's working... apparently none :)

I also added all necessarry MIME type mappings in my web.xml.

In the home.xhtml file, I use these resources like that:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

  <h:head>
  <h:outputStylesheet library="font-awesome-4.7.0" name="css/font-awesome.css" />
  <h:outputStylesheet name="css/default.css" />
  <h:outputScript name="js/default.js" />
  </h:head>

Now after all these configurations, it seems as if the resource handler is not able to load the fonts (my costum and the FA ones) as well as the JavaScript file. The interesting part is that all other styles of the css file are imported correctly. Also it's strange that it worked the exact same way when I booted the server for the first time today - after adding a favicon to the page, it didn't work anymore.

I'm getting notified of the following errors in my browser:

Uncaught TypeError: Cannot read property 'children' of null(…)
  http://localhost:8080/$root/javax.faces.resource/css/resources/fonts/Questrial-Regular.ttf

Failed to load resource: the server responded with a status of 404 (Not Found)

  http://localhost:8080/$root/javax.faces.resource/css/resources/fonts/Raleway-Regular.ttf

Failed to load resource: the server responded with a status of 404 (Not Found)

  http://localhost:8080/$root/javax.faces.resource/fonts/fontawesome-webfont.woff2?v=4.7.0
Failed to load resource: the server responded with a status of 404 (Not Found)

  http://localhost:8080/$root/javax.faces.resource/css/resources/fonts/Poppins-Regular.ttf
Failed to load resource: the server responded with a status of 404 (Not Found)

  http://localhost:8080/$root/javax.faces.resource/css/resources/fonts/Roboto-Regular.ttf
Failed to load resource: the server responded with a status of 404 (Not Found)

  http://localhost:8080/$root/javax.faces.resource/fonts/fontawesome-webfont.woff?v=4.7.0
Failed to load resource: the server responded with a status of 404 (Not Found)

  http://localhost:8080/$root/javax.faces.resource/fonts/fontawesome-webfont.ttf?v=4.7.0
Failed to load resource: the server responded with a status of 404 (Not Found)

I'd be grateful for any help

Server: Glassfish 4.1.1

ContentLicense: CC BY-SA 4.0


问:
How to return multiple values within a group of rows.
I have tried to use Max(), subqueries, and joins, but my knowledge is limited enough that I am not sure how to organize them. I was willing to just use several nested select statements, knowing it could be resource intensive, but I can't get it to work.

I need to return any nulls, as well as the highest ConfigID for each Location.

```<code>TABLE
ID     Location     ConfigID
1      AA           NULL
2      AA           2
3      AA           1
4      BB           5
5      BB           4
6      BB           3
7      CC           NULL
8      CC           6
</code>```

I want to see the results:

```<code>ID     Location     ConfigID
1      AA           NULL
2      AA           2
4      BB           5
7      CC           NULL
8      CC           6
</code>```

I have tried:

```<code>select ID, Location, ConfigID
from Table
where ConfigID is null
      or configID = (select ConfigID
                     from table
                     where Location in (select distinct Location
                                        from Table
                                        order by ConfigID desc
                                        )
                     )
</code>```

SQL server didn't like that because I cannot have an order by in a subquery unless Top is used. Now that I am looking at it again, I don't think that the order by is even within the correct subquery. It was as close as I could get. I was hopeful when I saw Select Max from each subset, but that was a dead-end, I think. Also, I don't believe that a self-join will work because the data I would self-join on is all in one column.

答:
You're almost there. Yes, you need to use TOP 1, what's wrong with that?

Try this:

```<code>SELECT ID, Location, ConfigID
FROM myTable t1
WHERE ConfigID IS NULL
   OR ID = (SELECT TOP 1 ID
            FROM myTable t2
            WHERE t2.Location = t1.Location
            ORDER BY ConfigID DESC)
</code>```

Here is a fiddle.

Body:
I have tried to use Max(), subqueries, and joins, but my knowledge is limited enough that I am not sure how to organize them. I was willing to just use several nested select statements, knowing it could be resource intensive, but I can't get it to work.

I need to return any nulls, as well as the highest ConfigID for each Location.

TABLE
ID     Location     ConfigID
1      AA           NULL
2      AA           2
3      AA           1
4      BB           5
5      BB           4
6      BB           3
7      CC           NULL
8      CC           6

I want to see the results:

ID     Location     ConfigID
1      AA           NULL
2      AA           2
4      BB           5
7      CC           NULL
8      CC           6

I have tried:

select ID, Location, ConfigID
from Table
where ConfigID is null
      or configID = (select ConfigID
                     from table
                     where Location in (select distinct Location
                                        from Table
                                        order by ConfigID desc
                                        )
                     )

SQL server didn't like that because I cannot have an order by in a subquery unless Top is used. Now that I am looking at it again, I don't think that the order by is even within the correct subquery. It was as close as I could get. I was hopeful when I saw Select Max from each subset, but that was a dead-end, I think. Also, I don't believe that a self-join will work because the data I would self-join on is all in one column.

Body:
You're almost there. Yes, you need to use TOP 1, what's wrong with that?

Try this:

SELECT ID, Location, ConfigID
FROM myTable t1
WHERE ConfigID IS NULL
   OR ID = (SELECT TOP 1 ID
            FROM myTable t2
            WHERE t2.Location = t1.Location
            ORDER BY ConfigID DESC)

Here is a fiddle.


问:
Position laser-controls entity after camera rotation
I have the following code for the laser controls which are perfectly positioned when the camera looks straight ahead after entering VR mode.

```<code><a-entity position="0.25 1.25 -0.2" class="laser-controls">
  <a-entity laser-controls="hand: right" line="color: red"></a-entity></a-entity>
</code>```

The issue is: when I rotate my head (camera), I would like to let the controls follow my head rotation smoothly (I have some code which looks if the rotation is greater than 110 degrees). I don't want the controllers be part of the camera since they should keep their own independent rotation. What I like is the behaviour of the controller model in Oculus Home (Gear VR).

How can I achieve this is my custom component, let's say in my tick function, which is called every two seconds (that code works already).

Thanks!

答:
How about using getAttribute() to check the rotation of the camera component and the laser control's entity? Then you could check if the difference exceeds 110 degrees or not:

```<code>let angle = laser.getAttribute('rotation');
if (camera.getAttribute('rotation').y - laser.getAttribute('rotation').y>110){
   angle.y++;
   laser.setAttribute('rotation',angle);
} else if(camera.getAttribute('rotation').y - laser.getAttribute('rotation').y<-110){
   angle.y--;
   laser.setAttribute('rotation',angle);
}
</code>```

UPDATE

If You want to position Your controller near Your head You can:

1.Instead of angle.y++/-- change it to Your camera's rotation. You can also change its x/y position close to the camera ( like camera.position.x + 0.5 )

2.But the above is instant, if You want to make it smooth, You could use the animation component, when the delta degree is >110 deg, set the animation attributes to move to the camera component location/rotation, emit a beginning event, disable the rotation check, listen for the animation end event, and enable the check. a bit like this:

```<code>init: function(){
  this.check = true;
  let check = this.check;
  animationel.addEventListener('animationend',function(){
      check = true;
  });
},tick(){
    if(this.check){
        if(rotationCheck()){
           this.check = false;
        }
    }
  }
</code>```

Body:
I have the following code for the laser controls which are perfectly positioned when the camera looks straight ahead after entering VR mode.

The issue is: when I rotate my head (camera), I would like to let the controls follow my head rotation smoothly (I have some code which looks if the rotation is greater than 110 degrees). I don't want the controllers be part of the camera since they should keep their own independent rotation. What I like is the behaviour of the controller model in Oculus Home (Gear VR).

How can I achieve this is my custom component, let's say in my tick function, which is called every two seconds (that code works already).

Thanks!

Body:
How about using getAttribute() to check the rotation of the camera component and the laser control's entity? Then you could check if the difference exceeds 110 degrees or not:

let angle = laser.getAttribute('rotation');
if (camera.getAttribute('rotation').y - laser.getAttribute('rotation').y>110){
   angle.y++;
   laser.setAttribute('rotation',angle);
} else if(camera.getAttribute('rotation').y - laser.getAttribute('rotation').y<-110){
   angle.y--;
   laser.setAttribute('rotation',angle);
}

UPDATE

If You want to position Your controller near Your head You can:

1.Instead of angle.y++/-- change it to Your camera's rotation. You can also change its x/y position close to the camera ( like camera.position.x + 0.5 )

2.But the above is instant, if You want to make it smooth, You could use the animation component, when the delta degree is >110 deg, set the animation attributes to move to the camera component location/rotation, emit a beginning event, disable the rotation check, listen for the animation end event, and enable the check. a bit like this:

init: function(){
  this.check = true;
  let check = this.check;
  animationel.addEventListener('animationend',function(){
      check = true;
  });
},tick(){
    if(this.check){
        if(rotationCheck()){
           this.check = false;
        }
    }
  }


问:
Using apply() with a custom function and a second data frame
I'm trying to generate predicted values from a large number of model simulations and I'm having a hard time doing it simply. I suspect I need something from the apply() family, but I can't figure out the syntax.  Maybe my knowledge of apply() is weak. Or maybe my function is wrong.  Any suggestions?

Suppose I've got following coefficients resulting from six model simulations...

```<code>coef <- data.frame(intercept=c(2,3,5,7,2,1),
                   b1 = c(.2,.5,.6,.7,.9,.4),
                   b2 = c(10,11,12,11,9,10))
</code>```

I want to compute (predicted values or) the linear combination of each row above and each row of the following data frame...

```<code>df <- data.frame(age = c(50,20,19, 42),
                 height = c(60,72,79, 66))
</code>```

...Using the following model equation:

```<code>coef$intercept + coef$b1*df$age + coef$b2*df$height
</code>```

Done right, I should get the following 24 data values:

```<code>612.0   726.0   795.8   670.4
688.0   805.0   881.5   750
755.0   881.0   964.4   822.2
702.0   813.0   889.3   762.4
587.0   668.0   730.1   633.8
621.0   729.0   798.6   677.8
</code>```

To get the above, I've tried the following function and use of apply()...

```<code>equation <-  function(...) coef$intercept + coef$b1*df$age + coef$b2*df$height
result <- apply(df, 1, equation)
</code>```

...but I don't get the correct answer. The "result" data frame just repeats the correct diagonals. I also get the message:

```<code>> Warning messages: 1: In coef$b1 * df$age :   longer object length is
> not a multiple of shorter object length
</code>```

Yes I can get the correct answer through simple matrix multiplication:

```<code>df$ones <- 1
df <- df[,c(3, 1, 2)]
result <- as.matrix(coef) %*% t(as.matrix(df))
</code>```

But it seems to me one ought to be able to do this more generally using apply() and a custom function. Use of apply() is more compact and puts me less at risk of having my matrix columns in the wrong order.  Any suggestions?

Body:
I'm trying to generate predicted values from a large number of model simulations and I'm having a hard time doing it simply. I suspect I need something from the apply() family, but I can't figure out the syntax.  Maybe my knowledge of apply() is weak. Or maybe my function is wrong.  Any suggestions?

Suppose I've got following coefficients resulting from six model simulations...

coef <- data.frame(intercept=c(2,3,5,7,2,1),
                   b1 = c(.2,.5,.6,.7,.9,.4),
                   b2 = c(10,11,12,11,9,10))

I want to compute (predicted values or) the linear combination of each row above and each row of the following data frame...

df <- data.frame(age = c(50,20,19, 42),
                 height = c(60,72,79, 66))

...Using the following model equation:

coef$intercept + coef$b1*df$age + coef$b2*df$height

Done right, I should get the following 24 data values:

612.0   726.0   795.8   670.4
688.0   805.0   881.5   750
755.0   881.0   964.4   822.2
702.0   813.0   889.3   762.4
587.0   668.0   730.1   633.8
621.0   729.0   798.6   677.8

To get the above, I've tried the following function and use of apply()...

equation <-  function(...) coef$intercept + coef$b1*df$age + coef$b2*df$height
result <- apply(df, 1, equation)

...but I don't get the correct answer. The "result" data frame just repeats the correct diagonals. I also get the message:

> Warning messages: 1: In coef$b1 * df$age :   longer object length is
> not a multiple of shorter object length

Yes I can get the correct answer through simple matrix multiplication:

df$ones <- 1
df <- df[,c(3, 1, 2)]
result <- as.matrix(coef) %*% t(as.matrix(df))

But it seems to me one ought to be able to do this more generally using apply() and a custom function. Use of apply() is more compact and puts me less at risk of having my matrix columns in the wrong order.  Any suggestions?

Body:
We can do this with %*%

coef[,1] + as.matrix(coef[-1]) %*% t(df)
#     [,1] [,2]  [,3]  [,4]
#[1,]  612  726 795.8 670.4
#[2,]  688  805 881.5 750.0
#[3,]  755  881 964.4 822.2
#[4,]  702  813 889.3 762.4
#[5,]  587  668 730.1 633.8
#[6,]  621  729 798.6 677.8


问:
Echo product title in woo commerce
At the bottom of every product I want to add the sentence:

Any Questions about "Product Name", get in touch with us

The code I'm using is

```<code><h1>Questions about <?php the_product); ?> get in touch</h1>
</code>```

This however doesn't seem to work, how do I pull the product name in Woocommerce?

答:
Here is what I use for my product page markups.

```

Title: Echo product title in woo commerce

Body:
At the bottom of every product I want to add the sentence:

Any Questions about "Product Name", get in touch with us

The code I'm using is

Questions about <?php the_product); ?> get in touch

This however doesn't seem to work, how do I pull the product name in Woocommerce?

Body:
Here is what I use for my product page markups.

<script type="application/ld+json">{
 "@context": "http://schema.org/",
    "@type": "Product",
    "name": "<?php echo the_title(); ?>",
    "category": "Designer Fashion Boutique",
    "description": "Designer Clothing Store and Online Fashion Boutique",
 "url": "<?php the_permalink(); ?>"},

</script>


问:
How to setup ember engines?
I've created a standalone routable engine with ember-engines 0.4.0, ember-cli 2.10.0.

I get this error if I call the engines index route (/thingy/):

Assertion Failed: Asset manifest does not list any available bundles.

Consuming App router.js:

this.mount('thingy-frontend', { as: 'thingy', path: 'thingy' });
```

<p>Engine App <code>routes.js</code>:</p>

<pre class="lang-js prettyprint-override"><code>this.route('index', { path: '/' });
</code>```

The engine is 'installed' via a symlink in the node_modules/ dir of the consuming ember-cli app. (See here why).

Just for fun I've tried to change the routes to test if that works ...

Consuming App router.js:

this.mount('thingy-frontend', { as: 'thingy' });
```

<p>Engine App <code>routes.js</code>:</p>

<pre class="lang-js prettyprint-override"><code>this.route('index', { path: 'new' });
</code>```

I've called /thingy/new and got an UnrecognizedURLError. Alternative, if I call the root path, I get an Assertion Failed: Asset manifest does not list any available bundles.

Also if I place a console.log('...'); in the engines index.js, I can't see any output. Seems like it isn't loaded at all.

The setup was inspired by the official README and the official example repos.

Any idea how to fix this Ember Engines setup?

You can find the repos on GitHub:

Engine: https://github.com/phortx/ember-engines-engine

Consuming App with README: https://github.com/phortx/ember-engines-app

答:
I'd add that incompatibility could also be an issue...

As Ember Engines is experimental and being developed against the master branches of Ember and Ember-CLI, be sure that you are using compatible versions.

Title: How to setup ember engines?

Body:
I've created a standalone routable engine with ember-engines 0.4.0, ember-cli 2.10.0.

I get this error if I call the engines index route (/thingy/):

Assertion Failed: Asset manifest does not list any available bundles.

Consuming App router.js:

this.mount('thingy-frontend', { as: 'thingy', path: 'thingy' });

Engine App routes.js:

this.route('index', { path: '/' });

The engine is 'installed' via a symlink in the node_modules/ dir of the consuming ember-cli app. (See here why).

Just for fun I've tried to change the routes to test if that works ...

Consuming App router.js:

this.mount('thingy-frontend', { as: 'thingy' });

Engine App routes.js:

this.route('index', { path: 'new' });

I've called /thingy/new and got an UnrecognizedURLError. Alternative, if I call the root path, I get an Assertion Failed: Asset manifest does not list any available bundles.

Also if I place a console.log('...'); in the engines index.js, I can't see any output. Seems like it isn't loaded at all.

The setup was inspired by the official README and the official example repos.

Any idea how to fix this Ember Engines setup?

You can find the repos on GitHub:

Engine: https://github.com/phortx/ember-engines-engine

Consuming App with README: https://github.com/phortx/ember-engines-app


问:
Getting the Delta between the rows on SQL
I need to get the difference between the row on the same column. I can use lag()over but how can I get the result like the pic, if the name changed then start counting as new

答:
Something like this:

```<code>select t.*,
       (call_received -
        lag(call_received, 1, 0) over (partition by agent_name order by id)
       ) as delta
from t;
</code>```

Note that this uses the rarely seen three-argument form of lag().

Body:
Something like this:

select t.*,
       (call_received -
        lag(call_received, 1, 0) over (partition by agent_name order by id)
       ) as delta
from t;

Note that this uses the rarely seen three-argument form of lag().


问:
AWS SDK can´t connect behind corporate proxy
My workstation is behind a corporate proxy, I have set environment variables and I am able to use everything but aws-sdk with NodeJS. Here a dump of the TCP connection:

```<code>No.     Time           Source                Destination           Protocol Length Info
  2 1.834143       105.103.15.106        105.103.82.47         TCP      74     54952 → 8080 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=497254718 TSecr=0 WS=128
  3 1.836141       105.103.82.47         105.103.15.106        TCP      74     8080 → 54952 [SYN, ACK] Seq=0 Ack=1 Win=14480 Len=0 MSS=1460 SACK_PERM=1 TSval=3399116010 TSecr=497254718 WS=128
  4 1.836165       105.103.15.106        105.103.82.47         TCP      66     54952 → 8080 [ACK] Seq=1 Ack=1 Win=29312 Len=0 TSval=497254719 TSecr=3399116010
  5 1.836779       105.103.15.106        105.103.82.47         TCP      310    54952 → 8080 [PSH, ACK] Seq=1 Ack=1 Win=29312 Len=244 TSval=497254719 TSecr=3399116010
  6 1.838250       105.103.82.47         105.103.15.106        TCP      66     8080 → 54952 [ACK] Seq=1 Ack=245 Win=15616 Len=0 TSval=3399116012 TSecr=497254719
 20 123.670911     105.103.82.47         105.103.15.106        TCP      66     8080 → 54952 [FIN, ACK] Seq=1 Ack=245 Win=15616 Len=0 TSval=3399237839 TSecr=497254719
 21 123.674168     105.103.15.106        105.103.82.47         TCP      66     54952 → 8080 [FIN, ACK] Seq=245 Ack=2 Win=29312 Len=0 TSval=497285178 TSecr=3399237839
 22 123.676592     105.103.82.47         105.103.15.106        TCP      66     8080 → 54952 [ACK] Seq=2 Ack=246 Win=15616 Len=0 TSval=3399237843 TSecr=497285178
</code>```

Notice that three-way handshake goes ok, than client (ip ending on 106) sends some data (psh, ack) on package number 5 and immediately, receiveis proxy´s ACK (packet number 6).  Then no communication for a long period (packages between 7 and 19 are not from this tcp conversation), packet 20 is a FIN (proxy timeout due no packages sent?). This conversation was generated by example provided by Amazon.

Node versions: tested on 6.10.0, 6.11.0 and 8.1.3
SDK installed today (2.82.0)

As a comparison, I run an aws cloudformatin describe-stack-resources --stack-name my-stack on the same Ubuntu machine. As known, aws CLI is python, the command runs OK, and conversation goes like:

```<code>No.     Time           Source                Destination           Protocol Length Info
  1 0.000000       105.103.15.106        105.103.82.47         TCP      74     54940 → 8080 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=496906305 TSecr=0 WS=128
  2 0.001987       105.103.82.47         105.103.15.106        TCP      74     8080 → 54940 [SYN, ACK] Seq=0 Ack=1 Win=14480 Len=0 MSS=1460 SACK_PERM=1 TSval=3397722434 TSecr=496906305 WS=128
  3 0.002008       105.103.15.106        105.103.82.47         TCP      66     54940 → 8080 [ACK] Seq=1 Ack=1 Win=29312 Len=0 TSval=496906305 TSecr=3397722434
  4 0.002100       105.103.15.106        105.103.82.47         TCP      127    [TCP segment of a reassembled PDU]
  5 0.003967       105.103.82.47         105.103.15.106        TCP      66     8080 → 54940 [ACK] Seq=1 Ack=62 Win=14592 Len=0 TSval=3397722436 TSecr=496906306
  6 0.003974       105.103.15.106        105.103.82.47         HTTP     68     CONNECT cloudformation.us-east-1.amazonaws.com:443 HTTP/1.0
  7 0.006035       105.103.82.47         105.103.15.106        TCP      66     8080 → 54940 [ACK] Seq=1 Ack=64 Win=14592 Len=0 TSval=3397722438 TSecr=496906306
  8 0.247802       105.103.82.47         105.103.15.106        HTTP     185    HTTP/1.0 200 Connection established
  9 0.247810       105.103.15.106        105.103.82.47         TCP      66     54940 → 8080 [ACK] Seq=64 Ack=120 Win=29312 Len=0 TSval=496906367 TSecr=3397722681
 10 0.248938       105.103.15.106        105.103.82.47         TLSv1.2  583    Client Hello
 11 0.250985       105.103.82.47         105.103.15.106        TCP      66     8080 → 54940 [ACK] Seq=120 Ack=581 Win=15616 Len=0 TSval=3397722683 TSecr=496906367
 12 0.684003       105.103.82.47         105.103.15.106        TLSv1.2  1995   Server Hello
 13 0.684011       105.103.15.106        105.103.82.47         TCP      66     54940 → 8080 [ACK] Seq=581 Ack=2049 Win=33152 Len=0 TSval=496906476 TSecr=3397723117
 14 0.690001       105.103.82.47         105.103.15.106        TLSv1.2  1488   CertificateServer Key Exchange, Server Hello Done
 15 0.690866       105.103.15.106        105.103.82.47         TLSv1.2  216    Client Key Exchange, Change Cipher Spec, Encrypted Handshake Message
 16 0.692974       105.103.82.47         105.103.15.106        TCP      66     8080 → 54940 [ACK] Seq=3471 Ack=731 Win=16640 Len=0 TSval=3397723125 TSecr=496906478
 17 0.968807       105.103.82.47         105.103.15.106        TLSv1.2  141    Change Cipher Spec, Encrypted Handshake Message
 18 0.969476       105.103.15.106        105.103.82.47         TLSv1.2  679    Application Data
 19 0.970992       105.103.82.47         105.103.15.106        TCP      66     8080 → 54940 [ACK] Seq=3546 Ack=1344 Win=17920 Len=0 TSval=3397723403 TSecr=496906547
 20 1.319977       105.103.82.47         105.103.15.106        TLSv1.2  617    Application Data
 21 1.324998       105.103.82.47         105.103.15.106        TCP      2114   [TCP segment of a reassembled PDU]
 22 1.325003       105.103.15.106        105.103.82.47         TCP      66     54940 → 8080 [ACK] Seq=1344 Ack=6145 Win=43008 Len=0 TSval=496906636 TSecr=3397723753
 23 1.329979       105.103.82.47         105.103.15.106        TLSv1.2  133    Application Data
 24 1.332987       105.103.15.106        105.103.82.47         TCP      66     54940 → 8080 [FIN, ACK] Seq=1344 Ack=6212 Win=43008 Len=0 TSval=496906638 TSecr=3397723763
 25 1.373825       105.103.82.47         105.103.15.106        TCP      66     8080 → 54940 [ACK] Seq=6212 Ack=1345 Win=17920 Len=0 TSval=3397723807 TSecr=496906638
 26 1.606041       105.103.82.47         105.103.15.106        TLSv1.2  119    Encrypted Alert
 27 1.606063       105.103.15.106        105.103.82.47         TCP      54     54940 → 8080 [RST] Seq=1345 Win=0 Len=0
</code>```

Notice that packets from 1 to 3 are threeway handshake and exact same as with JS SDK, packet 4 is similar to packet 5 of JS SDK, it is not shown on summary but it also has PSH flag and ACK, differences are the content (expected) and packet 5 is the proxy ACK to that data. From this point on things are different, aws CLI sends next pack as soon as the ACK arrives on packet 6. After data received, aws CLI sends FIN, receives ACK, Encrypt Alert and sends a RST (this is due Encrypt Alert not expected).

I can´t find why JS SDK stop to send data after last server ACK. But since proxy times out and send FIN ACK after sometime, my node script seems to hang for long until abort with error below:

```<code>{ NetworkingError: socket hang up
at TLSSocket.onHangUp (_tls_wrap.js:1124:19)
at TLSSocket.g (events.js:292:16)
at emitNone (events.js:91:20)
at TLSSocket.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)
</code>```

message: 'socket hang up',
  code: 'NetworkingError',
  region: 'us-west-2',
  hostname: 'bucket.s3-us-west-2.amazonaws.com',
  retryable: true,
  time: 2017-07-07T19:31:29.494Z } null

Any clue?

答:
Looking over the output, the CLI connection is using CONNECT (HTTP tunneling) as described here while your NodeJS SDK call doesn't appear to be doing so. It seems that NodeJS SDK with CONNECT type proxies is a bit weird. I'd recommend looking over the bug on it which mentions using node-tunnel to give something like this:

```<code>var AWS = require('aws-sdk');
var tunnel = require('tunnel');

var tunnelingAgent = tunnel.httpsOverHttp({
  proxy: { // Proxy settings
    host: 'proxyhost',
    port: 8080,
    proxyAuth: "user:pass",
  }
});

AWS.config.update({
  httpOptions: {
    agent: tunnelingAgent
  }
});

var s3 = new AWS.S3({region: 'us-west-2'});
s3.getObject({Bucket: 'bucket', Key: 'key'}, function (err, data) {
  console.log(err, data);
});
</code>```

While I unfortunately don't have an environment setup to test this I hope it will at least give you a start on how to approach the issue.

Body:
My workstation is behind a corporate proxy, I have set environment variables and I am able to use everything but aws-sdk with NodeJS. Here a dump of the TCP connection:

No.     Time           Source                Destination           Protocol Length Info
  2 1.834143       105.103.15.106        105.103.82.47         TCP      74     54952 → 8080 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=497254718 TSecr=0 WS=128
  3 1.836141       105.103.82.47         105.103.15.106        TCP      74     8080 → 54952 [SYN, ACK] Seq=0 Ack=1 Win=14480 Len=0 MSS=1460 SACK_PERM=1 TSval=3399116010 TSecr=497254718 WS=128
  4 1.836165       105.103.15.106        105.103.82.47         TCP      66     54952 → 8080 [ACK] Seq=1 Ack=1 Win=29312 Len=0 TSval=497254719 TSecr=3399116010
  5 1.836779       105.103.15.106        105.103.82.47         TCP      310    54952 → 8080 [PSH, ACK] Seq=1 Ack=1 Win=29312 Len=244 TSval=497254719 TSecr=3399116010
  6 1.838250       105.103.82.47         105.103.15.106        TCP      66     8080 → 54952 [ACK] Seq=1 Ack=245 Win=15616 Len=0 TSval=3399116012 TSecr=497254719
 20 123.670911     105.103.82.47         105.103.15.106        TCP      66     8080 → 54952 [FIN, ACK] Seq=1 Ack=245 Win=15616 Len=0 TSval=3399237839 TSecr=497254719
 21 123.674168     105.103.15.106        105.103.82.47         TCP      66     54952 → 8080 [FIN, ACK] Seq=245 Ack=2 Win=29312 Len=0 TSval=497285178 TSecr=3399237839
 22 123.676592     105.103.82.47         105.103.15.106        TCP      66     8080 → 54952 [ACK] Seq=2 Ack=246 Win=15616 Len=0 TSval=3399237843 TSecr=497285178

Notice that three-way handshake goes ok, than client (ip ending on 106) sends some data (psh, ack) on package number 5 and immediately, receiveis proxy´s ACK (packet number 6).  Then no communication for a long period (packages between 7 and 19 are not from this tcp conversation), packet 20 is a FIN (proxy timeout due no packages sent?). This conversation was generated by example provided by Amazon.

Node versions: tested on 6.10.0, 6.11.0 and 8.1.3
SDK installed today (2.82.0)

As a comparison, I run an aws cloudformatin describe-stack-resources --stack-name my-stack on the same Ubuntu machine. As known, aws CLI is python, the command runs OK, and conversation goes like:

No.     Time           Source                Destination           Protocol Length Info
  1 0.000000       105.103.15.106        105.103.82.47         TCP      74     54940 → 8080 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=496906305 TSecr=0 WS=128
  2 0.001987       105.103.82.47         105.103.15.106        TCP      74     8080 → 54940 [SYN, ACK] Seq=0 Ack=1 Win=14480 Len=0 MSS=1460 SACK_PERM=1 TSval=3397722434 TSecr=496906305 WS=128
  3 0.002008       105.103.15.106        105.103.82.47         TCP      66     54940 → 8080 [ACK] Seq=1 Ack=1 Win=29312 Len=0 TSval=496906305 TSecr=3397722434
  4 0.002100       105.103.15.106        105.103.82.47         TCP      127    [TCP segment of a reassembled PDU]
  5 0.003967       105.103.82.47         105.103.15.106        TCP      66     8080 → 54940 [ACK] Seq=1 Ack=62 Win=14592 Len=0 TSval=3397722436 TSecr=496906306
  6 0.003974       105.103.15.106        105.103.82.47         HTTP     68     CONNECT cloudformation.us-east-1.amazonaws.com:443 HTTP/1.0
  7 0.006035       105.103.82.47         105.103.15.106        TCP      66     8080 → 54940 [ACK] Seq=1 Ack=64 Win=14592 Len=0 TSval=3397722438 TSecr=496906306
  8 0.247802       105.103.82.47         105.103.15.106        HTTP     185    HTTP/1.0 200 Connection established
  9 0.247810       105.103.15.106        105.103.82.47         TCP      66     54940 → 8080 [ACK] Seq=64 Ack=120 Win=29312 Len=0 TSval=496906367 TSecr=3397722681
 10 0.248938       105.103.15.106        105.103.82.47         TLSv1.2  583    Client Hello
 11 0.250985       105.103.82.47         105.103.15.106        TCP      66     8080 → 54940 [ACK] Seq=120 Ack=581 Win=15616 Len=0 TSval=3397722683 TSecr=496906367
 12 0.684003       105.103.82.47         105.103.15.106        TLSv1.2  1995   Server Hello
 13 0.684011       105.103.15.106        105.103.82.47         TCP      66     54940 → 8080 [ACK] Seq=581 Ack=2049 Win=33152 Len=0 TSval=496906476 TSecr=3397723117
 14 0.690001       105.103.82.47         105.103.15.106        TLSv1.2  1488   CertificateServer Key Exchange, Server Hello Done
 15 0.690866       105.103.15.106        105.103.82.47         TLSv1.2  216    Client Key Exchange, Change Cipher Spec, Encrypted Handshake Message
 16 0.692974       105.103.82.47         105.103.15.106        TCP      66     8080 → 54940 [ACK] Seq=3471 Ack=731 Win=16640 Len=0 TSval=3397723125 TSecr=496906478
 17 0.968807       105.103.82.47         105.103.15.106        TLSv1.2  141    Change Cipher Spec, Encrypted Handshake Message
 18 0.969476       105.103.15.106        105.103.82.47         TLSv1.2  679    Application Data
 19 0.970992       105.103.82.47         105.103.15.106        TCP      66     8080 → 54940 [ACK] Seq=3546 Ack=1344 Win=17920 Len=0 TSval=3397723403 TSecr=496906547
 20 1.319977       105.103.82.47         105.103.15.106        TLSv1.2  617    Application Data
 21 1.324998       105.103.82.47         105.103.15.106        TCP      2114   [TCP segment of a reassembled PDU]
 22 1.325003       105.103.15.106        105.103.82.47         TCP      66     54940 → 8080 [ACK] Seq=1344 Ack=6145 Win=43008 Len=0 TSval=496906636 TSecr=3397723753
 23 1.329979       105.103.82.47         105.103.15.106        TLSv1.2  133    Application Data
 24 1.332987       105.103.15.106        105.103.82.47         TCP      66     54940 → 8080 [FIN, ACK] Seq=1344 Ack=6212 Win=43008 Len=0 TSval=496906638 TSecr=3397723763
 25 1.373825       105.103.82.47         105.103.15.106        TCP      66     8080 → 54940 [ACK] Seq=6212 Ack=1345 Win=17920 Len=0 TSval=3397723807 TSecr=496906638
 26 1.606041       105.103.82.47         105.103.15.106        TLSv1.2  119    Encrypted Alert
 27 1.606063       105.103.15.106        105.103.82.47         TCP      54     54940 → 8080 [RST] Seq=1345 Win=0 Len=0

Notice that packets from 1 to 3 are threeway handshake and exact same as with JS SDK, packet 4 is similar to packet 5 of JS SDK, it is not shown on summary but it also has PSH flag and ACK, differences are the content (expected) and packet 5 is the proxy ACK to that data. From this point on things are different, aws CLI sends next pack as soon as the ACK arrives on packet 6. After data received, aws CLI sends FIN, receives ACK, Encrypt Alert and sends a RST (this is due Encrypt Alert not expected).

I can´t find why JS SDK stop to send data after last server ACK. But since proxy times out and send FIN ACK after sometime, my node script seems to hang for long until abort with error below:

{ NetworkingError: socket hang up
at TLSSocket.onHangUp (_tls_wrap.js:1124:19)
at TLSSocket.g (events.js:292:16)
at emitNone (events.js:91:20)
at TLSSocket.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)

message: 'socket hang up',
  code: 'NetworkingError',
  region: 'us-west-2',
  hostname: 'bucket.s3-us-west-2.amazonaws.com',
  retryable: true,
  time: 2017-07-07T19:31:29.494Z } null

Any clue?

Body:
Looking over the output, the CLI connection is using CONNECT (HTTP tunneling) as described here while your NodeJS SDK call doesn't appear to be doing so. It seems that NodeJS SDK with CONNECT type proxies is a bit weird. I'd recommend looking over the bug on it which mentions using node-tunnel to give something like this:

var AWS = require('aws-sdk');
var tunnel = require('tunnel');

var tunnelingAgent = tunnel.httpsOverHttp({
  proxy: { // Proxy settings
    host: 'proxyhost',
    port: 8080,
    proxyAuth: "user:pass",
  }
});

AWS.config.update({
  httpOptions: {
    agent: tunnelingAgent
  }
});

var s3 = new AWS.S3({region: 'us-west-2'});
s3.getObject({Bucket: 'bucket', Key: 'key'}, function (err, data) {
  console.log(err, data);
});

While I unfortunately don't have an environment setup to test this I hope it will at least give you a start on how to approach the issue.


问:
How to convert kivy applications (.py) into apk on windows?
Note: Before you state that this question is duplicate, and link other questions such as:

Kivy standalone android apk on windows

Kivy to Apk in Windows

Keep in mind that they are from 2013-2014, aka 3-4 years ago, I searched around and I could not find any recent questions about this topic.

So I have this windows 10 computer, I have to convert an application made in kivy to apk, I've read the above answers and other resources and found out it is hopeless, and my best bet is to download a virtual machine, but that would take a lot of time just downloading it as my connection speed is pretty slow, so I would rather not take that approach unless it is really the only way to proceed, but all of this information was like 3 years old, is there any recent way to convert kivy to apk on windows without using virtual box and friends?

Note: I'm using Python 2.7.10 atm

答: python-for-android apparently works in the windows subsystem for linux, available in windows 10, so you could try that. I don't know what issues you might hit in particular. It isn't officially supported, although it probably could be if developers able to test it are interested.</p>


问:
evaluating "()" in node.js causes wierd behaviour, but browser says syntax error (bug in node.js?)
When I evaluate the expression "()" in node.js (without the quotes), it corrupts the environment. The global object is trashed and nothing works. When i evaluate the same express in the browser console it reports a syntax error. From my research it appears the browser is correct. Is this a bug in the node.js expression parser? Can anyone explain what is happening under the hood?
Here is a screenshot</p>

答:
() by itself isn't valid JavaScript syntax.

When Node encounters a Syntax Error in the REPL it waits for more input. It tries to indicate this by changing your prompt to three dots.

This is useful because sometimes you want to enter some code that contains a new line:

```<code>> () => { // this isn't valid syntax by itself
... }     // but you can complete a valid expression like this
</code>```

In this case there is no input you could add to complete a valid expression, but you can exit the "waiting for input" mode with ctrl-c.

Body:
() by itself isn't valid JavaScript syntax.

When Node encounters a Syntax Error in the REPL it waits for more input. It tries to indicate this by changing your prompt to three dots.

This is useful because sometimes you want to enter some code that contains a new line:

> () => { // this isn't valid syntax by itself
... }     // but you can complete a valid expression like this

In this case there is no input you could add to complete a valid expression, but you can exit the "waiting for input" mode with ctrl-c.


问:
Can't correctly extract information of a file
I am trying to extract some data of a file. For that purpose have made a script which reads the file and if some keyword is detected, it starts copying and then, when finds a blank line, it stops copying. I think it is not too bad, but is not working.

The python script i wrote is:

```<code>def out_to_mop (namefilein, namefileout):
    print namefilein
    filein=open(namefilein, "r")
    fileout=open(namefileout, "w")
    lines = filein.readlines()
    filein.close()

    #look for keyword "CURRENT.." to start copying
    try:
        indexmaxcycle = lines.index("          CURRENT BEST VALUE OF HEAT OF FORMATION")
        indexmaxcycle += 5
    except:
        indexmaxcycle = 0

    if indexmaxcycle != 0:
        while lines[indexmaxcycle]!=" \n":
            linediv = lines[indexmaxcycle].split()
            symbol = linediv[0]
            x = float(linediv[1])
            indexmaxcycle += 1
            fileout.write("%s \t %3.8f 1 \n" %(symbol, x))
    else:
        print "structure not found"
        exit()
    fileout.close()
</code>```

This function is supposed to extract info from this file called file1.out:

```<code>          CURRENT BEST VALUE OF HEAT OF FORMATION =  -1161.249249
  cycles=200 pm6 opt singlet eps=80   charge=-1

  C    -3.87724655 +1   1.30585983 +1   4.53273224 +1
  H    -7.60628859 +1   0.53968618 +1   3.72680573 +1
  O    -4.76978297 +1   4.45409715 +1   1.42608903 +1
  H    -4.66890488 +1   4.47267425 +1   2.41952335 +1
  H    -5.59468165 +1   3.93399792 +1   1.27757138 +1

 **********************
 *                    *
 * JOB ENDED NORMALLY *
 *                    *
 **********************
</code>```

but it prints "structure not found"

Would you help me a bit?

答:
You are looking for an exact match, but the line in the textfile is longer than the pattern you are looking for. Try to search for the beginning of the line instead:

```<code>pattern = "          CURRENT BEST VALUE OF HEAT OF FORMATION"
try:
    indexmaxcycle = [i for (i,s) in enumerate(lines) if s.startswith(pattern)][0]
    indexmaxcycle += 5
etc.
</code>```

[i for (i,s) in enumerate(lines) if s.startswith(pattern)] gives you all indices of elements that start with your pattern. If you add the [0] you get the first one.

I just noticed you can speed this up if you use generator expressions instead of list comprehensions:

```<code>pattern = "          CURRENT BEST VALUE OF HEAT OF FORMATION"
try:
    indexmaxcycle = next((i for (i,s) in enumerate(lines) if s.startswith('foo'))) + 5
except:
    etc.
</code>```

This will only search the list until it finds the first match.

Body:
I am trying to extract some data of a file. For that purpose have made a script which reads the file and if some keyword is detected, it starts copying and then, when finds a blank line, it stops copying. I think it is not too bad, but is not working.

The python script i wrote is:

def out_to_mop (namefilein, namefileout):
    print namefilein
    filein=open(namefilein, "r")
    fileout=open(namefileout, "w")
    lines = filein.readlines()
    filein.close()

    #look for keyword "CURRENT.." to start copying
    try:
        indexmaxcycle = lines.index("          CURRENT BEST VALUE OF HEAT OF FORMATION")
        indexmaxcycle += 5
    except:
        indexmaxcycle = 0

    if indexmaxcycle != 0:
        while lines[indexmaxcycle]!=" \n":
            linediv = lines[indexmaxcycle].split()
            symbol = linediv[0]
            x = float(linediv[1])
            indexmaxcycle += 1
            fileout.write("%s \t %3.8f 1 \n" %(symbol, x))
    else:
        print "structure not found"
        exit()
    fileout.close()

This function is supposed to extract info from this file called file1.out:

          CURRENT BEST VALUE OF HEAT OF FORMATION =  -1161.249249
  cycles=200 pm6 opt singlet eps=80   charge=-1

  C    -3.87724655 +1   1.30585983 +1   4.53273224 +1
  H    -7.60628859 +1   0.53968618 +1   3.72680573 +1
  O    -4.76978297 +1   4.45409715 +1   1.42608903 +1
  H    -4.66890488 +1   4.47267425 +1   2.41952335 +1
  H    -5.59468165 +1   3.93399792 +1   1.27757138 +1

 **********************
 *                    *
 * JOB ENDED NORMALLY *
 *                    *
 **********************

but it prints "structure not found"

Would you help me a bit?

Body:
You are looking for an exact match, but the line in the textfile is longer than the pattern you are looking for. Try to search for the beginning of the line instead:

pattern = "          CURRENT BEST VALUE OF HEAT OF FORMATION"
try:
    indexmaxcycle = [i for (i,s) in enumerate(lines) if s.startswith(pattern)][0]
    indexmaxcycle += 5
etc.

[i for (i,s) in enumerate(lines) if s.startswith(pattern)] gives you all indices of elements that start with your pattern. If you add the [0] you get the first one.

I just noticed you can speed this up if you use generator expressions instead of list comprehensions:

pattern = "          CURRENT BEST VALUE OF HEAT OF FORMATION"
try:
    indexmaxcycle = next((i for (i,s) in enumerate(lines) if s.startswith('foo'))) + 5
except:
    etc.

This will only search the list until it finds the first match.


问:
FIRStorageReference observing changes Swift
Is there a way to listen for changes to FIRStorage children like there is for FIRDatabase ".childChanged?" I have profile images in my storage and whenever users change them, I want to trigger my app to reCache them with my SAMCache method.</p>

答:
There isn't a way to listen to changes to FIRStorage. Instead, you could generate the downloadUrl or a random value and then store that in the database. Then you can listen to changes to that child in the database.

Example modified from the documentation:

```<code>// Upload the file to the path "images/rivers.jpg"
let uploadTask = riversRef.putData(data, metadata: nil) { (metadata, error) in
  guard let metadata = metadata else {
    // Uh-oh, an error occurred!
    return
  }
  // Metadata contains file metadata such as size, content-type, and download URL.
  let downloadURL = metadata.downloadURL
  ref.child("/users/\(userId)/profileImage").setValue(downloadURL)
}
</code>```

And then also attach a listener to ref.child("/users/(userId)/profileImage").

Body:
There isn't a way to listen to changes to FIRStorage. Instead, you could generate the downloadUrl or a random value and then store that in the database. Then you can listen to changes to that child in the database.

Example modified from the documentation:

// Upload the file to the path "images/rivers.jpg"
let uploadTask = riversRef.putData(data, metadata: nil) { (metadata, error) in
  guard let metadata = metadata else {
    // Uh-oh, an error occurred!
    return
  }
  // Metadata contains file metadata such as size, content-type, and download URL.
  let downloadURL = metadata.downloadURL
  ref.child("/users/\(userId)/profileImage").setValue(downloadURL)
}

And then also attach a listener to ref.child("/users/(userId)/profileImage").


答: This is just what happens when Node can't parse the expression you have typed, and it's waiting for more input to see if it can complete the parse. Try any other nonsense like ((( ), etc. and you will get the same result. You can use Ctrl-C to abort the parse and get back to a working prompt.

Title: evaluating "()" in node.js causes wierd behaviour, but browser says syntax error (bug in node.js?)

Body:
When I evaluate the expression "()" in node.js (without the quotes), it corrupts the environment. The global object is trashed and nothing works. When i evaluate the same express in the browser console it reports a syntax error. From my research it appears the browser is correct. Is this a bug in the node.js expression parser? Can anyone explain what is happening under the hood?
Here is a screenshot


问:
Angular - changing ngModel value manually doesn't detect the value as valid
I'm changing the value of a select in my template:

```<code>        <select id="CollaboratorId"
                    name="CollaboratorId"
                    formControlName="CollaboratorId"
                    class="form-control col-sm-8"
                    [(ngModel)]="SelectedUser.CollaboratorId"
                    (change)="onUserChange($event.target.value)" required>
                <option [ngValue]="undefined">Select Collaborator</option>
                <option *ngFor="let collaborator of CollaboratorsList" [ngValue]="collaborator.collaboratorId">{{collaborator.collaboratorFullName}}</option>
        </select>
</code>```

From my component with its ngModel name like this:

```<code>this.SelectedUser.CollaboratorId = data.collaboratorId;
</code>```

When running my program I can see indeed the value has changed, however because the value wasn't selected on change it's not being registered as valid. I know there's no way to change a form's control to valid, so is there a method to instead trigger the (change)? Thanks in advance.

答: I think it is not working properly because you are mixing reactive and template driven forms. Try removing [(ngModel)].</p>

Body:
I'm changing the value of a select in my template:

        <select id="CollaboratorId"
                    name="CollaboratorId"
                    formControlName="CollaboratorId"
                    class="form-control col-sm-8"
                    [(ngModel)]="SelectedUser.CollaboratorId"
                    (change)="onUserChange($event.target.value)" required>
                <option [ngValue]="undefined">Select Collaborator</option>
                <option *ngFor="let collaborator of CollaboratorsList" [ngValue]="collaborator.collaboratorId">{{collaborator.collaboratorFullName}}</option>
        </select>

From my component with its ngModel name like this:

this.SelectedUser.CollaboratorId = data.collaboratorId;

When running my program I can see indeed the value has changed, however because the value wasn't selected on change it's not being registered as valid. I know there's no way to change a form's control to valid, so is there a method to instead trigger the (change)? Thanks in advance.


问:
error TS2688: Cannot find type definition file for 'bson'
I can not find the type definition file for 'bson' "with a TS2688 error: Can not find type definition file for 'bson'
enter image description here</p>

答: Have you tried npm i @types/bson --save-dev? https://www.npmjs.com/package/@types/bson</p>


问:
Best way to store and retrieve data to and from database in android
I am currently developing a a project with multiple number of tables. So I created separate classes for storage and retrieval of data of each table.

Is there any better way so that I can reduce the number of classes? I am a beginner, so I am really uncertain about this.

答:
You must look around Room Persistence Library is an ORM between Java classes and SQLite:

Room provides an abstraction layer over SQLite to allow fluent database access while harnessing the full power of SQLite.
  Documentation


问:
How can I convert a date from the format "dd/mm/yyyy" to "yyyy/dd/mm"?
I have a Textbox in which the user is supposed to enter a date in the format dd/mm/yyyy, this date is stored as yyyy/mm/dd in the database.

So I want the user to enter the date in dd/mm/yyyy format and later I want to convert to yyyy/mm/dd so that I can query database.

How can I convert the user input date dd/mm/yyyy to yyyy/mm/dd?

答:
this date is stored as yyyy/mm/dd in
  the database

I hope that this is not true. I hope that you store the date as a datetime value in the database and not as a varchar value.

If you store the date as a datetime value, there is no point in converting the date string from one format to another, you should parse the string to a DateTime value.

Use the ParseExact method to parse a string from a specific format:

```<code>DateTime date = DateTime.ParseExact(theDateTextbox.Text, "dd'/'MM'/'yyyy", CultureInfo.InvariantCulture);
</code>```

Body:
this date is stored as yyyy/mm/dd in
  the database

I hope that this is not true. I hope that you store the date as a datetime value in the database and not as a varchar value.

If you store the date as a datetime value, there is no point in converting the date string from one format to another, you should parse the string to a DateTime value.

Use the ParseExact method to parse a string from a specific format:

DateTime date = DateTime.ParseExact(theDateTextbox.Text, "dd'/'MM'/'yyyy", CultureInfo.InvariantCulture);

ContentLicense: CC BY-SA 2.5