问:
OpenMP linking errors in Visual Studio 2019 LLVM
I've been trying to build an OpenMP sample program with an LLVM compiler integrated to Visual Studio 2019.

LLVM compiler was downloaded from here (version 10.0, win64), C:\Program Files\LLVM\bin added to the PATH environment variable. LLVM Compiler Toolchain extension was installed from Visual Studio Marketplace.

It successfully builds a hello world program, but when I try to use OpenMP the linker fails with the following errors:

```<code>1>clang version 10.0.0
1>Target: x86_64-pc-windows-msvc
1>Thread model: posix
1>InstalledDir: C:\Program Files\LLVM\bin
1> (in-process)
1> "C:\\Program Files\\LLVM\\bin\\clang-cl.exe" -cc1 -triple x86_64-pc-windows-msvc19.26.28805 -emit-obj -mrelax-all -mincremental-linker-compatible -disable-free -disable-llvm-verifier -discard-value-names -main-file-name llvmtest.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mframe-pointer=none -relaxed-aliasing -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -mllvm -x86-asm-syntax=intel -D_DEBUG -D_MT -D_DLL --dependent-lib=msvcrtd --dependent-lib=oldnames -stack-protector 2 -fcxx-exceptions -fexceptions -fexternc-nounwind -fms-volatile -fdefault-calling-conv=cdecl -fdiagnostics-format msvc -gcodeview -debug-info-kind=limited -v -resource-dir "C:\\Program Files\\LLVM\\lib\\clang\\10.0.0" -D _DEBUG -D _CONSOLE -D _UNICODE -D UNICODE -internal-isystem "C:\\Program Files\\LLVM\\lib\\clang\\10.0.0\\include" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.26.28801\\include" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.26.28801\\atlmfc\\include" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Auxiliary\\VS\\include" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.18362.0\\ucrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.18362.0\\um" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.18362.0\\shared" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.18362.0\\winrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.18362.0\\cppwinrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.6.1\\Include\\um" -O0 -Wall -Wno-error -fdeprecated-macro -fdebug-compilation-dir "Z:\\llvmtest" -ferror-limit 19 -fmessage-length 0 -fopenmp -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.26.28805 -std=c++14 -fdelayed-template-parsing -fobjc-runtime=gcc -fno-caret-diagnostics -fdiagnostics-show-option -faddrsig -o "Debug\\llvmtest.obj" -x c++ llvmtest.cpp
1>clang -cc1 version 10.0.0 based upon LLVM 10.0.0 default target x86_64-pc-windows-msvc
1>#include "..." search starts here:
1>#include <...> search starts here:
1> C:\Program Files\LLVM\lib\clang\10.0.0\include
1> C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\include
1> C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\atlmfc\include
1> C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\VS\include
1> C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt
1> C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um
1> C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\shared
1> C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\winrt
1> C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\cppwinrt
1> C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\Include\um
1>End of search list.
1>lld-link : error : undefined symbol: __kmpc_global_thread_num
1>>>> referenced by Z:\llvmtest\llvmtest.cpp:9
1>>>>               Debug\llvmtest.obj:(main)
1>
1>lld-link : error : undefined symbol: __kmpc_push_num_threads
1>>>> referenced by Z:\llvmtest\llvmtest.cpp:15
1>>>>               Debug\llvmtest.obj:(main)
1>
1>lld-link : error : undefined symbol: __kmpc_fork_call
1>>>> referenced by Z:\llvmtest\llvmtest.cpp:15
1>>>>               Debug\llvmtest.obj:(main)
1>
1>lld-link : error : undefined symbol: omp_get_thread_num
1>>>> referenced by Z:\llvmtest\llvmtest.cpp:19
1>>>>               Debug\llvmtest.obj:(.omp_outlined._debug__)
1>
1>lld-link : error : undefined symbol: omp_get_num_threads
1>>>> referenced by Z:\llvmtest\llvmtest.cpp:25
1>>>>               Debug\llvmtest.obj:(.omp_outlined._debug__)
1>Done building project "llvmtest.vcxproj" -- FAILED.
</code>```

The code is rather trivial:

    #include <omp.h>
    #include <stdio.h>

    int main()
    {
        int nthreads, tid;

        //omp_set_num_threads(4);

    #pragma omp parallel private(tid) num_threads(3)
        {
            tid = omp_get_thread_num();
            printf("Hello World from thread = %d\n", tid);

            if (tid == 0)
            {
                nthreads = omp_get_num_threads();
                printf("Number of threads = %d\n", nthreads);
            }

        }  /* All threads join master thread and terminate */
    }
```

<p>Project settings shown below:
<img src="https://i.stack.imgur.com/xqZTZ.png" alt="enter image description here">
<img src="https://i.stack.imgur.com/56p7Y.png" alt="enter image description here"></p>

<p>I have tried different options: <code>-fopenmp</code>, <code>-Xclang -fopenmp</code> compiler flags, passing <code>-openmp</code> and <code>-fopenmp</code> as linker flags, changing x64 to x86, adding <em>C:\Program Files\LLVM\lib</em> to the PATH. Nothing helped so far. </p>

<p>Interestingly enough, I can build the same code from the command line by running the following from <strong>x64 Native Tools Command Prompt for VS 2019</strong>:</p>

```clang-cl -openmp llvmtest.cpp
```

So, basically, -openmp flag was enough... Does anyone have an idea how to make it work in Visual Studio?

答:
Finally, I have managed to make it work (thanks to Marek Aniola, the author of the LLVM Toolchain extension, who helped me out).

First, I passed the /openmp flag to LLVM -> Additional Compiler Options (it works with -openmp too).

Second, it turns out that OpenMP is not automatically linked when building from Visual Studio (in contrast to compiling from the command line by means of clang-cl). Linker settings for LLVM are specified the same way as for the Microsoft linker.

The path to libraries C:\Program Files\LLVM\lib has to be added to Linker -> General -> Additional Library Directories.

It is also necessary to list libomp.lib in Linker -> Input -> Additional Dependencies.

Linker -> Optimization -> Link Time Code Generation must be set to Default.

These steps let me successfully build the code (64-bit application). Although the 64-bit LLVM compiler can build a 32-bit program, it includes only x64 version of OpenMP libraries, so in order to build a 32-bit application I had to link libomp.lib and copy libomp.dll from another LLVM distribution. If there is a better way to do that, please let me know.

Body:
I've been trying to build an OpenMP sample program with an LLVM compiler integrated to Visual Studio 2019.

LLVM compiler was downloaded from here (version 10.0, win64), C:\Program Files\LLVM\bin added to the PATH environment variable. LLVM Compiler Toolchain extension was installed from Visual Studio Marketplace.

It successfully builds a hello world program, but when I try to use OpenMP the linker fails with the following errors:

1>clang version 10.0.0
1>Target: x86_64-pc-windows-msvc
1>Thread model: posix
1>InstalledDir: C:\Program Files\LLVM\bin
1> (in-process)
1> "C:\\Program Files\\LLVM\\bin\\clang-cl.exe" -cc1 -triple x86_64-pc-windows-msvc19.26.28805 -emit-obj -mrelax-all -mincremental-linker-compatible -disable-free -disable-llvm-verifier -discard-value-names -main-file-name llvmtest.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mframe-pointer=none -relaxed-aliasing -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -mllvm -x86-asm-syntax=intel -D_DEBUG -D_MT -D_DLL --dependent-lib=msvcrtd --dependent-lib=oldnames -stack-protector 2 -fcxx-exceptions -fexceptions -fexternc-nounwind -fms-volatile -fdefault-calling-conv=cdecl -fdiagnostics-format msvc -gcodeview -debug-info-kind=limited -v -resource-dir "C:\\Program Files\\LLVM\\lib\\clang\\10.0.0" -D _DEBUG -D _CONSOLE -D _UNICODE -D UNICODE -internal-isystem "C:\\Program Files\\LLVM\\lib\\clang\\10.0.0\\include" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.26.28801\\include" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.26.28801\\atlmfc\\include" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Auxiliary\\VS\\include" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.18362.0\\ucrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.18362.0\\um" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.18362.0\\shared" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.18362.0\\winrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.18362.0\\cppwinrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.6.1\\Include\\um" -O0 -Wall -Wno-error -fdeprecated-macro -fdebug-compilation-dir "Z:\\llvmtest" -ferror-limit 19 -fmessage-length 0 -fopenmp -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.26.28805 -std=c++14 -fdelayed-template-parsing -fobjc-runtime=gcc -fno-caret-diagnostics -fdiagnostics-show-option -faddrsig -o "Debug\\llvmtest.obj" -x c++ llvmtest.cpp
1>clang -cc1 version 10.0.0 based upon LLVM 10.0.0 default target x86_64-pc-windows-msvc
1>#include "..." search starts here:
1>#include <...> search starts here:
1> C:\Program Files\LLVM\lib\clang\10.0.0\include
1> C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\include
1> C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\atlmfc\include
1> C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\VS\include
1> C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt
1> C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um
1> C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\shared
1> C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\winrt
1> C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\cppwinrt
1> C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\Include\um
1>End of search list.
1>lld-link : error : undefined symbol: __kmpc_global_thread_num
1>>>> referenced by Z:\llvmtest\llvmtest.cpp:9
1>>>>               Debug\llvmtest.obj:(main)
1>
1>lld-link : error : undefined symbol: __kmpc_push_num_threads
1>>>> referenced by Z:\llvmtest\llvmtest.cpp:15
1>>>>               Debug\llvmtest.obj:(main)
1>
1>lld-link : error : undefined symbol: __kmpc_fork_call
1>>>> referenced by Z:\llvmtest\llvmtest.cpp:15
1>>>>               Debug\llvmtest.obj:(main)
1>
1>lld-link : error : undefined symbol: omp_get_thread_num
1>>>> referenced by Z:\llvmtest\llvmtest.cpp:19
1>>>>               Debug\llvmtest.obj:(.omp_outlined._debug__)
1>
1>lld-link : error : undefined symbol: omp_get_num_threads
1>>>> referenced by Z:\llvmtest\llvmtest.cpp:25
1>>>>               Debug\llvmtest.obj:(.omp_outlined._debug__)
1>Done building project "llvmtest.vcxproj" -- FAILED.

The code is rather trivial:

    #include <omp.h>
    #include <stdio.h>

    int main()
    {
        int nthreads, tid;

        //omp_set_num_threads(4);

    #pragma omp parallel private(tid) num_threads(3)
        {
            tid = omp_get_thread_num();
            printf("Hello World from thread = %d\n", tid);

            if (tid == 0)
            {
                nthreads = omp_get_num_threads();
                printf("Number of threads = %d\n", nthreads);
            }

        }  /* All threads join master thread and terminate */
    }

Project settings shown below:

I have tried different options: -fopenmp, -Xclang -fopenmp compiler flags, passing -openmp and -fopenmp as linker flags, changing x64 to x86, adding C:\Program Files\LLVM\lib to the PATH. Nothing helped so far.

Interestingly enough, I can build the same code from the command line by running the following from x64 Native Tools Command Prompt for VS 2019:

clang-cl -openmp llvmtest.cpp

So, basically, -openmp flag was enough... Does anyone have an idea how to make it work in Visual Studio?


来源: stackexchange

问:
Selenium : Click on a link inside a div
I'm learning selenium and I'm trying a simple thing : click on the first result of a search on wikipedia.

```<code>from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

