w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Count within a time period, a group of a smaller time period
Yup, possible with a GROUP BY and a HAVING, using some UNIX_TIMESTAMP rounding (subtracting stamp % 300 from stamp) to group into blocks of 300 seconds (5 minutes). SELECT COUNT(*), MIN(stamp) FROM mytable WHERE stamp >= NOW() - INTERVAL 30 minute GROUP BY FROM_UNIXTIME( UNIX_TIMESTAMP(stamp) - MOD(UNIX_TIMESTAMP(stamp),300) ) HAVING COUNT(*) >= 4 This assumes that you mean clock blocks rather than rolling blocks, i.e. you want from 00:00:00 to 00:04:59 etc., rather than from 13:23:01 to 13:28:00. This causes some issues with the "30 minutes ago" rule, so you might want to think that one through a bit carefully. EDIT: Well seeing as you insisted on making it a rolling block... let's add some delicious awfully-performing joining. SELECT COUNT(*), rolling.s

Categories : Mysql

How to Put Slider that increase decrease brightness of camera in AVCaptureSession
For that just set Brightness of mainScreen with bellow code.. [[UIScreen mainScreen] setBrightness:sliderValue]; in slider value set value from 0 to 1 like bellow.. yourSlider.minimumValue = 0.f; yourSlider.maximumValue = 1.0f; and its UIControlEventValueChanged call any method like bellow and change the value , see bellow Example.. - (void)Brightness_Changed:(UISlider *)sender { [[UIScreen mainScreen] setBrightness:sender.value]; }

Categories : Iphone

Oracle group by work time period and non work time period
The key to this grouping is to subtract 9 hours from the datetime to get the "workdate" and then use the hour function to determine whether it is a work hour or something else. Here is an example: select trunc(worktime - 9.0/24) as workdate, (case when hour(worktime) between 8 and 20 then 'WorkHours' else 'OtherHours' end), count(*) from t group by trunc(worktime - 9.0/24), (case when hour(worktime) between 8 and 20 then 'WorkHours' else 'OtherHours' end); To check for a particular month, you probably want to use the workdate rather than the actual date (so the first nine hours of the month are really part of the previous month).

Categories : SQL

calculating closed issues within an open or created period SSRS
You can use DATEPART to obtain the week number of the year: UPDATED As Conrad Fix said on a comment, you should add the year to your result set: SELECT ISNULL(A.[Year],B.[Year]) [Year], ISNULL(A.[Week],B.[Week]) [Week], ISNULL(A.Opened,0) Opened, ISNULL(B.Closed,0) Closed FROM ( SELECT YEAR(OpenDate) [Year], DATEPART(WEEK,OpenDate) [Week], COUNT(*) Opened FROM YourTable WHERE [OpenDate] IS NOT NULL GROUP BY YEAR(OpenDate), DATEPART(WEEK,OpenDate)) A FULL JOIN ( SELECT YEAR(ClosedDate) [Year], DATEPART(WEEK,ClosedDate) [Week], COUNT(*) Closed FROM YourTable WHERE [ClosedDate] IS NOT NULL GROUP BY YEAR(ClosedDate), DATEPART(WEEK,

Categories : SQL

Querying for a time period between a time period
I think your logic is backwards, if you want the constants between the column values: SELECT * FROM ALLOCATION WHERE dt_starting <= STR_TO_DATE('2013-09-02', '%Y-%m-%d') AND dt_ending >= STR_TO_DATE('2013-09-06', '%Y-%m-%d') AND id_res = 1; EDIT: If you are looking for an overlap between the time periods, then the logic is that one starts before the other ends, and the first ends after the second neds: SELECT * FROM ALLOCATION WHERE dt_starting <= STR_TO_DATE('2013-09-06', '%Y-%m-%d') AND dt_ending >= STR_TO_DATE('2013-09-02', '%Y-%m-%d') AND id_res = 1;

Categories : Mysql

how to open front camera and back camera at same time?
First You are not creating any new object of Camera explicitly. You are using singleton method of Camera. So there will be only one instance in memory. Second In Android documentation, there is written that.. Your application should only have one Camera object active at a time for a particular hardware camera. So this will also tell us that, we can't use more then one objects of Camera at the same time. Conclusion It is not possible.

Categories : Java

Hide and display images for a time in a special time period
I recommend using a cycle pattern. Here's a demo (using 1.2 seconds to save you 1.98 minutes). var images = document.getElementsByTagName("img"); We wrap this in a closure so we can control our i variable. (function(){ var i = 0; The first thing we do in our interval is to hide the current image, which is images[i]. setInterval(function(){ images[i].style.display = "none"; The we check and see if i+1 would be a valid image. You could also write this as images[i+1] != null. If we can increment it, we do. Otherwise we start back at 0. With two images this toggles between 0 and 1. With 5 images it cycles 0, 1, 2, 3, 4, 0, 1, 2, ... if (i+1 < images.length) { i++; } else { i = 0; } Our new image is dis

Categories : Javascript

How can I output a composite signal made of two signals with different time period at the same time on one audio channel in matlab code?
It is hard to tell exactly what you need, but probably doing interpolation on the sequence that is sampled at the slower rate would work for your application. If t1s are your times from your faster sequence, and t2s are times from your slower sequence, and slow is your slower sequence then do: slowInterp = interp1(t2s, slow, t1s); now you will have the sequency slow sampled at the faster rate. This is only useful for displaying the time series. If you are doing any spectral analysis, this will introduce artifacts, but that is a more advanced topic. Using the resample function in the signal processing toolbox could also be useful.

Categories : Matlab

C#, decrease database access time
two things I would try: write a stored proc that returns multiple resultsets for the parents, childs, etc. write code to read the results and instantiate your objects have the stored proc use 'for xml' to create this structure on the db side in xml use xml deserializer to instantiate your objects

Categories : C#

Decrease rails boot time
RUBY_HEAP_MIN_SLOTS (default 10_000) - the initial number of heap slots and minimum number of slots at all times. One heap slot can hold one Ruby object. RUBY_HEAP_FREE_MIN (default 4_096) - the number of free slots that should be present after the garbage collector finishes running. If there are fewer than those defined, it allocates new ones according to RUBY_HEAP_SLOTS_INCREMENT and RUBY_HEAP_SLOTS_GROWTH_FACTOR parameters RUBY_HEAP_SLOTS_INCREMENT (default 10_000) - the number of new slots to allocate when all initial slots are used. The second heap. RUBY_HEAP_SLOTS_GROWTH_FACTOR (default 1.8) - multiplication factor used to determine how many new slots to allocate (RUBY_HEAP_SLOTS_INCREMENT * multiplication factor). For heaps #3 and onward. RUBY_GC_MALLOC_LIMIT (default 8_000_

Categories : Ruby On Rails

Extract time frames from time period
Haven't tested this, but I hope it gets you on the right track: <?php $price = 0; $start_timestamp = 1367449200; $end_timestamp = 1367546400; $start_time_of_day = 1367449200 % (24*60*60); // Number of seconds from start of the day $end_time_of_day = 1367546400 % (24*60*60); // Number of seconds from start of the day // How much time the time period spends in the first day (in seconds) $first_day_time = (24*60*60) - $start_time_of_day; // How much time the time period spends in the last day (in seconds) $last_day_time = (24*60*60) - $end_time_of_day; $full_days_time = $end_timestamp + $last_day_time - ($start_timestamp + $first_day_time); $full_days = round($full_days_time/(24*60*60)); // You can calculate by hand how much one full 24-hour day from 00:00 to 00:00 costs $price += $fu

Categories : PHP

how to decrease the width of parent div and child div at the same time in html5?
"Setting the width of the child as a percentage of the parent usually works" @Aaron Digulla http://jsfiddle.net/YswCH/ <div id="parent"> <div id="child">Lorem ipsum lorem ipsum lorem ipsum</div> </div> #parent { background: yellow; width: 15em; height: 5em; overflow: hidden; } #parent:hover { background: yellow; width: 10em; height: 5em; } #child { background: red; width: 80%; height: 4em; }

Categories : HTML

Decrease loading time between init and viewDidLoad in a UIViewController?
Logging output has an impact on performance. This is probably a lot quicker without those log output statements. However, is this really the slowest area of your code when you run it through instruments time profiler? I doubt that. Profile your code and concentrate on increasing the performance of the biggest bottlenecks first.

Categories : Iphone

How to decrease initial load time in Gwt multiple entry point project app
I dont know what version of the api you are using for it. You can use the Code Splitting feature to improve the performance. You can check this here.

Categories : Java

Sum over a period of time
I advice you a SQL manual. There are 5 aggregation function in SQL MIN - get minumum value of list MAX - get maximum value of list SUM - sum all not null value of list AVG - get average al all not null value of list COUNT - count all not null value of list

Categories : SQL

Get a Row if within certain time period of other row
I am not really sure of sql server syntax, but you can do something like this SELECT * FROM ( SELECT TOP 2 as1.AssetTagID, as1.TagID, as1.CategoryID, as1.Description, as1.HomeLocationID, as1.ParentAssetTagID , ar.DateScanned, LAG(ar.DateScanned) OVER (order by ar.DateScanned desc) AS lagging FROM Assets AS as1 INNER JOIN AssetsReads AS ar ON as1.AssetTagID = ar.AssetTagID WHERE (ar.ReadPointLocationID='Readpoint1' OR ar.ReadPointLocationID='Readpoint2') AND (ar.DateScanned between 'LastScan' AND 'Now') AND as1.TagID!='000000000000000000000000' ORDER BY ar.DateScanned DESC ) WHERE lagging IS NULL or DateScanned - lagging < '5 SECONDS' I have tried to sort the results by DateScanned desc and then just the

Categories : SQL

Determining a time period
I would look into using Android Notifications along with AlarmManager to handle the repeating. Particularly setRepeating in AlarmManager to call the service and creating the actual Notification in the onReceive of your service.

Categories : Android

Values over a time period
As suggested by @DanBracuk in the comments, you should probably take the parameter from SSRS and just update it based on the current date in your T-SQL code. Say you have an SSRS parameter Parameters!Month.Value which gets passed to your stored procedure as @Month. You can use GETDATE() and date functions like DATEDIFF() and DATEADD() to adjust @Month as required, e.g. in the stored procedure code something like: select @Month = case when datediff(dd, @Month, getdate()) > 90 then @Month else dateadd(dd, -90, @Month) end select * from MyTable where MyDate < @Month Update the first statement to meet your requirements; they seem a bit ambiguous at this point - apologies if I haven't understood the issue completely.

Categories : SQL

how to convert int into time period
I'm not entirely clear on what you're asking but I think this is what you're looking for. $date = new DateTime(); $date->sub(new DatePeriod('P'.$settings->days_back.'D')); echo $date->format('Y-m-d H:i:s'); You can also do (if you're using PHP 5.2) $date = new DateTime(); $date->modify('-' . $settings->days_back . ' days')); echo $date->format('Y-m-d H:i:s'); reference DateTime() DatePeriod()

