Skip to content

Instantly share code, notes, and snippets.

View awfki's full-sized avatar

Dave awfki

  • Atlanta, GA
View GitHub Profile

Mac Network Commands Cheat Sheet

After writing up the presentation for MacSysAdmin in Sweden, I decided to go ahead and throw these into a quick cheat sheet for anyone who’d like to have them all in one place. Good luck out there, and stay salty.

Get an ip address for en0:

ipconfig getifaddr en0

Same thing, but setting and echoing a variable:

@awfki
awfki / pynetbox_examples.md
Last active November 16, 2023 22:19
pynetbox examples

pynetbox examples

Long time network engineer, did some perl a long time ago and am liking python pretty well but the pynetbox documentation is badly lacking IMO. If I were a python wizard I'm sure it would all be obvious but I'm not and it's really frustrating that more example weren't provided.

Many of the following examples were cadged from various places on the interwebs and HAVE NOT BEEN TESTED.

Prereqs

import pynetbox
NETBOX = 'https://netbox.fq.dn/'
nb = pynetbox.api(NETBOX, get_token('nb'))

Jinja2

if/elif

{% if variable == 'one' %}stuff for one
{% elif variable == 'two' %}stuff for two
{% else %}stuff for anything else
{% endif %}

Ansible

@awfki
awfki / Bash string manipulation cheatsheet.md
Last active November 19, 2019 19:25 — forked from magnetikonline/README.md
Bash string manipulation cheatsheet

Bash string manipulation cheatsheet

Assignment
Assign value to variable if variable is not already set. Value will be returned.

Couple with : no-op if return value is to be discarded.
${variable="value"}
: ${variable="value"}
@awfki
awfki / uncipher.py
Created January 16, 2018 03:23 — forked from jayswan/uncipher.py
Python: reverse Cisco type 7 passwords with input from file or stdin
"""
Uncipher Cisco type 7 ciphered passwords
Usage: python uncipher.py <pass> where <pass> is the text of the type 7 password
Example:
$ python uncipher.py 094F4F1D1A0403
catcat
"""
import fileinput
import sys
@awfki
awfki / leasecheck.pl
Created December 12, 2017 18:46 — forked from mattpascoe/leasecheck.pl
Perl script to parse ISC DHCP lease file and display basic info. I dont recall if I wrote this or if I found it on the interwebs somewhere!?!?.. a quick goog search did not find it but hey its useful so have at it.
#!/usr/bin/perl
#
# Update the path to your lease file below
use strict;
use File::Copy;
#use DateTime;
#always parse a copy not the live file
#my $leasefile = '/var/lib/dhcpd/dhcpd.leases';
my $leasefile = '/var/lib/dhcp/db/dhcpd.leases';
@awfki
awfki / netbox-ansible.py
Created October 26, 2017 13:43 — forked from linuxsimba/netbox-ansible.py
Ansible Netbox Integration Example
#!/usr/bin/python
""" Ansible Inventory Generated From Netbox
Author: Stanley Karunditu <stanley@linuxsimba.com>
License: MIT
Requirements:
* use netbox device roles that result in hyphenated role names. E.g
@awfki
awfki / addresses.py
Created October 26, 2017 13:27 — forked from candlerb/addresses.py
Netbox report to check for missing Primary IP Addresses
from extras.reports import Report
from dcim.models import Device
from virtualization.models import VirtualMachine
from ipam.constants import *
from ipam.models import IPAddress, Prefix
LOOPBACK_ROLES = [
IPADDRESS_ROLE_LOOPBACK,
IPADDRESS_ROLE_ANYCAST,
IPADDRESS_ROLE_VIP,
@awfki
awfki / ToggleAirport Installation.md
Last active June 8, 2017 17:46 — forked from albertbori/Installation.md
Automatically disable Wifi when an Ethernet connection (cable) is plugged in on a Mac

Overview

This is a bash script that will automatically turn your wifi off if you connect your computer to an ethernet connection and turn wifi back on when you unplug your ethernet cable/adapter. If you decide to turn wifi on for whatever reason, it will remember that choice. This was improvised from this mac hint to work with Yosemite, and without hard-coding the adapter names. It's supposed to support growl, but I didn't check that part. I did, however, add OSX notification center support. Feel free to fork and fix any issues you encounter.

Most the credit for these changes go to Dave Holland.

Requirements

  • Mac OSX 10+
  • Administrator privileges