PATH = "chromedriver.exe"
driver = webdriver.Chrome(PATH)
driver.get("https://en.wikipedia.org")

# Input in the search bar
search = driver.find_element_by_id("searchInput")
search.send_keys("python", Keys.RETURN)

wait = WebDriverWait(driver, 10)
first_result = wait.until(
    EC.presence_of_element_located((By.CLASS_NAME, "mw-search-result-heading"))
)

first_result.click()
</code>```

So i'm able to select the heading of the first result. But I can't click on it.
I think it's because I'm clicking on the
 containing the link, rather than the actual link. Here is a snippet of the HTML :

How can I target the actual  link, without it having any class name, id or name ?

答:
You can chain find_* functions to get more specific with your WebElement queries:

```<code>first_result.find_element_by_tag_name("a").click()
</code>```

ContentLicense: CC BY-SA 4.0

Title: Selenium : Click on a link inside a div

Body:
I'm learning selenium and I'm trying a simple thing : click on the first result of a search on wikipedia.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

PATH = "chromedriver.exe"
driver = webdriver.Chrome(PATH)
driver.get("https://en.wikipedia.org")

# Input in the search bar
search = driver.find_element_by_id("searchInput")
search.send_keys("python", Keys.RETURN)

wait = WebDriverWait(driver, 10)
first_result = wait.until(
    EC.presence_of_element_located((By.CLASS_NAME, "mw-search-result-heading"))
)

first_result.click()

So i'm able to select the heading of the first result. But I can't click on it.
I think it's because I'm clicking on the
 containing the link, rather than the actual link. Here is a snippet of the HTML :

How can I target the actual  link, without it having any class name, id or name ?

Body:
You can chain find_* functions to get more specific with your WebElement queries:

first_result.find_element_by_tag_name("a").click()


问:
problems with a perl "system" script
Im trying to write a very simple script that copies files from several remote computers to my computer. I've written the following in perl:

```<code>@Comps = ("comp1","comp2","comp3","comp4");

foreach $comp (@Comps)
{
  system("copy /Y \\\\$comp\\c\$\\myfolder\\$comp*.log   C:\\Program Files\\My Cont Folder\\input\\");
}
</code>```

I get a syntax error and cant understand why.

Thanks!

答:
Looks like you've got error in the command itself, because the  perl code ran fine. (Gave me 4 times "command not found" since I'm on Unix).

I would suggest using list form of system() call: system("copy", "/Y", $src, $dst); and, probably, even sprintf() to fill out $src and $dst.

Of course, you can always check what exactly gets executed by running print before system. I often hesitate and often print.

ContentLicense: CC BY-SA 3.0

Title: problems with a perl "system" script

Body:
Im trying to write a very simple script that copies files from several remote computers to my computer. I've written the following in perl:

@Comps = ("comp1","comp2","comp3","comp4");

foreach $comp (@Comps)
{
  system("copy /Y \\\\$comp\\c\$\\myfolder\\$comp*.log   C:\\Program Files\\My Cont Folder\\input\\");
}

I get a syntax error and cant understand why.

Thanks!


问:
Reseed id to 00000001 and when selecting it return as 00000001 and not as 1
I have reseed a database column to 00000001 but when I select it with C# it returns only the 1 without the zeros. Are leading zeros not allowed in ms sql?</p>

答:
Numeric columns in general can't 've leading zeros and INT is one of them.
If you want to do so, you could use RIGHT() function as the following:

```<code>SELECT YourNumber, RIGHT(CONCAT('00000000', YourNumber), 8) DesiredResult
FROM
(
  VALUES
  (1), (2), (100), (190)
) T(YourNumber);
</code>```

Body:
Numeric columns in general can't 've leading zeros and INT is one of them.
If you want to do so, you could use RIGHT() function as the following:

SELECT YourNumber, RIGHT(CONCAT('00000000', YourNumber), 8) DesiredResult
FROM
(
  VALUES
  (1), (2), (100), (190)
) T(YourNumber);


问:
k8s with kubespray fails at dns config
My k8s with kubespray always bails out at the following error
"Too many nameservers. You can relax this check by set docker_dns_servers_strict=no and we will only use the first 3

In my cluster.yml I have this under - hosts
- docker_dns_servers_strict: no but I still get the error.
What am I missing?

答:
For me, it worked with adding  -e 'docker_dns_servers_strict=no':

```<code>ansible-playbook -i ../inventories/kubernetes.yaml --become --become-user=root cluster.yml -e 'docker_dns_servers_strict=no'
</code>```

Title: k8s with kubespray fails at dns config

Body:
For me, it worked with adding  -e 'docker_dns_servers_strict=no':

ansible-playbook -i ../inventories/kubernetes.yaml --become --become-user=root cluster.yml -e 'docker_dns_servers_strict=no'


问:
how to load a file into memory stream
I have a filename pointing to a text file, including its path, as a string. Now I'd like to load this .csv file into memory stream. How should I do that?

For example, I have this:

```<code>Dim filename as string="C:\Users\Desktop\abc.csv"
</code>```

答:
```<code>Dim stream As New MemoryStream(File.ReadAllBytes(filename))
</code>```

Title: how to load a file into memory stream

Body:
I have a filename pointing to a text file, including its path, as a string. Now I'd like to load this .csv file into memory stream. How should I do that?

For example, I have this:

Dim filename as string="C:\Users\Desktop\abc.csv"


问:
Powershell while loop cannot be broken
I have a while loop in powershell that checks for input

```<code>:checker while($choice1 = read-host "Do you want to continue? [Y/N/C]"){
    switch ($choice1){
        "N"{Echo Ok; $temporary = "Exit"; break :checker}
        "Y"{Echo Ok; $temporary = "Continue"; break :checker}
        "C"{Echo Ok; $temporary = "Cancel"; break :checker}
        default{"Invalid input"}
    }
}
</code>```

However, no matter the input, the while loop never gets broken. Is there an issue with my code, or is there a different way to do this that will ensure the correct things to happen?

答: Instead of break :checker, you should have break checker to break out to the outermost loop. It's just breaking out of the switch statement currently.

Title: Powershell while loop cannot be broken

Body:
I have a while loop in powershell that checks for input

:checker while($choice1 = read-host "Do you want to continue? [Y/N/C]"){
    switch ($choice1){
        "N"{Echo Ok; $temporary = "Exit"; break :checker}
        "Y"{Echo Ok; $temporary = "Continue"; break :checker}
        "C"{Echo Ok; $temporary = "Cancel"; break :checker}
        default{"Invalid input"}
    }
}

However, no matter the input, the while loop never gets broken. Is there an issue with my code, or is there a different way to do this that will ensure the correct things to happen?


问:
SQL Join - get rows that meet criteria from foreign key table
I need to find the rows in one table that meet specific attributes specified in a foreign key table.

I have these two tables:

```<code>ITEM
PK: ItemId
Text: nvarchar

