Questions tagged [timer]

This tag is for questions about using timers in code to make things happen in a certain order or for gathering amount of time elapsed.

0
votes
1answer
26 views

Suppress API call in Redux Saga based on a timer

I have an API that provides data that is updated on an infrequent schedule, about once every 2½ minutes on average. Assuming that it's okay to fetch only as often as every 2½ minutes or less often, I'...
4
votes
0answers
57 views

Game clock with configurable rate

Edit: Licensed source can be found here. The intent behind this class is to allow different game systems to run at their own clock rate. The physics integration rate should not be connected to the ...
1
vote
0answers
115 views

Timer queue with chrono

I would like to make the timer queue: 1. Each timer has id, time expired and callback to call 2. Queue stores timer and execute the callback of each timer whenever expired. Here is my code and demo: ...
8
votes
1answer
86 views

Quiz game with timer

This is my first Go program. I would like to know what could be improved, what is done wrong, and anything else that I should know. The CSV contains 10 questions with the 10 answers separated by a ...
3
votes
1answer
69 views

Tkinter stopwatch

As part of a personal project, I wanted to make a stopwatch with Python. I wish to show my friend but at the moment it is a little messy and long. Is there any way to make it more compact or easier to ...
7
votes
2answers
117 views

Pausable Timer Implementation for SDL in C

Problem I've written a timer module in C for an SDL game. I'd like to get some eyeballs on. I wrote this for 2 requirements: I needed a timer that would signal on an elapsed interval, AND that was ...
2
votes
1answer
202 views

A countdown clock in TypeScript

The gist of the code is, you give it a date, it will start counting down how many days, hours, minutes and seconds left by emitting an event 'countDown' and once 0 is reached 'expired' event is ...
3
votes
1answer
172 views

C# Timed buffer

Purpose of this code is to have buffer which will batch messages based on configured timeout. For example, one thread will continuously push data to this buffer, and when configured timeout pass, it ...
5
votes
1answer
216 views

Algorithm to find the number of years, months, days, etc between two dates

I've been working on this one for a while. Took me a while to figure out all the logic rules for dates and months. The goal of this method is to return the number of years, months, days, hours, ...
1
vote
1answer
37 views

A simple Java class for implementing code stop watches - follow-up

I have received a nice answer for this post. Now, it is my attempt for some improvement: ...
1
vote
1answer
57 views

A simple Java class for implementing code stop watches

(The next iteration: A simple Java class for implementing code stop watches - follow-up) Here is my attempt at more convenient benchmarking (yes, this time I am aware of JVM warmup, etc.), and it ...
2
votes
1answer
81 views

Stopwatch utility class in Java

Looking for input on my code for a Stopwatch utility written in Java. ...
5
votes
2answers
87 views

Frame limiting in an SDL game

I am a relatively novice programmer, and I am taking steps into graphics programming. I am writing a quick pong clone and want to cap the FPS to save system resources. This is how I have implemented ...
1
vote
1answer
55 views

Timed arithmetic quiz

In this program you have to solve 20 exercises. The time you need will be measured. If you break a record, you'll get an entry in the highscore list. The program can be downloaded here. You can only ...
3
votes
1answer
48 views

Pomodoro countdown timer synced to the clock

This countdown timer is supposed to: be synced to the user's clock at every hour and half hour, will start a 25 minute countdown followed by a 5 minute break The code works but I question its ...
1
vote
1answer
570 views

Dispatching Vuex getter via setInterval

I am fetching the friend list for a chat application using a Vuex store. I need to dispatch the getter via an interval. Is there a best practices way to do this? ...
1
vote
0answers
104 views

C++ embedded application to control a light with a timer

I enhanced the my daughter's bed light to IoT. Specifically I can turn the light on/off remotely and there is a timer & alarm function. All of this is implemented with a Particle Photon. This ...
4
votes
2answers
181 views

Sleep until specified time

It's sometimes useful to pause until a specified time (but inconvenient to use at or the like), so I wrote a tiny script to wait until a user-specified time point ...
2
votes
2answers
105 views

A 3 digit stopwatch

I decided to make a stopwatch as I decided it would be useful, and also as a challenge to learn more about how forms work. I'd just like some simple advice as to anything I can do better, thank you. <...
2
votes
2answers
86 views

React clock component

I'm new to React.js and this code came from 30 Days of React - Day 7. However the given code example wasn't working so I rewrote it myself. My biggest issue here is how to make the component work ...
3
votes
1answer
116 views

Using Threading.Timer to update a list of data

Attached is some code I have written for my application. It is an OWIN based web server which connects an Alexa Custom Skill, my security camera feed, and Microsoft Azure Face API. The number one ...
0
votes
1answer
169 views

Pomodoro timer in React

I created a simple Pomodoro timer using React JS. In my example: Timer should count down seconds until it reaches 00:00 Timers should switch between 25 and 5 minutes Timer should be able to start, ...
3
votes
1answer
74 views

JavaScript flipping clock

Here are two simple classes - Digit class maintains digit behaviour - primarily flipping animations, and Clock class handles everything that is related to time data. I'm going to use this code for ...
4
votes
1answer
6k views

Countdown Timer in Python

I am a beginner in Python and I am yet to move on from the basics to things like OOP.I wrote all of this code (Python 3) in an hour or so for a simple countdown timer.Although some parts of it are ...
4
votes
2answers
125 views

Speed-cubing timer console application

