Skip to content

Instantly share code, notes, and snippets.

View bartdorlandt's full-sized avatar

Bart Dorlandt bartdorlandt

View GitHub Profile
@ktbyers
ktbyers / ansible_j2.py
Last active August 18, 2021 23:28
Use Ansible Jinja2 Filters in Python
from jinja2.environment import Environment
from jinja2 import FileSystemLoader, StrictUndefined
from ansible_collections.ansible.netcommon.plugins.filter.ipaddr import ipmath
from ansible_collections.ansible.netcommon.plugins.filter.ipaddr import ipaddr
env = Environment(undefined=StrictUndefined)
env.loader = FileSystemLoader(['.', './templates/'])
env.filters["ipmath"] = ipmath
@wichert
wichert / mac.py
Created January 25, 2016 12:44
Python example for http://macvendors.co/
>>> import pprint
>>> import requests
>>> MAC_URL = 'http://macvendors.co/api/%s'
>>> r = requests.get(MAC_URL % 'BC:92:6B:A0:00:01')
>>> pprint.pprint(r.json())
{'result': {'address': '1 Infinite Loop Cupertino CA US 95014 ',
'company': 'Apple, Inc.',
'mac_prefix': 'BC:92:6B'}}
@paalfe
paalfe / CiscoKeyGen.py
Created May 17, 2015 20:45
Cisco IOU License Generator. Originally found at http://www.routingloops.co.uk/cisco/gns3-v1-1-install-on-ubuntu-14-04-lts/, I have done a few changes to it. Make the file executable with " chmod +x CiscoKeyGen.py " and execute it " ./CiscoKeyGen.py ".
#! /usr/bin/python
print "\n*********************************************************************"
print "Cisco IOU License Generator - Kal 2011, python port of 2006 C version"
import os
import socket
import hashlib
import struct
# get the host id and host name to calculate the hostkey
hostid=os.popen("hostid").read().strip()
hostname = socket.gethostname()
@Mic92
Mic92 / ansible.cfg
Created September 2, 2014 12:09
ansible connection plugin for lxc using lxc-attach
# add the following line to your ansible.cfg
connection_plugins = /usr/share/ansible_plugins/connection_plugins:/etc/ansible/connection_plugins
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active July 4, 2024 17:58
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname