Skip to content

Instantly share code, notes, and snippets.

@binocarlos
binocarlos / README.md
Created November 19, 2015 20:18
Distributed Matters demo

First - lets run a container that writes a file on one node:

$ docker run -ti \
  --v testdata:/data \
  --volume-driver flocker \
  busybox sh -c "echo hello > /data/file.txt"

Then - on another node - lets read the data from the same volume:

@binocarlos
binocarlos / boot2dockerchangesocket.sh
Last active August 29, 2015 14:17
A script that will update boot2docker to use a different unix socket
#!/bin/sh
cat /usr/local/etc/init.d/docker | sed 's/unix:\/\/ /unix:\/\/\/var\/run\/docker.real.sock /g' > /tmp/docker
sudo cp /tmp/docker /usr/local/etc/init.d/docker
sudo chmod a+x /usr/local/etc/init.d/docker
sudo /usr/local/etc/init.d/docker restart
sudo rm -f /var/run/docker.sock
@binocarlos
binocarlos / networkwait.sh
Created September 28, 2014 15:05
Wait for weave network - hijack entrypoint
#!/bin/sh
while ! grep -q ^1$ /sys/class/net/ethwe/carrier 2>/dev/null
do sleep 1
done
$@
#!/bin/bash
# uses imagemagick to stich together all images in a folder and
# then writes a css file with the correct offsets along with a
# test html page for verification that its all good
if [ $# -gt 0 ]
then
if [ $3 ]
@binocarlos
binocarlos / setup_git.sh
Created August 21, 2013 19:19
Configure git from a new install
#!/bin/bash
git config --global user.name "YOUR NAME HERE"
git config --global user.email "YOUR EMAIL HERE"
git config --global credential.helper 'cache --timeout=3600'
git config --global push.default simple
git config --global alias.add-commit '!git add -A && git commit'
@binocarlos
binocarlos / installansible.sh
Last active December 21, 2015 11:29
Ansible install script
sudo add-apt-repository ppa:rquillo/ansible -y
sudo apt-get update -y
sudo apt-get install ansible -y
echo localhost > myhosts
export ANSIBLE_HOSTS=$(pwd)/myhosts
ansible all -m ping -u ubuntu
@binocarlos
binocarlos / closure.js
Created August 18, 2013 23:58
An example of a basic closure pattern in JavaScript...
// this is the factory function that acts as a constructor
function factory(options){
var denominator = options.denominator || 1;
// here is our actual worker function
return function divider(input){
return input / denominator;
}
}
@binocarlos
binocarlos / example.js
Created August 4, 2012 17:50
RabbitMQ Fanout
var amqp = require('amqp');
var connection = amqp.createConnection({ host: "localhost", port: 5672 });
var count = 1;
connection.on('ready', function () {
connection.exchange("my_exchange", options={type:'fanout'}, function(exchange) {
var sendMessage = function(exchange, payload) {
console.log('about to publish')
var encoded_payload = JSON.stringify(payload);