Skip to content

Instantly share code, notes, and snippets.

View jeffmccune's full-sized avatar

Jeff McCune jeffmccune

View GitHub Profile
@jeffmccune
jeffmccune / holdings.rb
Created October 5, 2020 15:48
Transform the holdings data from Personal Capital into CSV for spreadsheet processing
#! /usr/bin/env ruby
#
#
require 'json'
def run!
h = Holdings.new; h.load("holdings.json")
h.table.each do |row|
puts row.join("\t")
end
@jeffmccune
jeffmccune / atom_zfs.md
Last active September 23, 2020 17:26
Atom Gigabit ZFS encryption

Write:

tank% bash -x /data/media/fio-test /data/media/local-test
+ fio --filename=/data/media/local-test --name=write --ioengine=posixaio --rw=write --bs=128k --size=16GB --numjobs=1 --iodepth=128 --runtime=60 --time_based --group_reporting --eta-newline=1
write: (g=0): rw=write, bs=(R) 128KiB-128KiB, (W) 128KiB-128KiB, (T) 128KiB-128KiB, ioengine=posixaio, iodepth=128
fio-3.12
Starting 1 process
write: Laying out IO file (1 file / 16384MiB)
Jobs: 1 (f=1): [W(1)][6.6%][w=368MiB/s][w=2941 IOPS][eta 00m:57s]
@jeffmccune
jeffmccune / setup_server
Created September 20, 2020 17:43
Setup Server
#! /bin/bash
#
# Initial setup of a server. Run this as root.
apt -qq -y install curl git sudo rsync
set -eu
install -o0 -g0 -m0700 -d /root/.ssh
tmpfile="$(mktemp)"
@jeffmccune
jeffmccune / avoid_ remove_old_addr.sh
Last active September 16, 2020 18:38
Work around dhclient -x breaking policy routing when google-guest-agent starts
#!/bin/bash
#
# See https://github.com/GoogleCloudPlatform/guest-agent/issues/76
tmpfile="$(mktemp)"
cat <<"EOF" >"$tmpfile"
logmessage "Skipping ip -4 addr del ${old_ip_address:-}/${old_prefix:-} dev ${interface:-} to work around https://github.com/GoogleCloudPlatform/guest-agent/issues/76"
exit_with_hooks 0
EOF
install -o 0 -g 0 -m 0755 "$tmpfile" /etc/dhcp/dhclient-down-hooks
rm -f "$tmpfile"
@jeffmccune
jeffmccune / stub_ip.sh
Created September 16, 2020 16:32
Stub IP to troubleshoot dhclient
#! /bin/bash
if ! [[ -f /jeff/ip ]]; then
mkdir /jeff
mv /sbin/ip /jeff/ip
fi
cat <<"EOF" > /sbin/ip
#! /bin/bash
#
read -a st < /proc/$$/stat
read -a ppid < /proc/${st[3]}/stat
$ bundle install --path .bundle/gems/
Fetching https://github.com/rodjek/rspec-puppet.git
Fetching gem metadata from https://rubygems.org/
Fetching version metadata from https://rubygems.org/
Fetching dependency metadata from https://rubygems.org/
Resolving dependencies.........
Installing rake 11.2.2
Installing CFPropertyList 2.2.8
Installing addressable 2.4.0
Installing ansi 1.5.0
@jeffmccune
jeffmccune / root_user.pp
Created April 11, 2012 18:01
Manage the Root User Password on Linux
# = Class: site::root_user
#
# This is a simple class to manage the root user password.
# The shadow hash of an existing password can be easily obtained
# by running `puppet resource user root` on a Linux system
# that has the desired root password already set.
# Puppet will then manage this password everywhere.
#
# First, I set the password to "puppet" on one Linux node and then get back the
# shadow hash.
@jeffmccune
jeffmccune / puppet_multiple_ca.md
Created July 5, 2012 19:03
Puppet Multiple CA's

Standard CA Bundle

This CA bundle is located at puppet master --confdir=$PUPPET_CONFDIR --configprint localcacert and contains CA certs in the following order:

  1. Root CA
  2. Signing CA
  3. Puppet Master CA 1
  4. Puppet Master CA 2

The following error may be resolved by changing the CA certificate order in the bundle to be:

@jeffmccune
jeffmccune / irc_notify_loop.rb
Created November 20, 2010 20:25
IRC Boxcar + Jabber notification
#!/usr/bin/env ruby
#
# This script reads lines from STDIN and sends a notification for each line.
# It's intended to be used with the fnotify.pl IRSSI script to write notices
# and hilights to a plain text file. tail -f links the two systems together.
require 'rubygems'
# For Jabber Notification
gem 'xmpp4r-simple'
@jeffmccune
jeffmccune / gist:3385373
Created August 18, 2012 08:46
Mountain Lion rbenv.md

rbenv 1.9.3-p194 build

To avoid OpenSSL segfaults, link ruby against macports' OpenSSL in /opt/local.

Before you install Ruby, make sure you have MacPorts installed for Mountain Lion.

$ CONFIGURE_OPTS="--with-openssl-dir=/opt/local" rbenv install 1.9.3-p194
Downloading http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz...
Installing yaml-0.1.4...
Installed yaml-0.1.4 to /Users/jeff/.rbenv/versions/1.9.3-p194