Skip to content

Instantly share code, notes, and snippets.

View keymon's full-sized avatar

Hector Rivas Gandara keymon

  • London, UK
  • 05:52 (UTC +01:00)
View GitHub Profile
@keymon
keymon / gist:3179821
Created July 26, 2012 01:59
Generating a configuration parser in ruby, like chef or others
require "erb"
class BigIpConfigurator
@@resources = {} # Hash with all the resources defined
# Define a resource, adding it to the list
def self.resource(name, defaults, &block)
@@resources[name] = {
:defaults => defaults,
:block => block
# using VirtualBox version $VBOX_VERSION
FROM boot2docker/boot2docker
RUN apt-get install p7zip-full
RUN mkdir -p /vboxguest && \
cd /vboxguest && \
curl -L -o vboxguest.iso http://download.virtualbox.org/virtualbox/$VBOX_VERSION/VBoxGuestAdditions_$VBOX_VERSION.iso && \
7z x vboxguest.iso -ir'!VBoxLinuxAdditions.run' && \
sh VBoxLinuxAdditions.run --noexec --target . && \
@keymon
keymon / cloudinit-network.yaml
Last active August 29, 2015 14:06
Testing coreos cloudinit
#cloud-config
#
coreos:
units:
- name: static.network
runtime: yes
content: |
[Match]
Name=en*
@keymon
keymon / setup-panamax.sh
Created September 8, 2014 22:37
Setting up panamax in a coreos-vagrant with 3 instances
#
# I was playing around with coreos cluster + panamax.io
#
# Clone the git repo from coreos-vagrant
git clone https://github.com/coreos/coreos-vagrant
# Setup the number of instances to 3, and use stable channel
sed 's/#*$num_instances=.*/$num_instances=3/;s/#*$update_channel=.*/$update_channel=\'stable\'/' config.rb.sample > config.rb
#!/usr/bin/env bash
[ $(id -u) = 0 ] || { echo "You must be root (or use 'sudo')" ; exit 1; }
fwrule=`ipfw -a list | grep "deny ip from any to any"`
fwrule_id=`echo $fwrule | awk '{ print $1 }'`
if [ "$fwrule" != "" ]; then
echo "Found blocking firewall rule: $(tput setaf 1)${fwrule}$(tput sgr0)"
printf "Deleting rule ${fwrule_id} ... "
ipfw delete ${fwrule_id}
@keymon
keymon / boot2docker-shellinit.sh
Created March 6, 2015 12:02
Some useful scripts using boot2docker on MacOSX
# Support for boot2docker
# Add this script to you .bashrc to create an alias to initialise the environment as needed
boot2docker-shellinit() {
if which boot2docker &>/dev/null; then
$(boot2docker shellinit 2> /dev/null)
# In order to map the port, just use this to do it:
# boot2docker down
# vboxmanage modifyvm "boot2docker-vm" --natpf1 "docker,tcp,127.0.0.1,2376,,2376"
# boot2docker up
VBOX_MAP_PORT=$(VBoxManage showvminfo boot2docker-vm --machinereadable | sed -n 's/Forwarding.*docker,tcp,127.0.0.1,\(.*\),,2376.*/\1/p')
@keymon
keymon / json2yaml.rb
Created May 14, 2015 11:19
Simple and directly convert from json to yaml
#!/usr/bin/env ruby
# usage:
# gem install json
# gem install yaml
# ./json2yaml.rb < file.json > file.yml
#
require "json"
require 'yaml'
puts JSON.parse(STDIN.read).to_yaml
http://cdn.rawgit.com/alphagov/multicloud-deploy/master/dashboard.html?token=...&gist=...&LEFT_WIDTH=30&RIGHT_WIDTH=70
@keymon
keymon / README.md
Last active August 29, 2015 14:26
GNU plot ab performance and CPU for a tsuru installation

AB benchmark and plotting

Small script to execute a apache benchmark ab from one host to other.

The scripts are designed for benchmark tsuru routers, and compare between hipache+nginx vs. vulcand.

It will gather metrics of request time and CPU in the target so they can be later plot using gnuplot.

@keymon
keymon / README.md
Last active September 22, 2015 09:53

IaaS start/stop and other useful scripts

Useful scripts to manage VMs on a IaaS: AWS, GCE, etc... Stop all vms, start them, etc..

aws_stop_vms_by_vpc.sh

Choose between the existing VPCs in a given region and stop all the VMs running there:

aws_stop_vms_by_vpc.sh [region]