Skip to content

Instantly share code, notes, and snippets.

View justincampbell's full-sized avatar
🌯
🍩

Justin Campbell justincampbell

🌯
🍩
View GitHub Profile
#!/usr/bin/ruby
require 'net/http'
require 'tempfile'
require 'uri'
feed_url = "http://www.nasa.gov/rss/dyn/lg_image_of_the_day.rss"
feed = Net::HTTP.get(URI.parse(feed_url))
image_filename = feed.split('url="http://www.nasa.gov/sites/default/files/')[1].split('"')[0]
image_url = "http://www.nasa.gov/sites/default/files/#{image_filename}"
#!/bin/bash -e
ua=$(defaults read com.apple.universalaccess whiteOnBlack)
cg=$(defaults read com.apple.CoreGraphics DisplayUseInvertedPolarity)
if [ "$ua" != "$cg" ]; then
echo "Values do not match"
exit 1
fi
x27[1;32mdocker output will be in this color.x27[0m
x27[1;32m==> docker: Creating a temporary directory for sharing data...x27[0m
x27[1;32m==> docker: Pulling Docker image: ubuntux27[0m
x27[0;32m docker: Using default tag: latestx27[0m
x27[0;32m docker: latest: Pulling from library/ubuntux27[0m
x27[0;32m docker: d3a1f33e8a5a: Already existsx27[0m
x27[0;32m docker: c22013c84729: Already existsx27[0m
x27[0;32m docker: d74508fb6632: Already existsx27[0m
x27[0;32m docker: 91e54dfb1179: Already existsx27[0m
package main
type Nameable struct {
Name string
}
type Person struct {
Nameable
}
PIDFILE := tmp/server.pid
PORT := 4567
default: test stop
start: $(PIDFILE)
$(PIDFILE):
rackup --daemonize --pid $(PIDFILE) --port $(PORT) config.ru
sleep 1
require 'benchmark'
n = (ENV['N'] || 1_000_000).to_i
HASH = { foo: 1, bar: 2 }.freeze
Benchmark.bm(20) do |x|
x.report("case") do
n.times do
case :baz
@justincampbell
justincampbell / log
Created June 4, 2015 14:34
Vault userpass/ldap over JSON
vault server -dev
export VAULT_ADDR='http://127.0.0.1:8200'
vault auth <token>
vault auth-enable userpass
vault write auth/userpass/users/justin password=secret policies=root
$ curl $VAULT_ADDR/v1/auth/userpass/login/justin -d '{ "password": "secret" }'
{
"lease_id": "",
@justincampbell
justincampbell / main.go
Created May 16, 2015 01:34
GetBucketPolicy reproduction
package main
import (
"fmt"
"os"
"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/s3"
)
@justincampbell
justincampbell / output.log
Created April 23, 2015 18:57
Terraform Output Bug
heroku_app.default: Creating...
all_config_vars.#: "" => "<computed>"
git_url: "" => "<computed>"
heroku_hostname: "" => "<computed>"
name: "" => "terraform-output-bug"
region: "" => "us"
stack: "" => "<computed>"
web_url: "" => "<computed>"
heroku_app.default: Creation complete