Skip to content

Instantly share code, notes, and snippets.

@hungsu
Last active May 24, 2023 05:40
Show Gist options
  • Save hungsu/9ccdc3ace1408608c2f1f117b6de59af to your computer and use it in GitHub Desktop.
Save hungsu/9ccdc3ace1408608c2f1f117b6de59af to your computer and use it in GitHub Desktop.
One random note from my to read list
var seedNotes = dv.pages('"Private/Urgent"').file.filter(function(note){return note.name !== "_Index"})
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min) + min); //The maximum is exclusive and the minimum is inclusive
}
var randomNoteIndex = getRandomInt(0, seedNotes.length)
var randomNote = seedNotes.filter(function(note,index){return index == randomNoteIndex})
dv.paragraph("Embed below:");
console.log(randomNote)
dv.paragraph("![["+randomNote.values[0].path+"]]")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment