Skip to content

Instantly share code, notes, and snippets.

View ahpook's full-sized avatar
:octocat:
OSPO @ Github

Eric Sorenson ahpook

:octocat:
OSPO @ Github
View GitHub Profile
## These were the changes i had to make to the rawhide ruby-1.8.7-p299 to get a clean compile
## under RHEL -- I additionally had to rebuild autoconf-2.60 (and therefore m4-1.4.12 from F11)
## but those were clean rebuilds. The lack of a BuildRoot was particularly problematic.
## (original from http://mirrors.lax-noc.com/fedora/development/rawhide/source/SRPMS/ruby-1.8.7.299-5.fc15.src.rpm)
--- ruby.spec.dist 2010-08-01 10:40:56.000000000 -0700
+++ ruby.spec 2010-08-22 02:02:08.000000000 -0700
@@ -16,12 +16,14 @@
Name: ruby
Facter.add("nisroles") do
confine :kernel => :solaris
setcode do
nisroles = Facter::Util::Resolution.exec('myreallcoolniscommand | grep whaticareabout')
end
end
@ahpook
ahpook / flac filename to id3 tag
Created May 18, 2011 21:59
Not proud of this
Given a directory of MP3s created from FLACs, untagged but correctly named:
1 - Enabl.ed - Modules Fail - odeq2.mp3
02 - Enabl.ed - Modules Fail - Its at this point, where i get drowsy.mp3
03 - Enabl.ed - Modules Fail - Arel Depiq.mp3
04 - Enabl.ed - Modules Fail - Melting in Stereo.mp3
05 - Enabl.ed - Modules Fail - Blowing Ashes.mp3
06 - Enabl.ed - Modules Fail - Make me what they say I am.mp3
07 - Enabl.ed - Modules Fail - exit4.mp3
08 - Enabl.ed - Modules Fail - Vinc Drae5.mp3
@ahpook
ahpook / times-tables.rb
Created July 5, 2011 04:23
Pair programming with my 6-year-old
#!/usr/bin/ruby
# times-tables.rb by gunnar and eric sorenson
x = 12
y = 12
puts "-" + "----" * x
1.upto(y) do |i|
print "|"
@ahpook
ahpook / gist:1182243
Created August 30, 2011 22:14
Use a generic client certificate with puppet

The problem

There's enough trouble with puppet's ssl model (mandatory client certs) that people go and do odd things to get around it. The primary problem is that for lab/preproduction environments, if you reinstall machines frequently, you lose access to the private key that generated the original cert but (absent some puppet cert --clean [node] operation) the cert still exists, leading to the dreaded Retrieved certificate doesn't match private key error.

A solution

Generate a single client certificate which all your nodes use, and have the master determine node names from facter rather than the SSL DN. This way you can re-install nodes with impunity and as long as your bootstrap plops down the correct config and the cert+key, you don't have any more SSL issues.

The caveats

If you have autosign turned on, this change represents a shift in security tradeoffs: you can turn off autosign and therefore more tightly control which clients can talk to your server because they need to have your clie

@ahpook
ahpook / sinatra-multiple-values-fail
Created September 6, 2011 21:32 — forked from randomcamel/sinatra-multiple-values-fail
Sinatra failing to produce multiple param values
# Sinatra 1.2.6 doesn't appear to properly handle multiple values for a form parameter. 'params[:my_param_name]'
# only returns the last one supplied. I've verified that Chrome is sending the full list, and the list appears in
# the rack.request.query_string variable (but not the rack.request.params variable).
# This comes straight outta rack so it's not actually sinatra's fault. It's also undocumented magic in the
# rack/utils.rb#normalize_params method.
require 'rubygems'
require 'sinatra'
@ahpook
ahpook / memorysize_raw.rb
Created September 8, 2011 00:28
Custom facter fact for raw memorysize.
# for some reason facter takes the raw memorysize and reports it as
# a formatted string, which is useless for calculation
#
Facter.add("memorysize_raw") do
confine :kernel => :linux
setcode do
size = 0
File.readlines("/proc/meminfo").each do |l|
size = $1.to_f if l =~ /^MemTotal:\s+(\d+)/
@ahpook
ahpook / config.ru
Created November 16, 2011 19:49 — forked from miwillhite/config.ru
require File.join(File.dirname(__FILE__), 'config', 'environment.rb')
# disable :run
run Helios
764 git branch 4426-regexp-nodes origin/master
765 git checkout 4426-regexp-nodes
766 git log regexp_nodes_environments
767 git merge c065e2e0892552fe92c2bd8a665547238fb96a40
768 git merge 338fbb248ae11c3aa95768687d829ff1d6776c0f
769 git merge d679dc58f3cf235245f478edec446c64afd48693
770 git status
771 git push me 4426-regexp-nodes
ended up with https://github.com/ahpook/puppet/commits/4426-regexp-nodes
@ahpook
ahpook / puppet.out
Created June 12, 2012 01:44
Arbitrary Pluginsync
notice: /File[/var/lib/puppet/lib/awesome_print.rb]/ensure: defined content as '{md5}95f5a0ae3b1ccce7f52aaa78333a4710'
debug: /File[/var/lib/puppet/lib/awesome_print.rb]: The container /var/lib/puppet/lib will propagate my refresh event
notice: /File[/var/lib/puppet/lib/awesome_print]/ensure: created
debug: /File[/var/lib/puppet/lib/awesome_print]: The container /var/lib/puppet/lib will propagate my refresh event
notice: /File[/var/lib/puppet/lib/awesome_print/ext]/ensure: created
debug: /File[/var/lib/puppet/lib/awesome_print/ext]: The container /var/lib/puppet/lib will propagate my refresh event
notice: /File[/var/lib/puppet/lib/awesome_print/ext/active_record.rb]/ensure: defined content as '{md5}8a025cc4c18f1a5f295ce25c95df1b77'
debug: /File[/var/lib/puppet/lib/awesome_print/ext/active_record.rb]: The container /var/lib/puppet/lib will propagate my refresh event
notice: /File[/var/lib/puppet/lib/awesome_print/inspector.rb]/ensure: defined content as '{md5}3bc952154e018460b7fe4c61e980d25c'
debug: /File[/var