ITEMATTRIBUTE
PK: ItemAttributeId
FK: ItemId
AttributeText: nvarchar
Value: int
</code>```

ItemAttribute has a foreign key to Items and defines dynamic attributes given for an item.
e.g:

```<code>ITEM:
ItemId  Text
1       ItemA
2       ItemB
3       ItemC

ITEMATTRIBUTE:
ItemAttributeID ItemId  AttributeText       Value
1               1       AttributeA          10
2               1       AttributeB          10
3               2       AttributeA          8
</code>```

I need to dynamically find items which have certain itamAttributes.
For example the desired query shall return items that have

AttributeA AND AttributeB: result should show only ItemA.

When I (left) join both tables I get a row for each item with the joined itemattribute:

```<code>select * from item i left join itemattribute a on i.itemid=a.itemid
</code>```

However I need a dynamic way to get items where defined itemattributes are set:
get all items that have AttributeA with a value > 5 and AttributeB with value > 5: result ItemA

As I don't know how many itemAttributes are set I can't do the query with stacked subselects or hardcoded as in:

```<code>select distinct i2.itemid from item i2, itemattribute a2,
(select i.itemid, a.attributetext from item i left join itemattribute a on i.itemid=a.itemid where AttributeText='AttributeA' and value > 5) ii
where i2.itemid=a2.itemid and a2.attributetexT='AttributeB' and value > 5
</code>```

答:
You need to aggregate your values to the Item level, then do the logic to filter for the Items you want.

In some dbs (like Snowflake) you can run a PIVOT, but in most you need to do conditional aggregations.

```<code>SELECT item_id, att_a_value, att_b_value
FROM (
SELECT
   i.item_id
   ,max(CASE WHEN ia.AttributeText = 'Attribute A' THEN ia.value END) as att_a_value
   ,max(CASE WHEN ia.AttributeText = 'Attribute B' THEN ia.value END) as att_b_value
FROM Items i
LEFT JOIN ItemAttributes ia ON i.item_id = ia.item_id
GROUP BY i.item_id
) z
WHERE z.att_a_value > 5 AND z.att_b_value > 5
</code>```

Body:
I need to find the rows in one table that meet specific attributes specified in a foreign key table.

I have these two tables:

ITEM
PK: ItemId
Text: nvarchar

ITEMATTRIBUTE
PK: ItemAttributeId
FK: ItemId
AttributeText: nvarchar
Value: int

ItemAttribute has a foreign key to Items and defines dynamic attributes given for an item.
e.g:

ITEM:
ItemId  Text
1       ItemA
2       ItemB
3       ItemC

ITEMATTRIBUTE:
ItemAttributeID ItemId  AttributeText       Value
1               1       AttributeA          10
2               1       AttributeB          10
3               2       AttributeA          8

I need to dynamically find items which have certain itamAttributes.
For example the desired query shall return items that have

AttributeA AND AttributeB: result should show only ItemA.

When I (left) join both tables I get a row for each item with the joined itemattribute:

select * from item i left join itemattribute a on i.itemid=a.itemid

However I need a dynamic way to get items where defined itemattributes are set:
get all items that have AttributeA with a value > 5 and AttributeB with value > 5: result ItemA

As I don't know how many itemAttributes are set I can't do the query with stacked subselects or hardcoded as in:

select distinct i2.itemid from item i2, itemattribute a2,
(select i.itemid, a.attributetext from item i left join itemattribute a on i.itemid=a.itemid where AttributeText='AttributeA' and value > 5) ii
where i2.itemid=a2.itemid and a2.attributetexT='AttributeB' and value > 5

Body:
You need to aggregate your values to the Item level, then do the logic to filter for the Items you want.

In some dbs (like Snowflake) you can run a PIVOT, but in most you need to do conditional aggregations.

SELECT item_id, att_a_value, att_b_value
FROM (
SELECT
   i.item_id
   ,max(CASE WHEN ia.AttributeText = 'Attribute A' THEN ia.value END) as att_a_value
   ,max(CASE WHEN ia.AttributeText = 'Attribute B' THEN ia.value END) as att_b_value
FROM Items i
LEFT JOIN ItemAttributes ia ON i.item_id = ia.item_id
GROUP BY i.item_id
) z
WHERE z.att_a_value > 5 AND z.att_b_value > 5


问:
PHP- Send mail with SMTP authentication without mail()
I am working on a website which is hosted on a server that has the function "mail()" disabled for security reasons.

I would like to know if there is another way around to bypass this and send an email with SMTP authentication ?

I don't own the server and I can't install any add-ons or plugins. There isn't PEAR nor Swift nor PHPMailer on that server.

How should I do?
Thank you for your help.

答:
You don't need to "install" PHPMailer. Just upload the script in your server and include it in your script.

I believe if you could use mail() function you can upload files to the server.

If you cannot, then you can't do nothing.


问:
No found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations:
I am trying to write a SOAP service using Spring, however I receive a Dependency Injection issue. I'm having problems using @Autowired through the Service like this:

```<code>    public interface UserDao {
    User getUser(String username);
}
</code>```

Implementation for Dao as below:

```<code>  @Controller("userDao")
    public class UserDaoImpl implements UserDao {
    private static Log log = LogFactory.getLog(UserDaoImpl.class);

    @Autowired
    @Qualifier("sessionFactory")
    private LocalSessionFactoryBean sessionFactory;

    @Override
    public User getUser(String username) {
        Session session = sessionFactory.getObject().openSession();
        // Criteria query = session.createCriteria(Student.class);
        Query query = session
                .createQuery("from User where username = :username");
        query.setParameter("username", username);
        try {
            System.out.println("\n Load Student by ID query is running...");
            /*
             * query.add(Restrictions.like("id", "%" + id + "%",
             * MatchMode.ANYWHERE)); return (Student) query.list();
             */
            return (User) query.uniqueResult();
        } catch (Exception e) {
            // TODO: handle exception
            log.info(e.toString());
        } finally {
            session.close();
        }
        return null;
    }

}
</code>```

and

```<code>public interface UserBo {
    User loadUser(String username);
}
</code>```

and

```<code>public class UserBoImpl implements UserBo {
    @Autowired
    private UserDao userDao;

    @Override
    public User loadUser(String username) {
        // TODO Auto-generated method stub
        return userDao.getUser(username);
    }

}

@WebService
@Component
public class UserService {

    @Autowired
    private UserBo userBo;

    @WebMethod(operationName = "say")
    public String sayHello(String name) {
        return ("Hello Java to " + name);
    }

    @WebMethod(operationName = "getUser")
    public User getUser(String username) {
        return userBo.loadUser(username);
    }
}
</code>```

The below is xml mapping file

```<code><?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ws="http://jax-ws.dev.java.net/spring/core"
    xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
    http://jax-ws.dev.java.net/spring/core
    http://jax-ws.java.net/spring/core.xsd
    http://jax-ws.dev.java.net/spring/servlet
    http://jax-ws.java.net/spring/servlet.xsd

    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-4.0.xsd">
    <context:annotation-config />

    <context:component-scan base-package="edu.java.spring.ws"></context:component-scan>
    <context:component-scan base-package="edu.java.spring.ws.dao"></context:component-scan>
    <bean id="userDao" class="edu.java.spring.ws.dao.UserDaoImpl"></bean>
    <!-- <context:component-scan base-package="edu.java.spring.ws.bo"></context:component-scan>
     -->
    <wss:binding url="/user">
        <wss:service>
            <ws:service bean="#userService" />
        </wss:service>
    </wss:binding>
    <bean id="userBo" class="edu.java.spring.ws.bo.impl.UserBoImpl"></bean>
    <bean id="dataSource"
        class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <property name="url" value="jdbc:mysql://localhost:3306/contentdb" />
        <property name="username" value="root" />
        <property name="password" value="123456" />
    </bean>
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"></property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                <prop key="hibernate.show_sql">true</prop>
            </props>
        </property>
        <property name="packagesToScan" value="edu.java.spring.ws.model" />
    </bean>
