I often use GitHub Gists to jot down quick snippets to share. Lately, I've also tried to make sure an add a proper README (and a LICENSE!) - partially so that readers have some context on what they're looking at, but also so I can remember what the heck I was doing when I wrote whatever code I've slung out there.
Gists are horrible for discoverability, and I always forget the neat things I've hacked together. I wanted a section on my website with at minimum links, but hopefully the actual content from some of my "better" gists - with better defined as:
- is a gist that I've starred
- is one of my own gists
- has a
README.md - is newer than 2017-01-01
I spent a little bit of time today hacking this together with bash, curl, and jq! I think it qualifies as just hacky enough to use as an example to validate this insane workflow :)
All the work happens in pull-gists.sh. A brief walkthrough:
- Hit the GitHub API to look for my starred gists
- (ab)use jq to filter down to gists where I'm the owner, it's newer than a given date, and has a
README.md - Iterate over the gists & extract a bunch of properties
- Write out some frontmatter (I'm using Hugo for my blog) to a file per gist / post
- Download the README as the post content
- A Hugo template adds embed script tags for each interesting file. (The README has already been added, and the LICENSE is just spam on a blog post)
On the backend, I'm currently hosted on Azure Storage + an Azure Function proxy as my frontend. The Hugo site gets built in Azure DevOps per-commit to master for regular posts. And I now have a daily build trigger to pick up new starred gists.
Putting it all together, this hacked together mess means I have a way to draft blog posts on https://gist.github.com/, then star them when I'm ready for them to go out. I'm pretty happy with this - I hope it sparks some interesting ideas for you as well!
NISN;Nama Lengkap;Tempat Lahir;Tanggal Lahir;KETERANGAN;;;
0132268377;AKHSANUL MIRZA;KARAWANG;2013-11-02;LULUS;;;
3130817303;AL RIZAL ARIF PUTRA;PASURUAN;2013-12-27;LULUS;;;
0141513277;AMIRAH MYESHA AZZAHRA;MOJOKERTO;2014-05-31;LULUS;;;
0136827752;DHUROTUN NASIKHA;PASURUAN;2013-06-29;LULUS;;;
0137278131;KHAYLAH AZIZATUL MAGHFIROH;PASURUAN;2013-05-29;LULUS;;;
0147013352;LAILI ZAKIYA;PASURUAN;2014-02-20;LULUS;;;
3131975283;MELA DWI BUDINENGTYAS;PASURUAN;2013-09-21;LULUS;;;
3141419771;MOCH. SYAHRADIT MAULANA;PASURUAN;2013-01-11;LULUS;;;
3132487468;MUHAMMAD AL FARIZI;PASURUAN;2013-03-03;LULUS;;;
0131861712;SYIFA' AULIYA';MOJOKERTO;2013-06-19;LULUS;;;
3134871172;DELLVA PUTRI MAHARANI;PASURUAN;2013-07-05;LULUS;;;
3125261227;HILMI ZIAN HABIBIE;PASURUAN;2013-10-27;LULUS;;;
3134954830;SULTAN ALMAS AL ABQORI;PASURUAN;2013-10-17;LULUS;;;