Skip to content

Instantly share code, notes, and snippets.

@donavanm
donavanm / gist:812782
Created February 5, 2011 21:01
A simple IP address reflector.
<?php
// Think something like http://whatismyipaddress.com, but machine parsable,
// small, and fast(ish). Returns a json encoded hash.
// Will accept a port & optional timeout parameter. Attempts to make a TCP
// connection back to the host on specified port. Useful to see if you're
// externally reachable.
// I'm surprised noone else got here first. - donavanm
// Really PHP? What year is this again?
function get_host($ip){
@donavanm
donavanm / logdest_json.rb
Created February 20, 2011 00:32
Adds json formatted ouput for Puppet applications
# Adds json formatted ouput for Puppet applications.
# Usage: puppet agent --logdest json
# Currently there's no way to load this as a plugin, see #6522. Appending this
# method to puppet/util/log/destinations.rb works. Meh.
# Would also be nice if Puppet::Util::Log had an #attributes method for
# accessors instead of instance_variable hacks.
Puppet::Util::Log.newdesttype :json do
def handle(msg)
message = {}
msg.instance_variables.each {|v| message[v.sub("@","")] = msg.instance_variable_get(v) }
@donavanm
donavanm / elasticat.json
Created March 22, 2012 05:44
CloudFormation EC2 & Route53 template
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Create an EC2 instance, set up Apache, and create Route53 A records",
"Parameters" : {
"KeyName" : {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
"Type" : "String",
@donavanm
donavanm / gist:2156519
Created March 22, 2012 06:00
region.strewth.org resource record set (rrset)
# Name Type Value TTL Region Identifier
region.strewth.org. A 122.248.206.109 300 ap-southeast-1 122.248.206.109
region.strewth.org. A 175.41.208.142 300 ap-northeast-1 175.41.208.142
region.strewth.org. A 184.72.6.100 300 us-west-1 184.72.6.100
region.strewth.org. A 50.112.16.165 300 us-west-2 50.112.16.165
region.strewth.org. A 23.20.203.251 900 us-east-1 23.20.203.251
region.strewth.org. A 177.71.146.114 300 sa-east-1 177.71.146.114
region.strewth.org. A 46.51.135.32 300 eu-west-1 46.51.135.32
The last field is a unique identifier in the rrset. Any unique string will work, it doesn't have to be the IP address.