</beans>
</code>```

And the error thrown when deploying is:
Here is the updated stack trace:

```<code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.sun.xml.ws.transport.http.servlet.SpringBinding#0' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot create inner bean '(inner bean)#538071ba' of type [org.jvnet.jax_ws_commons.spring.SpringService] while setting bean property 'service'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#538071ba' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'userService' while setting bean property 'bean'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.bo.UserBo edu.java.spring.ws.UserService.userBo; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userBo': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.dao.UserDao edu.java.spring.ws.bo.impl.UserBoImpl.userDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [edu.java.spring.ws.dao.UserDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:290)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:129)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1456)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1197)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4992)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5490)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#538071ba' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'userService' while setting bean property 'bean'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.bo.UserBo edu.java.spring.ws.UserService.userBo; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userBo': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.dao.UserDao edu.java.spring.ws.bo.impl.UserBoImpl.userDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [edu.java.spring.ws.dao.UserDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:336)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1456)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1197)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:276)
    ... 24 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.bo.UserBo edu.java.spring.ws.UserService.userBo; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userBo': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.dao.UserDao edu.java.spring.ws.bo.impl.UserBoImpl.userDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [edu.java.spring.ws.dao.UserDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
    ... 30 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.bo.UserBo edu.java.spring.ws.UserService.userBo; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userBo': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.dao.UserDao edu.java.spring.ws.bo.impl.UserBoImpl.userDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [edu.java.spring.ws.dao.UserDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
    ... 38 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userBo': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.dao.UserDao edu.java.spring.ws.bo.impl.UserBoImpl.userDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [edu.java.spring.ws.dao.UserDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1017)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:960)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:858)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480)
    ... 40 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.dao.UserDao edu.java.spring.ws.bo.impl.UserBoImpl.userDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [edu.java.spring.ws.dao.UserDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
    ... 51 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [edu.java.spring.ws.dao.UserDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1103)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:963)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:858)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480)
    ... 53 more
</code>```

答: When you use @DataJpaTest you need to load classes using @Import explicitly. It wouldn't load you for auto.</p>

Body:
I am trying to write a SOAP service using Spring, however I receive a Dependency Injection issue. I'm having problems using @Autowired through the Service like this:

    public interface UserDao {
    User getUser(String username);
}

Implementation for Dao as below:

  @Controller("userDao")
    public class UserDaoImpl implements UserDao {
    private static Log log = LogFactory.getLog(UserDaoImpl.class);

    @Autowired
    @Qualifier("sessionFactory")
    private LocalSessionFactoryBean sessionFactory;

    @Override
    public User getUser(String username) {
        Session session = sessionFactory.getObject().openSession();
        // Criteria query = session.createCriteria(Student.class);
        Query query = session
                .createQuery("from User where username = :username");
        query.setParameter("username", username);
        try {
            System.out.println("\n Load Student by ID query is running...");
            /*
             * query.add(Restrictions.like("id", "%" + id + "%",
             * MatchMode.ANYWHERE)); return (Student) query.list();
             */
            return (User) query.uniqueResult();
        } catch (Exception e) {
            // TODO: handle exception
            log.info(e.toString());
        } finally {
            session.close();
        }
        return null;
    }

}

and

public interface UserBo {
    User loadUser(String username);
}

and

public class UserBoImpl implements UserBo {
    @Autowired
    private UserDao userDao;

    @Override
    public User loadUser(String username) {
        // TODO Auto-generated method stub
        return userDao.getUser(username);
    }

}

@WebService
@Component
public class UserService {

    @Autowired
    private UserBo userBo;

    @WebMethod(operationName = "say")
    public String sayHello(String name) {
        return ("Hello Java to " + name);
    }

    @WebMethod(operationName = "getUser")
    public User getUser(String username) {
        return userBo.loadUser(username);
    }
}

The below is xml mapping file

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ws="http://jax-ws.dev.java.net/spring/core"
    xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
    http://jax-ws.dev.java.net/spring/core
    http://jax-ws.java.net/spring/core.xsd
    http://jax-ws.dev.java.net/spring/servlet
    http://jax-ws.java.net/spring/servlet.xsd

    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-4.0.xsd">
    <context:annotation-config />

    <context:component-scan base-package="edu.java.spring.ws"></context:component-scan>
    <context:component-scan base-package="edu.java.spring.ws.dao"></context:component-scan>
    <bean id="userDao" class="edu.java.spring.ws.dao.UserDaoImpl"></bean>

    <wss:binding url="/user">
        <wss:service>
            <ws:service bean="#userService" />
        </wss:service>
    </wss:binding>
    <bean id="userBo" class="edu.java.spring.ws.bo.impl.UserBoImpl"></bean>
    <bean id="dataSource"
        class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <property name="url" value="jdbc:mysql://localhost:3306/contentdb" />
        <property name="username" value="root" />
        <property name="password" value="123456" />
    </bean>
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"></property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                <prop key="hibernate.show_sql">true</prop>
            </props>
        </property>
        <property name="packagesToScan" value="edu.java.spring.ws.model" />
    </bean>
</beans>

And the error thrown when deploying is:
Here is the updated stack trace:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.sun.xml.ws.transport.http.servlet.SpringBinding#0' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot create inner bean '(inner bean)#538071ba' of type [org.jvnet.jax_ws_commons.spring.SpringService] while setting bean property 'service'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#538071ba' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'userService' while setting bean property 'bean'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.bo.UserBo edu.java.spring.ws.UserService.userBo; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userBo': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.dao.UserDao edu.java.spring.ws.bo.impl.UserBoImpl.userDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [edu.java.spring.ws.dao.UserDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:290)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:129)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1456)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1197)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4992)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5490)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#538071ba' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'userService' while setting bean property 'bean'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.bo.UserBo edu.java.spring.ws.UserService.userBo; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userBo': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.dao.UserDao edu.java.spring.ws.bo.impl.UserBoImpl.userDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [edu.java.spring.ws.dao.UserDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:336)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1456)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1197)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:276)
    ... 24 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.bo.UserBo edu.java.spring.ws.UserService.userBo; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userBo': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.dao.UserDao edu.java.spring.ws.bo.impl.UserBoImpl.userDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [edu.java.spring.ws.dao.UserDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
    ... 30 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.bo.UserBo edu.java.spring.ws.UserService.userBo; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userBo': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.dao.UserDao edu.java.spring.ws.bo.impl.UserBoImpl.userDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [edu.java.spring.ws.dao.UserDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
    ... 38 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userBo': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.dao.UserDao edu.java.spring.ws.bo.impl.UserBoImpl.userDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [edu.java.spring.ws.dao.UserDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1017)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:960)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:858)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480)
    ... 40 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.java.spring.ws.dao.UserDao edu.java.spring.ws.bo.impl.UserBoImpl.userDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [edu.java.spring.ws.dao.UserDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
    ... 51 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [edu.java.spring.ws.dao.UserDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1103)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:963)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:858)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480)
    ... 53 more


问:
How to manually release CMSampleBuffer
This code leads to memory leak and app crash:

```<code>    var outputSamples = [Float]()

    assetReader.startReading()
    while assetReader.status == .reading {
        let trackOutput = assetReader.outputs.first!

        if let sampleBuffer = trackOutput.copyNextSampleBuffer(),
            let blockBuffer = CMSampleBufferGetDataBuffer(sampleBuffer) {
            let blockBufferLength = CMBlockBufferGetDataLength(blockBuffer)
            let sampleLength = CMSampleBufferGetNumSamples(sampleBuffer) * channelCount(from: assetReader)
            var data = Data(capacity: blockBufferLength)
            data.withUnsafeMutableBytes { (blockSamples: UnsafeMutablePointer<Int16>) in
                CMBlockBufferCopyDataBytes(blockBuffer, atOffset: 0, dataLength: blockBufferLength, destination: blockSamples)
                CMSampleBufferInvalidate(sampleBuffer)

                let processedSamples = process(blockSamples,
                                               ofLength: sampleLength,
                                               from: assetReader,
                                               downsampledTo: targetSampleCount)
                outputSamples += processedSamples
            }
        }
    }
    var paddedSamples = [Float](repeating: silenceDbThreshold, count: targetSampleCount)
    paddedSamples.replaceSubrange(0..<min(targetSampleCount, outputSamples.count), with: outputSamples)
