Webslides with Pygments

Read the post

Source for these slides

Some JavaScript

const findStacksAndCancelUpdate = (cloudformation, event) => {
  return cloudformation.describeStackResources({
    LogicalResourceId: "TaskDefinition",
    PhysicalResourceId: event.detail.taskDefinitionArn
  }).promise()
    .then(data => Promise.all(data.StackResources.map(stackResource => {
      return stackStatusIsUpdateInProgress(cloudformation, stackResource)
        .then(res => res && cancelUpdateStack(cloudformation, stackResource))
    })))
};

exports.handler = (event, context, callback) => {
  findStacksAndCancelUpdate(new AWS.CloudFormation(), event)
    .then(() => callback())
    .catch(err => {
      console.log(`Error ${err}`);
      callback(err);
    });
};

Some Clojure

(defn numberify [s]
  (cond
    (number? s) s
    (re-matches #"^\d+$") (js/parseInt s)
    :default :cljs.spec.alpha/invalid))

(s/def ::number (s/conformer numberify))

(s/def :person/id (s/conformer uuid))
(s/def :person/name string?)
(s/def :person/age ::number)
(s/def :person/entity (s/keys :req [:person/id :person/name :person/age]))

Some Bash

#!/bin/bash

set -e

well_known_root="$1"

echo "$(date) About to renew certificates" >> /var/log/letsencrypt-renew.log
/usr/bin/docker run \
       -i \
       --rm \
       --name certbot \
       -v /etc/letsencrypt:/etc/letsencrypt \
       -v "$well_known_root:/webroot" \
       certbot/certbot \
       renew -w /webroot

echo "$(date) Cat certificates" >> /var/log/letsencrypt-renew.log

for dir in /etc/letsencrypt/live/*; do
  $(dirname "$0")/cat-cert.sh $(basename "$dir")
done

echo "$(date) Reload haproxy" >> /var/log/letsencrypt-renew.log
/usr/bin/docker kill -s HUP cirice-load-balancer

echo "$(date) Done" >> /var/log/letsencrypt-renew.log