Qooxdoo - ignore a global variable from the config.json file - qooxdoo

Can you ignore a global variable such as OpenLayers from the config.json file?
I've been having to do this at the top of every class file:
/**
* #ignore(OpenLayers)
*/
I also tried this:
"lint" :
{
"lint-check" :
{
"allowed-globals" :
[
"OpenLayers"
]
}
},
but that doesn't seem to do the trick. Thanks!

It really depends which Generator job you are running. Your second approach, adding OpenLayers to the config's lint/lint-check/allowed-globals should well serve you when running generate.py lint.
But in order to make it also relevant for compile jobs (source*, build), you need to inject the lint-check key also to their configuration. Just fork this key out into a dedicated job definition, and then include it in the "worker" jobs, e.g. like this:
"my-lint-options" : {
"lint-check" : {
"allowed-globals" : [
"OpenLayers"
]
}
},
"lint" : {
"extend" : ["my-lint-options"],
},
"source-script" : {
"extend" : ["my-lint-options"],
},
"source-all-script" : {
"extend" : ["my-lint-options"],
},
"build-script" : {
"extend" : ["my-lint-options"],
}
Now all relevant jobs should honor the setting to ignore the OpenLayers global.

Related

How do I declare a dependency that can be fulfilled by one of many differently named packages?

In a Raku distribution how do I depend on either Foo::Bar or Foo::Baz without requiring both?
You can use "any": [$dependency-spec1, $dependency-spec2]. This could look like one of the following (depending on if you use a plain string dependency or a hash):
"depends" : {
"runtime" : {
"any" : [
"Foo::Bar",
"Foo::Baz"
]
}
}
"depends" : {
"runtime" : {
"any" : [
{
"name" : "Foo::Bar"
},
{
"name" : "Foo::Baz"
}
]
}
}
This isn't constrained to raku dependencies either. For instance to declare a dependency on either curl or wget one can do:
"depends" : {
"runtime" : {
"any" : [
"curl:from<bin>",
"wget:from<bin>"
]
}
}
which would cause zef install $whatever to inform the user of the missing programs if none are found.

Solr: Atomic updates not consistently working

