text:
Q: Build RocksDB static library using vcpkg and custom gcc on Windows I am trying to create Kotlin/Native bindings for RocksDB. This requires that RocksDB is compiled using gcc and g++ version 9.2.0, because that is the only version that Kotlin/Native supports. If I build using 9.5.0 or later, then I get errors:
const: error: undefined reference to 'gettid'

The gettid wrapper was added to glibc 2.30, but Kotlin/Native uses glibc 2.15 when linking.
Since RocksDB has a Makefile that works on Linux and macOS, I am able to successfully build compatible RocksDB libraries. However, I am encountering problems when trying to build RocksDB on Windows.
The RocksDB wiki explains how to use vcpkg to build RocksDB on Windows, which is quite easy. However, vcpkg will use the system gcc, unless specially instructed otherwise using a special toolchain cmake file.
Updating vcpkg to use gcc 9.2.0
vcpkg will accept a custom cmake toolchain file where the location of gcc and g++ can be defined, so I have created that file:
# D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/konan-toolchain.cmake
set(CMAKE_C_COMPILER   "C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/gcc.exe")
set(CMAKE_CXX_COMPILER "C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/g++.exe")
set(CMAKE_VERBOSE_MAKEFILE ON)

And then set the file location using the VCPKG_CHAINLOAD_TOOLCHAIN_FILE property in the vcpkg triplet file I use to build RocksDB on Windows:
echo "set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE \"D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/konan-toolchain.cmake\")" \
>> ./triplets/community/x64-mingw-static.cmake

vcpkg install fails - "not able to compile a simple test program"
vcpkg seems to be correctly set up to use Kotlin/Native's gcc 9.2.0, but the vcpkg install fails:
Detecting compiler hash for triplet x64-windows...
Detecting compiler hash for triplet x64-mingw-static...
error: while detecting compiler information:
The log file content at "D:\a\kotlin-on-the-rocksdb\kotlin-on-the-rocksdb\vcpkg\buildtrees\detect_compiler\stdout-x64-mingw-static.log" is:
-- Found external ninja('1.10.2').
-- Configuring x64-mingw-static
CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:112 (message):
    Command failed: C:/ProgramData/chocolatey/bin/ninja.exe -v
    Working Directory: D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/buildtrees/detect_compiler/x64-mingw-static-rel/vcpkg-parallel-configure
    Error code: 1
    See logs for more information:
      D:\a\kotlin-on-the-rocksdb\kotlin-on-the-rocksdb\vcpkg\buildtrees\detect_compiler\config-x64-mingw-static-rel-CMakeCache.txt.log
      D:\a\kotlin-on-the-rocksdb\kotlin-on-the-rocksdb\vcpkg\buildtrees\detect_compiler\config-x64-mingw-static-out.log

Call Stack (most recent call first):
  scripts/cmake/vcpkg_configure_cmake.cmake:310 (vcpkg_execute_required_process)
  scripts/detect_compiler/portfile.cmake:18 (vcpkg_configure_cmake)
  scripts/ports.cmake:147 (include)

error: vcpkg was unable to detect the active compiler's information. See above for the CMake failure output.
Error: Process completed with exit code 1.

The log file contains more details:
[1/1] "C:/Program Files/CMake/bin/cmake.exe" -E chdir ".." "C:/Program Files/CMake/bin/cmake.exe" "D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/scripts/detect_compiler" "-G" "Ninja" "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_INSTALL_PREFIX=D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/packages/detect_compiler_x64-mingw-static" "-DCMAKE_MAKE_PROGRAM=C:/ProgramData/chocolatey/bin/ninja.exe" "-DCMAKE_SYSTEM_NAME=MinGW" "-DBUILD_SHARED_LIBS=OFF" "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/konan-toolchain.cmake" "-DVCPKG_TARGET_TRIPLET=x64-mingw-static" "-DVCPKG_SET_CHARSET_FLAG=ON" "-DVCPKG_PLATFORM_TOOLSET=external" "-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON" "-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=TRUE" "-DCMAKE_VERBOSE_MAKEFILE=ON" "-DVCPKG_APPLOCAL_DEPS=OFF" "-DCMAKE_TOOLCHAIN_FILE=D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/scripts/buildsystems/vcpkg.cmake" "-DCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION=ON" "-DVCPKG_CXX_FLAGS=" "-DVCPKG_CXX_FLAGS_RELEASE=" "-DVCPKG_CXX_FLAGS_DEBUG=" "-DVCPKG_C_FLAGS=" "-DVCPKG_C_FLAGS_RELEASE=" "-DVCPKG_C_FLAGS_DEBUG=" "-DVCPKG_CRT_LINKAGE=dynamic" "-DVCPKG_LINKER_FLAGS=" "-DVCPKG_LINKER_FLAGS_RELEASE=" "-DVCPKG_LINKER_FLAGS_DEBUG=" "-DVCPKG_TARGET_ARCHITECTURE=x64" "-DCMAKE_INSTALL_LIBDIR:STRING=lib" "-DCMAKE_INSTALL_BINDIR:STRING=bin" "-D_VCPKG_ROOT_DIR=D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg" "-DZ_VCPKG_ROOT_DIR=D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg" "-D_VCPKG_INSTALLED_DIR=D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/vcpkg_installed" "-DVCPKG_MANIFEST_INSTALL=OFF"
FAILED: ../CMakeCache.txt
"C:/Program Files/CMake/bin/cmake.exe" -E chdir ".." "C:/Program Files/CMake/bin/cmake.exe" "D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/scripts/detect_compiler" "-G" "Ninja" "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_INSTALL_PREFIX=D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/packages/detect_compiler_x64-mingw-static" "-DCMAKE_MAKE_PROGRAM=C:/ProgramData/chocolatey/bin/ninja.exe" "-DCMAKE_SYSTEM_NAME=MinGW" "-DBUILD_SHARED_LIBS=OFF" "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/konan-toolchain.cmake" "-DVCPKG_TARGET_TRIPLET=x64-mingw-static" "-DVCPKG_SET_CHARSET_FLAG=ON" "-DVCPKG_PLATFORM_TOOLSET=external" "-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON" "-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=TRUE" "-DCMAKE_VERBOSE_MAKEFILE=ON" "-DVCPKG_APPLOCAL_DEPS=OFF" "-DCMAKE_TOOLCHAIN_FILE=D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/scripts/buildsystems/vcpkg.cmake" "-DCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION=ON" "-DVCPKG_CXX_FLAGS=" "-DVCPKG_CXX_FLAGS_RELEASE=" "-DVCPKG_CXX_FLAGS_DEBUG=" "-DVCPKG_C_FLAGS=" "-DVCPKG_C_FLAGS_RELEASE=" "-DVCPKG_C_FLAGS_DEBUG=" "-DVCPKG_CRT_LINKAGE=dynamic" "-DVCPKG_LINKER_FLAGS=" "-DVCPKG_LINKER_FLAGS_RELEASE=" "-DVCPKG_LINKER_FLAGS_DEBUG=" "-DVCPKG_TARGET_ARCHITECTURE=x64" "-DCMAKE_INSTALL_LIBDIR:STRING=lib" "-DCMAKE_INSTALL_BINDIR:STRING=bin" "-D_VCPKG_ROOT_DIR=D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg" "-DZ_VCPKG_ROOT_DIR=D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg" "-D_VCPKG_INSTALLED_DIR=D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/vcpkg_installed" "-DVCPKG_MANIFEST_INSTALL=OFF"
System is unknown to cmake, create:
Platform/MinGW to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- The C compiler identification is GNU 9.2.0
-- Detecting C compiler ABI info
System is unknown to cmake, create:
Platform/MinGW to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/gcc.exe
System is unknown to cmake, create:
Platform/MinGW to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Check for working C compiler: C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/gcc.exe - works
-- Detecting C compile features
-- Detecting C compile features - done
-- The CXX compiler identification is unknown
-- Detecting CXX compiler ABI info
System is unknown to cmake, create:
Platform/MinGW to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/g++.exe
System is unknown to cmake, create:
Platform/MinGW to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Check for working CXX compiler: C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/g++.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.25/Modules/CMakeTestCXXCompiler.cmake:63 (message):
  The C++ compiler

    "C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/g++.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/buildtrees/detect_compiler/x64-mingw-static-rel/CMakeFiles/CMakeScratch/TryCompile-0ck1wg

    Run Build Command(s):C:/ProgramData/chocolatey/bin/ninja.exe cmTC_8403e && [1/2] Building CXX object CMakeFiles\cmTC_8403e.dir\testCXXCompiler.cxx.obj
    FAILED: CMakeFiles/cmTC_8403e.dir/testCXXCompiler.cxx.obj
    C:\Users\runneradmin\.konan\dependencies\msys2-mingw-w64-x86_64-2\bin\g++.exe    -o CMakeFiles\cmTC_8403e.dir\testCXXCompiler.cxx.obj -c D:\a\kotlin-on-the-rocksdb\kotlin-on-the-rocksdb\vcpkg\buildtrees\detect_compiler\x64-mingw-static-rel\CMakeFiles\CMakeScratch\TryCompile-0ck1wg\testCXXCompiler.cxx
    cc1plus.exe: error: unrecognized command-line option '-auxbase-strip'
    cc1plus.exe: error: too many filenames given; type 'cc1plus.exe --help' for usage
    ninja: build stopped: subcommand failed.

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:12 (enable_language)

-- Configuring incomplete, errors occurred!
See also "D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/buildtrees/detect_compiler/x64-mingw-static-rel/CMakeFiles/CMakeOutput.log".
See also "D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/buildtrees/detect_compiler/x64-mingw-static-rel/CMakeFiles/CMakeError.log".
ninja: build stopped: subcommand failed.

The log indicates that the correct gcc/g++ commands are used:
The C compiler identification is GNU 9.2.0

But it fails.
What I've tried
Increase logging
I have tried increasing the log verbosity, but I wasn't able to get more information.
set(CMAKE_VERBOSE_MAKEFILE ON)

unrecognized command-line option '-auxbase-strip'
I was only able to find that this option is internal, and shouldn't be used. I don't know where it's coming from. There's no mention of it in vcpkg.
This question mentions auxbase, but not auxbase-strip, and has no answers.
too many filenames given
The answers in this question suggest

*

*use -O2 instead of -o2, but from what I can tell RocksDB already uses -O2

*no spaces in paths - but I'm pretty sure that there aren't any...

GitHub Workflow
I am using a GitHub Workflow, so I can automate building with a Windows machine.
Here is a summary:

*

*Checkout vcpkg
git clone --depth 1 https://github.com/microsoft/vcpkg.git
cd vcpkg

