Skip to content

Instantly share code, notes, and snippets.

View jeroenvandijk's full-sized avatar

Jeroen van Dijk jeroenvandijk

View GitHub Profile
@thiagokokada
thiagokokada / download_bb_if_not_exist.clj
Last active May 28, 2021 22:36
Script that downloads Babashka if not available and runs the file as a Babashka script afterwards
#!/usr/bin/env bash
#_(
bb_dir="$HOME/.bb"
if [ ! -x "$bb_dir/bb" ]; then
echo "Babashka not found. Installing it at $bb_dir directory..."
download_dir="$(mktemp -d)"
trap "rm -rf $download_dir" EXIT
@cgrand
cgrand / heredoc.clj
Last active March 6, 2021 17:16
An ugly hacky heredoc for Clojure
(defn heredoc []
(let [delim (.readLine *in*)]
(->> (repeatedly #(.readLine *in*))
(take-while #(not= delim %))
(interpose \newline)
(apply str))))
; The following lines are read (by the reader) as:
; "Look )(\"\\T\na here doc!\n"
#=(heredoc)"""
@fmcmac
fmcmac / emr_drill.md
Last active December 1, 2021 20:03
AWS EMR Apache Drill using SSM and not bootstrap

Apache Drill on EMR

Taking over the management of an EMR cluster which is created on demand and terminated after use I set about "tidying it up". Part of the tidy up was to simplify the installion of Apache Drill.
Any improvements greatfully accepted.

Approach

I abandoned the use of a bootstrap script on the cluster to install Drill as I wanted to use the default installation of Zookeeper.
Additionally the use of SSM meant that I could install and tune Drill after the cluster was created without the risk of the bootstrap failing and blocking cluster creation.

Step 1: Install SSM

AWS says that SSM is installed "Amazon Linux base AMIs dated 2017.09 and later" (https://docs.aws.amazon.com/systems-manager/latest/userguide/sysman-install-ssm-agent.html).
I used the below to install it and ran this script as a bootstrap script on the EMR creation. "bootstrap_for_ssm.bash"

(ns switch
(:require [clojure.pprint :as pprint]))
(defn project-clj-map [filename]
(->> (slurp filename)
(read-string)
(drop 1)
(partition 2)
(map vec)
(into {})))
;; In response to blog post:
;; https://medium.com/@kasperpeulen/10-features-from-various-modern-languages-that-i-would-like-to-see-in-any-programming-language-f2a4a8ee6727
;; Run with lumo
;; https://github.com/anmonteiro/lumo
;;
;; # npm install -g lumo-cljs
;; lumo clojurescript-feature-examples.cljs

Application specific host grouping in Riemann-dash

It is generally desirable to group all the hosts for a specific service into a single dashboard view. For example, all the web servers are in single view while all the database servers are in another view.

This is usually not an issue when you are sending custom metrics using Riemann client. However, there are cases where you are using something that you do not control how the metrics are being sent. i.e., Riemann-tools.

Since Riemann-tools scripts are application agnostic, in order for the dashboard view to group hosts, we must inject some application specific information into the tags field. Tags is a collection of arbitrary strings. In the case of Riemann-tools scripts you can pass in arbitrary strings on the command line.

riemann-health --host 127.0.0.1 --tag "prod" --tag "webserver"

@mhawksey
mhawksey / gist:1170597
Created August 25, 2011 13:02
Google Apps Script to fill in a Document template with Spreadsheet data
function onOpen() {
var menuEntries = [ {name: "Create Diary Doc from Sheet", functionName: "createDocFromSheet"}];
var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.addMenu("Fitness Diaries", menuEntries);
}
function createDocFromSheet(){
var templateid = "1O4afl8SZmMxMFpAiN16VZIddJDaFdeRBbFyBtJvepwM"; // get template file id
var FOLDER_NAME = "Fitness Diaries"; // folder name of where to put completed diaries
// get the data from an individual user