After effects Script - Documentations for passing a regexp text into the Window.add() function - after-effects

I'm learning how to make UI panel in AE and I've got this code on Youtube
var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "Dockable Script", undefined, {resizeable:true, closeButton: false});
res = "group{orientation:'column',\
groupOne: Group{orientation:'row',\
createCompButton: Button{text:'Create Comp'},\
},\
groupTwo: Panel{orientation:'row',\
deleteCompButton: Button{text:'-'},\
deleteText: StaticText{text:'Delete Active Comp'},\
},\
groupThree: Group{orientation:'row',\
closeButton: Button{text:'Close'},\
},\
}";
myPane.grp = myPanel.add(res);
But I coudn't find any documentations about this type of wrapping every thing into a regexp text. All I found were just like this:
myPanel.createCompButton = myPanel.add('button', [10,10, 120, 60], "Create Comp", {name: 'create'});
Is there a documentation for that kind of wrapping?

That "wrapping" of the value for res in the example code is called a "resource string" and it's like semantic markup for UIs driven by Adobe's framework.
Here is the documentation on the topic:
https://extendscript.docsforadobe.dev/user-interface-tools/resource-specifications.html?highlight=resource%20string#resource-specifications

Related

IBM Watson Alchemy news iOS SDK Swift

The IBM Watson iOS SDK using the Alchemy News service on Bluemix returns a string result which requires parsing to pull out the fields like url and cleaned title. ref: https://github.com/watson-developer-cloud/swift-sdk
I pull the string into an array and parse it in swift3 using some string methods but this is pretty ordinary and can produce unpredictable results
Is there a more elegant approach where I can access specific fields, like the url and cleaned title which I am passing to a UITableViewCell to select and segue to the url link.
sample code:
let alchemyDataNews = AlchemyDataNews(apiKey: apiKey)
let failure = { (error: Error) in print(error) }
let start = "now-14d" // 7 day ago
let end = "now" // today
let query = ["count": "15",
"dedup": "true",
"q.enriched.url.title": "[IBM]",
"return": "enriched.url.url,enriched.url.title" "enriched.url.title,enriched.url.entities.entity.text,enriched.url.entities.entity.type"]
Also I have noticed the search string [IBM] has a prefix of 0, i.e. 0[IBM] and have also seen an "A". What do these prefixes mean and where are they documented
Here is one way you can access the fields from a returned payload.
alchemyDataNews.getNews(from: "now-4d", to: "now", query: queryDict, failure: failWithError) { news in
for doc in (news.result?.docs)! {
var cleanedTitle = doc.source?.enriched?.url?.cleanedTitle
var author = doc.source?.enriched?.url?.author
var title = doc.source?.enriched?.url?.title
}}
Also, here is a nice API reference link for alchemy data which contains all of the request parameters and filters.
https://www.ibm.com/watson/developercloud/alchemydata-news/api/v1/

How can you unit test Leaflet JS maps?

How can you unit test Leaflet JS maps?
I am really struggling with the same issue. Here is a link to some testing with the js test library 'mocha':
http://blog.mathieu-leplatre.info/test-your-leaflet-applications-with-mocha.html
However, I ran into further issues trying to call leaflet's sort of catch all 'L' function. The first was this:
}(window, document));
^
ReferenceError: window is not defined
I remedied that issue with this bit of code:
// Create globals so leaflet can load
GLOBAL.window = {};
GLOBAL.document = {
documentElement: {
style: {}
},
getElementsByTagName: function() { return []; },
createElement: function() { return {}; }
};
GLOBAL.navigator = {
userAgent: 'nodejs'
};
GLOBAL.L = require('leaflet');
Node.js Leaflet error
After I dealt with that issue, I am running into a problem with the actual functions, such as 'L.map(''). It seems that the function needs an element with an id to function correctly.
Here is the error I received for that function:
return (typeof id === 'string' ? document.getElementById(id) : id);
^
TypeError: document.getElementById is not a function
I hope this helps you a little bit, I certainly still haven't figured it out.
I have been working a bit more on testing and using Leaflet.
Currently I am using QUnit to run the tests.
I currently have to open it in a browser to see if it is working, maybe someone else knows how to run QUnit via commandline.
Before I wrote and ran my tests I took a look at the Leafletjs docs page and just started exploring the different js objects with the developer tools console on google chrome.
Leaflet docs:
http://leafletjs.com/reference-1.0.0.html
Example tests from my QUnit tests.js file:
QUnit.test("map default options", function( assert ) assert.equal(myMap.getCenter().toString(),
"LatLng(0, 8.846)",
"The map is centered at the ZMT's longitude, and the equator"
);
assert.equal(myMap.getZoom(),
2,
"The default zoom is set to 2"
);
});
QUnit.test("baseLayer layerGroup", function( assert ) {
assert.equal(baseLayer.getLayers().length,
1,
"There is just one layer in 'baseLayer' layerGroup"
);
assert.equal(baseLayer.getLayers()[0]._url,
"http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
"The url of the layer leads to the correct openstreet map tiles"
);
assert.equal(baseLayer.getLayers()[0].options.attribution,
'© OpenStreetMap',
"The attribution for the layer is correct"
);
assert.equal(baseLayer.getLayers()[0].options.minZoom,
0,
"The default minimum zoom is set to 0"
);
assert.equal(baseLayer.getLayers()[0].options.maxZoom,
19,
"The default maximum zoom is set to 19"
);
});

SharePoint List CSR handler are not fired - SharePoint online

I am trying to change style of sharepoint list using CSR. I want to apply bold to title column. I have added these code in JS file and reffered as JSLink(JavaScriptDisplayTemplate) to webpart. On document ready both renderTitleHandler & preRenderHandler are registered and also preRenderHandler are called successfully. But renderTitleHandler are not fired.
Please find my code snippet,
function renderTitleHandler(ctx) {
var fieldVal = ctx.CurrentItem[ctx.CurrentFieldSchema.Name];
var title = fieldVal.toString();
var html = '';
html += '<b>' + title + '</b>';
return html;
}
function preRenderHandler(ctx) {
ctx.ListTitle = '<b>' + ctx.ListTitle + '</b>';
}
(function() {
var overrideCtx = {};
overrideCtx.Templates = {};
overrideCtx.Templates.OnPreRender = preRenderHandler;
overrideCtx.Templates.Fields = {
"Title" : {"View" : renderTitleHandler}
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
})();
Thanks in advance.
Kannan.
Possibilities:
disable Minimal Download Strategy (mds). Sometimes this blocks your
javascripts caused by the async loading in the back of certain OOTB
scripts
remove the debugger;-line (is it possible that your code works when developer tools in your browser are open?)
Edit:
Found an example on my dev environment and i have the word View between quotes:
linkFilenameFiledContext.Templates.Fields = {
"Title": { "View": renderTitleHandler}
};
Hope it helps

Meteor subscriptions using deps

I'm trying to implement a searching feature in a Meteor application that re-subscribes/publishes a collection on every search, so there is only the exact Collection necessary in the client. I'm creating a reactive variable searchString, then changing it to the text in the search box on every search, then splitting the string into tags:
// Client
var searchString = "";
var searchStringDep = new Deps.Dependency;
var getSearchString = function(){
searchStringDep.depend();
return searchString;
}
var handle = Deps.autorun(function(){
var tags = getSearchString().split(" ");
tags = _.map(tags, function(tag){
return tag.replace(/[^\w]/g, "");
}).filter(function(t){
return t.toLowerCase();
});
Meteor.subscribe('results', tags);
});
Template.library.events({
'submit form': function(ev){
ev.preventDefault();
searchString = ev.target.search.value;
searchStringDep.changed();
}
})
Then, publishing a new Collection on the server, based on the tags:
// Server
Meteor.publish('results', function(tags){
regTags = _.map(tags, function(tag) { return new RegExp(tag)});
return Samples.find({tags: {$in: regTags}})
});
So I'm trying to match on regexes, but am having a weird issue where the subscription only changes when I add another tag, but changing existing tags fails.
So if the first searchString was tag1 and the second tag1 tag2, it works fine.
But if the first is tag1 and the second is tag2, the Collection doesn't update.
Any help is appreciated...I'm a beginner to Meteor, so if there is a better way to do what I'm trying to do, all suggestions are welcome. Thanks so much
'change #search': function(){
Meteor.subscribe('sampleResults', $('#search').val()); // or if you want on submit it's the same idea
}
and publish like
Meteor.publish('sampleResults, function(text){
return Samples.find({tags: {$regex: text}});
}
A few things:
1) Meteor has a very nice way of setting up reactive variables with the ReactiveVar component. I would suggest using that rather than creating another dependency for a variable.
2) The name that you are subscribing to: results is different than what is published on the server sampleResults and that can cause issues.
3) If you are on Meteor >= 0.9.1 you should be using Tracker and not Deps. You can use Deps if you want, but the new updated API is Tracker and is probably more stable. See the changelog for more details on that.
4) You don't have to set your Deps.autorun function equal to a variable. So you can have it as:
Tracker.autorun(function() {
// Code here
});

How can i use regex in mongodb over mongolab?

My question is simple but i can not find exact solution. All articles have gor below a line of code:
collection.findOne({hello:'world_no_safe'});
Above codes does work and returns to me undefined error.But it is existed. Anyway, My exact solution is above. Please help me and teach me how to use regex by searching inside of the json api. ı want to use %mysearch data% as a regex expression. ı want to make text search which is used all sentences in json.
For example : i have a json:
[{"data":"Andreas Kollegger explains what kinds of questions you can answer with a graph database. It's not only the big sites that "},{"data":"X explains what kinds of questions you can answer with a graph database. It's not only the big sites that "}]
if i use this expression: collection.findOne({hello:'%Andreas%'});
it has to return first data. Below a real sample from my project.
var mongo = require('mongodb');
var Server = mongo.Server;
var Db = mongo.Db;
var server = new Server('ds053479.mongolab.com', 53479, {auto_reconnect : true});
var db = new Db('orient', server);
db.open(function(err, client) {
client.authenticate('testname', 'fsfsff', function(err, success) {
var collection = db.collection('Models');
collection.insert({Name:'test1'});
// Fetch the document
collection.findOne({Name:'%world_no_safe%'});
});
According to the MongoDB Manual you can use the $regex operator:
collection.findOne({Name: { $regex: '.*world_no_safe.*' }});