Watching for messages being deleted (and created to some extent) via the Gmail API - gmail-api

Is it possible to do this without storing state? I see that it's possible to watch for all labels except DRAFT, but when you fetch the history, it's impossible to filter by more than a label (at least according to the documentation: https://developers.google.com/gmail/api/v1/reference/users/history/list).
Backstory: when you type something in a message, upon draft saving you get a spam of messageAdded and messageDeleted for the draft. The first one is okay, since you can almost safely assume that if it's not there when you try to fetch it, it's a draft, if you're fast enough. For the latter, it's impossible to figure out if the message was a draft or not without storing that in advance.

Gmail API now returns the (full set of) labelIds as part of the messageAdded and messageDeleted in the history.list() response:
https://developers.google.com/gmail/api/release-notes#2015-06-22
So at least you can use that to ignore DRAFTs from the reply.

Related

How can I identify an untranslatable value exists in FormRecognizer analysis

I posted the following Feature Request to the azure-sdk, but not sure if that was the correct place for getting a response, so reposting here.
https://github.com/Azure/azure-sdk-for-net/issues/20764
When processing a document against a custom trained model, when a value is present but not able to be translated (such as a signature), would it be possible to include something in the response to identify it as having a value though it wasn't able to be processed?
The specific use case is that our client needs to know that a document was signed by the parties involved. Without this feature, someone will be required to manually review thousands of document images per week to verify that they have been signed. In testing we have found that very few signatures are being translated any way, so the string response is coming back as null.
Thank you,
Rich
For Form Recognizer when a value is not detected although it is present it will be extracted as Null as Form Recognizer is not aware that a value exists it did not detect it. In case of signature this is usually due to the signature being unreadable and just a scribble.

Amazon Alexa: slot types

Can any one tell me the slot type of the intent which can have long sentences in the English(India) Language? In English(US) I use AMAZON.StreetAddress for this purpose. Thanks.
Consider using a custom slot type. According to Amazon, use of the Amazon.LITERAL type is discouraged, and a custom slot type is recommended instead. Usually for custom slot types, you specify a set of sample values. However, based on your use case, it sounds like you want a match that is as close as possible to just catching all possible inputs, which is Scenario #3 from this Amazon Alexa blog article. As the article's content for the "Catch All" scenario mentions:
If you use the same training data that you would have used for
LITERAL, you’ll get the same results.
IMO, of special importance is the last paragraph regarding Scenario #3.
If you’re still not getting the results, trying setting the CatchAll
values to around twenty 2 to 8 word random phrases (from a random word
generator – be really random). When the user says something that
matches your other utterances, those intents will still be sent. When
it doesn’t match any of those, it will fall to the CatchAll slot. If
you go this route, you’re going to lose accuracy because you’re not
taking full advantage of Alexa’s NLP so you’ll need to test heavily.
Hope that helps.

REST optimistic-locking and multiple PUTs

Far as I understand, PUT request is not supposed to return any content.
Consider the client wants to run this pseudo code:
x = resource.get({id: 1});
x.field1 = "some update";
resource.put(x);
x.field2 = "another update";
resource.put(x);
(Imagine I have an input control and a button "Save", this allows me to change a part of object "x" shown in an input control, then on button click PUT changes to server, then continue editing and maybe "save" another change to "x")
Following different proposals on how to implement optimistic locking in REST APIs, the above code MUST fail, because version mark (however implemented) for "x" as returned by get() will become stale after put().
Then how do you people usually make it work?
Or do you just re-GET objects after every PUT?
You can use "conditional" actions with HTTP, for example the If-Match header described here:
https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.24
In short: You deliver an ETag with the GET request, and supply this ETag back to the server in the If-Match header. The server will respond with a failure if the resource you are trying to PUT has another ETag. You can also use simple timestamps with the If-Unmodified-Since header.
Of course you will have to make your server code understand conditional requests.
For multiple steps, the PUT can indeed return the new representation, it can therefore include the new ETag or timestamp too. Even if the server does not return the new representation for a PUT, you could still use the timestamp from the response with an If-Unmodified-Since conditional PUT.
Here is probably what I was looking for: https://www.rfc-editor.org/rfc/rfc7231#section-4.3.4
They implicitly say that we CAN return ETag from PUT. Though only in the case server applied the changes as they were given, without any corrections.
However this raises yet another question. In real world app PUT caller will run asynchronously in JS gui, like in my example in the question. So, Save button might be pressed several times with or without entering any changes. If we don't use optimistic locking, then supposed PUT idempotency makes it safe to send another PUT query with each button click, as long as the last one wins (but actually if there were changes then it's not guaranteed, so the question remains).
But with optimistic locking, when first PUT succeeds, it returns updatred ETag, ok? And if there is another PUT request running, still with outdated tag version, that latter request will get 412 and the user will see a message "someone else changed the resource" - but actually it was our former changes.
What do you usually do to prevent that? Disable the Save button until its request is fully completed? What if it times out? Or do you think it's acceptable to see concurrent-change error message if it was a timeout, because the stability is already compromised anyway?

Message format in Channel API (GAE)?

I'm working on a HTML5 collaborative canvas drawing tool on GAE. Essentially people draw, send their coordinates and their motion to GAE through channel API and then other people receive the updates.
As required by the GAE documentation, I have a function in my javascript code to collect messages received from the server:
socket.onmessage= function (message) {
var s=message.data;
//Extract X,Y,motion out of s and Draw(x,y,motion)
};
However, the message data I'm sending are actually x and y coordinates and a string of either ("start"/"drag") in the form of:
x=505.0000457763672&y=111.66667175292969&type=start
I actually have no idea about any of the variables or features in this 'message' class and I wouldn't know to use 'message.data' if I didn't see it in someone else's source code - is this actually documented anywhere? I'd like to be able to use the substring features to effectively extract the 3 values but they don't seem to work with message.data.
Any idea if there are detailed documentations on the full member functions/classes/variables documentation on the message class?
Any input is much appreciated!
I wouldn't say it's documented WELL, but it is documented in the channels API docs:
https://developers.google.com/appengine/docs/python/channel/javascript
It specifically does say the message object has a parameter called 'data'.
You should be able to use javascript substring features just fine, but unless you show your code, no one will be able to help you with that.

Creating futures using Apple's GCD

I'm working on a library which implements the actor model on top of Grand Central Dispatch (specifically the C level API libdispatch). Basically a brief overview of my system is as such:
Communication happens between actors using messages
Multicast communication only (one actor to many actors)
Senders and receivers are decoupled from one another using a blackboard where messages are pushed to.
Messages are sent in the default queue asynchronously using dispatch_group_async() once a message gets pushed onto the blackboard.
I'm trying to implement futures in the language right now, so I've created a new type which holds some information:
A group of its own
The value being 'returned'
However, I have a problem since dispatch_block_t is of type void (^)(void) so it doesn't return anything. So my idea of in my future_new() function of setting up another group which can be used to execute a block returning a result, which I can store in my "value" member in my future_t structure, isn't going to work.
The rest of the futures implementation is very clear, except it all depends on being able to get the value into the future back from the actor, acting on the message.
When using the library, it would greatly reduce its usefulness if I had to ask users (and myself) to be aware when futures were going to be used by other parts of the system—It just isn't practical.
I'm wondering if anyone can think of a way around this?
Actually had Mike Ash's implementation pointed out to me, and as soon as I saw his initWithBlock: on MAFuture, I realized what I needed to do. Very much akin to what's done there, so I'll save the long winded response about how I'm doing it.

Resources