Skip to content

Instantly share code, notes, and snippets.

View Apsu's full-sized avatar

Eve Apsu

  • Lambda Labs
  • Pittsburgh, PA
View GitHub Profile
@Apsu
Apsu / ssh.exp
Created January 12, 2013 19:57
SSH expect wrapper hooked into scripts/gd (gpg -dq --batch --no-tty $@ 2>/dev/null)
#!/usr/bin/expect -f
trap {
set rows [stty rows]
set cols [stty columns]
stty rows $rows columns $cols < $spawn_out(slave,name)
} WINCH
set keyf [lindex $argv 0]
set user [lindex $argv 1]
@Apsu
Apsu / failover.sh
Last active February 12, 2024 07:08
An example failover script for dual WAN, using a ping healthcheck and managing default routes appropriately
#!/bin/bash
# Set defaults if not provided by environment
CHECK_DELAY=${CHECK_DELAY:-5}
CHECK_IP=${CHECK_IP:-8.8.8.8}
PRIMARY_IF=${PRIMARY_IF:-eth0}
PRIMARY_GW=${PRIMARY_GW:-1.2.3.4}
BACKUP_IF=${BACKUP_IF:-eth1}
BACKUP_GW=${BACKUP_GW:-2.3.4.5}
@Apsu
Apsu / grizzly.json
Last active December 17, 2015 23:19
Grizzly Quantum Environment
{
"name": "grizzly",
"description": "",
"cookbook_versions": {
},
"json_class": "Chef::Environment",
"chef_type": "environment",
"default_attributes": {
},
"override_attributes": {
@Apsu
Apsu / gist:5699414
Last active December 18, 2015 00:49
Quantum Cookbook Intro

Currently the assumed basic infrastructure is as follows:

  • 1+ Controller node(s) (role[single-controller] in Chef, didn't try HA roles, might need tweaking)
    • eth0: OOB management interface
  • 1 Network node (role[single-network-node] in Chef)
    • eth0: OOB (out of band, non-quantum) management interface
    • eth1: physical provider interface
  • 1+ Compute node(s) (role[single-compute] in Chef, same on HA)
    • eth0: OOB management interface
  • eth1: physical provider interface
@Apsu
Apsu / transform.sh
Created June 18, 2013 23:26
Set environment of all chef nodes
knife exec -E 'nodes.transform("chef_environment:_default") { |n| n.chef_environment("grizzly") }'
092600 Great time to setup an AndrewFS cluster! ;P
092611 .: skvidal:. Apsu: you're joking, right?
092625 .:Apsu:. haha. Yes. Though AFS is kind of amazing, for what it is
092631 .: skvidal:. Apsu: I maintained an AFS cell for long enough to know it is nothing you ever want to use
092632 for anything
092633 ever
092634 .:Apsu:. hahaha
092643 .: skvidal:. and the people involved should be hurt
092644 .:Apsu:. As I said. Amazing :P
092651 .: skvidal:. and their offspring made to never work on computers
@Apsu
Apsu / gist:5833564
Last active December 18, 2015 19:29
diff --git a/recipes/quantum-ovs-plugin.rb b/recipes/quantum-ovs-plugin.rb
index 4d00b8a..94a0455 100644
--- a/recipes/quantum-ovs-plugin.rb
+++ b/recipes/quantum-ovs-plugin.rb
@@ -49,11 +49,10 @@ execute "create integration bridge" do
not_if "ovs-vsctl show | grep 'Bridge br-int'" ## FIXME
end
-execute "create provider bridges" do
- node["quantum"]["ovs"]["provider_networks"].each do |k,v|
@Apsu
Apsu / notices.pl
Created June 27, 2013 15:25
Weechat IRCop server notices router
use strict;
my $Version = "0.01";
my $SCRIPT = "notices";
my $AUTHOR = "klb";
my $LICENSE = "GPL3";
my $DESCRIPTION = "test notices";
my $SourceServerBuffer;
@Apsu
Apsu / preset.sh
Last active March 13, 2024 01:24
GPG passphrase preset to be called from pam_exec
#!/bin/bash
# grab PAM-provided auth token
read token
# gpg-preset-passphrase is often in /usr/libexec or /usr/lib/gnupg
preset=/usr/lib/gnupg/gpg-preset-passphrase
# grab our user, USER isn't always set
USER=$(id -un)
@Apsu
Apsu / Soundex.py
Created August 7, 2013 18:27
Soundex generator one-liner
from functools import reduce # Needed for Python 3.x
from operator import add
def soundex(letters, duplicates=False, initial=True, size=4,
sounds=[('aeiouyhw', ''), ('bfpv', '1'), ('cgjkqsxz', '2'), ('dt', '3'), ('l', '4'), ('mn', '5'), ('r', '6')]):
return '0'*size if not len(letters) else ((letters[0] if initial else '') +
reduce(lambda stack, next: stack+next if stack[-1:] != next or duplicates else stack,
map(lambda letter: reduce(add, (val for (key,val) in sounds if letter in key), ''), letters[1:]), ''))[:size if size else None].ljust(size, '0')