*Update the cmake to be a release library (which makes the produced library much smaller) and use the custom toolchain cmake.
echo "set(VCPKG_BUILD_TYPE release)" >> ./triplets/community/x64-mingw-static.cmake

echo "set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE \"D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/konan-toolchain.cmake\")" >> ./triplets/community/x64-mingw-static.cmake

*set up vcpkg, set the RocksDB version
./bootstrap-vcpkg.sh

touch vcpkg.json;

cat <<EOT >> vcpkg.json
{
   "dependencies": [
   "rocksdb",
   "zstd",
   "zlib",
   "snappy",
   "lz4",
   "bzip2"
],
"overrides": [
   { "name": "rocksdb", "version": "${{ env.ROCKSDB_VERSION }}" }
   ]
}
EOT

vcpkg x-update-baseline --add-initial-baseline

vcpkg install

Additional logs
./vcpkg/buildtrees/detect_compiler/x64-windows-rel/CMakeFiles/CMakeOutput.log
The target system is: Windows - 10.0.20348 - AMD64
The host system is: Windows - 10.0.20348 - AMD64
Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
Compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe
Build flags: ;/nologo;/DWIN32;/D_WINDOWS;/W3;/utf-8;/MP;
Id flags:

The output was:
0
CMakeCCompilerId.c

Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "CMakeCCompilerId.exe"

Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "CMakeCCompilerId.obj"

The C compiler identification is MSVC, found in "D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/buildtrees/detect_compiler/x64-windows-rel/CMakeFiles/3.25.2/CompilerIdC/CMakeCCompilerId.exe"

Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe
Build flags: ;/nologo;/DWIN32;/D_WINDOWS;/W3;/utf-8;/GR;/EHsc;/MP;
Id flags:

The output was:
0
CMakeCXXCompilerId.cpp

Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "CMakeCXXCompilerId.exe"

Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "CMakeCXXCompilerId.obj"

The CXX compiler identification is MSVC, found in "D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/buildtrees/detect_compiler/x64-windows-rel/CMakeFiles/3.25.2/CompilerIdCXX/CMakeCXXCompilerId.exe"

./vcpkg/buildtrees/detect_compiler/x64-mingw-static-rel/CMakeFiles/CMakeError.log
Detecting C compiler ABI info failed to compile with the following output:
Change Dir: D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/buildtrees/detect_compiler/x64-mingw-static-rel/CMakeFiles/CMakeScratch/TryCompile-oiuqqn

Run Build Command(s):C:/ProgramData/chocolatey/bin/ninja.exe cmTC_3a862 && [1/2] Building C object CMakeFiles/cmTC_3a862.dir/CMakeCCompilerABI.c.obj

Using built-in specs.

COLLECT_GCC=C:\Users\runneradmin\.konan\dependencies\msys2-mingw-w64-x86_64-2\bin\gcc.exe

Target: x86_64-w64-mingw32

Configured with: ../gcc-9.2.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include --libexecdir=/mingw64/lib --enable-bootstrap --with-arch=x86-64 --with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++ --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts=yes --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --enable-plugin --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev2, Built by MSYS2 project' --with-bugurl=https://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld

Thread model: posix

gcc version 9.2.0 (Rev2, Built by MSYS2 project)

COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_3a862.dir/CMakeCCompilerABI.c.obj' '-c' '-mtune=generic' '-march=x86-64'

 C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/cc1.exe -quiet -v -iprefix C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/ -D_REENTRANT C:/Program Files/CMake/share/cmake-3.25/Modules/CMakeCCompilerABI.c -quiet -dumpbase CMakeCCompilerABI.c -mtune=generic -march=x86-64 -auxbase-strip CMakeFiles/cmTC_3a862.dir/CMakeCCompilerABI.c.obj -version -o C:\Users\RUNNER~1\AppData\Local\Temp\ccTdIyhC.s

GNU C17 (Rev2, Built by MSYS2 project) version 9.2.0 (x86_64-w64-mingw32)

    compiled by GNU C version 9.2.0, GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.21-GMP

warning: GMP header version 6.1.2 differs from library version 6.2.1.

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072

ignoring duplicate directory "C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/9.2.0/include"

ignoring nonexistent directory "C:/building/msys64/mingw64/include"

ignoring nonexistent directory "/mingw64/include"

ignoring duplicate directory "C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/9.2.0/include-fixed"

ignoring duplicate directory "C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/include"

ignoring nonexistent directory "C:/building/msys64/mingw64/x86_64-w64-mingw32/include"

#include "..." search starts here:

#include <...> search starts here:

 C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/include

 C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../include

 C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/include-fixed

 C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/include

End of search list.

GNU C17 (Rev2, Built by MSYS2 project) version 9.2.0 (x86_64-w64-mingw32)

    compiled by GNU C version 9.2.0, GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.21-GMP

warning: GMP header version 6.1.2 differs from library version 6.2.1.

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072

Compiler executable checksum: 3bcdf03344e3ad7cb057c2ec82f696e6

COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_3a862.dir/CMakeCCompilerABI.c.obj' '-c' '-mtune=generic' '-march=x86-64'

 C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/as.exe -v -o CMakeFiles/cmTC_3a862.dir/CMakeCCompilerABI.c.obj C:\Users\RUNNER~1\AppData\Local\Temp\ccTdIyhC.s

GNU assembler version 2.32 (x86_64-w64-mingw32) using BFD version (GNU Binutils) 2.32

COMPILER_PATH=C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/;C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/;C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/

LIBRARY_PATH=C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/;C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/;C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/../lib/;C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../lib/;C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/;C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../

COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_3a862.dir/CMakeCCompilerABI.c.obj' '-c' '-mtune=generic' '-march=x86-64'

[2/2] Linking C executable cmTC_3a862

Using built-in specs.

COLLECT_GCC=C:\Users\runneradmin\.konan\dependencies\msys2-mingw-w64-x86_64-2\bin\gcc.exe

Target: x86_64-w64-mingw32

Configured with: ../gcc-9.2.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include --libexecdir=/mingw64/lib --enable-bootstrap --with-arch=x86-64 --with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++ --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts=yes --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --enable-plugin --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev2, Built by MSYS2 project' --with-bugurl=https://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld

Thread model: posix

gcc version 9.2.0 (Rev2, Built by MSYS2 project)

COMPILER_PATH=C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/;C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/;C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/

LIBRARY_PATH=C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/;C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/;C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/../lib/;C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../lib/;C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/;C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../

COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_3a862.exe' '-mtune=generic' '-march=x86-64'

 C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/collect2.exe -plugin C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/liblto_plugin-0.dll -plugin-opt= -plugin-opt=-fresolution=C:\Users\RUNNER~1\AppData\Local\Temp\cc5FiNtF.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -m i386pep -Bdynamic -o cmTC_3a862.exe C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/crtbegin.o -LC:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0 -LC:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc -LC:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/../lib -LC:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../lib -LC:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib -LC:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../.. CMakeFiles/cmTC_3a862.dir/CMakeCCompilerABI.c.obj -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/../lib/default-manifest.o C:/Users/runneradmin/.konan/dependencies/msys2-mingw-w64-x86_64-2/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/crtend.o

COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_3a862.exe' '-mtune=generic' '-march=x86-64'

Cannot copy output executable
  ''
to destination specified by COPY_FILE:
  'D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/buildtrees/detect_compiler/x64-mingw-static-rel/CMakeFiles/3.25.2/CMakeDetermineCompilerABI_C.bin'
Recorded try_compile output location doesn't exist:
  D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/buildtrees/detect_compiler/x64-mingw-static-rel/CMakeFiles/CMakeScratch/TryCompile-oiuqqn/cmTC_3a862

Checking whether the CXX compiler is IAR using "" did not match "IAR .+ Compiler":
g++.exe: fatal error: no input files
compilation terminated.
Checking whether the CXX compiler is IAR using "" did not match "IAR .+ Compiler":
g++.exe: fatal error: no input files
compilation terminated.
Detecting CXX compiler ABI info failed to compile with the following output:
Change Dir: D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/buildtrees/detect_compiler/x64-mingw-static-rel/CMakeFiles/CMakeScratch/TryCompile-s77rm4

Run Build Command(s):C:/ProgramData/chocolatey/bin/ninja.exe cmTC_4db65 && [1/2] Building CXX object CMakeFiles\cmTC_4db65.dir\CMakeCXXCompilerABI.cpp.obj

FAILED: CMakeFiles/cmTC_4db65.dir/CMakeCXXCompilerABI.cpp.obj

C:\Users\runneradmin\.konan\dependencies\msys2-mingw-w64-x86_64-2\bin\g++.exe    -o CMakeFiles\cmTC_4db65.dir\CMakeCXXCompilerABI.cpp.obj -c "C:\Program Files\CMake\share\cmake-3.25\Modules\CMakeCXXCompilerABI.cpp"

cc1plus.exe: error: unrecognized command-line option '-auxbase-strip'
cc1plus.exe: error: too many filenames given; type 'cc1plus.exe --help' for usage
ninja: build stopped: subcommand failed.

Determining if the C++ compiler works failed with the following output:
Change Dir: D:/a/kotlin-on-the-rocksdb/kotlin-on-the-rocksdb/vcpkg/buildtrees/detect_compiler/x64-mingw-static-rel/CMakeFiles/CMakeScratch/TryCompile-552faq

Run Build Command(s):C:/ProgramData/chocolatey/bin/ninja.exe cmTC_e2caf && [1/2] Building CXX object CMakeFiles\cmTC_e2caf.dir\testCXXCompiler.cxx.obj

FAILED: CMakeFiles/cmTC_e2caf.dir/testCXXCompiler.cxx.obj

C:\Users\runneradmin\.konan\dependencies\msys2-mingw-w64-x86_64-2\bin\g++.exe    -o CMakeFiles\cmTC_e2caf.dir\testCXXCompiler.cxx.obj -c D:\a\kotlin-on-the-rocksdb\kotlin-on-the-rocksdb\vcpkg\buildtrees\detect_compiler\x64-mingw-static-rel\CMakeFiles\CMakeScratch\TryCompile-552faq\testCXXCompiler.cxx

cc1plus.exe: error: unrecognized command-line option '-auxbase-strip'
cc1plus.exe: error: too many filenames given; type 'cc1plus.exe --help' for usage
ninja: build stopped: subcommand failed.


text:
Q: NSObject release... Still shows up in ObjectAlloc I have been tracking down why NSObject references, while being explicitly release, still show up in ObjectAlloc.  In fact, have reduced down NSObject to a basic shell, with a [[myObject alloc]init] immediately followed by a [myObject release], and it does not look like it is being released in ObjectAlloc.  This is a big problem with a NavigationController app that pushes/pops multiple view controllers, as the recently popped viewcontrollers aren't being released, because of these 'unreleased' NSObject references.  Hmmmmmm.
I could put my code up here, and have a bunch of 'have you's that never get anywhere.  Autorelease pools, blah blah.
So, let's look at the Sample 'SeismicXML' sample app from Apple...   fire it up in ObjectAlloc/Leaks.  Very basic in getEarthquakeData:
XMLReader *streamingParser = [[XMLReader alloc] init];
[streamingParser parseXMLFileAtURL:[NSURL URLWithString:feedURLString] parseError:&parseError];
[streamingParser release];

I see a TON of junk laying around in ObjectAlloc from XMLReader, despite releasing it.  I bet if we put a 'refresh' button on this app to call 'getEarthquakeData' again, we would crash the app within 5 refreshes.
Any thoughts?

A: I think you are confused about the ObjectAlloc instrument which will show all object allocations for the lifetime of your application. It's main use is to track memory usage over time.
The instrument I think you want is the one that is called Leaks which shows you what memory is being leaked by not having any reference to it. That is pointers to objects not being sent release-dealloc before they are reassigned.

A: There might be an autorelease pool holding onto the object.  If you create many autoreleased objects without cleaning them out of the pool, you'll get leaks until you return to the outer loop with the autorelease pool.
Here's how autorelease pools work: in the main loop, there's an autorelease pool.  Everything autoreleased goes there.  At the end of every loop iteration, all the objects in the pool get released.  If you allocate objects in another loop somewhere, they won't actually get released until you return to the main loop.  Unless, of course, you create your own autorelease pool just for the loop.
Another problem could be that your object is never released.  If you get an exception between +alloc and -release you'll get a leak.  A way to fix this is to use instead:
[[[XMLReader alloc] init] autorelease]

Finally, you could be working with garbage collection here.  I don't know enough about the GC system to tell you what behavior you should expect.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Python Loop to write Dataframes to Excel Files if both the Dataframe and Excel File have the same name I have a dictionary of dataframes that I want to export to individual excel files stored in a specific directory.
I would like to set up a python loop that will export the dataframe (as a new sheet) to the excel file with the same name as the dataframe, and iterate through each dataframe.
This is what I have so far:
    multi_sheet_file = pd.ExcelFile(r'filename.xlsx')

    # Gets the sheet names in the file
    excel_sheet_names = multi_sheet_file.sheet_names

    dict_of_sheets = {}
    for sheet in excel_sheet_names:
        dict_of_sheets[sheet] = pd.read_excel(multi_sheet_file,
    sheet_name=sheet)

How do I set up a python loop that will export  the dataframe to an existing excel file with the same name?

A: You should be able to loop through your dictionary, where the keys are the sheet names:
for sheet, df in dict_of_sheets.items():
    df.to_excel('some_excel_file.xlsx', sheet_name=sheet)

I'm not sure if this needs to be an ordered operation or not, but in py3.6+ dictionaries are ordered based on the order of key insertion if that matters


text:
Q: Laravel Commenting System Only Working on most recent Post I recently created a commenting system for a blog. When there is one post in the blog, the commenting sytem works fine. However, when there are two posts on the blog, and I comment on the FIRST post, the comment shows up on the SECOND post. Similarily, if I add another post, so there are three posts in my blog, when I comment on the first post, the comment shows up under the third post. In the same situation, when I comment on the second post, the comment shows up under the third post. Here is my code:
/index.blade.php

@section('content')

@foreach($posts as $post)

{{ $post->title}}

by {{ $post->user->name }}

    image_path) }}' class="img-responsive" id="blogpic"/>

{{ Str::words($post->body) }}

id) }}">Read More...

    {{ Form::open(array('action' => 'CommentController@newComment')) }}
    {{ Form::hidden('post_id', $post->id) }}

    {{ Form::text('body', null, array('class'=>'form-control')) }}

    {{ Form::submit('Post', array('class'=>'btn btn-info')) }}

    @foreach($post->comments as $comment)

{{ $comment->user->name }}: {{ $comment->body }}

    @endforeach

@endforeach

  @stop

Here is my new comment controller:
    public function newComment()
{
    $comment = New Comment();
    $comment->user_id = Auth::user()->id;
    $comment->post_id = $post_id = Input::get('post_id');
    $comment->body = Input::get('body');

    Post::find($post_id)->comments()->save($comment);

    return Redirect::action('BlogController@index');
}

I am pretty sure the problem is in my index file, and I can provide more code if needed. My comment only seems to get the most recent id in this line
 {{ Form::hidden('post_id', $post->id) }}

What could be going wrong?
Thanks in advance


text:
Q: URL pattern in django to match limited set of words I have a URL pattern in Django where there is a variable (called name) that should only take one of a select list of words. Something like this:
path("profile/<marta|jose|felipe|manuela:name>/", views.profile),

So basically only these paths are valid:

*

*profile/marta/

*profile/jose/

*profile/felipe/

*profile/manuela/

How exactly can I configure this in the Django url patterns? The above syntax tries to illustrate the idea but doesn't work. I've seen this ten year old question but that uses the previous format in the url patterns file so I imagine it should be done differently now...?

A: Why not put them in view?
from django.http import Http404

def profiles(request, name):
    if not name in ['marta', 'jose', 'felipe', 'manuela']:
        raise Http404('You shall not pass!')

Or you can simply use re_path:
urlpatterns = [
    re_path(r'^profile/(?P<name>marta|jose|felipe|manuela)/$', views.index, name='index'),
]


text:
Q: Customizing a contact 7 form so email address sent to is based on variables chosen Try to customize a contact 7 form so that the email goes out to different email address based on the values selected from the dropdowns. I'm not a programmer, just someone at home trying to build a website. Can someone help me with the code or point me towards it?

A: I'm not sure you can solve this without a bit of programming.
However I think if you want to do as little programming as possible, I'd set up as many identical contact forms as many email addresses you want to possibly send to..
After this you could write a little bit of JavaScript that changes the action attribute of the form element to the desired contact form when someone selects a specific option from a dropdown so that when they click submit,their data is sent to the form which emails the correct person.
This approach is probably not as nice as having 1 form and then writing some php to sort it out who it sends to but it requires less code and is less likely to break your site if it goes wrong.

A: Please use the following code in form box,
[select your-recipient "CEO|ceo@example.com"
                    "Sales|sales@example.com"
                    "Support|support@example.com"]

Then add the tag to mail "TO" filed,
[your-recipient]


text:
Q: R: Split column of data into multiple, based on nr. of characters I have this column of data:
variable
WinterMACV
WinterMACV
WinterMACV
WinterMACV
WinterMACV
WinterMACV
...

I want to split it in 3: "Winter", "M" and "ACV". So it has to split after 6 letters, then 1, and the last 3 remain.
I've found info about splitting at a certain character like "_", "," of " ". But how about after a certain nr of characters?
I was planning to use str_split_fixed() from the stringr package. Don't know if that's possible here.

A: If you know for sure that the string you are splitting will always have the characters in those positions then:
df %>% mutate(v1 = substr(variable, 1, 6),
              v2 = substr(variable, 7, 7),
              v3 = substr(variable, 8, 10))


text:
Q: how to put files on the localhost So, if you guys have any macs then you know that PHP 5 and Apache 2 are already installed, but disabled for privacy reasons. I just know used terminal to enable Apache server and PHP. It told me that I need to transfer it to the localhost or root-directory, but I i'm unaware of how to go about that. So, please help!

A: This documentation is from the official PHP website and tells you everything you need to know wbout using the default installation on OSX: http://www.php.net/manual/en/install.macosx.bundled.php


text:
Q: why "ReferenceError: {fn} is not defined"? I am trying to build a fiddle to test some features of jBox, but when executing the code it complains about askMe not being defined. I do think that it is defined in my script which I also validated with JSLint, so I'm really struggling to get this working.
HTML:
Click me

JS:
var jb;

function askMe() {
  console.log(jb);
  jb.Open({"confirmButton": "new confirm-text here!"});
};

$(function(){

    jb = new jBox(
    "Confirm", {
        "cancel":function() {$(document).trigger("event_no");},
        "cancelButton":"No",
        "confirm":function(){$(document).trigger("event_yes");},
        "confirmButton":"Yes",
        "content":"Do you like this sample?",
        "title":"Your choice, please!"
        }
    );
});

A: I'm just posting this so that the answer can be closed. Rory's comment about  the wrapping in jsfiddle really put me on the right track - I had never really understood this feature! (Yeah, embarrassing, I know.)
Additionally it had to be a function-call with proper casing, as snowmonkey pointed out.


text:
Q: 406 Not Acceptacle error while hitting REST API from postman I had a getMapping API which always responding 406 Not acceptable error.
@GetMapping(path="/check/{userId}", produces="text/plain")
public @ResponseBody Long check(@PathVariable("userId") String userId) {
    return (long) 22;
}

EndPoint which I am hitting from postman,
localhost:8080/api/check/0003az

with header,
Content-Type : "application/json"
Accept : "text/plain"

from postman, and getting response as 406 Not Acceptable
Is there anything which Im missing here?

A: 406 Not Acceptable it means you are doing something wrong with return type.
Please go through this link and change your return (long) 22; to string or remove Accept: "text/plain"

A: Mind the difference between Long and long, as you are using Long as the return type and cast that to long.

A: Since I am using produces="text/plain" and trying to return Long I got this error. After changing the return type to String and converted Long result to String while returning error got fixed.


