exists

Angular2: No best common type exists among return expressions

匿名 (未验证) 提交于 2019-12-03 08:35:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Trying to compile my typescript with gulp but I'll get the following error: No best common type exists among return expressions. Where the code is a for loop which looks like this: getIndexInCompareList(result) { for (var i = 0; i < this.compare.length; i++) { if (this.compare[i].resource.id == result.resource.id) { return i; } } return false; } 回答1: any as your return value for the function to fix this issue. However, as many other functions such as indexOf return numbers only even if the value was not found I would suggest you do the same.

Check if file exists and continue else exit in Bash

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a script that is one script in a chain of others that sends an email. At the start of the script I want to check if a file exists and continue only if it exists, otherwise just quit. Here is the start of my script: if [ ! -f /scripts/alert ]; then echo "File not found!" && exit 0 else continue fi However I keep getting a message saying: line 10: continue: only meaningful in a `for', `while', or `until' loop Any pointers? 回答1: Change it to this: { if [ ! -f /scripts/alert ]; then echo "File not found!" exit 0 fi } A conditional isn't a

Relational division in mysql without aggregrate functions?

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to implement a simple relational division in mysql with where exists or where not exists.I don't want to use any of the aggregrate functions and also don't want to use where in or where not in clauses.I am trying to write relational algebra and relational calculus queries for the same so it would be easy if I do it this way. For example: GID PID TEAM 101 1 X 201 2 X 301 3 X 101 4 Y 201 5 Y 101 6 Z The answer is GID,TEAM/GID which gives X as the answer.I want to know how to implement this is mysql with where exists or not exists. 回答1:

No mapping exists from ObjectParameter to a known managed provider native type

匿名 (未验证) 提交于 2019-12-03 08:28:06
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am in the process of building a WCF service using EF to a Microsoft SQL Server but keep getting the following error: Additional information: No mapping exists from object type System.Data.Objects.ObjectParameter to a known managed provider native type. On this query: string ID = "XXID"; string Sql = @"SELECT * FROM @Table WHERE " + ID + " LIKE '@SearchTerm'"; ObjectParameter[] Parameters = new ObjectParameter[2]; Parameters[0] = new ObjectParameter("Table", Table); Parameters[1] = new ObjectParameter("SearchTerm", SearchTerm); using (var

Check if member function exists and is not inherited for SFINAE

匿名 (未验证) 提交于 2019-12-03 07:50:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How can I check if a member function exists and is not inherited? I need this to resolve ambiguity for the following example: A type either has a foo() or a bar() member function. Caller will call the one that exists for the given type. However, DerivedWithBar inherits foo() from BaseWithFoo but defines its own bar() . Thus, Caller does not know which function to call. I'd need a way to give the non-inherited foo precedence over the inherited bar() , but I do not know how to check if a member function is inherited or not. #include <iostream>

MongoDB sort by only exists entry, key with value first and key with null or not exists last

匿名 (未验证) 提交于 2019-12-03 07:50:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a collection of 15000 documents. Some documents have sr_no with numeric values and other with absent of sr_no . Now i want to get entries like all documents comes first which has sr_no with asc then all others. I tried .find().sort({sr_no:1}) but it return all null entries first then asc with sr_no . This question seems too close with duplicate . But slightly defer with numeric key. I answered it with hack below. 回答1: I used a dirty hack for this. MongoDB doc says that they have priorities for sorting as posted below image. So when i

CMake: build cross-platform distribution

匿名 (未验证) 提交于 2019-12-03 07:50:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: On my MacOSX I've developed an application that makes use of Qt and VTK libraries. I generate the makefile using CMake. Now I want to compile an end-user self-contained package on Windows, and it is supposed to work on end-user machine without needing to pre-install Qt or VTK libraries. I think is possible to do this by modifying the CMakeLists.txt file but a web search hasn't pointed me the right direction. How to make a distributable package for Windows using CMake? 回答1: What I have done in one of my own projects is write a little script

Click a button if text exist in page with iMacros

匿名 (未验证) 提交于 2019-12-03 07:50:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am trying to use iMacros with Firefox to click an UnFollow button ONLY if this code exist on the page... <small class = "follow-status" > follows you </small> If the above does not exist in the page source then it would run this iMacros code... TAG POS = 1 TYPE = DIV ATTR = TXT : UnFollow From what I have read, there is no if/else type syntax but you can run Javascript with EVAL ( "Javascript code here" ) If anyone knows how I could do this I could really use the help 回答1: You can trick Imacros to make an If statement, but first

Sonar runner: JAVA_HOME exists but does not point to a valid Java home folder

匿名 (未验证) 提交于 2019-12-03 07:50:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Situation : I installed Sonarqube on a Win XP 32-bit system. I set all paths as instructed. The server opens up well at localhost://9090. My JAVA_HOME is: C:\Program Files\Java\jdk1.7.0_60; Problem When I run, sonar-runner.bat, I get the following error: ERROR: Java_Home exists but does not point to a valid Java home folder. No "\bin\java.exe" file can be found here. What I tried: I added /bin to the path. I tried /jre, and then /jre/bin (Note: all of them contain the "/bin/java.exe" within them. Is this due to some permissions issue of the

If one of two elements exists, do something

强颜欢笑 提交于 2019-12-03 07:21:05
问题 I currently do this to check if one of two elements exists: if ($(".element1").length > 0 || $(".element2").length > 0) { //do stuff... } Is there a better way to rewrite the same? I mean, is .length the same as .length > 0 ? 回答1: if ($(".element1").is('*') || $(".element2").is('*')) { // code } EDIT (per comment) Select elements by multiple classes in one call: if ($(".element1, .element2").is('*')) { // code } 回答2: if ( $('#myDiv')[0] ) { //do something } ..works best! Found here. 回答3: All