intervals

Efficiently joining over interval ranges in SQL

我只是一个虾纸丫 提交于 2019-12-01 23:42:08
问题 Suppose I have two tables as follows (data taken from this SO post): Table d1 : x start end a 1 3 b 5 11 c 19 22 d 30 39 e 7 25 Table d2 : x pos a 2 a 3 b 3 b 12 c 20 d 52 e 10 The first row in both tables are column headers. I'd like to extract all the rows in d2 where column x matches with d1 and pos1 falls within (including boundary values) d1 's start and end columns. That is, I'd like the result: x pos start end a 2 1 3 a 3 1 3 c 20 19 22 e 10 7 25 The way I've seen this done so far is:

AngularJS $interval should dynamically in-/ decrease

故事扮演 提交于 2019-12-01 23:01:57
i just want to use $interval(anyFunction(){}, 1000); But value of 1000 should be variable, too. If i change it by defining a variable, the interval won't change on the view. Could someone post an example how to update the 'speed' of an $interval? Thank you very much. Just in case: my controller: $scope.food = 0; var stop; var farmInterval = 1000; $scope.startFarming = function () { console.log('farming started...'); if (angular.isDefined(stop)) return; stop = $interval(function () { $scope.food += 1; }, farmInterval); // <-- this value 'farmInterval' should be variable } $scope.stopFarming =

Efficiently joining over interval ranges in SQL

╄→гoц情女王★ 提交于 2019-12-01 22:31:45
Suppose I have two tables as follows (data taken from this SO post ): Table d1 : x start end a 1 3 b 5 11 c 19 22 d 30 39 e 7 25 Table d2 : x pos a 2 a 3 b 3 b 12 c 20 d 52 e 10 The first row in both tables are column headers. I'd like to extract all the rows in d2 where column x matches with d1 and pos1 falls within (including boundary values) d1 's start and end columns. That is, I'd like the result: x pos start end a 2 1 3 a 3 1 3 c 20 19 22 e 10 7 25 The way I've seen this done so far is: SELECT * FROM d1 JOIN d2 USING (x) WHERE pos BETWEEN start AND end But what is not clear to me is if

Confusion about how the promise returned by $interval works compared to $timeout in Angular

五迷三道 提交于 2019-12-01 22:08:23
问题 I'm having an issue understanding how the promise returned by $interval works in Angular. Let's say in the following example, we have a simple "api" factory with a method called "getStuff" that returns an array with one item. We also have a controller that calls $timeout on that factory: angular.module("app",[]) .factory('api', function(){ return { getStuff: function() { return ["stuff"]; } }; }) .controller('appCtrl', function($scope, $timeout, api){ $timeout(api.getStuff, 1000) .then

Confusion about how the promise returned by $interval works compared to $timeout in Angular

 ̄綄美尐妖づ 提交于 2019-12-01 21:34:02
I'm having an issue understanding how the promise returned by $interval works in Angular. Let's say in the following example, we have a simple "api" factory with a method called "getStuff" that returns an array with one item. We also have a controller that calls $timeout on that factory: angular.module("app",[]) .factory('api', function(){ return { getStuff: function() { return ["stuff"]; } }; }) .controller('appCtrl', function($scope, $timeout, api){ $timeout(api.getStuff, 1000) .then(function(response){ console.log(response); }); }) This will log '["stuff"]' in the console after 1 second,

Join two tables date from first in range of dates from second

こ雲淡風輕ζ 提交于 2019-12-01 20:47:34
问题 I have two tables like below (date format: yyyy-MM-dd): 1) Table1 - EMPLOYEE_OVERTIMES (alias: EO) EMPLOYEE_ID | OVERTIME_DATE ------------------------------------------------ 1 | 2012-04-01 2 | 2012-08-14 3 | 2012-07-22 4 | 2012-10-30 5 | 2012-06-07 2) Table2 - EMPLOYEE_HOLIDAYS (alias: EH) EMPLOYEE_ID | START_DATE | END_DATE | ----------------------------------------- 1 | 2012-03-28 | 2012-04-10 2 | 2012-01-14 | 2012-01-30 3 | 2012-07-15 | 2012-07-25 4 | 2012-10-10 | 2012-10-13 5 | 2012-06

Join two tables date from first in range of dates from second

冷暖自知 提交于 2019-12-01 19:11:52
I have two tables like below (date format: yyyy-MM-dd): 1) Table1 - EMPLOYEE_OVERTIMES (alias: EO) EMPLOYEE_ID | OVERTIME_DATE ------------------------------------------------ 1 | 2012-04-01 2 | 2012-08-14 3 | 2012-07-22 4 | 2012-10-30 5 | 2012-06-07 2) Table2 - EMPLOYEE_HOLIDAYS (alias: EH) EMPLOYEE_ID | START_DATE | END_DATE | ----------------------------------------- 1 | 2012-03-28 | 2012-04-10 2 | 2012-01-14 | 2012-01-30 3 | 2012-07-15 | 2012-07-25 4 | 2012-10-10 | 2012-10-13 5 | 2012-06-01 | 2012-06-07 The tables EMPLOYEE_OVERTIMES and EMPLOYEE_HOLIDAYS are joined from other tables. I

Checking if new interval overlaps - MySQL (or PHP)

二次信任 提交于 2019-12-01 19:04:50
I've been thinking on how I can simplify the problem presented here. Complex MySQL Query - Checking for overlapping DATE intervals At it's heart, minus all the fancy magic with DATES this is simply a problem of checking for overlapping intervals. After all dates can be thought of as numbers and it may make the logic easier. Imagine the following table: Schedules schedule_id | start | end 1 | 1 | 3 2 | 4 | 7 3 | 8 | 13 4 | 15 | 16 5 | 18 | 24 6 | 25 | 28 I'm trying to insert a new interval such that [a,b] do not overlap with any other interval. The considerations: Yes, I can pull the whole

Grouping a data.table by running intervals

元气小坏坏 提交于 2019-12-01 18:43:06
问题 I am using R with package data.table and I would like to group a data.table by running (time) intervals or overlapping bins. For each of these running intervals I would like to find the occurence of equal pairs of data. Further more these "equal pairs of data" should be not exactly equal, but in some interval range, too. The simple version of the question is as following: #Time X Y Counts # ... ... ... 1 #I would like to do: DT[, sum(counts), by = list(Time, X, Y)] #with Time, X and Y being

Calculate the perimeter and area of intersecting rectangles?

扶醉桌前 提交于 2019-12-01 18:19:15
I searched a lot, but I didn't find a good answer that works for this case. We have some rectangles that are horizontal or vertical. They can be placed on the page randomly. They can overlap or have a common edge or be separate from each other. I want to find an algorithm with O(nlogn) that can find perimeter and area of these rectangles. These pictures may make the problem clear. I think that interval trees might help, but I'm not sure how. It can be done by a sweep-line algorithm. We'll sweep an imaginary line from left to right. We'll notice the way the intersection between the line and the