This code is my first implementation of this style of application in the console. In essence a stopwatch with some added functionality. I was interested in getting some feedback before I refactor and ...
1
vote
0answers
51 views

Solidity code for TimeBasedWill (smart contract)

Following is a TimeBasedWill I have written in Solidity to be built on the Ethereum Blockchain. I have tested the code using Remix IDE. I would like to get your comments and opinions about security ...
11
votes
4answers
2k views

Countdown control with arc animation

I've implemented countdown timer control with arc animation that looks like this Implementation notes: For arc visualization I've created class Arc derived from <...
4
votes
1answer
67 views

Three versions of a counting-up timer in JavaScript

I made 3 versions of a counting-up timer in JavaScript: Version #1 All units of time (seconds, minutes, hours, and days) are updated every second, whether they change or not. Pro: Shorter code. ...
5
votes
1answer
3k views

Async friendly Timer

I'm trying to implement a Timer that schedule an async action with the following requirements: thread safe only one action should be running at any given time (period countdown should start when the ...
8
votes
3answers
9k views

Extremely simple timer class in C++

A very bare-bones timer class created using the std::chrono library. I would like to know if any optimisations are possible and just to clarity, I am using MSVC (...
3
votes
1answer
172 views

A rather accurate VBA stopwatch

Intro Related, related I'm trying to come up with a neat, accurate way of timing VBA code, as I'm yet to find a method to do this in VBA directly (without plugins etc.) The general idea was to ...
8
votes
1answer
154 views

A Simple Bash Timer

This is a timer I made quite some time ago and just came across it again today. I'm just wondering if there's anything wrong with it or anything I could improve. ...
5
votes
1answer
103 views

Scheduling using System.IObservable 2.0

As a follow up to this first attempt to create and use my own IObservable<T> implementation, this is version 2.0. The goal has been to correct the code where ...
4
votes
1answer
108 views

Scheduling using System.IObservable

With great inspiration from t3chb0ts ongoing work about scheduling, cron jobs etc. (last post here), I decided to make my own version of the Scheduler - using the observer pattern - as a learning ...
4
votes
0answers
126 views

Scheduler built with observables v2 (follow-up)

It would probably be too easy if the old Scheduler worked as intended being that simple. But an eye-openig review showed that from time to time it'll miss one ...
3
votes
1answer
4k views

Simple timer start and stop from console

Just a simple timer application for review. Stop and start the timer from the command line. The plan is to use this in a poker application to fold out a player if they don't act after a time ...
1
vote
1answer
109 views

Best accuracy and performance with timers in JS

Regular timers in JavaScript (setInteval & setTimeout) have two problems: They aren't as much accuracy as you can get in JS....
1
vote
1answer
77 views

UserScript to Highlight tab for queue item

It may seem a bit obsessive and/or pedantic, but the following script allows me to see when posts are ready for reviewing. I developed this UserScript for use with TamperMonkey to allow me to have a ...
1
vote
1answer
297 views

Multithreaded arithmetic quiz with 20-second time limit

I learned something about threads and I tried to use them in an programming exercise. The user of the program has to solve as many exercises as he can within twenty seconds. After that time the ...
3
votes
1answer
455 views

Multi-threaded Time Scheduler without polling

This is a quick shot at designing a time scheduler without polling. It is able to handle inputs which are to be executed earlier than already on the schedule. I want to improve it further, especially ...
11
votes
5answers
3k views

Stopwatch class

I am learning C# and I have an exercise: Design a class called Stopwatch. The job of this class is to simulate a stopwatch. It should provide two methods: Start and Stop. We call the start ...
30
votes
7answers
6k views

Car crash reaction time

In physics class we are doing an investigation thing. Some of the numbers might seem plucked out of thin air but they aren't. The maths is right(I think) I just want some feedback on the code. ...
4
votes
3answers
738 views

CHIP-8 delay timer in C++

I'm writing a CHIP-8 emulator in C++, which has two timers. If these timers are non-zero, they are decremented by 1 at 60Hz. I'm still getting the hang of C++, so I wanted to see if I'm doing this the ...
6
votes
1answer
211 views

Clock that changes document background color

This is a timer based clock (using setInterval()) that changes the background color of the body based on the clock time hexadecimal values. I suspect that this code ...
1
vote
1answer
610 views

Timer in JavaScript

This is my first JavaScript application (it's inspired by this timer). How could I improve it? I had to set the setInterval() to 980ms instead of 1000ms because it ...
11
votes
2answers
7k views

Progress Bar in C++

I made a simple progress bar with percentage counter for console applications in C++. Below is my code: ...
2
votes
1answer
191 views

A clock and a fortune: a full screen clock with random quotes in Tcl/Tk

I've written a small Tcl/Tk script for a friend that displays the current time, as well as a quote. He uses it in some project with a Raspberry Pi, and since I didn't want to cobble up something up in ...
4
votes
2answers
76 views

Measuring typing speed in terminal without a mistake

I tend to dislike my code. It's always a mess. I can't critique my own code though, because I just turn it into another mess. I've been programming slightly better every year, but this year it has ...
5
votes
1answer
3k views

Basic Countdown Timer

Below is a class,Countdown, that takes seconds as input from an entry, and starts counting down when the "Start" button is ...
4
votes
2answers
685 views

Countdown timer for new year

Please help me improve my code. Note that it runs just fine. Especially with the way I use SFML, I need lots of guidance since I've just started learning how to use this library. I'm still learning C++...