Skip to content

Instantly share code, notes, and snippets.

View lost-theory's full-sized avatar

Steven Kryskalla lost-theory

View GitHub Profile
@lost-theory
lost-theory / 01_intro.md
Last active March 26, 2019 15:52
Monitorama 2014 notes

Monitorama 2014 notes

http://monitorama.com/

Best talks day 1:

  • Please, no More Minutes, Milliseconds, Monoliths... or Monitoring Tools! - Adrian Cockcroft
    • gave 5 good rules for monitoring systems, showed what cloud / microservices monitoring looks like @ Netflix
  • Simple math to get some signal out of your noisy sea of data - Toufic Boubez
  • explains why static alert thresholds don't work and gave 3 techniques to use instead
@lost-theory
lost-theory / security-pd-meetup.md
Last active September 11, 2018 07:56
Security meetup @ Pagerduty 2014-07-11
@lost-theory
lost-theory / netstat-2015.md
Last active September 10, 2018 11:25
netstat on all machines -> python -> graphviz -> png
$ knife ssh -m "...every host in the network..." "sudo netstat -nutap" -a hostname > meganetstat.txt
$ python
>>> from collections import Counter as C
>>> HS = "...every host in the network...".split()
>>> ip = lambda s: s.split(":")[0]
>>> xs = [map(ip, [x[0], x[4], x[5]]) for x in [x.strip().split() for x in open("meganetstat.txt").readlines() if "tcp" in x] if len(x)>=6]
>>> ipmap = [(h, C([x[1] for x in xs if x[0] == h])) for h in HS]
>>> ipmapx = dict([(sorted([(x,y) for (x,y) in ip[1].items() if x.startswith("10.")], key=lambda t: -t[1])[0][0], ip[0]) for ip in ipmap])
>>> sorted(C(map(ipmapx.get, [x[2] for x in xs if x[2].startswith("10.")])).items(), key=lambda t: t[1])
@lost-theory
lost-theory / tests.py
Created August 18, 2012 07:09
mock render_template
from mock import patch #http://pypi.python.org/pypi/mock
import flask
import myapp
@patch('flask.templating._render', return_value='')
def test_mocked_render(mocked):
t = myapp.app.test_client()
print "mocked", repr(t.get("/").data)
print "was _render called?", mocked.called
@lost-theory
lost-theory / fab.py
Created February 14, 2012 23:43
fabric elocal - "local" command that raises an exception
#!/usr/bin/env python
from fabric.api import task, local, settings
class CommandFailed(Exception):
def __init__(self, message, result):
Exception.__init__(self, message)
self.result = result
def elocal(*args, **kwargs):
with settings(warn_only=True):
from flask import request, Flask
from cloudinary import uploader #pip install git+https://github.com/cloudinary/pycloudinary/
class Cloudinary(object):
def __init__(self, app):
config = app.config['CLOUDINARY_URL'].split('://')[1]
config = config.replace("@", ":")
self.api_key, self.api_secret, self.name = config.split(":")
@lost-theory
lost-theory / notes.md
Last active October 8, 2016 17:56
DevOps Master Class & Opbeat Launch, 2014-09-26
@lost-theory
lost-theory / 01_walkthrough.md
Last active April 2, 2016 20:10
Conda app local development on OSX and deploying to Heroku

Downloaded Miniconda installer from here:

http://conda.pydata.org/miniconda.html

In a terminal:

$ sh ./Downloads/Miniconda-latest-MacOSX-x86_64.sh
Enter (read license agreement)
yes (accept license agreement)

Enter (use default installation location)

import yaml
tree = yaml.load('''
---
- folder1
- folder2:
- subfolder1:
- deepfolder1
- subolder2
- folder3
$ #spoiler alert!
$ grep -rn CLUE .
$ for v in `grep Make: vehicles | awk '{print $2}' | sort | uniq`; do grep -rn $v interviews; done;
$ python
>>> membership_suspects = reduce(set.intersection, map(set, [[x.strip() for x in open("memberships/%s" % y).readlines()] for y in ["AAA", "Delta_SkyMiles", "Museum_of_Bash_History"]]))
>>> people = [x.strip().split('\t') for x in open("people").readlines() if "\t" in x]
>>> male_suspects = [x[0] for x in people if x[1] == "M"]