问:
CUDA + C++ don't play well together
Have been attempting to code a parallel version of AES to work on CUDA.
After finally finishing off the last few CUDA problems, so I started a compilation test to ensure if things would be working. However I hit a major detour.

```<code>1>------ Build started: Project: AES-CUDA, Configuration: Debug Win32 ------
1>Build started 05/17/2011 3:53:27 AM.
1>InitializeBuildStatus:
1>  Touching "Debug\AES-CUDA.unsuccessfulbuild".
1>CudaBuild:
1>  Compiling CUDA source file AES.cu...
1>
1>  C:\Users\*\Documents\Visual Studio 2010\Projects\AES-CUDA\AES-CUDA>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\bin\nvcc.exe" -gencode=arch=compute_20,code=\"sm_20,compute_20\" --use-local-env --cl-version 2010 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin"  -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include"  -G0  --keep-dir "Debug" -maxrregcount=0  --machine 32 --compile  -D_NEXUS_DEBUG -g    -Xcompiler "/EHsc /nologo /Od /Zi  /MDd " -o "Debug\AES.cu.obj" "C:\Users\*\Documents\Visual Studio 2010\Projects\AES-CUDA\AES-CUDA\AES.cu"
1>  AES.cu
1>  tmpxft_00001bd8_00000000-0_AES.cudafe1.gpu
1>  tmpxft_00001bd8_00000000-5_AES.cudafe2.gpu
1>  AES.cu
1>  tmpxft_00001bd8_00000000-0_AES.cudafe1.cpp
1>  tmpxft_00001bd8_00000000-11_AES.ii
1>  Deleting file "tmpxft_00001bd8_00000000-6_AES.cpp3.o".
1>ClCompile:
1>  main.cpp
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(12): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(12): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(12): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(12): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(12): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(12): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(12): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(12): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(55): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(55): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(55): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(55): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(55): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(55): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(55): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(55): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(60): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(60): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(64): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(64): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(66): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(66): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(66): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(66): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(67): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(67): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(67): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(67): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(68): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(68): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(68): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(68): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(69): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(69): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(79): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(79): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(80): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(80): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(81): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(81): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(82): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(82): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(84): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(84): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(85): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(85): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(86): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(86): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(87): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(87): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(93): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(93): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(93): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(93): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(93): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(93): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(93): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(93): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(98): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(98): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(102): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(102): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(104): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(104): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(104): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(104): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(105): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(105): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(105): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(105): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(106): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(106): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(106): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(106): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(107): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(107): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(117): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(117): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(118): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(118): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(119): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(119): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(120): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(120): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(122): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(122): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(123): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(123): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(124): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(124): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(125): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(125): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(136): error C2664: 'cudaMallocPitch' : cannot convert parameter 1 from 'unsigned char **' to 'void **'
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(142): error C2664: 'cudaMallocPitch' : cannot convert parameter 1 from 'unsigned char **' to 'void **'
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(147): error C2664: 'cudaMalloc' : cannot convert parameter 1 from 'unsigned char **' to 'void **'
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(170): error C2059: syntax error : '<'
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(175): error C2059: syntax error : '<'
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(176): error C2059: syntax error : '<'
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(177): error C2059: syntax error : '<'
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(178): error C2059: syntax error : '<'
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(182): error C2059: syntax error : '<'
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(182): fatal error C1003: error count exceeds 100; stopping compilation
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:02.56
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
</code>```

I have attached the proper CUDA 4.0 build customizations to my VS project as you can see from the build log. However the C++ compiler is re-interpreting the CUDA source file. Any ideas are appreciated.

答:
It appears you are including aes.cu from main.cpp, which is generally not a good idea.  If you need to mix host and device code, you should generally do it in .cu files, compiled using nvcc.  If you have functions that should be called from both host and device code, you can declare them as such:

```<code>__host__ __device__ int foo() { return do_something(); }
</code>```

However note that in these functions you can't use device-specific constructs like threadIdx.x.  If you have a __device__ __host__ function that needs to use device-specific constructs when running on the device, you can wrap that code in #ifdef __CUDA_ARCH__:

```<code>__host__ __device__ int sharedFunction {
#ifdef __CUDA_ARCH__
    return threadIdx.x * do_something();
#else
    return do_something_on_the_cpu();
#endif
}
</code>```

Title: CUDA + C++ don't play well together

Body:
Have been attempting to code a parallel version of AES to work on CUDA.
After finally finishing off the last few CUDA problems, so I started a compilation test to ensure if things would be working. However I hit a major detour.

1>------ Build started: Project: AES-CUDA, Configuration: Debug Win32 ------
1>Build started 05/17/2011 3:53:27 AM.
1>InitializeBuildStatus:
1>  Touching "Debug\AES-CUDA.unsuccessfulbuild".
1>CudaBuild:
1>  Compiling CUDA source file AES.cu...
1>
1>  C:\Users\*\Documents\Visual Studio 2010\Projects\AES-CUDA\AES-CUDA>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\bin\nvcc.exe" -gencode=arch=compute_20,code=\"sm_20,compute_20\" --use-local-env --cl-version 2010 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin"  -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include"  -G0  --keep-dir "Debug" -maxrregcount=0  --machine 32 --compile  -D_NEXUS_DEBUG -g    -Xcompiler "/EHsc /nologo /Od /Zi  /MDd " -o "Debug\AES.cu.obj" "C:\Users\*\Documents\Visual Studio 2010\Projects\AES-CUDA\AES-CUDA\AES.cu"
1>  AES.cu
1>  tmpxft_00001bd8_00000000-0_AES.cudafe1.gpu
1>  tmpxft_00001bd8_00000000-5_AES.cudafe2.gpu
1>  AES.cu
1>  tmpxft_00001bd8_00000000-0_AES.cudafe1.cpp
1>  tmpxft_00001bd8_00000000-11_AES.ii
1>  Deleting file "tmpxft_00001bd8_00000000-6_AES.cpp3.o".
1>ClCompile:
1>  main.cpp
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(12): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(12): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(12): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(12): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(12): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(12): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(12): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(12): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(55): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(55): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(55): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(55): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(55): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(55): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(55): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(55): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(60): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(60): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(64): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(64): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(66): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(66): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(66): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(66): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(67): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(67): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(67): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(67): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(68): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(68): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(68): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(68): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(69): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(69): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(79): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(79): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(80): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(80): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(81): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(81): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(82): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(82): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(84): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(84): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(85): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(85): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(86): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(86): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(87): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(87): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(93): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(93): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(93): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(93): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(93): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(93): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(93): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(93): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(98): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(98): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(102): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(102): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(104): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(104): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(104): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(104): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(105): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(105): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(105): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(105): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(106): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(106): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(106): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(106): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(107): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(107): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(117): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(117): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(118): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(118): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(119): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(119): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(120): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(120): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(122): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(122): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(123): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(123): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(124): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(124): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(125): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(125): error C2228: left of '.x' must have class/struct/union
1>          type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(136): error C2664: 'cudaMallocPitch' : cannot convert parameter 1 from 'unsigned char **' to 'void **'
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(142): error C2664: 'cudaMallocPitch' : cannot convert parameter 1 from 'unsigned char **' to 'void **'
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(147): error C2664: 'cudaMalloc' : cannot convert parameter 1 from 'unsigned char **' to 'void **'
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(170): error C2059: syntax error : '<'
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(175): error C2059: syntax error : '<'
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(176): error C2059: syntax error : '<'
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(177): error C2059: syntax error : '<'
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(178): error C2059: syntax error : '<'
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(182): error C2059: syntax error : '<'
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(182): fatal error C1003: error count exceeds 100; stopping compilation
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:02.56
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I have attached the proper CUDA 4.0 build customizations to my VS project as you can see from the build log. However the C++ compiler is re-interpreting the CUDA source file. Any ideas are appreciated.

Body:
It appears you are including aes.cu from main.cpp, which is generally not a good idea.  If you need to mix host and device code, you should generally do it in .cu files, compiled using nvcc.  If you have functions that should be called from both host and device code, you can declare them as such:

__host__ __device__ int foo() { return do_something(); }

However note that in these functions you can't use device-specific constructs like threadIdx.x.  If you have a __device__ __host__ function that needs to use device-specific constructs when running on the device, you can wrap that code in #ifdef __CUDA_ARCH__:

