How do i set a watch on an object in ceph? - c

I am trying to keep a watch on an object in Ceph, but I don't know how to do it. I searched for examples online but could not find any. Found some documentation here. It says that I can use rados_watch to watch an object for changes. But I dont know how to implement it in C, especially the rados_watchcb_t part. It says rados_watchcb_t would contain the action to execute on notification. How do I declare it?
This is what I tried:
rados_watchcb_t rados_watch = printf("Updated");
But this gives an error.

Related

discord.collection is not a constructor

I'm trying to write a discord bot and am constantly getting this error whenever i try to run it.
TypeError: discord.collection is not a constructor
It's from this line of code
bot.commands = new discord.collection();
I'm not the best at JavaScript and have looked around google and can't find anything that matches my exact issue, all the ones I find have the same error but are something completely different.
whether or not this command is outdated or no longer in use I am unsure of but any help would be greatly appreciated!
It's Collection, not collection. The standard for naming classes is always first letter capitalized.

Firebase: referencing docs with a string vs. referencing docs with a ref. Is there a difference?

This is more of a general question, I've been bouncing around multiple posts on StackOverflow and reading what I've found so far in the docs. I haven't found anything super concrete yet to answer the post question which is: what are the benefits of linking documents to one another through the ref type vs. the string type?
As of now, I'm converting all my string "refs" to properly typed "refs". However, since i'm still relatively new to the platform I'm scratching my head wondering if this is even necessary. I assume I'd be just as effective at finding related docs with the string as with a reference.
Also, for the sake of future readers as of me posting this, you can set a ref like so:
db.collection(...).add({
...
reference: firebaseFirestore.doc(
`lesson_translations/${translationID}`
),
// reference is now typed as a 'ref'
})
I had found other posts on stackoverflow accessing it with .doc(...).ref which doesnt seem to be a thing anymore.
It's mostly a matter of personal preference and perceived convenience. There is not really anything a reference type can do that a string and your own code could not also do.
Having a reference type mostly saves you the trouble of building a new reference object in your code, if that's what you would have done with a string document ID anyway. You can also use it in security rules for the same purpose when it comes time to use get() to fetch another document referenced by a field.
Again, it's personal preference. Do whatever is most convenient for you.
When you call a document reference, you instantly get the document details while if you take a string path and call it, it will take some time to find that data. It is just a matter of a few milliseconds and a few lines of code. Imagine if you had a list of document references to store and you store them as strings, and then had to call all of them looping over it
I know of one tangible benefit, but it's only relevant if you are using a library for data binding that supports loading nested documents to n depth. I personally am using vuefire, but I would assume something similar exists for the react ecosystem.
It allows you to e.g. bind a collection or document to a variable, and automatically sync all the data of referenced documents.
Example
You sync a collection('users') with a depth of two, and each user document contains an array of favourites:
{
name:'John',
favourites: [ref1, ref2, ref3]
}
The library would immediately download the references and replace the original ref files with the data:
{
name:'John',
favourites: [{title:'foo'}, {title:'bar', {title: 'baz'}]
}

Sanity PatchEvent functions are not very clear on what they do

I'm using sanity and trying to figure out what exactly the set, unset, insert functions do. As well there are methods on the PatchEvent class itself and I can't seem to find any documentation on that either.
For example I can see that set in the example takes one argument. But through more research of the code set actually takes two arguments, one being the path and the other being the value. It is unclear how path works and what it exactly does.
Since I am trying to update an object in array it looks like this is something I should be doing as this is what is done in the default ArrayInput. I tried to make it work, but no errors and no updates are happening. This is what I have:
PatchEvent.from(key ? set(key, [idx, '_key']) : unset())
On top of all this I can see that there are methods directly on the PatchEvent that are also being used like prefixAll, prepend, and append. I more or less would just like some good documentation on all of this otherwise I might as well just stick with the HTTP Api and update/manage everything on my own for the custom components.

What is the use of .scope() in AngularJS?

What is the use of .scope() in AngularJS? I have seen some code examples using this but I am not quite sure what the use is, and I have been unable to find an answer in SO posts and in AngularJS documentation. For example:
var scope = angular.element(document.getElementById("MainWrap")).scope();
Is this somehow similar to use of $digest or $apply?
Here an example of what I use it for every day:
Open Console in dev tools.
Right-click an element in your page that is managed by AngularJS, select inspect element option
Now write in console: angular.element($0).scope()
You just got a scope of said element as that element sees it. You can go up through the parent, manage its content (don't forget to $apply() afterward to test the change, otherwise, it won't bind) or do similar things you can in console with any JS object.
There are more uses for it for sure internally, but this one I find really helpful when debugging. So in relation to $apply() it is and is not linked to it, depending what you use it for.

Angular $resource: update self from get

Is there any built-in method or conventionally correct approach to this? I'm not asking about issuing an update, but rather, requesting one. I could query for it again, but the goal is that the object reference stay the same.
The approach I've taken so far is to define an instance method called "refresh" that gets the same resource instance by ID and then iterates over its properties, copying them over to the original object (how I love thee _.extend). But it seems like something that might already be included functionality in ngResource and I just can't find it. If not, does Angular provide a means to make such a "refresh" method default to all $resources the same way save, delete, etc already are?
So I actually found the answer as I was writing the question, but I'm going to post it and answer anyway in case it might help someone else.
While writing that and looking stuff up, I realized that get is not restricted to being a static method of the resource. What threw me here was that on an instance, it's named $get. And lo, $get does exactly what I wanted. However it does not seem to be documented on Angular's site -- in fact the site says that only non-GET actions are instance methods, so who'd have thought? I mean, aside from that it seems totally obvious now.

Resources