text:
Q: installing opencv failed- pasting the contents of CMakeError.log I tried the following
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential cmake unzip pkg-config
sudo apt-get install libjpeg-dev libpng-dev libtiff-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install libxvidcore-dev libx264-dev
sudo apt-get install libgtk-3-dev
sudo apt-get install libatlas-base-dev gfortran
sudo apt-get install python3-dev
cd ~
wget -O opencv.zip https://github.com/opencv/opencv/archive/4.0.0.zip
wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/4.0.0.zip
unzip opencv.zip
unzip opencv_contrib.zip
mv opencv-4.0.0 opencv
mv opencv_contrib-4.0.0 opencv_contrib
wget https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py
sudo pip install virtualenv virtualenvwrapper
sudo rm -rf ~/get-pip.py ~/.cache/pip
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source /usr/local/bin/virtualenvwrapper.sh
echo -e "\n# virtualenv and virtualenvwrapper" >> ~/.bashrc
echo "export WORKON_HOME=$HOME/.virtualenvs" >> ~/.bashrc
echo "export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3" >> ~/.bashrc
echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~/.bashrc
source ~/.bashrc
mkvirtualenv cv -p python3
workon cv
pip install numpy
cd ~/opencv
mkdir build
cd build

then I tried compiling for opencv with command

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local
-D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=OFF -D OPENCV_ENABLE_NONFREE=ON -D
OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules -D
PYTHON_EXECUTABLE=~/.virtualenvs/cv/bin/python -D BUILD_EXAMPLES=ON ..
I downloaded again and it is compiling. Earlier i downloaded to Downloads folder. Now I downloaded to home folder. Now compiling fine. The below error is not there.
But I get error
-- Configuring incomplete, errors occurred!
See also "/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeOutput.log".
See also "/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeError.log".

Some text is deleted
contents of CMakeError.log
Build output check failed:
    Regex: 'unrecognized .*option'
    Output line: 'cc1plus: warning: unrecognized command line option '-Wno-shorten-64-to-32''
Compilation failed:
    source file: '/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/src.cxx'
    check option: ' -Wno-shorten-64-to-32'
===== BUILD LOG =====
Change Dir: /home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_838ea/fast"
/usr/bin/make -f CMakeFiles/cmTC_838ea.dir/build.make CMakeFiles/cmTC_838ea.dir/build
make[1]: Entering directory '/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_838ea.dir/src.cxx.o
/usr/bin/c++     -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security   -Winit-self -Wpointer-arith   -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -Wno-deprecated -Wno-missing-declarations -Wno-shadow -Wno-unused-parameter -Wno-unused-local-typedefs -Wno-sign-compare -Wno-sign-promo -Wno-undef -Wno-ignored-qualifiers -Wno-extra -Wno-unused-function  -O3 -DNDEBUG -fPIE   -Wno-shorten-64-to-32 -o CMakeFiles/cmTC_838ea.dir/src.cxx.o -c /home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/src.cxx
/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/src.cxx:1:0: warning: ignoring #pragma   [-Wunknown-pragmas]
 #pragma
 ^
cc1plus: warning: unrecognized command line option '-Wno-shorten-64-to-32'
Linking CXX executable cmTC_838ea
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_838ea.dir/link.txt --verbose=1
/usr/bin/c++      -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security   -Winit-self -Wpointer-arith   -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -Wno-deprecated -Wno-missing-declarations -Wno-shadow -Wno-unused-parameter -Wno-unused-local-typedefs -Wno-sign-compare -Wno-sign-promo -Wno-undef -Wno-ignored-qualifiers -Wno-extra -Wno-unused-function  -O3 -DNDEBUG    -Wl,--gc-sections  CMakeFiles/cmTC_838ea.dir/src.cxx.o  -o cmTC_838ea
make[1]: Leaving directory '/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp'

===== END =====

Build output check failed:
    Regex: 'unrecognized .*option'
    Output line: 'cc1plus: warning: unrecognized command line option '-Wno-enum-compare-switch''
Compilation failed:
    source file: '/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/src.cxx'
    check option: ' -Wno-enum-compare-switch'
===== BUILD LOG =====
Change Dir: /home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_668b1/fast"
/usr/bin/make -f CMakeFiles/cmTC_668b1.dir/build.make CMakeFiles/cmTC_668b1.dir/build
make[1]: Entering directory '/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_668b1.dir/src.cxx.o
/usr/bin/c++     -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security   -Winit-self -Wpointer-arith   -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -Wno-deprecated -Wno-missing-declarations -Wno-shadow -Wno-unused-parameter -Wno-unused-local-typedefs -Wno-sign-compare -Wno-sign-promo -Wno-undef -Wno-ignored-qualifiers -Wno-extra -Wno-unused-function -Wno-invalid-offsetof  -O3 -DNDEBUG -fPIE   -Wno-enum-compare-switch -o CMakeFiles/cmTC_668b1.dir/src.cxx.o -c /home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/src.cxx
/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/src.cxx:1:0: warning: ignoring #pragma   [-Wunknown-pragmas]
 #pragma
 ^
cc1plus: warning: unrecognized command line option '-Wno-enum-compare-switch'
Linking CXX executable cmTC_668b1
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_668b1.dir/link.txt --verbose=1
/usr/bin/c++      -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security   -Winit-self -Wpointer-arith   -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -Wno-deprecated -Wno-missing-declarations -Wno-shadow -Wno-unused-parameter -Wno-unused-local-typedefs -Wno-sign-compare -Wno-sign-promo -Wno-undef -Wno-ignored-qualifiers -Wno-extra -Wno-unused-function -Wno-invalid-offsetof  -O3 -DNDEBUG    -Wl,--gc-sections  CMakeFiles/cmTC_668b1.dir/src.cxx.o  -o cmTC_668b1
make[1]: Leaving directory '/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp'

===== END =====

Build output check failed:
    Regex: 'unrecognized .*option'
    Output line: 'cc1plus: warning: unrecognized command line option '-Wno-inconsistent-missing-override''
Compilation failed:
    source file: '/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/src.cxx'
    check option: ' -Wno-inconsistent-missing-override'
===== BUILD LOG =====
Change Dir: /home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_cbd2d/fast"
/usr/bin/make -f CMakeFiles/cmTC_cbd2d.dir/build.make CMakeFiles/cmTC_cbd2d.dir/build
make[1]: Entering directory '/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_cbd2d.dir/src.cxx.o
/usr/bin/c++     -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security   -Winit-self -Wpointer-arith   -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -Wno-deprecated -Wno-missing-declarations -Wno-shadow -Wno-unused-parameter -Wno-unused-local-typedefs -Wno-sign-compare -Wno-sign-promo -Wno-undef -Wno-ignored-qualifiers -Wno-extra -Wno-unused-function -Wno-invalid-offsetof -Wno-suggest-override  -O3 -DNDEBUG -fPIE   -Wno-inconsistent-missing-override -o CMakeFiles/cmTC_cbd2d.dir/src.cxx.o -c /home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/src.cxx
/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/src.cxx:1:0: warning: ignoring #pragma   [-Wunknown-pragmas]
 #pragma
 ^
cc1plus: warning: unrecognized command line option '-Wno-inconsistent-missing-override'
Linking CXX executable cmTC_cbd2d
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_cbd2d.dir/link.txt --verbose=1
/usr/bin/c++      -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security   -Winit-self -Wpointer-arith   -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -Wno-deprecated -Wno-missing-declarations -Wno-shadow -Wno-unused-parameter -Wno-unused-local-typedefs -Wno-sign-compare -Wno-sign-promo -Wno-undef -Wno-ignored-qualifiers -Wno-extra -Wno-unused-function -Wno-invalid-offsetof -Wno-suggest-override  -O3 -DNDEBUG    -Wl,--gc-sections  CMakeFiles/cmTC_cbd2d.dir/src.cxx.o  -o cmTC_cbd2d
make[1]: Leaving directory '/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp'

===== END =====

Build output check failed:
    Regex: 'unrecognized .*option'
    Output line: 'cc1plus: warning: unrecognized command line option '-Wno-implicit-fallthrough''
Compilation failed:
    source file: '/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/src.cxx'
    check option: ' -Wno-implicit-fallthrough'
===== BUILD LOG =====
Change Dir: /home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_c8e77/fast"
/usr/bin/make -f CMakeFiles/cmTC_c8e77.dir/build.make CMakeFiles/cmTC_c8e77.dir/build
make[1]: Entering directory '/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_c8e77.dir/src.cxx.o
/usr/bin/c++     -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security   -Winit-self -Wpointer-arith   -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -Wno-deprecated -Wno-missing-declarations -Wno-shadow -Wno-unused-parameter -Wno-unused-local-typedefs -Wno-sign-compare -Wno-sign-promo -Wno-undef -Wno-ignored-qualifiers -Wno-extra -Wno-unused-function -Wno-invalid-offsetof -Wno-suggest-override  -O3 -DNDEBUG -fPIE   -Wno-implicit-fallthrough -o CMakeFiles/cmTC_c8e77.dir/src.cxx.o -c /home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/src.cxx
/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/src.cxx:1:0: warning: ignoring #pragma   [-Wunknown-pragmas]
 #pragma
 ^
cc1plus: warning: unrecognized command line option '-Wno-implicit-fallthrough'
Linking CXX executable cmTC_c8e77
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_c8e77.dir/link.txt --verbose=1
/usr/bin/c++      -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security   -Winit-self -Wpointer-arith   -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -Wno-deprecated -Wno-missing-declarations -Wno-shadow -Wno-unused-parameter -Wno-unused-local-typedefs -Wno-sign-compare -Wno-sign-promo -Wno-undef -Wno-ignored-qualifiers -Wno-extra -Wno-unused-function -Wno-invalid-offsetof -Wno-suggest-override  -O3 -DNDEBUG    -Wl,--gc-sections  CMakeFiles/cmTC_c8e77.dir/src.cxx.o  -o cmTC_c8e77
make[1]: Leaving directory '/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp'

===== END =====

Build output check failed:
    Regex: 'unrecognized .*option'
    Output line: 'cc1: warning: unrecognized command line option '-Wno-implicit-fallthrough''
Compilation failed:
    source file: '/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/src.c'
    check option: ' -Wno-implicit-fallthrough'
===== BUILD LOG =====
Change Dir: /home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_0ad64/fast"
/usr/bin/make -f CMakeFiles/cmTC_0ad64.dir/build.make CMakeFiles/cmTC_0ad64.dir/build
make[1]: Entering directory '/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_0ad64.dir/src.c.o
/usr/bin/cc    -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden  -O3 -DNDEBUG -fPIE   -Wno-implicit-fallthrough -o CMakeFiles/cmTC_0ad64.dir/src.c.o   -c /home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/src.c
/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/src.c:1:0: warning: ignoring #pragma   [-Wunknown-pragmas]
 #pragma
 ^
cc1: warning: unrecognized command line option '-Wno-implicit-fallthrough'
Linking C executable cmTC_0ad64
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_0ad64.dir/link.txt --verbose=1
/usr/bin/cc     -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden  -O3 -DNDEBUG    -Wl,--gc-sections  CMakeFiles/cmTC_0ad64.dir/src.c.o  -o cmTC_0ad64
make[1]: Leaving directory '/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp'

===== END =====

Build output check failed:
    Regex: 'unrecognized .*option'
    Output line: 'cc1plus: warning: unrecognized command line option '-Wno-unused-private-field''
Compilation failed:
    source file: '/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/src.cxx'
    check option: ' -Wno-unused-private-field'
===== BUILD LOG =====
Change Dir: /home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_84ab8/fast"
/usr/bin/make -f CMakeFiles/cmTC_84ab8.dir/build.make CMakeFiles/cmTC_84ab8.dir/build
make[1]: Entering directory '/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_84ab8.dir/src.cxx.o
/usr/bin/c++     -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -Wno-unused-function -Wno-deprecated-declarations -Wno-overloaded-virtual  -O3 -DNDEBUG -fPIE   -Wno-unused-private-field -o CMakeFiles/cmTC_84ab8.dir/src.cxx.o -c /home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/src.cxx
/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/src.cxx:1:0: warning: ignoring #pragma   [-Wunknown-pragmas]
 #pragma
 ^
cc1plus: warning: unrecognized command line option '-Wno-unused-private-field'
Linking CXX executable cmTC_84ab8
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_84ab8.dir/link.txt --verbose=1
/usr/bin/c++      -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -Wno-unused-function -Wno-deprecated-declarations -Wno-overloaded-virtual  -O3 -DNDEBUG    -Wl,--gc-sections  CMakeFiles/cmTC_84ab8.dir/src.cxx.o  -o cmTC_84ab8
make[1]: Leaving directory '/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp'

===== END =====

Determining if the CL_VERSION_2_0 exist failed with the following output:
Change Dir: /home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_6a76e/fast"
/usr/bin/make -f CMakeFiles/cmTC_6a76e.dir/build.make CMakeFiles/cmTC_6a76e.dir/build
make[1]: Entering directory '/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_6a76e.dir/CheckSymbolExists.c.o
/usr/bin/cc    -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden  -O3 -DNDEBUG -fPIE   -o CMakeFiles/cmTC_6a76e.dir/CheckSymbolExists.c.o   -c /home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c
/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:2:47: fatal error: OpenCL_INCLUDE_DIR-NOTFOUND/CL/cl.h: No such file or directory
compilation terminated.
CMakeFiles/cmTC_6a76e.dir/build.make:65: recipe for target 'CMakeFiles/cmTC_6a76e.dir/CheckSymbolExists.c.o' failed
make[1]: *** [CMakeFiles/cmTC_6a76e.dir/CheckSymbolExists.c.o] Error 1
make[1]: Leaving directory '/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_6a76e/fast' failed
make: *** [cmTC_6a76e/fast] Error 2

File /home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <OpenCL_INCLUDE_DIR-NOTFOUND/CL/cl.h>

int main(int argc, char** argv)
{
  (void)argv;
#ifndef CL_VERSION_2_0
  return ((int*)(&CL_VERSION_2_0))[argc];
#else
  (void)argc;
  return 0;
#endif
}

Determining if the CL_VERSION_1_2 exist failed with the following output:
Change Dir: /home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_9c7fc/fast"
/usr/bin/make -f CMakeFiles/cmTC_9c7fc.dir/build.make CMakeFiles/cmTC_9c7fc.dir/build
make[1]: Entering directory '/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_9c7fc.dir/CheckSymbolExists.c.o
/usr/bin/cc    -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden  -O3 -DNDEBUG -fPIE   -o CMakeFiles/cmTC_9c7fc.dir/CheckSymbolExists.c.o   -c /home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c
/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:2:47: fatal error: OpenCL_INCLUDE_DIR-NOTFOUND/CL/cl.h: No such file or directory
compilation terminated.
CMakeFiles/cmTC_9c7fc.dir/build.make:65: recipe for target 'CMakeFiles/cmTC_9c7fc.dir/CheckSymbolExists.c.o' failed
make[1]: *** [CMakeFiles/cmTC_9c7fc.dir/CheckSymbolExists.c.o] Error 1
make[1]: Leaving directory '/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_9c7fc/fast' failed
make: *** [cmTC_9c7fc/fast] Error 2

File /home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <OpenCL_INCLUDE_DIR-NOTFOUND/CL/cl.h>

int main(int argc, char** argv)
{
  (void)argv;
#ifndef CL_VERSION_1_2
  return ((int*)(&CL_VERSION_1_2))[argc];
#else
  (void)argc;
  return 0;
#endif
}

Determining if the CL_VERSION_1_1 exist failed with the following output:
Change Dir: /home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_83bb4/fast"
/usr/bin/make -f CMakeFiles/cmTC_83bb4.dir/build.make CMakeFiles/cmTC_83bb4.dir/build
make[1]: Entering directory '/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_83bb4.dir/CheckSymbolExists.c.o
/usr/bin/cc    -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden  -O3 -DNDEBUG -fPIE   -o CMakeFiles/cmTC_83bb4.dir/CheckSymbolExists.c.o   -c /home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c
/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:2:47: fatal error: OpenCL_INCLUDE_DIR-NOTFOUND/CL/cl.h: No such file or directory
compilation terminated.
CMakeFiles/cmTC_83bb4.dir/build.make:65: recipe for target 'CMakeFiles/cmTC_83bb4.dir/CheckSymbolExists.c.o' failed
make[1]: *** [CMakeFiles/cmTC_83bb4.dir/CheckSymbolExists.c.o] Error 1
make[1]: Leaving directory '/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_83bb4/fast' failed
make: *** [cmTC_83bb4/fast] Error 2

File /home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <OpenCL_INCLUDE_DIR-NOTFOUND/CL/cl.h>

int main(int argc, char** argv)
{
  (void)argv;
#ifndef CL_VERSION_1_1
  return ((int*)(&CL_VERSION_1_1))[argc];
#else
  (void)argc;
  return 0;
#endif
}

Determining if the CL_VERSION_1_0 exist failed with the following output:
Change Dir: /home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_8c594/fast"
/usr/bin/make -f CMakeFiles/cmTC_8c594.dir/build.make CMakeFiles/cmTC_8c594.dir/build
make[1]: Entering directory '/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_8c594.dir/CheckSymbolExists.c.o
/usr/bin/cc    -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden  -O3 -DNDEBUG -fPIE   -o CMakeFiles/cmTC_8c594.dir/CheckSymbolExists.c.o   -c /home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c
/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:2:47: fatal error: OpenCL_INCLUDE_DIR-NOTFOUND/CL/cl.h: No such file or directory
compilation terminated.
CMakeFiles/cmTC_8c594.dir/build.make:65: recipe for target 'CMakeFiles/cmTC_8c594.dir/CheckSymbolExists.c.o' failed
make[1]: *** [CMakeFiles/cmTC_8c594.dir/CheckSymbolExists.c.o] Error 1
make[1]: Leaving directory '/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_8c594/fast' failed
make: *** [cmTC_8c594/fast] Error 2

File /home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <OpenCL_INCLUDE_DIR-NOTFOUND/CL/cl.h>

int main(int argc, char** argv)
{
  (void)argv;
#ifndef CL_VERSION_1_0
  return ((int*)(&CL_VERSION_1_0))[argc];
#else
  (void)argc;
  return 0;
#endif
}

Determining if the include file sys/videoio.h exists failed with the following output:
Change Dir: /home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_369b8/fast"
/usr/bin/make -f CMakeFiles/cmTC_369b8.dir/build.make CMakeFiles/cmTC_369b8.dir/build
make[1]: Entering directory '/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_369b8.dir/CheckIncludeFile.c.o
/usr/bin/cc    -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden  -O3 -DNDEBUG -fPIE   -o CMakeFiles/cmTC_369b8.dir/CheckIncludeFile.c.o   -c /home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c
/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:25: fatal error: sys/videoio.h: No such file or directory
compilation terminated.
CMakeFiles/cmTC_369b8.dir/build.make:65: recipe for target 'CMakeFiles/cmTC_369b8.dir/CheckIncludeFile.c.o' failed
make[1]: *** [CMakeFiles/cmTC_369b8.dir/CheckIncludeFile.c.o] Error 1
make[1]: Leaving directory '/home/sandeep/Downloads/opencv/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_369b8/fast' failed
make: *** [cmTC_369b8/fast] Error 2

A:
You can install open cv using pip

pip install opencv-python

And also install opencv-contrib using pip

pip install opencv-contrib-python

A: faced similar error and resolved it by correcting this path
OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules

Note: In case you don't have opencv_contrib folder, you can get it
git clone https://github.com/opencv/opencv_contrib.git


text:
Q: Search in a timespan I have this list with timestamps and I'd like to be able to search for all elements in a certain timespan (every timespan has corresponding information in another list) depending on the users input (hours <= 24 or days from midnight or neither).
Example (this is just an example list, the solution should work on very large lists)
list =  ['2002-03-31 19:30:41', '2002-03-31 19:30:41', '2002-03-31 19:43:49', '2002-03-31     19:43:50', '2002-03-31 19:50:05', '2002-03-31 19:50:06', '2002-03-31 19:50:06', '2002-03-31 19:50:44', '2002-03-31 19:50:45', '2002-03-31 19:50:45', '2002-03-31 19:51:50', '2002-03-31 19:51:50', '2002-03-31 19:51:50', '2002-03-31 19:52:25', '2002-03-31 19:52:25', '2002-03-31 19:52:25', '2002-03-31 19:53:05', '2002-03-31 19:53:06', '2002-03-31 19:53:06', '2002-03-31 19:53:06', '2002-03-31 19:53:17', '2002-03-31 19:54:14', '2002-03-31 19:54:14']
activity= [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w]

I'm going to use the last element list[-1] as a reference point. If the user wants to see activities during the past three hours witch means from 2002-03-31 16:54:14 to 2002-03-31 19:54:14 the positions of the timestamps are going to be used to get the activities from the other list.
I thought first about converting every timestamp to something usable so its easier to compare each element but there must be an easier solution.
this module looks usable but I can't figure out how I could use it.
Best regards

A: As a workflow:

*

*Use the datetime module to transform your strings into datetime object with the strptime method: you get a list of datetime objects.

*Compute timedeltas by subtracting each entry of this list from the last one.

*You can use the seconds attribute of a timedelta to find out how many seconds between one point and the reference: compare that to 3*3600 (3h) to find out which items fall in the proper period.