__host__ __device__ int sharedFunction {
#ifdef __CUDA_ARCH__
    return threadIdx.x * do_something();
#else
    return do_something_on_the_cpu();
#endif
}


来源: stackexchange

问:
Unable to add in the text colour of my menu navbar
This should be a fairly simple thing, however no matter where I add in color: black; the menu items do not show, you can only see them when I click and highlight over them. Please could someone point out which class needs to color tag to alter the text colour to black? I have tried placing it in .topnav with color: black; but did not change anything?

Also I can't get the active class to change when I'm on a different page, seems to only stay on the Home page?

```<code>.topnav {
  background-color:white;
  overflow: hidden;
}

/* Style the links inside the navigation bar */
.topnav a {
  float: left;
  display: block;
  color: black;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 17px;
}

/* Add an active class to highlight the current page */
.active {
  background-color: grey;
  color: white;
}

/* Hide the link that should open and close the topnav on small screens */
.topnav .icon {
  display: none;
}

/* Dropdown container - needed to position the dropdown content */
.dropdown {
  float: left;
  overflow: hidden;
}

/* Style the dropdown button to fit inside the topnav */
.dropdown .dropbtn {
  font-size: 17px;
  border: none;
  outline: none;
  color: white;
  padding: 14px 16px;
  background-color: inherit;
  font-family: inherit;
  margin: 0;
}

/* Style the dropdown content (hidden by default) */
.dropdown-content {
  display: none;
  position: absolute;
  background-color: #f9f9f9;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
  z-index: 1;
}

/* Style the links inside the dropdown */
.dropdown-content a {
  float: none;
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  text-align: left;
}

/* Add a dark background on topnav links and the dropdown button on hover */
.topnav a:hover, .dropdown:hover .dropbtn {
  background-color: #555;
  color: white;
}

/* Add a grey background to dropdown links on hover */
.dropdown-content a:hover {
  background-color: #ddd;
  color: black;
}

/* Show the dropdown menu when the user moves the mouse over the dropdown button */
.dropdown:hover .dropdown-content {
  display: block;
}
</code>```

THE MENU CODE:

```<code><!-- NAV BAR homepage-->
<nav>
  <!-- https://www.w3schools.com/howto/howto_js_topnav_responsive.asp -->
  <div class="topnav" id="myTopnav">
      <a href="index.php" class="active"><i class="fas fa-home">  Home</i></a>
      <a href="about.php"><i class="fas fa-info-circle">  About</i></a>
      <a href="contact.php"><i class="fas fa-envelope">  Contact</i></a>
      <?php
        // The below is a small 'if else' statement which depending on whether a user is logged in or not, the menu items will differ
        // If logged in, then show the logout and the dashboard item
        // If not logged in, then show the login and signup button
        if (!isset($_SESSION['studentID'])) {
          echo "<a name='login-submit' href='login.php'><i class='fas fa-sign-in-alt'>  Login</i></a>";
          echo "<a href='signup.php'><i class='fas fa-check-square'>  Sign Up</i></a>";
        } else if (isset($_SESSION['studentID'])) {
          echo "<a href ='dashboard.php'><i class='fas fa-tachometer-alt'>  Dashboard</i></a> ";
          echo "<a name='logout-submit' href='scripts/logout-script.php'><i class='fas fa-sign-out-alt'>  Logout</i></a>";
        }
      ?>
      <a href="javascript:void(0);" style="font-size:15px;" class="icon" onclick="menu2Function()">☰</a>
  </div>
</nav>
</code>```

I have right clicked into the console to check the styles tab:

This is what I see on my screen without hovering over an item in the menu:

Then this is what I see when I hover over an item (About):

答:
a good way to assure if the color is not being overwritten you can put "!important" after the color like the following code below

.top-nav {
color:black !important;
}```

ContentLicense: CC BY-SA 4.0

Body:
This should be a fairly simple thing, however no matter where I add in color: black; the menu items do not show, you can only see them when I click and highlight over them. Please could someone point out which class needs to color tag to alter the text colour to black? I have tried placing it in .topnav with color: black; but did not change anything?

Also I can't get the active class to change when I'm on a different page, seems to only stay on the Home page?

.topnav {
  background-color:white;
  overflow: hidden;
}

/* Style the links inside the navigation bar */
.topnav a {
  float: left;
  display: block;
  color: black;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 17px;
}

/* Add an active class to highlight the current page */
.active {
  background-color: grey;
  color: white;
}

/* Hide the link that should open and close the topnav on small screens */
.topnav .icon {
  display: none;
}

/* Dropdown container - needed to position the dropdown content */
.dropdown {
  float: left;
  overflow: hidden;
}

/* Style the dropdown button to fit inside the topnav */
.dropdown .dropbtn {
  font-size: 17px;
  border: none;
  outline: none;
  color: white;
  padding: 14px 16px;
  background-color: inherit;
  font-family: inherit;
  margin: 0;
}

/* Style the dropdown content (hidden by default) */
.dropdown-content {
  display: none;
  position: absolute;
  background-color: #f9f9f9;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
  z-index: 1;
}

/* Style the links inside the dropdown */
.dropdown-content a {
  float: none;
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  text-align: left;
}

/* Add a dark background on topnav links and the dropdown button on hover */
.topnav a:hover, .dropdown:hover .dropbtn {
  background-color: #555;
  color: white;
}

/* Add a grey background to dropdown links on hover */
.dropdown-content a:hover {
  background-color: #ddd;
  color: black;
}

/* Show the dropdown menu when the user moves the mouse over the dropdown button */
.dropdown:hover .dropdown-content {
  display: block;
}

THE MENU CODE:

        Home
        About
        Contact
      <?php
        // The below is a small 'if else' statement which depending on whether a user is logged in or not, the menu items will differ
        // If logged in, then show the logout and the dashboard item
        // If not logged in, then show the login and signup button
        if (!isset($_SESSION['studentID'])) {
          echo "  Login";
          echo "  Sign Up";
        } else if (isset($_SESSION['studentID'])) {
          echo "  Dashboard ";
          echo "  Logout";
        }
      ?>
      ☰

I have right clicked into the console to check the styles tab:

This is what I see on my screen without hovering over an item in the menu:

Then this is what I see when I hover over an item (About):


问:
FTP with command to mainframe dataset
Is there a way to FTP a file to a mainframe dataset and run a command like this?

"SITE RECL=150"

I was able to do it with an FTP library called Fluent FTP. Are there any other free libraries that support this or another way to do it with code besides using a third party library using C#?

答:
You could investigate other FTP libraries, such as edtFTPnet/Free:

https://enterprisedt.com/products/edtftpnet/

However, a couple questions:

Should you be interacting with the mainframe via file transfers at all? File transfers are inherently batch-oriented. If your end users have batch-oriented expectations, OK, fair enough. But is that true now, and will they in the future? Mainframes offer myriad choices for bidirectional, transactional, online-oriented interactions, so you don't have to insert unnecessary/unwanted delays in business processes (if that's what you're trying to do or at least to perpetuate).

How about shifting to a REST API interaction, even if you must use a file transfer? If the mainframe in question is running z/OS, the z/OS Management Facility (z/OSMF) provides the "z/OS data set and file REST interface" that shouldn't require any extra FTP library at all. z/OSMF is included as a standard, IBM supported feature with the base z/OS operating system license at no additional charge. All IBM supported releases of z/OS (and a couple now unsupported, older z/OS releases) include z/OSMF. IBM z/OSMF documentation is available here (z/OS 2.4 assumed, and this link is otherwise subject to change):

https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.4.0/com.ibm.zos.v2r4.izu/izu.htm

Title: FTP with command to mainframe dataset


问:
Flutter Web (Beta), Dart, Can't get asynchronous Future function to finish - with JSON Firestore wrapper plugin - asyc, await, Future
I'm writing a web app with Flutter (Flutter web available on beta channel), and the official, Google supported, Firebase library doesn't support the web version of flutter.

I'm using an open source plugin (which has been incredible), acting as a wrapper for the JSON end point functionality of Firebase.
Plugin: https://pub.dev/packages/firebase

```<code>Future<List<Item>> pullItems(int zip, String key, int index) async {
    List<Item> itemList = [];
    final ref = store.collection("vendors-global").doc("usa").collection(zip.toString()).doc(key).collection("items");
    int i = 0;
    ref.onSnapshot.listen((querySnapshot) {
      final int snapSize = querySnapshot.size;
    querySnapshot.forEach((field) {
      var item = field.data();
      print(key + " : " + field.id);     //this prints all the items in ea. key, for debugg
      Item itemObject = new Item(item['name']);
      itemList.add(itemObject);
      i++;
      if (i == snapSize) { //this counter is how I triggered this function off after a
                     //similar function before it finished, where the parent keys came from.
        return itemList;
      }
      });
    });
  return itemList;
}
</code>```

The issue seems to be with the .onSnapshot.listen((querySnapshot), specifically the .listen, being an open connection. I've seen this done where the list of Items is defined in a one line call to the Firestore beginning with an await statement, and ending with .map(()..).toList(). But it was with the standard google API which seems to have some more flexibility.

```<code>Future<List<Item>> loadItems() async {
      final List<Item> itemList = (await Firestore.instance.collection('items').getDocuments()).documents.map((snapshot) => Item(doc['kode'], doc['name'])).toList();
      return itemList;
    }
</code>```

The practical issue is that this future function immediately returns the blank List itemList = []; due to the return at the bottom. However, if I remove the bottom return it throws a warning and won't compute at that point.

Is there any way to use the .onSnapshot listen functionality to traverse through a number of docs in a collection, and return them as a list?

Thanks so much for any input, this has been frustrating me for 10+ hours

答:
What you need is to use a Completer ... This works just like a promise deferal in javascript if you are familiar with that.  Check it out:

```<code>Future<List<Item>> pullItems(int zip, String key, int index) {
    Completer<List<Item>> completer = Completer();
    List<Item> itemList = [];
    final ref = store.collection("vendors-global").doc("usa").collection(zip.toString()).doc(key).collection("items");
    int i = 0;
    ref.onSnapshot.listen((querySnapshot) {
      final int snapSize = querySnapshot.size;
    querySnapshot.forEach((field) {
      var item = field.data();
      print(key + " : " + field.id);     //this prints all the items in ea. key, for debugg
      Item itemObject = new Item(item['name']);
      itemList.add(itemObject);
      i++;
      if (i == snapSize) { //this counter is how I triggered this function off after a
                     //similar function before it finished, where the parent keys came from.
        completer.complete(itemList);
      }
      });
    });
  return completer.future;
}
</code>```

Notice how I removed the async from the end of your function .. the async is there to automatically create the Future<List<Item>> for you if there are any await calls used inside of the function.  Since you are using callbacks instead of await then you should just use the Completer to handle your future for you.  It returns the future and will trigger any code waiting on its "completion" when completer.complete(...) is called.

Body:
I'm writing a web app with Flutter (Flutter web available on beta channel), and the official, Google supported, Firebase library doesn't support the web version of flutter.

I'm using an open source plugin (which has been incredible), acting as a wrapper for the JSON end point functionality of Firebase.
Plugin: https://pub.dev/packages/firebase

Future<List<Item>> pullItems(int zip, String key, int index) async {
    List<Item> itemList = [];
    final ref = store.collection("vendors-global").doc("usa").collection(zip.toString()).doc(key).collection("items");
    int i = 0;
    ref.onSnapshot.listen((querySnapshot) {
      final int snapSize = querySnapshot.size;
    querySnapshot.forEach((field) {
      var item = field.data();
      print(key + " : " + field.id);     //this prints all the items in ea. key, for debugg
      Item itemObject = new Item(item['name']);
      itemList.add(itemObject);
      i++;
      if (i == snapSize) { //this counter is how I triggered this function off after a
                     //similar function before it finished, where the parent keys came from.
        return itemList;
      }
      });
    });
  return itemList;
}

The issue seems to be with the .onSnapshot.listen((querySnapshot), specifically the .listen, being an open connection. I've seen this done where the list of Items is defined in a one line call to the Firestore beginning with an await statement, and ending with .map(()..).toList(). But it was with the standard google API which seems to have some more flexibility.

Future<List<Item>> loadItems() async {
      final List<Item> itemList = (await Firestore.instance.collection('items').getDocuments()).documents.map((snapshot) => Item(doc['kode'], doc['name'])).toList();
      return itemList;
    }

The practical issue is that this future function immediately returns the blank List itemList = []; due to the return at the bottom. However, if I remove the bottom return it throws a warning and won't compute at that point.

Is there any way to use the .onSnapshot listen functionality to traverse through a number of docs in a collection, and return them as a list?

Thanks so much for any input, this has been frustrating me for 10+ hours

Body:
What you need is to use a Completer ... This works just like a promise deferal in javascript if you are familiar with that.  Check it out:

Future<List<Item>> pullItems(int zip, String key, int index) {
    Completer<List<Item>> completer = Completer();
    List<Item> itemList = [];
    final ref = store.collection("vendors-global").doc("usa").collection(zip.toString()).doc(key).collection("items");
    int i = 0;
    ref.onSnapshot.listen((querySnapshot) {
      final int snapSize = querySnapshot.size;
    querySnapshot.forEach((field) {
      var item = field.data();
      print(key + " : " + field.id);     //this prints all the items in ea. key, for debugg
      Item itemObject = new Item(item['name']);
      itemList.add(itemObject);
      i++;
      if (i == snapSize) { //this counter is how I triggered this function off after a
                     //similar function before it finished, where the parent keys came from.
        completer.complete(itemList);
      }
      });
    });
  return completer.future;
}

Notice how I removed the async from the end of your function .. the async is there to automatically create the Future<List<Item>> for you if there are any await calls used inside of the function.  Since you are using callbacks instead of await then you should just use the Completer to handle your future for you.  It returns the future and will trigger any code waiting on its "completion" when completer.complete(...) is called.


问:
Vuejs get current year and following year
I want to create a select option with current date and next year date using vuejs

here is my code

```<code>new Vue ({
  el: '.container',
  methods: {
    getCurrentYear() {
      return new Date().getFullYear();
    }
  }
});
<div class="container">
  <select id="dob">
    <option value="0">Year:</option>
    <option v-for="year in getCurrentYear()" :value="year">{{ year }}</option>
  </select>
</code>```

Thanks for helping

答:
new Vue({
  el: '#app',

  data: {
    selectedYear: ''
  },

  computed: {
    getYears () {
      let currentDate = new Date()
      let currentYear = currentDate.getFullYear()
      let nextyear = currentYear++
      return [currentYear, nextyear]
    }
  }
})```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>

<div id="app">

  Currently selected year: {{ selectedYear }} <br>

  <select v-model="selectedYear">
    <option value="">select year</option>
    <option
      v-for="(year, i) in getYears"
      :key="i"
      :value="year"
    >
      {{ year }}
    </option>
  </select>

</div></code>```

Body:
I want to create a select option with current date and next year date using vuejs

here is my code

new Vue ({
  el: '.container',
  methods: {
    getCurrentYear() {
      return new Date().getFullYear();
    }
  }
});

  <select id="dob">
    <option value="0">Year:</option>
    <option v-for="year in getCurrentYear()" :value="year">{{ year }}</option>
  </select>

Thanks for helping

Body:
new Vue({
  el: '#app',

  data: {
    selectedYear: ''
  },

  computed: {
    getYears () {
      let currentDate = new Date()
      let currentYear = currentDate.getFullYear()
      let nextyear = currentYear++
      return [currentYear, nextyear]
    }
  }
})

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>

<div id="app">

  Currently selected year: {{ selectedYear }} <br>

  <select v-model="selectedYear">
    <option value="">select year</option>
    <option
      v-for="(year, i) in getYears"
      :key="i"
      :value="year"
    >
      {{ year }}
    </option>
  </select>

</div>


问:
How to dyn_cast in LLVM to identify StoreInst?
I'm trying to identify StoreInst. I read LLVM manual, and tried to use dyn_cast to do that. But the following program returns very weird result.

```<code>bool runOnFunction(Function &F) override{
    for (const BasicBlock &BB : F){
        for (const Instruction &I : BB){
            const char *s = I.getOpcodeName();
            std::string str(s);
            errs()<<"at the instruction of "<<str<<"\n";
            if (const StoreInst *SI = dyn_cast<StoreInst>(&I))
                    errs()<<"FOUND STORE\n";
        }
    }
    return true;
}
</code>```

The result is as followed. dyn_cast somehow returns true when the instruction is actually a CallInst. Anyone know why this happened? And how can I fix it? btw, I've installed some old versions of LLVM on the same machine, but think I compiled the pass under LLVM-7.0.0, and get the .ll file using clang-7.0.0 by clang-7 -O0 -S -emit-llvm HelloWorld.cpp. Would the previous installed versions affect this version? Thanks!!

```<code>at the instruction of call
at the instruction of call
at the instruction of ret
at the instruction of alloca
FOUND STORE
at the instruction of alloca
FOUND STORE
at the instruction of alloca
FOUND STORE
at the instruction of store
at the instruction of store
at the instruction of store
at the instruction of call
at the instruction of call
at the instruction of ret
at the instruction of call
at the instruction of ret
</code>```

答: I suspect, since your pass is a FunctionPass, it runs in parallel on multiple functions, so your log messages are printed out of order.

Body:
I'm trying to identify StoreInst. I read LLVM manual, and tried to use dyn_cast to do that. But the following program returns very weird result.

bool runOnFunction(Function &F) override{
    for (const BasicBlock &BB : F){
        for (const Instruction &I : BB){
            const char *s = I.getOpcodeName();
            std::string str(s);
            errs()<<"at the instruction of "<<str<<"\n";
            if (const StoreInst *SI = dyn_cast<StoreInst>(&I))
                    errs()<<"FOUND STORE\n";
        }
    }
    return true;
}

The result is as followed. dyn_cast somehow returns true when the instruction is actually a CallInst. Anyone know why this happened? And how can I fix it? btw, I've installed some old versions of LLVM on the same machine, but think I compiled the pass under LLVM-7.0.0, and get the .ll file using clang-7.0.0 by clang-7 -O0 -S -emit-llvm HelloWorld.cpp. Would the previous installed versions affect this version? Thanks!!

at the instruction of call
at the instruction of call
at the instruction of ret
at the instruction of alloca
FOUND STORE
at the instruction of alloca
FOUND STORE
at the instruction of alloca
FOUND STORE
at the instruction of store
at the instruction of store
at the instruction of store
at the instruction of call
at the instruction of call
at the instruction of ret
at the instruction of call
at the instruction of ret


问:
Any way to get correct output after passing positional named argument (*args, **kwargs) to function?
I was trying to filter dataframe based on the list of named arguments, thanks to @MkWTF on this post. However, I want to use *args as an argument to loop through then use the filtering function, which means I am going to have a list of filtered dataframe based on named argument as an output.

in my case, I need to use cty_rpt column as named argument (*args) to loop through the country code then use filtering function to get filtered dataframe:

minimal data

here is the minimal data that posted on gist minimal data

attempt:

```<code>import pandas as pd

df=pd.read_csv('mydf.csv', encoding='utf-8')
def data_filter(df, startDate, endDate, date_colname="date", inplace=False, **kwargs):
  s = ''
  for i,j in kwargs.items():
      s += '{}=="{}"&'.format(i,j)
  s += '{}>"{}"&'.format(date_colname, startDate)
  s += '{}<"{}"'.format(date_colname, endDate)
  return df.query(s, inplace=inplace)
</code>```

the idea is first subset df by looping through its df.cty_rpt then each subsetted dataframe further filtered by list of **kwargs, which would make list of filtered dataframe.

I feel like above attempt might be realized as follow:

new attempt to change the definition of my function

```<code>def func1(df, *args, startDate, endDate, date_col='date', inplace=False, **kwargs):
    output = []
    for arg in pd.unique(args):
        s = ''
        for i, j in kwargs.items():
            s += '{}=="{}"&'.format(i,j)
        s += '{}>"{}"&'.format(date_colname, startDate)
        s += '{}<"{}"'.format(date_colname, endDate)
        res = df.query(s, inplace=inplace)
        res = df.query(arg, inplace=False)
        output.append(res)
    return output

func1(df, df.cty_rpt,startDate='2013-12-31', endDate='2019-01-01', meat_type='Beef', temperature='Chilled',flow='E')
</code>```

but I got empty list, I don't understand what's going on here. Any idea? where is the bug of my attempt? any quick solution on that?

goal:

I want to get a list of dataframe where each dataframe can be filtered by country code wise. I was explicitly looping through df.cty_rpt then use dataa_filter function, but I feel like using *args would simplify that but I couldn't get what I actually need. Any idea to get this done? thanks

答:
I hope this gets you part way there. With your *args strategy, it appears that you want to query on unique values in (potentially) several columns. You can use pd.unique to get unique values from any one column and an outer for to extend that to multiple columns. I don't know how you want to handle multiple columns exactly, so I just guessed on one way.

You can build most of the query before starting the loop for unique cty_rpt values. Do it an a list and build the string per query.

I couldn't get this to work when adding in the start/end dates, so I left it commented out.

```<code>import pandas as pd

def func1(df, *args, startDate, endDate, date_col='date', inplace=False, **kwargs):
    output = []
    query_terms = ['{}=="{}"'.format(*item) for item in kwargs.items()]

    # Todo: This didn't work for me, date query needs to be debugged
    # query_terms += [
    #    '{}>"{}"'.format(date_col, startDate),
    #    '{}<"{}"'.format(date_col, endDate)]

    for series in args:
        for name in pd.unique(series):
            print('querying', series.name, name)
            s = "&".join(query_terms + ['{}=="{}"'.format(series.name, name)])
            res = df.query(s, inplace=inplace) # todo: i think inplace should always be false
            output.append(res)
    return output

df = pd.read_csv("mydf.csv", encoding="utf-8")
print(df)
result = func1(df, df.cty_rpt,startDate='2013-12-31', endDate='2019-01-01', meat_type='Beef', temperature='Chilled',flow='E')

for res in result:
    print('------------------------------')
    print(res)
</code>```

Output

```<code>    Unnamed: 0 flow cty_rpt     origin           destination      value      qty1       date animal_type meat_type temperature
0            0    E      AR  Argentina               Albania  115691.00  18.26200   1/1/2017      Bovine      Beef      Frozen
1            1    I      AR  Argentina               Albania   72425.20  19.17100   1/1/2016      Bovine      Beef      Frozen
2            2    I      US  Argentina                Angola  109523.15  50.94100   5/1/2014      Bovine      Beef      Frozen
3            3    E      US  Argentina  United Arab Emirates    1078.00   0.15300  10/1/2014      Bovine      Beef     Chilled
4            4    E      US  Argentina               Albania    3373.00   0.26200  12/1/2014      Bovine      Pork      Frozen
5            5    E      US  Argentina                Angola   36308.77   9.55494   4/1/2015      Bovine      Pork      Frozen
6            6    E      AR  Argentina                Angola   10654.65   0.87569   6/1/2017      Bovine      Pork     Chilled
7            7    E      AR  Argentina  United Arab Emirates      86.50   0.02000   7/1/2016      Bovine      Pork     Chilled
8            8    I      AR  Argentina                Angola   68797.00  12.12000   1/1/2014      Bovine      Beef     Chilled
9            9    I     AUC  Argentina                Angola   42000.00  21.00000   2/1/2017      Bovine      Beef      Frozen
10          10    I     AUC  Argentina               Albania  180078.00  26.79100  12/1/2017      Bovine      Beef      Frozen
11          11    I     AUC  Argentina                Angola  194402.47  45.29000   1/1/2015      Bovine      Pork      Frozen
12          12    I     AUC  Argentina  United Arab Emirates   97928.05   6.47850   1/1/2014      Bovine      Pork     Chilled
13          13    E      US  Argentina                Angola   61430.00  10.85000   4/1/2014      Bovine      Beef     Chilled
14          14    E      US  Argentina                Angola    4153.80   1.97800  12/1/2014      Bovine      Beef      Frozen
15          15    E      US  Argentina               Albania   55599.30  10.29300   6/1/2014      Bovine      Beef      Frozen
16          16    I      US  Argentina                Angola   11531.00   0.20100  10/1/2014      Bovine      Beef      Frozen
17          17    I      AR  Argentina  United Arab Emirates    1908.50   0.17800   4/1/2017      Bovine      Pork      Frozen
18          18    I      AR  Argentina                Angola   59476.10  10.85600   1/1/2018      Bovine      Pork      Frozen
19          19    E      CN  Argentina                Angola  452174.70  74.82600  12/1/2014      Bovine      Pork      Frozen
20          20    E      CN  Argentina               Albania  101596.00  13.57200  11/1/2014      Bovine      Pork      Frozen
21          21    E      KR  Argentina                Angola  135035.00  27.00700   5/1/2014      Bovine      Beef      Frozen
22          22    E      KR  Argentina                Angola   86506.00  46.76000  10/1/2015      Bovine      Beef      Frozen
23          23    I      KR  Argentina             Argentina  300876.85  24.53188   3/1/2014      Bovine      Beef     Chilled
24          24    E      KR  Argentina               Albania  475380.06  72.74437   9/1/2015      Bovine      Pork      Frozen
25          25    E      AR  Argentina               Albania   80396.00   8.77800   1/1/2018      Bovine      Pork      Frozen
26          26    I      AR  Argentina  United Arab Emirates     160.00   0.02000  11/1/2014      Bovine      Pork     Chilled
27          27    I      US  Argentina               Albania  212000.00  26.50000  10/1/2015      Bovine      Beef      Frozen
28          28    E      US  Argentina               Albania  164459.08  20.70592  12/1/2015      Bovine      Beef      Frozen
29          29    E     AUC  Argentina               Albania  235810.00  49.22200   3/1/2015      Bovine      Beef      Frozen
querying cty_rpt AR
querying cty_rpt US
querying cty_rpt AUC
querying cty_rpt CN
querying cty_rpt KR
------------------------------
Empty DataFrame
Columns: [Unnamed: 0, flow, cty_rpt, origin, destination, value, qty1, date, animal_type, meat_type, temperature]
Index: []
------------------------------
    Unnamed: 0 flow cty_rpt     origin           destination    value    qty1       date animal_type meat_type temperature
3            3    E      US  Argentina  United Arab Emirates   1078.0   0.153  10/1/2014      Bovine      Beef     Chilled
13          13    E      US  Argentina                Angola  61430.0  10.850   4/1/2014      Bovine      Beef     Chilled
------------------------------
Empty DataFrame
Columns: [Unnamed: 0, flow, cty_rpt, origin, destination, value, qty1, date, animal_type, meat_type, temperature]
Index: []
------------------------------
Empty DataFrame
Columns: [Unnamed: 0, flow, cty_rpt, origin, destination, value, qty1, date, animal_type, meat_type, temperature]
Index: []
------------------------------
Empty DataFrame
Columns: [Unnamed: 0, flow, cty_rpt, origin, destination, value, qty1, date, animal_type, meat_type, temperature]
Index: []
</code>```

Body:
I was trying to filter dataframe based on the list of named arguments, thanks to @MkWTF on this post. However, I want to use *args as an argument to loop through then use the filtering function, which means I am going to have a list of filtered dataframe based on named argument as an output.

in my case, I need to use cty_rpt column as named argument (*args) to loop through the country code then use filtering function to get filtered dataframe:

minimal data

here is the minimal data that posted on gist minimal data

attempt:

import pandas as pd

df=pd.read_csv('mydf.csv', encoding='utf-8')
def data_filter(df, startDate, endDate, date_colname="date", inplace=False, **kwargs):
  s = ''
  for i,j in kwargs.items():
      s += '{}=="{}"&'.format(i,j)
  s += '{}>"{}"&'.format(date_colname, startDate)
  s += '{}<"{}"'.format(date_colname, endDate)
  return df.query(s, inplace=inplace)

the idea is first subset df by looping through its df.cty_rpt then each subsetted dataframe further filtered by list of **kwargs, which would make list of filtered dataframe.

I feel like above attempt might be realized as follow:

new attempt to change the definition of my function

def func1(df, *args, startDate, endDate, date_col='date', inplace=False, **kwargs):
    output = []
    for arg in pd.unique(args):
        s = ''
        for i, j in kwargs.items():
            s += '{}=="{}"&'.format(i,j)
        s += '{}>"{}"&'.format(date_colname, startDate)
        s += '{}<"{}"'.format(date_colname, endDate)
        res = df.query(s, inplace=inplace)
        res = df.query(arg, inplace=False)
        output.append(res)
    return output

func1(df, df.cty_rpt,startDate='2013-12-31', endDate='2019-01-01', meat_type='Beef', temperature='Chilled',flow='E')

but I got empty list, I don't understand what's going on here. Any idea? where is the bug of my attempt? any quick solution on that?

goal:

I want to get a list of dataframe where each dataframe can be filtered by country code wise. I was explicitly looping through df.cty_rpt then use dataa_filter function, but I feel like using *args would simplify that but I couldn't get what I actually need. Any idea to get this done? thanks

Body:
I hope this gets you part way there. With your *args strategy, it appears that you want to query on unique values in (potentially) several columns. You can use pd.unique to get unique values from any one column and an outer for to extend that to multiple columns. I don't know how you want to handle multiple columns exactly, so I just guessed on one way.

You can build most of the query before starting the loop for unique cty_rpt values. Do it an a list and build the string per query.

I couldn't get this to work when adding in the start/end dates, so I left it commented out.

import pandas as pd

def func1(df, *args, startDate, endDate, date_col='date', inplace=False, **kwargs):
    output = []
    query_terms = ['{}=="{}"'.format(*item) for item in kwargs.items()]

    # Todo: This didn't work for me, date query needs to be debugged
    # query_terms += [
    #    '{}>"{}"'.format(date_col, startDate),
    #    '{}<"{}"'.format(date_col, endDate)]

    for series in args:
        for name in pd.unique(series):
            print('querying', series.name, name)
            s = "&".join(query_terms + ['{}=="{}"'.format(series.name, name)])
            res = df.query(s, inplace=inplace) # todo: i think inplace should always be false
            output.append(res)
    return output

df = pd.read_csv("mydf.csv", encoding="utf-8")
print(df)
result = func1(df, df.cty_rpt,startDate='2013-12-31', endDate='2019-01-01', meat_type='Beef', temperature='Chilled',flow='E')

for res in result:
    print('------------------------------')
    print(res)

Output

    Unnamed: 0 flow cty_rpt     origin           destination      value      qty1       date animal_type meat_type temperature
0            0    E      AR  Argentina               Albania  115691.00  18.26200   1/1/2017      Bovine      Beef      Frozen
1            1    I      AR  Argentina               Albania   72425.20  19.17100   1/1/2016      Bovine      Beef      Frozen
2            2    I      US  Argentina                Angola  109523.15  50.94100   5/1/2014      Bovine      Beef      Frozen
3            3    E      US  Argentina  United Arab Emirates    1078.00   0.15300  10/1/2014      Bovine      Beef     Chilled
4            4    E      US  Argentina               Albania    3373.00   0.26200  12/1/2014      Bovine      Pork      Frozen
5            5    E      US  Argentina                Angola   36308.77   9.55494   4/1/2015      Bovine      Pork      Frozen
6            6    E      AR  Argentina                Angola   10654.65   0.87569   6/1/2017      Bovine      Pork     Chilled
7            7    E      AR  Argentina  United Arab Emirates      86.50   0.02000   7/1/2016      Bovine      Pork     Chilled
8            8    I      AR  Argentina                Angola   68797.00  12.12000   1/1/2014      Bovine      Beef     Chilled
9            9    I     AUC  Argentina                Angola   42000.00  21.00000   2/1/2017      Bovine      Beef      Frozen
10          10    I     AUC  Argentina               Albania  180078.00  26.79100  12/1/2017      Bovine      Beef      Frozen
11          11    I     AUC  Argentina                Angola  194402.47  45.29000   1/1/2015      Bovine      Pork      Frozen
12          12    I     AUC  Argentina  United Arab Emirates   97928.05   6.47850   1/1/2014      Bovine      Pork     Chilled
13          13    E      US  Argentina                Angola   61430.00  10.85000   4/1/2014      Bovine      Beef     Chilled
14          14    E      US  Argentina                Angola    4153.80   1.97800  12/1/2014      Bovine      Beef      Frozen
15          15    E      US  Argentina               Albania   55599.30  10.29300   6/1/2014      Bovine      Beef      Frozen
16          16    I      US  Argentina                Angola   11531.00   0.20100  10/1/2014      Bovine      Beef      Frozen
17          17    I      AR  Argentina  United Arab Emirates    1908.50   0.17800   4/1/2017      Bovine      Pork      Frozen
18          18    I      AR  Argentina                Angola   59476.10  10.85600   1/1/2018      Bovine      Pork      Frozen
19          19    E      CN  Argentina                Angola  452174.70  74.82600  12/1/2014      Bovine      Pork      Frozen
20          20    E      CN  Argentina               Albania  101596.00  13.57200  11/1/2014      Bovine      Pork      Frozen
21          21    E      KR  Argentina                Angola  135035.00  27.00700   5/1/2014      Bovine      Beef      Frozen
22          22    E      KR  Argentina                Angola   86506.00  46.76000  10/1/2015      Bovine      Beef      Frozen
23          23    I      KR  Argentina             Argentina  300876.85  24.53188   3/1/2014      Bovine      Beef     Chilled
24          24    E      KR  Argentina               Albania  475380.06  72.74437   9/1/2015      Bovine      Pork      Frozen
25          25    E      AR  Argentina               Albania   80396.00   8.77800   1/1/2018      Bovine      Pork      Frozen
26          26    I      AR  Argentina  United Arab Emirates     160.00   0.02000  11/1/2014      Bovine      Pork     Chilled
27          27    I      US  Argentina               Albania  212000.00  26.50000  10/1/2015      Bovine      Beef      Frozen
28          28    E      US  Argentina               Albania  164459.08  20.70592  12/1/2015      Bovine      Beef      Frozen
29          29    E     AUC  Argentina               Albania  235810.00  49.22200   3/1/2015      Bovine      Beef      Frozen
querying cty_rpt AR
querying cty_rpt US
querying cty_rpt AUC
querying cty_rpt CN
querying cty_rpt KR
------------------------------
Empty DataFrame
Columns: [Unnamed: 0, flow, cty_rpt, origin, destination, value, qty1, date, animal_type, meat_type, temperature]
Index: []
------------------------------
    Unnamed: 0 flow cty_rpt     origin           destination    value    qty1       date animal_type meat_type temperature
3            3    E      US  Argentina  United Arab Emirates   1078.0   0.153  10/1/2014      Bovine      Beef     Chilled
13          13    E      US  Argentina                Angola  61430.0  10.850   4/1/2014      Bovine      Beef     Chilled
------------------------------
Empty DataFrame
Columns: [Unnamed: 0, flow, cty_rpt, origin, destination, value, qty1, date, animal_type, meat_type, temperature]
Index: []
------------------------------
Empty DataFrame
Columns: [Unnamed: 0, flow, cty_rpt, origin, destination, value, qty1, date, animal_type, meat_type, temperature]
Index: []
------------------------------
Empty DataFrame
Columns: [Unnamed: 0, flow, cty_rpt, origin, destination, value, qty1, date, animal_type, meat_type, temperature]
Index: []


问:
Extract a string of words between multiple specific words in R
I have a long string that includes one or multiple keywords, "Realm" in this case. I have been using gsub, but that only takes the words after the last of the keywords.

so the string could look like:

...Attributes  \r\n      Realm - Afrotropical  \r\n  IUCN Ecosystem -- Terrestrial biome...

or

...Attributes  \r\n      Realm - Afrotropical  \r\n   Realm - Neotropical  \r\n .  IUCN Ecosystem -- Terrestrial biome...

I have been using the function:

```<code>Realm_fun<-function(x){gsub('^.*Realm -\\s*|\\s*IUCN Ecosystem.*$', '', x)}
</code>```

then using lapply to fun it on all of the strings.

what can I do to get Afrotropical for the first string and Afrotropical , Neotropical for the second?

答:
I do not know how exactly you need the words to be. But one idea could be:

```<code>  regmatches(st, gregexpr("Realm - \\K(\\w+)",st,perl = TRUE))
[[1]]
[1] "Afrotropical"

