Skip to content

Instantly share code, notes, and snippets.

@nextrevision
nextrevision / example-rancher-metadata-tree
Last active February 24, 2018 17:53
Example traversed tree of the Rancher metadata service
/containers
/containers/0
/containers/0/create_index :
/containers/0/health_state :
/containers/0/host_uuid : da4aa4b0-ee2f-4ad3-8ded-b09917821cfa
/containers/0/hostname : dockermachine
/containers/0/ips
/containers/0/ips/0 : 10.42.176.231
/containers/0/labels
/containers/0/name : Network Agent
package main
import (
"fmt"
"github.com/pkg/errors"
"github.com/rancher/go-rancher-metadata/metadata"
)
func main() {
@nextrevision
nextrevision / deleteJobBuildRange
Last active February 19, 2016 20:22
Jenkins groovy script to delete builds x through y for a specific job
# from http://superuser.com/a/589532
Jenkins.instance.getItemByFullName('jobName').builds.findAll { it.number > 1 && it.number < 100 }.each { it.delete() }
@nextrevision
nextrevision / vagrant_up_vb4.3
Created January 27, 2016 15:38
vagrant #6895 debug logs
# using an image with NetworkManager disabled from starting
INFO global: Vagrant version: 1.8.1
INFO global: Ruby version: 2.2.3
INFO global: RubyGems version: 2.4.5.1
INFO global: VAGRANT_VAGRANTFILE="/home/ubuntu/project/Vagrantfile.rhel-project"
INFO global: VAGRANT_LOG="debug"
INFO global: VAGRANT_OLD_ENV_HOME="/home/ubuntu"
INFO global: VAGRANT_OLD_ENV_XDG_SESSION_ID="78"
INFO global: VAGRANT_OLD_ENV_PWD="/home/ubuntu/project"
INFO global: VAGRANT_OLD_ENV_GOPATH="/home/ubuntu/Projects/go"
@nextrevision
nextrevision / readinglist2json.js
Created December 2, 2015 16:07
Script to convert Safari's reading list to JSON
# Usage: npm install plist-json && node readinglist2json.js
var plist = require('plist-json');
plist.parse(process.env.HOME + '/Library/Safari/Bookmarks.plist', function(err, json) {
if (err) {
console.log(err);
return;
}
for (i=0; i<json.Children.length; i++) {
@nextrevision
nextrevision / unsource.sh
Last active November 16, 2015 16:10
Small script to unsource variables from a script or file. See http://nextrevision.github.io/2015/unsourcing-vars-files-in-bash/
#!/bin/bash -e
if [ -z "$1" ]; then
echo "usage: unsource.sh vars.env"
elif [ ! -f "$1" ]; then
echo "No such file: ${1}"
else
__start_env=$(mktemp -t unsource.XXXXXX)
__end_env=$(mktemp -t unsource.XXXXXX)
@nextrevision
nextrevision / registrycli
Last active August 29, 2015 14:23
CLI tool to interact with private docker registries
#!/bin/bash
# requirements:
# brew install gawk gsed
# settings file ~/.registry_settings
# REGISTRY="registry.acme.com"
# URL="https://${REGISTRY}:5000/v1"
# USERNAME="admin"
# PASSWORD="password"
@nextrevision
nextrevision / puppet_compile.rb
Created April 20, 2015 20:37
Compiles a puppet catalog without any puppet config files
# Requires automysqlbackup and stdlib module to be a child
# directory of the CWD
require "puppet"
require "json"
def run
manifest_path = './manifests/site.pp'
module_paths = ['../','./']
config_dir = nil
hiera_config = nil
@nextrevision
nextrevision / watch_pps.sh
Created March 2, 2015 14:20
Watch PPS for a given interface
#!/bin/bash
[ -z $1 ] && { echo "usage: $0 [iface] [interval: default 1]"; exit 1; }
IFACE=$1
INTERVAL=${2:-1}
loop=1
PPS_RX=/sys/class/net/${IFACE}/statistics/rx_packets
PPS_TX=/sys/class/net/${IFACE}/statistics/tx_packets
@nextrevision
nextrevision / replay_and_test.py
Last active August 29, 2015 14:15
Duplicate/Replay and Reroute HTTP Request and Compare Responses with mitmproxy
# File: Vagrantfile
# Vagrant.configure(2) do |config|
# config.vm.box = "ubuntu/trusty64"
# end
#
# Process:
# $ wget https://gist.githubusercontent.com/nextrevision/f81cc9493af565613e6a/raw/e48f4229743f1f29e82fb17d7129c8dead3c51f0/replay_and_test.py
# $ vagrant up
# $ vagrant ssh
# $ sudo apt-get update