Skip to content

Instantly share code, notes, and snippets.

View miketheman's full-sized avatar

Mike Fiedler miketheman

View GitHub Profile
@miketheman
miketheman / my_package.py
Last active March 20, 2021 23:22 — forked from benkehoe/package_with_single_sourced_version.py
Single sourcing a python package version using importlib.metadata.version()
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:
require "statsd"
# Create a stats instance.
statsd = Statsd.new("localhost", 8125)
# Increment a counter for 5 minutes, 1 point per second
(1...300).each { statsd.count("dev.mike.dogstatsd", 1) ; sleep 1 }
@miketheman
miketheman / clformat.rb
Last active December 18, 2015 13:39 — forked from jtimberman/clformat.rb
Updated clformat for URL handling
#!/usr/bin/env ruby
#require 'bundler/setup'
require 'date'
require 'jiralicious'
require 'json'
require 'net/https'
require 'uri'
# Pass component name on command line as first argument
# File dropped of by Chef, local modifications will be overwritten!
# 2013-05-08T00:00:02+00:00 10.87.125.117 haproxy[30746]: 10.44.133.138:39039 [07/May/2013:23:59:56.974] public dogdispatcher/i-5e4d843b:9000 4/0/5001/1002/6009 202 166 - - ---- 132/132/35/11/1 0/0 "POST /api/v1/series/?api_key=<redacted> HTTP/1.1"
# Field numbers, description, example
# Ref: https://code.google.com/p/haproxy-docs/wiki/HTTPLogFormat
# 1 (rsyslog) log time
# 2 (rsyslog) haproxy server
# 3 process_name '[' pid ']:' haproxy[14389]:
# 4 client_ip ':' client_port 10.0.1.2:33317
@miketheman
miketheman / gist:4169770
Created November 29, 2012 15:24 — forked from grantr/gist:1105416
Chef mysql master/slave recipes
## mysql::master
ruby_block "store_mysql_master_status" do
block do
node.set[:mysql][:master] = true
m = Mysql.new("localhost", "root", node[:mysql][:server_root_password])
m.query("show master status") do |row|
row.each_hash do |h|
node.set[:mysql][:master_file] = h['File']
node.set[:mysql][:master_position] = h['Position']
end
@miketheman
miketheman / Vagrantfile
Created February 17, 2012 17:05 — forked from jean/Vagrantfile
Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
#njj From http://devops.me/2011/10/10/vagrant-tricks-and-troubleshooting/
config.vm.customize ["modifyvm", :id, "--memory", "800"]
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
@miketheman
miketheman / set_environment.rb
Created December 29, 2011 16:12 — forked from nstielau/set_environment.rb
A Knife plugin to set node environment
## Knife plugin to set node environment
# See http://wiki.opscode.com/display/chef/Environments
#
## Install
# Place in .chef/plugins/knife/set_environment.rb
#
## Usage
# Nick-Stielaus-MacBook-Pro:chef-repo nstielau$ knife node set_environment mynode.net my_env
# Looking for mynode.net
# Setting environment to my_env