</code>```

This is due to copyNextSampleBuffer() and The Create Rule.

In turn, we can not use CFRelease() in Swift. The reason why a link to the Objective-C only rule is there is beyond my understanding.

Is there a way to release CMSampleBuffer manually in Swift?

答:
I recently solved a similar issue by using an autoreleasepool

Try wrapping the area where sampleBuffer is used in an autoreleasepool. Something like this:

```<code>var outputSamples = [Float]()

assetReader.startReading()
while assetReader.status == .reading {
    let trackOutput = assetReader.outputs.first!

    autoreleasepool {
        if let sampleBuffer = trackOutput.copyNextSampleBuffer(),
            let blockBuffer = CMSampleBufferGetDataBuffer(sampleBuffer) {
            let blockBufferLength = CMBlockBufferGetDataLength(blockBuffer)
            let sampleLength = CMSampleBufferGetNumSamples(sampleBuffer) * channelCount(from: assetReader)
            var data = Data(capacity: blockBufferLength)
            data.withUnsafeMutableBytes { (blockSamples: UnsafeMutablePointer<Int16>) in
                CMBlockBufferCopyDataBytes(blockBuffer, atOffset: 0, dataLength: blockBufferLength, destination: blockSamples)
                CMSampleBufferInvalidate(sampleBuffer)

                let processedSamples = process(blockSamples,
                                               ofLength: sampleLength,
                                               from: assetReader,
                                               downsampledTo: targetSampleCount)
                outputSamples += processedSamples
            }
        }
    }
}
var paddedSamples = [Float](repeating: silenceDbThreshold, count: targetSampleCount)
paddedSamples.replaceSubrange(0..<min(targetSampleCount, outputSamples.count), with: outputSamples)
</code>```

If I understand correctly, once it moves out of the scope of autoreleasepool, the sampleBuffer will be released

Title: How to manually release CMSampleBuffer

Body:
This code leads to memory leak and app crash:

    var outputSamples = [Float]()

    assetReader.startReading()
    while assetReader.status == .reading {
        let trackOutput = assetReader.outputs.first!

        if let sampleBuffer = trackOutput.copyNextSampleBuffer(),
            let blockBuffer = CMSampleBufferGetDataBuffer(sampleBuffer) {
            let blockBufferLength = CMBlockBufferGetDataLength(blockBuffer)
            let sampleLength = CMSampleBufferGetNumSamples(sampleBuffer) * channelCount(from: assetReader)
            var data = Data(capacity: blockBufferLength)
            data.withUnsafeMutableBytes { (blockSamples: UnsafeMutablePointer<Int16>) in
                CMBlockBufferCopyDataBytes(blockBuffer, atOffset: 0, dataLength: blockBufferLength, destination: blockSamples)
                CMSampleBufferInvalidate(sampleBuffer)

                let processedSamples = process(blockSamples,
                                               ofLength: sampleLength,
                                               from: assetReader,
                                               downsampledTo: targetSampleCount)
                outputSamples += processedSamples
            }
        }
    }
    var paddedSamples = [Float](repeating: silenceDbThreshold, count: targetSampleCount)
    paddedSamples.replaceSubrange(0..<min(targetSampleCount, outputSamples.count), with: outputSamples)

This is due to copyNextSampleBuffer() and The Create Rule.

In turn, we can not use CFRelease() in Swift. The reason why a link to the Objective-C only rule is there is beyond my understanding.

Is there a way to release CMSampleBuffer manually in Swift?

Body:
I recently solved a similar issue by using an autoreleasepool

Try wrapping the area where sampleBuffer is used in an autoreleasepool. Something like this:

var outputSamples = [Float]()

assetReader.startReading()
while assetReader.status == .reading {
    let trackOutput = assetReader.outputs.first!

    autoreleasepool {
        if let sampleBuffer = trackOutput.copyNextSampleBuffer(),
            let blockBuffer = CMSampleBufferGetDataBuffer(sampleBuffer) {
            let blockBufferLength = CMBlockBufferGetDataLength(blockBuffer)
            let sampleLength = CMSampleBufferGetNumSamples(sampleBuffer) * channelCount(from: assetReader)
            var data = Data(capacity: blockBufferLength)
            data.withUnsafeMutableBytes { (blockSamples: UnsafeMutablePointer<Int16>) in
                CMBlockBufferCopyDataBytes(blockBuffer, atOffset: 0, dataLength: blockBufferLength, destination: blockSamples)
                CMSampleBufferInvalidate(sampleBuffer)

                let processedSamples = process(blockSamples,
                                               ofLength: sampleLength,
                                               from: assetReader,
                                               downsampledTo: targetSampleCount)
                outputSamples += processedSamples
            }
        }
    }
}
var paddedSamples = [Float](repeating: silenceDbThreshold, count: targetSampleCount)
paddedSamples.replaceSubrange(0..<min(targetSampleCount, outputSamples.count), with: outputSamples)

If I understand correctly, once it moves out of the scope of autoreleasepool, the sampleBuffer will be released


问:
docker storage backend and container-generated data storage
I am learning about Docker storage and I am little bit confused about

Question 1 :

Do we have for each docker host 1 backend store ( to store layers of images and writable-layers of containers ) ?

and if we configure a container-generated data store ( to persist the data wrote by a container (Volumes,Bind mounts,tmpfs mounts) ) are we going have 2 stores ( backend and container-generated-data store ) or is it just one store ?

Question 2 : suppose we have configured a volume to persist container-generated data , is it still gonning to be a a union fs layer somewhere else that is going to be persisted even if the container is removed ?

Question 3 : containers are runnable images , but concretly can you explain to me what are they ? are they just a unionFs layer ?

Question 4 :
if we uninstall or stop docker is the thin pool on loopback device saved or is it removed ?

 and what if we configure a thin pool on a logical volume and we uninstall docker will we still have the images and the container-generated data on the logical volume ?

Question 5 : how do we configure docker to use a group volume ( or a logical volume ) in a remote machine ?

Question 6 : what is the different between the persistant storage configured for kubernetes/okd/openshift cluser and the persistant storage configured for docker and does the configuration for docker storage conflict with the one of kubernetes ?
https://docs.okd.io/latest/install_config/persistent_storage/index.html
https://docs.okd.io/latest/install_config/persistent_storage/index.html

答:
Answer 1 :

Yes we have one and only one docker backend storage for each docker host

backend store : is used to store only the images and the container layer

volumes

if volume bind : then store in filesystem else in :

/var/lib/docker/volumes/

3 . Bind mounts : stored anywhere on the host system

4 . tmpfs mounts : stored anywhere on the host system

Answer 2 :

volumes are not used to persist all the container layer but a specific folder

Answer 3 :

containers are just layers on top of the image layer where the process that it runs are isolated using

Answer 4 :

writable layer using backend store on loop back device is ephemeral so it won't be persisted after stop of docker container nore uninstall of docker engine.

Answer 5 :

use SAN or NAS

Answer 6 :

docker storage is used to store images and container
kubernetes is used to persist data of containers


问:
HTML how to open a video when i click a button
So I want to make it so when I click the button I have set, the background will change to this mp4 file that will automatically play (with audio), but I'm pretty new to HTML so I cant get the button to actually do anything. This is the code I have so far, it's in the body section. I've tried using onclick with .innerHTML (like in the example below), I've tried different variations of that but I can't get it to work, I can't think of an alternative so I'm asking ya'll beautiful people</p>

```<code><p> Hey, ya like this clock?</p>
<p> Click this button >:)</p>
<input type="button" value="( ͡° ͜ʖ ͡°)" onclick="clicc()">
<script>
function clicc(){
    document.body.innerHTML = "<div class="section">"
            <video>
                <source src="ZA WARUDO.mp4" type="video/mp4">
            </video>
        </div>
}
</code>```

答:
There's an issue with your use of quotations.
you can't create a string with "" and then have HTML attributes with "" as well.

```<code><html>
<head>
<script>
function clicc(){
 document.body.innerHTML = "<div class='section'><video controls><source src='https://file-examples.com/wp-content/uploads/2017/04/file_example_MP4_480_1_5MG.mp4' type='video/mp4'></video></div>"
}
</script>
</head>
<body>
<p> Hey, ya like this clock?</p>
<p> Click this button >:)</p>
<input type="button" value="( ͡° ͜ʖ ͡°)" onClick="clicc()">
</body>

</html>
</code>```

Check this demo: https://jsfiddle.net/7pruecmh/5/

Body:
So I want to make it so when I click the button I have set, the background will change to this mp4 file that will automatically play (with audio), but I'm pretty new to HTML so I cant get the button to actually do anything. This is the code I have so far, it's in the body section. I've tried using onclick with .innerHTML (like in the example below), I've tried different variations of that but I can't get it to work, I can't think of an alternative so I'm asking ya'll beautiful people

 Hey, ya like this clock?

 Click this button >:)

<input type="button" value="( ͡° ͜ʖ ͡°)" onclick="clicc()">

Body:
There's an issue with your use of quotations.
you can't create a string with "" and then have HTML attributes with "" as well.

<html>
<head>
<script>
function clicc(){
 document.body.innerHTML = "<div class='section'><video controls><source src='https://file-examples.com/wp-content/uploads/2017/04/file_example_MP4_480_1_5MG.mp4' type='video/mp4'></video></div>"
}
</script>
</head>
<body>
<p> Hey, ya like this clock?</p>
<p> Click this button >:)</p>
<input type="button" value="( ͡° ͜ʖ ͡°)" onClick="clicc()">
</body>

</html>

Check this demo: https://jsfiddle.net/7pruecmh/5/


问:
Bool Filter not showing just the filtered data in Elastic Search
I have an index "tag_nested" which has data of following type :

```<code>{
    "jobid": 1,
    "table_name": "table_A",
    "Tags": [
      {
        "TagType": "WorkType",
        "Tag": "ETL"
      },
      {
        "TagType": "Subject Area",
        "Tag": "Telecom"
      }
    ]
}
</code>```

When I fire the query to filter data on "Tag" and "TagType" by firing following query :

```<code>POST /tag_nested/_search
{
    "query": {
        "bool": {
            "must": {"match_all": {}},
            "filter": [
                {"term": {
                    "Tags.Tag.keyword": "ETL"
                }},
                 {"term": {
                    "Tags.TagType.keyword": "WorkType"
                }}
            ]
        }
    }
}
</code>```

It gives me the following output. The problem I am facing is while the above query filters documents which doesn't have filtered data BUT it shows all the "Tags" of that document instead of just the filter one

```<code>{
        "_index" : "tag_nested",
        "_type" : "_doc",
        "_id" : "9",
        "_score" : 1.0,
        "_source" : {
          "jobid" : 1,
          "table_name" : "table_A",
          "Tags" : [
            {
              "TagType" : "WorkType",
              "Tag" : "ETL"
            },
            {
              "TagType" : "Subject Area",
              "Tag" : "Telecom"
            }
          ]
        }
      }
</code>```

Instead of above result I want my output to be like :

```<code>{
        "_index" : "tag_nested",
        "_type" : "_doc",
        "_id" : "9",
        "_score" : 1.0,
        "_source" : {
          "jobid" : 1,
          "table_name" : "table_A",
          "Tags" : [
            {
              "TagType" : "WorkType",
              "Tag" : "ETL"
            }
          ]
        }
      }
</code>```

答:
Already answered here, here and here.

TL;DR you'll need to make your Tags field of type nested, resync your index & use inner_hits to only fetch the applicable tag group.

Body:
I have an index "tag_nested" which has data of following type :

{
    "jobid": 1,
    "table_name": "table_A",
    "Tags": [
      {
        "TagType": "WorkType",
        "Tag": "ETL"
      },
      {
        "TagType": "Subject Area",
        "Tag": "Telecom"
      }
    ]
}

When I fire the query to filter data on "Tag" and "TagType" by firing following query :

POST /tag_nested/_search
{
    "query": {
        "bool": {
            "must": {"match_all": {}},
            "filter": [
                {"term": {
                    "Tags.Tag.keyword": "ETL"
                }},
                 {"term": {
                    "Tags.TagType.keyword": "WorkType"
                }}
            ]
        }
    }
}

It gives me the following output. The problem I am facing is while the above query filters documents which doesn't have filtered data BUT it shows all the "Tags" of that document instead of just the filter one

{
        "_index" : "tag_nested",
        "_type" : "_doc",
        "_id" : "9",
        "_score" : 1.0,
        "_source" : {
          "jobid" : 1,
          "table_name" : "table_A",
          "Tags" : [
            {
              "TagType" : "WorkType",
              "Tag" : "ETL"
            },
            {
              "TagType" : "Subject Area",
              "Tag" : "Telecom"
            }
          ]
        }
      }

Instead of above result I want my output to be like :

{
        "_index" : "tag_nested",
        "_type" : "_doc",
        "_id" : "9",
        "_score" : 1.0,
        "_source" : {
          "jobid" : 1,
          "table_name" : "table_A",
          "Tags" : [
            {
              "TagType" : "WorkType",
              "Tag" : "ETL"
            }
          ]
        }
      }


问:
What is the difference between self and not self objects particularly in Tkinter class?
I have this simple code with self.btn1

```<code>from tkinter import Tk, ttk, messagebox
import tkinter as tk

class Main(tk.Frame):
    def __init__(self, root):
        super().__init__(root)
        self.btn1 = ttk.Button(self, text="test")
        self.btn1.pack()

if __name__ == "__main__":
    root = tk.Tk()
    app = Main(root)
    app.pack()
    root.mainloop()
</code>```

and this code without self button

```<code>from tkinter import Tk, ttk, messagebox
import tkinter as tk

class Main(tk.Frame):
    def __init__(self, root):
        super().__init__(root)
        btn1 = ttk.Button(self, text="test")
        btn1.pack()

if __name__ == "__main__":
    root = tk.Tk()
    app = Main(root)
    app.pack()
    root.mainloop()
</code>```

Both of them work similarly, but what's the difference, which one should I use?

答:
The only real difference lies in how easy it is to retrieve the reference to the Button instance should you need one. With the former, it's just app.btn1. With the latter, it's app.winfo_children()[0].

```<code>>>> app.winfo_children()[0] is app.btn1
True
</code>```

Body:
I have this simple code with self.btn1

from tkinter import Tk, ttk, messagebox
import tkinter as tk

class Main(tk.Frame):
    def __init__(self, root):
        super().__init__(root)
        self.btn1 = ttk.Button(self, text="test")
        self.btn1.pack()

if __name__ == "__main__":
    root = tk.Tk()
    app = Main(root)
    app.pack()
    root.mainloop()

and this code without self button

from tkinter import Tk, ttk, messagebox
import tkinter as tk

class Main(tk.Frame):
    def __init__(self, root):
        super().__init__(root)
        btn1 = ttk.Button(self, text="test")
        btn1.pack()

if __name__ == "__main__":
    root = tk.Tk()
    app = Main(root)
    app.pack()
    root.mainloop()

Both of them work similarly, but what's the difference, which one should I use?

Body:
The only real difference lies in how easy it is to retrieve the reference to the Button instance should you need one. With the former, it's just app.btn1. With the latter, it's app.winfo_children()[0].

>>> app.winfo_children()[0] is app.btn1
True


答:
the problem is with the quotes and double quotes, here is the fixed js code bit:

```<code><p> Hey, ya like this clock?</p>
<p> Click this button >:)</p>

<input type="button" value="( ͡° ͜ʖ ͡°)" onclick="clicc()">

<script>
function clicc(){
  document.body.innerHTML = "<div class='section'><video source src='ZA WARUDO.mp4' type='video/mp4'></video></div>";
}
</script>
</code>```

If you want to use double quotes for everything you'll have to escape the ones that are not to define the html string, the ones you'll use to define the html elements attributes, like this:

```<code>document.body.innerHTML = "<div class=\"section\"><video source src=\"ZA WARUDO.mp4\" type=\"video/mp4\"></video></div>";
</code>```

Title: HTML how to open a video when i click a button

Body:
the problem is with the quotes and double quotes, here is the fixed js code bit:

<p> Hey, ya like this clock?</p>
<p> Click this button >:)</p>

<input type="button" value="( ͡° ͜ʖ ͡°)" onclick="clicc()">

<script>
function clicc(){
  document.body.innerHTML = "<div class='section'><video source src='ZA WARUDO.mp4' type='video/mp4'></video></div>";
}
</script>

If you want to use double quotes for everything you'll have to escape the ones that are not to define the html string, the ones you'll use to define the html elements attributes, like this:

document.body.innerHTML = "<div class=\"section\"><video source src=\"ZA WARUDO.mp4\" type=\"video/mp4\"></video></div>";


问:
Is there a way to stop the function from returning the jsx till an asyn function is called in a React functional Component?
Please look at the following code:-

```<code>import React, { useState } from "react";

export const Context = React.createContext();

