Skip to content

Instantly share code, notes, and snippets.

@buth
buth / channels.go
Created September 23, 2014 16:23
go-routine / channel puzzle
package main
func send(c chan int, i int){
c <- i
}
func main() {
c := make(chan int)
go send(c, 1)
go send(c, 2)
@buth
buth / config.rb
Created August 14, 2014 15:21
Add `required` to mixlib-config.
require 'mixlib/config'
module MyConfig
extend Mixlib::Config
def self.required(name)
default(name) {raise "You must provide a configuration value for #{name}."}
end
config_strict_mode true
@buth
buth / variables.rb
Created August 10, 2014 16:49
Ruby class variables
module M
def value
@@value ||= rand(100)
end
end
class A
include M
end
@buth
buth / threadio.rb
Created July 29, 2014 21:46
Thread IO in Ruby
module ThreadIO
def ThreadIO.puts(s)
@@semaphore ||= Mutex.new
@@semaphore.synchronize do
STDOUT.puts s
end
Thread.pass
end
end
@buth
buth / docker-registry.yaml
Created July 10, 2014 20:53
Docker Registry on CoreOS with Cloud-Config
#cloud-config
users:
- name: nytint
coreos-ssh-import-url: https://s3.amazonaws.com/newsdev-ops/keys.json
groups:
- docker
write_files:
- path: /etc/nginx/nginx.conf
@buth
buth / chef-server-reindex.sh
Created February 11, 2014 16:32
Rebuild the Chef-SOLR index from the database without dropping existing data.
sudo PATH=/opt/chef-server/embedded/bin:$PATH /opt/chef-server/embedded/service/erchef/bin/reindex-chef-server reindex