I've been using Atomic updates to Solr documents as a means of avoiding completely rebuilding the records when something changes, but it doesn't seem to be consistently working. For example, I POST something like the following on /solr/myCollection/update:
{ "add": {
"overwrite" : true,
"doc" : {
"subscriptions" : {
"remove" : [
"aliases/nBro7MgwqMeMHFm2Z1sSYzVqL21DxJtR"
]
},
"id" : "messages/NbRkzeqngmLF2D32WdjDmaYzNqMh2VkG"
}
}, "add": {
"overwrite" : true,
"doc" : {
"subscriptions" : {
"remove" : [
"aliases/nBro7MgwqMeMHFm2Z1sSYzVqL21DxJtR"
]
},
"id" : "messages/S6AZ602Vz4EAgdcqCZSnkXGEcDKC2puL"
}
}, "add": {
"overwrite" : true,
"doc" : {
"subscriptions" : {
"remove" : [
"aliases/nBro7MgwqMeMHFm2Z1sSYzVqL21DxJtR"
]
},
"id" : "messages/OeyOtZApaJglZ3XgU7uq2o49S7GydCzw"
}
}, "commit": {
}}
(snippet shortened for StackOverflow, can be hundreds per batch)
I expect it will remove the supplied aliases from the subscriptions field, but it's not:
{
"id":"messages/NbRkzeqngmLF2D32WdjDmaYzNqMh2VkG",
"streamId":"streams/0jbNwQd5g2tqN1vpRRifYGhH97Fz62le",
"streamLabel":"Welcome Center",
"sourceId":"sources/DTibywwJ1ZNIm4JXzc8F5gXA5phmcinH",
"sourceLabel":"general",
"creator":"aliases/nBro7MgwqMeMHFm2Z1sSYzVqL21DxJtR",
"creatorUsername":"mhicks",
"creatorName":"Matt Hicks",
"subscriptions":["groups/public",
"aliases/9Nu0zc3eS7bCnhwP7Bw2WVYkDILC4MZE",
"aliases/0hN67LeVaeWKniYUv9jT4YPmqottCqRZ",
"aliases/dugX1k8JQ2RrEiVuxfKV8qBftL3dRtEd",
"aliases/4Ulkxjdjc3uFBc2828L7JDNQkjiC84vv",
"aliases/DbByXFl2NCcoKThSA4yGv8pKBM1dWhFp",
"aliases/JCDTqlyJuFSjBe0tkng1mzet6pL4F55F",
"aliases/ZWAQCMYoycEHgZgkAJ6bxo4v8yX87jYJ",
"aliases/CDCZDosfX4R3DAq0JJNZA40Q0xHiCRVu",
"aliases/2ziDmuiVkGNGvE0njc4SwWraRJNJRVHb",
"aliases/1xNazeGAv20I9MIbeSXwzwVQCTlOh2zZ",
"aliases/CRcvnOA1fJJzFms4QqyPJcVAvAqmOKLb",
"aliases/qFe3qWuasRiPAA41y5MK4ub1HbgSihb1",
"aliases/LlKfoB815ztAhW1DH6XtZEXZ9Un3l48u",
"aliases/OZhEhBH93wsXINety2w0xFg4hnwQl4yI",
"aliases/nBro7MgwqMeMHFm2Z1sSYzVqL21DxJtR",
"aliases/q8blp7SopFFE7OKhvhOsU1h7abXQPVpx",
"aliases/UAR27PGeXUzfhcRgNBWwQGHzkc7Lg0MQ",
"aliases/9kHPOtdiausgfitQeiO2NfeuaTesXqE5",
"aliases/8jryJ5wn6WTBWfYCVQcKelgiCwAfjVBZ",
"aliases/5yz9Br4m4ODSx2ydklJN5xKF7zMCosOh",
"aliases/NLjQvsm2hzLcyWSs67FsvYcylCOjhZSj",
"aliases/rItMpsP5jNnFXAHj33ybe0ZJ8aVe1AYk",
"aliases/lsCmZCkm2GJ8IeqwLCOrZTKQcsc7pf1a",
"aliases/9BgLlfn3DYmMtYU4B7VIyo54p7xPbOv9",
"aliases/ChNDsmWrgsDPs0XjuDEbt036EKryZoSi",
"aliases/WuFOXLN5bPRzanWlWADjIiO1RrIeJ5GO",
"aliases/KBs2oB9GBzHvRc24eH7u55o7JxpZqPz9",
"aliases/zY7Je82JF12ZtF0otSjcPwItVgZqZB9g",
"aliases/ncDj6orc8c7Uhjuohuy2HcvaP1D07Yx5",
"aliases/vfSQiOMUhmKsLZN97HHaZQnsjY9KAIuK",
"aliases/nBro7MgwqMeMHFm2Z1sSYzVqL21DxJtR",
"aliases/nBro7MgwqMeMHFm2Z1sSYzVqL21DxJtR",
"aliases/nBro7MgwqMeMHFm2Z1sSYzVqL21DxJtR",
"aliases/nBro7MgwqMeMHFm2Z1sSYzVqL21DxJtR",
"aliases/nBro7MgwqMeMHFm2Z1sSYzVqL21DxJtR"],
"created":1565453073618,
"modified":1565453073618,
"_version_":1642305728917012480}
Even worse, I'm using add-distinct when I add the aliases, but as you can see from the snippet above, it's adding a new entry each time.
The call returns successfully without errors, but it's obviously not doing what I'm expecting. It seems to work some of the time though and I can't seem to determine rhyme or reason for why. To be clear, it's consistently not working for this specific scenario.
I'm not sure if it makes a difference, but I'm running SolrCloud on this dev instance on 8.0.0.

How can I specify the shape of the state in a React/Redux application?

