Skip to content

Instantly share code, notes, and snippets.

@kotarou3
Created October 17, 2014 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kotarou3/e2fd20ed9e86730446ed to your computer and use it in GitHub Desktop.
Save kotarou3/e2fd20ed9e86730446ed to your computer and use it in GitHub Desktop.
Randomises the due dates of the cards in a deck, but only bringing them closer to being due. Run in Anki's REPL console (ctrl+:)
# Randomises the due dates of the cards in a deck, but only bringing them closer to being due
# Run in Anki's REPL console (ctrl+:)
from random import random
from math import floor
deckName = u"わかった!"
for cid in self.col.decks.cids(self.col.decks.byName(deckName)["id"], True):
card = self.col.getCard(cid)
due = abs(card.due - self.col.sched.today)
isDuePositive = card.due - self.col.sched.today >= 0
if due >= 2:
adjustment = floor(random() * (due / 2 + 1))
card.due = (due - adjustment) * (1 if isDuePositive else -1) + self.col.sched.today
card.flushSched()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment