EKAlarms with relativeOffset - ios

I'm currently trying to write a method to compare EKAlarms to one another. The problem with this is between absoluteDate and relativeOffset. Comparing two alarms each with an absoluteDate is easy, but if one or both have a relativeOffset, you need to know what event they're relatively offset from. As per the documentation,
relativeOffset: The offset from the start of an event, at which the alarm fires.
Yet, I see no documentation on setting the trigger for a relativeOffset alarm. Can anyone help me figure out what I'm missing? How can I compare two EKAlarms with relativeOffsets?
Thanks for the help!

As you rightly say:
if one or both have a relativeOffset, you need to know what event they're relatively offset from
Quite so. But how can you possibly not know that? EKAlarms do not float around loose, falling from the sky like snowflakes. If not attached to an EKCalendarItem, a relative EKAlarm is meaningless; there is nothing to compare. If it is attached to an EKCalendarItem, then you clearly know that fact - otherwise, where would you have gotten the alarm from??? Either you just created the alarm, and are about to attach it to an EKCalendarItem yourself, or you have started with the EKCalendarItem and have looked at its alarms property, in which case you also know the EKCalendarItem's startDate and can calculate from there.

Related

Playwright: how to wait until there is no animation on the page?

I'm trying to figure out how to check whether the page has fully loaded in Playwright. await page.waitForLoadState('networkidle'); doesn't always work for me on Javascript-heavy sites. I've resorted to taking a screenshot base64, waiting 100 ms, taking a new screenshot, and comparing whether those are the same. However this doesn't seem ideal, is there any way to ask Playwright when the last animation frame was redrawn?
There are several options that may help you.
1. Solution 1:
First, you can maybe determine which element is loading last, and then go with
page.waitForSelector('yourselector')
or even wait for multiple selectors to appear
page.waitForSelector('yourselector1','yourselector2')
2. Solution 2
page.waitForLoadState('domcontentloaded')
Because
page.waitForLoadState('networkidle')
by default will wait for network event and if 0.5 seconds nothing is network trafficking it will say, I am no longer need to wait. And that is why you maybe have stohastic beh.
If the given solution doesn't work for you, you can try with locator.
page.locator(selector[, options])
It has multiple api like locator.isDisabled or locator.waitFor([options]) or locator.isVisible([options]) or locator.frameLocator(selector) ....... a lot more.
see the below link here:
https://playwright.dev/docs/api/class-locator

Get duration of video with AVFoundation

To get the duration of an AVPlayerItem I could do: player.currentItem.duration.
Instead of this, I could also get the duration from my backend as an Int. Then I can convert this to a Float to be used anywhere I need the duration for. I think this might be better in terms of performance and less work on my end to get the duration.
For example Apple says this about getting duration:
“A vital concept in AV Foundation is that initializing an asset or a
track does not necessarily mean that it is ready for use. It may
require some time to calculate even the duration of an item (an MP3
file, for example, may not contain summary information). Rather than
blocking the current thread while a value is being calculated, you ask
for values and get an answer back asynchronously through a callback
that you define using a block.”
Any thoughts on things that could go wrong if I decide to hardcode the duration by getting it from the server? Is this good practice?
If you already know the value on your backend, and you're already making call to say get the video URL, retrieving the duration seems a reasonable idea.
Although - is there any chance of a mismatch? If you do it client side it's "guaranteed" to be correct.
If you have to make a special call to get it, I wouldn't as it's likely to take much longer than determining it during asset initialisation.

WF DelayActivity fires immediately?

I have a Workflow I have created and deployed to a Sharepoint 2007 farm. When it runs against an item two delay activities I have created fire immediately.
I have setup a callback on the InitializeTimeoutDuration event. Through logs and debug output I can see that it is setting the delay to one hour. However, at the next SP timer job cycle (less than 5 minutes) the events proceeding the Delay activity fire off.
I'm lost here. Any help is greatly appreciated.
Update
Through some digging I was able to determine why this was firing off. Once the workflow started a record gets added to the ScheduledWorkItems table in the SP Content database. However, the "DeliveryDate" on the record is set to the current time while the "Created" date is set to one hour previous. However, the delay I'm using is 2 hours, so neither of these times make sense to me at all. Going to try hardcoding it....
Update 2
Even with a hardcoded duration the times are off. I hardcoded a 2 hour delay in and the "DeliveryDate" is now one hour in the future while the "Created" date is one hour in the past. So at least the difference between them is good.
Update
Well, that's embarrassing... found the problem. I'm posting it in here for others that may make mistakes like I do. First off, I was not correct in my UTC->local conversion. The times on the database were correct. What was not correct was how I was setting the TimeoutDuration:
// WRONG!
delayActivity.TimeoutDuration = new TimeSpan("1:00:00"); // one hour
what I should have been doing:
// RIGHT!
((DelayActivity)sender).TimeoutDuration = new TimeSpan("1:00:00"); // one hour
once I made that change everything else seems to be fine.
Well, that's embarassing... found the problem. I'm posting it in here for others that may make mistakes like I do. First off, I was not correct in my UTC->local conversion. The times on the database were correct. What was not correct was how I was setting the TimeoutDuration:
// WRONG!
delayActivity.TimeoutDuration = new TimeSpan("1:00:00"); // one hour
what I should have been doing:
// RIGHT!
((DelayActivity)sender).TimeoutDuration = new TimeSpan("1:00:00"); // one hour
once I made that change everything else seems to be fine.

JavaMail: how to get new messages comparing with time-stamps

I'm trying to get messages after a certain time-stamp, the way I've coded it was suggested by another programmer in this site:
GregorianCalendar date = new GregorianCalendar();
SearchTerm newer = new ReceivedDateTerm(ComparisonTerm.GT,date.getTime());
Message msgs[] = folder.search(newerThen);
The issue is that I get all the messages since the date, not the specific time. I was wondering if there is some work-around to emulate this. I mean, for an instance, if I want to get all the messages since today in the midday I would get those messages spicifically and not those ones received in today's morning.
Thanks in advance,
EDIT:
A new thought concerning to this: perhaps some date manipulation could do the job. I mean, comparing the minutes in the timestamp and filter programmatically those messages that don't fit the criteria. I know it's not the best way, but it could work.
PS: I'm using IMAP and trying to get mails from gmail, but I guess it should work no matter what the mail-server is.
Unfortunately, no. In this case, the IMAP protocol is being used by the JavaMail classes, and IMAP's SEARCH command takes only dates, not times (see the SINCE and SENTSINCE criteria).
You could use the setTime() method to query for some specific time.
Example:
setTime(timeInMilliseconds)

RxSwift: Receive events immediately, unless the last event was processed within a certain interval

New to RxSwift / Reactivex. Basically what I'm trying to do is to make a server call whenever something happens, but make sure it's not done more often than every 10 seconds. Less often if possible.
For instance, whenever an event ("needs update") is generated I'd like to call the server immediately if more than 10 seconds have passed since my last call. If less time has passed I'd like to make the call on the 10 second mark from the last one. It doesn't matter how many events have been generated within these 10 seconds.
I looked at the description of throttle but it appears to starve if events happen very quickly, which isn't desirable.
How can I achieve this?
There's a proposed new operator for RxSwiftExt that would give you something you're looking for, I think. However, it doesn't exist yet. You might want to keep an eye on it, though.
https://github.com/RxSwiftCommunity/RxSwiftExt/issues/10

Resources