Skip to content

Instantly share code, notes, and snippets.

@fluxrad
fluxrad / some_user.rb
Created November 1, 2011 21:52
Facter fact to test for a user
require 'facter'
Facter.add("some_user") do
setcode do
system "/usr/bin/id someuser >/dev/null 2>&1"
end
end
@fluxrad
fluxrad / pre-commit
Created April 11, 2012 19:04
A pre-commit git hook to validate puppet syntax
#!/bin/bash
# pre-commit git hook to check the validity of a puppet manifest
#
# Prerequisites:
# gem install puppet-lint puppet
#
# Install:
# /path/to/repo/.git/hooks/pre-comit
# Source RVM if needed
@fluxrad
fluxrad / projects.md
Created January 16, 2013 18:25
Random project ideas or "Cool shit that needs to happen."

Projects that totally need to happen

  • People need to know when a Turntable room is active - use case: companies that have employees who like to jam out together. Idead: An IFTTT channel or a job that contacts a group of subscribers when a Turntable.fm room is active/updated.
@fluxrad
fluxrad / sshrm.sh
Created September 9, 2013 19:02
A function definition to quickly remove host+key entries from .ssh/known_hosts. Useful for when a node is replaced, or you otherwise need to remove a group of hosts.
# Remove any entries from SSH known_hosts file
# that match the specified string.
sshrm () {
node=$1
echo "Removing $node from SSH known hosts"
sed -i '.bak' -e "/^$node/d" ~/.ssh/known_hosts
}
@fluxrad
fluxrad / Gemfile
Created July 18, 2014 19:30
Explode a list of netmasks
source 'https://rubygems.org'
gem 'netaddr'
@fluxrad
fluxrad / stackdriver.sh
Created September 11, 2014 20:46
Install Stackdriver Agent
#!/bin/bash
curl -o /etc/apt/sources.list.d/stackdriver.list http://repo.stackdriver.com/precise.list
curl --silent https://app.stackdriver.com/RPM-GPG-KEY-stackdriver |apt-key add -
apt-get update
apt-get install stackdriver-agent
@fluxrad
fluxrad / Dockerfile
Created September 22, 2014 19:21
Dockerfile for a basic rbenv + rails environment
# Inspired by Deepak's setup here - https://gist.github.com/deepak/5925003
FROM ubuntu:14.04
RUN apt-get update -qq && apt-get install -y build-essential nodejs npm git curl mysql-client libmysqlclient-dev
RUN mkdir -p /my_awesome_social_media_app
# Install rbenv
RUN git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv
RUN echo '# rbenv setup' > /etc/profile.d/rbenv.sh
@fluxrad
fluxrad / gist:be6088c7b4a752d2bf04
Created October 20, 2014 21:07
Dockerfile build fail.
FROM ruby:2.1.3
# works with ruby:2.1.2
# run with `docker build -t test .`
RUN apt-get -y update -qq && apt-get -y install r-base-dev
RUN pry
@fluxrad
fluxrad / update_hostname.sh
Created November 6, 2014 22:08
Update hostname on an AWS instance
# Fix an EC2 instance's hostname.
echo "ip-$(echo $(curl -s http://169.254.169.254/latest/meta-data/local-ipv4 | tr '.' '-'))" | sudo tee /etc/hostname | sudo xargs hostname
@fluxrad
fluxrad / bar.js
Created April 9, 2015 20:17
Dynamically requiring module in NodeJS
exports.index = function(req, res) {
res.send('This is bar!');
};