A: You are incredibly lucky in that your timestamps are in the easiest possible order for sorting, and you can punt on the whole "converting to a time value" and just do string comparisons:
times =  ['2002-03-31 19:30:41', '2002-03-31 19:30:41', '2002-03-31 19:43:49', '2002-03-31     19:43:50', '2002-03-31 19:50:05', '2002-03-31 19:50:06', '2002-03-31 19:50:06', '2002-03-31 19:50:44', '2002-03-31 19:50:45', '2002-03-31 19:50:45', '2002-03-31 19:51:50', '2002-03-31 19:51:50', '2002-03-31 19:51:50', '2002-03-31 19:52:25', '2002-03-31 19:52:25', '2002-03-31 19:52:25', '2002-03-31 19:53:05', '2002-03-31 19:53:06', '2002-03-31 19:53:06', '2002-03-31 19:53:06', '2002-03-31 19:53:17', '2002-03-31 19:54:14', '2002-03-31 19:54:14']
activity= ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w']

start = '2002-03-31 16:54:14'
end = '2002-03-31 19:54:14'

for time, activity in zip(times, activity):
    if time >= start and time <= end:
        print time, activity

A: Something like this should work
ls =  ['2002-03-31 19:30:41', '2002-03-31 19:30:41', '2002-03-31 19:43:49', '2002-03-31     19:43:50', '2002-03-31 19:50:05', '2002-03-31 19:50:06', '2002-03-31 19:50:06', '2002-03-31 19:50:44', '2002-03-31 19:50:45', '2002-03-31 19:50:45', '2002-03-31 19:51:50', '2002-03-31 19:51:50', '2002-03-31 19:51:50', '2002-03-31 19:52:25', '2002-03-31 19:52:25', '2002-03-31 19:52:25', '2002-03-31 19:53:05', '2002-03-31 19:53:06', '2002-03-31 19:53:06', '2002-03-31 19:53:06', '2002-03-31 19:53:17', '2002-03-31 19:54:14', '2002-03-31 19:54:14']

# target is one of the items in the list
target = datetime.strptime('2002-03-31 19:53:17', '%Y-%m-%d %H:%M:%S')
for l in ls:
    print datetime.strptime(l, '%Y-%m-%d %H:%M:%S') - target

Prints
-1 day, 23:37:24
-1 day, 23:37:24
-1 day, 23:50:32
-1 day, 23:50:33
-1 day, 23:56:48
-1 day, 23:56:49
-1 day, 23:56:49
-1 day, 23:57:27
-1 day, 23:57:28
-1 day, 23:57:28
-1 day, 23:58:33
-1 day, 23:58:33
-1 day, 23:58:33
-1 day, 23:59:08
-1 day, 23:59:08
-1 day, 23:59:08
-1 day, 23:59:48
-1 day, 23:59:49
-1 day, 23:59:49
-1 day, 23:59:49
0:00:00
0:00:57
0:00:57

The datetime.strptime(l, '%Y-%m-%d %H:%M:%S') - target returns a timedelta object (docs). You can access the timedelta objects days, seconds and microseconds attributes and compare those to some desired time span. For instance to get all the index of all the events that occured less than an hour from some reference point:
less_than_an_hour = []
for i,l in enumerate(ls):
    if (datetime.strptime(l, '%Y-%m-%d %H:%M:%S') - target).seconds < 3600:
        less_than_an_hour.append(i)

A: I'd:

*

*convert the list of timestamps to datetime objects:
times = [datetime.datetime.strptime(t, '%Y-%m-%d %H:%M:%S') for t in times]

*Use the bisect module to find your start time the user requested. Using bisect is a much faster method than using linear search, provided you translate the user input to datetime objects as well:
start = datetime.datetime(2002, 3, 31, 19, 53, 17)
startindex = bisect.bisect_left(times, start)

*Use itertools functions to merge the two lists into one that shows entries that match your range:
end = datetime.datetime(2002, 4, 1, 07, 53, 17)

merged = itertools.izip(times, activity)
fromstart = itertools.islice(merged, startindex)
untilend = itertools.takewhile(lambda e: e[0] <= end, fromstart)

The untilend iterable now generates entries between start and end as (time, activity) tuples, without using any extra memory for copied lists. This let's you handle huge amounts of data efficiently.
Demo:
>>> import itertools
>>> import datetime
>>> import bisect
>>> times =  ['2002-03-31 19:30:41', '2002-03-31 19:30:41', '2002-03-31 19:43:49', '2002-03-31     19:43:50', '2002-03-31 19:50:05', '2002-03-31 19:50:06', '2002-03-31 19:50:06', '2002-03-31 19:50:44', '2002-03-31 19:50:45', '2002-03-31 19:50:45', '2002-03-31 19:51:50', '2002-03-31 19:51:50', '2002-03-31 19:51:50', '2002-03-31 19:52:25', '2002-03-31 19:52:25', '2002-03-31 19:52:25', '2002-03-31 19:53:05', '2002-03-31 19:53:06', '2002-03-31 19:53:06', '2002-03-31 19:53:06', '2002-03-31 19:53:17', '2002-03-31 19:54:14', '2002-03-31 19:54:14']
>>> activity= ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w']
>>> times = [datetime.datetime.strptime(t, '%Y-%m-%d %H:%M:%S') for t in times]
>>> start = datetime.datetime(2002, 3, 31, 19, 53, 17)
>>> end = datetime.datetime(2002, 4, 1, 07, 53, 17)
>>> startindex = bisect.bisect_left(times, start)
>>> merged = itertools.izip(times, activity)
>>> fromstart = itertools.islice(merged, startindex)
>>> untilend = itertools.takewhile(lambda e: e[0] <= end, fromstart)
>>> for time, activity in untilend:
...     print time, activity
...
2002-03-31 19:30:41 a
2002-03-31 19:30:41 b
2002-03-31 19:43:49 c
2002-03-31 19:43:50 d
2002-03-31 19:50:05 e
2002-03-31 19:50:06 f
2002-03-31 19:50:06 g
2002-03-31 19:50:44 h
2002-03-31 19:50:45 i
2002-03-31 19:50:45 j
2002-03-31 19:51:50 k
2002-03-31 19:51:50 l
2002-03-31 19:51:50 m
2002-03-31 19:52:25 n
2002-03-31 19:52:25 o
2002-03-31 19:52:25 p
2002-03-31 19:53:05 q
2002-03-31 19:53:06 r
2002-03-31 19:53:06 s
2002-03-31 19:53:06 t

redpajama_set_name: RedPajamaStackExchange


text:
Q: The Least Area For a Needle to Pass Through a Curve? I don't know if this question is a famous one. One of my fellows asked me these questions to tease me, but I was able to find a solution for only one of these:

There is one needle of length $2$ placed on the $x$-axis from $(0, 0)$ to $(2, 0)$. It had been dipped into ink, so when the needle moves, the ink colors the plane as it goes. Ignore the width of the needle(i.e., the needle is a segmented line).

*

*There are $n$ number of points in the plane. What is the least area for the needle to touch each point?

*There is a line of length $n$. We say a needle passes through the line when the needle literally passes through every points in the line. What is the least area for the given needle to pass through the length $n$ line?

*What if the line is a length $n$ curve?

According to him, I've only answered him right the first question. My solution was this: just move the needle backwards a lot, then the angle between the needle and one point ($\theta _1$) becomes smaller as the needle keeps going backward. So we can make the angle smaller as we want, which implies the colored area caused by moving the needle by $\theta_1$ also becomes smaller as we want. Following this argument, we can say that we can make the total colored area smaller as we want(i.e., the sum of limit of the total area caused by changing $\theta_1$ to $\theta_n$ goes to 0).
What makes me crazy is the last two questions. I answered him the following way: as before, move the needle backwards infinitely. Then the angle between the needle and the two endpoints of the curve becomes smaller as it keep moves backward.
Now think it as shooting a shot from the needle to one of a dot of the line. So first shoot at the one endpoint of the line, move back, shoot at the next dot, move back, and repeating this procedure. Then it requires in total $\theta$ angle, the angle between the needle and the two endpoints of the given line. But, since we can make the angle smaller as we want, again the total area caused by changing $\theta$ goes to 0.
But he said this is a wrong proof. And I think he mentioned that the answer of questions #2 and #3 are different. But according to my argument, there's no reason for having different answers for the two last questions.
Progress There was a decent discussion on the topic with Bill Trok, and I want to show you the whole progress, regardless of their validity.

*

*Consider a bijection between [0, $\theta$] to [c, d], where the last interval represents the line segment. Then using the bijection $f$, I think we can argue that we need - by using the shooting technique mentioned above - $\theta$ amount of change in angle in total to shoot every element in [c, d]. But since we can make that $\theta$ as small as we want, the area would go to 0 in the limit. Hence, the answer seems to be 0 in the limit. The techinical problem suggested by Bill Trok was that in this way, maybe some 'unmeasurable' problem would occur. Sadly, I yet haven't taken any measure theory class.

*First, let the needle lie on the y-axis and the segmented line on the positive x-axis right next to the origin. Then first, move the needle down then rotate the needle by $\theta$ to color a part of the line. Now as we move by $\theta$, the colored area is as close as tan$\theta$, which is bigger than $\theta$ itself. Then move the needle backward again then make the tip of the needle pointing at the uncolored segment, doing this procedure again. The conclusion was... a little bit ambiguous, though.

*Bill Tork has linked to contents related to Kekeya set. According to this, we can just rotate the needle as far as we want with an arbitrary small amounts of space, so the answers seem to be 0 in the limit.
Help me! I cannot come up with any more clever ideas.
P.S. I couldn't classify this question by myself, so I just put it in geometry. Any suitable modifications are welcomed.


text:
Q: Adding a Column to CSV Using Data Returned From Function I've been working on a script that takes output from a syslog server containing firewall logs, re-organizes that output to a new CSV file in a more readable format, and then performs a lookup on the source IP addresses to identify what city traffic originates from. I'm not sure how to get the results from my function that looks up details on the IP addresses to add additional columns to the new CSV file.
This is an example of a single record from the source file. Note: I've edited the IP addresses to mask them.

2018-07-01 14:48:47,Local7.Info,192.168.1.00,device="SFW"
  date=2018-07-01 time=14:48:39 timezone="PDT" device_name="XG"
  device_id=00000000000000 log_id=010101600001 log_type="Firewall"
  log_component="Firewall Rule" log_subtype="Allowed" status="Allow"
  priority=Information duration=11 fw_rule_id=3 policy_type=3
  user_name="" user_gp="" iap=0 ips_policy_id=0 appfilter_policy_id=0
  application="Secure Socket Layer Protocol" application_risk=1
  application_technology="Network Protocol"
  application_category="Infrastructure" in_interface="Port2"
  out_interface="Port1" src_mac=00: 0:00: 0:00: 0 src_ip=75.148.000.000
  src_country_code=USA dst_ip=23.24.000.000 dst_country_code=USA
  protocol="TCP" src_port=55000 dst_port=443 sent_pkts=7 recv_pkts=6
  sent_bytes=1369 recv_bytes=918 tran_src_ip=192.168.000.000
  tran_src_port=0 tran_dst_ip=192.168.000.000 tran_dst_port=0
  srczonetype="WAN" srczone="WAN" dstzonetype="LOCAL" dstzone="LOCAL"
  dir_disp="" connevent="Stop" connid="1782869248" vconnid=""
  hb_health="No Heartbeat" message="" appresolvedby="Signature"

With the help of other users on here, I've been able to write a script that creates a new CSV file ($output_file) with a more reader-friendly format, and looks up information on the src_ip column. I'm not sure how I can take the results from that function (Get-IPGeolocation) and add additional columns to my $output_file with the results.
#Parameters for environment
$regex = '\b(\w+)=([^ ]+)'
$input_path = "C:\powershell_work\ParsingSophos\data.csv"
$output_file = "C:\powershell_work\GeolocatingIPs\combine-output.csv"

#Function used to lookup IP-Address information.
function Get-IPGeolocation
{
    Param
    (
        [string]$IPAddress
    )

    $request = Invoke-RestMethod -Method Get -Uri "http://geoip.nekudo.com/api/$IPAddress"

    [PSCustomObject]@{
        IP        = $request.IP
        City      = $request.City
        Country   = $request.Country.Name
        Code      = $request.Country.Code
        Location  = $request.Location.Latitude
        Longitude = $request.Location.Longitude
        TimeZone  = $request.Location.Time_zone
    }
}

# Parsing the input_path file, and exporting to a more workable format
Select-String -LiteralPath $input_path -AllMatches -Pattern $regex | ForEach-Object {
    $obj = New-Object pscustomobject
    foreach ($match in $_.Matches) {
      Add-Member -InputObject $obj -NotePropertyName $match.Groups[1].Value -NotePropertyValue $match.Groups[2].Value
    }
    $obj
} | Select-Object *_ip, srczone, src_country_code, dstzone, dst_country_code |
     Export-Csv -NoTypeInformation $output_file

# Gathering list of Source IPs to be used in the lookup
$src_ips = Import-CSV $output_file | select -ExpandProperty src_ip

# Loop that runs each IP through the function to find IP address information
ForEach($ip in $src_ips) {
Get-IPGeolocation -IPAddress $ip
}

Running that script with multiple records of data in your $input_path CSV file returns results like this.
Output Exmaple

A: In essence, you're asking how to merge two custom objects:
A simple example (PSv4+ syntax, assumes that the property-name sets don't overlap):
# Create two sample custom objects to merge.
$co1 = [pscustomobject] @{ one = 1; two = 2; three = 3 }
$co2 = [pscustomobject] @{ four = 4; five = 5; six = 6 }

# Add $co2's properties to $co1
$co2.psobject.properties.foreach({
  Add-Member -InputObject $co1 -NotePropertyName $_.Name -NotePropertyValue $_.Value
})

# Output $co1, which now contains its own properties plus the ones from $co2.
$co1

The above yields:
one   : 1
two   : 2
three : 3
four  : 4
five  : 5
six   : 6

Applied to your scenario:
Import-Csv $output_file | ForEach-Object {
  $obj = $_
  (Get-IPGeolocation -IPAddress $obj.src_ip).psobject.properties.foreach({
    Add-Member -InputObject $obj -NotePropertyName $_.Name -NotePropertyValue $_.Value
  })
  $obj
} | Export-Csv -NoTypeInformation .\merged.csv


text:
Q: Paypal IPN script not working For some reason my script connects to the database and has no errors however nothing in the database seems to update. I cannot find anything wrong with it. Here is my code:
    // read the post from PayPal system and add 'cmd'
    $req = 'cmd=_notify-validate';

    foreach ($_POST as $key => $value) {
          $value = urlencode(stripslashes($value));
          $req .= "&$key=$value";
        }

    // post back to PayPal system to validate
    $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
    $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
    $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
    $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);

    // assign posted variables to local variables
    $item_name = $_POST['item_name'];
    $item_number = $_POST['item_number'];
    $payment_status = $_POST['payment_status'];
    $payment_amount = $_POST['mc_gross'];
    $payment_currency = $_POST['mc_currency'];
    $txn_id = $_POST['txn_id'];
    $receiver_email = $_POST['receiver_email'];
    $payer_email = $_POST['payer_email'];
    $user_id = mysql_real_escape_string($_POST['custom']);
    $today = date("F j, Y, g:i a");

    echo "hi";

    if (!$fp) {
       // HTTP ERROR
    } else {
      fputs ($fp, $header . $req);
      while (!feof($fp)) {
        $res = fgets ($fp, 1024);
        if (strcmp ($res, "VERIFIED") == 0) {
            if ($payment_status=='Completed') {
                $txn_id_check = mysql_query("SELECT 'txn_id' FROM 'log' WHERE 'txn_id' ='".$txn_id."'");
                if (mysql_num_rows($txn_id_check) !=1) {
                    if ($receiver_email=='HiddenForStackQuestion') {
                        if ($payment_amount=='29.95' && $payment_currency=='USD') {
                        $log_query = mysql_query("INSERT INTO 'log' VALUES ('','".$txn_id."','".$payer_email."')");
                        $update_premium = mysql_query("UPDATE 'users' SET authLevel='1', startDate='".$today."'  WHERE 'fbID'='".$user_id."'");

                        }

                        }

                    }
            }

        }
        else if (strcmp ($res, "INVALID") == 0) {
             // log for manual investigation
        }
      }
      fclose ($fp);
    }
    ?>

And Here is my button.
    <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_xclick-subscriptions">
    <input type="hidden" name="business" value="hiddenForStackQuestion">
    <input type="hidden" name="lc" value="US">
    <input type="hidden" name="item_name" value="hiddenForStackQuestion">
    <input type="hidden" name="no_note" value="1">
    <input type="hidden" name="no_shipping" value="2">
    <input type="hidden" name="rm" value="1">
    <input type="hidden" name="return" value="hiddenForStackQuestion">
    <input type="hidden" name="cancel_return" value="hiddenForStackQuestion">
    <input type="hidden" name="src" value="1">
    <input type="hidden" name="a3" value="29.95">
    <input type="hidden" name="p3" value="1">
    <input type="hidden" name="t3" value="Y">
    <input type="hidden" name="notify_url" value="hiddenForStackQuestion" />
          <input type="hidden" name="custom" value="<?php echo $userId ?>" />
    <input type="hidden" name="currency_code" value="USD">
    <input type="hidden" name="bn" value="PP-SubscriptionsBF:btn_subscribeCC_LG.gif:NonHosted">
    <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" style="border:none;">
    </form>

I have been on this for awhile but am having no luck. Anyone see what is wrong?

A: This
<input type="hidden" name="notify_url" value="hiddenForStackQuestion" />

Doesn't happen to be hosted on localhost, I hope?
An IPN POST is initiated by PayPal's servers, and as such must be a FQDN. localhost won't work.


text:
Q: How to create a job in shell script? I know that execute a command and add & to the end would create a job and make the command execute in background.
Now I want to create a job in a bash shell. I tried
#!/bin/bash

my-job &
# some other tasks

Then I executed jobs, but I got no output. However, ps aux does show my-job is running in the background.
I want to create a job inside a script, because in some cases I want to bring the job into foreground.

A: jobs are usually an interactive shell concept, as there is usually a controlling terminal involved.
A shell script is executed in a non-interactive, non-login session of shell, hence no job control by default.
You can force job control inside a script, by setting:
set -m

inside the script.
From help set:
-m  Job control is enabled.


text:
Q: Global Style for GridSplitter that depends on its orientation I'd like to create a global style that would affect every "GridSplitter" of my app to change its cursor appearance when mouse is over.
This code works for vertical GridSplitter:
<Style TargetType="GridSplitter">
  <Setter Property="Cursor" Value="SizeWe"></Setter>
</Style>

But I don't know how to detect its orientation and set the Value to "SizeNs" when appropriate.
I do not want to have to change every GridSplitter code. I want one style that could apply for every Gridsplitter without having to set a resource key.
Any idea ?
For all of those who have a XamlParseException : 'Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '15' and line position '9'.
Ensure you have proper syntax for Cursor names.

A: You can use ResizeDirection property in control template triggers and set appropriate cursor.
<Style TargetType="GridSplitter">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="GridSplitter">

                <Rectangle Fill="{TemplateBinding Background}"></Rectangle>

                <ControlTemplate.Triggers>
                    <Trigger Property="ResizeDirection" Value="Columns">
                        <Setter Property="Cursor" Value="SizeNS"></Setter>
                    </Trigger>
                    <Trigger Property="ResizeDirection" Value="Rows">
                        <Setter Property="Cursor" Value="SizeWE"></Setter>
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>


text:
Q: How to delay a javascript function I use this code and it works so that when i reload the page the button is autoclicked but i want to make a delay so that it will be clicked after 60 seconds from page reloading
window.onload = function () {
  var button = document.getElementById('clickButton');
  button.form.submit();
};

A: window.onload = function() {
  setTimeout(() => {
    var button = document.getElementById('clickButton');
    button.form.submit();
  }, 60000);
}

Use setTimeout() https://developer.mozilla.org/en-US/docs/Web/API/setTimeout

A: To delay a page to execute some function use setTimeout takes in most cases two arguments the first is the function to be excuted after such a amount of time given by the second argument in ms
setTimeout(
function(){
 var button = document.getElementById('clickButton');
button.form.submit();
}
, 60*1000);//60 * 1000 = 60000ms = 60s


text:
Q: Can you perform an iteration in the VB6 immediate window? While debugging a VB6 program it would be useful to output a fairly large multidimensional array in the immediate window. That would enable copy/paste to another editor for analysis and would be easier than clicking through the array in the locals window.
However I'm unsure of how to use looping syntax in the immediate window - or even if this is possible.

A: You can use the colon (:) to separate statements on a single line.  For instance:
for x=0 to 2:for y=0 to 2: ? myData(x,y): next : next

Result:

This is 0 0
  This is 0 1
  This is 0 2
  This is 1 0
  This is 1 1
  This is 1 2
  This is 2 0
  This is 2 1
  This is 2 2

A: After more messing around than this should have required, it turns out the answer is:

Although most statements are supported in the Immediate window, a control structure is valid only if it can be completely expressed on one line of code; use colons to separate the statements that make up the control structure. The following For loop is valid in the Immediate window:
For I = 1 To 20 : Print 2 * I : Next I

(which is formally documented here.)
Some additional details:

*

*Variables in the immediate window do not require declaration -- even if Option Explicit is used in the module / program being run. This makes arbitrary for-looping convenient (but also makes mistakes easier when trying to reference variables in current scope).

*Printing can be done with any of: Debug.Print, just Print or ?

*Nested loops work.


text:
Q: Dynamically rename header to 1,2,3,4,5 Im trying to remame the columns in the table below with ascending integers. The dates will change week on week, so I need a way to dynamically rename in alteryx, is there a way of doing this with the dynamic rename tool? or another method perhaps?

To be turned into:

Week Start
1
2
3
4
5

Week
46
47
47
48
49

Thanks

A: You'll need to use a combination of the Transform tools and a Record ID.  Use the Transpose tool with the 'Week Start' as your "Key column" then use the Summarize and group by the new Name field to get a list of all your dates and sort the dates in ascending order.
Add a Record ID after to give each date an ID.  Join this back to the original Transpose and then Cross Tab to get the output you want.
See screenshot in link below.
AlteryxChangeColumnnames


text:
Q: What package now provides \NewDocumentCommand? I see that I can use the command \NewDocumentCommand
without adding \usepackage{xparse}
What package contains \NewDocumentCommand?
Is there a package that contains the xparse package?
Does any LaTeX compiler always contain it or is it only when using XeLaTeX?

A: Since the 2020-10-01 release, most of[1] xparse (rebranded as ltcmd) is built into the LaTeX kernel, so \NewDocumentCommand is available out of the box (see section Providing xparse in the format in the ltnews32).

1: Some argument types, considered bad practice, were considered deprecated and not moved to the kernel (see this blog post on that).  To use these argument types you still have to load the xparse package.


text:
Q: Successful PHP login does only appear after reloading the page I've a little problem with my login script. Everything works fine, but when I submit my form, the page reloads & does not show that im logged in. Now, when I reload the page again from myself, it does show that I'm logged in (The echo test). I'm really not getting behind the problem. Everything is in my index.php, I know there are other ways to do it, but this is for a very special application.
<?php
session_start();
if(!isset($_SESSION['userid'])) {
  ?>

  <?php
  // if isset POST (...) & SQL Script here
  if ($user !== false && password_verify($passwort, $user['passwort'])) {
    $_SESSION['userid'] = $user['id'];
    echo "test";
  } else {
    $errorMessage = "Die eingegebenen Login-Daten sind nicht korrekt.
Bitte versuchen Sie es erneut.

";
  }

  if(isset($errorMessage)) {
    echo $errorMessage;
  }
  ?>

    <form method="post">
      <input type="text" name="loginname" placeholder="Benutzername oder E-Mail" autofocus maxlength="64" autocapitalize="off" autocorrect="off" spellcheck="false" required>

      <input type="password" name="passwort" placeholder="Passwort" maxlength="64" autocorrect="off" required>

      <input type="submit" value="Anmelden">

    </form>

  <?php
} else if(isset($_SESSION['userid'])) {
  $userid = $_SESSION['userid'];
  echo "Hallo User: ".$userid;
}
?>

Okay so I think I found my mistake.
When I load the page the first time -> No userid is set.
When I submit the form -> No userid is set.
When the Script now comes to if(isset()) it does set a userid.
Now a userid is set, but logically it now ignores the else if statement.
Has anyone a nice workaround? Because I would really like to stay on the main page. (Also no AJAX)

A: Okay so I've found a solution to my problem.
If Login is set -> Show no Form
If Login is set and correct -> Show the User Panel
If Login is set, but incorrect -> Show Form
If Login is not set -> Show Form
To round things up, simply include all the other stuff. (In this case login.php)
<?php
session_start();
if(!isset($_SESSION['userid'])) {
  if(isset($_POST["loginname"]) && isset($_POST["passwort"])) {

    //  SQL Script here

    if ($user !== false && password_verify($passwort, $user['passwort'])) {
      $showFormular = false;
      $_SESSION['userid'] = $user['id'];
    } else {
      $showFormular = true;
      $errorMessage = "Die eingegebenen Login-Daten sind nicht korrekt.
Bitte versuchen Sie es erneut.

";
    }
  } else {
    $showFormular = true;
  }

} else if(isset($_SESSION['userid'])) {
  $showFormular = false;
}

if ($showFormular) {
  include "login.php";
} else {
  $userid = $_SESSION['userid'];
  echo "Hallo User: ".$userid;
}
?>


text:
Q: How to implement Inheritance concept in javascript? I recently started learning JavaScript. but i don't have any Project Experience. Recently attended Interview on JavaScript:
He asked one question about Inheritance: should be look like this:
I need One Method Called Vehicle and another two Methods Like one is Two-Wheeler and another one four-wheeler Method.
If I create Instance for those two methods like Below
var two-wheeler1 = new two-wheeler("Shine","125 kph") ;

another instance is like below
var four-wheeler1 = new four-wheller("audi","1000kph");

if I print the
 two-wheeler1.getWheeles()  //it should print 2 wheels

If i print the
four-wheeler1.getWheeles() //it Should print 4 Wheels

How to achieve this. Could you please any one help me?

A: Presumably the interviewer and his company is programming in modern JS (ES6, or TypeScript). If not, you should probably find another company to interview. ES6 provides nice clean syntax for defining classes and inheritance relationships:
class Vehicle {
  constructor(brand, kmp) {
    this.brand = brand;
    this.kmp = kmp;
  }

  getWheels() { return `${this.nWheels} wheels`; }
}

class TwoWheeler extends Vehicle {
  constructor(brand, kmp) {
    super(brand, kmp);
    this.nWheels = 2;
  }
}

class FourWheeler extends Vehicle {
  constructor(brand, kmp) {
    super(brand, kmp);
    this.nWheels = 4;
  }
}

By the way, in the rest of the world we call two-wheelers "motorcycles" or "scooters", and four-wheelers "cars".

A: Please review following code to under stand better OOP and Inheritance in JS:
function twoWheeler(brand, kmp) {
   this.brand=brand;
   this.kmp=kmp;
   this.getWheeles=function() {
     return "2 wheels"
   };
   this.getVehicleInfo=function() {
     return "Brand Name: " + this.brand + " Speed: " + this.kmp + " Type: 2   wheeler."
   };
  }

 function fourWheller(brand, kmp){
   this.brand=brand;
   this.kmp=kmp;
   this.getWheeles=function() {
     return "4 wheels"
   };
   this.getVehicleInfo=function() {
      return "Brand Name: " + this.brand + " Speed: " + this.kmp + " Type: 4 wheeler."
    };
  }

  fourWheller.fourWheller= new twoWheeler();
  fourWheller.prototype.constructor=fourWheller;

  var twoWheeler1 = new twoWheeler("Shine","125 kph");
  var fourWheller1 = new fourWheller("Audi","1000kph");

  console.log(twoWheeler1.getWheeles())
  console.log(fourWheller1.getWheeles())

  console.log(twoWheeler1.getVehicleInfo())
  console.log(fourWheller1.getVehicleInfo())


text:
Q: jquery mobile does not execute the Script on the response of ajax request I'm working on jQuery Mobile and currently stumbled upon a road block
On render to "task" index page after successfully creating the "Task"(I accordance with rails App) the index page compromise of ul#listview with count bubble  some thing of this is kind  . On the beneath the page there is the script to to get the count  as seen in the bubble example (mention above) but it seem that script never execute.
Here is the Code:
partials  => _index.html.erb

Tasks

        My Task

        All Task

I have also tried:
$(document).ready(function() { // above function // }) ,
    $("#task").live("pagecreate",function(){ // above function // })
    $("#task").live("pageshow",function(){ // above function // })
    $("#task").live("pagebeforecreate",function(){ // above function // })

But it seem not even the alert is also not executed.
Regards
Viren Negi

A: You are missing a closing
 tag. But even without this works OK for me.
You don't have a template/layout with another data-role=page in it do you?
This code works for me (including the missing UL)
<!DOCTYPE html>

    <title>Test</title>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />

</script>

Tasks

        My Task

        All Task

A: There are 2 solution for above problem I manage to find out
SOLUTIONS

*

*Remove the Page from the dom  through pagehide event so that there is only one dom in the page with same dom id .
something like this

$('#car_list').live('pagehide',function() {
      $(this).remove();

    });

(The approach has a serious caveat if you have jquery-mobile back functionality enable. It might land you on page whose back page would have been removed by the page hide event living the user in no man land situation . Plus to remove and download a page again just because the  bubble count got change in the page is a very hard trade off that where the second solution worked for me)

*

*This solution defined the global variable on the page and every time the get_count method is called it check whether the global variable is define if yes update the current page with count just the way the old page is updated
function get_count() {
   $.ajax( {
         url:'/get_count.json',
         dataType : "json",
         success : function(result) {
           $.each(['fer','lam','fia','cor','mer'],function(index,value) {
              console.log(window.reloaded);
              // the below if statement will only execute for the second time
              if (window.reloaded && typeof(window.reloaded) != "undefined") {
                console.log("hello");
                $(".ui-page-active").find("#"+value).text(result[value])
              }
              $("#"+value).text(result[value]);
           })
           window.reloaded = true ;
         }
     });
   }

Update the code with the 2nd solution in heroku app too.
Accepting this as valid answer until some provide more better way to achieve the same


text:
Q: (Woocommerce) How to add a custom page between cart and checkout with a file upload field per product item in the cart? I am using Woocommerce.
I want to add a custom page in between the cart and checkout page. In this custom page, I want to show a file upload field per product item in the cart. This has to tie into the order page in the admin.
Additionally, I also want to add some HTML depending on the product variation in the cart.
If product variation ID147 is in cart, show HTML "Link for ID147".
If product variation ID236 is in cart, show HTML "Link for ID236".
I have somewhat managed to complete the first part which is to add a custom page in between the cart and checkout.
add_action('woocommerce_proceed_to_checkout', 'change_proceed_to_checkout');

function change_proceed_to_checkout() {
    remove_action('woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20);
    add_action('woocommerce_proceed_to_checkout', 'stan_button_proceed_to_upload_artwork_page', 20);
}

function stan_button_proceed_to_upload_artwork_page() {
    $button_name = esc_html__('Custom page step', 'woocommerce');
    $button_link = get_permalink(1636);
    ?>

    <a href="<?php echo $button_link;?>" class="btn">
        <?php echo $button_name; ?>
    </a>
    <?php
}

Any help would be much appreciated.
Thanks.


text: Q: cabal doesn't seem to register installed packages I just upgraded GHC from version 8.10.2 to 8.10.3 on Windows 10 using Chocolatey, and cabal doesn't seem to work properly. I tried to install ieee754 for use with Agda, the installation went through without problem. The compiled files are in %AppData%\cabal\store, but neither cabal list --installed nor ghc-pkg list outputs it as an installed package, and import Numeric.IEEE in ghci results in an error. However, cabal outputs Up to date upon rerunning cabal install ieee754, so apparently cabal knows the package is installed, but somehow did not register it as installed. Any idea how to fix this?


text:
Q: Sufficient statistic under transformation I just read a weird question when I'm learning sufficient statistic myself. It says whether the sufficient statistic of variance and standard deviation are the same under normal distribution with known $\mu$.
The first idea comes like, they are the same since if the statistic of variance is sufficient, then it must be sufficient for the square root. And I think factorisation theorem can show this as well.
However, I just finish the learning about unbiased estimator. It says unbiasedness is not preserved under transformation. Like sample variance is unbiased while sample standard deviation is biased. Quite confused if the transformation will affect the sufficient statistic.
The question may be stupid since I just start to learn statistic. Any insights would be appreciated.

A: You seem confused about the concepts of sufficiency and unbiasedness. To be clear: unbiasedness plays no part in the definition of sufficiency. The reason is simple: If $T$ is sufficient for some parameter $\theta$ indexing a distribution family, then so is also $T/10, 10T, 1000T$ and a lot of other one-to-one functions of $T$. Al those functions cannot be unbiased at the same time (as estimators of $\theta$ or of some function of $\theta$.) When you are clear about this you can think again, starting afresh, on your first paragraph question.


text:
Q: Find parameter $k_f$ for which steady-state error equals $0$
$u(t)=t, G_0(s)=\frac{k_p}{s}, G_R(s)=k_f$
Find parameter $k_f$ for which steady-state error equals 0
Finding $E(s)$
$$E(s) = U(s)*\frac{1}{1+\frac{k_p}{s}*k_f} = \frac{1}{s^2+k_pk_f*s}$$
Steady-state error:
$$\lim\limits_{s \to 0} s*\frac{1}{s^2+k_pk_f*s}=\lim\limits_{s \to 0} \frac{1}{s+k_pk_f}=\frac{1}{k_pk_f}$$
So there's no $k_f$ that exist that would fulfill the requirements, but apparently that's wrong somehow.
Could anyone tell me where I have made a mistake?


text:
Q: How can I remove duplicates from one List that are found in another? This is for .NET 2.0, so I cannot use LINQ.
I have a bit of an interesting problem.
I am merging two lists of custom type "Article".
The below code does the job nicely:
List<Article> merge = new List<Article>(GetFeatureArticles());
merge.AddRange(result);

return merge;

GetFeatureArticle has only 2 items that are the first two elements in the merged list.
"result" is large and its elements trail "GetFeatureArticle"'s elements.
The problem is that I need to compare the list returned from "GetFeatureArticles()"
to the list in "result" and, if there is a match, remove the matched item in result, not
in "GetFeatureArticles". Both lists are of type List<Article>.
I am limited by C# 2.0 unfortunately.
Thank you.
EDIT EDIT EDIT EDIT EDIT EDIT EDIT EDIT EDIT EDIT EDIT EDIT
This is the implementation I ultimately went with as GetFeaturedArticles()
will always be two items:
List<Article> k = new List<Article>(GetFeatureArticles());

            foreach (Article j in k)
            {
                for( int i = 0; i < tiles.Count; i++ )
                {
                    if (j.ID == tiles[i].ID)
                        tiles.Remove(tiles[i]);
                }
            }

            k.AddRange(tiles);

            return k;

A: Assuming you have some sort of object equality implemented.
var listA = new List<Article> {a, b, c, d};
var listB = new List<Article> {e, f}; //Where e, f are equal to b, c in a.
listA.RemoveAll(listB.Contains);

A: use
List<Article> g = new List<Article>(GetFeatureArticles());

foreach (Article a in g)
{
if (result.Contains (a))
    result.Remove (a);
}

g.AddRange (result);

return g;

EDIT - as per comments:
I assume that Article is a reference type and is implemented with suitable Equals and GetHashCode methods respectively - otherwise the above would only work for equal references (= "same object in both Lists")...

A: returnList = returnList.Union(ListToAdd).ToList();

or if combinging multiple lists of items...
foreach (List<ListItem> l in ListsToAdd)
{
    returnList = returnList.Union(l).ToList();
}

A: Build a Dictionary from the result set. Then:
foreach (Article a featuredArticles)
{
    if (resultsDictionary.ContainsKey(a.Key))
    {
        resultsDictionary.Remove(a.Key);
    }
}

Then convert the dictionary back to a list.

A: This works against .NET Framework 2.0:
var featured = new List<Article>(GetFeaturedArticles());

result.RemoveAll(featured.Contains);

result.InsertRange(0, featured);

return result;


text:
Q: How do I Embed a font with my C# application? (using Visual Studio 2005) What is the best way to embed a truetype font within the application i'm developing? Basically i want to make sure a particular font is available to my application when installed on another machine. I have the *.ttf font file and just need a way of embedding it or automatically installing it when the application is run.
Do i need to set the installation program to install the font during installation or can i dynamically load the font during runtime of the application? In fact both would be nice to know.
The application is being developed in C# using .NET 2.0.

A: This blog post should help you.
Basically you add the font as an embedded resource then load it into a PrivateFontCollection object.

A: Here's Will's answer, translated to C# (untested):
PrivateFontCollection pfc = new PrivateFontCollection();

using (Stream fontStream = GetType().Assembly.GetManifestResourceStream("Alphd___.ttf"))
{
    if (null == fontStream)
    {
        return;
    }

    int fontStreamLength = (int) fontStream.Length;

    IntPtr data = Marshal.AllocCoTaskMem(fontStreamLength);

    byte[] fontData = new byte[fontStreamLength];
    fontStream.Read(fontData, 0, fontStreamLength);

    Marshal.Copy(fontData, 0, data, fontStreamLength);

    pfc.AddMemoryFont(data, fontStreamLength);

    Marshal.FreeCoTaskMem(data);
}

along with their Paint() method:
protected void Form1_Paint(object sender, PaintEventArgs e)
{
    bool bold = false;
    bool italic = false;

    e.Graphics.PageUnit = GraphicsUnit.Point;

    using (SolidBrush b = new SolidBrush(Color.Black))
    {
        int y = 5;

        foreach (FontFamily fontFamily in pfc.Families)
        {
            if (fontFamily.IsStyleAvailable(FontStyle.Regular))
            {
                using (Font font = new Font(fontFamily, 32, FontStyle.Regular))
                {
                    e.Graphics.DrawString(font.Name, font, b, 5, y, StringFormat.GenericTypographic);
                }
                y += 40;
            }
            if (fontFamily.IsStyleAvailable(FontStyle.Bold))
            {
                bold = true;
                using (Font font = new Font(fontFamily, 32, FontStyle.Bold))
                {
                    e.Graphics.DrawString(font.Name, font, b, 5, y, StringFormat.GenericTypographic);
                }
                y += 40;
            }
            if (fontFamily.IsStyleAvailable(FontStyle.Italic))
            {
                italic = true;
                using (Font font = new Font(fontFamily, 32, FontStyle.Italic))
                {
                    e.Graphics.DrawString(font.Name, font, b, 5, y, StringFormat.GenericTypographic);
                }
                y += 40;
            }

            if(bold && italic)
            {
                using(Font font = new Font(fontFamily, 32, FontStyle.Bold | FontStyle.Italic))
                {
                    e.Graphics.DrawString(font.Name, font, b, 5, y, StringFormat.GenericTypographic);
                }
                y += 40;
            }

            using (Font font = new Font(fontFamily, 32, FontStyle.Underline))
            {
                e.Graphics.DrawString(font.Name, font, b, 5, y, StringFormat.GenericTypographic);
                y += 40;
            }

            using (Font font = new Font(fontFamily, 32, FontStyle.Strikeout))
            {
                e.Graphics.DrawString(font.Name, font, b, 5, y, StringFormat.GenericTypographic);
            }
        }
    }
}

A: Its easier than this seems; you can embed the font as a resource in your app and access it as a strongly-typed property within the Properties namespace of your app.  But the given link should be a good starting point.

For the VB-disabled:
Add the font as a resource in your application.  Call the resource MyFontLol.  You can access this resource (as a byte array) from Properties.Resources.MyFontLol.
I haven't tested the following, but it appears to be workable:
public void LoadMyFontLolKThx()
{
    // get our font and wrap it in a memory stream
    byte[] myFont = Properties.Resources.MyFontLol;
    using (var ms = new MemoryStream(myFont))
    {
        // used to store our font and make it available in our app
        PrivateFontCollection pfc = new PrivateFontCollection();
        // The next call requires a pointer to our memory font
        // I'm doing it this way; not sure what best practice is
        GCHandle handle = GCHandle.Alloc(ms, GCHandleType.Pinned);
        // If Length > int.MaxValue this will throw
        checked
        {
            pfc.AddMemoryFont(
                handle.AddrOfPinnedObject(), (int)ms.Length);
        }
        var font = new Font(pfc.Families[0],12);

        // use your font here
    }
}

One last note.  The PFC stores the font as a GDI+ font.  These aren't compatible with some forms controls.  From the docs:

To use the memory font, text on a
  control must be rendered with GDI+.
  Use the
  SetCompatibleTextRenderingDefault
  method, passing true, to set GDI+
  rendering on the application, or on
  individual controls by setting the
  control's UseCompatibleTextRendering
  property to true. Some controls cannot
  be rendered with GDI+.

A: it might not be the best way but couldn't you just include the font with your resources and then copy it to the font's folder on the windows dir?


text:
Q: Removing CAKeyframeAnimation doesn't release the memory I'm adding a CAKeyframeAnimation to the layer of an ImageView for representing the animation of an image:
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"contents"];
animation.values = arrayOfImages;
[animation setRemovedOnCompletion:YES];
animation.delegate = self;
[animation setValue:delegate forKey:@"AnimatedImageViewDelegate"];
animation.repeatCount = repeatCount;
animation.fillMode = kCAFillModeForwards;
animation.calculationMode = kCAAnimationDiscrete;
[animation setValue:animationName forKey:@"name"];

When I want to start the animation I call:
animation.duration = duration;
[self.layer addAnimation:animation forKey:animationName];
[self.layer setContents:[animation.values lastObject]];

When the animation finishes, I want to completely remove it and release its memory.
[self.layer removeAllAnimations];
[self.layer removeAnimationForKey:animationName];

Doing this, and using Instruments-Activity Monitor, the memory is not relased unless I release the complete imageView.
How can I release that animation memory without destroy the UIImageView???

A: You are using the convenience method to instantiate the object. So you will not have control over when the object is actually released. To have control over that, you will need to alloc the object and dealloc it yourself:
Create the instance:
CAKeyframeAnimation *animation = [[CAKeyframeAnimation alloc] init];

Then after the animation finished call after your remove lines:
[animation release];

A: First off, if this is an iOS 5 project ARC should be handling your releases for you - which is really nice!
Now -- I used a lot of animations in my project and noticed similar bursts in the heap. My guess is that CA caches a lot of what is animated internally. To confirm those items are actually being autoreleased I recommend setting up a test for allocations or leaks with the instruments tool and do the following:

*

*Determine a situation where you would trigger and the animation.

*Mark the heap after the animation completes.

*Trigger something that would take you to another view where the objects should have been removed.

*Repeat the process in steps 1-2-3 as many times as you want. I normally do it about 10 times or so.

That's it.. basically animate - mark - undo - animate - mark. You should see the heapshots decreasing to 0 or almost 0 if CoreAnimation is autoreleasing objects correctly!
For more info on how to test like this take a look at this article:
http://www.friday.com/bbum/2010/10/17/when-is-a-leak-not-a-leak-using-heapshot-analysis-to-find-undesirable-memory-growth/

A: I have same problem about memory with CAKeyframeAnimation when set values = array of images.
And i see that the problem i get is that the images are inited by [UIImage imagewithname:] which is cached to memory by default. So my solution is change to use  [UIImage imageWithContentsOfFile:]
Hope this helpful.

A: In my case the CAKeyframeAnimation added to an imageView and container view is not getting released even that its not on the view hierarchy.
It turned out that the CAKeyframeAnimation delegate was holding it. I just removed the delegate:
beatAnimation.delegate = nil


text:
Q: How to remove the unwanted vertical space? I'm using Exam class to create solutions, but the flaign* environment does not align my equation with the \part. How do I make them align?
\documentclass[a4paper, twoside, 12pt]{exam}

\usepackage{amssymb,amsmath}
\usepackage{graphicx}
\marksnotpoints
\pointsinrightmargin
\bracketedpoints
\printanswers

\begin{document}
\begin{questions}

\question  The functions $f$ and $g$ are defined by
\begin{align*}
f : x &\mapsto 4-x^2, \ \ x \in \mathbb{R} \\
g : x &\mapsto \frac{1}{x-4}, \ \ x\in \mathbb{R}, \ x \not= 4.
\end{align*}
\begin{parts}
   \part[3] Define $f\circ g$ in a similar form.
\end{parts}

\begin{solution}
\begin{parts}
    \part
        \begin{flalign*}
            fg(x) &= f(g(x)) &\\
            &=f(\frac{1}{x-4}) \\
            &= 4 - \frac{1}{(x-4)^2}
        \end{flalign*}
\end{parts}
\end{solution}

Specifically, my problem is here in this image:

A: This might be a good application for TABstacks, which can be placed inline, unlike align environments.
\documentclass[a4paper, twoside, 12pt]{exam}

\usepackage{amssymb,amsmath}
\usepackage{tabstackengine}
\stackMath
\setstackgap{S}{5pt}% GAP BETWEEN ADJACENT STACKED EQUATION ROWS
\usepackage{graphicx}
\marksnotpoints
\pointsinrightmargin
\bracketedpoints
\printanswers

\begin{document}
\begin{questions}

\question  The functions $f$ and $g$ are defined by
\begin{align*}
f : x &\mapsto 4-x^2, \ \ x \in \mathbb{R} \\
g : x &\mapsto \frac{1}{x-4}, \ \ x\in \mathbb{R}, \ x \not= 4.
\end{align*}
\begin{parts}
   \part[3] Define $f\circ g$ in a similar form.
\end{parts}

\begin{solution}
\begin{parts}
    \part
        \alignShortunderstack{
            fg(x) =& f(g(x)) \\
            =&f(\dfrac{1}{x-4}) \\
            =& 4 - \dfrac{1}{(x-4)^2}
        }
\end{parts}
\end{solution}
\end{questions}
\end{document}

If one always wants to process TABstack arguments in \displaystyle, this undocumented code can be added to the preamble
\makeatletter
\renewcommand\TAB@delim[1]{\displaystyle#1}
\makeatother

A: You have to use inline math here. Maybe like the following:
% arara: pdflatex

\documentclass[a4paper, twoside, 12pt]{exam}
\usepackage{amssymb,mathtools}
\marksnotpoints
\pointsinrightmargin
\bracketedpoints
\printanswers

\begin{document}
    \begin{questions}
        \question  The functions $f$ and $g$ are defined by
        \begin{alignat*}{2}
        f : x &\mapsto 4-x^2,  &&\quad x\in \mathbb{R} \\
        g : x &\mapsto \frac{1}{x-4}, &&\quad x\in \mathbb{R} \vee x \not= 4.
        \end{alignat*}
        \begin{parts}
            \setcounter{partno}{2} % for demo only
            \part[3] Define $f\circ g$ in a similar form.
        \end{parts}
        \begin{solution}
            \begin{parts}
            \setcounter{partno}{2} % for demo only
                \part
                $\!\begin{aligned}[t]
                f(x)\circ g(x) &= f(g(x)) &\\
                &= f\Bigl(\frac{1}{x-4}\Bigr) \\
                &= 4 - \frac{1}{(x-4)^2}
                \end{aligned}$
            \end{parts}
        \end{solution}
\end{questions}
\end{document}


text:
Q: Are User-specific environment variables in Windows 7 stored locally or in the profile I have some libraries like Qt and OpenCV which are installed locally on several machines. The environment variables such as QTDIR and QMAKESPEC are user environment variables. Will these be stored seperately on each machine or are these variables now part of the user profile, i.e. a certain user will always have the same QTDIR on all machines?

A: They're stored in the user's registry, at HKEY_CURRENT_USER\Environment, which is part of the profile.


text:
Q: This foreach has a cast in the middle, can it be translated to linq? Resharper is always asking me to change foreach loops into linq, and I try to. This one stumped me.
foreach(var fileEnvironment in fileEnvironmentSection.FileEnvironmentList) {
    var element = fileEnvironment as FileEnvironmentElement;
    if(element == null) {
        //Not the expected type, so nothing to do
    } else {
        //Have the expected type, so add it to the dictionary
        result.Add(element.Key, element.Value);
    }
}

The fileEnvironment is returned as an object from the configuration section. That's the reason for the cast.

A: You can use the OfType operator:

Filters the elements of an IEnumerable based on a specified type.

foreach(var element in fileEnvironmentSection.FileEnvironmentList
                                             .OfType<FileEnvironmentElement>())
{
    result.Add(element.Key, element.Value);
}

LINQ isn't going to help with the body of the loop since it's mutating an existing dictionary - LINQ is normally used for creating new data rather than modifying existing data.
If you don't mind returning a new dictionary here, you could do:
var newResult = fileEnvironmentSection.FileEnvironmentList
                                      .OfType<FileEnvironmentElement>()
                                      .ToDictionary(element => element.Key,
                                                    element => element.Value);


text:
Q: I installed Ubuntu only, not dual-boot. But now I can't find my drives I recently clean installed Ubuntu without dual boot, so everything was erased, but now I can't seem to find where my C and D drives are located.
Here are the results of some commands that I tried:
sudo fdisk -l
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track , 19457 cylinders, total 312581808 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/0 size (minimum/optimal): 512 bytes / 512 bytes
Disk identifiers: 0x000cf109

Device     Boot        Start         End       Blocks    Id  Systems
/dev/sda1   *          2048       308457471  154227712   83  Linux
/dev/sda2         308459518       312580095   2060289     5  Extended
/dev/sda5         308459520       312580095   2060288    82 Linuxswap/Solaris

mount
/dev/sda1 on / type ext4 (rw, errors = remount - ro)
proc on /proc type proc (rw,noexec, nosuid, nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/cgroup type tmpfs (rw)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
none on /dev type devtmpfs (rw, mode = 0755)
devpts on /dev/pts type devpts (rw, noexec, nosuid, gid = 5, mode = 0620)
tmpfs on /run type tmpfs (rw,noexec, nosuid, size = 10%, mode = 0755)
none on /run/lock type tmpfs (rw, noexec, nosuid, nodev, size = 5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
none on /run/user type tmpfs (rw,noexec,nosuid,nodev,size=104857600,mode=0755)
none on /sys/fs/pstore type pstore (rw)
systemd on /sys/fs/cgroup/systemd type cgroup (rw,noexec,nosuid,nodev,none,name=systemd)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid, nodev, user = dangmanhtruong)

sudo lsblk
NAME              MAJ:MIN   RM      SIZE    RO    TYPE   MOUNTPOINT
sda                 8:0      0     149.1G    0    disk
--sda1              8:1      0     147.1G    0    part   /
--sda2              8:2      0         1K    0    part
--sda5              8:5      0         2G    0    part   [swap]

Please help me thank you very much

A: There is no C: partition and no D: partition anymore. As you said that you installed Ubuntu by choosing the option to use the whole disk for Ubuntu, of course the disk was erased completely.
The C: partition on which most probably the Windows operating system was located and the D: partition on which most probably your personal data was located before are gone forever.
Let's explain it as easy as possible to understand the difference ... your new disk layout now is :
sda1 (formerly C:) used for Ubuntu and sda2 / sda5 (formerly D:) used for linux-swap


text:
Q: Is there a way to use the name of the imported file in naming a new created file? In my program I import a certain file, at the end I create a file in which I save the outputs. I would like to use the name of the imported file (with some additions) as the name of the newly created file.
Since I have a large amount of files to import, I would like to do this in order to have a better overview of which files were created based on which files.
For example: I open a file with file=open('summer.txt') and I would like to use the 'summer' of the original file and just add the year, the name of the new file would be 'summer2020.txt'.
I would like to automatically detect the name of the imported file, add the year and that would be the name of my new file. (the addition to the name ('2020') would be the same for every opened file)
I' m still new to python, so I don't know if this is possible or if there is a better way of doing it. Thank you very much for any help!

A: Here's an example to automatically get the current year:
from datetime import datetime
curdate = datetime.now()
curyear = str(curdate.year)
file = open('summer'+curyear+'.txt')

A: If you are using Python 3.9, you can use pathlib and the new with_stem method
file_path=Path('summer.txt')
new_file_path = file_path.with_stem(file_path.stem+'2020')

Advantage of using pathlib is that it supports multiple platforms (win/osx/linux) and their different ways of specifying paths. Also allows you to easily split the file name in to the stem summer and suffix .txt.
For versions of python like 3.6.5, you can do the following instead
new_file_path = file_path.with_name(f"{file_path.stem}2020{file_path.suffix}")

A: As you have many files you maybe want something like
import glob, shutil
myfiles = glob.glob("*.txt")
for fname in myfiles:
    basename = fname[:-4] # drop .txt at the end
    newname = f"{basname}2020.txt"
    shutil.copy(fname, newname)


text:
Q: When to lock an object in a game I'm writing a game in Java where each game object has a number of properties, but these can all be changed in one of two ways:

*

*Every second, a tick runs which may automatically cause a change.

*Users can send a request to the server and make a modification themselves.

Should I lock the Object while the tick is running, or is this not beneficial? I was just concerned, for example, if the user made a change to an object while the tick was deleting it.

A: Whenever two or more threads need to change the same object and potentially at the same time, you need to ensure that the object remains in a consistent state making it synchronized.
Apparently, it's not only about the object, but also its containing object, because you mention "if the user made a change to an object while the tick was deleting it".
Alternative
Another approach could be to implement object update requests by using the command design pattern.  You could then maintain a shared queue of commands that would be fed by the web server and by the tick. You could then consume the queue in a single update thread executing one command at a time, thus avoiding conflicts.


text:
Q: Trying to remove with if in python but not working? I have used the below code to remove 20 from list1
list1 = [5, 20, 15, 20, 25, 50, 20]
if 20 in list1:
    list1.remove(20)

It doesn't remove instead if i do it this way first:
list1.remove(20)

but the above line only removes the first occurrence of it but when i run the if loop again, it removes the last occurrence too.
Why if loop doesn't work without that?
list1 = [5, 20, 15, 20, 25, 50, 20]
a = 20
if a in list1:
    list1.remove(a)

>>> print(list1)
[5, 15, 20, 25, 50, 20]


text:
Q: BeautifulSoup string How do I get the price £500,000 out of this HTML?

From
        £500,000

A: Use the .next_sibling result of finding elements with a price-modifier class perhaps?
print unicode(soup.find(class_='price-modifier').next_sibling)

A: Its not a very elegant solution, but its an alternative to Martijn's suggestion:
p = soup('p',{'id':'price-detail'})[0]
modifier = p('span',{'class':'price-modifier'})[0].contents[0]
price = p.findAll(text=True)

if modifier in price:
    price.remove(modifier)

print ' '.join(x for x in price)


text:
Q: Trying to prove $2( \sqrt{n+1}-\sqrt n )< \frac{1}{\sqrt n}<2( \sqrt{n}-\sqrt {n-1})$ and use this to prove... I am trying to prove this $2( \sqrt{n+1}-\sqrt n )< \frac{1}{\sqrt n}<2( \sqrt{n}-\sqrt {n-1})$ if $n \ge 1$ and using this to prove $2\sqrt{m}-2<\sum^m_{n=1} \frac{1}{\sqrt n}<2( 2\sqrt{m}-1)$ if $m\ge 2$ and in particular i want to show that $m=10^6$ the last inequality is between 1998 and 1999
i am using prove by induction ,first ,for the first statement but i having trouble establish for n=1 and i am confuse how to prove if n is true by hypothesis then n+1.for the second part i didn't get to that part
Edit
reading the answers and comments bellow now i find myself trying to prove the second part that is prove $2\sqrt{m}-2<\sum^m_{n=1} \frac{1}{\sqrt n}<2( 2\sqrt{m}-1)$.
My attempt
$2( \sqrt{n+1}-\sqrt n )< \frac{1}{\sqrt n}<2( \sqrt{n}-\sqrt {n-1})\Leftrightarrow \sum^m_{n=1}2( \sqrt{n+1}-\sqrt n )< \sum^m_{n=1}\frac{1}{\sqrt n}<\sum^m_{n=1}2( \sqrt{n}-\sqrt {n-1})\Leftrightarrow $
i assume this to be true
$2\sum^m_{n=1}( \sqrt{n+1}-\sqrt n )< \sum^m_{n=1}\frac{1}{\sqrt n}<2\sum^m_{n=1}( \sqrt{n}-\sqrt {n-1})\Leftrightarrow $
now using telescoping that is $\sum^m_{n=1} (a_n - a_{n-1})=(a_m - a_0)$ i can not make sense of it

A: Hint: Observe that $$\sqrt{n+1}-\sqrt{n}=\dfrac{\left(\sqrt{n+1}-\sqrt{n}\right)\left(\sqrt{n+1}+\sqrt{n}\right)}{\sqrt{n+1}+\sqrt{n}}.$$

A: For a positive decreasing sequence $(a_n)$, we can write the inequality $$\int\limits_{k+1}^{n+1}a(x)dx\leq\sum\limits_{v=k+1}^{n}a_v\leq\int\limits_{k}^na(x)dx$$ Then, in special case, taking $a_n=\frac{1}{\sqrt{n}}$, $a(x)=\frac{1}{\sqrt{x}}$ and $k=n-1$ you get the desired result.
For the other inequality, you can take $k=0$ in the left side of the inequality above . Then take $k=1$ and add the first term $a_1=1$ in the right side.


text:
Q: asp.net application takes long to start--even after compiling I have an asp.net app on IIS 7.  It is 'pre-compiled', but I understand that IIS must still compile the assemblies the first time they're run.
Here is the problem--After I publish and deploy the application, I log in, and (as expected) it takes about 30 seconds to see the login page.  Then I visit every page so that they are compiled (I have used the 'individual file for each page' or whatever option).
So far so good.
Then 10 minutes later i log in and it's near instantaneous.   Still good and expected.
Yet the next day, my first logon takes 30 seconds or more again.  Nobody changed web.config or copied any new assemblies in the meantime--this I am sure of.
Does anyone have an idea why this is happening?  Is there an application timeout (as opposed to a session timeout)?   Is there some setting in IIS admin console that I may have left at some default that is not optimal?
Thanks for any help on this,
James

A: Yes, starting an ASP.NET application in IIS is relatively slow. How much? It depends...
It's slow again the next day because IIS shuts down apps when they are inactive for some time.
The solution is "Application Initialization". This is built-in in IIS 8 and available out-of-band as a module for IIS 7.5:
http://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-application-initialization

A: There is an Idle Time-Out on the Application Pool under Advanced Settings. Set this to 0 and the application will not stop due to inactivity.


text:
Q: Ignore a more tag when using get_the_content() This is such a simple question it seems yet I can't find a definite answer on it.
So how do you make get_the_content() obtain all the content of a post even if it has <!--more--> inside of the text which normally makes the function return after it has been used ?

A: I would just get the raw content from $post->post_content, strip the <!--more--> and then do whatever you need with the result. Just remember, $post->post_content and get_the_content() both return unfiltered text, if you need filtered content, simply apply the the_content filter to the result from those two results
EXAMPLE inside the LOOP
global $post;
$unfiltered_content = str_replace( '<!--more-->', '', $post->post_content );
// If you need filtered content returned
$filtered_content = apply_filters( 'the_content', $unfiltered_content );
// Output filtered content
echo $filtered_content;


text:
Q: How to limit a table row count and replace if found? I'm fairly new to the database queries and such and right away I find my self with a complex situation.
My DB table contains 3 columns:
_id | stringValue | timeStamp

I have 3 constraints;

*

*Max rows allowed equals 100.

*If table is full the oldest item will be removed.

*If a new item to be added matches the stringValue than only the timestamp will be updated.

I'm currently making 3 queries:

*

*Check if item already exists if it does just update it. If it doesn't just add it.

*If item did not exist check how many items are on the table

*If over 100 items remove the oldest

I'm thinking there might be a one query I can do to achieve all this... Any tips or ideas would be appreciated!

A: For the issue of insert if an item doesn't existing or updating if it does not, use "INSERT OR REPLACE INTO" for your sql statement.
For the constraint on the max number of rows, this is something you'll have to handle separately and there are a few ways you can do this.
Here's an older post to check out:
Limit an sqlite Table's Maximum Number of Rows


text:
Q: Problema ao recuperar JWT no Angular No server-side tenho um serviço utilizando Spring Security e JWT para autenticação e autorização, no client-side tenho uma SPA em Angular. O problema ocorre quando tento autenticar, pois recebo 200 como status code, mas não consigo recuperar o token.
Spring
@EnableWebSecurity
public class WebSecurity extends WebSecurityConfigurerAdapter {
  private UserDetailsService userDetailsService;
  private BCryptPasswordEncoder bCryptPasswordEncoder;

public WebSecurity(UserDetailsService userDetailsService, BCryptPasswordEncoder bCryptPasswordEncoder) {
    this.userDetailsService = userDetailsService;
    this.bCryptPasswordEncoder = bCryptPasswordEncoder;
}

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.cors().and().csrf().disable().authorizeRequests().antMatchers(HttpMethod.POST, SIGN_UP_URL).permitAll()
            .anyRequest().authenticated().and().addFilter(new JWTAuthenticationFilter(authenticationManager()))
            .addFilter(new JWTAuthorizationFilter(authenticationManager()))
            // this disables session creation on Spring Security
            .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
}

@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder);
}

@Bean
CorsConfigurationSource corsConfigurationSource() {
    final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
    CorsConfiguration config = new CorsConfiguration();
    config.setAllowCredentials(true);
    config.addAllowedOrigin("*");
    config.addAllowedHeader("*");
    config.addExposedHeader("Authorization");
    config.addAllowedMethod("OPTIONS");
    config.addAllowedMethod("GET");
    config.addAllowedMethod("POST");
    config.addAllowedMethod("PUT");
    config.addAllowedMethod("DELETE");
    source.registerCorsConfiguration("/**", config);
    return source;
}
}

AuthenticationFilter
public class JWTAuthenticationFilter extends UsernamePasswordAuthenticationFilter {
private AuthenticationManager authenticationManager;

public JWTAuthenticationFilter(AuthenticationManager authenticationManager) {
    this.authenticationManager = authenticationManager;
}

@Override
public Authentication attemptAuthentication(HttpServletRequest req,
                                            HttpServletResponse res) throws AuthenticationException {
    try {
        ApplicationUser creds = new ObjectMapper()
                .readValue(req.getInputStream(), ApplicationUser.class);

        return authenticationManager.authenticate(
                new UsernamePasswordAuthenticationToken(
                        creds.getUsername(),
                        creds.getPassword(),
                        new ArrayList<>())
        );
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

@Override
protected void successfulAuthentication(HttpServletRequest req,
                                        HttpServletResponse res,
                                        FilterChain chain,
                                        Authentication auth) throws IOException, ServletException {

    String token = Jwts.builder()
            .setSubject(((User) auth.getPrincipal()).getUsername())
            .setExpiration(new Date(System.currentTimeMillis() + EXPIRATION_TIME))
            .signWith(SignatureAlgorithm.HS512, SECRET.getBytes())
            .compact();
    res.addHeader(HEADER_STRING, TOKEN_PREFIX + token);
}

}
Angular
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import 'rxjs/add/operator/map';

@Injectable()
  export class AuthService {

 private loggedIn = false;

 constructor(private http: HttpClient) {
    this.loggedIn = !!localStorage.getItem('auth-token');
 }

 login(username, password) {
    return this.http
     .post(
       'http://localhost:7070/login',
        { "username": username, "password": password }
        ).map((res: Response) => {
       console.log(res.headers.get('Authorization'));
      }) ;
 }
}

Console
Angular is running in the development mode. Call enableProdMode() to
enable the production mode.
login.component.ts:28 TypeError: Cannot read property 'headers' of
null
at MapSubscriber.eval [as project] (auth.service.ts:20)
at MapSubscriber._next (map.js:79)
at MapSubscriber.Subscriber.next (Subscriber.js:92)
at MapSubscriber._next (map.js:85)
at MapSubscriber.Subscriber.next (Subscriber.js:92)
at FilterSubscriber._next (filter.js:90)
at FilterSubscriber.Subscriber.next (Subscriber.js:92)
at MergeMapSubscriber.notifyNext (mergeMap.js:151)
at InnerSubscriber._next (InnerSubscriber.js:25)
at InnerSubscriber.Subscriber.next (Subscriber.js:92)

A: Solução
Importar o HttpResponse
import { HttpResponse } from '@angular/common/http';
Substituir a classe de Response para HttpResponse<any>
Método modificado
login(username, password) {
return this.http
 .post(
   'http://localhost:7070/login',
    { "username": username, "password": password }
    ).map((res: HttpResponse<any>) => {
   console.log(res.headers.get('Authorization'));
  }) ;

}