The thing that has puzzled me the most ever since I started reading about SPAs is how to handle the application state.
Although I have found in Redux most of the answers I was looking for there's still a couple of things that I'm not sure how to handle.
One of those things is how to specify the shape of the "entities" I want to use in my app. In other frameworks I've used in the past I've seen an extensive use of ES2015 classes for this purpose, but in React/Redux applications object literals are by far,the preferred way to express the application state.
Last night I was reading about normalizing data in the redux docs, and although it gave me great ideas about how to deal with deeply nested objects, it left me with the feeling that there was something missing and that thing is how to specify in a single spot and as clear as possible what the structure/shape of the state of the application is.
Take the sample data used in the article mentioned above:
{
posts : {
byId : {
"post1" : {
id : "post1",
author : "user1",
body : "......",
comments : ["comment1", "comment2"]
},
"post2" : {
id : "post2",
author : "user2",
body : "......",
comments : ["comment3", "comment4", "comment5"]
}
}
allIds : ["post1", "post2"]
},
comments : {
byId : {
"comment1" : {
id : "comment1",
author : "user2",
comment : ".....",
},
"comment2" : {
id : "comment2",
author : "user3",
comment : ".....",
},
"comment3" : {
id : "comment3",
author : "user3",
comment : ".....",
},
"comment4" : {
id : "comment4",
author : "user1",
comment : ".....",
},
"comment5" : {
id : "comment5",
author : "user3",
comment : ".....",
},
},
allIds : ["comment1", "comment2", "comment3", "commment4", "comment5"]
},
users : {
byId : {
"user1" : {
username : "user1",
name : "User 1",
}
"user2" : {
username : "user2",
name : "User 2",
}
"user3" : {
username : "user3",
name : "User 3",
}
},
allIds : ["user1", "user2", "user3"]
}
}
How would you express the shape of this data? Just like this?
{
posts : {
},
comments : {
},
users : {
}
}
Or perhaps:
{
posts : {
byId : {
}
allIds : []
},
comments : {
byId : {
}
allIds : []
},
users : {
byId : {
}
allIds : []
}
}
Well, that tells me nothing about the actual shape of the objects that live inside each of the byId objects and that's exactly what has been bothering me since I started studying a little bit of Redux.
So the question is, is there any way/common practice that would let me express in the clearest possible way, the shape, specifically each of the properties of the objects that make up the state that the store is going to manage?
As author of that "Structuring Reducers" docs section, that's because the actual content of your data items is entirely dependent on you and your application. This is really more of a generic Javascript "how do I express types?" question. There's static type systems like TypeScript and Flow; documentation-based approaches like JSDoc; runtime approaches like the React PropTypes library or tcomb; and schema-based approaches like JSON-Schema. Any of those approaches are valid ways to document and enforce data type definitions within an application.
Normalization is simply an approach for organizing those values, regardless of how you've chosen to define what their contents are.
Assuming you're using plain JS, the simplest way is to use propTypes.shape.
// An object taking on a particular shape
optionalObjectWithShape: PropTypes.shape({
color: PropTypes.string,
fontSize: PropTypes.number
}),
If you're using propTypes, I suggest declaring the shape of all objects in this manner.
Benefits:
Your object shapes are explicit.
You're alerted quickly when unexpected object shapes are passed around.
You get enhanced autocompletion support in modern editors like Webstorm.
Since the object shape is just an object, you can centralize the declaration to avoid repeating yourself.
You don't need to move to TypeScript, Flow, etc. to have explicit types and basic type safety at runtime.
The nice thing of Redux is that you have a very clear separation of concerns of the state. Every reducer is responsible of its own part of the state and if you end up to extend a reducer by adding more data/logic, you just need to breakdown that reducer in smaller reducers.
Generally, I would avoid the use of arrays inside big collections of data inside a reducer. Arrays are cool and gives you lot of nice functionalities (sorting, filtering, reducing, etc.) but looping through them is expensive. If you can, use objects and use an ID to identify your object, in this way you access to the object using the fastest way possible.
Using your example, I would use the first approach:
{
posts: {
1554: {},
1557: {}
},
comments: {},
users: {},
}
In case you need to keep track of the list objects the array, you just creates two new reducers inside your posts reducer:
// postsReducer.js
import byId from 'postsByIdReducer'
import allIds from 'allIdsReducer'
export default combineReducers({
byId,
allIds
})
So your state will be like
{
posts: {
byIds: {},
allIds: []
}
}

How get time on timecurrent on node of Firebase using Angular?

I want to show only the time on the view, when use $firebaseArray I get the list of items and i want to get only the time.
Firebase tree
{
"eventmodel" : {
"-KX6kDkufxLg-fLocsN7" : {
"info" : "ok",
"limit" : 2,
"timeCurrentStart" : "29/11/2016 17:38",
},
"-KXBB-R7xAPl65xhlTpg" : {
"info" : "ok",
"limit" : 2,
"timeCurrentStart" : "29/11/2016 17:38",
}
}
}
The Firebase client always retrieves complete nodes. There is no way to get only the timeCurrentStart property of each node.
So either you'll have to store the timeCurrentStart properties in a separate node:
{
"eventmodeltimes" : {
"-KX6kDkufxLg-fLocsN7" : "29/11/2016 17:38",
"-KXBB-R7xAPl65xhlTpg" : "29/11/2016 17:38"
}
}
Or you'll have to retrieve the entire nodes and only show timeCurrentStart:
<span>{{event.timeCurrentStart}}</span>

Elasticsearch : Set the number of the elements of an array in a field

I'm trying to store the number of elements of an array into a field with an update. (updating the record with the count of the array).
Like for example
{
array = [ { "a" : "b" }, { "c" : "d" } ]
nb_elements = 2
}
I have tried an update with the following script
{
"script" : "ctx._source.nb_elements= ctx._source.array.values.length"
}
But it don't work.
I also tried :
{
"script" : "ctx._source.nb_elements = count",
"params" : {
"count" : ctx._source.array.values.length
}
}
But i wasn't more successfull.
Does anybody know if this is possible and if, how to do it ?
First of all you need to enable dynamic scripting by adding script.disable_dynamic: false to your config file.
Secondly, I'm supposing that you are using groovy (It's the default scripting language from 1.4).
Using the update api with this script should work:
{
"script": "ctx._source.nb_elements=ctx._source.array.size"
}

Resources