I keep track of hikes we do in an EXCEL spreadsheet. I use WORD to create journal pages using a lot of MERGEFIELDS. I have clean maps of parks. After we do a hike, I use an editor to draw a route on the clean map of where we hiked producing a route map.
I would like to INCLUDEPICTURE the route map if there is one, otherwise a clean map. For these examples "Death Valley Map.jpg" does exist, "Death Valley Map Route.jpg" does not exist.
I cannot see that "{ IF TRUE ..." ever does anything. Is there some WORD option or switch that needs to be set? My problem is that I cannot get any if test to branch false when the file does not exist.
Test Case
Test Result
{ IF "Death Valley Map.jpg" }
null
{ IF "Death Valley Map Route.jpg" }
null
{ IF "Death Valley Map.jpg" "GoodA" "BadA" }
GoodA
{ IF "Death Valley Map Route.jpg" "GoodB" "BadB" }
GoodB
{ IF TRUE "Death Valley Map.jpg" }
Death Valley Map.jpg
{ IF TRUE "Death Valley Map Route.jpg" }
Death Valley Map Route.jpg
{ IF TRUE "Death Valley Map.jpg" "GoodC" "BadC" }
Death Valley Map.jpg
{ IF TRUE "Death Valley Map Route.jpg" "GoodD" "BadD" }
Death Valley Map Route.jpg
{ IF { IF TRUE "Death Valley Map.jpg" } "GoodE" "BadE" }
GoodE
{ IF { IF TRUE "Death Valley Map Route.jpg" } "GoodF" "BadF" }
GoodF
{ IF { IF TRUE "Death Valley Map.jpg" } <> "" "GoodG" "BadG" }
GoodG
{ IF { IF TRUE "Death Valley Map Route.jpg" } <> "" "GoodH" "BadH" }
GoodH
{ IF { INCLUDEPICTURE "{ IF TRUE "Death Valley Map.jpg" }" \d } "GoodI" "BadI" }
GoodI
{ IF { INCLUDEPICTURE "{ IF TRUE "Death Valley Map Route.jpg" }" \d } "GoodJ" "BadJ" }
GoodJ
{ IF { IF TRUE { INCLUDEPICTURE "{ IF TRUE "Death Valley Map.jpg" }" \d } } "GoodK" "BadK" }
GoodK
{ IF { IF TRUE { INCLUDEPICTURE "{ IF TRUE "Death Valley Map Route.jpg" }" \d } } "GoodL" "BadL" }
GoodL
{ IF { IF TRUE { INCLUDEPICTURE "{ IF TRUE "Death Valley Map.jpg" }" \d } } <> "" "GoodM" "BadM" }
GoodM
{ IF { IF TRUE { INCLUDEPICTURE "{ IF TRUE "Death Valley Map Route.jpg" }" \d } } <> "" "GoodN" "BadN" }
GoodN
Screen shots in case I didn't type exactly:
screen shot of test cases
screen shot of test results
Related
Here's my settings:
{
"C_Cpp.errorSquiggles": "Enabled",
"C_Cpp.intelliSenseEngine": "Default",
"C_Cpp.intelliSenseEngineFallback": "Disabled",
"C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 0}",
"workbench.sideBar.location": "right",
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true
},
"editor.formatOnPaste": true,
"editor.formatOnType": true,
"terminal.integrated.shell.windows": "C:/msys64/usr/bin/bash.exe",
"terminal.integrated.shellArgs.windows": [ "-i" ],
"terminal.integrated.env.windows": {
"MSYSTEM": "MINGW64",
"PATH" : "/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/"
}
}
It correctly format braces as:
void myCode() {
}
and not:
void myCode()
{
}
but when I copy/paste, it also add a new indention, such as:
void myCode() {
}
Expecially when there are some code before this.
Why? How can i fix it?
EDIT: here's a practical example. This is the code I have:
struct Test : Module
{
enum ParamIds {
TRIGGER_PARAM,
CYCLE_PARAM,
RATE_PARAM,
RATE_FINE_PARAM,
RISE_LENGTH_PARAM,
NUM_PARAMS
};
enum InputIds
{
TRIGGER_INPUT,
TAIL_LENGTH_CV_INPUT,
NUM_INPUTS
};
enum OutputIds {
EOR_OUTPUT,
EOF_OUTPUT,
EOC_OUTPUT,
RISING_OUTPUT,
FALLING_OUTPUT,
OUT_OUTPUT,
NUM_OUTPUTS
};
};
If now within InputIds I paste a value in that empty space, that's the result:
struct Test : Module
{
enum ParamIds {
TRIGGER_PARAM,
CYCLE_PARAM,
RATE_PARAM,
RATE_FINE_PARAM,
RISE_LENGTH_PARAM,
NUM_PARAMS
};
enum InputIds {
TRIGGER_INPUT,
ASD_PARAM,
TAIL_LENGTH_CV_INPUT,
NUM_INPUTS
};
enum OutputIds {
EOR_OUTPUT,
EOF_OUTPUT,
EOC_OUTPUT,
RISING_OUTPUT,
FALLING_OUTPUT,
OUT_OUTPUT,
NUM_OUTPUTS
};
};
As you can see, it adds a tab and mess the whole code.
I am a beginner to couchDB.
I have data as below:
one:[{
"name":abc,
"value":1
},
{
"name":efg,
"value":1
},
{
"name":abc,
"value":1
},
I would like to get the count of similar keys and get the maximum.
e.g. in my case "abc" is twice. so the maximum(reduce function) should return
result: {"name":abc,value:2}
Did you try this design document:
{
"_id":"_design/company",
"views":
{
"abc_customers": {
"map": "function(doc) { if (doc.name == 'abc') emit(doc.name,doc.value) }",
"reduce" : "_count"
},
"efg_customers": {
"map": "function(doc) { if (doc.name == 'efg') emit(doc.name,doc.value) }",
"reduce" : "_count"
}
}
}
See this one for a comparison of _count and _sum. Possibly you need _count.
By the above CouchDB design document, you will get count for each doc.name of abc, efg, ... and then you can do a search for max/min of counts.
I have 3 variantMaps created from JSON and I would like to substitute
for example all 3 things from 3d with 2nd and than second to first to the properties.
QVariantMap wholeMapToChange; //1.
QVariantMap propertiesMapToChange; //2.
QVariantMap cmdMap; //3.
1st contain this JSON data but in map:
{
properties {
"A": true,
"B": true,
"fieldName": "ewfqfqewf",
"C": false,
"fieldPassword": "451541611",
"isBtnSignOnClicked": true
},
type: "xyz"
}
2nd contain this JSON data but in map:
{
"A": true,
"B": true,
"fieldName": "ewfqfqewf",
"C": false,
"fieldPassword": "451541611",
"isBtnSignOnClicked": true
}
3d contain this JSON data but in map:
{
"fieldName": "nick",
"fieldPassword": "0000",
"isBtnSignOnClicked": true
}
What I see as a possibility for substituing 3 with 2 is to create cycle
for (QVariantMap::const_iterator it = propertiesMapToChange.begin(); it != propertiesMapToChange.end(); ++it){
for (QVariantMap::const_iterator itt = cmdMap.begin(); itt != cmdMap.end(); ++itt){
///here would be the comparig...
}
}
But I dont think this is good solution... I would like to ask you for advice or opinion, whether its correct, or there exist better way to do that.
Thx
It is the right solution if the maps aren't too big, since the cost is N*M. But it is a premature pessimization. You should implement the loop to have N+M cost: after all, the maps are sorted, so you only need to iterate each map once.
A complete example:
// https://github.com/KubaO/stackoverflown/tree/master/questions/json-map-iter-39979440
#include <QtCore>
QVariantMap replaceMap(QVariantMap dst, const QVariantMap & src) {
auto dit = dst.begin();
auto sit = src.begin();
while (dit != dst.end() && sit != src.end()) {
if (sit.key() < dit.key()) {
++ sit;
continue;
}
if (dit.key() < sit.key()) {
++ dit;
continue;
}
Q_ASSERT(sit.key() == dit.key());
dit.value() = sit.value();
++ sit;
++ dit;
}
return dst;
}
int main() {
auto json1 = QJsonDocument::fromJson({R"ZZ({
"properties":{
"A":true,
"B":true,
"fieldName":"ewfqfqewf",
"C":false,
"fieldPassword":"451541611",
"isBtnSignOnClicked":true
},
"type":"xyz"
})ZZ"}).toVariant().value<QVariantMap>();
auto json2 = QJsonDocument::fromJson({R"ZZ({
"A":true,
"B":true,
"fieldName":"ewfqfqewf",
"C":false,
"fieldPassword":"451541611",
"isBtnSignOnClicked":true
})ZZ"}).toVariant().value<QVariantMap>();
auto json3 = QJsonDocument::fromJson(
{R"ZZ({
"fieldName":"nick",
"fieldPassword":"0000",
"isBtnSignOnClicked":true
})ZZ"}).toVariant().value<QVariantMap>();
json2 = replaceMap(json2, json3);
auto props = replaceMap(json1["properties"].value<QVariantMap>(), json2);
json1["properties"] = props;
qDebug() << QJsonDocument::fromVariant(json1).toJson().constData();
}
Output:
{
"properties": {
"A": true,
"B": true,
"C": false,
"fieldName": "nick",
"fieldPassword": "0000",
"isBtnSignOnClicked": true
},
"type": "xyz"
}
Having a bit of a headache with a scraping scenario I'm trying in Google Sheets.
In a nutshell, we want to use Google Sheets with ImportXML to create scraped feed from clients' websites pulling product details.
Here is a link to the smaller version of the doc. https://docs.google.com/a/sprt.co.za/spreadsheets/d/1dSbglYniWa_cijb6yDty576j33CTk9Cf8J38a3VXHSU/edit?usp=sharing
Currently this specific client only has the Item Price, etc details in a text area in the code. So when I use =ImportXml($C$2, "//textarea") it gives me the entire text area across two cells. From these cells, actually only the second one I need to pull out details but I am pretty stuck on the Regex on a piece if data this big.
" { ""id"": ""061013AACI9"", ""productId"": ""061013AACI9"", ""name"": ""VANS MEN'S
PERFORATED LEATHER ERA"", ""price"": ""R 799.00"", ""oldPrice"": """", ""brand"":
""Vans"", ""brandURL"": ""/plp/vans/_/N-1z140je"", ""defaultImages"": [ ],
""images"": [ { ""thumb"":
""http://tfgsrv.wigroup.co/06/Thumbnail/31460739.jpg"", ""large"":
""http://tfgsrv.wigroup.co/06/Detail/31460739.jpg"" } , { ""thumb"":
""http://tfgsrv.wigroup.co/06/ThumbnailAlternative/31460739_01.jpg"",
""large"": ""http://tfgsrv.wigroup.co/06/DetailAlternative/31460739_01.jpg"" }
, { ""thumb"":
""http://tfgsrv.wigroup.co/06/ThumbnailAlternative/31460739_02.jpg"",
""large"": ""http://tfgsrv.wigroup.co/06/DetailAlternative/31460739_02.jpg"" }
, { ""thumb"":
""http://tfgsrv.wigroup.co/06/ThumbnailAlternative/31460739_03.jpg"",
""large"": ""http://tfgsrv.wigroup.co/06/DetailAlternative/31460739_03.jpg"" }
], ""transientProfile"": ""true"", ""wishListId"": ""anonymous"", ""colors"": [ {
""id"": ""31460739"", ""name"": ""White"", ""path"":
""http://tfgsrv.wigroup.co/06/ColourSwatch/31460739_SW.jpg"", ""activeColor"" :
true, ""available"" : true } ], ""sizes"": [ { ""id"": ""31460740_06"", ""name"":
""6"", ""available"": false } , { ""id"": ""31460741_06"", ""name"": ""7"",
""available"": true } , { ""id"": ""31460742_06"", ""name"": ""8"", ""available"": true
} , { ""id"": ""31460743_06"", ""name"": ""9"", ""available"": false } , { ""id"":
""31460744_06"", ""name"": ""10"", ""available"": true } , { ""id"": ""31460745_06"",
""name"": ""11"", ""available"": false } ], ""productType"" : ""ColourSize"" } "
I need to pull out the R 799.00 value from that mess. So if anyone is willing to help out. Because frankly my talent and skill has run it's course in trying to navigate that with RegEx.
Try this:
""price"":\s""([^"]+)""
Demo
Output:
MATCH 1
1. [124-132] `R 799.00`
How to execute aggregation framework task on secondary node using c++ driver?
Here`s an example that always executes on primary node:
DBClientConnection c;
bo res;
vector<bo> pipeline;
pipeline.push_back( BSON( "$match" << BSON( "firstName" << "Stephen" ) ) );
c.connect( "localhost:12345" );
c.runCommand( "test", BSON( "aggregate" << "people" << "pipeline" << pipeline ), res );
cout << res.toString() << endl;
I need to execute it on secondary.
While I haven't worked with the C++ driver for MongoDB, running aggregations on secondary is easily possible by simply setting the read preference to secondary. For e.g. on the shell:
mongo -u admin -p <pwd> --authenticationDatabase admin --host
RS-repl0-0/server-1.servers.example.com:27017,server-2.servers.example.com:27017
RS-repl0-0:PRIMARY> use test
switched to db test
RS-repl0-0:PRIMARY> db.setSlaveOk() // Ok to run commands on a slave
RS-repl0-0:PRIMARY> db.getMongo().setReadPref('secondary') // Set read pref
RS-repl0-0:PRIMARY> db.getMongo().getReadPrefMode()
secondary
RS-repl0-0:PRIMARY> db.zips.aggregate( [
... { $group: { _id: "$state", totalPop: { $sum: "$pop" } } },
... { $match: { totalPop: { $gte: 10*1000*1000 } } }
... ] )
{ "_id" : "CA", "totalPop" : 29754890 }
{ "_id" : "FL", "totalPop" : 12686644 }
...
One can verify from the MongoDB logs that this indeed ran on the secondary:
...
2016-12-05T06:20:14.783+0000 I COMMAND [conn200] command test.zips command: aggregate { aggregate: "zips", pipeline: [ { $group: { _id: "$state", totalPop: { $sum: "$pop" } } }, {
$match: { totalPop: { $gte: 10000000.0 } } } ], cursor: {} } keyUpdates:0 writeConflicts:0 numYields:229 reslen:338 locks:{ Global: { acquireCount: { r: 466 } }, Database: { acquire
Count: { r: 233 } }, Collection: { acquireCount: { r: 233 } } } protocol:op_command 49ms
...
Note that this is applicable on secondaries of a sharded MongoDB cluster as well.