Categories : PHP

How do I set a PHP cookie for one second or a short period of time?
Yes, you are doing it right! time()+1 is completely valid. Here is more information from the PHP manual about cookie expiration time: This is a Unix timestamp so is in number of seconds since the epoch. In other words, you'll most likely set this with the time() function plus the number of seconds before you want it to expire. Or you might use mktime(). time()+60*60*24*30 will set the cookie to expire in 30 days. If set to 0, or omitted, the cookie will expire at the end of the session (when the browser closes). But one (1) second is, as commented, a little bit too short to be useful.

Categories : PHP

R time series period subtract?
Your problem is not well defined. But I guess you try to split your data by event and by week. Then for each event try to compute the count return defined by : Count_week[i]- count_week[i+1]/count_week[i] You can use by to process by event, then for each week you split your time series by week ( the difficult part). by(subret,subret$event_name,function(x){ nn <- nrow(x) x.week <- split(x$count,cut(seq(nn), c(seq(0,nn,7),max(nn)))) ll <- length(x.week) res <- if(ll >1) lapply(seq(ll-1),function(y){ x.week[[y]]-x.week[[y+1]]/x.week[[y]] }) else NA }) [1]] [1] 1.000000 2.000000 6.857143 5.166667 10.818182 1.750000 0.750000 [[2]] [1] 0.000000 -1.666667 -14.000000 2.800000 -1.500000 8.777778 12.692308

Categories : R

Aggregation by time period in lubridate
I don't know why you'd use lubridate for this. If you're just looking for something less awesome than xts you could try this tapply(bikecounts$Northbound, as.Date(bikecounts$Date, format="%m/%d/%Y"), sum) Basically, you just need to split by Date, then apply a function. lubridate could be used for creating a grouping factor for split-apply problems. So, for example, if you want the sum for each month (ignoring year) tapply(bikecounts$Northbound, month(mdy_hms(bikecounts$Date)), sum) But, it's just using wrappers for base R functions, and in the case of the OP, I think the base R function as.Date is the easiest (as evidenced by the fact that the other Answers also ignored your request to use lubridate ;-) ). Something that wasn't covered by the Answer to the other Question lin

Categories : R

