Skip to content

Instantly share code, notes, and snippets.

View cespare's full-sized avatar

Caleb Spare cespare

View GitHub Profile
---
- name: hang test
hosts: "{{ hosts }}"
tasks:
- name: hang test 1
local_action: command ssh {{ inventory_hostname }} ls
when: task_to_run == "1"
- name: hang test 2
local_action: shell ssh {{ inventory_hostname }} ls 2>/dev/null
when: task_to_run == "2"
@cespare
cespare / rsync.yml
Created January 15, 2014 15:43
Ansible hang
---
- name: rsync set default value for copy_dest
set_fact: copy_dest={{ dest }}
when: copy_dest is not defined
- name: rsync src={{ src }} dest={{ dest }} copy_dest={{ copy_dest }}
local_action: >
rsync --archive --compress --copy-unsafe-links --checksum --itemize-changes --exclude=.git
--exclude=.vagrant --copy-dest={{ copy_dest }} {{ src }} {{ inventory_hostname }}:{{ dest }}
register: rsync
# The machines:
# Mac OS (MBP Retina):
$ sysctl -n machdep.cpu.brand_string
Intel(R) Core(TM) i5-3230M CPU @ 2.60GHz
$ go version
go version go1.2 darwin/amd64
# Linux desktop (Ubuntu 13.10):
$ go version
@cespare
cespare / results.txt
Last active December 31, 2015 19:19
My results for @kellabyte's benchmark
# Ubuntu 13.10, cpu is Intel Core i5-2500K
$ go version
go version go1.2 linux/amd64
$ ./client 1 100000
Sent 100000 in 428.895171ms for a rate of 233157/second
$ ./client 4 100000
Sent 400000 in 1.79000027s for a rate of 223463/second
$ GOMAXPROCS=4 ./client 1 100000
Sent 100000 in 454.46171ms for a rate of 220040/second
$ GOMAXPROCS=4 ./client 4 100000
@cespare
cespare / ansible-lookup.rb
Created October 28, 2013 04:17
Ansible host reverse lookup script
#!/usr/bin/env ruby
version_parts = RUBY_VERSION.split(".").map(&:to_i)
if version_parts[0] < 2 && version_parts[1] < 9
abort "Ruby >= 1.9 required."
end
require "set"
if ARGV.size != 1
@cespare
cespare / Dockerfile
Created September 16, 2013 15:24
Example Go builder docker image. It's set up for Go 1.1.2 on linux/amd64 and darwin/amd64.
FROM ubuntu
# Make sure the package repository is up to date.
RUN echo "deb http://us.archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
RUN apt-get update
# Install necessary packages. Vim is for convenience when I'm poking around in the container.
RUN apt-get install -y build-essential git bzr mercurial vim
# Download and install Go for cross-compilation.
@cespare
cespare / wslog.go
Created September 13, 2013 02:16
Example of how one might do websocket logging when using go-apachelog for http logging.
package main
import (
"io"
"log"
"net/http"
"os"
"time"
"code.google.com/p/go.net/websocket"
package main
import (
"fmt"
"os"
"strconv"
"syscall"
)
func main() {
package main
import (
"fmt"
"os"
"os/signal"
)
// Wait for a signal (any signal), print it out, and quit.
@cespare
cespare / Vagrantfile
Created April 7, 2013 03:10
My default minimal Vagrantfile. Better than the huge thing 'vagrant init' generates.
Vagrant.configure("2") do |config|
config.vm.box = "quantal64"
config.vm.hostname = "give-this-a-name"
config.vm.box_url = "http://cloud-images.ubuntu.com/quantal/current/quantal-server-cloudimg-vagrant-amd64-disk1.box"
config.vm.provision :shell, :inline =>
"sudo mkdir -p /root/.ssh && sudo cp /home/vagrant/.ssh/authorized_keys /root/.ssh/"
# config.vm.network :forwarded_port, guest: 80, host: 8080
# config.vm.synced_folder "../data", "/vagrant_data"