Added build script, templates and readings doc.

This website is now statically built in place using Jinja2 templates and
markdown. Tidy is an optional dependency which makes the markup more
standardized. Since index.html is now a build artifact, it is .gitignored.
This commit is contained in:
Dakota Blair 2020-09-22 21:29:49 -04:00
parent 381383764e
commit d3ca53795d
7 changed files with 120 additions and 31 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
index.html

View File

@ -1,31 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Dakota's tilde.club</title>
<link rel="stylesheet" type="text/css" href="tilde.css" media="screen" />
</head>
<body>
<header>
<h1>David Dakota Blair</h1>
<ol>
<h2>Table of Contents</h2>
<li>About</li>
<li>Fun bash one liners</li>
</ol>
</header>
<section>
<h1>About</h1>
This is Dakota's tilde.club page.
</section>
<section>
<h1>Fun bash one liners</h1>
<dl>
<dt>Print a few random numbers</dt>
<dd>od -d &lt; /dev/random | awk '{ print $2 }' | head</dd>
</dl>
</section>
</body>
</html>

84
index.tmpl.html Normal file
View File

@ -0,0 +1,84 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Dakota's tilde.club</title>
<link rel="stylesheet" type="text/css" href="tilde.css" media="screen" />
<script src="tilde.js" async defer crossorigin="anonymous"></script>
</head>
<body>
<header>
<h1>David Dakota Blair</h1>
<h2>Table of Contents</h2>
<ol>
<li><a href="#about">About</a></li>
<li><a href="#bash">Fun bash one liners</a></li>
<li>
<a href="#readings">Readings</a>:
<a href="#2020">2020</a>
<a href="#2019">2019</a>
<a href="#2018">2018</a>
<a href="#2017">2017</a>
<a href="#2016">2016</a>
<a href="#2015">2015</a>
</li>
</ol>
</header>
<hr />
<section id="about">
<h1>About</h1>
This is Dakota's tilde.club page.
</section>
<hr />
<section id="bash">
<h1>Fun bash one liners</h1>
<dl>
<dt>Print a few random numbers</dt>
<dd>od -d &lt; /dev/random | awk '{ print $2 }' | head</dd>
</dl>
<dl>
<dt>A simple awk for isolating columns</dt>
<dd>awk '{print $2}'</dd>
</dl>
<dl>
<dt>Find lines containing literal tabs</dt>
<dd>awk '/\t/'</dd>
<dd>grep -P</dd>
</dl>
<dl>
<dt>Remove all tab characters</dt>
<dd>tr -d '\t'</dd>
</dl>
<dl>
<dt>Join files using a tab separator</dt>
<dd>join -t $'\t' file1 file2</dd>
</dl>
<dl>
<dt>Simple system benchmarks</dt>
<dd>yes | sed '=' | sed '/y/d'</dd>
<dd>time seq -n 1e6</dd>
</dl>
<dl>
<dt>What shell am I using?</dt>
<dd>lsof -p $$</dd>
</dl>
<dl>
<dt>See which processes are listening to a $PORT</dt>
<dd>netstat -pntl | grep $PORT # linux</dd>
<dd>lsof -nP -iTCP:$PORT | grep LISTEN # os x</dd>
</dl>
<dl>
<dt>Useful flags for rsync</dt>
<dd>rsync -h --progress --stats --verbose</dd>
</dl>
<dl>
<dt>Recover files from a slightly corrupted tar archive</dt>
<dd>cpio -ivd -H tar &lt; file.tar</dd>
</dl>
</section>
<hr />
<section id="readings">
{{readings}}
</section>
</body>
</html>

25
publish.py Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env python
import io
from subprocess import run
import markdown
from jinja2 import Template
def main():
tidy_exists = run(["which", "-s", "tidy"]).returncode == 0
with open("readings.md") as readings, open("index.tmpl.html") as tmpl:
readings_html = markdown.markdown(readings.read())
template = Template(tmpl.read())
out = template.render(
readings=readings_html
)
with open("index.html", "w") as outfile:
outfile.write(out)
if tidy_exists:
run((
"""tidy --quiet yes -modify -config tidy.conf index.html"""
).split(" "))
if(__name__ == "__main__"):
main()

1
readings.md Normal file
View File

@ -0,0 +1 @@
# Readings

3
requirements.txt Normal file
View File

@ -0,0 +1,3 @@
Jinja2==2.11.2
Markdown==3.2.2
MarkupSafe==1.1.1

6
tidy.conf Normal file
View File

@ -0,0 +1,6 @@
doctype: html5
indent: yes
indent-spaces: 1
quiet: yes
repeated-attributes: keep-last
wrap: 76