问:
How to stream live-video display from a webcam using FFMPEG command on tcl version 8.0 and windows 7?
I am working on project were i need to have the live video streaming.
I am able to save the video using the command:

```<code>proc a {}  {
exec ffmpeg -f dshow -rtbufsize 64M -i "video=Integrated Webcam" -s 1280x720 -f sdl2 -
}
a

this is the current error:
</code>```

ffmpeg started on 2017-11-17 at 15:24:45
Report written to "ffmpeg-20171117-152445.log"
Command line:
ffmpeg -f dshow -report -rtbufsize 64M -i "video=Integrated Webcam" -s 1280x720 -f sdl2 -
ffmpeg version N-87353-g183fd30 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 7.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib
  libavutil      55. 76.100 / 55. 76.100
  libavcodec     57.106.101 / 57.106.101
  libavformat    57. 82.101 / 57. 82.101
  libavdevice    57.  8.101 / 57.  8.101
  libavfilter     6.105.100 /  6.105.100
  libswscale      4.  7.103 /  4.  7.103
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
Splitting the commandline.
Reading option '-f' ... matched as option 'f' (force format) with argument 'dshow'.
Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
Reading option '-rtbufsize' ... matched as AVOption 'rtbufsize' with argument '64M'.
Reading option '-i' ... matched as input url with argument 'video=Integrated Webcam'.
Reading option '-s' ... matched as option 's' (set frame size (WxH or abbreviation)) with argument '1280x720'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'sdl2'.
Reading option '-' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option report (generate a report) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url video=Integrated Webcam.
Applying option f (force format) with argument dshow.
Successfully parsed a group of options.
Opening an input file: video=Integrated Webcam.
[dshow @ 0000000000e06a40] Selecting pin Capture on video
dshow passing through packet of type video size   614400 timestamp 5773900280000 orig timestamp 5773900274254 graph timestamp 5773900280000 diff 5746 Integrated Webcam
[dshow @ 0000000000e06a40] All info found
Input #0, dshow, from 'video=Integrated Webcam':
  Duration: N/A, start: 577390.028000, bitrate: N/A
    Stream #0:0, 1, 1/10000000: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 640x480, 30 fps, 30 tbr, 10000k tbn, 10000k tbc
Successfully opened the file.
Parsing a group of options: output url -.
Applying option s (set frame size (WxH or abbreviation)) with argument 1280x720.
Applying option f (force format) with argument sdl2.
Successfully parsed a group of options.
Opening an output file: -.
Successfully opened the file.
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Press [q] to stop, [?] for help
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
[rawvideo @ 0000000000d90be0] PACKET SIZE: 614400, STRIDE: 1280
detected 4 logical cores
dshow passing through packet of type video size   614400 timestamp 5773900600000 orig timestamp 5773900607587 graph timestamp 5773900600000 diff -7587 Integrated Webcam
[graph 0 input from stream 0:0 @ 0000000000d96200] Setting 'video_size' to value '640x480'
[graph 0 input from stream 0:0 @ 0000000000d96200] Setting 'pix_fmt' to value '1'
[graph 0 input from stream 0:0 @ 0000000000d96200] Setting 'time_base' to value '1/10000000'
[graph 0 input from stream 0:0 @ 0000000000d96200] Setting 'pixel_aspect' to value '0/1'
[graph 0 input from stream 0:0 @ 0000000000d96200] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:0 @ 0000000000d96200] Setting 'frame_rate' to value '10000000/333333'
[graph 0 input from stream 0:0 @ 0000000000d96200] w:640 h:480 pixfmt:yuyv422 tb:1/10000000 fr:10000000/333333 sar:0/1 sws_param:flags=2
[scaler_out_0_0 @ 0000000000d967e0] Setting 'w' to value '1280'
[scaler_out_0_0 @ 0000000000d967e0] Setting 'h' to value '720'
[scaler_out_0_0 @ 0000000000d967e0] Setting 'flags' to value 'bicubic'
[scaler_out_0_0 @ 0000000000d967e0] w:1280 h:720 flags:'bicubic' interl:0
[AVFilterGraph @ 0000000000d94d40] query_formats: 4 queried, 3 merged, 0 already done, 0 delayed
[scaler_out_0_0 @ 0000000000d967e0] w:640 h:480 fmt:yuyv422 sar:0/1 -> w:1280 h:720 fmt:yuyv422 sar:0/1 flags:0x4
dshow passing through packet of type video size   614400 timestamp 5773900970000 orig timestamp 5773900940920 graph timestamp 5773900970000 diff 29080 Integrated Webcam
dshow passing through packet of type video size   614400 timestamp 5773901240000 orig timestamp 5773901274253 graph timestamp 5773901240000 diff -34253 Integrated Webcam
dshow passing through packet of type video size   614400 timestamp 5773901720000 orig timestamp 5773901607586 graph timestamp 5773901720000 diff 112414 Integrated Webcam
dshow passing through packet of type video size   614400 timestamp 5773902040000 orig timestamp 5773901940919 graph timestamp 5773902040000 diff 99081 Integrated Webcam
dshow passing through packet of type video size   614400 timestamp 5773902360000 orig timestamp 5773902274252 graph timestamp 5773902360000 diff 85748 Integrated Webcam
dshow passing through packet of type video size   614400 timestamp 5773902680000 orig timestamp 5773902607585 graph timestamp 5773902680000 diff 72415 Integrated Webcam
dshow passing through packet of type video size   614400 timestamp 5773903000000 orig timestamp 5773902940918 graph timestamp 5773903000000 diff 59082 Integrated Webcam
dshow passing through packet of type video size   614400 timestamp 5773903320000 orig timestamp 5773903274251 graph timestamp 5773903320000 diff 45749 Integrated Webcam
dshow passing through packet of type video size   614400 timestamp 5773903640000 orig timestamp 5773903607584 graph timestamp 5773903640000 diff 32416 Integrated Webcam
[sdl,sdl2 @ 0000000000d911c0] w:1280 h:720 fmt:yuyv422 -> w:1280 h:720
Output #0, sdl,sdl2, to 'pipe:':
  Metadata:
    encoder         : Lavf57.82.101
    Stream #0:0, 0, 333333/10000000: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 1280x720, q=2-31, 442368 kb/s, 30 fps, 30 tbn, 30 tbc
    Metadata:
      encoder         : Lavc57.106.101 rawvideo
dshow passing through packet of type video size   614400 timestamp 5773903970000 orig timestamp 5773903940917 graph timestamp 5773903970000 diff 29083 Integrated Webcam
dshow passing through packet of type video size   614400 timestamp 5773904280000 orig timestamp 5773904274250 graph timestamp 5773904280000 diff 5750 Integrated Webcam
av_interleaved_write_frame(): Operation not permitted
No more output streams to write to, finishing.
dshow passing through packet of type video size   614400 timestamp 5773904660000 orig timestamp 5773904607583 graph timestamp 5773904660000 diff 52417 Integrated Webcam
frame=    1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.03 bitrate=N/A speed=0.0797x
video:1800kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Input file #0 (video=Integrated Webcam):
  Input stream #0:0 (video): 1 packets read (614400 bytes); 1 frames decoded;
  Total: 1 packets (614400 bytes) demuxed
Output file #0 (pipe:):
  Output stream #0:0 (video): 1 frames encoded; 1 packets muxed (1843200 bytes);
  Total: 1 packets (1843200 bytes) muxed
1 frames successfully decoded, 0 decoding errors
dshow passing through packet of type video size        0 timestamp 5773907070000 orig timestamp 2644601806342528 graph timestamp 5773907070000 diff -2638827899272528 Integrated Webcam
Conversion failed!```
</div>
</div>
</p>

```% source c:/other/a/d.tcl
couldn't execute "ffmpeg -f dshow -t 00:00:10 -i {video=Integrated Webcam} -b 5000k -s 1280x720 c:\test\sample-a.avi": no such file or directory
% source c:/other/a/d.tcl
invalid command name "ffmpeg"
% source c:/other/a/d.tcl
ffmpeg version N-87353-g183fd30 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 7.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib
  libavutil      55. 76.100 / 55. 76.100
  libavcodec     57.106.101 / 57.106.101
  libavformat    57. 82.101 / 57. 82.101
  libavdevice    57.  8.101 / 57.  8.101
  libavfilter     6.105.100 /  6.105.100
  libswscale      4.  7.103 /  4.  7.103
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
Input #0, dshow, from 'video=Integrated Webcam':
  Duration: N/A, start: 523220.045000, bitrate: N/A
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 640x480, 30 fps, 30 tbr, 10000k tbn, 10000k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Press [q] to stop, [?] for help
Output #0, sdl,sdl2, to 'pipe:':
  Metadata:
    encoder         : Lavf57.82.101
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 1280x720, q=2-31, 442368 kb/s, 30 fps, 30 tbn, 30 tbc
    Metadata:
      encoder         : Lavc57.106.101 rawvideo
av_interleaved_write_frame(): Operation not permitted
frame=    1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.03 bitrate=N/A speed=0.0471x
video:1800kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!
%
```

<p>But, the problem is i don't want to save the video, I just want to have live video streaming. </p>

<p>link: https://trac.ffmpeg.org/wiki/StreamingGuide, provide the command for live video streaming, but it want work, the webcem gets started, but live video streaming is not displayed on screen.</p>

<p>so, can any one help me out to get right "FFMPEG" command or even any TCL script, to get the live video streaming displayed on on my windows 7. </p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>ffplay started on 2017-11-17 at 12:44:40
Report written to "ffplay-20171117-124440.log"
Command line:
ffplay -report C:/test/sample.avi
ffplay version N-87353-g183fd30 Copyright (c) 2003-2017 the FFmpeg developers
  built with gcc 7.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib
  libavutil      55. 76.100 / 55. 76.100
  libavcodec     57.106.101 / 57.106.101
  libavformat    57. 82.101 / 57. 82.101
  libavdevice    57.  8.101 / 57.  8.101
  libavfilter     6.105.100 /  6.105.100
  libswscale      4.  7.103 /  4.  7.103
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
    nan    :  0.000 fd=   0 aq=    0KB vq=    0KB sq=    0B f=0/0
[NULL @ 0000000002aea040] Opening 'C:/test/sample.avi' for reading
[file @ 0000000002ae9c80] Setting default whitelist 'file,crypto'
[avi @ 0000000002aea040] Format avi probed with size=2048 and score=100
[avi @ 0000000002af30c0] use odml:1
[avi @ 0000000002aea040] Before avformat_find_stream_info() pos: 5678 bytes read:107912 seeks:4 nb_streams:1
[avi @ 0000000002aea040] All info found
[avi @ 0000000002aea040] After avformat_find_stream_info() pos: 33035 bytes read:107912 seeks:4 frames:1
Input #0, avi, from 'C:/test/sample.avi':
  Metadata:
    encoder         : Lavf57.82.101
  Duration: 00:00:10.00, start: 0.000000, bitrate: 5072 kb/s
    Stream #0:0, 1, 1/30: Video: mpeg4 (Simple Profile) (FMP4 / 0x34504D46), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 5078 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc
detected 4 logical cores
    nan M-V:    nan fd=   0 aq=    0KB vq=  595KB sq=    0B f=0/0
Video frame changed from size:0x0 format:none serial:-1 to size:1280x720 format:yuv420p serial:1
[ffplay_buffer @ 0000000003a17ee0] Setting 'video_size' to value '1280x720'
[ffplay_buffer @ 0000000003a17ee0] Setting 'pix_fmt' to value '0'
[ffplay_buffer @ 0000000003a17ee0] Setting 'time_base' to value '1/30'
[ffplay_buffer @ 0000000003a17ee0] Setting 'pixel_aspect' to value '1/1'
[ffplay_buffer @ 0000000003a17ee0] Setting 'frame_rate' to value '30/1'
[ffplay_buffer @ 0000000003a17ee0] w:1280 h:720 pixfmt:yuv420p tb:1/30 fr:30/1 sar:1/1 sws_param:
[AVFilterGraph @ 0000000002b14fc0] query_formats: 2 queried, 1 merged, 0 already done, 0 delayed</code>```

答:
Assuming your ffmpeg is a recent build, use

```<code>ffmpeg -f dshow -rtbufsize 64M -i "video=Integrated Webcam" -s 1280x720 -f sdl2 -
</code>```

A window will pop up with the video output.

For not-so-recent builds, you may have to use sdl and not sdl2.

Get recent builds from http://ffmpeg.zeranoe.com/builds/

Body:
I am working on project were i need to have the live video streaming.
I am able to save the video using the command:

proc a {}  {
exec ffmpeg -f dshow -rtbufsize 64M -i "video=Integrated Webcam" -s 1280x720 -f sdl2 -
}
a

this is the current error:

ffmpeg started on 2017-11-17 at 15:24:45
Report written to "ffmpeg-20171117-152445.log"
Command line:
ffmpeg -f dshow -report -rtbufsize 64M -i "video=Integrated Webcam" -s 1280x720 -f sdl2 -
ffmpeg version N-87353-g183fd30 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 7.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib
  libavutil      55. 76.100 / 55. 76.100
  libavcodec     57.106.101 / 57.106.101
  libavformat    57. 82.101 / 57. 82.101
  libavdevice    57.  8.101 / 57.  8.101
  libavfilter     6.105.100 /  6.105.100
  libswscale      4.  7.103 /  4.  7.103
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
Splitting the commandline.
Reading option '-f' ... matched as option 'f' (force format) with argument 'dshow'.
Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
Reading option '-rtbufsize' ... matched as AVOption 'rtbufsize' with argument '64M'.
Reading option '-i' ... matched as input url with argument 'video=Integrated Webcam'.
Reading option '-s' ... matched as option 's' (set frame size (WxH or abbreviation)) with argument '1280x720'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'sdl2'.
Reading option '-' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option report (generate a report) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url video=Integrated Webcam.
Applying option f (force format) with argument dshow.
Successfully parsed a group of options.
Opening an input file: video=Integrated Webcam.
[dshow @ 0000000000e06a40] Selecting pin Capture on video
dshow passing through packet of type video size   614400 timestamp 5773900280000 orig timestamp 5773900274254 graph timestamp 5773900280000 diff 5746 Integrated Webcam
[dshow @ 0000000000e06a40] All info found
Input #0, dshow, from 'video=Integrated Webcam':
  Duration: N/A, start: 577390.028000, bitrate: N/A
    Stream #0:0, 1, 1/10000000: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 640x480, 30 fps, 30 tbr, 10000k tbn, 10000k tbc
Successfully opened the file.
Parsing a group of options: output url -.
Applying option s (set frame size (WxH or abbreviation)) with argument 1280x720.
Applying option f (force format) with argument sdl2.
Successfully parsed a group of options.
Opening an output file: -.
Successfully opened the file.
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Press [q] to stop, [?] for help
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
[rawvideo @ 0000000000d90be0] PACKET SIZE: 614400, STRIDE: 1280
detected 4 logical cores
dshow passing through packet of type video size   614400 timestamp 5773900600000 orig timestamp 5773900607587 graph timestamp 5773900600000 diff -7587 Integrated Webcam
[graph 0 input from stream 0:0 @ 0000000000d96200] Setting 'video_size' to value '640x480'
[graph 0 input from stream 0:0 @ 0000000000d96200] Setting 'pix_fmt' to value '1'
[graph 0 input from stream 0:0 @ 0000000000d96200] Setting 'time_base' to value '1/10000000'
[graph 0 input from stream 0:0 @ 0000000000d96200] Setting 'pixel_aspect' to value '0/1'
[graph 0 input from stream 0:0 @ 0000000000d96200] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:0 @ 0000000000d96200] Setting 'frame_rate' to value '10000000/333333'
[graph 0 input from stream 0:0 @ 0000000000d96200] w:640 h:480 pixfmt:yuyv422 tb:1/10000000 fr:10000000/333333 sar:0/1 sws_param:flags=2
[scaler_out_0_0 @ 0000000000d967e0] Setting 'w' to value '1280'
[scaler_out_0_0 @ 0000000000d967e0] Setting 'h' to value '720'
[scaler_out_0_0 @ 0000000000d967e0] Setting 'flags' to value 'bicubic'
[scaler_out_0_0 @ 0000000000d967e0] w:1280 h:720 flags:'bicubic' interl:0
[AVFilterGraph @ 0000000000d94d40] query_formats: 4 queried, 3 merged, 0 already done, 0 delayed
[scaler_out_0_0 @ 0000000000d967e0] w:640 h:480 fmt:yuyv422 sar:0/1 -> w:1280 h:720 fmt:yuyv422 sar:0/1 flags:0x4
dshow passing through packet of type video size   614400 timestamp 5773900970000 orig timestamp 5773900940920 graph timestamp 5773900970000 diff 29080 Integrated Webcam
dshow passing through packet of type video size   614400 timestamp 5773901240000 orig timestamp 5773901274253 graph timestamp 5773901240000 diff -34253 Integrated Webcam
dshow passing through packet of type video size   614400 timestamp 5773901720000 orig timestamp 5773901607586 graph timestamp 5773901720000 diff 112414 Integrated Webcam
dshow passing through packet of type video size   614400 timestamp 5773902040000 orig timestamp 5773901940919 graph timestamp 5773902040000 diff 99081 Integrated Webcam
dshow passing through packet of type video size   614400 timestamp 5773902360000 orig timestamp 5773902274252 graph timestamp 5773902360000 diff 85748 Integrated Webcam
dshow passing through packet of type video size   614400 timestamp 5773902680000 orig timestamp 5773902607585 graph timestamp 5773902680000 diff 72415 Integrated Webcam
dshow passing through packet of type video size   614400 timestamp 5773903000000 orig timestamp 5773902940918 graph timestamp 5773903000000 diff 59082 Integrated Webcam
dshow passing through packet of type video size   614400 timestamp 5773903320000 orig timestamp 5773903274251 graph timestamp 5773903320000 diff 45749 Integrated Webcam
dshow passing through packet of type video size   614400 timestamp 5773903640000 orig timestamp 5773903607584 graph timestamp 5773903640000 diff 32416 Integrated Webcam
[sdl,sdl2 @ 0000000000d911c0] w:1280 h:720 fmt:yuyv422 -> w:1280 h:720
Output #0, sdl,sdl2, to 'pipe:':
  Metadata:
    encoder         : Lavf57.82.101
    Stream #0:0, 0, 333333/10000000: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 1280x720, q=2-31, 442368 kb/s, 30 fps, 30 tbn, 30 tbc
    Metadata:
      encoder         : Lavc57.106.101 rawvideo
dshow passing through packet of type video size   614400 timestamp 5773903970000 orig timestamp 5773903940917 graph timestamp 5773903970000 diff 29083 Integrated Webcam
dshow passing through packet of type video size   614400 timestamp 5773904280000 orig timestamp 5773904274250 graph timestamp 5773904280000 diff 5750 Integrated Webcam
av_interleaved_write_frame(): Operation not permitted
No more output streams to write to, finishing.
dshow passing through packet of type video size   614400 timestamp 5773904660000 orig timestamp 5773904607583 graph timestamp 5773904660000 diff 52417 Integrated Webcam
frame=    1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.03 bitrate=N/A speed=0.0797x
video:1800kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Input file #0 (video=Integrated Webcam):
  Input stream #0:0 (video): 1 packets read (614400 bytes); 1 frames decoded;
  Total: 1 packets (614400 bytes) demuxed
Output file #0 (pipe:):
  Output stream #0:0 (video): 1 frames encoded; 1 packets muxed (1843200 bytes);
  Total: 1 packets (1843200 bytes) muxed
1 frames successfully decoded, 0 decoding errors
dshow passing through packet of type video size        0 timestamp 5773907070000 orig timestamp 2644601806342528 graph timestamp 5773907070000 diff -2638827899272528 Integrated Webcam
Conversion failed!

% source c:/other/a/d.tcl
couldn't execute "ffmpeg -f dshow -t 00:00:10 -i {video=Integrated Webcam} -b 5000k -s 1280x720 c:\test\sample-a.avi": no such file or directory
% source c:/other/a/d.tcl
invalid command name "ffmpeg"
% source c:/other/a/d.tcl
ffmpeg version N-87353-g183fd30 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 7.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib
  libavutil      55. 76.100 / 55. 76.100
  libavcodec     57.106.101 / 57.106.101
  libavformat    57. 82.101 / 57. 82.101
  libavdevice    57.  8.101 / 57.  8.101
  libavfilter     6.105.100 /  6.105.100
  libswscale      4.  7.103 /  4.  7.103
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
Input #0, dshow, from 'video=Integrated Webcam':
  Duration: N/A, start: 523220.045000, bitrate: N/A
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 640x480, 30 fps, 30 tbr, 10000k tbn, 10000k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Press [q] to stop, [?] for help
Output #0, sdl,sdl2, to 'pipe:':
  Metadata:
    encoder         : Lavf57.82.101
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 1280x720, q=2-31, 442368 kb/s, 30 fps, 30 tbn, 30 tbc
    Metadata:
      encoder         : Lavc57.106.101 rawvideo
av_interleaved_write_frame(): Operation not permitted
frame=    1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.03 bitrate=N/A speed=0.0471x
video:1800kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!
%

But, the problem is i don't want to save the video, I just want to have live video streaming.

link: https://trac.ffmpeg.org/wiki/StreamingGuide, provide the command for live video streaming, but it want work, the webcem gets started, but live video streaming is not displayed on screen.

so, can any one help me out to get right "FFMPEG" command or even any TCL script, to get the live video streaming displayed on on my windows 7.

ffplay started on 2017-11-17 at 12:44:40
Report written to "ffplay-20171117-124440.log"
Command line:
ffplay -report C:/test/sample.avi
ffplay version N-87353-g183fd30 Copyright (c) 2003-2017 the FFmpeg developers
  built with gcc 7.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib
  libavutil      55. 76.100 / 55. 76.100
  libavcodec     57.106.101 / 57.106.101
  libavformat    57. 82.101 / 57. 82.101
  libavdevice    57.  8.101 / 57.  8.101
  libavfilter     6.105.100 /  6.105.100
  libswscale      4.  7.103 /  4.  7.103
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
    nan    :  0.000 fd=   0 aq=    0KB vq=    0KB sq=    0B f=0/0
