Menu
  • HOME
  • TAGS

Execute method with Angular's $timeout in a for loop

javascript,angularjs,timeout,intervals

You need to wrap it in a closure function, pass in the i variable, and then it will become available within the scope of that new function.. e.g. for(var i = 0; i < 10; i++) { (function(i){ // i will now become available for the someMethod to call $timeout(function()...

Calculating total length of a union of time intervals presented at a table

mysql,datetime,intervals

Disclaimer This is probably best done outside of SQL For Those That Like Painful Queries You could create a query that attempts to decide whether there is a row elsewhere in the table that overlaps the end column. If there is not then try to find out how much time...

Translation of interval

postgresql,datetime,translation,intervals,postgresql-8.4

I think no. sorry. day, month etc are field in type interval. it will be in English. like you don't expect use "vybrac" instead of select :) But you can have locale in time values, yes. td=# set lc_time TO pl_PL; SET td=# SELECT to_char(to_timestamp (4::text, 'MM'), 'TMmon'); to_char ---------...

How to spread the average between two intervals in oracle

sql,oracle,oracle11g,intervals

EDIT: Added union to include the final missing row Some thing like this may work. Assuming the input data is in table a, with b as (select level-1 lev from dual connect by level <= 60 ), v as ( select start_date, value current_value, lead(value) over (order by start_date) next_value...

jQuery - clearInterval seems not to work

jquery,if-statement,intervals,clearinterval

So currently, your code is going to run something like this order: window.intervalcount = 0; // Interval is defined here var interval = setInterval(function () { intervalcount += 1; $("#feedback").text(intervalcount); }, 1000); // will be 0 still if(intervalcount > 5) { clearInterval(interval); } // 1 second after the interval is...

Combinations of N Boost interval_set

c++,algorithm,boost,intervals,boost-icl

As I surmised, there's a "highlevel" approach here. Boost ICL containers are more than just containers of "glorified pairs of interval starting/end points". They are designed to implement just that business of combining, searching, in a generically optimized fashion. So you don't have to. If you let the library do...

Javascript Event Listener at Interval

javascript,intervals,event-listener

You can add and remove the event listener as desired: function processMotion(e) { // your code here to process devicemotion events } function addMotionListener() { window.addEventListener("devicemotion", processMotion); } function removeMotionLisener() { window.removeEventListener("devicemotion", processMotion); } So, just call addMotionListener() when you want to start listening to motion. Then call removeMotionListener() when...

Javascript: Excuting 2 functions in desired interval

javascript,timer,setinterval,intervals

function fooBar(foo,delay){ var i=1; setInterval(function(){ if (i%(foo+1) ==0){ console.log("BAR"); } else { console.log("foo"); } i++; //set i back to 0. not necessary, though if (i==(foo+1)){ i=0; } },delay); } fooBar(3,1000);//number of "foo"s , delay in ms ...

VB2010 Setting logarithmic scale intervals

vb.net,visual-studio-2010,charts,intervals

You can enable the MinorGrid property chart.ChartAreas(0).AxisY.MinorGrid = True to show the horizontal lines in between the powers of 10 like shown bellow. But there is a limitation in showing the value for each subdivision. They can only appear in fixed intervals by using the Interval property of the LabelStyle....

How to awk number into ranges and print the lower

awk,intervals

Grouping it by 4 using awk Min awk 'NR%4==1' file 2 7 13 19 Max awk 'NR%4==0' file 6 12 18 To get the min and max value. awk 'ORS=NR%4?FS:RS' file | awk '{for (i=1;i<=NF;i++) {min=$i<min||!min?$i:min; max=$i>max||!max?$i:max} print min,max;min=max=0}' 2 6 7 12 13 18 19 19 First awk group...

PHP: Next delivery date [on hold]

php,date,datetime,intervals

You could use DatePeriod for this. DatePeriod will take a DateTime object as a start date, for the first parameter, a DateInterval object as the interval on which to repeat, for the second parameter, and a DateTime object or integer representing the ending date or number of recurrences for the...

using intervals to assign categorical values

r,data.frame,dplyr,intervals

You can use foverlaps in data.table: library(data.table) C.DT <- data.table(C) C.DT[, A1:=A] # required for `foverlaps` so we can do a range search # `D` and `E` are your interval matrices I1 <- data.table(cbind(data.frame(D), idX=LETTERS[1:4], idY=NA)) I2 <- data.table(cbind(data.frame(E), idX=NA, idY=LETTERS[16:19])) setkey(I1, X1, X2) # set the keys on our...

Finding All Intervals That Overlap a Point

c++,computational-geometry,intervals,skip-lists

Suggest using CGAL range trees: Wikipedia says interval trees (1-dimensional range trees) can "efficiently find all intervals that overlap with any given interval or point"....

Matplotlib: Find a region on a graph by mouse click

python,matplotlib,coordinates,mouse,intervals

There are some built in tools to provide blocking mouse input (see plt.ginput). The other option is to roll your own. The easiest way to do this is to make a helper class to store the clicked values: class ClickKeeper(object): def __init__(self): self.last_point = None def on_click(self, event): self.last_point =...

stopping timer in an anonymous function jquery

jquery,timer,intervals,clear

Move the click handler inside the anonymous function, so that it will have the same scope as the timer variable. You can then add this within the click handler: clearInterval(timer); Snippet $(function() { var timer; var secs = 0; var mins = 0; var timeField = document.getElementById("time"); timeField.innerHTML = "00:00";...

How to count the number of values that are between intervals in excel

excel,intervals

Change > and < to >= and <= in your SUMPRODUCT. You can also try COUNTIFS formula - should work faster. With the following sample layout: Enter in C3 and drag it down: =COUNTIFS($A$1:$G$1,">=" &A3,$A$1:$G$1,"<="&B3) ...

QSerialPort: how to adjust the emiting time of readysignal using number of bytes received

qt,serial-port,intervals,qtserialport

In general readyread signal would be emitted even if one byte is received. But the response time depends on many factors like the driver, CPU load or how much the Qt event-loop is busy. When a receive is detected in the serial port, all data in the driver buffer will...

Date interval sum and subtraction in Java

java,date,sum,intervals,subtraction

I found exactly what I needed: Ranges, from the guava-libraries. Works like this: Range<Date> a = Range.closed( new GregorianCalendar(2015, 0, 1).getTime(), new GregorianCalendar(2015, 0, 20).getTime()); Range<Date> b = Range.closed( new GregorianCalendar(2015, 0, 5).getTime(), new GregorianCalendar(2015, 0, 10).getTime()); Range<Date> c = Range.closed( new GregorianCalendar(2015, 0, 11).getTime(), new GregorianCalendar(2015, 0, 14).getTime()); Range<Date>...

overlapping of 3 intervals: what is the fastest way

javascript,python,logic,intervals,overlapping

Python solution for any number of intervals regardless of order of the numbers in the interval. It'll either return True, min t value, max t value or False, t value, t value. def in_interval(intervals): if len(intervals) == 0: return False, None, None min_t = min(intervals[0]) max_t = max(intervals[0]) for interval...

how to show an event happened between two dates in R

r,date,intervals

You can try library(dplyr) df1 %>% mutate_each(funs(as.Date(., '%d/%m/%Y')), matches('start|end|date')) %>% mutate(drug.end= as.Date(ifelse(is.na(drug.end), End.date, drug.end),origin='1970-01-01'), Event= as.integer((Diag_date >= Drug.start & Diag_date<=drug.end) & !is.na(Diag_date))) #%>% #mutate_each(funs(format(., '%d/%m/%Y')), matches('start|end|date')) # ID Diag_date Treatment End.date Drug.start drug.end Event #1 1 <NA> 0 2002-03-15 2002-01-01 2002-02-01 0 #2 1 <NA> 1 2002-03-15 2002-02-01 2002-03-01 0...

R assign week value for a range of numbers

r,intervals

As the 'date' column have only week days and without any breaks, we can use gl/paste to create week index. This doesn't depend on the nrow of the dataset i.e. even if the nrow is not a multiple of 5, it will work. dataset$week <- paste('Week', as.numeric(gl(nrow(dataset),5, nrow(dataset)))) Other option...

Youtube iframe javascript, track percentage of video watched?

javascript,video,youtube,intervals,track

Here is a demo, I think the variables and functions have names explicit enough to understand everything, but if you have any question or problem, go ahead and ask. One thing I have to mention is that it won't be exact. If your interval gets executed once per second and...

Python- Count the frequency of messages within a date range within per dynamic interval

python,date,range,intervals

You want to implement numpy.histogram() for dates: import numpy as np times = np.fromiter((d['first_alerted_time'] for d in example_table), dtype='datetime64[us]', count=len(example_table)) bins = np.fromiter(date_range(start_date, end_date + step, step), dtype=times.dtype) a, bins = np.histogram(times, bins) print(dict(zip(bins[a.nonzero()].tolist(), a[a.nonzero()]))) Output {datetime.datetime(2014, 12, 11, 2, 0): 3, datetime.datetime(2014, 12, 11, 2, 3): 1} numpy.historgram() works...

How to calculate number of days since start of year with DateTime while accounting for leap years?

php,datetime,intervals

Turns out this is a reported PHP bug from 2012 that I JUST found while I was making this question: https://bugs.php.net/bug.php?id=62476 That's annoying. Here is a workaround: $date = DateTime::createFromFormat('m/d/Y', '01/01/2016'); $date->add(date_interval_create_from_date_string('59 days')); echo $date->format('m/d/Y')."\n"; ...

Fastest way to find intervals which contain a given point in time

c#,algorithm,datetime,intervals

Let's say you store your task in a class like this: public class MyTask { public string name; public DateTime startDt; public DateTime endDt; // ... } The basic idea is to maintain two collections with tasks, one ordered by startDt the scond by endDt. We are going to use...

how to make sure both files remain open when comparing two files

python,file,input,intervals,overlap

The with block for "bed" is closing the file after the block is complete. But while normally you would embed the open function call inside your with statement like so: with open(B, 'r') as input2 instead you are opening the file only once and then trying to operate on it...

Python: optimizing pairwise overlaps between intervals

python,intervals

Generally, this kind of problem becomes much easier if you sort the intervals by starting point. Firstly, let us define a function, in order to make things clearer: def overlap( r1, r2 ): left = max(r1[0], r2[0]) right = min(r1[1], r2[1]) over = right - left return (left, right, over)...

How to tweak the SET intervalstyle (change the Interval Output) in PostgreSQL?

postgresql,intervals

You can set the interval output style, but only to one of a few pre-defined formats that are unambigious on input, and that PostgreSQL knows how to parse back into intervals. Per the documentation these are the SQL standard interval format, two variants of PostgreSQL specific syntax, and iso_8601 intervals....

PHP DateTime Interval errors

php,datetime,intervals,dateinterval

When using DateInterval() to create an interval you use M for minutes, not i. Also, if there are no seconds you must omit it from the interval declaration: $busts = $ts->add(new DateInterval('PT6M5S')); $lamts = $busts->add(new DateInterval('PT11M')); i is used for getting the number of minutes in a date interval: echo...

Merge columns to time variable

r,time,intervals

You can try test$time <- strptime(with(test, sprintf('%02d:%02d', hour, min)), '%H:%M') test$time[1:5] #[1] "2014-12-05 06:30:00 EST" "2014-12-05 06:31:00 EST" #[3] "2014-12-05 06:32:00 EST" "2014-12-05 06:33:00 EST" #[5] "2014-12-05 06:34:00 EST" Update For aggregating the counts (sum), you could try aggregate(count~ cbind(timeGr=as.character(cut(time, breaks='3 min'))), test, FUN=sum) timeGr count #1 2014-12-05 06:30:00 30.67396...

How to get time interval as seen in message from a NSDate Eg 2m, 3h, Tuesday, 2014-06-01

ios,time,nsdate,intervals,messages

I suggest to use this category. It is very helpful for what you are looking for. For example this line of code: NSString *displayString = [NSDate stringForDisplayFromDate:date]; produces the following kinds of output: - ‘3:42 AM’ – if the date is after midnight today - ‘Tuesday’ – if the date...

Overlapping Intervals and Minimum Values

algorithm,computational-geometry,intersection,intervals

The idea to assign values is correct. You just need to sort intervals by their minumum value(in increasing order). That is, the solution looks like this: Build a segment tree(with -infinity values in all nodes). Process all intervals in sorted order. For each interval, just assign its value(no matter what...

How to find the longest interval of 1's in a list [matlab]

arrays,matlab,list,matrix,intervals

Using this anwser as a basis, you can do as follows: a = [1 0 0 1 1 1 0 0 0 0 1 1 1 1 1 1 1 ] dsig = diff([0 a 0]); startIndex = find(dsig > 0); endIndex = find(dsig < 0) - 1; duration =...

Add two hours to timestamp

sql,oracle,plsql,timestamp,intervals

You need to change your HOUR TO MINUTE to match the value you're actually passing: sysdate + INTERVAL '0 02:00:00.0' DAY TO SECOND You might also want to use systimestamp instead of sysdate. You can use a shorter interval literal too if you're always adding exactly two hours: systimestamp +...

How to apply newly added object in array in ng-repeat interval?

javascript,angularjs,intervals

Currently you are cashing the $scope.tabs.length when you invoke the $interval service. If you want to display items that have been added after you call count, you have to check array length within you interval function, something like: interval = $interval(function() { if ($scope.tabs.length-1 > i) { ... } else...

How to check if a number is in a interval

python,coding-style,range,intervals

I use a class with __contains__ to represent the interval: class Interval(object): def __init__(self, middle, deviation): self.lower = middle - abs(deviation) self.upper = middle + abs(deviation) def __contains__(self, item): return self.lower <= item <= self.upper Then I define a function interval to simplify the syntax: def interval(middle, deviation): return Interval(middle,...

Use label value as the value for timer interval

vb.net,timer,label,intervals,value

Int32.TryParse initializes the int parameter when it could parse the string to Int32 successfully, otherwise it will be 0. So either the string cannot be parsed because the format is invalid orit is "0". What is it's value? The value frmSettings.Lbl_Error_Millisec_Fin.Text is 0, take note that I've taken that from...

Clear Input Box Every x Seconds [closed]

javascript,php,html,intervals,clear

Vanilla javascript: clears input value every 3 seconds setInterval( function() { document.getElementById("my-input").value = ""; }, 3000); <input id="my-input" type="text" /> ...

Union and intersection of intervals

r,intervals

This is a bit awkward, but the idea is that you unroll the data into a series of opening and closing events. Then you track how many intervals are open at a time. This assume each group doesn't have any overlapping intervals. df <- data.frame(id=c(rep("a",4),rep("b",2),rep("c",3)), start=c(100,250,400,600,150,610,275,600,700), end=c(200,300,550,650,275,640,325,675,725)) sets<-function(start, end, group,...

Postgresql complains when interval is result of string concatenation

postgresql,date,casting,intervals

That's because date is actually a function in PostgreSQL. There is an interval function too, but you need to quote it: SELECT "interval"(substring('2015015' from 5)||' days'); It is also possible to specify a type cast using a function-like syntax: typename ( expression ) However, this only works for types whose...

Coding a Calculator on Python

python,python-3.x,calculator,intervals

You are running the while loop until a and x becomes equal while you are actually looking for the intermediate value to be equal to x. You should write the loop like this instead: while float(CR5((a+x)/2.0))!= x: and while float(CR5((b+x)/2.0))!= x: result for x=4: (3.9999, 4.0001) ...

How to call a clearInterval() method from one function to stop a setInterval() method in another

javascript,jquery,html,slideshow,intervals

You can use this example to implement yours.. var interval; $('#stop').click(function(){ clearInterval(interval); }); var slide = function(){ alert("testing setInterval"); } interval = setInterval(slide,2000); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <button id="stop">stop interval</button> ...

Finding minimum number of points which covers entire set of intervals?

algorithm,intervals

You can use a greedy algorithm: Sort all intervals by their end points(in increasing order). Iterate over a sorted array of intervals. When an interval is over, there are two options: It is already covered by some point. Nothing should be done in this case. It is not covered yet....

Double setInterval

javascript,jquery,ajax,intervals

var islem; $(document).ajaxComplete(function () { $(".iframeFake").load(function () { clearInterval(islem); islem = setInterval(function () { $('.iframeFake').each(function (event) { console.log(1); }, 1000); }); }); If you want to maintain that there is always one interval, store the variable at a higher scope, and cancel before you create to stop any lingering...

Increment minute to the nearest 15 minute interval

php,date,datetime,intervals

$min15InSecs = 15*60; $min15 = time()-(time()%$min15InSecs)+$min15InSecs; $start = new DateTime(date("Y-m-d H:i", $min15)); $start->add(new DateInterval('PT1H')); $end = new DateTime("2015-05-16 19:00"); $interval = new DateInterval('PT15M'); $period = new DatePeriod($start, $interval, $end); $current_date = date('d-M-Y g:i:s A'); $current_time = strtotime($current_date); foreach ($period as $dt) { echo $dt->format('H:i')."<br>"; } ...

Shorter notation for interval type

postgresql,time,format,intervals,postgresql-8.4

Use date_trunc(): SELECT date_trunc('second', interval '1 day 14:28:09.00901'); ...

R and lubridate: do the intervals in x fit into any of the intervals in y?

r,intervals,lubridate

I would approach this using data.tables foverlaps function First, we will convert to data.table objects, create start and end intervals, and sort campus.df by these intervals library(data.table) setDT(task.df)[, `:=`(start = as.POSIXct(paste(Start.Date, Start.Time)), end = as.POSIXct(paste(End.Date, End.Time)))] setkey(setDT(campus.df)[, `:=`(start = as.POSIXct(paste(Start.Date, Start.Time)), end = as.POSIXct(paste(End.Date, End.Time)))], start, end) Then, we could...

How many intervals are containing an another interval?

algorithm,optimization,intervals

Sort by startpoint, count the number of inversions in the list of endpoints using the mergesort-derived O(n log n)-time algorithm.

Convert Date to interval string oracle

sql,oracle,intervals

It looks like you're trying to get the time part from DATE2 and add it to DATE1? I'm afraid that Oracle doesn't recognize TO_CHAR(date2...) as an INTERVAL literal even though it appears to be in the correct format. I would try this instead (good old-fashioned Oracle date arithmetic): date1 +...

Delete fraction from variable

php,variables,delete,intervals

Use the floor() function to remove the fraction after the decimal: $cn = floor($cc/25); ...

Given a start time and an interval in minutes, determine if current time is an interval

c#,vb.net,datetime,intervals,calculated

My pseudo modulus operation: float tolerance = 0.0001f; if((CurTime - StartTime) % IntervalMinutes <= tolerance) { // Do something } ...

Oracle SQL Query Where Timestamp is in Last 1 hour Using Systimestamp

sql,oracle,timestamp,intervals

Using localtimestamp rather than systimestamp solved the issue as implicitly converting to a date type to subtract (1/24) loses the time zone.

How to obtain the complement intervals from an array of intervals in perl?

arrays,perl,intervals

If the intervals are already sorted and don't overlap: #!/usr/bin/perl use warnings; use strict; use List::MoreUtils qw{ natatime }; my @ary1 = qw(23-44 85-127 168-209); my $diff = 1; my $pair = natatime 2, '...', map({ map { $diff *= -1; $_ + $diff } split /-/ } @ary1), '...';...

How to stop $interval on leaving ui-state?

angularjs,intervals,angularjs-ui-router

clear your interval on $destroy Try like this $scope.$on("$destroy",function(){ if (angular.isDefined($scope.Timer)) { $interval.cancel($scope.Timer); } }); ...

For-loop to find values falling into a specified interval in Matlab

matlab,for-loop,matrix,indexing,intervals

You don't want to use loops for this in Matlab: VALS = ~(pvals < 2.7613 | pvals > 0.3621405); By the way, to fix your loop (and for every loop you ever make in Matlab) you should pre-allocate memory by just adding the line VALS = zeros(size(pvals)); before you loop....

Getting error when using prepareStatement with interval in query

java,oracle,prepared-statement,intervals

The entire expression INTERVAL '7' DAY is a literal, you cannot simply replace a part of it with a variable (parameter). Use the function NUMTODSINTERVAL(?,'DAY') instead.

optimize has weird behavior when I change the interval

r,loops,intervals,mathematical-optimization,maximize

This optimization problem is essentially going to be impossible for any optimizer (such as optimize()) that assumes the objective function is smooth and has a single minimum. You didn't give a reproducible example, but here's an example of an objective function that's just about as ugly as yours: set.seed(101) r...

PHP/MySQL Deleting before interval

php,mysql,intervals

Try this: $query = "DELETE FROM my_table WHERE DATE_ADD(`time`, INTERVAL 2 HOUR) < NOW()"; It adds two hours to your column value and if it is less then the current time it will be deleted. SQL Fiddle...

c++ tracking discrete space sequence

c++,boost,intervals

You can indeed use Boost ICL, as you suspected. The default interval combining style is "Joining". This is exactly what you need! So, it's home run. Here's a trivial demo with exactly the input events as given in the example. I print the state of the record at each event...

Conflict with simulation cron

angularjs,cordova,time,intervals,ionic

Most likely the js runtime was unloaded from the device browser for your page (since the user is not looking at it and the device wants to save on battery), that is why it stops working, I don't think it is possible to overcome this completely you could somewhat fake...

Sum of geometric points on large interval

algorithm,intervals

Sort the points. Iterate over the points and compute the running sum of the values up to each point. Store the sums in an array. When you want to compute the sum for an interval, find the lower and upper limit by binary search, then look up the lower sum...

Map intervals defined in data frame to vector

r,intervals

One solution is to replace your intervals by a simple id ( a sequence). This should be done for ints and out data.frames. Each id identify one interval. Once you do this the merge is straightforward. ## first I extract the intevals from ints in ordered manner id <- !is.na(ints$minValue)&!is.na(ints$maxValue)...

setInterval not repeating

javascript,web,intervals

Try using else if var func = function () { 'use strict'; if (time === 1) { document.getElementById("top-background").style.backgroundColor = "#000"; time += 1; } else if (time === 2) { document.getElementById("top-background").style.backgroundColor = "#aaa"; time += 1; } else if (time === 3) { document.getElementById("top-background").style.backgroundColor = "#d5d5d5"; time -= 2; }...

Run jQuery ajax in custom intervals

jquery,ajax,intervals

You can use setInterval. The first parameter is the function you want to be executed and the second one defines the intervals (in milliseconds) on how often to execute the code. In your case 5 minutes = 300 seconds which is 300*1000 milliseconds. setInterval(function() { jQuery.ajax({ url: "/wp-admin/admin-ajax.php", data :...

R segment function with intervals

r,intervals,segments

You need to supply vectors of coordinates x0 and y0 and x1 and y1 which are the x and y coordinates to draw from and to respectively. Consider the following working example: x <- seq(0, 1000, length = 200) y <- seq(0, 80000, length = 200) plot(x,y,type="n") from.x <- c(0,...

Swift Repeat Interval

uisegmentedcontrol,intervals

I found out that one of the old interval methods was depreciate in iOS 8.0. I found I need to use: notification.repeatInterval = NSCalendarUnit.CalendarUnitWeekOfMonth ...

Combine data into smaller discrete intervals

f#,mapping,intervals,discrete-mathematics

let interval = 10 let index = [6;12;18;24] let value =[101;102;103;104] let intervals = List.map (fun e -> e/interval) index let keys = List.map2(fun e1 e2 -> (e1,e2)) intervals value let skeys = Seq.ofList keys let result = skeys |>Seq.groupBy (fun p -> fst p) |>Seq.map (fun p -> snd...

create loop in R precipitation data defined interval start and end

r,loops,time-series,intervals,percentage

The R time series method ts, which you're trying to use, may be appropriate when there are an equal number of values per unit of time as in the case of months and years where there are 12 months in every year. However, since the number of days in a...

data structure for storing angle intervals

algorithm,binary-search-tree,computational-geometry,intervals,angle

The circularity of angles is not a major obstacle: to instead an interval like [270, 45) that wraps around, instead insert two intervals [270, 360), [0, 45). To implement insertion without wraparound, we can use a binary search tree. This tree tracks the uncovered intervals by mapping each endpoint of...

TIMESTAMP WITHOUT TIME ZONE, INTERVAL and DST extravaganza

ruby-on-rails,postgresql,intervals,dst,postgresql-9.4

I've created a function which calculates ended_at by adding duration days to started_at honoring DST changes of a given time zone. Both started_at and ended_at, however, are in UTC and therefore play nice with Rails. It turns started_at (timestamp without time zone, implicit UTC by Rails) to a timestamp with...

Vectorization of findInterval()

r,vectorization,intervals

You can do rowSums(X > Y) # [1] 0 2 ...

How to create delay/interval after receiving data from Arduino to Flash

actionscript-3,flash,timer,arduino,intervals

It is not entirely clear what you are asking (data being "clustered") but a few things – You are creating a new TextField on every Arduino event and adding them as children. Do you wish to have all the past events display or are you just wanting to display the...

Given an interval stored as [{name, value},…], how would I find where x lies?

javascript,intervals

Consider defining your ranges like this: [ { name: 'good', range: [6, Infinity }, { name: 'normal', range: [3, 6] }, { name: 'warning', value: [-6, -3] }, { name: 'danger', value: [-Infinity, -6] } ] With the existing data, you can build such a range like so: var points...

Change NSTimer interval after a certain number of fires

objective-c,cocoa-touch,nstimer,intervals

Make the timer object a member variable. Initially set animation time as 1 second. In the callback invalidate the timer and create a new one with 1 or 4 seconds depending on the counter. @interface ViewController () @property (strong,nonatomic) NSMutableArray *images; @property (strong,nonatomic) UIImageView *animationImageView; { NSTimer *_timer; } @end...

R: String character vector using logical OR | to sprintf time interval

r,string,printf,logic,intervals

Perhaps not as short, but this makes use of the fact that you're actually working with date/time values here and they do not behave like regular numeric sequences strftime(seq( as.POSIXct("2014-01-01 9:20:00"), as.POSIXct("2014-01-01 15:40:00"), by="20 min") , "%H:%M") # [1] "09:20" "09:40" "10:00" "10:20" "10:40" "11:00" "11:20" "11:40" "12:00" # [10]...

clearInterval() not clearing setInterval()

javascript,intervals,clearinterval

Problem seems to be in function fadeOut(), at this line: if(opac < 0) {setInterval(fadeIn, fadeInterval)}; //<-- required fadeTiming instead, also missing the assignment Try this: if(opac < 0) { clearInterval(fadeInterval); //make sure if the interval isn't already running fadeInterval = setInterval(fadeIn, fadeTiming); } ...

SQL select all but exlude results when datetime is between midnight and 6am

mysql,datetime,intervals

A big thank you for those you responded, I used your exemples and managed to make em work with my table and my data. Here's the final request : SELECT * from My Table where time(FROM_UNIXTIME(`date`)) > '06:00:00' and `date` > UNIX_TIMESTAMP("2015-05-01 00:00:00") and `date` < UNIX_TIMESTAMP("2015-05-02 00:00:00"); Basically the...

How to split a continuous variable into intervals of equal length (defined number) and list the interval with cut points only in R?

r,intervals

You're looking for cut cut(1:10, c(1, seq(2.5, 10, by=2.5)), include.lowest = T) # [1] [1,2.5] [1,2.5] (2.5,5] (2.5,5] (2.5,5] (5,7.5] (5,7.5] (7.5,10] # [9] (7.5,10] (7.5,10] # Levels: [1,2.5] (2.5,5] (5,7.5] (7.5,10] If you just want the evenly spaced breaks, use seq x <- 0:10 seq(min(x), max(x), len=5) # [1]...

General python function with many interval cases that returns specific values depending on interval

python,function,intervals

As is suggested by dlask's comment in your question, you can make use of the bisect library: boundaries = [0.009, 380.2, 389.8, 390.2, 399.8, 410.2] values = [None, -39, -94, -39, -60, -39, None] # what you need import bisect values[bisect.bisect_left(boundaries, x)] Assume you can construct boundaries and values with...

Teradata SQL to group by hour interval out of a TIMESTAMP(6)

sql,datetime,intervals,teradata

There's no HOUR function in Teradata, according to Standard SQL it's EXTRACT: EXTRACT(HOUR FROM timestampcol) And of course you need a aggregate function, but i assume VOLUME will be the alias for a SUM/AVG/COUNT :-)...

Changing Timer Interval in Backgroundworker DoWork Disables the Timer [C#]

c#,multithreading,timer,backgroundworker,intervals

It took me a while, but I found out what was wrong. I'll post you a working code, just in case someone will have the same problem. public partial class Form1 : Form { public int ticks = 0; public bool running = false; public bool push = false; public...

How does the INTERVAL datatype work?

sql,oracle,oracle11g,intervals

An interval of 300 months is exactly the same thing as an interval of 25 years, and they are of the same data type too: year intervals, year-month intervals and month intervals are just three ways of expressing the same type. You're shown +25-00 because one of the representations had...

SQL query to split records by intervals

sql-server,sql-server-2008-r2,intervals

The task you want to achieve is non trivial. A possible solution involves placing all From / To dates in an ordered sequence. The following UNPIVOT operation: SELECT ID, EventDate, StartStop, ROW_NUMBER() OVER (ORDER BY ID, EventDate, StartStop) AS EventRowNum, IsCancel FROM (SELECT ID, IsCancel, [From], [To] FROM Event) Src...

Computing pairwise distances between a set of intervals

r,intervals

Here's an Rcpp solution. It will be fast and memory efficient (for details see below). First let's define a helper function which calculates all the pairwise distances. If n is the number of intervals to consider, we have n*(n-1)/2 unique pairs of vectors (we don't take the same intervals into...

Delay textbox-textchenged in vb

vb.net,timer,delay,intervals,firing

TextChanged fires every time you change the content of the textbox. So there is no way to block this behavior. Perhaps you could add a button and move the recalculation on the button click event or better add an event handler for the Validating event. This event is triggered when...

JavaScript Calculate time difference in known intervals

javascript,date,datetime,time,intervals

Here's a function that should do what you want. As suggested in the comments, just calculate the time in milliseconds and increment until you reach your stop time. function calculate() { var a = []; var startValue = document.getElementById("startTime").value; var endValue = document.getElementById("endTime").value; var intervalValue = document.getElementById("interval").value; var startDate =...

Is it possible to show iAd after some definite intervals in iOS

ios,intervals,iad

Looking through the iAd Programming Guide I cannot find any explicit instruction to not periodically hide and display iAds as you are suggesting. To achieve this the best way to do it would be through the use of an NSTimer. I would declare a property: /** A timer used to...

How do I get a Pandas TimeSeries for user sessions (using Pandas or Numpy)

python,numpy,pandas,time-series,intervals

I found an approach that seems to work well: Assuming we can transform our Login/Logout data into two DataFrames indexed by time: Login UserLogin -------- --------- 8:58AM User_2 9:23AM User_3 10:25AM User_1 3:10PM User_3 Logout UserLogout -------- ---------- 1:35PM User_3 4:49PM User_3 5:12PM User_2 6:01PM User_1 Then we can add...