Skip to content

Instantly share code, notes, and snippets.

View juliandunn's full-sized avatar

Julian C. Dunn juliandunn

View GitHub Profile
@juliandunn
juliandunn / output.txt
Created August 15, 2014 03:40
How do you set a node attribute to the value of stdout from a shell command?
% chef-apply -l info recipe.rb
[2014-08-14T23:38:46-04:00] INFO: Run List is []
[2014-08-14T23:38:46-04:00] INFO: Run List expands to []
Recipe: (chef-apply cookbook)::(chef-apply recipe)
* ruby_block[demo] action run[2014-08-14T23:38:46-04:00] INFO: Processing ruby_block[demo] action run ((chef-apply cookbook)::(chef-apply recipe) line 2)
[2014-08-14T23:38:46-04:00] INFO: ruby_block[demo] called
- execute the ruby block demo
* log[demo] action write[2014-08-14T23:38:46-04:00] INFO: Processing log[demo] action write ((chef-apply cookbook)::(chef-apply recipe) line 9)
[2014-08-14T23:38:46-04:00] INFO: Hello world
@juliandunn
juliandunn / makeomnibus.sh
Created August 5, 2014 01:45
Initial revision of shell script to get thee an Omnibus on AIX
#!/bin/sh
# Nuke and pave all the freeware RPMs
rpm -qa | sed -e 's/\-[AIX Servers^\-]*\-[AIX Servers^\-]*$//' | egrep -v '(AIX-rpm|zlib|gettext)' | xargs rpm -e
# Get all deps for wget
perl -e 'use LWP::Simple; getprint($ARGV[0]);' ftp://www.oss4aix.org/rpmdb/deplists/aix61/wget-1.15-1.aix5.1.ppc.deps > /tmp/wget-1.15-1.aix5.1.ppc.deps
while read i; do
perl -e 'use LWP::Simple; getprint($ARGV[0]);' ftp://www.oss4aix.org/everything/RPMS/${i} > /tmp/${i}
@juliandunn
juliandunn / get-ruby-compile-options.sh
Created July 24, 2014 12:35
how to get compile type options and compiler, etc. from Ruby
ruby -r rbconfig -r pp -e 'pp RbConfig::CONFIG'
Start: Mon Jul 21 20:22:01 2014
HOST: borkbork.nyc.urbandecoder.n Loss% Snt Last Avg Best Wrst StDev
1.|-- nectar.nyc.urbandecoder.n 0.0% 25 0.9 2.1 0.8 12.7 2.9
2.|-- l100.nycmny-vfttp-59.veri 0.0% 25 5.3 8.5 4.8 32.2 7.2
3.|-- g0-1-3-3.nycmny-lcr-21.ve 4.0% 25 16.6 11.9 8.5 16.6 2.2
4.|-- ae3-0.ny325-bb-rtr2.veriz 0.0% 25 19.9 17.7 7.2 59.9 14.9
5.|-- ??? 100.0 25 0.0 0.0 0.0 0.0 0.0
6.|-- 0.ae2.br3.nyc4.alter.net 0.0% 25 7.9 9.3 7.4 16.4 2.0
7.|-- 204.255.168.66 0.0% 25 9.9 10.7 7.8 26.5 4.0
8.|-- ??? 100.0 25 0.0 0.0 0.0 0.0 0.0
@juliandunn
juliandunn / default.rb
Created July 12, 2014 03:20
example of using Chefspec to make assertions about guards
# Recipe code
service 'true_guard' do
action :start
only_if { File.exist?('/tmp/trueguard') }
end
service 'false_guard' do
action :start
not_if { File.exist?('/tmp/falseguard') }
irb(main):001:0> Class.class
=> Class
irb(main):002:0> Class.superclass
=> Module
irb(main):003:0> Module.superclass
=> Object
irb(main):004:0> Object.superclass
=> BasicObject
irb(main):005:0> BasicObject.superclass
=> nil
@juliandunn
juliandunn / cli-uis-need-ux-too.txt
Created June 12, 2014 14:01
C'mon man, command-line UIs are UIs too
borkbork ~$ s3cmd mb jdunn-getchef-foo
ERROR: Parameter problem: Expecting S3 URI with just the bucket name set instead of 'jdunn-getchef-foo'
borkbork ~$ s3cmd mb s3://jdunn-getchef-foo
Bucket 's3://jdunn-getchef-foo/' created
@juliandunn
juliandunn / monkeypatch-nil.rb
Created June 11, 2014 19:44
Monkeypatching NilClass to clarify what the heck is meant by "NoMethodError: undefined method `[]' for nil:NilClass"
class NilClass
def []
raise "What the hell, dawg, you can't access an element of nil"
end
def [](a)
raise "What the hell, dawg, you can't access element #{a} of nil"
end
end
node.default['demo'] = true
node.default['demoagain'] = false
ruby_block 'whee' do
block do
puts 'Ohai, world'
end
not_if { node['demo'] }
end
@juliandunn
juliandunn / devopsdays-pgh-bad-wifi.txt
Created May 29, 2014 15:07
Much sadness - pinging default gateway on pitt wifi
fq-guest-wireless-pittnet-150-212-95-96 ~$ ping 150.212.94.1
PING 150.212.94.1 (150.212.94.1): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
64 bytes from 150.212.94.1: icmp_seq=0 ttl=255 time=2079.387 ms
Request timeout for icmp_seq 3
64 bytes from 150.212.94.1: icmp_seq=1 ttl=255 time=3054.474 ms
64 bytes from 150.212.94.1: icmp_seq=2 ttl=255 time=2520.698 ms
64 bytes from 150.212.94.1: icmp_seq=3 ttl=255 time=1846.184 ms
64 bytes from 150.212.94.1: icmp_seq=4 ttl=255 time=949.714 ms