Skip to content

Instantly share code, notes, and snippets.

View petems's full-sized avatar
🏠
Working from home

Peter Souter petems

🏠
Working from home
View GitHub Profile
@petems
petems / get_vagrant_names.rb
Created July 3, 2013 10:14
Get all VM's from Vagrantfile
if File.exists?("Vagrantfile")
vagrant_status = `vagrant status`
if vagrant_status != ''
vagrant_status.each_line do |line|
if match = /([a-z]+[\s]+)(created|not created|poweroff|running|saved)[\s](\(virtualbox\)|\(vmware\))/.match(line)
puts match[1].strip!
end
end
else
$stderr.puts "Vagrant status error - Check your Vagrantfile or .vagrant folder"
@petems
petems / gist:5956008
Created July 9, 2013 09:32
Install Ruby 1.9.3 on Ubuntu without Rbenv/RVM
# Install Ruby 1.9.3
apt-get install -qq ruby1.9.1 ruby1.9.1-dev rubygems1.9.1 irb1.9.1 ri1.9.1 rdoc1.9.1 build-essential libopenssl-ruby1.9.1 libssl-dev zlib1g-dev
update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.9.1 400 \
--slave /usr/share/man/man1/ruby.1.gz ruby.1.gz \
/usr/share/man/man1/ruby1.9.1.1.gz \
--slave /usr/bin/ri ri /usr/bin/ri1.9.1 \
--slave /usr/bin/irb irb /usr/bin/irb1.9.1 \
--slave /usr/bin/rdoc rdoc /usr/bin/rdoc1.9.1
@petems
petems / .aws_stuff
Last active December 20, 2015 06:49
How to mass delete all EC2 instances, useful to run on a cron if you're paranoid about leaving stuff on all the time...
# Get these from https://console.aws.amazon.com/iam/home?#security_credential
export AMAZON_ACCESS_KEY_ID=FOO
export AMAZON_SECRET_ACCESS_KEY=BAR
export EC2_REGION="eu-west-1"
@petems
petems / loglevels.pp
Created August 15, 2013 01:01
All the levels of logging for puppet...
node default {
notice("try to run this script with -v and -d to see difference between log levels")
notice("function documentation is available here: http://docs.puppetlabs.com/references/latest/function.html")
notice("--------------------------------------------------------------------------")
debug("this is debug. visible only with -d or --debug")
info("this is info. visible only with -v or --verbose or -d or --debug")
alert("this is alert. always visible")
crit("this is crit. always visible")
emerg("this is emerg. always visible")
@petems
petems / tugboat.bash
Created August 22, 2013 13:14
Tugboat bash completion... (WIP)
#!/usr/bin/env bash
_tugboatcomplete() {
COMPREPLY=($(compgen -W "`tugboat | grep "tugboat "`" -- ${COMP_WORDS[COMP_CWORD]}))
return 0
}
complete -o default -o nospace -F _tugboatcomplete tugboat
@petems
petems / brew_reset.sh
Created August 22, 2013 14:22
Brew hard-reset... For when a brew update goes wrong, this resets it back to remote head
cd `brew --prefix`
git remote add origin https://github.com/mxcl/homebrew.git
git fetch origin
git reset --hard origin/master
@petems
petems / seyren_deb.sh
Last active December 22, 2015 00:38
Seyren to .deb file using FPM
#Since Seyren doesn't have versioning, use Github SHA's so you can see what revision it is...
SEYREN_SHA="5642a0c18425ee760a9f11d63d39a81e16742660"
echo "[Building Seyren Deb]"
rm -rf build/seyren/
git clone -q -b master https://github.com/scobal/seyren build/seyren;
cd build/seyren
git checkout -q $SEYREN_SHA
mvn clean package -q
cd ..
fpm -s dir -t deb -n seyren --deb-field "GithubSHA:$(SEYREN_SHA)" -a all -v 0.1 --prefix /opt seyren
@petems
petems / Gemfile
Last active November 18, 2021 11:05
An example http download with Progress Bar output in the command line with Ruby and the native `net/http` library...
source "https://rubygems.org"
gem "progressbar"
@petems
petems / gist:6812615
Created October 3, 2013 16:20
$PATH issues with rbenv and brew...
$ echo $PATH
/opt/boxen/homebrew/include/:/Users/peterso/perl5/perlbrew/bin:/Users/peterso/perl5/perlbrew/perls/perl-5.16.0/bin:bin:/opt/boxen/rbenv/shims:/opt/boxen/rbenv/bin:/opt/boxen/rbenv/plugins/ruby-build/bin:node_modules/.bin:/opt/boxen/nodenv/shims:/opt/boxen/nodenv/bin:/opt/boxen/bin:/opt/boxen/homebrew/bin:/opt/boxen/homebrew/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:bin:/opt/boxen/rbenv/shims:/opt/boxen/rbenv/bin:/opt/boxen/rbenv/plugins/ruby-build/bin:node_modules/.bin:/opt/boxen/nodenv/shims:/opt/boxen/nodenv/bin:/opt/boxen/bin:/opt/boxen/homebrew/bin:/opt/boxen/homebrew/sbin
$ ll /opt/boxen/homebrew/include/mpg123.h
lrwxr-xr-x 1 peterso staff 40 19 Jul 14:14 /opt/boxen/homebrew/include/mpg123.h -> ../Cellar/mpg123/1.15.4/include/mpg123.h
$ bundle install
Fetching gem metadata from https://rubygems.org/...
Installing audite (0.3.0)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
@petems
petems / puppet_install_deb.sh
Created October 23, 2013 13:43
Puppet Install through shell for Ubuntu
# Pick your poison http://apt.puppetlabs.com/pool/lucid/main/p/puppet/
PUPPET_COMMON_VERSION=3.1.1-1puppetlabs1
HIERA_VERSION=1.1.2-1puppetlabs1
echo 'APT::Install-Recommends "false";' >> /etc/apt/apt.conf
echo 'APT::Get::AllowUnauthenticated "true";' >> /etc/apt/apt.conf
echo 'deb http://apt.puppetlabs.com precise main' > /etc/apt/sources.list.d/puppetlabs.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 4BD6EC30