Skip to content

Instantly share code, notes, and snippets.

View technovangelist's full-sized avatar

Matt Williams technovangelist

View GitHub Profile
@technovangelist
technovangelist / init.lua
Created August 21, 2017 12:53
current (2017-08-21) hammerspoon config
local appfinder = require "hs.appfinder"
local app = require "hs.application"
local alive1 = hs.image.imageFromPath("~/bin/alive1.png")
local alive2 = hs.image.imageFromPath("~/bin/alive2.png")
alive = hs.menubar.new()
if alive then
alive:setIcon(alive2,false)
end
function updateAlive()
@technovangelist
technovangelist / gist:217d706332ff57a421af2693aeb0a771
Last active August 17, 2017 19:52
Great Sample Applications
https://github.com/dockersamples - Docker Compose and Swarm Samples
https://github.com/kubernetes/kubernetes/tree/master/examples - Example apps for K8s
https://github.com/elastic/examples
https://github.com/reactjs/redux/tree/master/examples
https://github.com/googlesamples
https://github.com/serverless/examples
https://github.com/graphcool-examples
https://github.com/RestDB/clientexamples
https://github.com/oracle/oracle-db-examples
https://github.com/electron/simple-samples
$(function() {
var margin = { top: 300, right: 100, bottom: 100, left: 100 },
width = 1400 - margin.right - margin.left,
height = 1080 - margin.top - margin.bottom;
var parseTime = d3.timeParse("%H:%M:%S");
var x = d3.scaleTime().range([0, width]);
var y = d3.scaleLinear().range([height, 0]);
var log2y = d3.scaleLinear().range([height, 0]);
- hosts: manager
become: yes
tasks:
- name: Initialize Docker Swarm
shell: docker swarm init --advertise-addr {{ ansible_eth1.ipv4.address}}
- hosts: manager
become: no
tasks:
- name: Capture Docker Swarm Join Command
@technovangelist
technovangelist / gist:e60825c77fcbb082ae491a9723fd58b6
Created April 12, 2016 20:24
use the stress command to stress the cpu, io, disk, and memory a random amount every x seconds where x is a random number up to 20.
while sleep `shuf -i 0-10 -n 1`; do sudo stress -c `shuf -i 1-4 -n 1` -m `shuf -i 1-2 -n 1` -d `shuf -i 1-5 -n 1` -i `shuf -i 0-4 -n 1` -t `shuf -i 0-20 -n 1`s; done
@technovangelist
technovangelist / setup.md
Created February 12, 2016 23:17
Setting up Pushover.net and Datadog
  1. Create Pushover account
  2. Create a new Application in the Pushover site.
  3. You should now have a token and user id. You will need this for the webhook
  4. Go to the Datadog webhooks integration
  5. Enter Pushover for the name.
  6. Under URL enter `https://api.pushover.net/1/messages.json?token=YOURPUSHOVERAPPTOKEN&user=YOURPUSHOVERUSERID
  7. Under Custom Payload, enter {"title":"$EVENT_TITLE","message":"$EVENT_MSG"}
  8. Check both Use Custom Payload and Encode as form
  9. Create a monitor that notifies @webhook-pushover
  10. Boom, you are done
@technovangelist
technovangelist / datadog-nginx
Last active April 25, 2017 20:35 — forked from gane5h/datadog-nginx
Nginx log parsing with datadog
"""
Thanks to gane5h for the original script. this is a small kludgy tweak to that one.
Custom parser for nginx log suitable for use by Datadog 'dogstreams'.
To use, add to datadog.conf as follows:
dogstreams: [path to ngnix log (e.g: "/var/log/nginx/access.log"]:[path to this python script (e.g "/usr/share/datadog/agent/dogstream/nginx.py")]:[name of parsing method of this file ("parse")]
so, an example line would be:
dogstreams: /var/log/nginx/access.log:/usr/share/datadog/agent/dogstream/nginx.py:parse
Log of nginx should be defined like that:
log_format time_log '$time_local "$request" S=$status $bytes_sent T=$request_time R=$http_x_forwarded_for';
when starting dd-agent, you can find the collector.log and check if the dogstream initialized successfully
@technovangelist
technovangelist / gist:ca8b01692459776d668f
Created July 9, 2015 13:47
Getting HTTPie working on the mac
1) Go to https://github.com/jkbrzt/httpie to get the full instructions on its use
2) Install it: brew install httpie
3) If you are on a Mac and have not upgraded your Python version install other stuff:
pip install --upgrade pyopenssl pyasn1 ndg-httpsclient
(I have the new 15" MBP with force touch trackpad so its as new as they get and I had to install this)
4) Use it....
If trying to use this to look at Docker Stats API, the command to use is going to be:
from dogapi import dog_http_api as api
import console
import json
from StringIO import StringIO
api.api_key = 'apikey'
api.application_key = 'appkey'
board_id = console.input_alert('enter screenboard id')
@technovangelist
technovangelist / dockerstop.zsh
Last active February 25, 2017 19:14
cron script to shutdown boot2docker
#!/bin/zsh
# set cron to run this every couple of minutes and it will shutdown boot2docker
# when its been running with no processes for maxminutes
maxminutes=10
local bdout
local dpqout
bdout=$(boot2docker status) 2>/dev/null
if [[ $bdout = "running" ]]; then
echo "boot2docker running"