Skip to content

Instantly share code, notes, and snippets.

View Calculator.java
/*
* @name Calculator.java
*
* Created on Jan 13, 2012, 5:03:48 PM
*/
package plugins;
View juniper_bgp_peer_data.groovy
import com.santaba.agent.groovyapi.snmp.Snmp;
import javax.xml.bind.DatatypeConverter;
def convertHexIPtoString(hex) {
if (hex.contains(":")) {
tempaddr = hex.split(":")
hex = tempaddr.join("")
}
InetAddress address = InetAddress.getByAddress(DatatypeConverter.parseHexBinary(hex))
View gist:4fb7064d7f72105913c8e8a4c1e21a8f
term from-ospf {
from {
protocol ospf;
route-filter 10.0.0.0/8 orlonger;
}
then accept;
}
term from-ospf_accept-only-large-externals {
from {
protocol ospf;
View Code.gs
var DAYSOFWEEK = [ScriptApp.WeekDay.SUNDAY, ScriptApp.WeekDay.MONDAY, ScriptApp.WeekDay.TUESDAY,
ScriptApp.WeekDay.WEDNESDAY, ScriptApp.WeekDay.THURSDAY,
ScriptApp.WeekDay.FRIDAY, ScriptApp.WeekDay.SATURDAY];
String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
}
function isValidDate(d) {
return d instanceof Date && !isNaN(d);
View reload_nginx.sh
#!/bin/sh
PATH=/usr/local/bin:/usr/bin:/bin
sudo cp /volume1/docker/www.usenet.conf /etc/nginx/app.d/www.usenet.conf
sudo nginx -s reload
View gist:d640ffcd54c539bc58e6d186d42571a9
server {
listen [::]:80;
server_name www.drop1.neilhanlon.me drop1.neilhanlon.me;
root /var/www/html/;
index index.html;
location / {
root /var/www/html/;
access_log on;
try_files $uri $uri/;
View gist:975ec30e616d42098abe2f5b3de0ce7f
[platform]
name = XCP
version = 2.3.0
[branding]
name = XenServer
version = 7.2.0
[keys]
key1 = RPM-GPG-KEY-XS-7-LCM
View gist:1ad95838cbe77601023ac4e63d898f94
default_vlans: &default_vlans "{
'vlan {{ admin_vlan }}': {
'description': 'Production/Administration',
'tagged_members': [
{
'port': 'port-channel 10',
'state': 'present'
}
],
'state': 'present'
View methods.py
def add_interface_group_to_segment(self, tenant_name, segment_name, interface_group_name, vlan_id):
segments = self.get_segments(tenant_name)
interface_groups = self.get_interface_groups()
segment_membership = self.get_segment_interface_groups(tenant_name, segment_name)
verb = self.verb_check(segment_membership)
segment_exists, dummy = self.resource_exists(segments, 'name', segment_name)
interface_group_exists, dummy = self.resource_exists(interface_groups, 'name', interface_group_name)
interface_assigned_to_segment, dummy = self.resource_exists(segment_membership, 'interface-group', interface_group_name)
View neil.py
def assign_interface_group_to_segment(vlans, interface_groups):
if not ( type(vlans) is list ) and ( type(interface_groups) is list):
print("Parameters must be supplied as a list.")
return
# Lets go ahead and normalize the vlan list into strings because I'm nice to myself...
vlans = [str(vlan) for vlan in vlans]
segments = [segment for segment in segment_info if segment[':vlan_tag'] in vlans]