[[2]]
[1] "Afrotropical" "Neotropical"
</code>```

If you do not want to split the words:

```<code>trimws(gsub("(?m)^.*Realm - (\\w+)|((?!Realm).)*$","\\1 ",st,perl=TRUE))

[1] "Afrotropical"                "Afrotropical  \nNeotropical"

gsub("(?m)^(?:(?!Real).)*$|[\r\n]|.*Realm - ","",st, perl = TRUE)

[1] "Afrotropical  "              "Afrotropical  Neotropical  "
</code>```

Body:
I have a long string that includes one or multiple keywords, "Realm" in this case. I have been using gsub, but that only takes the words after the last of the keywords.

so the string could look like:

...Attributes  \r\n      Realm - Afrotropical  \r\n  IUCN Ecosystem -- Terrestrial biome...

or

...Attributes  \r\n      Realm - Afrotropical  \r\n   Realm - Neotropical  \r\n .  IUCN Ecosystem -- Terrestrial biome...

I have been using the function:

Realm_fun<-function(x){gsub('^.*Realm -\\s*|\\s*IUCN Ecosystem.*$', '', x)}

then using lapply to fun it on all of the strings.

what can I do to get Afrotropical for the first string and Afrotropical , Neotropical for the second?

Body:
I do not know how exactly you need the words to be. But one idea could be:

  regmatches(st, gregexpr("Realm - \\K(\\w+)",st,perl = TRUE))
[[1]]
[1] "Afrotropical"

[[2]]
[1] "Afrotropical" "Neotropical"

If you do not want to split the words:

trimws(gsub("(?m)^.*Realm - (\\w+)|((?!Realm).)*$","\\1 ",st,perl=TRUE))

[1] "Afrotropical"                "Afrotropical  \nNeotropical"

gsub("(?m)^(?:(?!Real).)*$|[\r\n]|.*Realm - ","",st, perl = TRUE)

[1] "Afrotropical  "              "Afrotropical  Neotropical  "


问:
Why is Angular routerLink (without leading slash) broken when navigating back to empty path?
Let's take this basic navigation tree:

primary

secondary

deep

Look at my Stackblitz project.

My routes are

```<code>const routes: Routes = [
  {
    path: "",
    component: PageParentComponent,
    children: [
      {
        path: "",
        component: PageChildPrimaryComponent
      },
      {
        path: "secondary",
        component: PageChildSecondaryComponent
      },
      {
        path: "secondary/deep",
        component: PageDeepComponent
      }
    ]
  }
];
</code>```

Using routerLink="..">, I can successfully navigate up one level,
and using routerLink="../.."> two levels.
However, when I use double dots to go back to the "primary" page from any deeper page,
any routerLink that doesn't start with a slash is messed up;
the root part of the URL (https://angular-ukxb4a.stackblitz.io/ or localhost:4200/, when run locally) is replaced with %28. When I use routerLink="/"> (slash instead of double dots), everything is fine.

Why is that happening?

答:
The URL you want to go is

https://angular-ukxb4a.stackblitz.io/secondary

NOT

https://%28secondary%29/

The starting slash will append path to your existing path.
I hope this will help you.

Body:
Let's take this basic navigation tree:

primary

secondary

deep

Look at my Stackblitz project.

My routes are

const routes: Routes = [
  {
    path: "",
    component: PageParentComponent,
    children: [
      {
        path: "",
        component: PageChildPrimaryComponent
      },
      {
        path: "secondary",
        component: PageChildSecondaryComponent
      },
      {
        path: "secondary/deep",
        component: PageDeepComponent
      }
    ]
  }
];

Using , I can successfully navigate up one level,
and using  two levels.
However, when I use double dots to go back to the "primary" page from any deeper page,
any routerLink that doesn't start with a slash is messed up;
the root part of the URL (https://angular-ukxb4a.stackblitz.io/ or localhost:4200/, when run locally) is replaced with %28. When I use  (slash instead of double dots), everything is fine.

Why is that happening?


问:
Same class on parent and child element for navigation ".nav-links" - Looking for best CSS solution
I have to create left section for a website ".leftpart" in which I have parent navigation class ".nav-links" with CSS properties. I have also have same class ".nav-links" as a sub section under parent ".nav-links". I want to give a different background color "red" to child ".nav-links" [Edit and Save]. Can you anyone suggest best way to do this ?

My code is below, thanks in advance :

.leftpart {
          width: 100%;
          display: block;
          margin: 20px;
        }

        .leftpart .nav-links ul {
          list-style: none;
          margin: 0;
          padding: 0;
          display: block;
        }

        .leftpart .nav-links ul li {
          margin-bottom:20px;
        }

        .leftpart .nav-links ul li a {
           background:green;
           color:#fff;
           padding: 20px;
           display: inline-block;
        }```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="leftpart">
        <div class="nav-links">
          <h1> Primary Links </h1>
          <ul>
            <li>
              Profile
            </li>

            <li>
              Friends
            </li>

            <li>
              Milestones
            </li>

            <li>
              Groups
            </li>
          </ul>

          <div class="sub-seciton">
              <div class="nav-links">
                <ul>
                  <li>
                    Edit
                  </li>

                  <li>
                    Save
                  </li>
                </ul>
              </div>
          </div>

        </div>

        <div class="nav-links">
          <h1> Secondary Links </h1>
          <ul>
            <li>
              Privacy
            </li>

            <li>
              Settings
            </li>
          </ul>
        </div>
    </div></code>```

答:
You need to target .nav-links inside the sub-section. You can also style your nav-links siblings separately. See my example:

.leftpart {
          width: 100%;
          display: block;
          margin: 20px;
        }

        .leftpart .nav-links ul {
          list-style: none;
          margin: 0;
          padding: 0;
          display: block;
        }

        .leftpart .nav-links ul li {
          margin-bottom:20px;
        }

        .leftpart > .nav-links ul li a {
           background:green;
           color:#fff;
           padding: 20px;
           display: inline-block;
        }

 .leftpart .nav-links .sub-seciton .nav-links  ul li a {
            background:red ;

 }

.leftpart > .nav-links:nth-child(2) ul li a {
background: blue;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="leftpart">
        <div class="nav-links">
          <h1> Primary Links </h1>
          <ul>
            <li>
              Profile
            </li>

            <li>
              Friends
            </li>

            <li>
              Milestones
            </li>

            <li>
              Groups
            </li>
          </ul>

          <div class="sub-seciton">
              <div class="nav-links">
                <ul>
                  <li>
                    Edit
                  </li>

                  <li>
                    Save
                  </li>
                </ul>
              </div>
          </div>

        </div>

        <div class="nav-links">
          <h1> Secondary Links </h1>
          <ul>
            <li>
              Privacy
            </li>

            <li>
              Settings
            </li>
          </ul>
        </div>
    </div></code>```

