Multi colored reflection in space with data boxes being pulled towards a void

Tracking 100 Days To Offload

  • Adam Douglas

It is the second time around that I’m participating in the 100 Days to Offload challenge and this time around I’m now determined to meet the goal of 100 posts or at least come dang near to it. Saying this though, it is only been since November 29, 2022 that out of know where I’ve been posting every single day without fail making it 13 days in a row. Though it seems like a small achievement, I’m personally thrilled that I’ve been able to come up with something to write about without any issues. Honestly, I have so many ideas I can’t keep up. This is all a good thing, so I decided to reflect on why is it that I agreed and wanted to do this challenge, yet I’ve only done 50 posts thus far and deadline is fast approaching on January 14, 2022.

Discovering The Problems

Finding the issues as to why I’ve not been making posts has been tough. I’m just not certain the two reasons I found are the only ones. Either way the one issue is, I’ve been doing so many things in my life that I’ve made myself feel overwhelmed and as a result I’ve put this challenge on the bottom of my list even though it should be close to the top of my list as this challenge contributes to my job as a content creator. The second issue is that I’ve not been keeping track of my progress in the challenge and therefore for me at least takes me away from focusing on achieving the intended goal.

Resolving The Problems

To fix the first issue, I need to reduce the amount of tasks, projects, volunteering, etc. in my life and also make sure to use task management tools consistently to help remove the feeling of being overwhelmed. As a result this should help me to create healthy boundaries, which honestly we should all have in our lives. So far this has been working, and I believe once I have a major project I’m working on done that will relieve a lot of stress for me. Now the second issue, I’ve not fully completed, however it will do for now until I have exactly what I want. What I did was create a simple Bash script that looks at all the posts I’ve done and return statistics for the 100 Days to Offload challenge as well as general overall statistics for my website.

Stats Script

The script only requires four settings, website build directory, website posts directory, website drafts directory and the start date for 100 Days to Offload challenge. Once these settings have been configured, the script is ready to use.

Requirements to run the script is very minimal with using, Jekyll, Bash, date and du. As well, the published date must be within the file name (e.g. 2022-12-11-tracking-100-days-to-offload) and formatted as “YYYY-MM-DD” (YYYY = 4 digit year, MM = 2 digit month, DD = 2 digit day). The reason the date is taken from the file name is because, the file creation date is not always representative of when a post was published. As long as the date is stored within the file name this code should work with just about any static website.

Presently the following statistics are supported.

100 Days to Offload Stats

  • Start Date
  • End Date
  • Total Posts
  • Total Remaining Posts

General Stats

  • Total posts
  • Total post drafts
  • Total website disk usage

Script Code

Before running the script, make sure to have the execute permission set on the file name (e.g. $ chmod +x stats).

#!/usr/bin/env bash
dirBuild="/home/adam/dev/adamsdesk.com/_site"
dirPosts="/home/adam/dev/adamsdesk.com/_posts"
dirDrafts="/home/adam/dev/adamsdesk.com/_drafts"
#100 Days to Offload start date, value formatted as YYYYMMDD
startDate=20220114
endDate="$(date -d "$startDate+1 year" "+%Y%m%d")"

prepare() {
    validateConfig
    getStats
}
validateConfig() {
    if [[ -z "$dirBuild" ]]
    then
        quit "The configuration setting \"dirBuild\" is not defined."
    fi
    if [[ -z "$dirPosts" ]]
    then
        quit "The configuration setting \"dirPosts\" is not defined."
    fi
    if [ -z "$dirDrafts" ]
    then
        quit "The configuration setting \"dirDrafts\" is not defined."
    fi
    if [ -z "$startDate" ]
    then
        quit "The configuration setting \"startDate\" is not defined."
    fi
    if [ ! -d "$dirBuild" ]
    then
        quit "The directory '$dirBuild' was not found or permission was denied. The operation has been halted."
    fi
    if [ ! -d "$dirPosts" ]
    then
        quit "The directory '$dirPosts' was not found or permission was denied. The operation has been halted."
    fi
    if [ ! -d "$dirDrafts" ]
    then
        quit "The directory '$dirDrafts' was not found or permission was denied. The operation has been halted."
    fi
}
getStats() {
    getPostCount
    getDraftCount
    getDiskUsage
}
getPostCount() {
    postCount=0
    postCountChallenge=0
    for post in "$dirPosts"/*.md;
    do
        [[ -e "$post" ]] || continue

        postContents="$(cat "$post")"
        post="${post##*/}"
        post="${post:0:4}${post:5:2}${post:8:2}"
        if [[ "$postContents" =~ .*\-\ 100DaysToOffload.* ]] && [ "$post" -ge "$startDate" ] && [ "$post" -le "$endDate" ]
        then
                ((postCountChallenge++))
        else
            ((postCount++))
        fi
    done
    postCount="$((postCount+postCountChallenge))"
}
getDraftCount() {
    draftCount=0
    for drafts in "$dirDrafts"/*.md;
    do
        [[ -e "$drafts" ]] || continue
        draft="${drafts:10}"
        if [ "${draft:1:4}" != 'tpl-' ] && [ "${draft:1}" != 'reminders.md' ]
        then
            ((draftCount++))
        fi
    done
}
getDiskUsage(){
    diskUsage="$(du -hs $dirBuild | cut -f1)"
}
displayStats() {
        printf "\n%b\n" "\033[1m100 Days to Offload Stats\033[0m"
        printf "\t%s %s\n" "Start Date:" "$(date -d "$startDate" "+%B %d, %Y")"
        printf "\t%s %s\n" "End Date:" "$(date -d "$endDate" "+%B %d, %Y")"
        printf "\t%s\n" "Total Posts: $postCountChallenge"
        printf "\t%s\n" "Total Remaining Posts: $((100-postCountChallenge))"
        printf "\n%b\n" "\033[1mGeneral Stats\033[0m"
        printf "\t%s\n" "Total Posts: $postCount"
        printf "\t%s\n" "Total Post Drafts: $draftCount"
        printf "\t%s\n\n" "Total Disk Usage: $diskUsage"
}
quit() {
    if [[ "$1" = 0 ]]
    then
            exit 0
    else
            printf "%b\n" "\033[1mError:\033[0m $1"
            exit 1
    fi
}

prepare
displayStats

Example Output

$ ./stats
100 Days to Offload Stats
    Start Date: January 14, 2022
    End Date: January 14, 2023
    Total Posts: 50
    Total Remaining Posts: 50

General Stats
    Total Posts: 98
    Total Post Drafts: 49
    Total Disk Usage: 26M

Closing Thoughts

I believe with the changes I’ve made and by using of the stats script I will be better equipped to remain on track and focus on achieving the goal I personally chose to participate in. I admit it’s going to be tight to get 100 posts by the deadline, but at least I’m challenging myself and learning along the way.

How do you track your 100 Days to Offload progress? What challenges have you faced in participating in the 100 Days to Offload challenge? I would love to hear your thoughts and experiences by contacting me.

This is post 50 of 100, and is round 2 of the 100 Days To Offload challenge.

    • update for clarity
    • correct tag name
    • Add filter post by tag 100DaysToOffload for getPosts()
    • change 100DaysToOffload message