[NULL @ 0000000002aea040] Opening 'C:/test/sample.avi' for reading
[file @ 0000000002ae9c80] Setting default whitelist 'file,crypto'
[avi @ 0000000002aea040] Format avi probed with size=2048 and score=100
[avi @ 0000000002af30c0] use odml:1
[avi @ 0000000002aea040] Before avformat_find_stream_info() pos: 5678 bytes read:107912 seeks:4 nb_streams:1
[avi @ 0000000002aea040] All info found
[avi @ 0000000002aea040] After avformat_find_stream_info() pos: 33035 bytes read:107912 seeks:4 frames:1
Input #0, avi, from 'C:/test/sample.avi':
  Metadata:
    encoder         : Lavf57.82.101
  Duration: 00:00:10.00, start: 0.000000, bitrate: 5072 kb/s
    Stream #0:0, 1, 1/30: Video: mpeg4 (Simple Profile) (FMP4 / 0x34504D46), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 5078 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc
detected 4 logical cores
    nan M-V:    nan fd=   0 aq=    0KB vq=  595KB sq=    0B f=0/0
Video frame changed from size:0x0 format:none serial:-1 to size:1280x720 format:yuv420p serial:1
[ffplay_buffer @ 0000000003a17ee0] Setting 'video_size' to value '1280x720'
[ffplay_buffer @ 0000000003a17ee0] Setting 'pix_fmt' to value '0'
[ffplay_buffer @ 0000000003a17ee0] Setting 'time_base' to value '1/30'
[ffplay_buffer @ 0000000003a17ee0] Setting 'pixel_aspect' to value '1/1'
[ffplay_buffer @ 0000000003a17ee0] Setting 'frame_rate' to value '30/1'
[ffplay_buffer @ 0000000003a17ee0] w:1280 h:720 pixfmt:yuv420p tb:1/30 fr:30/1 sar:1/1 sws_param:
[AVFilterGraph @ 0000000002b14fc0] query_formats: 2 queried, 1 merged, 0 already done, 0 delayed

Body:
Assuming your ffmpeg is a recent build, use

ffmpeg -f dshow -rtbufsize 64M -i "video=Integrated Webcam" -s 1280x720 -f sdl2 -

A window will pop up with the video output.

For not-so-recent builds, you may have to use sdl and not sdl2.

Get recent builds from http://ffmpeg.zeranoe.com/builds/


来源: stackexchange

问:
Entity Framework error with two similar Model
I have two model that link two different db with the same table name.

The two db are managed by the customer and i haven't any authorization for change table name.

I need to copy one row from one db to the other. The code is ok but and i have add one model in the project and one in a dll that i reference in the project.

When i try to use the model i have this error:

C# MVC Schema specified is not valid. Errors: \r\nMultiple types with the name 'Example' exist in the EdmItemCollection in different namespaces.  Convention based mapping requires unique names

How can i solve this problem without change table name in the server?

答:
So you have two databases, but with one or more tables with the same names. Let's say both databases have a table named TableA.

You have two DbContext classes, one for each database. It's a bit more complicated if the databases are thus similar (have the same DbSets) that you want to use the same DbContext.

2 different DbContexts for 2 databases

The table with name TableA from databaseA represents something different that the table with the same name from databaseB, for instance, TableA from databaseA contains Persons and TableA from databaseB contains Addresses:

```<code>class DbContextA : DbContext
{
    public DbSet<Person> Persons {get; set;}
    ...
}
class DbContextB : DbContext
{
    public DbSet<Address> Addresses {get; set;}
    ...
}
</code>```

Via the constructor you could make sure that the DbContexts connect to the correct databases. However, without some model building, entity framework would expect table names Persons and Addresses (maybe a problem with this plural).

Therefore you'll have to tell Entity Framework that Persons should be stored in TableA, and that Addresses should also be stored in TableA.

This is done in DbContext.OnModelCreating:

```<code>protected override OnModelCreating(...)
{
    // Persons should be stored into a table with name TableA
    modelbuilder.Entity<Person>().ToTable("TableA");
    ...
}
</code>```

Similarly you connect Addresses to TableA.

1 DbContext for 2 different Databases

It could be that your two databases are different, but these differences are thus small that you could use the same DbContext class for them, only with some different parameters. Another reason could be that you don't know these parameters at design time.

This makes sense. After all, the purpose of your DbContext is to hide the database behind the DbContext. It could be a SQL database, but it could also be an Excel file, or a CSV file. And even if both databases would be SQL databases, it could be that one database has different table names than the other, or that all decimal values in one database have more precision than the decimal values in the other database.

I meet this problem when my DbContext should be able to work with a slightly different Unit-Test database, or with both Microsoft Sql and MySql.

To solve this, you create a class that contains parameters for modelBuilding. Give an object of this class to your DbContext, and let OnModelCreating use the information in this object to build the database model:

Example: my databases differ in the DateTimeType they use, and the decimal precision

```<code>class DbModelInfo
{
    public string DateTimeType {get; set;}
    public byte DecimalScale {get; set;}
    public byte DecimalPrecision {get; set;}

    public static DbModelInfo Default
    {
         get
         {
             return new DbModelInfo()
             {
                 DateTimeType = "datetime2";
                 DecimalPrecistion = 19;
                 DecimalScale = 8;
             }
         }
    }

    public static DbModelInfo UnitTesting {...}
}
</code>```

Give the object to your DbContext. OnModelCreating checks if there is an object, if not it could use the Default:

```<code>class MyDbcontext : DbContext
{
    ...
    public DbModelInfo DbModelInfo {get; set;}

    public override void OnModelCreating(...)
    {
        // if no model info set, use default
        if (this.DbModelInfo == null)
           this.DbModelInfo = DbModelInfo.Default;

        // set precision of all decimals:
        modelBuilder.Properties<decimal>()
            .Configure(decmal => decmal.HasPrecision(
                this.DbModel.DecimalPrecision,
                this.DbModel.DecimalScale));
        // set type of all DateTime:
        modelBuilder.Properties<DateTime>()
            .Configure(datTime => datTime.HasColumnType(this.DbModel.DateTimeType));
    }
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
So you have two databases, but with one or more tables with the same names. Let's say both databases have a table named TableA.

You have two DbContext classes, one for each database. It's a bit more complicated if the databases are thus similar (have the same DbSets) that you want to use the same DbContext.

2 different DbContexts for 2 databases

The table with name TableA from databaseA represents something different that the table with the same name from databaseB, for instance, TableA from databaseA contains Persons and TableA from databaseB contains Addresses:

class DbContextA : DbContext
{
    public DbSet<Person> Persons {get; set;}
    ...
}
class DbContextB : DbContext
{
    public DbSet<Address> Addresses {get; set;}
    ...
}

Via the constructor you could make sure that the DbContexts connect to the correct databases. However, without some model building, entity framework would expect table names Persons and Addresses (maybe a problem with this plural).

Therefore you'll have to tell Entity Framework that Persons should be stored in TableA, and that Addresses should also be stored in TableA.

This is done in DbContext.OnModelCreating:

protected override OnModelCreating(...)
{
    // Persons should be stored into a table with name TableA
    modelbuilder.Entity<Person>().ToTable("TableA");
    ...
}

Similarly you connect Addresses to TableA.

1 DbContext for 2 different Databases

It could be that your two databases are different, but these differences are thus small that you could use the same DbContext class for them, only with some different parameters. Another reason could be that you don't know these parameters at design time.

This makes sense. After all, the purpose of your DbContext is to hide the database behind the DbContext. It could be a SQL database, but it could also be an Excel file, or a CSV file. And even if both databases would be SQL databases, it could be that one database has different table names than the other, or that all decimal values in one database have more precision than the decimal values in the other database.

I meet this problem when my DbContext should be able to work with a slightly different Unit-Test database, or with both Microsoft Sql and MySql.

To solve this, you create a class that contains parameters for modelBuilding. Give an object of this class to your DbContext, and let OnModelCreating use the information in this object to build the database model:

Example: my databases differ in the DateTimeType they use, and the decimal precision

class DbModelInfo
{
    public string DateTimeType {get; set;}
    public byte DecimalScale {get; set;}
    public byte DecimalPrecision {get; set;}

    public static DbModelInfo Default
    {
         get
         {
             return new DbModelInfo()
             {
                 DateTimeType = "datetime2";
                 DecimalPrecistion = 19;
                 DecimalScale = 8;
             }
         }
    }

    public static DbModelInfo UnitTesting {...}
}

Give the object to your DbContext. OnModelCreating checks if there is an object, if not it could use the Default:

class MyDbcontext : DbContext
{
    ...
    public DbModelInfo DbModelInfo {get; set;}

    public override void OnModelCreating(...)
    {
        // if no model info set, use default
        if (this.DbModelInfo == null)
           this.DbModelInfo = DbModelInfo.Default;

        // set precision of all decimals:
        modelBuilder.Properties<decimal>()
            .Configure(decmal => decmal.HasPrecision(
                this.DbModel.DecimalPrecision,
                this.DbModel.DecimalScale));
        // set type of all DateTime:
        modelBuilder.Properties<DateTime>()
            .Configure(datTime => datTime.HasColumnType(this.DbModel.DateTimeType));
    }
}


问:
JHipster changes in HTML are not effective
my question is about a little problem with changes in Jhipster. I've created a project and imported it to intellij idea. After that I tried to make some changes in the "home.components.html" file. That is the file, which is shown wenn you open the app as a localhost. I tried to run the app after the changes,  but the changes aren't shown. For example i changed the h1 tag in this file, from "Welcome Java Hipster" to "ABC".

What can i do?

Thank you very much!

答:
Run yarn start in a new terminal (or cmd if you are a Windows user).

As soon as you modify one of your HTML/CSS/TypeScript file, your browser will refresh itself automatically

More info: http://www.jhipster.tech/development/


问:
Secure way to store sensitive API details of users (localStorage or database?)
I am playing around with the idea of creating a website for cryptocurrencies, where a user can sign up on my website, enter his API details for one of the exchange markets that I will support, which allows him to trade on that exchange, but using my “more user friendly” web interface.

My main goal is to create a more user friendly interface than what most exchange websites offer. I am not hooking directly into any cryptocurrencies or wallets, all I do is use the API of existing exchange markets, relay the information to my website, where I have a more user friendly interface.

Since this is a very sensitive subject in regards to security, I am trying to figure out, what the best way would be to store the API details of the users.
In general I don’t like the idea of storing the API details on my database server, nor on my server in general. The thought of having my website hacked and all the API details being exposed is terrifying. Of course each exchange website that supports APIs has their own security built in, such as API sessions with 2FA, IP restrictions, weekly generations of new API secret keys, daily trading limits via API, and not allowing withdrawals of wallets via API. But damage can still be done if those API details get stolen.

I would prefer if there would be a way where I would not need to store the API details on my server at all, but rather have the user save them locally on his PC. That way he is in charge of keeping the API details secure.

This thought brought me then to the idea of creating a desktop app using electron (https://electron.atom.io/). That way I can still create the website the way I want, but it’s wrapped into electron, so it always run locally. Before I pursue this idea, I would like to keep investigating my previous idea of a regular website, as I prefer to have my website cloud based, SaaS, to prevent piracy.

So I wonder, storing API details of a user, without saving them on the server, what other options would I have?
Cookies? Probably not secure.
What about localStorage? https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API

Are there other options or am I too paranoid about this? Is it generally accepted to store sensitive API details on a database server along with the rest of the users details?

答:
I think saving data in to users computers is wrong way, because  when you will save user's personal data in to your server, you will be able to control security of your server, when  it will be saved on user compputer the security of your server will be depended from users. Today we know many methods how to deceve users and I think, that the programmers  must take care of his users. when you will save data in server db you can switch many methods, like email verification or verification by phone you can send  message with some verification code, switch ssl service, also you can avoid on sql injection using a modern framework like Laravel or Yii 2,  in any case if you will save  user data in you server the security of your application will be depended of you.
if you will save  user data  in local computer, today hackers uses many methods to steal users cookies or methods to get a controll on pc, for example  you can read this post

https://krebsonsecurity.com/2011/09/right-to-left-override-aids-email-attacks/
today hackers using this method, creates an exe file which extension on first look is docx  or other some extension for example  pdf and so on ...

but in real it is an exe file and it is runnable, user can download it, and run... I think  you understood what can do hacker with users computers by this way, today so many viruses which even very professional users cant recognize.


问:
Using words for "like" query on each word
I've got this query which works correctly in looping through a set of words and doing a like condition on certain fields for each word, along with searching on DOB if required.

Can anyone see a way of doing this within the need for the While loop? I can't see to find a way of using STRING_SPLIT to do this which I've tried but I can't add a LIKE using this.

```<code>SET STATISTICS IO ON
SET STATISTICS TIME ON