Body:
I have to create left section for a website ".leftpart" in which I have parent navigation class ".nav-links" with CSS properties. I have also have same class ".nav-links" as a sub section under parent ".nav-links". I want to give a different background color "red" to child ".nav-links" [Edit and Save]. Can you anyone suggest best way to do this ?

My code is below, thanks in advance :

.leftpart {
          width: 100%;
          display: block;
          margin: 20px;
        }

        .leftpart .nav-links ul {
          list-style: none;
          margin: 0;
          padding: 0;
          display: block;
        }

        .leftpart .nav-links ul li {
          margin-bottom:20px;
        }

        .leftpart .nav-links ul li a {
           background:green;
           color:#fff;
           padding: 20px;
           display: inline-block;
        }

 Primary Links

              Profile

              Friends

              Milestones

              Groups

                    Edit

                    Save

 Secondary Links

              Privacy

              Settings

Body:
You need to target .nav-links inside the sub-section. You can also style your nav-links siblings separately. See my example:

.leftpart {
          width: 100%;
          display: block;
          margin: 20px;
        }

        .leftpart .nav-links ul {
          list-style: none;
          margin: 0;
          padding: 0;
          display: block;
        }

        .leftpart .nav-links ul li {
          margin-bottom:20px;
        }

        .leftpart > .nav-links ul li a {
           background:green;
           color:#fff;
           padding: 20px;
           display: inline-block;
        }

 .leftpart .nav-links .sub-seciton .nav-links  ul li a {
            background:red ;

 }

.leftpart > .nav-links:nth-child(2) ul li a {
background: blue;
}

<div class="leftpart">
        <div class="nav-links">
          <h1> Primary Links </h1>
          <ul>
            <li>
              <a href="/profile.html">Profile</a>
            </li>

            <li>
              <a href="/friends.html">Friends</a>
            </li>

            <li>
              <a href="/milestone.html">Milestones</a>
            </li>

            <li>
              <a href="/groups.html">Groups</a>
            </li>
          </ul>

          <div class="sub-seciton">
              <div class="nav-links">
                <ul>
                  <li>
                    <a href="#">Edit</a>
                  </li>

                  <li>
                    <a href="#">Save</a>
                  </li>
                </ul>
              </div>
          </div>

        </div>

        <div class="nav-links">
          <h1> Secondary Links </h1>
          <ul>
            <li>
              <a href="/privacy.html">Privacy</a>
            </li>

            <li>
              <a href="/settings.html">Settings</a>
            </li>
          </ul>
        </div>
    </div>


问:
Add shaded region across all panels in ridgeline plot
I have a dataframe df:

```<code> set.seed(3467)

 df<- data.frame(method= c(rep("A", 1000), rep("B", 1000), rep("C", 1000)),
            beta=c(rnorm(1000, mean=0, sd=1),rnorm(1000, mean=2, sd=1.4),rnorm(1000, mean=0, sd=0.5)))
</code>```

I wish to create a ridge plot like so:

```<code>ggplot(df, aes(x = beta, y = method, color = method, fill = method)) +
geom_density_ridges(size=1)+
scale_fill_manual(values = c("#228b2250", "#0072B250", "#483d8b50")) +
scale_color_manual(values = c("#228b22", "#0072B2", "#483d8b"), guide = "none") +
stat_density_ridges(quantile_lines = TRUE, quantiles = c(0.025, 0.5, 0.975), alpha = 0.6, size=1)
</code>```

I wish to add a shaded rectangle like so:

```<code>ggplot(df) +
geom_rect(data = data.frame(x = 1),
        xmin = -1, xmax = 1, ymin = -Inf, ymax = Inf,
        alpha = 0.5, fill = "gray") +
geom_density_ridges2(aes(x = beta, fill = method, y = method))
</code>```

However, this attempt is unsuccessful:

```<code>ggplot(df, aes(x = beta, y = method, color = method, fill = method)) +
geom_density_ridges(size=1)+
scale_fill_manual(values = c("#228b2250", "#0072B250", "#483d8b50")) +
scale_color_manual(values = c("#228b22", "#0072B2", "#483d8b"), guide = "none") +
stat_density_ridges(quantile_lines = TRUE, quantiles = c(0.025, 0.5, 0.975), alpha = 0.6, size=1)+
geom_rect(data = data.frame(x = 1),
        xmin = -1, xmax = 1, ymin = -Inf, ymax = Inf,
        alpha = 0.5, fill = "grey")
</code>```

The geom_rect() function does not seem to work with geom_density_ridges() only geom_density_ridges2().

答:
Is this what you are looking for? This is a slight modification of your code. I think we can specifically specify the data frame and aes for each layer if some elements cannot be recognized.

```<code>library(ggplot2)
library(ggridges)

ggplot() +
  geom_rect(data = data.frame(x = 1),
            xmin = -1, xmax = 1, ymin = -Inf, ymax = Inf,
            alpha = 0.5, fill = "gray") +
  geom_density_ridges(data = df, aes(x = beta, y = method, color = method, fill = method),
                      size=1)+
  scale_fill_manual(values = c("#228b2250", "#0072B250", "#483d8b50")) +
  scale_color_manual(values = c("#228b22", "#0072B2", "#483d8b"), guide = "none") +
  stat_density_ridges(data = df, aes(x = beta, y = method, color = method, fill = method),
                      quantile_lines = TRUE, quantiles = c(0.025, 0.5, 0.975), alpha = 0.6, size=1)
</code>```

Body:
I have a dataframe df:

 set.seed(3467)

 df<- data.frame(method= c(rep("A", 1000), rep("B", 1000), rep("C", 1000)),
            beta=c(rnorm(1000, mean=0, sd=1),rnorm(1000, mean=2, sd=1.4),rnorm(1000, mean=0, sd=0.5)))

I wish to create a ridge plot like so:

ggplot(df, aes(x = beta, y = method, color = method, fill = method)) +
geom_density_ridges(size=1)+
scale_fill_manual(values = c("#228b2250", "#0072B250", "#483d8b50")) +
scale_color_manual(values = c("#228b22", "#0072B2", "#483d8b"), guide = "none") +
stat_density_ridges(quantile_lines = TRUE, quantiles = c(0.025, 0.5, 0.975), alpha = 0.6, size=1)

I wish to add a shaded rectangle like so:

ggplot(df) +
geom_rect(data = data.frame(x = 1),
        xmin = -1, xmax = 1, ymin = -Inf, ymax = Inf,
        alpha = 0.5, fill = "gray") +
geom_density_ridges2(aes(x = beta, fill = method, y = method))

However, this attempt is unsuccessful:

ggplot(df, aes(x = beta, y = method, color = method, fill = method)) +
geom_density_ridges(size=1)+
scale_fill_manual(values = c("#228b2250", "#0072B250", "#483d8b50")) +
scale_color_manual(values = c("#228b22", "#0072B2", "#483d8b"), guide = "none") +
stat_density_ridges(quantile_lines = TRUE, quantiles = c(0.025, 0.5, 0.975), alpha = 0.6, size=1)+
geom_rect(data = data.frame(x = 1),
        xmin = -1, xmax = 1, ymin = -Inf, ymax = Inf,
        alpha = 0.5, fill = "grey")

The geom_rect() function does not seem to work with geom_density_ridges() only geom_density_ridges2().

Body:
Is this what you are looking for? This is a slight modification of your code. I think we can specifically specify the data frame and aes for each layer if some elements cannot be recognized.

library(ggplot2)
library(ggridges)

ggplot() +
  geom_rect(data = data.frame(x = 1),
            xmin = -1, xmax = 1, ymin = -Inf, ymax = Inf,
            alpha = 0.5, fill = "gray") +
  geom_density_ridges(data = df, aes(x = beta, y = method, color = method, fill = method),
                      size=1)+
  scale_fill_manual(values = c("#228b2250", "#0072B250", "#483d8b50")) +
  scale_color_manual(values = c("#228b22", "#0072B2", "#483d8b"), guide = "none") +
  stat_density_ridges(data = df, aes(x = beta, y = method, color = method, fill = method),
                      quantile_lines = TRUE, quantiles = c(0.025, 0.5, 0.975), alpha = 0.6, size=1)


问:
Is it possible to call a variable from string input
I have five Labels in my form.

The names of the label are the following.

```<code>1) labelTeam1Name.Text
1) labelTeam2Name.Text
3) labelTeam3Name.Text
4) labelTeam4Name.Text
5) labelTeam5Name.Text
</code>```

now I want to run a loop and get the text values of the label

```<code>for( int i = 1; i < 6; i++ )
{
    string str = labelTeam(i)Name.Text  // Get the values based on the input i

}
</code>```

I can definitely fill these values in an array or list and then call them in the loop.

is it possible to do something like this labelTeam(i)Name.Text?

答:
You can use Controls and OfType

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

```<code>var results = Controls.OfType<Label>().Select(x => x.Text);
</code>```

or

```<code>foreach (var ctrl in Controls.OfType<Label>())
{
    //var str = ctrl.Text;
}
</code>```

if you need to base this on the name, you could use Find or

```<code>var labels = Controls.OfType<Label>().ToList();

for (int i = 0; i < labels.Count(); i++)
{
   var label = labels.FirstOrDefault(x => x.Name == $"blerp{i}derp");

   if (label != null)
   {

   }
}
</code>```

Body:
I have five Labels in my form.

The names of the label are the following.

1) labelTeam1Name.Text
1) labelTeam2Name.Text
3) labelTeam3Name.Text
4) labelTeam4Name.Text
5) labelTeam5Name.Text

now I want to run a loop and get the text values of the label

for( int i = 1; i < 6; i++ )
{
    string str = labelTeam(i)Name.Text  // Get the values based on the input i

}

I can definitely fill these values in an array or list and then call them in the loop.

is it possible to do something like this labelTeam(i)Name.Text?

Body:
You can use Controls and OfType

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

var results = Controls.OfType<Label>().Select(x => x.Text);

or

foreach (var ctrl in Controls.OfType<Label>())
{
    //var str = ctrl.Text;
}

if you need to base this on the name, you could use Find or

var labels = Controls.OfType<Label>().ToList();

for (int i = 0; i < labels.Count(); i++)
{
   var label = labels.FirstOrDefault(x => x.Name == $"blerp{i}derp");

   if (label != null)
   {

   }
}


问:
Generating a presigned URL to upload to an S3 bucket
I'm trying to generate a presigned URL for an S3 bucket on AWS to upload files to like this:

```<code>$ aws s3 presign s3://mybucket/somefolder/
</code>```

Then I use that URL to upload a file:

```<code>$ curl "https://mybucket.s3.amazonaws.com/somefolder/?AWSAccessKeyId=***&Signature=***&Expires=***"  --upload-file "./file"
</code>```

But then it prints out an XML error:

```<code><?xml version="1.0" encoding="UTF-8"?>
<Error>
  <Code>SignatureDoesNotMatch</Code>
  <Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>
  <AWSAccessKeyId>***********</AWSAccessKeyId>
  <StringToSign>PUT

    ************
    /mybucket/somefolder/</StringToSign>
  <SignatureProvided>**************</SignatureProvided>
  <StringToSignBytes>**************</StringToSignBytes>
  <RequestId>************</RequestId>
  <HostId>************</HostId>
</Error>
</code>```

What am I doing wrong?

[UPDATE]

OK, so I have to specify the object name in the presigned URL. So I did but I'm still facing the same error message:

```<code>$ aws s3 presign s3://mybucket/someobject
</code>```

And then:

```<code>$ curl "https://mybucket.s3.amazonaws.com/someobject?AWSAccessKeyId=***&Signature=***&Expires=***"  --upload-file "./file"
</code>```

And I'll get the exact same error as before. To make sure that it's not a permission problem, I tested it like this:

```<code>$ aws s3 cp ./file s://mybucket/
</code>```

And the file was copied! Any suggestions?

[UPDATE]

I even tested with an object which actually exists in the bucket and managed to successfully download it. But still I cannot write to the object, only read.

答:
It looks like cli command aws s3 presign is only for GetObject. Parameter 'get_object' is hardcoded in source code. (See line 671)

You can create presigned URL for PutObject using other SDK such as boto3. Make sure to set client method 'put_object'

Body:
I'm trying to generate a presigned URL for an S3 bucket on AWS to upload files to like this:

$ aws s3 presign s3://mybucket/somefolder/

Then I use that URL to upload a file:

$ curl "https://mybucket.s3.amazonaws.com/somefolder/?AWSAccessKeyId=***&Signature=***&Expires=***"  --upload-file "./file"

But then it prints out an XML error:

<?xml version="1.0" encoding="UTF-8"?>
<Error>
  SignatureDoesNotMatch
  <Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>
  <AWSAccessKeyId>***********</AWSAccessKeyId>
  <StringToSign>PUT

    ************
    /mybucket/somefolder/</StringToSign>
  <SignatureProvided>**************</SignatureProvided>
  <StringToSignBytes>**************</StringToSignBytes>
  <RequestId>************</RequestId>
  <HostId>************</HostId>
</Error>

What am I doing wrong?

[UPDATE]

OK, so I have to specify the object name in the presigned URL. So I did but I'm still facing the same error message:

$ aws s3 presign s3://mybucket/someobject

And then:

$ curl "https://mybucket.s3.amazonaws.com/someobject?AWSAccessKeyId=***&Signature=***&Expires=***"  --upload-file "./file"

And I'll get the exact same error as before. To make sure that it's not a permission problem, I tested it like this:

$ aws s3 cp ./file s://mybucket/

And the file was copied! Any suggestions?

[UPDATE]

I even tested with an object which actually exists in the bucket and managed to successfully download it. But still I cannot write to the object, only read.