Skip to content

Instantly share code, notes, and snippets.

View ae6rt's full-sized avatar

Mark Petrovich ae6rt

  • Petaluma, CA
View GitHub Profile
@ae6rt
ae6rt / skydns-rc.yaml
Created July 24, 2015 21:25
SkyDNS Kubernetes replication controller resource
---
apiVersion: v1
kind: ReplicationController
metadata:
labels:
k8s-app: kube-dns
kubernetes.io/cluster-service: "true"
version: v5
name: kube-dns-v5
namespace: kube-system
#cloud-config
---
ssh_authorized_keys:
- ssh-rsa xxxx
write_files:
- path: /opt/bin/waiter.sh
owner: root
content: |
#! /usr/bin/bash
@ae6rt
ae6rt / gist:a37c97e9af4dc0d9a62b
Created February 20, 2015 23:19
Partial modelling of a Maven POM in Go. There's a lot here, including namespaces, attribute namespaces, and dynamic elements.
type Project struct {
XMLName struct{} `xml:"http://maven.apache.org/POM/4.0.0 project"`
SchemaLocation string `xml:"http://www.w3.org/2001/XMLSchema-instance schemaLocation,attr"`
ModelVersion string `xml:"modelVersion"`
GroupID string `xml:"groupId"`
ArtifactID string `xml:"artifactId"`
Version string `xml:"version"`
Packaging string `xml:"packaging"`
Properties Properties `xml:"properties"`
DependencyManagement DependencyManagement `xml:"dependencyManagement"`
@ae6rt
ae6rt / gist:4074df9c41338feb9260
Created December 24, 2014 16:22
Go Dockerfile with libgit2 support
FROM ubuntu
MAINTAINER "Mark Petrovic <[email protected]>"
# Install packages
RUN echo "deb http://elided/ubuntu/xoom /" > /etc/apt/sources.list.d/xoom.list
RUN apt-get update && apt-get install -y --force-yes golang=1.3.3 openssl ca-certificates mercurial git openjdk-7-jre gcc build-essential ruby ruby-dev cmake pkg-config libssl-dev
# Environment
ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/go/bin:/go/bin
ENV GOPATH /go
@ae6rt
ae6rt / gist:a5bbe626f5334f976bd8
Created November 30, 2014 01:59
A shutdown-hook scaffold for Go
package lifecycle
import (
"log"
"os"
"os/signal"
)
var targets []Shutdowner
@ae6rt
ae6rt / gist:6959dd50e3a98ec0a1c7
Created November 28, 2014 16:28
Restore default implementations of code in Go unit tests
If you replace a default function in a package for unit testing purposes, make sure you
restore it so the next test does not mistakenly inherit the reassignment:
func TestEndpointNoScopes(t *testing.T) {
saveAuth := auth
defer func() {
auth = saveAuth
}()
auth = func(*http.Request, []string) (bool, error) {
@ae6rt
ae6rt / gist:32537e2f3a9d4102bfae
Created November 27, 2014 23:47
Setting subpackage vars with ldflags during a Go build
VERSION := 1.0
DATE := $(shell date)
COMMIT_ID := $(shell git rev-parse --short HEAD)
SDK_INFO := $(shell go version)
BUILD_DIR=build
LD_FLAGS := -X github.com/xoom/gorest/rest.version $(VERSION) -X github.com/xoom/gorest/rest.commit $(COMMIT_ID) -X github.com/xoom/gorest/rest.buildTime '$(DATE)' -X github.com/xoom/gorest/rest.sdkInfo '$(SDK_INFO)'
@ae6rt
ae6rt / gist:3e5bd5088c24eb352ba1
Created November 16, 2014 18:34
Dockerfile with persisted git clone
FROM phusion/baseimage:0.9.15
RUN apt-get -y update && apt-get install -y git
RUN git clone https://github.com/ae6rt/go-mode.el.git
@ae6rt
ae6rt / gist:2c17d65bed574c895f0e
Created November 16, 2014 14:48
Wrapper around Go exec.Command to return stdout, stderr, and err
func Exec(cmd string, args ...string) ([]byte, []byte, error) {
if debug {
log.Printf("%s %v\n", cmd, args)
}
stdout := &bytes.Buffer{}
stderr := &bytes.Buffer{}
command := exec.Command(cmd, args...)
command.Stdout = stdout
command.Stderr = stderr
@ae6rt
ae6rt / gist:0aa35403f678bfe54960
Created November 15, 2014 14:24
Read lines from a buffer of bytes
func GetBranches() ([]string, error) {
cmd := "git"
args := []string{"ls-remote", "--heads"}
if debug {
log.Printf("%s %v\n", cmd, args)
}
command := exec.Command(cmd, args...)
if data, err := command.Output(); err != nil {
return nil, err