export default function ImportBefore() {
  const [message, setMessage] = useState("");

  (async () => {
    await new Promise(resolve => setTimeout(resolve, 5000));
    setMessage("Antha Rama Mayam!");
  })();

  return (
    <Context.Provider value={message}>Message is {message}</Context.Provider>
  );
}
</code>```

As I see the output initially it is "Message is" and later after the 5 seconds it is "Message is Antha Rama Mayam". This is as expected.

Is there a way to stop the return till the async function is returned and the message is set appropriately.

I tried with Suspense and useState with Lazy Loading. Also, useEffect did not add much value here. Is there a way out?

答:
No.

However, what you can do is return something like a loading spinner while message is empty or whatever else you could imagine. Perhaps just return an empty div?

```<code>return (
    {message ? (
        <Context.Provider value={message}>Message is {message}</Context.Provider>
    ) : (
        <div></div>
    )}
)
</code>```

Body:
Please look at the following code:-

import React, { useState } from "react";

export const Context = React.createContext();

export default function ImportBefore() {
  const [message, setMessage] = useState("");

  (async () => {
    await new Promise(resolve => setTimeout(resolve, 5000));
    setMessage("Antha Rama Mayam!");
  })();

  return (
    <Context.Provider value={message}>Message is {message}</Context.Provider>
  );
}

As I see the output initially it is "Message is" and later after the 5 seconds it is "Message is Antha Rama Mayam". This is as expected.

Is there a way to stop the return till the async function is returned and the message is set appropriately.

I tried with Suspense and useState with Lazy Loading. Also, useEffect did not add much value here. Is there a way out?

Body:
No.

However, what you can do is return something like a loading spinner while message is empty or whatever else you could imagine. Perhaps just return an empty div?

return (
    {message ? (
        <Context.Provider value={message}>Message is {message}</Context.Provider>
    ) : (
        <div></div>
    )}
)


问:
How to map an array of elements for Reach component in typescript?
This is my component:

import React, { FunctionComponent as FC } from 'react';

type shapeMidNumbersInput = { arrMidNumbers: Array<number> };

const MidNumbers: FC<shapeMidNumbersInput> = ({ arrMidNumbers }): Array<Element> => (

    {arrMidNumbers.map(item => (

{item}

    ))}

);

const Caller = () => <MidNumbers arrMidNumbers={[3, 4, 5]} />;

export default Caller;

```

<p>The error I'm getting is:</p>

<blockquote>
  <p>Type 'JSX.Element[]' is not assignable to type 'Element[]'. Type 'Element' is missing the following properties from the type 'Element': assignedSlot, attributes, classList, className, and 123 more.
  Type 'Element' is missing the following properties from type 'ReactElement'type, props, key</p>
</blockquote>

<p>I'm expecting output</p>

<pre class="lang-html prettyprint-override"><code><section>
   <div>3</div>
   <div>4</div>
   <div>5</div>
</section>
</code>```

Any suggestions where I'm going wrong with my typescript code?

thanks

答:
You don't need to declare the return type of the function MidNumbers. Array<Element> is the wrong type, and anyway declaring the function variable itself as type FC<shapeMidNumbersInput> automatically infers the return type correctly because the generic class does it for you.

```<code>const MidNumbers: FC<shapeMidNumbersInput> = ({ arrMidNumbers }) => (
  <section>
    {arrMidNumbers.map(item => (
      <div>{item}</div>
    ))}
  </section>
);
</code>```

Body:
This is my component:

import React, { FunctionComponent as FC } from 'react';

type shapeMidNumbersInput = { arrMidNumbers: Array<number> };

const MidNumbers: FC<shapeMidNumbersInput> = ({ arrMidNumbers }): Array<Element> => (

    {arrMidNumbers.map(item => (

{item}

    ))}

);

const Caller = () => <MidNumbers arrMidNumbers={[3, 4, 5]} />;

export default Caller;

The error I'm getting is:

Type 'JSX.Element[]' is not assignable to type 'Element[]'. Type 'Element' is missing the following properties from the type 'Element': assignedSlot, attributes, classList, className, and 123 more.
  Type 'Element' is missing the following properties from type 'ReactElement'type, props, key

I'm expecting output

3

4

5

Any suggestions where I'm going wrong with my typescript code?

thanks

Body:
You don't need to declare the return type of the function MidNumbers. Array<Element> is the wrong type, and anyway declaring the function variable itself as type FC<shapeMidNumbersInput> automatically infers the return type correctly because the generic class does it for you.

const MidNumbers: FC<shapeMidNumbersInput> = ({ arrMidNumbers }) => (
  <section>
    {arrMidNumbers.map(item => (
      <div>{item}</div>
    ))}
  </section>
);


问:
Hyperledger Fabric java how to use getQueryResult()
I'm trying to use the getQueryResult() method in a transaction but i'm not able to understand what type of string i have to pass in the method.
I have an asset composed by and id, name, surname and an hash. I want to verify that the hash doesn't alreaty exists in the ledger.
The underlying database is couchdb.
All the string i used returned me an error. Could someone help me to use the right syntax?
Thank you</p>

答: Save your data in JSON format, and then later passon 'couch db' query to this method to get answer.</p>


问:
MySql match get record where columns value near others (under threshold)
I have the following coordinates records

what I want is, to get all records where z1 difference with any other record is less than 4 (threshold)

that means in the above table, the last 2 records have a difference less than 4 then I want to get them in the query.

also if a new record with z1 = 808 exists, then this record and the record with id 28478 should be returned because they have a difference with less than 4.

is there any way I can achieve this in MySql?

or maybe PHP, without talking so long to do it?

Edit:
here is the data:

```<code>+-------+-------+-------+-------+-------+
|  id   |  x1   |  x2   |  z1   |  z2   |
+-------+-------+-------+-------+-------+
| 28478 | -1500 | -1496 |   804 |   808 |
| 29929 | -1500 | -1496 |  1444 |  1448 |
| 30051 | -1500 | -1496 | -1168 | -1164 |
| 30346 | -1500 | -1496 |  -336 |  -332 |
| 28039 | -1496 | -1492 | -1128 | -1124 |
| 28969 | -1496 | -1492 | -1424 | -1420 |
| 29265 | -1496 | -1492 |  -520 |  -516 |
| 29872 | -1496 | -1492 |  1288 |  1292 |
| 30122 | -1496 | -1492 |  -932 |  -928 |
| 30846 | -1496 | -1492 |  1376 |  1204 |
| 30898 | -1496 | -1492 |  1380 |  1384 |
+-------+-------+-------+-------+-------+
</code>```

I tried

```<code>select *
from coordinates t
where
    x1 between -1500 and -1500 + 4
  and exists (
        select 1
        from coordinates t1
        where t1.id <> t.id
          and abs(t1.z1 - t.z1) <= 4);
</code>```

but didn't work.

答:
You can use exists:

```<code>select t.*
from mytable t
where exists (
    select 1
    from mytable t1
    where t1.id <> t.id and abs(t1.z1 - t.z1) <= 4
)
</code>```

It might be more efficient not to use abs():

```<code>select t.*
from mytable t
where exists (
    select 1
    from mytable t1
    where t1.id <> t.id and t1.z1 - t.z1 between -4 and 4
)
</code>```

Demo on DB Fiddle - both queries yield:

```
   id |    x1 |    x2 |   z1 |   z2
