stopping parser when error found in semantic action
Tag : cpp , By : lonehunter01
Date : March 29 2020, 07:55 AM
With these it helps Spirit has a special value you can use in a semantic action to make the parse fail. It's called _pass and you should set it to false. From some of my code: variable_reference_impl_[_pass = lookup_symbol_(_1, false)][_val = _1]
|
Newly signed assembly not found (stopping deployment)
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further Sorted it now; I'll post the answer just in case anybody else comes up against the same problem. For the wsp I'm deploying to also deploy the project dependency - it needs to be included in the project manifest. You get to this by double clicking on Package (in the primary project being deployed) > Advanced tab at the bottom > and then adding the assembly from project output.
|
Computing all values or stopping and returning just the best value if found
Tag : list , By : francisco santos
Date : March 29 2020, 07:55 AM
it fixes the issue OK, I'm not sure how your whole setup looks like, but I tried to prepare a minimal example that would mirror your situation. Here it is then: object StreamTest {
case class Item(value : Int)
def createItems() = List(Item(0),Item(3),Item(30),Item(8),Item(8),Item(4),Item(54),Item(-1),Item(23),Item(131))
def computeValue(i : Item) = { Thread.sleep(3000); i.value * 2 - 2 }
def process(minValue : Int)(items : Seq[Item]) = {
val stream = Stream(items: _*).map(item => item -> computeValue(item)).filter(tuple => tuple._2 >= 0)
stream.find(tuple => tuple._2 < minValue).map(List(_)).getOrElse(stream.sortBy(_._2).toList)
}
}
val items = StreamTest.createItems()
val result = StreamTest.process(2)(items)
result.foreach(r => println("Original: " + r._1 + " , calculated: " + r._2))
[info] Running Main
Original: Item(3) , calculated: 4
Original: Item(4) , calculated: 6
Original: Item(8) , calculated: 14
Original: Item(8) , calculated: 14
Original: Item(23) , calculated: 44
Original: Item(30) , calculated: 58
Original: Item(54) , calculated: 106
Original: Item(131) , calculated: 260
[success] Total time: 31 s, completed 2013-11-21 15:57:54
val result = StreamTest.process(5)(items)
[info] Running Main
Original: Item(3) , calculated: 4
[success] Total time: 7 s, completed 2013-11-21 15:55:20
|
stopping 'sed' after match found on a line; don't let sed keep checking all lines to EOF
Tag : bash , By : lwl_seu
Date : March 29 2020, 07:55 AM
like below fixes the issue Ok so I got the job done with this little (or perhaps big if too much overkill?) script I whipped up: #!/bin/bash
sedLnCnt=1
while [[ "$sedLnCnt" -lt 521 ]] ; do
lN=$(sed -n "${sedLnCnt} p" sGNoSecNums.html|sed -r 's/^([^\t]*\t).*$/\1/') #; echo "\$lN: $lN"
lnNum=($(grep -n "$lN" sGNoSecNums.html|sed -r 's/^([0-9]+):.*$/\1/')) #; echo "num of matches: ${#lnNum[@]}"
if [[ "${#lnNum[@]}" -gt 1 ]] ; then #'if'
lCnt="${#lnNum[@]}"
((eleN = $lCnt-1)) #; echo "\$eleN: ${eleN}" # var $eleN needs to be 1 less than total line count of zero-based array
while [[ "$lCnt" -gt 0 ]] ; do
sed -ri "${lnNum[$eleN]}s/^([^\t]*)\t/\1 \(${lCnt}\)\t/" sGNoSecNums.html
((lCnt--))
((eleN--))
done
fi
((sedLnCnt++))
done
|
Stopping response if document isn't found
Date : March 29 2020, 07:55 AM
Any of those help As I said in my comment, you need to properly sequence your async operations so you don't start the next one until you know the result of the previous one and have processed that. You can do that like this: // Create a new Game ID.
v1.post("/", function(req, res, next) {
if ( !("project_id" in req.body) ) {
return res.send("You need to provide Project ID");
}
// Check if the Project ID is in the file.
// Problematic bit
projectExists( req.body.project_id, function(c) {
if ( c == 0 ) {
return res.send("The provided Project Id does not exist in our database.");
} else {
var gameDataObj = req.body;
GameData.addGameId(gameDataObj, function (err, doc) {
if (err) {
if (err.name == "ValidationError") {
return res.send("Please send all the required details.");
}
throw err;
};
res.json(doc);
})
}
});
});
|