Skip to content

Instantly share code, notes, and snippets.

View DavidWittman's full-sized avatar

David Wittman DavidWittman

View GitHub Profile
@DavidWittman
DavidWittman / lsyncd.lua
Created June 21, 2012 00:14
Lsyncd alternate SSH key
settings = {
logfile = "/var/log/lsyncd/lsyncd.log",
statusFile = "/var/log/lsyncd/lsyncd-status.log",
statusInterval = 20
}
servers = {
"web02",
"web03"
}
@DavidWittman
DavidWittman / python-nested_list_comprehensions.md
Created July 26, 2012 20:08
Nested list comprehensions in Python

Nested list comprehensions in Python

For some reason or another, I'm always second guessing myself when writing nested list comprehensions. Here's a quick example to clarify what's going behind the scenes:

>>> words = ["foo", "bar", "baz"]
>>> [letter for word in words for letter in word]
['f', 'o', 'o', 'b', 'a', 'r', 'b', 'a', 'z']
@DavidWittman
DavidWittman / iptables-nat.md
Created September 29, 2012 20:38
iptables n'at

iptables n'at

Source NAT

Source NAT changes the source address in IP header of a packet. It may also change the source port in the TCP/UDP headers. The typical usage is to change the a private (rfc1918) address/port into a public address/port for packets leaving your network. Available only in the POSTROUTING chain in iptables.

Syntax

iptables -t nat -A POSTROUTING -i eth1 -j SNAT --to-source 1.2.3.4[:port]

Example

@DavidWittman
DavidWittman / 1z0873-notes.md
Last active December 10, 2015 04:48
MySQL DBA exam 1Z0-873 Notes

Notes from the DBA Exam (Part 1)

Note: for questions where you can select multiple answers, it will tell you how many to choose.

Overview

  • Lots of InnoDB and transactional stuff
  • Understand everything about locking

Specific questions

OpenStack Summit Images Talk

Who we are

Rackspace Private Cloud. We install and operate Openstack clusters, both locally in our datacenters, and remotely in customer datacenters.

Reference Alamo v3?

What are we talking about?

Automating base image builds for OpenStack private clouds.

@DavidWittman
DavidWittman / clouddns-export.py
Last active December 12, 2018 01:06
Exports all domains for a Rackspace Cloud account in BIND9 format
#!/usr/bin/env python
import json
import os
import time
import clouddns
USERNAME = ''
APIKEY = ''
@DavidWittman
DavidWittman / wireshark-analysis.md
Last active January 4, 2024 17:14
Outline for Packet Analysis with Wireshark

Packet Analysis with Wireshark

Links

Common filters

Source IP is 192.168.1.1

ip.src == 192.168.1.1

@DavidWittman
DavidWittman / tokenreaper.sql
Last active December 14, 2015 09:08
MySQL scheduled event to remove Keystone authentication tokens expired for over one week.
USE keystone
-- This needs to be set in the my.cnf to persist
SET GLOBAL event_scheduler = 1;
DELIMITER $$
CREATE EVENT tokenreaper
ON SCHEDULE EVERY 1 WEEK
DO BEGIN
DELETE FROM `token` WHERE expires <= DATE_SUB(NOW(), INTERVAL 1 WEEK);
END $$
DELIMITER ;
@DavidWittman
DavidWittman / saltstack-devstack.md
Last active March 29, 2018 15:36
Automated DevStack deployments on Rackspace with salt-cloud

Automated DevStack deployments on Rackspace with salt-cloud

Preparation

Install salt-master and salt-cloud

These instructions will install salt-master and salt-cloud on recent Ubuntu releases. Consult the SaltStack Installation Documentation should you require instructions for other distributions.

echo deb http://ppa.launchpad.net/saltstack/salt/ubuntu `lsb_release -sc` main | sudo tee /etc/apt/sources.list.d/saltstack.list
@DavidWittman
DavidWittman / neutron-scope
Last active December 20, 2015 00:39
neutron-scope: Run a command in the network namespace of an OpenStack server by name or ID
#!/bin/bash
# neutron-scope
#
# Run a command in the network namespace of an OpenStack server
#
# Pro-tip: The string _IP_ is replaced with the first IP address of the server
# e.g. neutron-scope my-server ssh root@_IP_
set -e