--what will become stored proc parameters
DECLARE @searchwords NVARCHAR(max) = 'mary jo' --can accept many search words
DECLARE @LowerDate date = '01 Jan 1980' --could be NULL
DECLARE @UpperDate date = '31 Dec 1980' --could be NULL
--local variables
DECLARE @word NVARCHAR(50)
Declare @ID int

Create Table #SearchWords
(
    ID int IDENTITY(1,1),
    Word varchar(50)
)

Create Table #Results
(
    ClientID int,
    FirstName varchar(50),
    LastName varchar(50),
    VerificationCode varchar(100),
    DOB date
)

Insert into #SearchWords
(
    Word
)
SELECT
    value
FROM
    STRING_SPLIT(@searchwords, ' ')
WHERE
    RTRIM(value) <> ''

While (Select Count(*) From #SearchWords) > 0
Begin

    Select Top 1
        @ID = ID,
        @Word = Word
    From
        #SearchWords

    INSERT INTO #Results
    (
        ClientID,
        FirstName,
        LastName,
        VerificationCode,
        DOB
    )
    SELECT
        ClientID,
        FirstName,
        LastName,
        VerificationCode,
        DOB
    FROM
        Client
    WHERE
       (FirstName like '%' + @Word + '%' or
        LastName like '%' + @Word + '%' or
        VerificationCode like '%' + @Word + '%')

    Delete #SearchWords Where ID = @ID
End

IF (@LowerDate IS NOT NULL and @UpperDate IS NOT NULL)
BEGIN
    INSERT INTO #Results
    (
        ClientID,
        FirstName,
        LastName,
        VerificationCode,
        DOB
    )
    SELECT
        ClientID,
        FirstName,
        LastName,
        VerificationCode,
        DOB
    FROM
        Client
    WHERE
       (DOB >= @LowerDate and DOB <= @UpperDate)
END

select * from #Results

drop table #Results
drop table #SearchWords
</code>```

答:
Try to use the following query

```<code>SELECT
    ClientID,
    FirstName,
    LastName,
    VerificationCode,
    DOB
FROM Client c
WHERE EXISTS(
          SELECT *
          FROM #SearchWords s
          WHERE (c.FirstName LIKE CONCAT('%',s.Word,'%'))
             OR (c.LastName LIKE CONCAT('%',s.Word,'%'))
             OR (c.VerificationCode LIKE CONCAT('%',s.Word,'%'))
        )
  AND DOB BETWEEN ISNULL(@LowerDate,DOB) AND ISNULL(@UpperDate,DOB)
</code>```

A variant for a question from your comment

```<code>SELECT
    ClientID,
    FirstName,
    LastName,
    VerificationCode,
    DOB
INTO #Result
FROM Client c
WHERE EXISTS(
          SELECT *
          FROM #SearchWords s
          WHERE (c.FirstName LIKE CONCAT('%',s.Word,'%'))
             OR (c.LastName LIKE CONCAT('%',s.Word,'%'))
             OR (c.VerificationCode LIKE CONCAT('%',s.Word,'%'))
        )
  AND DOB BETWEEN ISNULL(@LowerDate,DOB) AND ISNULL(@UpperDate,DOB)

IF(EXISTS(SELECT * FROM #Result))
BEGIN
  SELECT *
  FROM #Result
END
ELSE
BEGIN
  SELECT
      ClientID,
      FirstName,
      LastName,
      VerificationCode,
      DOB
  FROM Client
  WHERE DOB BETWEEN ISNULL(@LowerDate,DOB) AND ISNULL(@UpperDate,DOB)
END

DROP TABLE #Result
</code>```

A variant without a temporary table

```<code>SELECT TOP 1 WITH TIES
  ClientID,
  FirstName,
  LastName,
  VerificationCode,
  DOB
FROM
  (
    SELECT
        1 RowPriority,
        ClientID,
        FirstName,
        LastName,
        VerificationCode,
        DOB
    FROM Client c
    WHERE EXISTS(
              SELECT *
              FROM #SearchWords s
              WHERE (c.FirstName LIKE CONCAT('%',s.Word,'%'))
                 OR (c.LastName LIKE CONCAT('%',s.Word,'%'))
                 OR (c.VerificationCode LIKE CONCAT('%',s.Word,'%'))
            )
      AND DOB BETWEEN ISNULL(@LowerDate,DOB) AND ISNULL(@UpperDate,DOB)

    UNION ALL

    SELECT
        2 RowPriority,
        ClientID,
        FirstName,
        LastName,
        VerificationCode,
        DOB
    FROM Client c
    WHERE DOB BETWEEN ISNULL(@LowerDate,DOB) AND ISNULL(@UpperDate,DOB)
  ) q
ORDER BY RowPriority
</code>```

One more variant

```<code>SELECT TOP 1 WITH TIES
  ClientID,
  FirstName,
  LastName,
  VerificationCode,
  DOB
FROM
  (
    -- the first scenario - we use only words filter without the DOB filter
    SELECT
        1 RowPriority, -- max priority
        ClientID,
        FirstName,
        LastName,
        VerificationCode,
        DOB
    FROM Client c
    WHERE EXISTS(
              SELECT *
              FROM #SearchWords s
              WHERE (c.FirstName LIKE CONCAT('%',s.Word,'%'))
                 OR (c.LastName LIKE CONCAT('%',s.Word,'%'))
                 OR (c.VerificationCode LIKE CONCAT('%',s.Word,'%'))
            )
      AND @LowerDate IS NULL

    UNION ALL

    -- the second scenario - we use words and DOB filters
    SELECT
        2 RowPriority,
        ClientID,
        FirstName,
        LastName,
        VerificationCode,
        DOB
    FROM Client c
    WHERE EXISTS(
              SELECT *
              FROM #SearchWords s
              WHERE (c.FirstName LIKE CONCAT('%',s.Word,'%'))
                 OR (c.LastName LIKE CONCAT('%',s.Word,'%'))
                 OR (c.VerificationCode LIKE CONCAT('%',s.Word,'%'))
            )
      AND DOB BETWEEN @LowerDate AND @UpperDate

    -- the third scenario - we use only DOB filter
    SELECT
        3 RowPriority, -- min priority
        ClientID,
        FirstName,
        LastName,
        VerificationCode,
        DOB
    FROM Client c
    WHERE (SELECT COUNT(*) FROM #SearchWords)=0
      AND DOB BETWEEN @LowerDate AND @UpperDate
  ) q
ORDER BY RowPriority
</code>```

A variant with an auxiliary variable

```<code>-- an auxiliary variable
DECLARE @Scenario int=CASE
        WHEN (SELECT COUNT(*) FROM #SearchWords)>0 THEN IIF(@LowerDate IS NULL,1,2)
        WHEN (SELECT COUNT(*) FROM #SearchWords)=0 AND @LowerDate IS NOT NULL THEN 3
    END

SELECT
    ClientID,
    FirstName,
    LastName,
    VerificationCode,
    DOB
FROM Client c
WHERE
    (
        (
            @Scenario IN(1,2)
            AND EXISTS(
                  SELECT *
                  FROM #SearchWords s
                  WHERE (c.FirstName LIKE CONCAT('%',s.Word,'%'))
                     OR (c.LastName LIKE CONCAT('%',s.Word,'%'))
                     OR (c.VerificationCode LIKE CONCAT('%',s.Word,'%'))
                )
        )
        OR
        @Scenario=3 -- this scenario doesn't use word filter
    )
  AND
    (
        (@Scenario IN(2,3) AND DOB BETWEEN @LowerDate AND @UpperDate)
        OR
        @Scenario=1 -- this scenario doesn't use DOB filter
    )
</code>```

Body:
I've got this query which works correctly in looping through a set of words and doing a like condition on certain fields for each word, along with searching on DOB if required.

Can anyone see a way of doing this within the need for the While loop? I can't see to find a way of using STRING_SPLIT to do this which I've tried but I can't add a LIKE using this.

SET STATISTICS IO ON
SET STATISTICS TIME ON

--what will become stored proc parameters
DECLARE @searchwords NVARCHAR(max) = 'mary jo' --can accept many search words
DECLARE @LowerDate date = '01 Jan 1980' --could be NULL
DECLARE @UpperDate date = '31 Dec 1980' --could be NULL
--local variables
DECLARE @word NVARCHAR(50)
Declare @ID int

Create Table #SearchWords
(
    ID int IDENTITY(1,1),
    Word varchar(50)
)

Create Table #Results
(
    ClientID int,
    FirstName varchar(50),
    LastName varchar(50),
    VerificationCode varchar(100),
    DOB date
)

Insert into #SearchWords
(
    Word
)
SELECT
    value
FROM
    STRING_SPLIT(@searchwords, ' ')
WHERE
    RTRIM(value) <> ''

While (Select Count(*) From #SearchWords) > 0
Begin

    Select Top 1
        @ID = ID,
        @Word = Word
    From
        #SearchWords

    INSERT INTO #Results
    (
        ClientID,
        FirstName,
        LastName,
        VerificationCode,
        DOB
    )
    SELECT
        ClientID,
        FirstName,
        LastName,
        VerificationCode,
        DOB
    FROM
        Client
    WHERE
       (FirstName like '%' + @Word + '%' or
        LastName like '%' + @Word + '%' or
        VerificationCode like '%' + @Word + '%')

    Delete #SearchWords Where ID = @ID
End

IF (@LowerDate IS NOT NULL and @UpperDate IS NOT NULL)
BEGIN
    INSERT INTO #Results
    (
        ClientID,
        FirstName,
        LastName,
        VerificationCode,
        DOB
    )
    SELECT
        ClientID,
        FirstName,
        LastName,
        VerificationCode,
        DOB
    FROM
        Client
    WHERE
       (DOB >= @LowerDate and DOB <= @UpperDate)
END

select * from #Results

drop table #Results
drop table #SearchWords

Body:
Try to use the following query

SELECT
    ClientID,
    FirstName,
    LastName,
    VerificationCode,
    DOB
FROM Client c
WHERE EXISTS(
          SELECT *
          FROM #SearchWords s
          WHERE (c.FirstName LIKE CONCAT('%',s.Word,'%'))
             OR (c.LastName LIKE CONCAT('%',s.Word,'%'))
             OR (c.VerificationCode LIKE CONCAT('%',s.Word,'%'))
        )
  AND DOB BETWEEN ISNULL(@LowerDate,DOB) AND ISNULL(@UpperDate,DOB)

A variant for a question from your comment

SELECT
    ClientID,
    FirstName,
    LastName,
    VerificationCode,
    DOB
INTO #Result
FROM Client c
WHERE EXISTS(
          SELECT *
          FROM #SearchWords s
          WHERE (c.FirstName LIKE CONCAT('%',s.Word,'%'))
             OR (c.LastName LIKE CONCAT('%',s.Word,'%'))
             OR (c.VerificationCode LIKE CONCAT('%',s.Word,'%'))
        )
  AND DOB BETWEEN ISNULL(@LowerDate,DOB) AND ISNULL(@UpperDate,DOB)

IF(EXISTS(SELECT * FROM #Result))
BEGIN
  SELECT *
  FROM #Result
END
ELSE
BEGIN
  SELECT
      ClientID,
      FirstName,
      LastName,
      VerificationCode,
      DOB
  FROM Client
  WHERE DOB BETWEEN ISNULL(@LowerDate,DOB) AND ISNULL(@UpperDate,DOB)
END

DROP TABLE #Result

A variant without a temporary table

SELECT TOP 1 WITH TIES
  ClientID,
  FirstName,
  LastName,
  VerificationCode,
  DOB
FROM
  (
    SELECT
        1 RowPriority,
        ClientID,
        FirstName,
        LastName,
        VerificationCode,
        DOB
    FROM Client c
    WHERE EXISTS(
              SELECT *
              FROM #SearchWords s
              WHERE (c.FirstName LIKE CONCAT('%',s.Word,'%'))
                 OR (c.LastName LIKE CONCAT('%',s.Word,'%'))
                 OR (c.VerificationCode LIKE CONCAT('%',s.Word,'%'))
            )
      AND DOB BETWEEN ISNULL(@LowerDate,DOB) AND ISNULL(@UpperDate,DOB)

    UNION ALL

    SELECT
        2 RowPriority,
        ClientID,
        FirstName,
        LastName,
        VerificationCode,
        DOB
    FROM Client c
    WHERE DOB BETWEEN ISNULL(@LowerDate,DOB) AND ISNULL(@UpperDate,DOB)
  ) q
ORDER BY RowPriority

One more variant

SELECT TOP 1 WITH TIES
  ClientID,
  FirstName,
  LastName,
  VerificationCode,
  DOB
FROM
  (
    -- the first scenario - we use only words filter without the DOB filter
    SELECT
        1 RowPriority, -- max priority
        ClientID,
        FirstName,
        LastName,
        VerificationCode,
        DOB
    FROM Client c
    WHERE EXISTS(
              SELECT *
              FROM #SearchWords s
              WHERE (c.FirstName LIKE CONCAT('%',s.Word,'%'))
                 OR (c.LastName LIKE CONCAT('%',s.Word,'%'))
                 OR (c.VerificationCode LIKE CONCAT('%',s.Word,'%'))
            )
      AND @LowerDate IS NULL

    UNION ALL

    -- the second scenario - we use words and DOB filters
    SELECT
        2 RowPriority,
        ClientID,
        FirstName,
        LastName,
        VerificationCode,
        DOB
    FROM Client c
    WHERE EXISTS(
              SELECT *
              FROM #SearchWords s
              WHERE (c.FirstName LIKE CONCAT('%',s.Word,'%'))
                 OR (c.LastName LIKE CONCAT('%',s.Word,'%'))
                 OR (c.VerificationCode LIKE CONCAT('%',s.Word,'%'))
            )
      AND DOB BETWEEN @LowerDate AND @UpperDate

    -- the third scenario - we use only DOB filter
    SELECT
        3 RowPriority, -- min priority
        ClientID,
        FirstName,
        LastName,
        VerificationCode,
        DOB
    FROM Client c
    WHERE (SELECT COUNT(*) FROM #SearchWords)=0
      AND DOB BETWEEN @LowerDate AND @UpperDate
  ) q
ORDER BY RowPriority

A variant with an auxiliary variable

-- an auxiliary variable
DECLARE @Scenario int=CASE
        WHEN (SELECT COUNT(*) FROM #SearchWords)>0 THEN IIF(@LowerDate IS NULL,1,2)
        WHEN (SELECT COUNT(*) FROM #SearchWords)=0 AND @LowerDate IS NOT NULL THEN 3
    END

SELECT
    ClientID,
    FirstName,
    LastName,
    VerificationCode,
    DOB
FROM Client c
WHERE
    (
        (
            @Scenario IN(1,2)
            AND EXISTS(
                  SELECT *
                  FROM #SearchWords s
                  WHERE (c.FirstName LIKE CONCAT('%',s.Word,'%'))
                     OR (c.LastName LIKE CONCAT('%',s.Word,'%'))
                     OR (c.VerificationCode LIKE CONCAT('%',s.Word,'%'))
                )
        )
        OR
        @Scenario=3 -- this scenario doesn't use word filter
    )
  AND
    (
        (@Scenario IN(2,3) AND DOB BETWEEN @LowerDate AND @UpperDate)
        OR
        @Scenario=1 -- this scenario doesn't use DOB filter
    )


问:
How to find the total number of pages in pdf file loaded in objective c?
Is there any way to determine the total number of pages once the pdf file is loaded in the ipad? I am using CATiledLayer Method for loading the pdf file.

Thanking you.

答:
Okay Thanks Altealice.I implemented in this manner and i am able to find the number of pages.

Using the following code:

```<code>NSString *pathToPdfDoc = [[NSBundle mainBundle] pathForResource:@"mypdf" ofType:@"pdf"];
NSURL *pdfUrl = [NSURL fileURLWithPath:pathToPdfDoc];
CGPDFDocumentRef document = CGPDFDocumentCreateWithURL((CFURLRef)pdfUrl);
size_t pageCount = CGPDFDocumentGetNumberOfPages(document);
</code>```

ContentLicense: CC BY-SA 2.5

Body:
Okay Thanks Altealice.I implemented in this manner and i am able to find the number of pages.

Using the following code:

NSString *pathToPdfDoc = [[NSBundle mainBundle] pathForResource:@"mypdf" ofType:@"pdf"];
NSURL *pdfUrl = [NSURL fileURLWithPath:pathToPdfDoc];
CGPDFDocumentRef document = CGPDFDocumentCreateWithURL((CFURLRef)pdfUrl);
size_t pageCount = CGPDFDocumentGetNumberOfPages(document);


问:
Customer filter pipe - Angular2
In the below component view,

```<code><h2>Topic listing</h2>

<form id="filter">
  <label>Filter topics by name:</label>
  <input type="text" [(ngModel)]="term">
</form>

<ul id="topic-listing">
  <li *ngFor="let topic of topics | filter: term">
    <div class="single-topic">
      <!-- Topic name -->
      <span [ngStyle]="{background: 'yellow'}">name - {{topic.name}}</span>
      <!-- Topic type -->
      <h3>{{topic.type}}</h3>
    </div>
  </li>
</ul>
</code>```

Custom filter syntax is: let topic of topics | filter: term

where custom filter is:

```<code>import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'filter'
})

export class FilterPipe implements PipeTransform {

  transform(topics: any, term: any): any {
    // check if search term is undefined
    if(term === undefined) return topics;
    return topics.filter(function(topic){ // javascript filter(function)
      // if below is false, then topic will be removed from topics array
      return topic.name.toLowerCase().includes(term.toLowerCase());
    })
  }

}
</code>```

the component class maintains data for topics:

```<code>export class DirectoryComponent implements OnInit {
  topics = [
    {type:"Fiction", name:"Avatar"},
    {type:"NonFiction", name:"Titanic"},
    {type:"Tragedy", name:"MotherIndia"},
  ];
  constructor() { }

  ngOnInit() {
  }

}
</code>```

Edit: Without form tag, code works fine.

```<code>  <label>Filter topics by name:</label>
  <input type="text" [(ngModel)]="term">
</code>```

Why custom filter FilterPipe does not filter term provided in input element?

答:
Add brackets to your filter condition

```<code><ul id="topic-listing">
  <li *ngFor="let topic of (topics | filter: term)">
    <div class="single-topic">
      <!-- Topic name -->
      <span [ngStyle]="{background: 'yellow'}">name - {{topic.name}}</span>
      <!-- Topic type -->
      <h3>{{topic.type}}</h3>
    </div>
  </li>
</ul>
</code>```

Check the TS file

```<code>import { Component } from '@angular/core';

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.css' ]
})
export class AppComponent  {
  name = 'Angular 5';
  term : any = "avatar";
  topics = [
    {type:"Fiction", name:"Avatar"},
    {type:"NonFiction", name:"Titanic"},
    {type:"Tragedy", name:"MotherIndia"},
  ];
}
</code>```

Remove the word function and change it to below code. refer the working version here

```<code>return topics.filter((topic)=>{
      return topic.name.toLowerCase().includes(term.toLowerCase());
    })
</code>```

update - root cause of the issue

if you want to use NgModel inside the form tags, either the name attribute must be set or the form control must be defined as 'standalone' in ngModelOptions

Title: Customer filter pipe - Angular2

Body:
In the below component view,

Topic listing

<form id="filter">
  Filter topics by name:
  <input type="text" [(ngModel)]="term">
</form>

      name - {{topic.name}}

{{topic.type}}

Custom filter syntax is: let topic of topics | filter: term

where custom filter is:

import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'filter'
})

export class FilterPipe implements PipeTransform {

  transform(topics: any, term: any): any {
    // check if search term is undefined
    if(term === undefined) return topics;
    return topics.filter(function(topic){ // javascript filter(function)
      // if below is false, then topic will be removed from topics array
      return topic.name.toLowerCase().includes(term.toLowerCase());
    })
  }

}

the component class maintains data for topics:

export class DirectoryComponent implements OnInit {
  topics = [
    {type:"Fiction", name:"Avatar"},
    {type:"NonFiction", name:"Titanic"},
    {type:"Tragedy", name:"MotherIndia"},
  ];
  constructor() { }

  ngOnInit() {
  }

}

Edit: Without form tag, code works fine.

  Filter topics by name:
  <input type="text" [(ngModel)]="term">

Why custom filter FilterPipe does not filter term provided in input element?

Body:
Add brackets to your filter condition

<ul id="topic-listing">
  <li *ngFor="let topic of (topics | filter: term)">
    <div class="single-topic">
      <!-- Topic name -->
      <span [ngStyle]="{background: 'yellow'}">name - {{topic.name}}</span>
      <!-- Topic type -->
      <h3>{{topic.type}}</h3>
    </div>
  </li>
</ul>

Check the TS file

import { Component } from '@angular/core';

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.css' ]
})
export class AppComponent  {
  name = 'Angular 5';
  term : any = "avatar";
  topics = [
    {type:"Fiction", name:"Avatar"},
    {type:"NonFiction", name:"Titanic"},
    {type:"Tragedy", name:"MotherIndia"},
  ];
}

Remove the word function and change it to below code. refer the working version here

return topics.filter((topic)=>{
      return topic.name.toLowerCase().includes(term.toLowerCase());
    })

update - root cause of the issue

if you want to use NgModel inside the form tags, either the name attribute must be set or the form control must be defined as 'standalone' in ngModelOptions


问:
Magic First and Last Indicator in a Loop in Ruby/Rails?
Ruby/Rails does lots of cool stuff when it comes to sugar for basic things, and I think there's a very common scenario that I was wondering if anyone has done a helper or something similar for.

```<code>   a = Array.new(5, 1)

   a.each_with_index do |x, i|
     if i == 0
       print x+1
     elsif i == (a.length - 1)
       print x*10
     else
        print x
     end
   end
</code>```

Pardon the ugliness, but this gets at what one might want... is there a ruby way to do something to the first and last of a loop?

[EDIT] I think ideally this would be an extension on Array with parameters (array instance, all elements function,  first elements function,  last elements function)... but I'm open to other thoughts.

答:
I see a lot of hacks here that are pretty close, but all heavily dependent on the given iterator having a fixed size and NOT being an iterator.  I'd like to also propose saving the previous element as you iterate through to know the first/last element that was iterated over. </p>

```<code>previous = {}
elements.each do |element|
  unless previous.has_key?(:element)
    # will only execute the first time
  end

  # normal each block here

  previous[:element] = element
end

# the last element will be stored in previous[:element]
</code>```

Body:
Ruby/Rails does lots of cool stuff when it comes to sugar for basic things, and I think there's a very common scenario that I was wondering if anyone has done a helper or something similar for.

   a = Array.new(5, 1)

   a.each_with_index do |x, i|
     if i == 0
       print x+1
     elsif i == (a.length - 1)
       print x*10
     else
        print x
     end
   end

Pardon the ugliness, but this gets at what one might want... is there a ruby way to do something to the first and last of a loop?

[EDIT] I think ideally this would be an extension on Array with parameters (array instance, all elements function,  first elements function,  last elements function)... but I'm open to other thoughts.

Body:
I see a lot of hacks here that are pretty close, but all heavily dependent on the given iterator having a fixed size and NOT being an iterator.  I'd like to also propose saving the previous element as you iterate through to know the first/last element that was iterated over.

previous = {}
elements.each do |element|
  unless previous.has_key?(:element)
    # will only execute the first time
  end

  # normal each block here

  previous[:element] = element
end

# the last element will be stored in previous[:element]


问:
How do i execute alert() in parent component after onClick in child component
In here, i'm passing data from child to parent and i am able to pass it through but i want alert function to execute only after onClick event is triggered in the child component but it is executing everytime onSubmit event is fired, it looks like there is a requirement of some life cycle method in order to make it work but i'm not getting it. Can someone help me with this please

Parent

```<code>onList(list) {
  alert(list);
 }

  render() {
    return (
      <div>
       <form>
        <input type='textarea'
               onKeyPress={this.handleSubmit}
        />
        <Child {...this.state} sendList={this.onList}/>
       </form>
      </div>
    )
  }
</code>```

Child

```<code>    {
      this.props.listArr.map((list,index) => {
         return(
           <div key={index}>
            <li>{list}
              <div>
               <button className="btn btn-primary btn-xs glyphicon glyphicon-pencil" onClick={this.props.sendList(list)} />
              </div>
            </li>
           </div>
         )})
     }
</code>```

答:
change to:
<Child {...this.state} sendList={(...args) => this.onList(...args)} />, to preserve the function context.

then, in Child just call that method as this.props.sendList()

Body:
In here, i'm passing data from child to parent and i am able to pass it through but i want alert function to execute only after onClick event is triggered in the child component but it is executing everytime onSubmit event is fired, it looks like there is a requirement of some life cycle method in order to make it work but i'm not getting it. Can someone help me with this please

Parent

onList(list) {
  alert(list);
 }

  render() {
    return (

       <form>
        <input type='textarea'
               onKeyPress={this.handleSubmit}
        />
        <Child {...this.state} sendList={this.onList}/>
       </form>

    )
  }

Child

    {
      this.props.listArr.map((list,index) => {
         return(

{list}

               <button className="btn btn-primary btn-xs glyphicon glyphicon-pencil" onClick={this.props.sendList(list)} />

         )})
     }


问:
Top tips for secure web applications
I am looking for easy steps that are simple and effective in making a web application more secure.

What are your top tips for secure web applications, and what kind of attack will they stop?

答:
Microsoft Technet has en excellent article:

Ten Tips for Designing, Building, and Deploying More Secure Web Applications

Here are the topics for the tips answered in that article:

Never Directly Trust User Input

Services Should Have Neither System nor Administrator Access

Follow SQL Server Best Practices

Protect the Assets

Include Auditing, Logging, and Reporting Features

Analyze the Source Code

Deploy Components Using Defense in Depth

Turn Off In-Depth Error Messages for End Users

Know the 10 Laws of Security Administration

Have a Security Incident Response Plan

OwnerDisplayName: Oded

Title: Top tips for secure web applications

OwnerDisplayName: Espo

LastEditorDisplayName: Espo


问:
Check for value definedness in C++
I'm working in C++ and I need to know if a scalar value (for instance a double) is "defined" or not. I also need to be able to "undef" it if needed:

```<code>class Foo {
public:
    double get_bar();

private:
    double bar;
    void calculate_bar() {
        bar = something();
    }
};

double Foo::get_bar() {
    if ( undefined(bar) )
        calculate_bar();
    return bar;
}
</code>```

Is it possible in C++?

Thanks

答: C++ does not have an "undefined" state for primitive types.  The closest available for float/double would be NAN, but that really has a different meaning.</p>

OwnerDisplayName: Tunnuz

Title: Check for value definedness in C++

Body:
I'm working in C++ and I need to know if a scalar value (for instance a double) is "defined" or not. I also need to be able to "undef" it if needed:

class Foo {
public:
    double get_bar();

private:
    double bar;
    void calculate_bar() {
        bar = something();
    }
};

double Foo::get_bar() {
    if ( undefined(bar) )
        calculate_bar();
    return bar;
}

Is it possible in C++?

Thanks

OwnerDisplayName: Darron


问:
Xcode 9 App installation failed, Could not write to the device
I've just updated to Xcode 9 and am getting App installation failed Could not write to the device error popup every other time. I see there are older questions on the subject, but this one is particular to iOS 11 and Xcode 9. I've never had the issue before.

How do I make sure Xcode 9 can install app to device every time?

答: In my case the problem appears while I use manual signing and try to debug the app in Release mode. Although the fastlane builds and uploads fine in this mode fine, direct XCode debugging fails with the error "Could not write to the device". Temp switching to automatic signing mode fixed this issue.

ContentLicense: CC BY-SA 4.0


问:
C++ 64-bit Excel add-in (XLL) is not loading correctly in 64-bit Excel
I have a piece of C++ code, which creates a XLL (Excel add-in). It can be successfully loaded by Excel, and works perfectly.

Then, I switched to 64-bit Excel, and the code stopped working. So I have recompiled the code in Visual Studio using x64 platform settings. The compilation went error free.

Now when I try to load it in 64-bit Excel, Excel does not recognize the file extension:

It complains showing "The file format and extension of 'MyAddin.xll' don't match.", and gives me the follwoing options to continue: yes, no, or cancel.

If I ignore the message and press yes, then the add-in crashes, and I get the error:

This program cannot be run in DOS mode.

Since the add-in compiles correctly, I am not sure how to troubleshoot this error. My question is: Can anyone please give me any pointers as to how to overcome the problem?

My requirements are:

64-bit Excel must recognize my XLL as valid add-in (the first error message has to go away)

What means the second error?

答: You use the 32 bit version of Excel to open the 64 bit plug-in, and you will report errors that can only be opened under DOS. You need to install a 64 bit (normally unable to install 32 bit and 64 bit) office to open the 64 bit plug-in!</p>


问:
Choco Solver math expression generation
I want to use Choco solver to write a Java program that generates math problems that satisfy a number of constraints.
The problems have to take the following form:

```<code>x @ y ∆ z = r
</code>```

Where:

x, y & z are positive integers, not necessarily different from one another, with one of them being 2 digits long and the other two 1 digit long

@ & ∆ are operators +, - or * (note that both can also stand for the same operator)

r is a positive 1-digit integer

I want to generate these math problems "on demand" (as in, one at the time) and they need to be randomised (i.e. there no should be no pattern or fixed order across the generated problems).

It has been well over 10 years since I have done constraint (satisfaction) programming, but I believe C(S)P (preferably by means of Choco), is a suitable tool to apply here.
Is this correct and can someone help me get started?

答:
Everything is in the documentation and official tutorials (http://choco-tuto.readthedocs.io/en/latest/). If you feel this is too complex, look at this ultra simple example (https://www.cosling.com/choco-solver/hello-world). It shows how to make  a+b<8, from that you can do:
x@y=A
A delta z =r
(through arithm and/or times constraint)</p>

Title: Choco Solver math expression generation

Body:
I want to use Choco solver to write a Java program that generates math problems that satisfy a number of constraints.
The problems have to take the following form:

x @ y ∆ z = r

Where:

x, y & z are positive integers, not necessarily different from one another, with one of them being 2 digits long and the other two 1 digit long

@ & ∆ are operators +, - or * (note that both can also stand for the same operator)

r is a positive 1-digit integer

I want to generate these math problems "on demand" (as in, one at the time) and they need to be randomised (i.e. there no should be no pattern or fixed order across the generated problems).

It has been well over 10 years since I have done constraint (satisfaction) programming, but I believe C(S)P (preferably by means of Choco), is a suitable tool to apply here.
Is this correct and can someone help me get started?


问:
is it a proper way to do php update?
here with the updated core. Is it a proper way to do it?
I try to do Prepared Statements by following the tutorial from the web, but not working well.

```<code>$Enrolsql = "Select * FROM Enrol WHERE ActivityID=$activityid AND UserPhone=$userPhone AND UseUp=1";

$Enrolresult = $conn->query($Enrolsql);
if ($Enrolresult->num_rows > 0) {

    $ssql = "UPDATE Enrol SET UseUp=0 WHERE ActivityID=$activityid";
    if (mysqli_query($conn, $ssql)) {
        echo "+1+"; //successfully Used.
    } else {
        echo "+2+"; // System Error.
    }
} else {
    echo "+0+"; // Coupon is not Vaild
}

$conn->close();
</code>```

Database Table info:

答:
You can do multiple checks here:

Check if any errors:

```<code>if (!mysql_error()) print 'Query executed successfully.';
</code>```

Check affected rows:

```<code>if(mysql_affected_rows() || mysql_affected_rows() == 0){
    // no error
} else {
    // error
}
</code>```

Title: is it a proper way to do php update?

Body:
here with the updated core. Is it a proper way to do it?
I try to do Prepared Statements by following the tutorial from the web, but not working well.

$Enrolsql = "Select * FROM Enrol WHERE ActivityID=$activityid AND UserPhone=$userPhone AND UseUp=1";

$Enrolresult = $conn->query($Enrolsql);
if ($Enrolresult->num_rows > 0) {

    $ssql = "UPDATE Enrol SET UseUp=0 WHERE ActivityID=$activityid";
    if (mysqli_query($conn, $ssql)) {
        echo "+1+"; //successfully Used.
    } else {
        echo "+2+"; // System Error.
    }
} else {
    echo "+0+"; // Coupon is not Vaild
}

$conn->close();

Database Table info:

Body:
You can do multiple checks here:

Check if any errors:

if (!mysql_error()) print 'Query executed successfully.';

Check affected rows:

if(mysql_affected_rows() || mysql_affected_rows() == 0){
    // no error
} else {
    // error
}


问:
How to Set Timer for check Internet Connection on a WebKitView in ios
I am using RechabilitySwift(https://github.com/ashleymills/Reachability.swift) library.I am prompting user with a message using UIAlertController,if Internet connection is not available.How can I set timer for network connection retry on the webview.</p>

答:
maybe you should use notification or observer instead,

for notification you can try this code

```<code>NotificationCenter.default.addObserver(self, selector:Selector(("checkForReachability:")), name:
NSNotification.Name.reachabilityChanged, object: nil)
let reachability: Reachability = Reachability.forInternetConnection()
reachability.startNotifier()
</code>```

Body:
maybe you should use notification or observer instead,

for notification you can try this code

NotificationCenter.default.addObserver(self, selector:Selector(("checkForReachability:")), name:
NSNotification.Name.reachabilityChanged, object: nil)
let reachability: Reachability = Reachability.forInternetConnection()
reachability.startNotifier()


问:
Modifying Insert statements before PutHiveStreaming
My CSV file contains a column with DATE TIME format like 12-10-2017 11:30

Now using puthivestreaming i can insert those records easily but my requirement is to remove just the TIME from this & keep only 12-10-2017

I can acheive this using Hive command line with substr() method while inserting, Not sure if Nifi supports it

I also thought about ReplaceText but since i have multiple DateTIMe like columns on single row, i cannot do this.

How can i achieve this?.

答:
you can easily get your required column by using getDelimitedField.

https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#getdelimitedfield

Input-->1,12-10-2017 11:30,23

in replaceText,just give ${Input:getDelimitedField(2):substringBefore(' ')}

It yields flow file content with 12-10-2017.

Hope this helpful for you.


问:
XAML Code Behind file and MVC
Does the code behind file have the same purpose as a Control class of MVC or the Boundary-Control-Entity Pattern?

I did some small projects with Silverlight and WPF, and most of the time I pretty much put the logic in the code behind file. Though with references to other classes. Not everything in the code behind.

What was/is the initial purpose of the code behind file and how do most of you use it?

Thanks,

Grant

答:
Originally, the code-behind file, in conjunction with data converters in WPF, served the same purpose as the code-behind in VB6, C#, VB.NET, what have you. It is primarily a place to put code that responds to UI events. However, in the case of WPF and Silverlight, coding in the code-behind file is potentially very messy and can easily lead to maintenance problems later on, if there is anything more than the simplest program to be implemented.

"Model-View-ViewModel" (MVVM) was conceived, I think, late in the development of WPF; Silverlight was conceived later than MVVM. Near as I can tell. Not every consultant I've heard talking about WPF or Silverlight is convinced that MVVM is "the preferred" design pattern, but it is a solid abstraction model.

WPF isn't as well tooled as WinForms, even today. This is part of what makes it potentially very messy with the potential maintenance problems. MVVM, as a design pattern, makes up for a lot of the drawbacks stemming from the immaturity of XAML and WPF/Silverlight as a user interface model, while bringing forward most of the tremendous advantages offered by XAML and WPF.

Summaries of MVVM are available here, here, and here. Josh Smith is a leading authority on the pattern, he sells a book called "Advanced MVVM" which I'm told is useful; I was able to implement some complex implementations without it, though.

Title: XAML Code Behind file and MVC


问:
Using python with regex to match and mail
I am trying to write a script that reads a log file that matches all items that have specific strings, i.e., today's date, a constant word, and the first number after the word. I am fairly new to Python, and have several issues;

How to match different groups using regular expressions without having one variable for each regex match
(var1 = date + word + 7-something, var2 = date + word + 9-something, and so on)

How to print the matches by group suffixed by another word, such as:

Group 1

Geneva:

2017-11-14: Word: 7712742 (1346134)

Group 2

Helsinki:

2017-11-02: Word: 9124741 (912478)

I would then like to write all of these matches and their suffixes to an e-mail.
The current way I have tried to tackle this is:

```<code>import time
import re
import glob

logpath = glob.glob('C:\\path\\to\\file*.log')[0]
readfile = open(logpath, "r")
daysdate = time.strftime("%Y-%m-%d")
regex = re.compile(daysdate + ".*[Word:] \d.+")
for line in readfile:
    req_id = regex.findall(line)
    for word in req_id:
        #this print shows all regex matches from the log file
        print(req_id,)
...
    mail.Body += "%s\n" % word
    mail.Send()
</code>```

Now, this prints out all matches for today's date and sends a mail to the desired user(s), but I am yet to find a way to do it as described above, short of creating and writing to several files, which then are read from. This feels like a very non-Pythonic way (and just bad practice for scripting overall).

Would one want go about this using several loops, such as for each match where the date is date + word + 7-something, print("Geneva:\n", req_id7), or are there other, better ways to solve this? The output of such an example gives:

```<code>Geneva: ['2017-11-15 04.03.18: Word: 78271187 (783342)']
Geneva: ['2017-11-15 04.03.19: Word: 75612345 (755491)']
Geneva: ['2017-11-15 04.03.22: Word: 70145678 (798640)']
</code>```

Where I would like the output to be:

```<code>Geneva:
['2017-11-15 04.03.18: Word: 78271187 (783342)']
['2017-11-15 04.03.19: Word: 75612345 (755491)']
['2017-11-15 04.03.22: Word: 70145678 (798640)']
</code>```

答:
I might be wrong but this could be one way to hack the problem:

```<code>import datetime
date = datetime.datetime.now().strftime('%Y-%m-%d')

regex = re.compile(date + r': Word: (7*.|9.*)')
</code>```

and then run the normal find command.

Body:
I am trying to write a script that reads a log file that matches all items that have specific strings, i.e., today's date, a constant word, and the first number after the word. I am fairly new to Python, and have several issues;

How to match different groups using regular expressions without having one variable for each regex match
(var1 = date + word + 7-something, var2 = date + word + 9-something, and so on)

How to print the matches by group suffixed by another word, such as:

Group 1

Geneva:

2017-11-14: Word: 7712742 (1346134)

Group 2

Helsinki:

2017-11-02: Word: 9124741 (912478)

I would then like to write all of these matches and their suffixes to an e-mail.
The current way I have tried to tackle this is:

import time
import re
import glob

logpath = glob.glob('C:\\path\\to\\file*.log')[0]
readfile = open(logpath, "r")
daysdate = time.strftime("%Y-%m-%d")
regex = re.compile(daysdate + ".*[Word:] \d.+")
for line in readfile:
    req_id = regex.findall(line)
    for word in req_id:
        #this print shows all regex matches from the log file
        print(req_id,)
...
    mail.Body += "%s\n" % word
    mail.Send()

Now, this prints out all matches for today's date and sends a mail to the desired user(s), but I am yet to find a way to do it as described above, short of creating and writing to several files, which then are read from. This feels like a very non-Pythonic way (and just bad practice for scripting overall).

Would one want go about this using several loops, such as for each match where the date is date + word + 7-something, print("Geneva:\n", req_id7), or are there other, better ways to solve this? The output of such an example gives:

Geneva: ['2017-11-15 04.03.18: Word: 78271187 (783342)']
Geneva: ['2017-11-15 04.03.19: Word: 75612345 (755491)']
Geneva: ['2017-11-15 04.03.22: Word: 70145678 (798640)']

Where I would like the output to be:

Geneva:
['2017-11-15 04.03.18: Word: 78271187 (783342)']
['2017-11-15 04.03.19: Word: 75612345 (755491)']
['2017-11-15 04.03.22: Word: 70145678 (798640)']

Body:
I might be wrong but this could be one way to hack the problem:

import datetime
date = datetime.datetime.now().strftime('%Y-%m-%d')

regex = re.compile(date + r': Word: (7*.|9.*)')

and then run the normal find command.


问:
Add string resources instead of static data
I am trying to add some string resources to replace Content string but i cannot seem to access them because its a static class. How do i add items to DummyItem from a non static context?

I edited to add a custom context class i seen on another post.
It works now but the custom context class throws a warning - Do not place Android context classes in static fields; this is a memory leak.

Is this actually a memory leak? How? and can i resolve it?

// Custom Context Class

```<code>public class MyCustomContext extends Application {

    private static Context context;

    public void onCreate() {
        super.onCreate();
        MyCustomContext.context = getApplicationContext();
    }

    public static Context getAppContext() {
        return MyCustomContext.context;
    }
}
</code>```

// Dummy Content Class

```<code>public class DummyContent {

    public static final List<DummyItem> ITEMS = new ArrayList<>();

    public static final Map<String, DummyItem> ITEM_MAP = new HashMap<>(5);

    static {
        addItem(new DummyItem("1", R.drawable.p1, "Item #1", "Author A", res.MyCustomContext.getAppContext().getString(R.string.ContentA));
        addItem(new DummyItem("2", R.drawable.p2, "Item #2", "Author B", res.MyCustomContext.getAppContext().getString(R.string.ContentB));
        addItem(new DummyItem("3", R.drawable.p3, "Item #3", "Author C", res.MyCustomContext.getAppContext().getString(R.string.ContentC)));
    }

    private static void addItem(DummyItem item) {
        ITEMS.add(item);
        ITEM_MAP.put(item.id, item);
    }

    public static class DummyItem {
        public final String id;
        public final int photoId;
        public final String title;
        public final String author;
        public final String content;

        public DummyItem(String id, int photoId, String title, String author, String content) {
            this.id = id;
            this.photoId = photoId;
            this.title = title;
            this.author = author;
            this.content = content;
        }
    }
}
</code>```

// List Fragment

```<code>import android.annotation.TargetApi;
import android.app.Activity;
import android.app.ListFragment;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.graphics.drawable.RoundedBitmapDrawable;
import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.BitmapImageViewTarget;

import com.app.test.R;
import com.app.test.DummyContent;

/**
 * Shows a list of all available quotes.
 */
public class PortfolioListFragment extends ListFragment {

    private Callback callback = dummyCallback;

    /**
     * A callback interface. Called whenever a item has been selected.
     */
    public interface Callback {
        void onItemSelected(String id);
    }

    /**
     * A dummy no-op implementation of the Callback interface. Only used when no active Activity is present.
     */
    private static final Callback dummyCallback = new Callback() {
        @Override
        public void onItemSelected(String id) {
        }
    };

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setListAdapter(new MyListAdapter());
        setHasOptionsMenu(true);
    }

    @Override
    public void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        // notify callback about the selected list item
        callback.onItemSelected(DummyContent.ITEMS.get(position).id);
    }

    /**
     * onAttach(Context) is not called on pre API 23 versions of Android.
     * onAttach(Activity) is deprecated but still necessary on older devices.
     */
    @TargetApi(23)
    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        onAttachToContext(context);
    }

    /**
     * Deprecated on API 23 but still necessary for pre API 23 devices.
     */
    @SuppressWarnings("deprecation")
    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
            onAttachToContext(activity);
        }
    }

    /**
     * Called when the fragment attaches to the context
     */
    protected void onAttachToContext(Context context) {
        if (!(context instanceof Callback)) {
            throw new IllegalStateException("Activity must implement callback interface.");
        }

        callback = (Callback) context;
    }

    private class MyListAdapter extends BaseAdapter {

        @Override
        public int getCount() {
            return DummyContent.ITEMS.size();
        }

        @Override
        public Object getItem(int position) {
            return DummyContent.ITEMS.get(position);
        }

        @Override
        public long getItemId(int position) {
            return DummyContent.ITEMS.get(position).id.hashCode();
        }

        @Override
        public View getView(int position, View convertView, ViewGroup container) {
            if (convertView == null) {
                convertView = LayoutInflater.from(getActivity()).inflate(R.layout.list_item_article, container, false);
            }

            final DummyContent.DummyItem item = (DummyContent.DummyItem) getItem(position);
            ((TextView) convertView.findViewById(R.id.article_title)).setText(item.title);
            ((TextView) convertView.findViewById(R.id.article_subtitle)).setText(item.author);
            final ImageView img = (ImageView) convertView.findViewById(R.id.thumbnail);
            Glide.with(getActivity()).load(item.photoId).asBitmap().into(new BitmapImageViewTarget(img) {
                @Override
                protected void setResource(Bitmap resource) {
                    RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(getActivity().getResources(), resource);
                    circularBitmapDrawable.setCircular(true);
                    img.setImageDrawable(circularBitmapDrawable);
                }
            });

            return convertView;
        }
    }

    public PortfolioListFragment() {
    }
}
</code>```

答: So, you can't use a findViewById(R.string.myString) resource because it isn't final? Not really sure if that's what you are asking or not.

Body:
I am trying to add some string resources to replace Content string but i cannot seem to access them because its a static class. How do i add items to DummyItem from a non static context?

I edited to add a custom context class i seen on another post.
It works now but the custom context class throws a warning - Do not place Android context classes in static fields; this is a memory leak.

Is this actually a memory leak? How? and can i resolve it?

// Custom Context Class

public class MyCustomContext extends Application {

    private static Context context;

    public void onCreate() {
        super.onCreate();
        MyCustomContext.context = getApplicationContext();
    }

    public static Context getAppContext() {
        return MyCustomContext.context;
    }
}

// Dummy Content Class

public class DummyContent {

    public static final List<DummyItem> ITEMS = new ArrayList<>();

    public static final Map<String, DummyItem> ITEM_MAP = new HashMap<>(5);

    static {
        addItem(new DummyItem("1", R.drawable.p1, "Item #1", "Author A", res.MyCustomContext.getAppContext().getString(R.string.ContentA));
        addItem(new DummyItem("2", R.drawable.p2, "Item #2", "Author B", res.MyCustomContext.getAppContext().getString(R.string.ContentB));
        addItem(new DummyItem("3", R.drawable.p3, "Item #3", "Author C", res.MyCustomContext.getAppContext().getString(R.string.ContentC)));
    }

    private static void addItem(DummyItem item) {
        ITEMS.add(item);
        ITEM_MAP.put(item.id, item);
    }

    public static class DummyItem {
        public final String id;
        public final int photoId;
        public final String title;
        public final String author;
        public final String content;

        public DummyItem(String id, int photoId, String title, String author, String content) {
            this.id = id;
            this.photoId = photoId;
            this.title = title;
            this.author = author;
            this.content = content;
        }
    }
}

// List Fragment

import android.annotation.TargetApi;
import android.app.Activity;
import android.app.ListFragment;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.graphics.drawable.RoundedBitmapDrawable;
import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.BitmapImageViewTarget;

import com.app.test.R;
import com.app.test.DummyContent;

/**
 * Shows a list of all available quotes.
 */
public class PortfolioListFragment extends ListFragment {

    private Callback callback = dummyCallback;

    /**
     * A callback interface. Called whenever a item has been selected.
     */
    public interface Callback {
        void onItemSelected(String id);
    }

    /**
     * A dummy no-op implementation of the Callback interface. Only used when no active Activity is present.
     */
    private static final Callback dummyCallback = new Callback() {
        @Override
        public void onItemSelected(String id) {
        }
    };

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setListAdapter(new MyListAdapter());
        setHasOptionsMenu(true);
    }

    @Override
    public void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        // notify callback about the selected list item
        callback.onItemSelected(DummyContent.ITEMS.get(position).id);
    }

    /**
     * onAttach(Context) is not called on pre API 23 versions of Android.
     * onAttach(Activity) is deprecated but still necessary on older devices.
     */
    @TargetApi(23)
    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        onAttachToContext(context);
    }

    /**
     * Deprecated on API 23 but still necessary for pre API 23 devices.
     */
    @SuppressWarnings("deprecation")
    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
            onAttachToContext(activity);
        }
    }

    /**
     * Called when the fragment attaches to the context
     */
    protected void onAttachToContext(Context context) {
        if (!(context instanceof Callback)) {
            throw new IllegalStateException("Activity must implement callback interface.");
        }

        callback = (Callback) context;
    }

    private class MyListAdapter extends BaseAdapter {

        @Override
        public int getCount() {
            return DummyContent.ITEMS.size();
        }

        @Override
        public Object getItem(int position) {
            return DummyContent.ITEMS.get(position);
        }

        @Override
        public long getItemId(int position) {
            return DummyContent.ITEMS.get(position).id.hashCode();
        }

        @Override
        public View getView(int position, View convertView, ViewGroup container) {
            if (convertView == null) {
                convertView = LayoutInflater.from(getActivity()).inflate(R.layout.list_item_article, container, false);
            }

            final DummyContent.DummyItem item = (DummyContent.DummyItem) getItem(position);
            ((TextView) convertView.findViewById(R.id.article_title)).setText(item.title);
            ((TextView) convertView.findViewById(R.id.article_subtitle)).setText(item.author);
            final ImageView img = (ImageView) convertView.findViewById(R.id.thumbnail);
            Glide.with(getActivity()).load(item.photoId).asBitmap().into(new BitmapImageViewTarget(img) {
                @Override
                protected void setResource(Bitmap resource) {
                    RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(getActivity().getResources(), resource);
                    circularBitmapDrawable.setCircular(true);
                    img.setImageDrawable(circularBitmapDrawable);
                }
            });

            return convertView;
        }
    }

    public PortfolioListFragment() {
    }
}


问:
Unable to upload to generic repository with correct filename using curl
I have a gzip file loaded with some scripts and jars. I tried to upload it to Artifactory generic repository using the below command

```<code> curl --insecure -uvaib:AP6yNYCePVfi5Ej8cXx1vq2SuFs -T "./deploy.tar.gz" "https://artifactory.service.apz/artifactory/EVC_Release/AC_2017_11a/deploy.tar.gz"
</code>```

I get the below error message.

```<code>{
  "errors" : [ {
"status" : 400,
"message" : "Parent AC_2017_11a must be a folder"
 } ]
</code>```

if I remove the name of the artifact from the end, it uploads but the filename becomes the package name

the structure I am looking at is
EVC_Release --> specific release name --> gzip file.

is there an issue with the options or my configuration in Artifactory?

答:
You first need to create the folder.

So you should have 2 commands:

```<code> curl -uvaib:AP6yNYCePVfi5Ej8cXx1vq2SuFs -X PUT "https://artifactory.service.apz/artifactory/EVC_Release/AC_2017_11a"
 curl --insecure -uvaib:AP6yNYCePVfi5Ej8cXx1vq2SuFs -T "./deploy.tar.gz" "https://artifactory.service.apz/artifactory/EVC_Release/AC_2017_11a/deploy.tar.gz"
</code>```

Any reason why you are not using JFrog CLI? It is much more powerful and user-friendly than what you are trying to achieve.
Once configured, the upload is simply:

```<code>jfrog rt upload ./deploy.tar.gz EVC_Release/AC_2017_11a/deploy.tar.gz
</code>```

Body:
I have a gzip file loaded with some scripts and jars. I tried to upload it to Artifactory generic repository using the below command

 curl --insecure -uvaib:AP6yNYCePVfi5Ej8cXx1vq2SuFs -T "./deploy.tar.gz" "https://artifactory.service.apz/artifactory/EVC_Release/AC_2017_11a/deploy.tar.gz"

I get the below error message.

{
  "errors" : [ {
"status" : 400,
"message" : "Parent AC_2017_11a must be a folder"
 } ]

if I remove the name of the artifact from the end, it uploads but the filename becomes the package name

the structure I am looking at is
EVC_Release --> specific release name --> gzip file.

is there an issue with the options or my configuration in Artifactory?

Body:
You first need to create the folder.

So you should have 2 commands:

 curl -uvaib:AP6yNYCePVfi5Ej8cXx1vq2SuFs -X PUT "https://artifactory.service.apz/artifactory/EVC_Release/AC_2017_11a"
 curl --insecure -uvaib:AP6yNYCePVfi5Ej8cXx1vq2SuFs -T "./deploy.tar.gz" "https://artifactory.service.apz/artifactory/EVC_Release/AC_2017_11a/deploy.tar.gz"

Any reason why you are not using JFrog CLI? It is much more powerful and user-friendly than what you are trying to achieve.
Once configured, the upload is simply:

jfrog rt upload ./deploy.tar.gz EVC_Release/AC_2017_11a/deploy.tar.gz