Snippets Collections
var secondsRemaining = 60    
Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { (Timer) in
        if secondsRemaining > 0 {
            print ("\(self.secondsRemaining) seconds")
            secondsRemaining -= 1
        } else {
            Timer.invalidate()
        }
    }
import React, { useState } from "react";
import "./App.css";

const App = () => {
  const [counterA, setCounterA] = useState(0);
  const [counterB, setCounterB] = useState(0);

  return (
    <div>
      <button
        onClick={() => {
          setCounterA(counterA + 1);
        }}
      >
        Increment A
      </button>
      <button
        onClick={() => {
          setCounterB(counterB + 1);
        }}
      >
        Increment B
      </button>
      <div>counterA: {counterA}</div>
      <div>counterB: {counterB}</div>
    </div>
  );
};

export default App;
from collections import defaultdict, namedtuple, Counter, deque

Counter(words).most_common(6)
function animationInterval(ms, signal, callback) {
  // Prefer currentTime, as it'll better sync animtions queued in the
  // same frame, but if it isn't supported, performance.now() is fine.
  const start = document.timeline
  ? document.timeline.currentTime
  : performance.now();

  function frame(time) {
    if (signal.aborted) return;
    callback(time);
    scheduleFrame(time);
  }

  function scheduleFrame(time) {
    const elapsed = time - start;
    const roundedElapsed = Math.round(elapsed / ms) * ms;
    const targetNext = start + roundedElapsed + ms;
    const delay = targetNext - performance.now();
    setTimeout(() => requestAnimationFrame(frame), delay);
  }

  scheduleFrame(start);
}
star

Wed Apr 05 2023 15:59:39 GMT+0000 (Coordinated Universal Time) https://codetogo.io/

#javascript #counter #count
star

Tue Feb 01 2022 07:12:29 GMT+0000 (Coordinated Universal Time)

#ios #swift #timer #counter #count #countdown
star

Wed Jun 30 2021 08:17:32 GMT+0000 (Coordinated Universal Time)

#react.js #usestate #setstate #counter
star

Wed May 26 2021 18:02:58 GMT+0000 (Coordinated Universal Time)

#python #counter
star

Sat Mar 27 2021 13:23:33 GMT+0000 (Coordinated Universal Time)

#javascript #counter #timer

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension