Git styled calendar with custom dates
git styled calendar created from list of dates saved as csv file
Daniel Gustaw
• 2 min read
Let us assume that you have a set of dates. You want to display these dates in a readable clear way.
For example like this:
So I have great info. It is one line of code, maybe two…
In this article I will show how to generate an image like these.
What do you need?
- jq - great toll for json / text processing
- node - js interpreter
- awk - text processor for selecting data
Installation
npm i -g cli-gh-cal
Preparing file with dates
We want to prepare a file with dates like these
2019-08-13
2018-05-19
2018-06-22
2019-04-16
Allow us to assume that you need to show dates of creation of files in your folder with photos. You can do it using the command
ls -l --time-style=long-iso . | awk '{print $6}' | sort > /tmp/dates.csv
Option --time-style
allows showing dates in easy to the processing format. Next awk
selects column with dates and sorted dates are saved in temporary file /tmp/dates.csv
.
Displaying git styled calendar
Now if you want to display these dates, you need to type
cli-gh-cal --data "$(jq -R '[inputs | [.,1] ]' < /tmp/dates.csv)"
In this case, we put to work jq
- powerful templater for json files. It allows replacing the list of dates to json string required by cli-gh-cal
. After executing this command you should see an image similar to presented at the beginning.
Required packages
To work there, have to be installed node
. I recommend installing it with nvm
on the local machine.
https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-18-04
Next package - cli-gh-cal
can be installed by npm
- node packages manager
Finally, you need also jq
I hope you like this article. For me, it is a great example of how a small amount of code is needed to achieve great-looking results in data visualization today. Wow!
Screenshot from my console
Other articles
You can find interesting also.
tRPC - super fast development cycle for fullstack typescript apps
We building tRPC client and server with query, mutation, authentication and subscriptions. Authentication for websocket can be tricky and it is in this case so there are presented three approaches to solve this problem.
Daniel Gustaw
• 15 min read
Installation of a renewable TLS certificate (certbot + apache on Ubuntu)
There are many methods to obtain a certificate that allows encrypting HTTP traffic. One of them is installing Certbot and using it in conjunction with the Apache server.
Daniel Gustaw
• 2 min read
Rust implementation of RFC 7396 - JSON Merge Patch
Rust's speed and reliability make it ideal for implementing JSON Merge Patch, as defined in RFC 7396. This specification enables efficient and safe partial updates to JSON documents.
Daniel Gustaw
• 10 min read