Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Mike Fiedler miketheman

🏠
Working from home
View GitHub Profile
@miketheman
miketheman / zook_grow.md
Created Jul 22, 2013
Adding nodes to a ZooKeeper ensemble
View zook_grow.md

Adding 2 nodes to an existing 3-node ZooKeeper ensemble without losing the Quorum

Since many deployments may start out with 3 nodes and so little is known about how to grow a cluster from 3 memebrs to 5 members without losing the existing Quorum, here is an example of how this might be achieved.

In this example, all 5 nodes will be running on the same Vagrant host for the purpose of illustration, running on distinct configurations (ports and data directories) without the actual load of clients.

YMMV. Caveat usufructuarius.

Step 1: Have a healthy 3-node ensemble

@miketheman
miketheman / security-group-cleanup.py
Created May 7, 2012
AWS EC2 Unused Security Group cleanup
View security-group-cleanup.py
#!/usr/bin/env python
import sys
import boto
import pprint
del_flag = ''
if len(sys.argv) > 1:
del_flag = sys.argv[1]
@miketheman
miketheman / my_package.py
Last active Mar 20, 2021 — forked from benkehoe/my_package.py
Single sourcing a python package version using importlib.metadata.version()
View my_package.py
try:
# importlib.metadata is present in Python 3.8 and later
import importlib.metadata as importlib_metadata
except ImportError:
# use the shim package importlib-metadata pre-3.8
import importlib_metadata as importlib_metadata
try:
__version__ = importlib_metadata.version(__package__ or __name__)
except importlib_metadata.PackageNotFoundError:
@miketheman
miketheman / Makefile
Created Sep 1, 2016
Django + docker-compose Makefile
View Makefile
CURRENT_DIRECTORY := $(shell pwd)
TESTSCOPE = apps
TESTFLAGS = --with-timer --timer-top-n 10 --keepdb
help:
@echo "Docker Compose Help"
@echo "-----------------------"
@echo ""
@echo "Run tests to ensure current state is good:"
View hypermail.rb
class Hypermail < Formula
desc "Hypermail is a free (GPL) program to convert email from Unix mbox format to html."
homepage "http://www.hypermail-project.org/"
url "https://github.com/hypermail-project/hypermail/releases/download/v2.4.0/hypermail-2.4.0.tar.gz"
sha256 "f97995b9bb1ece888968467cdad05e3daa7662ff3e3a5739e378b4f3adeb26c6"
license "GPL-2.0"
depends_on "bison" => :build
depends_on "gcc"
View main.dart
flip(inputInt) {
return inputInt = 1 - inputInt;
}
void main() {
print(flip(0));
print(flip(1));
}
@miketheman
miketheman / enable_alerting.py
Created Feb 14, 2020
A simple script to enable GitHub's Data Services & Vulnerability Scanning on a given Organization's Repositories
View enable_alerting.py
from github import Github
gh = Github('SET_GITHUB_ACCESS_TOKE_HERE')
org = gh.get_organization('SET_ORG_NAME_HERE')
repos = org.get_repos()
for repo in repos:
if repo.archived:
@miketheman
miketheman / _how_to.md
Last active Jun 4, 2020
Mike's Super Janky Manual GitHub Vuln Alert Query
View _how_to.md

How To

Prerequsites:

  • GitHub account with admin-level rights to repos, possibly even org-level admin.
  • Command Line familiarity
  • jq tool

Note: Commands have been written assuming a macOS machine, they may work on other platforms, but I haven't tested those.

@miketheman
miketheman / installer.log
Last active Feb 22, 2020
chefdk-0.7.0-rc.2-1.dmg failure log
View installer.log
Jul 11 10:16:27 wing Installer[99257]: LSExceptions [0x7f857ac0cbb0] loaded
Jul 11 10:16:27 wing Installer[99257]: @(#)PROGRAM:Install PROJECT:Install-1000
Jul 11 10:16:27 wing Installer[99257]: @(#)PROGRAM:Installer PROJECT:Installer-852
Jul 11 10:16:27 wing Installer[99257]: Hardware: MacBookAir6,1 @ 1.70 GHz (x 4), 8192 MB RAM
Jul 11 10:16:27 wing Installer[99257]: Running OS Build: Mac OS X 10.11 (15A215h)
Jul 11 10:16:27 wing Installer[99257]: Env: __CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0
Jul 11 10:16:27 wing Installer[99257]: Env: TMPDIR=/var/folders/78/3jyqdny925n348fpr6wh23bc0000gn/T/
Jul 11 10:16:27 wing Installer[99257]: Env: HOME=/Users/miketheman
Jul 11 10:16:27 wing Installer[99257]: Env: SHELL=/bin/bash
Jul 11 10:16:27 wing Installer[99257]: Env: SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.C1W3TcCVzf/Listeners
@miketheman
miketheman / linux_entropy.py
Created Dec 31, 2015
Datadog Agent Linux Entropy Available
View linux_entropy.py
from checks import AgentCheck
class LinuxEntropyCheck(AgentCheck):
def check(self, instance):
with open('/proc/sys/kernel/random/entropy_avail', 'r') as procfile:
data = procfile.read().strip()
self.gauge('system.kernel.entropy_available', int(data))