Skip to content

Instantly share code, notes, and snippets.

View dpetersen's full-sized avatar

Don Petersen dpetersen

View GitHub Profile
@dpetersen
dpetersen / first terminal
Last active January 23, 2016 03:38
Here is my output from a fresh Ubuntu 14.04.3 x64 (also tried 15.10 x64) Digital Ocean instance. The first line of the second terminal was a successful run (exits properly within milliseconds), the second run will hang indefinitely and not exit. Note that the actual number of times I need to run the client until it will fail is seemingly random.
root@ubuntu-2gb-sfo1-01:~# apt-get update && apt-get install -y git curl
<output trimmed>
root@ubuntu-2gb-sfo1-01:~# curl -O https://storage.googleapis.com/golang/go1.5.3.linux-amd64.tar.gz
<output trimmed>
root@ubuntu-2gb-sfo1-01:~# tar -zxf go1.5.3.linux-amd64.tar.gz
root@ubuntu-2gb-sfo1-01:~# mv go /usr/local
root@ubuntu-2gb-sfo1-01:~# export PATH=$PATH:/usr/local/go/bin
root@ubuntu-2gb-sfo1-01:~# mkdir gopath
root@ubuntu-2gb-sfo1-01:~# export GOPATH=/root/gopath
root@ubuntu-2gb-sfo1-01:~# go get github.com/dpetersen/headerbug/client
@dpetersen
dpetersen / safe-docker-clean.sh
Created January 18, 2016 00:27
Hopefully a safe way to clean up stopped containers and orphaned images from Docker. Gee, maybe there should be a way to do this that doesn't involve googling for it every time. http://stackoverflow.com/questions/17236796/how-to-remove-old-docker-containers
#!/bin/bash
docker rm -v $(docker ps -q -f status=exited)
docker rmi $(docker images -q -f "dangling=true")
@dpetersen
dpetersen / circle.yml.diff
Created March 11, 2015 16:28
CircleCI junit integration
commit 744cfc17ad795077a427b19d02c10e4f0b5008b7
Author: Don Petersen <[email protected]>
Date: Tue Mar 10 15:43:22 2015 -0600
Include circle-compatible test output.
diff --git a/circle.yml b/circle.yml
index a2763cf..ece9b30 100644
--- a/circle.yml
+++ b/circle.yml
@dpetersen
dpetersen / main.go
Last active August 29, 2015 14:16
Serialize shmerialize
package main
import (
"encoding/json"
"fmt"
)
type Cat struct {
Angry bool `json:"angry"`
Declawed bool `json:"declawed"`
@dpetersen
dpetersen / warnings.rs
Created February 23, 2015 00:43
warnings
#![feature(core)]
// This triggers:
// add #![feature(core)] to the crate attributes to silence this warning
// warning: use of unstable library feature 'core': naming scheme needs to be revisited
use std::f64::consts::PI;
fn main() {
println!("Hello, world! {}", PI);
}
@dpetersen
dpetersen / demo.go
Last active August 29, 2015 14:13
Friday demo
package demo
// The Savable interface should be implemented by any resource associated with
// an Account that can be persisted.
type Savable interface {
Save(Account) (string, error)
}
// An Account ties together all records associated with a single client.
//
@dpetersen
dpetersen / switch.go
Last active August 29, 2015 14:11
type switch
package main
import "fmt"
type Fetchable interface {
URL() string
}
type Completable interface {
HasCompleted()
@dpetersen
dpetersen / .rspec
Last active December 28, 2015 11:08
have_received vs. should_receive
--color
@dpetersen
dpetersen / pre-commit.rb
Created March 19, 2013 22:13
Pre-commit caning.
#!/usr/bin/env ruby
begin
require 'rubygems'
require 'cane/cli'
rescue LoadError
warn "You're missing a dependency, either rubygems or cane!"
end
`git stash -u --keep-index`
@dpetersen
dpetersen / user_spec.rb
Created August 8, 2012 18:05
User spec with implicit subject
describe User do
describe "#can_do_dangerous_stuff?" do
subject { user.can_do_dangerous_stuff? }
context "when the User is a customer" do
let(:user) { User.new("customer") }
it { should be_false }
end
context "when the User is an admin" do