Skip to content

Instantly share code, notes, and snippets.

@riethm
riethm / cs_upload_object.py
Last active October 2, 2020 18:01
Upload a file to cleversafe using aws python sdk
#!/bin/python
'''Sample: Upload a file to cleversafe'''
import boto3
# Create an s3 resource object, pointing to Cleversafe's public "s3" endpoint
s3 = boto3.resource('s3', endpoint_url='https://s3-api.us-geo.objectstorage.softlayer.net')
# The above reads credentials from environment variables, or ~/.aws/credentials file
# Alternatively, you can provide credentials with the following kwargs:
@riethm
riethm / orderHourlyBM.go
Created October 3, 2016 14:47
Order hourly bare metal using a preset
func orderHourlyBM(sess *session.Session) {
hwservice := services.GetHardwareService(sess)
//hwservice.GetCreateObjectOptions()
template := datatypes.Hardware{}
template.Datacenter = &datatypes.Location{Name: sl.String("dal01")}
template.Hostname = sl.String("mike-bm-test")
template.Domain = sl.String("softlayer.com")
template.HourlyBillingFlag = sl.Bool(true)
template.NetworkComponents = []datatypes.Network_Component{{MaxSpeed: sl.Int(1000)}}
@riethm
riethm / update.sh
Last active September 22, 2016 15:40
#!/bin/bash
apt-get update -y
apt-get dist-upgrade -y
@riethm
riethm / responder.go
Created September 16, 2016 13:53
httpmock responder that cycles through a list of responses
import (
"net/http"
"github.com/jarcoal/httpmock"
)
func NewChainResponder(responders []httpmock.Responder) httpmock.Responder {
cursor := 0
return func(req *http.Request) (*http.Response, error) {
@riethm
riethm / mock.go
Last active September 15, 2016 13:22
golang httpmock augmented with assertions
import (
"testing"
"github.com/jarcoal/httpmock"
"net/http"
"io/ioutil"
)
type Call struct {
req *http.Request
INFO global: Vagrant version: 1.7.2
INFO global: Ruby version: 2.0.0
INFO global: RubyGems version: 2.0.14
INFO global: VAGRANT_EXECUTABLE="/opt/vagrant/bin/../embedded/gems/gems/vagrant-1.7.2/bin/vagrant"
INFO global: VAGRANT_LOG="debug"
INFO global: VAGRANT_INSTALLER_EMBEDDED_DIR="/opt/vagrant/bin/../embedded"
INFO global: VAGRANT_INSTALLER_VERSION="2"
INFO global: VAGRANT_DETECTED_OS="Linux"
INFO global: VAGRANT_INSTALLER_ENV="1"
INFO global: VAGRANT_INTERNAL_BUNDLERIZED="1"