Skip to content

Instantly share code, notes, and snippets.

View ozzyjohnson's full-sized avatar

Ozzy Johnson ozzyjohnson

View GitHub Profile
@ozzyjohnson
ozzyjohnson / ipak.R
Created March 7, 2016 01:18 — forked from stevenworthington/ipak.R
Install and load multiple R packages at once
# ipak function: install and load multiple R packages.
# check to see if packages are installed. Install them if they are not, then load them into the R session.
ipak <- function(pkg){
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg))
install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
@ozzyjohnson
ozzyjohnson / flip.py
Created May 18, 2015 00:58
hello world coin flips
import sys
import itertools
for test in itertools.product([False,True], repeat=2):
bob_flip = test[0]
alice_flip = test[1]
if bob_flip == False:
bob_guess = True
else:
bob_guess = False
@ozzyjohnson
ozzyjohnson / gist:aaebe09b0168da5b7180
Last active August 29, 2015 14:21
Convert exports from a NetWare DNS/DHCP server to CSV.
BEGIN {
FS = "="
ipan = ""
at = ""
lt = ""
hn = ""
lu = ""
le = ""
mac = ""
ci = ""
@ozzyjohnson
ozzyjohnson / filtermember.awk
Created May 12, 2015 23:56
Filtering the output of Novell eDirectory LDAP queries for CNs, I think.
BEGIN {
cn = ""
}
function trim(field) {
gsub(/\r/, "", field)
gsub(/^[ \t]+/, "", field)
return field;
}
@ozzyjohnson
ozzyjohnson / esx-cdp_neighbor.awk
Created May 12, 2015 23:52
ESXi CDP Neighbor to CSV
#Parses the output of CDP neighbor information from a VMWare ESXi host.
#
#-------------------------
#hostname vmnic1
#CdpVersion : 2
#Timeout : 0
#Ttl : 152
#Samples : 9854
#DevId : aaa-bbbb-cccc-dd
#Address : 10.10.1.1
@ozzyjohnson
ozzyjohnson / cdp_neighbor.awk
Created April 25, 2015 01:27
awk cisco IOS cli script
BEGIN {
device_id = ""
entry_address = ""
ip_address = ""
platform = ""
capabilities = ""
interface = ""
port_id = ""
holdtime = ""
version = ""
@ozzyjohnson
ozzyjohnson / vagrant_spot_instance.md
Last active June 19, 2018 15:44
Use an EC2 spot instance with Vagrant

Setup:

git clone git@github.com:nabeken/vagrant-aws.git
cd vagrant-aws
git checkout spot-3
gem build vagrant-aws.gemspec
vagrant install plugin vagrant-aws-0.5.0.gem

Vagrantfile:

@ozzyjohnson
ozzyjohnson / gist:a685d8104f5ce0ecbfa8
Created December 25, 2014 22:19
Destroying all docker images.
#!/bin/bash
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
@ozzyjohnson
ozzyjohnson / ucs_vif.md
Created November 28, 2014 22:57
Cisco UCS VIF paths enter error disabled until first use.

This produces warning events F0207, F0479, F0283. These errors clear once each port has been fully initialized by an appropriate driver - ESXi or Debian Squeeze installer images are an easy way to take care of this. Shame the docs make no mention of this and point only to failed uplinks and un-acknowledged hardware.

@ozzyjohnson
ozzyjohnson / gist:381b5beba6dc486b8c4f
Created November 14, 2014 18:23
Drop vmware tools on old Ubuntu guests.
mkdir -p /media/cdrom \
&& mount /dev/sr0 /media/cdrom \
&& tar -C /tmp -xzvf /media/cdrom/*.gz \
&& /tmp/vmware-tools-distrib/vmware-install.pl -d \
&& rm -rf /tmp/vmware-tools-distrib