Skip to content

Instantly share code, notes, and snippets.

@djmaze
djmaze / http_test.rb
Created December 23, 2013 19:06
Tests for Net::HTTP issues with SSL in Ruby 1.9/2.0 and JRuby
#/usr/bin/env ruby
RUBY_VERSIONS = %w[1.9.3-p327-perf 2.0.0-p247 jruby-1.7.6]
RUBY_MODES = %w[1.9 2.0]
URL = ARGV[0] || 'https://github.com/'
def run(*additional_params)
puts "[example 1]"
run_ruby_with_code(<<-EOC, additional_params)
require 'net/http'
@djmaze
djmaze / install.sh
Last active August 29, 2015 13:58
Install master version of fig on Linux
# clone
git clone git@github.com:orchardup/fig.git
cd fig
# build
sudo script/build-linux
# let it fail, adjust permissions, then build again:
sudo chown `id -u` dist
sudo script/build-linux
@djmaze
djmaze / dock-attach.sh
Created April 10, 2014 07:12
Attach to a running docker container on docker >= 0.9
# Attach to a running docker container using "dock-attach <CONTAINER ID OR NAME>^
dock_attach() {
local name_or_cid=$1
local pid=$(sudo docker inspect --format='{{.State.Pid}}' $name_or_cid)
sudo nsenter --target $pid --mount --uts --ipc --net --pid /bin/bash
}
alias dock-attach=dock_attach
@djmaze
djmaze / gist:10934696
Created April 16, 2014 21:25
Installing and running geard on Arch Linux
# Example taken from http://openshift.github.io/geard/deploy_with_geard.html
yaourt -S geard-git
sudo systemctl start geard.service
curl -O https://raw.githubusercontent.com/openshift/geard/master/deployment/fixtures/rockmongo_mongo.json
sudo gear deploy rockmongo_mongo.json
# wait a minute for the images to download amd the containers to start...
@djmaze
djmaze / Docker_build_workarounds_for_ARM.md
Created April 19, 2014 01:08
Workarounds for docker build errors on ARM

To those having problems building and running docker containers on ARM devices: Here are two workarounds for getting containers built at least.

First, the ugly one. Run the build in a loop until it is successful:

while [ 1 ]; do sudo docker build .; if [ $? -ne 1 ]; then break; fi; done

The other one is a fantastic trick. Use qemu to build the ARM images on your x86 system! See this post for the howto.

@djmaze
djmaze / coreos-multitail.sh
Created June 15, 2014 16:38
Tail on multiple CoreOS servers in parallel
#!/bin/sh
#
# Run like this:
#
# coreos-multitail.sh core@xxx core@yyy ...
SERVERS=($*)
echo Tailing ${SERVERS[@]}, press CTRL-C to exit
trap ctrl_c int
@djmaze
djmaze / build.sh
Last active August 29, 2015 14:04
Building Twister with Docker and getting the exe out
# Inside the twister-core source directory, run:
sudo ./twister-on-docker build
sudo docker run --rm -v $(pwd):/target --entrypoint /usr/bin/env twister cp /twister-core/twisterd /target
# Now twisterd should be there!
file twisterd
# Alternatively, get the current twisterd from the automatic build:
sudo docker pull miguelfreitas/twister
sudo docker run --rm -v $(pwd):/target --entrypoint /usr/bin/env miguelfreitas/twister cp /twister-core/twisterd /target
@djmaze
djmaze / Dockerfile
Created September 10, 2014 19:12
ember-cli Dockerfile
FROM ubuntu:14.04
RUN apt-get update
RUN apt-get -y install git
RUN apt-get -y install nodejs npm
RUN ln -s /usr/bin/nodejs /usr/local/bin/node
ENV CLI_VERSION 0.0.42
RUN npm install -g ember-cli bower phantomjs
@djmaze
djmaze / PKGBUILD
Created September 22, 2014 21:20
Docker 1.2.0 PKGBUILD with patch against tag-naming bug
# $Id$
# Maintainer: Sébastien "Seblu" Luttringer
pkgname=docker
pkgver=1.2.0
pkgrel=1
epoch=1
pkgdesc='Pack, ship and run any application as a lightweight container'
arch=('x86_64')
url='http://www.docker.io/'
@djmaze
djmaze / docker-cleanup
Created November 5, 2014 13:48
Cleanup old Docker containers and images
#!/bin/sh
# Cleanup docker files: untagged containers and images.
#
# Use `docker-cleanup -n` for a dry run to see what would be deleted.
untagged_containers() {
# Print containers using untagged images: $1 is used with awk's print: 0=line, 1=column 1.
# NOTE: "[0-9a-f]{12}" does not work with GNU Awk 3.1.7 (RHEL6).
# Ref: https://github.com/blueyed/dotfiles/commit/a14f0b4b#commitcomment-6736470
docker ps -a | tail -n +2 | awk '$2 ~ "^[0-9a-f]+$" {print $'$1'}'