Ignacio Torres Masdeu


2018 wk.30: Holiday

It’s the first time in eleven years I enjoy a complete holiday:

What’s a geek to do?

  1. Deploy Triton at home.
  2. Provision a Chef server and setup a bunch of recipes to provision VMs with services like unbound or syncthing.
  3. Decide that he is fed up with nginx and create a recipe to provision good old Apache.
  4. Try out Hugo and decide that the effort to migrate from Jekyll is worth it.
  5. Just because we’re at it, create some Emacs convenience functions to create new posts.

If you’re reading this Hugo and Apache are doing their work. And the functions are these just in case someone is interested.

(defvar itorres-blog-path)
(defun itorres-blog-slugify (s)
  "Create a slug from a string"
  (let (dc)
    (setq dc (downcase s))
    (replace-regexp-in-string "[^[:alnum:]]" "-" dc)))

(defun itorres-blog-post-path (title)
      (format
       "%s/%s/%s/%s-%s.md"
       itorres-blog-path
       (format-time-string "%Y" nil "UTC0")
       (format-time-string "%m" nil "UTC0")
       (format-time-string "%Y-%m-%d" nil "UTC0")
       (itorres-blog-slugify title)))

(defun itorres-blog-front-matter (title)
  (insert "---\n")
  (insert (concat "date: '" (format-time-string "%Y-%m-%dT%TZ" nil "UTC0") "'\n"))
  (insert "lang: en\n")
  (insert "published: draft\n")
  (insert (concat "title: '" (format-time-string "%Y wk.%W: " nil "UTC0") title "'\n"))
  (insert "---\n\n"))

(defun itorres-blog-new-post (title)
  "Create new blog post with today's date and prompt for title"
  (interactive "sPost title: ")
  (let (bn)
    (setq bn (find-file (itorres-blog-post-path title)))
    (set-buffer bn)
    (itorres-blog-front-matter title)))

Extra ball, a handy function to copy a totp token generated from the seed string at point.

(defun itorres-totp ()
  "Call goathtool totp with string at point"
  (interactive)
  (let (seed token)
    (setq seed (current-word t t))
    (setq token (string-trim (shell-command-to-string (concat "~/bin/goathtool totp -b " seed))))
    (kill-new token)
    (message (concat "totp token " token " copied to kill ring"))))