Is it possible for an application to uninstall itself after a period of time?
First of all, uninstall app automatically is not good way. Try to disable all features. Generally, you need the following algorithm: 1) On starting your app (for example in first activity) get SharedPreferences (http://developer.android.com/reference/android/content/SharedPreferences.html) and check key with date of first start (for example "firstStartDate"). Also, reads key "lastStartDate". 2) If key "firstStartDate" doesn't exist - it's first start of your app, get current date and write it as value of both keys, than continue normal work of app. 3) If key "firstStartDate" exists - get current date and check that your trial is not expired (claculate days count between first start and current date). Also, check that current date is more or equal date in "lastStartDate" (protection f

Categories : Android

Increment a date by some time period
Use lubridate::days > require(lubridate) > Sys.Date() [1] "2013-08-23" > Sys.Date() + days(1) [1] "2013-08-24" > ISOdate(2013, 8, 23) [1] "2013-08-23 12:00:00 GMT" > ISOdate(2013, 8, 23) + days(1) [1] "2013-08-24 12:00:00 GMT" With lubridate, you can also use years(), seconds(), etc., or define your own duration.

Categories : R

how to get the count ONLY in a specific time period
This should return the count of plates meeting your criteria SELECT COUNT(*) plate_count FROM (SELECT plate FROM anpr_in WHERE location='a35.1.ob.1' AND DATE(time) BETWEEN '2012-07-24' AND '2012-09-02' GROUP BY plate HAVING COUNT(*) > 10) x SQLFIDDLE You don't need DISTINCT because GROUP BY already reduces it down to distinct plate numbers.

Categories : Mysql

Move sprite over period of time
This has to do with integer division. Your screen width is presumably TritonForge.pixel.width? When dividing this by dayTime it will probably always equal zero as your screen is not 7,500 pixels (again assuming here.) This is because integer division rounds down to the nearest whole number. Say your screen is 1200 pixels. 1200 / 7500 = .16. That rounds down to 0. So instead change your code too... double x; x = (TritonForge.pixel.width / (double)dayTime) * dayFrame; And cast x to an int as appropriate.

Categories : Java

How do I count items for some time period?
require 'time' def group_by_period(items) groups = { :day => {}, :hour => {}, :t20min => {} } items.reduce(groups) do |memo, item| # Compute the correct buckets for the item's timestamp. timestamp = Time.parse(item[2]).utc item_day = timestamp.to_date.to_s item_hour = timestamp.iso8601[0..12] item_20min = timestamp.iso8601[0..15] item_20min[14..18] = (item_20min[14..15].to_i / 20) * 20 # Place the item in each bucket. [[:day,item_day], [:hour,item_hour], [:t20min,item_20min]].each do |k,v| memo[k][v] = [] unless memo[k][v] memo[k][v] << item end memo end end sample_db_output = [ [1, 'foo', '2010-01-01T12:34:56Z'], [2, 'bar', '2010-01-02T12:34:56Z'], [3, 'gah', '2010-01-02T13:34:56Z'], [4, 'zip', '2010-01-02T

Categories : Ruby

First and last record for a user in a given time period in one query
This is something that you could consider: SELECT t.id, t.user_id, t.date, t.other_columns FROM table t WHERE user_id = 1 AND date = ( SELECT MIN(date) FROM table WHERE user_id = t.user_id AND date > DATE_SUB(CURDATE(), INTERVAL 24 HOUR)) UNION ALL SELECT id, user_id, date, other_columns FROM table WHERE user_id = 1 AND date = ( SELECT MAX(date) FROM table WHERE user_id = t.user_id AND date > DATE_SUB(CURDATE(), INTERVAL 24 HOUR))

Categories : Mysql

App closing unexpectedly after a long period of time
You can't really stop your app getting killed by the OS. Android is designed in such a way to manage apps that are not being actively used. In your case, if you are planning to do something in the background, a background service is the ideal place to achieve that. You can never ensure that you app remains active all the time.

Categories : Android

R - get the most common string value (mode) for a given time period
Using ddply from plyr ddply(Data, .(timeblock, groupname, someuser), function(x){as.character( unique( x$groupname[x$someuser== names(which.max(table(x$someuser))) ] ) ) } ) timeblock groupname someuser V1 1 1 blue bob blue 2 1 blue sally blue 3 1 green bob green .........

Categories : String

Programmatically selecting a period of time in Fullcalendar
So I've got your answer (I needed something very similar and stumbled across this when looking for help). We need to think outside of FullCalendar and the DOM for a minute. FullCalendar uses MomentJS, and this is about to come in handy (this wasn't included in your example, and you need it for the following). First, you need to create an array of either weekends or weekdays. I did so for the next 365 days (next full year). Example of Array of weekends using MomentJS: $('#weekends').click(function() { weekend_array = new Array(); var cal = $('#calendar').fullCalendar('getCalendar'); var curr_moment = moment(cal); for(k=0; k<365; k++) // for the next 365 days (next year) { // if weekend if(curr_moment.day()==0 || curr_moment.day()==6) // 0 being S

Categories : Javascript

End a session after a period of time if the page has been inactive - PHP
Where did you define $_SESSION['start' ]? I test this: $session_life = time() - $_SESSION['start']; echo $session_life ,' - ', $_SESSION['timeout']; die(); And both $session_life and $_SESSION['timeout'] has the same values so the question is, which value takes $_SESSION['start']?

Categories : PHP

Transition after a certain period of time in state machine
To break the solutions into two major groups, you can: Use a Ruby/Rails queueing solution, like DelayedJob, Resque, or Sidekiq; or, Use a cronjob. The former tends to make the most sense if you're already using one of those tools or know you're going to end up using one of them. All of them require a fairly substantial amount of effort to get going. Resque and Sidekiq require configuring a Redis server while DelayedJob uses your existing database. Resque additionally requires a plugin to schedule jobs, while DelayedJob and Sidekiq natively support scheduling a job. All three require creating job models and configuring workers to run. The latter's pretty simple assuming you have cron access. Write yourself up a script in Ruby, and schedule it to run automatically via cron. I haven't u

Categories : Ruby On Rails

Determining Rows Inserted After A Period of Time
Could you try something like this? This should take the time manipulation out of the linq. DateTime time = DateTime.Now.AddSeconds(-30) var student = (from x in db.Students where x.Name == name && x.InsertTime < time select x).ToList();

Categories : Misc

Waiting a period of time between method executions
var whoseTurn = 0; while (true) { setTimeout(takeTurn(players[whoseTurn]), 500); whoseTurn = (whoseTurn + 1) % 3; } So.. This will create a timer, then increment the turn in a tight loop. And it's not even calling takeTurn because you are calling it (by supplying arguments). Not what you want. One fix would be to call setInterval, and increment the turn at the end of each go-round. But that doesn't let the turns be variable-length. (I.e. if it takes 100ms, then the next turn will come in 400ms. The correct way to structure it is to kick off the first turn once, then kick off a timer at the end of each turn: function takeTurn() { player = players[whoseTurn]; //Now taking a turn whoseTurn = (whoseTurn + 1) % 3; setTimeout(takeTurn, 500); } setTimeout(tak

Categories : Javascript

How can I wait for a period of time after a button is clicked?
Use a CountDownTimer: CountDownTimer timer = new CountDownTimer(4000, 1000) { @Override public void onFinish() { *function containing the second statement* } @Override public void onTick(long millisLeft) { // not ticking } }; and in the onClick method in the click listener use: timer.start();

Categories : Android

Running a background agent with in particular period of time in a day in WP8
The only option available to you is the ScheduledAgent. When the OnInvoke(ScheduledTask task) method is invoked just check that the current time is within the range you are interested in (8AM to 8PM). If it is then go ahead and do your processing. If it is not just call NotifyComplete() and return.

Categories : Windows Phone 8

Strange behavior with Joda-Time in period calculation
Why do you think that this result is incorrect? Month is not number of days. Month is abstract unit So last day of month plus month is last day of next month and not the first day of month after next month. Why do you think that 30/05/2013.plusMonths(9) = 28/02/2014 //incorrect result should be 01/03/2014 why not 02/03/2014? You are wrong in your hypothesis. Joda time works well in your example

Categories : Java

Private bytes memory increases over the period of time
There's no quick fix for this, especially in C++ memory maintenance is something you have to practice throughout the development process, not slap on at the end. And since it could be virtually anywhere in your code (no pun intended), it's not really practical to post code here. My only advice is to look for use of the new operator, and make sure that there is an accompanying delete. Also using unit tests on your classes/functions/etc. can help narrow down the problem. Good luck.

Categories : C++

How to check a timeperiod is overlapping another time period in java
JOda Time has this functionality baked in. It's very well-built and on JSR route to replace the broken Java Calendar API. You should probably considering using it.

Categories : Java



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.