Skip to content

Instantly share code, notes, and snippets.

View scottslowe's full-sized avatar

Scott S. Lowe scottslowe

View GitHub Profile
@scottslowe
scottslowe / json-prettify-script
Created November 8, 2013 01:32
This very simple shell script can be used by BBEdit as a text filter to "prettify" JSON output in a more human-readable form.
#!/bin/sh
python -m json.tool
@scottslowe
scottslowe / pretty-json
Created November 8, 2013 12:09
This output came from running the raw JSON-serialized response to a REST API through the python json.tool command.
{
"result_count": 3,
"results": [
{
"_href": "/ws.v1/lswitch/3ca2d5ef-6a0f-4392-9ec1-a6645234bc55",
"_schema": "/ws.v1/schema/LogicalSwitchConfig",
"type": "LogicalSwitchConfig"
},
{
"_href": "/ws.v1/lswitch/81f51868-2142-48a8-93ff-ef612249e025",
@scottslowe
scottslowe / ugly-json
Last active August 19, 2016 23:59
This is raw JSON-serialized output from a REST API call
{"results": [{"type": "LogicalSwitchConfig", "_schema": "/ws.v1/schema/LogicalSw
itchConfig", "_href": "/ws.v1/lswitch/3ca2d5ef-6a0f-4392-9ec1-a6645234bc55"}, {"
type": "LogicalSwitchConfig", "_schema": "/ws.v1/schema/LogicalSwitchConfig", "_
href": "/ws.v1/lswitch/81f51868-2142-48a8-93ff-ef612249e025"}, {"type": "Logical
SwitchConfig", "_schema": "/ws.v1/schema/LogicalSwitchConfig", "_href": "/ws.v1/
lswitch/9fed3467-dd74-421b-ab30-7bc9bfae6248"}], "result_count": 3}
@scottslowe
scottslowe / lxc-template
Created November 25, 2013 19:59
This snippet of libvirt XML can be used as a template when creating LXC containers that you want to run/manage via libvirt.
<domain type='lxc'>
<name>REPLACE</name>
<memory>327680</memory>
<os>
<type>exe</type>
<init>/sbin/init</init>
</os>
<vcpu>1</vcpu>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
@scottslowe
scottslowe / bridged-libvirt-ovs-xml
Created December 2, 2013 11:51
You can use this libvirt XML code to define a virtual network that "front ends" Open vSwitch (OVS).
<network>
<name>bridged</name>
<uuid>ff5f8075-31a7-4cc9-21bf-5c8d144f58f0</uuid>
<forward mode='bridge'/>
<bridge name='br-ex' />
<virtualport type='openvswitch'/>
<portgroup name='untagged' default='yes'>
</portgroup>
</network>
@scottslowe
scottslowe / apt-source-uca-havana
Created December 13, 2013 19:10
This snippet of Puppet code configures an Ubuntu system to use the Havana packages from the Ubuntu Cloud Archive as an apt repository.
apt::source { 'ubuntu-cloud':
location => 'http://ubuntu-cloud.archive.canonical.com/ubuntu',
repos => 'main',
release => 'precise-updates/havana',
include_src => false,
required_packages => 'ubuntu-cloud-keyring',
}
@scottslowe
scottslowe / move-msg-applescript
Created December 16, 2013 17:32
This AppleScript can be used to help quickly file spam messages into a spam training folder
-- This script moves messages to a spam training folder
-- Set some default values to be used later in the script; not all values may be used
property destMailbox : "Spam Training"
property destAccount : "example.com"
-- Handler called when running script from script menu
on run
tell application "Mail"
set theSelectedMessages to selection
if ((count of theSelectedMessages) < 1) then
@scottslowe
scottslowe / lxc-ovsup
Created January 22, 2014 23:14
This script can be used to automatically attach LXC instances to Open vSwitch (OVS) on startup. You'll need to call this script from the container's configuration using the "lxc.network.script.up" configuration parameter.
#!/bin/bash
BRIDGE="br-int"
ovs-vsctl --may-exist add-br $BRIDGE
ovs-vsctl --if-exists del-port $BRIDGE $5
ovs-vsctl --may-exist add-port $BRIDGE $5
@scottslowe
scottslowe / new-lswitch-json
Created February 19, 2014 23:26
This snippet of JSON-encoded data could be used with a VMware NSX RESTful API call to create a new logical switch.
{
"display_name": "test-lswitch",
"port_isolation_enabled": false,
"transport_zones": [
{
"zone_uuid": "dca3d854-b329-5458-b711-0df2d5762d7a",
"binding_config": {},
"transport_type": "stt"
}
],
@scottslowe
scottslowe / libvirt-default-network
Created April 2, 2014 15:32
This XML is the definition of the default libvirt network.
<network>
<name>default</name>
<uuid>259bc60d-0ed4-4924-8537-6bccb979843e</uuid>
<forward mode='nat'/>
<bridge name='virbr0' stp='on' delay='0'/>
<ip address='192.168.122.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.122.2' end='192.168.122.254'/>
</dhcp>
</ip>