----: | ----: | ----: | ---: | ---:
30846 | -1496 | -1492 | 1376 | 1204
30898 | -1496 | -1492 | 1380 | 1384
```

Body:
I have the following coordinates records

what I want is, to get all records where z1 difference with any other record is less than 4 (threshold)

that means in the above table, the last 2 records have a difference less than 4 then I want to get them in the query.

also if a new record with z1 = 808 exists, then this record and the record with id 28478 should be returned because they have a difference with less than 4.

is there any way I can achieve this in MySql?

or maybe PHP, without talking so long to do it?

Edit:
here is the data:

+-------+-------+-------+-------+-------+
|  id   |  x1   |  x2   |  z1   |  z2   |
+-------+-------+-------+-------+-------+
| 28478 | -1500 | -1496 |   804 |   808 |
| 29929 | -1500 | -1496 |  1444 |  1448 |
| 30051 | -1500 | -1496 | -1168 | -1164 |
| 30346 | -1500 | -1496 |  -336 |  -332 |
| 28039 | -1496 | -1492 | -1128 | -1124 |
| 28969 | -1496 | -1492 | -1424 | -1420 |
| 29265 | -1496 | -1492 |  -520 |  -516 |
| 29872 | -1496 | -1492 |  1288 |  1292 |
| 30122 | -1496 | -1492 |  -932 |  -928 |
| 30846 | -1496 | -1492 |  1376 |  1204 |
| 30898 | -1496 | -1492 |  1380 |  1384 |
+-------+-------+-------+-------+-------+

I tried

select *
from coordinates t
where
    x1 between -1500 and -1500 + 4
  and exists (
        select 1
        from coordinates t1
        where t1.id <> t.id
          and abs(t1.z1 - t.z1) <= 4);

but didn't work.

Body:
You can use exists:

select t.*
from mytable t
where exists (
    select 1
    from mytable t1
    where t1.id <> t.id and abs(t1.z1 - t.z1) <= 4
)

It might be more efficient not to use abs():

select t.*
from mytable t
where exists (
    select 1
    from mytable t1
    where t1.id <> t.id and t1.z1 - t.z1 between -4 and 4
)

Demo on DB Fiddle - both queries yield:

   id |    x1 |    x2 |   z1 |   z2
----: | ----: | ----: | ---: | ---:
30846 | -1496 | -1492 | 1376 | 1204
30898 | -1496 | -1492 | 1380 | 1384


问:
R function for calculating a 'cumulative difference'
I have a vector like

```<code>v <- c(76, 31, 33, 7)
</code>```

and need to calculate its 'cumulative difference' resulting in

```<code>cumdiff <- c(45, 12, 5)
</code>```

which is 76 - 31 = 45 and 45 - 33 = 12 and 12 - 7 = 5.

Is there an R function like cumsum or do I need to use a loop?

Thank you very much for your help on this.

答:
We can also use accumulate from purrr

```<code>library(purrr)
accumulate(v, `-`)[-1]
#[1] 45 12  5
</code>```

Body:
I have a vector like

v <- c(76, 31, 33, 7)

and need to calculate its 'cumulative difference' resulting in

cumdiff <- c(45, 12, 5)

which is 76 - 31 = 45 and 45 - 33 = 12 and 12 - 7 = 5.

Is there an R function like cumsum or do I need to use a loop?

Thank you very much for your help on this.

Body:
We can also use accumulate from purrr

library(purrr)
accumulate(v, `-`)[-1]
#[1] 45 12  5


答:
You can do:

```<code>dates = ['date1','date2']
df[dates] = df[dates].apply(lambda x:pd.to_datetime(x).dt.normalize())
</code>```

Output:

```<code>     Name      date1      date2
0     bob 2014-05-12 2014-08-31
1  george 2014-05-15 2014-08-12
</code>```

Title: Pandas: Extract date from unconventional timestamp -- YYY/MM/DD:HH:MM:SS AM

Body:
I have data in the following format:

d = {'Name': ['bob', 'george'], 'date1': ['2014/05/12:12:00:00 AM', '2014/05/15:12:00:00 AM'], 'date2': ['2014/08/31:11:59:59 PM', '2014/08/12:11:59:59 PM']}
df = pd.DataFrame(data=d)

   Name                   date1                   date2
0     bob  2014/05/12:12:00:00 AM  2014/08/31:11:59:59 PM
1  george  2014/05/15:12:00:00 AM  2014/08/12:11:59:59 PM

How do I manipute the two date columns to get the following format?

Expected output:

     Name       date1       date2
0     bob  2014-05-12  2014-08-31
1  george  2014-05-15  2014-08-12

Body:
You can do:

dates = ['date1','date2']
df[dates] = df[dates].apply(lambda x:pd.to_datetime(x).dt.normalize())

Output:

     Name      date1      date2
0     bob 2014-05-12 2014-08-31
1  george 2014-05-15 2014-08-12


问:
react-pdf failing to render base64 PDF data, interpreting as hex string
I'm trying to use the react-pdf library to display a base64 encoded PDF file. The B64 data is accurate, as it loads in an iframe as such:

```<code> <iframe
   className={css.previewIframe}
   src={`data:application/pdf;base64,${
     this.props.encodedPdf
   }`}
 />
</code>```

However, if I insert the data into a react-pdf document as such, I get an error:

```<code><Document file={this.props.encodedPdf} />
</code>```

The Document is rendered with an error message Failed to load PDF file., and the console logs the following error: InvalidPDFException {name: "InvalidPDFException", message: "Invalid PDF structure"}

I also get a lot of warnings like the following: Warning: Ignoring invalid character "109" in hex string

The documentation clearly states that the file prop can be B64 encoded content. Any idea on what the issue could be? Here is the B64 data if needed:

```<code>JVBERi0xLjMKMSAwIG9iago8PAovS2lkcyBbIDMgMCBSIF0KL1R5cGUgL1BhZ2VzCi9Db3VudCAxCj4+CmVuZG9iagoyIDAgb2JqCjw8Ci9Qcm9kdWNlciAoUHlQREYyKQo+PgplbmRvYmoKMyAwIG9iago8PAovQ29udGVudHMgNSAwIFIKL1JvdGF0ZSAwCi9UeXBlIC9QYWdlCi9SZXNvdXJjZXMgPDwKL1Byb2NTZXQgWyAvUERGIC9UZXh0IF0KPj4KL0Nyb3BCb3ggWyAwIDAgNjEyIDc5MiBdCi9QYXJlbnQgMSAwIFIKL01lZGlhQm94IFsgMCAwIDYxMiA3OTIgXQo+PgplbmRvYmoKNCAwIG9iago8PAovVHlwZSAvQ2F0YWxvZwovUGFnZXMgMSAwIFIKPj4KZW5kb2JqCjUgMCBvYmoKPDwKL0xlbmd0aCAxMAovRmlsdGVyIC9GbGF0ZURlY29kZQo+PgpzdHJlYW0KSIkCCDAAAAAAAQplbmRzdHJlYW0KZW5kb2JqCnhyZWYKMCA2CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDY4IDAwMDAwIG4gCjAwMDAwMDAxMDggMDAwMDAgbiAKMDAwMDAwMDI3MyAwMDAwMCBuIAowMDAwMDAwMzIyIDAwMDAwIG4gCnRyYWlsZXIKPDwKL1NpemUgNgovUm9vdCA0IDAgUgovSW5mbyAyIDAgUgo+PgpzdGFydHhyZWYKNDAzCiUlRU9GCg==
</code>```

If I add data:application/pdf;base64, to the beginning of the string, there are no errors, but also nothing is rendered.

答:
The issue was:

I needed data:application/pdf;base64, in front of the string

I did not have a  component inside of my  component. See https://github.com/wojtekmaj/react-pdf/issues/203

Body:
I'm trying to use the react-pdf library to display a base64 encoded PDF file. The B64 data is accurate, as it loads in an iframe as such:

However, if I insert the data into a react-pdf document as such, I get an error:

<Document file={this.props.encodedPdf} />

The Document is rendered with an error message Failed to load PDF file., and the console logs the following error: InvalidPDFException {name: "InvalidPDFException", message: "Invalid PDF structure"}

I also get a lot of warnings like the following: Warning: Ignoring invalid character "109" in hex string

The documentation clearly states that the file prop can be B64 encoded content. Any idea on what the issue could be? Here is the B64 data if needed:

JVBERi0xLjMKMSAwIG9iago8PAovS2lkcyBbIDMgMCBSIF0KL1R5cGUgL1BhZ2VzCi9Db3VudCAxCj4+CmVuZG9iagoyIDAgb2JqCjw8Ci9Qcm9kdWNlciAoUHlQREYyKQo+PgplbmRvYmoKMyAwIG9iago8PAovQ29udGVudHMgNSAwIFIKL1JvdGF0ZSAwCi9UeXBlIC9QYWdlCi9SZXNvdXJjZXMgPDwKL1Byb2NTZXQgWyAvUERGIC9UZXh0IF0KPj4KL0Nyb3BCb3ggWyAwIDAgNjEyIDc5MiBdCi9QYXJlbnQgMSAwIFIKL01lZGlhQm94IFsgMCAwIDYxMiA3OTIgXQo+PgplbmRvYmoKNCAwIG9iago8PAovVHlwZSAvQ2F0YWxvZwovUGFnZXMgMSAwIFIKPj4KZW5kb2JqCjUgMCBvYmoKPDwKL0xlbmd0aCAxMAovRmlsdGVyIC9GbGF0ZURlY29kZQo+PgpzdHJlYW0KSIkCCDAAAAAAAQplbmRzdHJlYW0KZW5kb2JqCnhyZWYKMCA2CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDY4IDAwMDAwIG4gCjAwMDAwMDAxMDggMDAwMDAgbiAKMDAwMDAwMDI3MyAwMDAwMCBuIAowMDAwMDAwMzIyIDAwMDAwIG4gCnRyYWlsZXIKPDwKL1NpemUgNgovUm9vdCA0IDAgUgovSW5mbyAyIDAgUgo+PgpzdGFydHhyZWYKNDAzCiUlRU9GCg==

If I add data:application/pdf;base64, to the beginning of the string, there are no errors, but also nothing is rendered.