Skip to content

Instantly share code, notes, and snippets.

@jarosite
jarosite / teamcity.rb
Last active August 29, 2015 14:07 — forked from agross/teamcity.rb
class TeamCity
def self.running?
ENV.include? 'TEAMCITY_PROJECT_NAME'
end
def self.method_missing(method, *args, &block)
return unless running?
message_name = camel_case method.to_s
publish message_name, args[0]
@jarosite
jarosite / gist:61936e241e91738ba719
Last active August 29, 2015 14:27
Puppet external fact for EC2 Tags
#!/bin/bash
region=`facter ec2_placement_availability_zone | sed 's/[a-z]$//g'`
instanceId=`facter ec2_instance_id`
/usr/bin/aws ec2 describe-tags --filters "Name=resource-id,Values=${instanceId}" --region ${region} | jq '.Tags[] | "ec2_tag_" + .Key + "=" + .Value' | tr [:upper:] [:lower:] | tr -d '"'
exit 0
@jarosite
jarosite / ec2tags.rb
Last active August 29, 2015 14:27 — forked from rafaelfelix/ec2tags.rb
Hack to get ec2 tags to facter. Depends on aws-cli (https://github.com/aws/aws-cli), jq (http://stedolan.github.io/jq/) and the JSON RubyGem (http://rubygems.org/gems/json)
require 'facter'
require 'json'
if Facter.value("ec2_instance_id") != nil
instance_id = Facter.value("ec2_instance_id")
region = Facter.value("ec2_placement_availability_zone")[0..-2]
tags = Facter::Util::Resolution.exec("aws ec2 describe-tags --filters \"name=resource-id,values=#{instance_id}\" --region #{region} | jq '[.Tags[] | {key: .Key, value: .Value}]'")
parsed_tags = JSON.parse(tags)
parsed_tags.each do |tag|
@jarosite
jarosite / public_enc_example.sh
Created November 21, 2019 16:32 — forked from thinkerbot/public_enc_example.sh
Public-key encryption example using OpenSSL
#!/bin/bash
#
# Public-Key Encryption and Decryption
# * http://www.openssl.org/
# * http://barelyenough.org/blog/2008/04/fun-with-public-keys/
#
# Mac OS X 10.6.4
# OpenSSL 0.9.8l 5 Nov 2009
# Generate keys