Skip to content

Instantly share code, notes, and snippets.

View philipnrmn's full-sized avatar
verified account

Philip Norman philipnrmn

verified account
View GitHub Profile
@philipnrmn
philipnrmn / strict-install.sh
Created February 8, 2019 23:15
A script for quickly installing a DC/OS framework in strict mode (NB: grants superuser permissions!)
#!/usr/bin/env zsh
# usage: strict-install elastic
dcos_url=$(dcos config show core.dcos_url)
dcos_acs_token=$(dcos config show core.dcos_acs_token)
secret_name="$1_secret"
service_account_id="$1"
ts=$(date "+%Y%m%d")
tmp="/tmp/install_$1_$ts"
@philipnrmn
philipnrmn / prometheus.yaml
Created March 6, 2018 21:13
The DC/OS on Docker Prometheus config file
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager).
external_labels:
monitor: 'codelab-monitor'
@philipnrmn
philipnrmn / stat-pwd.py
Created February 22, 2018 23:51
Stat the current directory
import os
print(os.stat('.'))
@philipnrmn
philipnrmn / toggle.json
Created November 30, 2017 22:44
This metronome job toggles the health of a random instance belonging to the marathon malinger task
{
"id": "malinger-toggle",
"labels": {},
"run": {
"cpus": 0.01,
"mem": 128,
"disk": 0,
"cmd": "curl -X POST http://malinger.marathon.l4lb.thisdcos.directory/toggle",
"env": {},
"placement": {
@philipnrmn
philipnrmn / malinger.json
Created November 30, 2017 22:42
The health of each task belonging to this marathon instance can be toggled
{
"id": "/malinger",
"cmd": "cd $MESOS_SANDBOX && pip install flask && python malinger.py",
"cpus": 0.1,
"mem": 128,
"disk": 0,
"instances": 1,
"healthChecks": [
{
"portIndex": 0,
@philipnrmn
philipnrmn / statsd-emitter-docker.json
Created November 27, 2017 22:22
Statsd Emitter (Docker) Marathon App Configuration
{
"id": "/statsd-emitter-docker",
"cmd": "/bin/statsd-emitter",
"container": {
"type": "DOCKER",
"volumes": [
{
"containerPath": "/bin/statsd-emitter",
"hostPath": "/opt/mesosphere/bin/statsd-emitter",
"mode": "RO"
@philipnrmn
philipnrmn / statsd-emitter-ucr.json
Created November 27, 2017 22:21
Statsd Emitter (UCR) Marathon App Configuration
{
"id": "/statsd-emitter-ucr",
"cmd": "/opt/mesosphere/bin/statsd-emitter",
"container": {
"type": "MESOS",
"volumes": []
},
"cpus": 0.001,
"disk": 0,
"instances": 1,
@philipnrmn
philipnrmn / malinger.json
Last active April 19, 2017 22:46
A Marathon application with togglable health
{
"id": "/malinger",
"cmd": "cd $MESOS_SANDBOX && pip install flask && python malinger.py",
"cpus": 0.1,
"mem": 128,
"disk": 0,
"instances": 1,
"container": {
"type": "DOCKER",
"docker": {
@philipnrmn
philipnrmn / six_seventeen.clj
Created February 19, 2017 06:16
Spiral sort in clojure
(ns elements.six-seventeen)
(def sample [[ 1 2 3 4 5]
[ 6 7 8 9 10]
[11 12 13 14 15]
[16 17 18 19 20]
[21 22 23 24 25]])
(defn top
[matrix]
@philipnrmn
philipnrmn / sort_in_place.py
Created January 27, 2017 18:30
Sorting a string in place
# Exercise: sort the words in an arbitrary string in place.
# For the purposes of this exercise, assume the string is
# lowercase and no two words start with the same character.
def take_word(sentence):
"""Generator; yields all words in a sentence"""
word = ''
for c in sentence:
if c == ' ':
yield word