text:
Q: In Svelte, using Auth.js, how can I get a session in a +server component Using svelte kit ( https://kit.svelte.dev ) and Authjs ( authjs.dev ), how can you retrieve the user session in a +server.(ts/js) endpoint?

A: The session can be found in the request event ( RequestEvent ), under request.locals.getSession() function.
Example:
import type { RequestEvent } from './$types';
import { json } from '@sveltejs/kit';
export const GET = async (request: RequestEvent) => {

    const sessions = await request.locals.getSession();
    const sessions_as_json_string = JSON.stringify(sessions, null, 4);
    return json({
        sessions_as_json_string
    });
};


text:
Q: Facebook Permissions - can I use one permisson for iOS and Android? I have similar iOS and Android apps, and both need publish permission from Facebook. Do I need to send both apps for review, or it will be enough to send just one app?

A: Yes, you have to apply separately for every platform. For every platform, you have to provide a demo app, and for every platform, you will separately receive permissions.

A: While integrating facebook with your android app,you need to add your Android development key hash to your Facebook developer profile to generate a key hash.
However, If you already have a Facebook app with an App ID that represents the same app on another platform, you can use the same app ID for iOS.


text:
Q: What happens when a quarry mines a chest? I have a quarry mining above an abandoned mine. There's a good chance eventually the quarry will mine a chest block. Will the quarry suck up the chest with its contents, or just the chest?

A: The quarry breaks open the chest and then picks up the items on the ground as it passes over them. It's the same way for beehives, if you have those in your world.


text:
Q: How do I upgrade AMD PSP drivers? If I look at C:\Windows\system32\drivers\amdpsp.sys, it is version 4.15.0.0.  The latest version is 5.17.0.0.  I'd like to upgrade to the latest.
I tried Windows update but it says I am up to date.
I went to update catalog https://www.catalog.update.microsoft.com/Search.aspx?q=AMD+PSP
Not exactly sure which one to download, but many seem to point to the same file
I get a CAB file.  Reading online, I rename it to a "KB" file but there is no KB number.  So I skip that step.  Then run "dism /online /add-package /packagepath:filename.cab"
When I run this, I get an error "An error occurred trying to open filename.cab Error: 0x80070002.
The system cannot find the file specified."
I try extracting the CAB file and its just drivers.  I try going to windows update and updating the driver pointing to that folder but it doesnt update anything.
I then goto AMD: https://www.amd.com/en/support/kb/release-notes/rn-ryzen-chipset-3-10-08-506
I run the installer, it specifically says it is installing the PSP driver 5.17.0.0.
However, after install and reboot, amdpsp.sys remains unchanged and at version 4.15.0.0


text:
Q: Updating property within Dependency property doesn't show within view I have a class, called Clan. A property within Clan is a bool Voiced, defaulting to false.
I have a view, ClanUI. This has a dependency Property of type Clan.
In the VM, I have a property of type Clan, which is passed into the view as a dependency property:
<UC:ClanUI Clan="{Binding Meilyr}" />

Within the ClanUI view, I have an image, which calls a command within the VM. It uses the correct DataContext:
...
<i:InvokeCommandAction Command="{Binding DataContext.ClanVoiced, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" CommandParameter="{Binding Clan.Name}" />
...

In that command within the VM, I set the value of Voiced on the property Meilyr, which is passed into the view as a DP from false to true.
within the view, I have a datatrigger which should reflect a change in Voice.
<Style TargetType="{x:Type Border}">
    <Setter Property="BorderThickness" Value="2" />
    <Style.Triggers>
        <DataTrigger Binding="{Binding Clan.Voiced}" Value="false">
            <Setter Property="BorderThickness" Value="0" />
        </DataTrigger>
    </Style.Triggers>
</Style>

I have tried starting with Voiced default to true, and this shows a border thickness of 2. So the binding is working correctly. I have debugged, and the code is hitting the VM correctly, and the Meilyr voiced property is being changed to true, and it is calling OnPropertyChanged correctly.
I have no idea why, when I change a value within the DP from the VM it doesn't reflect those changes within the view.
EDIT: Providing more code as requested
Here is the border and the image within the view. Clicking the image calls a command in the VM
<Grid DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}">
    ...
    <Border BorderBrush="Red" Margin="5">
        <Image Source="{Binding Clan.Image, FallbackValue='../Media/Clans/Meilyr.png'}" Height="40" VerticalAlignment="Center">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="MouseUp">
                    <i:InvokeCommandAction Command="{Binding DataContext.ClanVoiced, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" CommandParameter="{Binding Clan.Name}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </Image>
        <Border.Style>
            <Style TargetType="{x:Type Border}">
                <Setter Property="BorderThickness" Value="2" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Clan.Voiced}" Value="false">
                        <Setter Property="BorderThickness" Value="0" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </Border.Style>
    </Border>
    ...
</Grid>

And here is the Dependency Property in the xaml.cs:
public Clan Clan
    {
        get { return (Clan)GetValue(ClanProperty); }
        set { SetValue(ClanProperty, value); }
    }
    public static readonly DependencyProperty ClanProperty =
        DependencyProperty.Register("Clan", typeof(Clan),
        typeof(ClanUI), new PropertyMetadata(null));

in the Main View, here is how I place the view:
<UC:ClanUI Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="2" Clan="{Binding Meilyr}" />

and here are some snippets from the VM:
private Clan _Meilyr = new Clan();
    public Clan Meilyr
    {
        get
        {
            return _Meilyr;
        }
        set
        {
            _Meilyr = value;
            OnPropertyChanged("Meilyr");
        }
    }

...

private ICommand _ClanVoiced;
public ICommand ClanVoiced
{
    get
    {
        if (_ClanVoiced == null)
        {
            _ClanVoiced = new RelayCommand(ClanVoicedEx, null);
        }
        return _ClanVoiced;
    }
}
private void ClanVoicedEx(object p)
{
    if(Clans.FindAll(C => C.Voiced).Count >= 2)
    {
        //TODO
    }
    //Clans.First(C => C.Name == p.ToString()).Voiced = true; //<< This is how I will eventually be doing it, the next line was to ensure I was setting the correct thing.
    Meilyr.Voiced = true; //When debugging, when I click the image this line is hit, and after it has executed, inspecting Meilyr.Voiced shows it as being true.
}

Finally, here is the Voiced property within Clan.cs, as well as the OnPropertyChanged.
private bool _Voiced = false; //<< When I default this to true instead, it displays how I expect in the view. Initial bindings seem to work fine. It just doesn't seem to know when Voiced changes for some reason...
public bool Voiced
{
    get
    {
        return _Voiced;
    }
    set
    {
        _Voiced = value;
        OnPropertyChanged("Voiced");
    }
}

...

#region INotifyPropertyChanged Members

public event PropertyChangedEventHandler PropertyChanged;

