summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@gmail.com>2018-03-05 19:23:12 +0100
committerKévin Le Gouguec <kevin.legouguec@gmail.com>2018-03-06 07:12:58 +0100
commit46da44abbedc58b918fa78c022bde2afcdd3ef6e (patch)
tree31af272689994c2abff36fa198b729e57ba96cf7
downloadmemory-leaks-46da44abbedc58b918fa78c022bde2afcdd3ef6e.tar.xz
Add title page and word-count script
-rwxr-xr-xhooks/post-commit19
-rw-r--r--index.md9
-rwxr-xr-xupdate-count.sh22
3 files changed, 50 insertions, 0 deletions
diff --git a/hooks/post-commit b/hooks/post-commit
new file mode 100755
index 0000000..8e92990
--- /dev/null
+++ b/hooks/post-commit
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+if [ -f .UPDATING_COUNT ]
+then
+ exit 0
+fi
+
+echo "Checking word count…"
+
+./update-count.sh
+
+if git diff --quiet --exit-code -- index.md
+then
+ exit 0
+fi
+
+touch .UPDATING_COUNT
+git commit --amend --no-edit -- index.md
+rm .UPDATING_COUNT
diff --git a/index.md b/index.md
new file mode 100644
index 0000000..a27f257
--- /dev/null
+++ b/index.md
@@ -0,0 +1,9 @@
+# Peniblec's Memory Leaks
+## still reachable: 55 words in 1 pages
+
+I was worrying about forgetting stuff so I started taking notes; then
+I started worrying about scattering my notes over several antediluvian
+computers so I figured I should put them all in one repository and
+back them up somewhere.
+
+This is the somewhere.
diff --git a/update-count.sh b/update-count.sh
new file mode 100755
index 0000000..abc8d42
--- /dev/null
+++ b/update-count.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+count-leaks ()
+{
+ let pages=0
+ let words=0
+
+ while read filename
+ do
+ let words+=$(wc -w ${filename} | cut -d' ' -f1)
+ let pages+=1
+ done
+
+ echo ${words} ${pages}
+}
+
+read words pages < <(find . -name '*.md' | count-leaks)
+
+pattern="\([0-9]*\) words in \([0-9]*\) pages"
+actual="${words} words in ${pages} pages"
+
+sed -i "s/${pattern}/${actual}/" index.md