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 / malinger.py
Last active December 14, 2015 11:01
Fails marathon healthchecks predictably
#!/usr/local/bin/python3
# -*- coding: utf-8 -*-
from flask import Flask, redirect, url_for
from os import environ
'''
Usage:
$ pip3 install flask
$ PORT=8001 python3 malinger.py
@philipnrmn
philipnrmn / jquery.jerky.js
Created August 20, 2013 15:34
Jerky easing in jQuery
(function($) {
// The bigger the step, the jerkier the animation
var step = 0.11,
lastStep = 0;
$.easing.jerky = function(t) {
if (t < step)
lastStep = 0;
if (t > lastStep + step)
lastStep += step;
@philipnrmn
philipnrmn / keybase.md
Created April 19, 2016 14:19
Keybase Proof

Keybase proof

I hereby claim:

  • I am philipnrmn on github.
  • I am philipnrmn (https://keybase.io/philipnrmn) on keybase.
  • I have a public key ASDiSTp2dK4h1OVB0iMrLwQgCKWWQ-0_tYJn-PcrqBeCDwo

To claim this, I am signing this object:

@philipnrmn
philipnrmn / default.conf
Created January 12, 2017 00:06
Dockerhub Nginx SSL default.conf
server {
listen 80;
listen 443 ssl;
server_name localhost;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
@philipnrmn
philipnrmn / marathon.json
Created January 12, 2017 00:36
A sample nginx-on-marathon config which serves HTTP and HTTPS
{
"id": "/philip/mesos-https",
"instances": 1,
"cpus": 0.1,
"mem": 128,
"disk": 0,
"gpus": 0,
"fetch": [
{
"uri": "https://gist.githubusercontent.com/philipnrmn/1c37364baf3157f51567401c51373f5c/raw/00f435020499104b06f06fdf6caed4b435b0acf8/default.conf",
@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
@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 / 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 / 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 / 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"