private void OnPropertyChanged(string propertyName)
{
    PropertyChangedEventHandler handler = PropertyChanged;

    if (handler != null)
    {
        if (handler.Target is CollectionView)
        {
            ((CollectionView)handler.Target).Refresh();
        }
        else
        {
            handler(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}

#endregion

A: Make sure that the Clan class implements the INotifyPropertyChanged interface and raises the PropertyChanged event in the setter of the Voiced property.
Since you are binding to the Clan.Voiced property it doesn't matter whether the view model class where the Meilyr and ClanVoided properties are defined implements the INotifyPropertyChanged interface.

A: Can you post the ViewModel code please.
I am assuming you are updating the Clan property changed but not the Voice property changed.  In other words, Voiced needs to be a property with it's own property changed event firing.


text:
Q: Use a plugin like barcodescanner in nativescript vue Im trying to use the barcodescanner plugin here with nativescript-vue so first i install it with npm like that in my project :
npm install nativescript-barcodescanner
then i register it in my src/main.js file :
Vue.registerElement('BarcodeScanner', () => require('nativescript-barcodescanner').BarcodeScanner)
And then  i tried many ways to include the scanner in my vue component but i always get an error. Does anyone knows how to use this component with nativescript vue ?
as an xml component it return a frame error :
<BarcodeScanner
  class="scanner-round"
  formats="QR_CODE, EAN_13"
  beepOnScan="true"
  reportDuplicates="true"
  preferFrontCamera="false"
  (scanResult)="onScanResult($event)">
</BarcodeScanner>

A: In fact we need to use normal javascript require to use this barcodescanner plugin like that :
const BarcodeScanner = require("nativescript-barcodescanner").BarcodeScanner;

and then inside a computed method :
var barcodescanner = new BarcodeScanner();

and then use this class :
barcodescanner
    .scan(
        {
            // Enter here your scanner preferences
        }
    )
    .then(
        result => {
            // handle here the barcode result.
        }
    )


text:
Q: where is dbconsole in grails v3.2.5 doing some dev mode work on grails 3.2.5 but cant find the /dbconsole applet.
i run my app and go the root url and type /dbconsole, and get a 404.  I tried editing an entry in application.groovy to ensure it was enabled in dev, and explicitly set the urlRoot, to no effect.
has dbconsole been dropped from latest grails builds, or is it there but hidden ?
i tried variations of this in application groovy and in application.yml, to no effect - always get 404 on the browser
environments {
    production {
        //grails.serverURL = "http://www.changeme.com"
        grails.dbconsole.enabled = true
        grails.dbconsole.urlRoot = '/admin/dbconsole'
    }
    development {
        grails.serverURL = "http://localhost:8080/${appName}"
        grails.dbconsole.enabled = true
        grails.dbconsole.urlRoot = "${appName}/dbc"
    }
    test {
        grails.serverURL = "http://localhost:8080/${appName}"
    }
}

documentation implies it should still work but i am unable to get it to come up

A: It's http://localhost:8080/h2-console now, not http://localhost:8080/dbconsole . At least in the 4.0.x version of Grails.

A: ok i think i have it.  I was using Intellij and just imported the project as normal.  however i was running the grails-app/init/application to fire up the app.  I noticed it said it was in production mode - so the fix for that was top copy the run configuration, and call it "application - dev" or something like that.
you then add a line to the VM args "-Dgrails.env=dev" with this.  Now when you run the application by right clicking it shows the new configuration name.

once it was back in dev mode, then you could add the default "/dbconsole" after the root screen and it throws the H2 console.
usual caveats apply on security and protection of this url - but back in business and i can see the tables that Gorm is creating on my behalf.
also if you want to use config.slurper formatting as is still shown in the examples, you need to create an application.groovy in grails-app/conf, and put your entries in there, else i guess you transpose to application.yml format, i find groovy code easier to read somehow.
got there in the end

A: Maybe your Grails app is using a different driver, or serving in another address,  take a look at:
Database Console session


text:
Q: Know position "person" in file with ftell() and fseek() in c I have a file that containes informations about workers:

First name | Last name | phone (empty space)  First name 2... All in one line

And the question is to display information of worker when user choose 1,2 or 3... each number indicate a worker.
And i found this program that does that, but i didn't understand how the code work from line 30 to line 38 :
#include <stdio.h>
#include <string.h>

void main() {

typedef struct personne{
    char nom [20] ;
    char prenom [15] ;
    int age ;
    char tel[12] ;
} personne ;
personne p;

FILE * f ;
if ((f = fopen("Contacts.dat", "rb")) == NULL) {
    printf("\nImpossible de lire le fichier commandes.dat\n");
}
else{
    int num ; /* Bloc number to be found */
    long taille, /* File size  */
    pos ; /* position in the file */

    fseek (f, 0, SEEK_END) ;
    taille = ftell(f);

    printf (" Enter rank : ") ;
    scanf ("%d",&num) ;
    num--;                   //FROM HERE (LINE 30) !!!
    pos = num * sizeof(personne) ;

    if ( num < 0 || pos >= taille )
        printf ("-- This rank does not exist ") ;
    else {
        fseek (f, pos, SEEK_SET) ;
        fread (&p, sizeof(p), 1, f) ; //TO HERE (LINE 38)!!!
        printf ("nom : %s\n", p.nom) ;
        printf ("prenom : %s\n", p.prenom) ;
        printf ("age : %d\n", p.age) ;
        printf ("telephone : %s\n", p.tel) ;
    }

    fclose (f) ;
}}

Am knew to c language any help will be appreciated


text:
Q: Empty request payload when saving new record - Ember-data What I'm Trying:
Persist a new record but for some reason the request payload is empty even though the record has data.
Here's a fiddle: http://jsfiddle.net/brancusi/m8VrB/16/
(Disregard the firebase, it's just there so we can inspect the request payload on save.)
Explanation:
You will notice that when you save the record, the request payload is empty.
Ideally the request payload would look something like this:
{
    "inventory": {
        "entry_time": "2014-02-05",
        "client_id": 1,
        "user_id": 1,
        "product_stock_levels": [
            {
                "product_id": 1,
                "quantity": 2
            },
            {
                "product_id": 2,
                "quantity": 0
            },
            {
                "product_id": 3,
                "quantity": 8
            }
        ]
    }
}

Notes:
This only seems to be a problem when it's a new record. Updating existing records send the correct payload.

A: You are expecting ember data to embed relationships in a model on save as default. This is not the default behavior.
You could define relationships as being embedded per model. But there is no support for embedded record feature anymore as stated here: https://github.com/emberjs/data/blob/master/TRANSITION.md I am not sure if basic embedded record features still work with latest version of ember data. But you define a record as embedded like this:
App.InventorySerializer = DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {
    attrs: {
        productStockLevels: {embedded: 'always'}
    }
});

Because core team stopped support for this embedded records feature and it is very basic I would recommend you to use EmbbededAdapter or EmbeddedMixin if you need support for embedded records. You find them here: https://github.com/pixelhandler/ember-data-extensions
But as Ember Data EmbeddedAdapter is not stable yet. Perhaps you should consider not to embedded records to reduce complexity if you are flexible in defining the api.


text:
Q: Using Web-Workers in stand alone V8 Javascript Engine I tried to adopt the shell.cc sample from the V8 distribution package for my own purposes.
I want to spawn a web-worker to execute a long-running script, and execute:
var myWorker = new Worker("my_task.js");

But I receive the following error message:
(shell):1: ReferenceError: Worker is not defined
var myWorker = new Worker("my_task.js");
                   ^
ReferenceError: Worker is not defined
    at (shell):1:20

Is there a way to activate Web Workers in the V8 Engine?
Thank you in advance for any help on this issue!

A: I think you'd use the Child Process library for node or one of the other libraries that implements threading.  As far as I know, web workers are a browser thing, not part of the standard node.js implementation and if you want that sort of API, you would need to use a third party library that implements something like that API.
Other useful references:
Lightweight Web Worker API implementation with native threads
Concurrency on Node Discussion
Web Worker implementation in node

A: Too late though: But for any one still searching for it:
Check d8.cc file in v8 source code , it exposes Worker Template:


text:
Q: What is an efficient way to send large data over the wire? I have a list of strings List<string>. Actually is a list of file paths. And I need to send it to a webservice.  The list can contain huge count of items (1 000 - 10 000).
What would be the most efficient way to accomplish this? considering that the message payload will be quite high.
I am asking for ideas and principles, not code samples.
Thanks much.

A: For paths - firstly (or rather: lastly) gzip or deflate it. If large numbers of things are going to have common roots, nest that data perhaps?
i.e. so
/foo/bar/blap/a/b
/foo/bar/blap/c/d

becomes
/foo/bar/blap
 /a/b
 /c/d

Beyond that - the payload is going to far exceed any protocol overheads etc, so use whichever protocols etc make life simple for you.

A: just using compression. gzip or deflate stream. string compression ratio is very good.

A: if you are stuck with a certain communication protocol, perhaps chuncking can be considered.

A: Serialization combined with deflation techniques already suggested is highly efficient and reliable.


text:
Q: Mongoose options for .find Trying to return the last 10 objects from Mongoose. Cannot figure out the find method. Any suggestions? {limit:10} is not working.

router.get('/tweets', function(req, res, next){
  Tweet.find({}, ['createdAt'], {limit:10}, function(err,objects) { res.json(objects)});

});

A: Try to use the method limit on find.
router.get('/tweets', function(req, res, next){
        Tweet.find({})
            .sort({'createdAt': -1})
            .limit(10)
            .exec(function(err,objects) {
                res.json(objects)
            });
    });


text:
Q: Firefox OS TCPSocket API : SSL received a record that exceeded the maximum permissible length Is it possible to turn off SSL cert verification in Firefox OS? I have Geeksphone dev preview and try to make IMAP client via TCPSocket API, but server cert is somehow invalid. I got this error:
SSL received a record that exceeded the maximum permissible length.
(Error Code: ssl_error_rx_record_too_long)

My TCPSocket initializacion is as follows
var TCPSocket = navigator.mozTCPSocket.open(
        "mbp.telekom.de",
        993,
        {useSSL:'starttls'}
    );

When I try to connect to GMail or another account, everything works OK.
Is this really server cert error or is it something else?
Thanks

A: Turning off the certificate verification is generally a bad idea and unlikely to help. The error says ssl_error_rx_record_too_long, and record that is too long is just too long, whether you choose to accept any certificate or not. This type of error tends to be caused by a record that is "too long for SSL/TLS", that is, some message that isn't valid SSL/TLS at all.
There are a few other problems here.

*

*According to the documentation, TCPSocket takes a boolean for its useSSL parameter, not a string. It would seem fair to assume that somewhere in the code, there's an if (useSSL) {...}, so 'starttls' in your configuration counts as true.

*Port 993 tends to be usable for IMAP over SSL (after an initial connection via SSL), not IMAP+STARTTLS on port 143 (where the same socket is upgraded to SSL/TLS after an initial plain-text connection).

*The server at mbp.telekom.de doesn't accept SSL/TLS initial connections (like most IMAP servers would on that port), but accepts plain text IMAP connections upgradable to SSL/TLS via STARTTLS (which it should do on port 143 instead). This is likely to be a problem with the server configuration. This also explain why your connection works with imap.gmail.com (since it does support normal SSL/TLS connection that don't use STARTTLS on port 993, and since your {useSSL:'starttls'} in fact means {useSSL:true}).
You could in principle implement your IMAP client to upgrade the connection to SSL/TLS after using the STARTTLS command, but you'd need to be able to upgrade the same socket to SSL/TLS. I can't see anything in the TCPSocket documentation that would allow this (in the same way as SSLSocketFactory.createSocket(Socket, ...) does in Java, for example).
EDIT:
After a quick look at the TCPSocket.js source code, it seems that it does support starttls indeed, but this only makes sense with the undocumented upgradeToSecure method.
You might be able to implement IMAP+STARTTLS this way: initiate a plain IMAP connection, and then upgrade to SSL/TLS with the STARTTLS command, as described in RFC 2595. This is normally done on port 143, but since your server is (rather incorrectly) configured for this on port 993, it should work there too.

A: That's not a certificate error, that's an SSL protocol error.  SSL packages data into 'frames' or 'records'. (pretty much packets, but at the SSL level rather than the socket level).  There is a maximum length for these frames (16kb, I believe), and the server sent a frame longer than that.  I couldn't tell you why: but maybe their certificate is too big and their SSL lib has bugs.


text:
Q: Derive upper bound for inequality Consider a function $f: \mathbb{R}^n \rightarrow \mathbb R$ and a random variable $Z$ also taking values in $\mathbb{R}^n$.
Suppose $\sup_z \lvert f(z)\rvert = B <\infty$
Consider the following vectors $S = (Z_1,..,Z_n)$ and $S'= (Z_1,...,Z_i',..,Z_n)$, so you only change the i-th component for a given sample. Each $Z_i$ is a random variable in $\mathbb{R}^n$. Then I want to show that:
$$|g(S)-g(S')| \leq \frac{2B}{n}$$
for $$g(S):= \left\lvert \frac{1}{n} \sum_{i=1}^n f(Z_i)- E[f(Z)]\right\rvert $$
If I didn't have  $E[f(Z)]$ I would get: $|g(S)-g(S')| =  |\frac{1}{n} \left( f(Z_i) -  f(Z_i')\right) | \leq  \frac{1}{n} 2B $.
What can I do with $E[f(Z)]$
Are they the same if I only change the $i$-th component?

A: Observe that by the reversed triangular inequality,
$$
\left\lvert g(S)-g(S')\right\rvert=
\left\lvert \left\lvert \frac{1}{n} \sum_{j=1}^n f(Z_j)- E[f(Z)]\right\rvert -\left\lvert   \frac{1}{n} \sum_{j=1}^n f(Z^*_j)- E[f(Z)]\right\rvert \right\rvert\leqslant \left\lvert  \frac{1}{n} \sum_{j=1}^n f(Z_j)- E[f(Z)] -    \left(\frac{1}{n} \sum_{j=1}^n f(Z^*_j)- E[f(Z)] \right) \right\rvert,
$$
where $Z_j^*=Z_j$ if $j\neq i$ and $Z_i^*=Z'_i$. So the term $E[f(Z)]$ will cancel out.


text:
Q: received remote notification doesn't appear in notification center, but badge number on the app icon appears iphone app, which I made, works oddly on some devices. I've confirmed the app has registered itself to APN and received device token correctly. actually, the app put the token into the remote database. However, when I send a remote notification some devices, running iOS 5.0.1, doesn't show the remote notification in the notification center. Weird thing is that, the badge number of app icon is shown correctly when the notification is received. So, I'm guessing something goes messed up in the OS. What can I do to resolve it, or even to find a cause?
Those devices were used for development, and the same app was installed signed with development profile. Newly installed app is signed with distribution profile and I'm sure I'm using correct APN server & cert/key files, not for sandbox. Other devices, running iOS 4.3 or 5.1 beta, handles remote notification with no problems.

A: I had the same problem on IOS 6 (not tested on other OS).
The number of badge has been updated but there was no notification displayed.
The problem was the notification data were too long, I put custom data (such as the list of identifiers). Apple allows 256 bytes (ie 256 characters). That is why sometimes the notification was displayed, sometimes not (because the data I generated were too long and exceeded the limit of 256 bytes).
Hope this can help.

A: This is a certificate problem that can result from a provisioning profile being created after enabling push for an App ID. Revoke any certificates (to be safe) and re-make the provisioning profiles with those new certificates and app IDs. Remove old certs and provisioning profiles from your Mac and re-deploy the app. It should work then.


text:
Q: form validation yml I would like to know if it is possible to define conditions in the validation.yml file...
vendor\MyBundle\Entity\Image:
  properties:
   color:
      - NotBlank: ~
   name:
      - NotBlank: ~

for example :
  field xxx is NotBlank if field yyyy = true
Thank you

A: You need to use Callback validation:
http://symfony.com/doc/2.1/reference/constraints/Callback.html
Then, basically, you define the validation rules....


text:
Q: Require input in a hidden div to be filled; after goes back in display:block I have a form on my page, with 3 questions(inputs). This is an example of 1 question on my from. Coded this input to show an additional DIV ONLY when a user puts a number greater than 0 in its field. The additional DIV is set to: display:hidden by default on the page until someone changes the question's input to greater than 0. What I need to do is that REQUIRE the text area in that DIV to be filled (IF DIV IS VISIBLE) before the page form can submit. I currently have this code:

// Your listen for value changes in your input
  document.querySelector('#tix_quantity2').addEventListener('change', function calculate(e) {
  const div = document.querySelector('#div-to-show-hide');
  // Your grab the input value and test your condition
      if (Number(e.target.value) > 0)
      div.style.display = 'block';
    else
      div.style.display = 'none';
  });
<input type="text"  class="NetscapeFix CalTicketQuantity form-control" name="tix_quantity" id="tix_quantity2" value="0" size="4" maxlength="4">

INPUT: Text area (When visible on page. It needs to be required before the form on this page would submit)

A: Make the textarea visible on the required condition. If the element is visible then make the textareas required value as true, or set it to false

document.querySelector('#tix_quantity2').addEventListener('change', function calculate(e) {
    const div = document.querySelector('#div-to-show-hide');
    // Your grab the input value and test your condition
    if (Number(e.target.value) > 0) {
        div.style.display = 'block';
        const node = document.querySelector('#div-to-show-hide textarea');
        node.required = true;
    }
    else {
        div.style.display = 'none';
        const node = document.querySelector('#div-to-show-hide textarea');
        node.required = false;
    }
});
<form action="">
    <input type="text" class="NetscapeFix CalTicketQuantity form-control" name="tix_quantity" id="tix_quantity2"
        value="0" size="4" maxlength="4">

        <textarea name="" id="" cols="30" rows="10"></textarea>

    <button type="submit">Submit</button>
</form>

A: The input field should be mentioned as a required.
<input type="text"  class="NetscapeFix CalTicketQuantity form-control" name="tix_quantity" id="tix_quantity2" value="0" size="4" maxlength="4" required>

INPUT: Text area (When visible on page. It needs to be required before the form on this page would submit)

Please check this.

A: you can add "required" to textarea
<form action="/action_page.php">
  <textarea name="comment" required></textarea>
  <input type="submit">
</form>


text:
Q: Prevent Facebook from scraping specific images when somebody shares a link to my page Is it possible to prevent Facebook from using specific images when a user shares a link to a page on my site?
My site has user-generated content and while I include proper og:image tags for images the user uploads and which are part of his/her article, sometimes no image is uploaded or the image uploaded does not meet Facebook's quality requirements. In that case, Facebook will pick other images it finds on the page and those other images can be from a "Related articles" section or images not content-related at all. It would be nice if I could flag these images in such a way that Facebook ignores them.


text:
Q: Excel crashes on workbook.close? I have a VBA function that will crash excel when I run it ("Microsoft Excel has stopped working"), but works fine if I step through each line in the editor. I want to open another workbook with the function, change the slicers on a given sheet, find a value, and then close the new workbook without saving it. The function I have is as follows:
Function ValueLookup()

Dim Check As Boolean
Dim NewBook As Workbook

Check = IsWorkBookOpen("C:\Location\Filename")
If Check = False Then
    Set NewBook = Workbooks.Open("C:\Location\Filename")
Else
    Set NewBook = Workbooks("Filename")
End If

NewBook.Activate
Worksheets("Sheetname").Activate

ActiveSheet.PivotTables("pivottable1")ManualUpdate = True

With ActiveWorkbook.SlicerCaches("Slicer_SlicerName")
    .ClearManualFilter
    .VisibleSlicerItemsList = Array("[Tablename].[Columnname].&[MyValue]")
End With

ActiveSheet.PivotTables("pivottable1").ManualUpdate = False

ValueLookup = ActiveSheet.Cells.Find(What:="*", _
                                     After:=Range("A1"), _
                                     LookAt:=xlPart, _
                                     LookIn:=xlFormulas, _
                                     searchorder:=xlByRows, _
                                     searchdirection:=xlPrevious, _
                                     MatchCase:=False)

If Check = False Then NewBook.Close savechanges:=False

End Function

(IsWorkBookOpen() is taken from Detect whether Excel workbook is already open, and doesn't seem to present any issues).
It seems that trying to close the new workbook is what's causing the issue, and if the workbook is open before I run the function there is no issue. The subroutine that calls the function will normally execute the line after the function right before excel crashes (opening a MsgBox for user input). I have tried adding Sleep 1000 after each line and adding DoEvents after the last line with no change in results. I've tried changing
NewBook.Close savechanges:= False

to
Application.Windows("NewBook").Close

without any difference. I've also tried replacing the end with
If Check = False Then
    Cancel = True
    Application.OnTime Now, "Close_Xls"
End If

End Function

Sub Close_Xls()
    ThisWorkBook.Close savechanges:=False
End Sub

but this closes the wrong workbook (the original one I'd like the macro to be run from) after my subroutine has finished. However, it does seem to execute the code successfully before closing the wrong workbook, and does not cause excel to crash.
Any suggestions?
Edit:
It now appears to work without issues. I changed the following:
If Check = False Then NewBook.Close savechanges:=False

End Function

To
NewBook.Saved = True
    If Check = False Then
        Cancel = True
        Application.OnTime Now, "Close_Xls"
    End If

End Function

Sub Close_Xls()

    Workbooks("Filename").Close savechanges:=False

End Sub

Thanks!

A: Changing the Close_Xls() sub to the following will target the correct sheet to close:
Sub Close_Xls()
    Workbooks("Filename").Close savechanges:=False
End Sub

Another way to close the workbook without saving that might work is to use:
NewBook.Saved = True

before closing.


text:
Q: How to use Hyperledger fabric for existing cryptocurrency trade (Ether, Bitcoin)? I am working on a project for creating a platform which specializes on cryptocurrency trading. I want to migrate from Ethereum blockchain to Hyperledger fabric. My question is can I use Hyperledger fabric for existing cryptocurrency trade transactions, e.g. Ethereum, Bitcoin and so on?

A: Hyperledger fabric does not have native cryptocurrency support.Though you can always include bitcoin api(bitcoin for developers) with your contract. But hyperledger fabric being private/consortium kind of Blockchain I don't know what exactly you are looking out for.


text:
Q: Shifting a button down How do I shift a button location down? I have a UISwitch when its on, which will then display some stuffs, but that would cover one of my button. How do I shift the button down so that it's not overlapped?

A: Set the frame of the button to the new location.  For instance, this will move the button down 100 pixels:
myButton.frame = CGRectOffset(myButton.frame, 100.0, 0);


text:
Q: Setting up spring boot project with liquibase I have a spring boot 2 project(jhipster) and I am a little confused on how hibernate tables work with liquibase.
Right now I have a bunch of data classes with hibernate annotations and I would like to insert some static data for testing purposes. I have a bunch of questions in getting started.
Do I have to define liquibase changeSets to create tables when I already have the hibernate annotated data classes?
How do I run liquibase changeSets when configuring the database?
EDIT -----
How are the foreign key relationships named between the changeset and the domain(java) code? For example I have a Person table and it holds a reference to an Address table. How do I represent this relationship within the changeSet table?
The Person table doesn't hold an id of an Address, it holds the reference.

A:
Spring boot has excellent integration with liquibase.

If you want liquibase to handle creation of the tables (DDL) and not hibernate:
you need to disable the hibernate auto-create flag.
set spring.jpa.hibernate.ddl-auto=none
(or) remove this property from application.yml file.
Just include following into pom.xml:
<dependency>
      <groupId>org.liquibase</groupId>
      <artifactId>liquibase-core</artifactId>
</dependency>

Below is the sample code to create tables and insert data into table.

File location:
  src/main/resources/db/changelog/db.changelog-master.yaml

  databaseChangeLog:
  - changeSet:
      id: 1
      author: sgollapinni
      changes:
        - createTable:
            tableName: person
            columns:
              - column:
                  name: id
                  type: int
                  autoIncrement: true
                  constraints:
                    primaryKey: true
                    nullable: false
              - column:
                  name: first_name
                  type: varchar(255)
                  constraints:
                    nullable: false
              - column:
                  name: last_name
                  type: varchar(255)
                  constraints:
                    nullable: false
        - createTable:
            tableName: address
            columns:
              - column:
                  name: id
                  type: int
                  autoIncrement: true
                  constraints:
                    primaryKey: true
                    nullable: false
              - column:
                  name: city
                  type: varchar(255)
                  constraints:
                    nullable: false
              - column:
                  name: person_id
                  type: varchar(255)
                  constraints:
                        nullable: false
                        foreignKeyName: fk_person_address
                        references: person(id)
  - changeSet:
      id: 2
      author: sgollapinni
      changes:
        - insert:
            tableName: person
            columns:
              - column:
                  name: first_name
                  value: Sunil
              - column:
                  name: last_name
                  value: Kumar
        - insert:
            tableName: address
            columns:
              - column:
                  name: city
                  value: Bangalore
              - column:
                  name: user_id
                  value: (Select id from person where name = 'Sunil')

Otherwise, if you want hibernate to handle the DDL and only you want to insert some static data for testing purposes, you can still do this using liquibase.
You can use changeSets to add the DML statements.
- changeSet:
  id: 1
  author: sgollapinni
  changes:
    - insert:
        tableName: person
        columns:
          - column:
              name: first_name
              value: Sunil
          - column:
              name: last_name
              value: Kumar
    - insert:
        tableName: address
        columns:
          - column:
              name: city
              value: Bangalore
          - column:
              name: user_id
              value: (Select id from person where name = 'Sunil')

Hope it helps!


text:
Q: How to not use attribute default value over rest API in magento2 Im working on api integration between one store of magento2 multi store installation and product db of a client. Our current problem is that part of the items for in our store are duplicated (same sku) with different shops. Which by itself is fine and expected. But we would like to be sure that parent products (eg form default view) are never overwriting our values. Right now this works fine for all values that are set for the product.
Problem starts when for example we create product A for shop TEST_SHOP which is new for the shop and installation, with no description, then 3rd  party also adds product A for default view with description. Then our product automatically gets description form new update.
As far as I understand this is caused by use default value check box (it is checked by default for empty values). Can this check box be unchecked from API ?
Thanks

A: I am using 2.2 and see that setting values across different store views is not well documented at all.
The "Use Default Value" checkbox is inferred through the content on each site so cannot be set specifically. If the field or attribute is set at Store View level then if it has content in a specific store view it will unchecked. If it has no content in the store view it will be checked.
To set the content in a specific store view use the pattern: -
rest/{siteView}/V1/products/{sku}
To set it at the highest level ready to inherit use: -
rest/all/V1/products/{sku}
I have found for fields such as "Product Name" setting the value to "null" through the API will unset the field and revert to "Use Default Values" in the admin.
For product attributes (such as content) you will need to omit the attribute from the PUT request in the store view and it will then inherit the value set at the all level.
EDIT - Seems like omitting the custom attribute does not maintain the "Use Default Values". I have a call logged with Magento support on this topic so will hopfully be able to update here.
EDIT TWO - Magento support has highlighted that updating the Custom Attributes should NOT include a name field (even though a GET will return this field). If you update in a store view context without the name field and set the value to null the "Use Default Values" will be restored/maintained: -
PUT /rest/{site_view}/V1/products/{SKU}
{"product" :
  {
    ...
    "name": null,
    ...
    "custom_attributes": [
    {
      "attribute_code": "short_description",
      "value": null,
    },
    ...
  }
}

A: I can confirm the above method works! I have been using this (https://github.com/vpsnak/magento2-rest-use-default) as a workaround to achieve this.


text:
Q: Запись определенного формата сигнала Есть определенный формат сигнала .adc, нужно представить заголовок этого файла в реализации c#, вот пример части этого формата в бинарном представлении:
флаги................. long  (DWORD) - 4 байта
младший бит:
целочисленные отсчеты      - 00000000H
отсчеты с плавающей точкой - 00000001H
первый бит:
отсчеты комплексные        - 00000002H
отсчеты некомплексные      - 00000000H
резерв заголовка......           - 8 байт
желательно заполнить нулями
отсчеты   - (массив переменной длины)
Некомплексные отсчеты:
целочисленные      - shortint* - 2N байт
с плавающей точкой - float*     - 4N байт
Комплексные отсчеты:
Записаны подряд пары вида (реальная,мнимая) части
целочисленные      - shortint* - 4N байт
если разрядность АЦП выше 16, то целочисленные отсчеты
представлены следующим образом:
  - int*       - 8N байт
с плавающей точкой - float*     - 8N байт
Кто-нибудь может помочь реализовать(привести пример), либо же подсказать где можно прочитать по этому поводу?

A: Создайте структуру и энумератор флагов
// структуру и энумератор расположите снаружи класса, просто в неймспейсе
public enum HeaderFlag : long
{
    Flag1 = 1,
    Flag2 = 2,
    Flag3 = 4,
    Flag4 = 8
}

public struct Header
{
    [Flags]
    public HeaderFlag Flags { get; set; }
    public uint CountersInt { get; set; }
    public float CountersFloat { get; set; }
    // и так далее
}

Затем при считайте заголовок в массив байт byte[] и разберите поток байт в цикле присваивая значения полей
byte[] headerArray = ...;

Header header = new Header();
byte[] temp;

temp = headerArray.Take(4).ToArray();
header.Flags = ...;

temp = headerArray.Skip(4).Take(4).ToArray();
header.CountersInt = ...;
}

Как преобразовывать массив байт в числа, можно посмотреть здесь.
Наверно еще можно попробовать использовать маршалинг.


text:
Q: How do I fix a no longer responsive website? I am new to all this and I am desperate to understand what went wrong here:
https://www.festivalcinemaafricano.org

This URL used to work fine on mobile devices until a couple of months ago (see the web archive) and I really can't find the problem.
Can you help me out? Thanks!

A: Is it because you have a width set on your .container class of 1151px, removing that seems to make it responsive again


text:
Q: Have trouble using numba atomic operation functions (cuda.atomic.compare_and_swap) I am trying to use Numba to write cuda kernels for my code. And somehow I wanna use the atomic operation in part of my code and I wrote a test kernel to see how cuda.atomic.compare_and_swap works. On the documentation it says this:
enter image description here
from numba import cuda
import numpy as np

@cuda.jit
def atomicCAS(N,out1):
    idx = cuda.threadIdx.x + cuda.blockIdx.x * cuda.blockDim.x
    if idx >= N:
        return
    A = out1[idx:]
    cuda.atomic.compare_and_swap(A,idx,0)

N    = 1024
out1 = np.arange(N)
out1 = np.zeros(N)
dout1 = cuda.to_device(out1)
tpb  = 32
bpg  = int(np.ceil(N/tpb))
atomicCAS[bpg,tpb](N,dout1)
hout1 = dout1.copy_to_host()

Then I got this error:

TypingError: Invalid use of Function(<class 'numba.cuda.stubs.atomic.compare_and_swap'>) with argument(s) of type(s): (array(float64, 1d, A), int64, Literal[int](0))
 * parameterized
In definition 0:
    All templates rejected with literals.
In definition 1:
    All templates rejected without literals.
This error is usually caused by passing an argument of a type that is unsupported by the named function.
[1] During: resolving callee type: Function(<class 'numba.cuda.stubs.atomic.compare_and_swap'>)
[2] During: typing of call at /home/qinyu/test.py (20)

This is a pretty naive code and I think I feed in the write type of variables but I got this typingerror. It worked pretty well with the other atomic operations in Numba. This is the only one that does not work for me. Can somebody help me figure out the problem or is there another alternative ways to do this? Thanks!

A: The key in the error message is this:
array(float64, 1d, A), int64, Literal[int](0))

CUDA atomicCAS only supports integer types. You cannot pass a floating point type.


text:
Q: why does my program crash when i attempt to run this?
Possible Duplicate:
I need help declaring a temarary array to hold a bitmap picture while i rotate it 90 degrees

why does my program crash when i attempt to run this?
Also on the end of line 10(+ (image.infoHeader.biWidth-c-1);) of the code is not working the way i want it to; do you see what wrong with it?
void rotate90(Image& image)
{
    Pixel * tempPixel = new Pixel[(image.infoHeader.biWidth * image.infoHeader.biHeight)];
    for(int r = 0; r < image.infoHeader.biHeight; r ++)
    {
        for(int c = 0; c < image.infoHeader.biWidth; c++)
        {

            int f = c+(r*image.infoHeader.biWidth);
            int t = (image.infoHeader.biHeight - r - 1) + (image.infoHeader.biWidth-c-1);
            tempPixel[t] = image.pixels[f];
        }
    }
    tempPixel = image.pixels;
    delete[] tempPixel;
}

A: This is a problem:
tempPixel = image.pixels;
delete[] tempPixel;

You overwrite the pointer you got from new with a different address. Then you call delete[] on the pointer which now points to memory owned by the image object.


text:
Q: discrete math use an element argument Q)Let U be a universe.Use an element arguement to prove the following statement.
For all sets A,B and B in P(U),(C-A) u (B-A)⊆ ( B U C) -A.
Def : Z ⊆ W ={(z,w):x∈ X and y ∈ Y}.
Proof:
W=(C-A) U (B-A) ={(c,a):a∈A and c∈C}U{(a,b):a∈A and b∈B}
Z=(B U C)-A = {(a,y):a∈A and y∈BU C}
For all  a∈A:
Case 1.b∈C. If b∈C then (a,b)∈Z. Also (a,b)∈W.
Case 2. b∉C.If b∉C, then b is not in BU C. Then (a,b) is not in Z. b is also not in C-A, so it's not in W.
Case 3. By definition of the Union, a is also a member of C-A and A - C. By definition of intersection, a belongs to(B-A) ∩ (C-A).
Case 4. By definition of a subset, (B-A) ∩ (C-A) is a subset of (B U C) - A.
Case 5. Therefore (B-A) ∩ (C-A)⊆(B U C) - A.
My first time doing element argument.I spend hours to solve this, i want to make sure i am right. Can pls check and advice if i am right or wrong. And where i can make improvemet? Thanks for ur time

A: Before anything else, here are some definitions.

$A\subseteq B$ if and only if for every $a\in A$ you have also that $a\in B$
That is to say, there is nothing that is in $A$ while not in $B$. (note, $\emptyset$ is always a subset of every other set)

Another definition which seems to have confused you

$A\backslash B = \{x~:~x\in A\text{ and }x\notin B\}$
(equivalently written as $A-B$ or $A\setminus B$ or $A\cap B^c$)

Here is the question as I understand it (given your typing).
Let $U$ be a universe.  Use an element argument to prove the following statement: For all sets $A,B$ and $C$ in $\mathcal{P}(U)$, you have that $(C\backslash A)\cup (B\backslash A)\subseteq (B\cup C)\backslash A$.
Here is an elegant set theoretic proof that uses DeMorgan's laws and symbolic manipulation, (note here that each $=$ can be interpreted left to right as $\subseteq$ while also can be interpreted right to left as $\supseteq$)
$(C\backslash A)\cup (B\backslash A) = (C\cap A^c)\cup (B\cap A^c) = (C\cup B)\cap A^c = (B\cup C)\backslash A$

Using an element argument, it should be set up as follows:
$x\in (C\backslash A)\cup (B\backslash A)\Rightarrow x\in (C\backslash A)$ or $x\in (B\backslash A)\Rightarrow (x\in C$ but not $A)$ or $(x\in B$ but not $A)\Rightarrow x\notin A\text{ and }x\in C\cup B$
$\Rightarrow x\in (B\cup C)\cap A^c\Rightarrow x\in (B\cup C)\backslash A\Rightarrow (C\backslash A)\cup (B\backslash A)\subseteq (B\cup C)\backslash A$
If you wish to do a case argument (which is much longer), then consider all possibilities for $x\in^? A, x\in^? B, x\in^? C$ (there are 8 possible configurations) and look to see if each of the eight configurations leads to $x$ being an element of the set on the left and being an element of the set on the right or $x$ not being an element on the left (with no concern about the right).

A: Here is a slightly different way to approach element arguments (a.k.a. element chasing): start at the most complex side, expand the definitions, simplify using the laws of logic, and take it from there.
$
\newcommand{\calc}{\begin{align} \quad &}
\newcommand{\calcop}[2]{\\ #1 \quad & \quad \unicode{x201c}\text{#2}\unicode{x201d} \\ \quad & }
\newcommand{\endcalc}{\end{align}}
\newcommand{\ref}[1]{\text{(#1)}}
\newcommand{\true}{\text{true}}
\newcommand{\false}{\text{false}}
$In this case, let's calculate which $\;x\;$ are in $\;(C - A) \cup (B - A)\;$.

For all $\;x\;$,
$$\calc
x \in (C - A) \cup (B - A)
\calcop={definition of $\;\cup\;$}
x \in C - A \;\lor\; x \in B - A
\calcop={definition of $\;-\;$, twice}
(x \in C \land x \not\in A) \;\lor\; (x \in B \land x \not\in A)
\calcop{\tag{*}=}{logic: extract common conjunct $\;x \not\in A\;$}
(x \in C \;\lor\; x \in B) \;\land\; x \not\in A
\calcop={definition of $\;\cup\;$}
(x \in C \cup B) \;\land\; x \not\in A
\calcop={definition of $\;-\;$}
x \in (C \cup B) - A
\endcalc$$
By set extensionality, we've proven $\;(C - A) \cup (B - A) \;=\; (C \cup B) - A\;$.

In the above proof, the simplification is done in step $\ref{*}$: that is the key step of this proof.
Note that we've proven equality ($\;=\;$) instead of the weaker $\;\subseteq\;$, since there was no reason to use implication ($\;\Rightarrow\;$) anywhere.
Also, compare this proof to the "elegant set theoretic proof" from JMoravitz's answer: it has exactly the same structure, but that proof is on the set theory level, and this one is on the element level.


text:
Q: How to get the input data of a field from my webapp I am trying to create an app for house rental, and i dont know how to get the user's input data (e.g: size,price etc). Is there anyone that can help or suggest any solution ?
My github links:
Frontend:
https://github.com/Gkonst1/chatbotEstateAgent
Backend:
https://github.com/loukia12/backend-CB


text:
Q: Is there a way to hold a collection of "messages" upto size 1 MB and write the result to JSON/CSV file I have a blocking queue which keep getting messages through some app, now In asp.net app I tried to consume the queue and write the output into CSV/JSON file.
Here I want to hold messages up to 1MB which receive from blocking queue and then write it out, now again hold data for 1MB and write again...so on.
In below code, I'm using system.reactive buffer and can hold number of observable 's and write to JSON, but Is there any way on size of observable 's?
class Program
{
    private static readonly BlockingCollection<Message> MessagesBlockingCollection = new BlockingCollection<Message>();

    private static void Producer()
    {
        int ctr = 1;
        while (ctr <= 11)
        {
            MessagesBlockingCollection.Add(new Message { Id = ctr, Name = $"Name-{ctr}" });
            Thread.Sleep(1000);
            ctr++;
        }
    }

    private static void Consumer()
    {
        var observable = MessagesBlockingCollection.GetConsumingEnumerable().ToObservable();

        var bufferedNumberStream = observable.BufferWithThrottle(TimeSpan.FromSeconds(60), 5)
                                    .Subscribe(ts =>
                                    {
                                        WriteToFile(ts.ToList());
                                    });
    }

    private static void WriteToFile(List<Message> listToWrite)
    {
        using (StreamWriter outFile = System.IO.File.CreateText(Path.Combine(@"C:\TEMP", $"{DateTime.Now.ToString("yyyyMMddHHmmssfff")}.json")))
        {
            outFile.Write(JsonConvert.SerializeObject(listToWrite));
        }
    }

    static void Main(string[] args)
    {
        var producer = Task.Factory.StartNew(() => Producer());
        var consumer = Task.Factory.StartNew(() => Consumer());
        Console.Read();
    }
}

Extension Reactive Method,
public static IObservable<IList<TSource>> BufferWithThrottle<TSource>(this IObservable<TSource> source,
                                                                            TimeSpan threshold, int noOfStream)
    {
        return Observable.Create<IList<TSource>>((obs) =>
        {
            return source.GroupByUntil(_ => true,
                                       g => g.Throttle(threshold).Select(_ => Unit.Default)
                                             .Merge(g.Buffer(noOfStream).Select(_ => Unit.Default)))
                         .SelectMany(i => i.ToList())
                         .Subscribe(obs);
        });
    }

Message Class,
public class Message
{
    public int Id { get; set; }
    public string Name { get; set; }
}


text:
Q: Using foreach with a Spark RDD in python I'm trying to take a very large RDD running on a cluster and write it to a .csv. It's so large that .collect() breaks, so instead I'd like to save the RDD into pieces on each node and then somehow bring them together, as order doesn't matter. My thought is to use foreach with the CSV printer function, so that each part writes it's values, then I can gather the parts together manually, perhaps by FTP.
I'm a Spark user with some experience, but to date I've never been able to make the RDD's foreach method do anything useful. When I try to run the example given in the documentation,
>>> def f(x): print x
>>> sc.parallelize([1, 2, 3, 4, 5]).foreach(f)

I get nothing back on my console. I believe this is because the 'print' is being performed on the separate nodes rather than the namenode where the console is located. In that case though, I really can't see much point in the foreach function at all!
How can I get the results of my for each back to the name node without first calling the collect() function?
NB. I'm also open to using the saveAsTextFile() RDD function, but again I've not been able to make it work! It seems to create a folder instead of a text file, although this is perhaps because they exist on each node as well instead of centrally?

A: The answer here:
View RDD contents in Python Spark?
The reason claimed is that it's not a Python 2.6 function.


text:
Q: fscanf padding with 0 with new lines I am having trouble reading in a control file with multiple new lines at the end.
    void readControlFromFile (FILE *f)
    {
    int N = 100;
    controlData = (ControlEntry **)malloc(sizeof(ControlEntry *) * N);
    char line [10];
    controlData[0] = (ControlEntry *)malloc(sizeof(ControlEntry));
    fscanf (f, "%d %d %d", &controlData[0]->occurance, &controlData[0]->text, &controlData[0]->pattern);
    while(fgets(line, 10, f) != NULL)
    {
        controlData[lineCount] = (ControlEntry *)malloc(sizeof(ControlEntry));
        fscanf (f, "%d %d %d", &controlData[lineCount]->occurance, &controlData[lineCount]->text, &controlData[lineCount]->pattern);
        //printf("%d %d %d \n", controlData[lineCount]->occurance, controlData[lineCount]->text, controlData[lineCount]->pattern);
        lineCount++;

        if(lineCount == N)
        {
            N*=2;
            controlData = (ControlEntry **)realloc(controlData, sizeof(ControlEntry *) * N);
        }
    }

}

The fscanf seems to put default values of 0 into the buffer, and I have tried a break as follows:
if(line[0] == '\n')
{
 break;
}

But to no avail. I am aware this will be a simple fix, but I am a bit new with C.
Thanks

A: You must check the return value of fscanf (or any other *scanf).  It will tell  you how many tokens were read.


text:
Q: How to fix '503 Service not found' for a specific REST api call? I have a vue.js+Node.js+MongoDB app hosting at heroku and up until recently it worked fine.
Now, suddenly when im trying to do an action on the app that sends an 'add' POST to the server im getting this error :
'POST http://www.mysportapp.co/user/add 503 (Service Unavailable)'
NOTES :

*

*i didnt change nothing in the code, and it worked before.

*when i first load my app there is an initial call to ther server that works.

*when im running my app localy, it works fine, no errors.

//frontend function :

async function saveUser(email) {
    var user = { email,date: Date.now()}
    var res = await axios.post(`${BASE_URL}/add`,user)
    localStorage.setItem('currUser',res.data)
    return res.data
}

//backend router :

app.post(`${BASE}/add`, (req, res) => {
        const user = req.body
        userService.checkUser(user)
        .then(userDetails =>{
            brokerService.getDetails(userDetails)
            .then(brokerDetails => {
                req.session.brokerDetails = brokerDetails
                if (userDetails.isNew) sendGridService.createMsg(userDetails.email,userDetails.countryCode,brokerDetails)
                res.json(userDetails)
            })
        })
    })

Anyone has an idea what can be the reason for this ?


text:
Q: NSException kills the app if raised in background I am performing some network related code. When the code starts executing and the user sends the app in background and that time if exception raise the app is killed. if exception is not raised app is not killed. Is it possible to stop/pause any kind of network activity? or a way to stop app from killing?
UPDATE
I am using matt gallahar (cocoa with love) written uncaughtexception handler. How do I cancel the request once it fired. The code for request is called in this function
+(NSString*)validate:(NSString*)username password:(NSString*)password server:(NSString*)server port:(int)port encryption:(int)encryption authentication:(int)authentication folders:(NSMutableArray*)folders {
    CTCoreAccount* account = [[CTCoreAccount alloc] init];

    @try   {
        [account connectToServer:server port:port connectionType:encryption authType:authentication login:username password:password];
    } @catch (NSException *exp) {
        NSLog(@"connect exception: %@", exp);
        return [NSString stringWithFormat:@"Connect error: %@", [ImapFolderWorker decodeError:exp]];
    }
}

- (void)connectToServer:(NSString *)server port:(int)port
        connectionType:(int)conType authType:(int)authType
        login:(NSString *)login password:(NSString *)password {
    int err = 0;
    int imap_cached = 0;

    const char* auth_type_to_pass = NULL;
    if(authType == IMAP_AUTH_TYPE_SASL_CRAM_MD5) {
        auth_type_to_pass = "CRAM-MD5";
    }

    err = imap_mailstorage_init_sasl(myStorage,
                                     (char *)[server cStringUsingEncoding:NSUTF8StringEncoding],
                                     (uint16_t)port, NULL,
                                     conType,
                                     auth_type_to_pass,
                                     NULL,
                                     NULL, NULL,
                                     (char *)[login cStringUsingEncoding:NSUTF8StringEncoding], (char *)[login cStringUsingEncoding:NSUTF8StringEncoding],
                                     (char *)[password cStringUsingEncoding:NSUTF8StringEncoding], NULL,
                                     imap_cached, NULL);

    if (err != MAIL_NO_ERROR) {
        NSException *exception = [NSException
                exceptionWithName:CTMemoryError
                reason:CTMemoryErrorDesc
                userInfo:nil];
        [exception raise];
    }

    err = mailstorage_connect(myStorage);
    if (err == MAIL_ERROR_LOGIN) {
        NSException *exception = [NSException
                exceptionWithName:CTLoginError
                reason:CTLoginErrorDesc
                userInfo:nil];
        [exception raise];
    }
    else if (err != MAIL_NO_ERROR) {
        NSException *exception = [NSException
                exceptionWithName:CTUnknownError
                reason:[NSString stringWithFormat:@"Error number: %d",err]
                userInfo:nil];
        [exception raise];
    }
    else
        connected = YES;
}

The Exception occurs If I enter different Port number that time the exception raises in the following line
NSException *exception = [NSException
                    exceptionWithName:CTUnknownError
                    reason:[NSString stringWithFormat:@"Error number: %d",err]
                    userInfo:nil];
            [exception raise]; // this line kills the app if the app is in background.

These functions are in MailCore Library. Now if someone knows the solution please help me.

A: Have you registered an uncaughtExceptionHandler for your application? Also, Apple does recommend that you cancel any open network requests (or at least be prepared for them to fail) prior to shutting down (use -  (void)applicationDidEnterBackground:(UIApplication *)application). See the "Being a Responsible Background Application" section of this link: https://developer.apple.com/library/ios/DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html#//apple_ref/doc/uid/TP40007072-CH4-SW47