Skip to content

Instantly share code, notes, and snippets.

View cpuguy83's full-sized avatar
🐶

Brian Goff cpuguy83

🐶
View GitHub Profile
description "LDAP"
start on filesystem and started docker
stop on runlevel [!2345]
respawn
respawn limit 5 5
script
/usr/bin/docker start -a ldap
end script
@cpuguy83
cpuguy83 / docker-events.rb
Created February 1, 2014 19:19
High performance Docker events api event handler prototype
#!/usr/bin/env ruby
require 'bundler/setup'
require 'http'
require 'celluloid'
require 'celluloid/io'
require 'json'
class Event
@cpuguy83
cpuguy83 / Dockerfile
Created January 28, 2014 13:45
Docker issues#3753 Demo
FROM busybox
ADD echo.sh /tmp/echo.sh
ENTRYPOINT ["/tmp/echo.sh"]
@cpuguy83
cpuguy83 / operating_hour.rb
Created January 23, 2014 16:15
Time zone parsing from local time
class OperatingHour
class MissingTimeZoneError < StandardError; end
class MissingTimeStringError < StandardError; end
attr_reader :time_string, :time_zone
def initialize(opts={})
@time_string = opts[:time_string]
@time_zone = opts[:time_zone]
end
merged_images = left.images.with_index.collect do |image, index|
compare(left.images[index], right.images[index], index)
end
FROM ubuntu
# some awesome stuff with mysql
VOLUME /var/lib/mysql
--- End Dockerfile ---
docker build -t my/awesome_mysql_stuff
@cpuguy83
cpuguy83 / buildfile.go
Created December 27, 2013 21:30
extract functionality for building CMD and ENTRYPOINT
func (b *buildFile) BuildCmdFromJson(args string) []string {
var cmd []string
if err := json.Unmarshal([]byte(args), &cmd); err != nil {
utils.Debugf("Error unmarhsalling: %s, setting %s to /bin/sh -c", err)
cmd = []string{"/bin/sh", "-c", args}
}
return cmd
}
func (b *buildFile) CmdCmd(args string) error {
@cpuguy83
cpuguy83 / buildfile.go
Created December 27, 2013 16:53
Add support for multiple ENV key/values in one line
func (b *buildFile) CmdEnv(args string) error {
var env map[string]string
if err := json.Unmarshal([]byte(args), &env); err != nil {
env = []string{args}
}
if err := b.commit("", env, fm.Sprintf("ENV %v", env)); err != nil {
return err
}
@cpuguy83
cpuguy83 / client.rb
Last active December 30, 2015 16:09
Crude demo of async I/O using Celluloid::IO Actor with external class utilizing Celluoid::IO::TCPSocket. No need for GIL-less Ruby for this to work (except perhaps on the server, which isn't using evented IO for this demo)
require 'celluloid'
require 'celluloid/io'
class MySocket
def go
@sock ||= Celluloid::IO::TCPSocket.open('localhost', 2000)
puts "#{@sock.read}"
end
end
@cpuguy83
cpuguy83 / chef_windows_bootstrap.rb
Last active December 30, 2015 03:48
Custom Chef bootstrap for Windows
#!/usr/bin/env ruby
require 'winrm'
IP=ARGV[0]
USER=ARGV[1]
endpoint = "http://#{IP}:5985/wsman"
winrm = WinRM::WinRMWebService.new endpoint, :plaintext, user: USER, pass: 'secret', basic_auth_only: true
winrm.set_timeout 1800
installer_file = "c:\\Users\\#{USER}\\Downloads\\chef_client.msi"