Skip to content

Instantly share code, notes, and snippets.

@jstaffans
jstaffans / ebs-snapshot-for-volume.sh
Last active February 25, 2019 14:14 — forked from sap1ens/ebs-snapshot-for-volume.sh
Bash script for Automatic EBS Volume Snapshots and Cleanup on Amazon Web Services. Original - https://github.com/CaseyLabs/aws-ec2-ebs-automatic-snapshot-bash
#!/bin/bash
# Original was modified to do backup only for one specified volume.
set -ue
set -o pipefail
export PATH=$PATH:/usr/local/bin/:/usr/bin
## START SCRIPT
@jstaffans
jstaffans / gist:22811dcf1b1509534c25dd07b98823f0
Created January 22, 2019 12:28
Files newer than date, group by date, sum sizes
find ./ -maxdepth 1 -type f -newer /tmp/start -printf '%TY-%Tm-%Td %s\n'|awk '{sum[$1]+= $2;}END{for (date in sum){print date, sum[date];}}'|sort
;; https://hackernoon.com/how-to-lose-an-it-job-in-10-minutes-3d63213c8370
(defn set-rotated
"Returns a set of all possible rotations of a string"
[s]
(loop [i 0
acc #{}]
(if (= i (count s))
acc
(recur (inc i) (conj acc (->> s cycle (drop i) (take (count s)) (apply str)))))))
@jstaffans
jstaffans / gist:5c56b687f0f75a330d2df251c564e24d
Created May 24, 2018 18:35
Generate own SSL certificate (useful for one-off tests, private machines)
sudo openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout "cert.key" -out "cert.pem" -batch
@jstaffans
jstaffans / jepsen.md
Last active April 4, 2018 18:47
Jepsen notes

Setup, development

  • can start a cluster of Docker containers locally for development/testing
    • see up.sh in jepsen/docker
  • use these from Leiningen running locally on same machine as Docker host: https://stackoverflow.com/a/45071285/1479173
    • ie resolve Docker containers from host
    • add node host names to a file (e.g. nodes.txt) with a trailing dot and do lein run test --nodes-file ./nodes.txt
n1.
{:user {:deploy-repositories [["clojars" {:url "https://clojars.org/repo"
:creds {:username "USERNAME" :password "PASSWORD"}
:sign-releases false}]]}}
@jstaffans
jstaffans / react_js_spacemacs.md
Created September 25, 2017 07:56
React/JS in Spacemacs

syl20bnr/spacemacs#8206

"For what it's worth, I'd recommend not worry about indentation and using prettier, eslint-plugin-prettier, eslint_d, and eslintd-fix. With that combo, every time you save your file it will completely format and indent your code for you. It's a game changer."

// https://css-tricks.com/bem-101/
=e($elements...)
$selector: ()
@each $element in $elements
$selector: append($selector, unquote("&__" + $element), comma)
#{$selector}
@content
=m($modifiers...)
$selector: ()

Scrum and Agile Software Development

http://www.scrumguides.org/ How Scrum works, from the original authors

Scrum and XP (Extreme Programming) from the Trenches — the mechanics of Scrum and agile software development https://www.infoq.com/minibooks/scrum-xp-from-the-trenches-2

  • this is the 2nd edition from 2015
  • the author has added notes (in grey boxes) with his thoughts now compared to the 1st edition - I agree with most of them!
@jstaffans
jstaffans / mock_api.clj
Created August 20, 2017 16:09
Mock an API by using a well-structured directory tree
(defn mock-api-response
[prefix-path uri]
(let [resource-path (format "%s/%s/index.json" prefix-path uri)]
{:headers {"Content-Type" "application/json"
"Access-Control-Allow-Origin" "*"}
:body (slurp (io/resource resource-path))}))
(defroutes routes
(GET "/mock/:uri{[\\/\w\d]+}" [uri]
(mock-api-response "mock_api" uri)))