Skip to content

Instantly share code, notes, and snippets.

@mo-karbalaee
Last active October 27, 2025 13:06
Show Gist options
  • Select an option

  • Save mo-karbalaee/30ad922206e52ba9fc033df86b12099d to your computer and use it in GitHub Desktop.

Select an option

Save mo-karbalaee/30ad922206e52ba9fc033df86b12099d to your computer and use it in GitHub Desktop.

Revisions

  1. mo-karbalaee revised this gist Oct 27, 2025. No changes.
  2. mo-karbalaee revised this gist Oct 27, 2025. 2 changed files with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions count_down.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    ```countdown-to
    title: Semester Period
    startDate: 2025-10-01
    startTime: 08:00:00
    endDate: 2026-03-29
    endTime: 14:00:00
    type: circle
    color: #ff5722
    trailColor: #f5f5f5
    infoFormat: {percent}% complete - {remaining} until {end:LLL d, yyyy}
    updateInRealTime: true
    updateIntervalInSeconds: 30
    ```
    File renamed without changes.
  3. mo-karbalaee created this gist Oct 27, 2025.
    47 changes: 47 additions & 0 deletions template.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    ```dataviewjs
    // Get all tasks in the current note
    let tasks = dv.current().file.tasks;
    // Store counts in variables
    let totalTasks = tasks.length;
    let completedTasks = tasks.filter(t => t.checked).length;
    let notCompletedTasks = tasks.filter(t => !t.checked).length;
    // Compute ratio of undone/done if needed
    let ratioUndoneToDone = notCompletedTasks / completedTasks;
    // Now all numbers are stored in variables and can be used in code
    // Example: using them in a string
    let statusSummary = `Total: ${totalTasks}, Completed: ${completedTasks}, Not Completed: ${notCompletedTasks}, Ratio Undone/Done: ${ratioUndoneToDone}`;
    statusSummary // this line "returns" the string in the note
    ```

    ```dataviewjs
    // Get tasks
    let tasks = dv.current().file.tasks;
    let totalTasks = tasks.length;
    let completedTasks = tasks.filter(t => t.checked).length;
    let notCompletedTasks = totalTasks - completedTasks;
    // Calculate ratio
    let ratio = totalTasks === 0 ? 0 : completedTasks / totalTasks;
    // Progress bar styling
    let barWidth = 300; // total width in pixels
    let filledWidth = barWidth * ratio;
    // Generate HTML progress bar
    let htmlBar = `
    <div style="background-color:#eee; border-radius:8px; width:${barWidth}px; height:20px; overflow:hidden;">
    <div style="background-color:#4caf50; width:${filledWidth}px; height:100%; transition: width 0.3s;"></div>
    </div>
    <div style="margin-top:4px; font-weight:bold;">${completedTasks}/${totalTasks} completed</div>
    </div>
    `;
    // Render HTML
    dv.el("div", htmlBar, {allowHTML: true});
    ```