Skip to content

Instantly share code, notes, and snippets.

View smashwilson's full-sized avatar
🤖
HAPPINESS IS MANDATORY

Ash Wilson smashwilson

🤖
HAPPINESS IS MANDATORY
  • GitHub Staff
  • 10:59 (UTC -04:00)
View GitHub Profile
@smashwilson
smashwilson / deconst-publish
Last active September 23, 2015 13:35
Manually publish Sphinx repositories to staging.developer.rackspace.com or developer.rackspace.com
#!/bin/bash
set -euo pipefail
help() {
cat <<EOM >&2
Usage: ${0} [-e staging] [-k APIKEY] [-p .]
-e env Choose the environment to submit to. Either "production" or "staging". Default: staging.
-k APIKEY Use the specified API key. Default: \${CONTENT_STORE_APIKEY}.
@smashwilson
smashwilson / update-lb.py
Created September 2, 2015 13:34
Update the condition of a load balancer node with libcloud
import os
import time
from libcloud.loadbalancer.types import State, Provider, MemberCondition
from libcloud.loadbalancer.providers import get_driver
username = os.environ['RACKSPACE_USERNAME']
apikey = os.environ['RACKSPACE_APIKEY']
region = os.environ['RACKSPACE_REGION']
@smashwilson
smashwilson / lb-update-condition.js
Created September 2, 2015 12:57
Updating the condition of an existing node on a Cloud Load Balancer
// Updating the condition of an existing load balancer node with pkgcloud.
var pkgcloud = require('pkgcloud');
var client = pkgcloud.loadbalancer.createClient({
provider: 'rackspace',
username: process.env.RACKSPACE_USERNAME,
apiKey: process.env.RACKSPACE_APIKEY,
region: process.env.RACKSPACE_REGION
});
// User code:
// "Extract" still has return type "os.GetHeader, err"
c, err := containers.Get(client, "foo").Extract()
if err != nil {
if gophercloud.HasErrorCode(err, gophercloud.ErrNotFound) {
// ...
}
@smashwilson
smashwilson / example.yml
Created February 13, 2015 18:45
Sample playbook for Rackspace Cloud Monitoring modules.
---
- name: Rackspace Cloud Monitoring test playbook
hosts: all
connection: local
gather_facts: false
tasks:
- name: Entity
rax_mon_entity:
credentials: .credentials
@smashwilson
smashwilson / terrible_hackedup_ruby.rb
Created February 13, 2015 14:12
Automatically convert Perigee calls to client.Request calls.
#!/bin/env ruby
require 'find'
def convert(path)
content = File.read(path)
ncontent = []
line_no = 1
in_req = false
@smashwilson
smashwilson / multipleopts.go
Created November 17, 2014 15:56
Using multiple OpenStack extensions that modify the server creation options in Gophercloud
import (
"github.com/rackspace/gophercloud/openstack/compute/v2/servers"
bfw "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume"
dc "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/diskconfig"
)
// 1. Base CreateOpts
baseOpts := servers.CreateOpts{
Name: "servername",
@smashwilson
smashwilson / pagination.rb
Created October 17, 2014 11:59
Pagination in Fog
require 'pp'
storage = Fog::Storage.new(
provider: :rackspace,
rackspace_username: ENV['RAX_USERNAME'],
rackspace_api_key: ENV['RAX_API_KEY'],
rackspace_region: :dfw
)
d = storage.directories.get('big-container')
@smashwilson
smashwilson / commands.sh
Last active November 7, 2019 23:35
Move a subdirectory from one git repository to a subdirectory of another, without losing commit history.
# Assumptions:
#
# * After the merge is complete, the directory should exist in the target repository and not exist in the source
# repository. In other words, this is a move, not a cross-reference: we never want to be able to push commits
# back to the source repository, or merge further changes from the source repository. If you want to do that
# instead, a subtree merge is what you're looking for.
#
# * The directory doesn't exist in the target repository yet.
#
# In this example, we're moving the "/openstack-swift/" directory from jclouds/jclouds-labs-openstack to
// This is a proposal for an alternative approach to client interactions with Gophercloud.
import (
"time"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/rackspace"
)
// Provider adheres to a common gophercloud.Client interface.