intervals

Find out if a series of dates covering an interval

ぃ、小莉子 提交于 2019-12-05 20:21:12
I have two objects calendar Calendar startCalendar = new GregorianCalendar(2013,0,31); Calendar endCalendar = new GregorianCalendar(); I want to know if the interval between the two dates listed above is covered by n of other objects pair calendars without holes between intervals Example1: Calendar startCalendar1(2013,0,31); Calendar endCalendar1(2014,0,31); Calendar startCalendar2(2013,5,31); Calendar endCalendar2(); Is GOOD Example2: Calendar startCalendar1(2013,0,31); Calendar endCalendar1(2014,0,31); Calendar startCalendar2(2014,2,31); Calendar endCalendar2(); NOT GOOD I use Java 6 Thanks

Code to run macro on time interval?

寵の児 提交于 2019-12-05 20:21:00
How can I set a macro to run at a specific time and then at set intervals afterwards? I would like it to run at the top of each hour so I would like to start it at 07:00AM for example and then every hour after I want it to run again. Here is the code: Sub Refresh_All() ' ' Refresh_All Macro ' ' Keyboard Shortcut: Ctrl+Y ' ChDir "Q:\Quality Control" Workbooks.Open Filename:= _ "Q:\Quality Control\Internal Failure Log - Variable Month.xlsm" Dim endTime As Date endTime = DateAdd("s", 10, Now()) Do While Now() < endTime DoEvents Loop ActiveWorkbook.RefreshAll endTime = DateAdd("s", 10, Now()) Do

Calculating the intersection between two angle intervals

守給你的承諾、 提交于 2019-12-05 18:22:46
I'm trying to calculate the intersection between two angle intervals, as in the picture below. Unfortunately, the branch at -pi is making the code much uglier than I have hoped. Here is my first draft. Note that I have not tested this code for correctness, but rather have just gone through the scenarios in my head. As you can see in the function branchify , angle intervals are constrained such that from (p)a1 -> (p)a2 counter-clockwise, the difference is at most pi. In otherwise, the intervals are defined by the smallest difference in angle. [a1, a2] is the first interval, [pa1, pa2] the

Algorithm for merging overlapping intervals

前提是你 提交于 2019-12-05 15:57:42
I have been searching for an efficient algorithm to merge overlapping intervals on a dynamic array of intervals. For example, (start time, end time) wise, [(1, 2), (4, 8), (3, 10)] becomes [(1, 2), (3, 10)] after merging because (4, 8) and (3, 10) are overlapped. Overlapping means any part of the two intervals share the same moment. I know when a full array is given the operation can be done with a stack after sorting the intervals on start time ascending order ( reference: geeksforgeeks ). But this algorithm is effectively applicable only when given array is non dynamic, but I am searching

findInterval() with varying intervals in data.table R

こ雲淡風輕ζ 提交于 2019-12-05 12:30:49
I have asked this question a long time ago, but haven't found the answer yet. I do not know if this is legit in stackoverflow, but I repost it. I have a data.table in R and I want to create a new column that finds the interval for every price of the respective year/month. Reproducible example: set.seed(100) DT <- data.table(year=2000:2009, month=1:10, price=runif(5*26^2)*100) intervals <- list(year=2000:2009, month=1:10, interval = sort(round(runif(9)*100))) intervals <- replicate(10, (sample(10:100,100, replace=T))) intervals <- t(apply(intervals, 1, sort)) intervals.dt <- data.table

NSTimer with multiple time intervals in a sequence

时光怂恿深爱的人放手 提交于 2019-12-05 10:55:53
Without creating multiple NSTimer instances, how would one achieve an NSTimer to fire a specific or multiple method with different intervals in a sequence. For example method1 (0.3 sec), method2 (0.5), method3 (0.7) and so on. I would appreciate if someone could please share any example code. holex I'm not sure what your final goal is with this but after reading your question I would recommend to try the following way , maybe this is what you'd look for. you should put this code where you normally wanted to start the same NSTimer class with different intervals (what is not possible,

Loop through two arrays deleting overlaps in perl

心不动则不痛 提交于 2019-12-05 10:37:44
I have two sets of ranges, represented by [ start, stop ] values. Some of the ranges overlap, meaning that the start of one range is in between the [ start, stop ] of the other range. I'd like to make a new set of ranges that has no such overlap, and also doesn't include any new values in a range. The ranges look like this: @starts @ends 5 108 5 187 44 187 44 229 44 236 64 236 104 236 580 644 632 770 The output that I expect would be this: @starts @ends 5 236 580 770 This is because the first seven ranges overlap with the interval from 5 => 236, and the last two overlap with the interval from

Determining the length of a user's visit based on SQL timestamps

本秂侑毒 提交于 2019-12-05 05:02:41
问题 I am divided between using a C# implementation and a pure SQL 2005/2008 implementation. I need to determine the length of usage based on timestamps of their last actions. My table contains "friendID" (uniqueIdentifier) and "lastAction" datetime. Here is an example: Bob, 1:00 PM Bob, 1:01 PM Bob, 1:20 PM Bob, 1:25 PM Jack, 5:00 PM Bob, 11:20 PM I want to "time out" a user if they had 60 minutes of inactivity. If your suggestion works correctly, there should be 3 separate sessions from the data

Test if date occurs in multiple date ranges with R

梦想与她 提交于 2019-12-05 02:36:46
问题 I have a data frame with multiple date ranges (45 to be exact): Range Start End 1 2014-01-01 2014-02-30 2 2015-01-10 2015-03-30 3 2016-04-20 2016-10-12 ... ... ... They will never overlap I also have a data frame with various event dates (200K+): Event Date 1 2014-01-02 2 2014-03-20 3 2015-04-01 4 2016-08-18 ... ... I want to test if these dates fall within any of these ranges: Event Date InRange 1 2014-01-02 TRUE 2 2014-03-20 FALSE 3 2015-04-01 FALSE 4 2016-08-18 TRUE ... What is the best

Angular2 Observable with interval

狂风中的少年 提交于 2019-12-05 02:10:34
问题 I have a function that needs to be called about every 500ms. The way I am looking at doing it with angular2 is using intervals and observables. I have tried this function to create the observable: counter() { return Observable.create(observer => { setInterval(() => { return this.media.getCurrentPosition(); }, 500) }) } With this code for the subscriber: test() { this.playerService.initUrl(xxxx) // This works this.playerService.counter().subscribe(data => { res => { console.log(data); } }) } I