Skip to content

Instantly share code, notes, and snippets.

View somic's full-sized avatar

Dmitriy Samovskiy somic

View GitHub Profile
#!/usr/bin/env ruby
#
# forking supervisor - forks workers and replaces dead workers.
# start it in one console, send signals to it from another console.
#
require 'rubygems'
require 'daemons/daemonize'
require 'ip'
IP::Address::IPv4.class_eval do
# returns next IP address
def next(step=1)
IP::Address::Util.unpack(self.pack + step)
end
# returns previous IP address
@somic
somic / gist:102602
Created April 27, 2009 17:30
a way to emulate rabbitmqctl from python
#!/usr/bin/env python
# requires py_interface
# http://www.lysator.liu.se/~tab/erlang/py_interface/
import sys, os, time
from py_interface import erl_node, erl_eventhandler
from py_interface.erl_opts import ErlNodeOpts
from py_interface.erl_term import ErlAtom, ErlBinary
@somic
somic / gist:123889
Created June 4, 2009 22:16
Prints out how many seconds ago this EC2 instance was started
#!/bin/bash
#
# Prints out how many seconds ago this EC2 instance was started
#
# It uses Last-Modified header returned by EC2 metadata web service, which as far
# as I know is not documented, and hence I assume there is no guarantee
# that Last-Modified will be always set correctly.
#
# Use at your own risk.
#
@somic
somic / udp_hole_punch_tester.py
Created November 3, 2009 04:13
UDP Hole Punching test tool
#!/usr/bin/env python
#
# udp_hole_punch_tester.py - UDP Hole Punching test tool
#
# Usage: udp_hole_punch_tester.py remote_host remote_port
#
# Run this script simultaneously on 2 hosts to test if they can punch
# a UDP hole to each other.
#
# * remote_port should be identical on 2 hosts.
@somic
somic / instantiate_vapp_template.xml
Created January 22, 2010 17:36
vCloud API XML for instantiatevAppTemplate (replace 000 with your IDs)
<InstantiateVAppTemplateParams name="d" xml:lang="en" xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<VAppTemplate href="https://services.vcloudexpress.terremark.com/api/v0.8/vAppTemplate/000" />
<InstantiationParams>
<VirtualHardwareSection xmlns:q1="http://www.vmware.com/vcloud/v0.8">
<Item xmlns="http://schemas.dmtf.org/ovf/envelope/1">
<InstanceID xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">1</InstanceID>
<ResourceType xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">3</ResourceType>
<VirtualQuantity xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">1</VirtualQuantity>
</Item>
<Item xmlns="http://schemas.dmtf.org/ovf/envelope/1">
The lock-in I believe @randybias is referring to (and I personally
totally agree with him on this) is more subtle.
There most likely are not going to be significant issues moving a system
consisting of 1 or 2 instances.
But imagine you have a 10-instance topology in GoGrid. GG has 2 NICs, but even
more importantly - one NIC is private network (which gives
you access to your storage), the second NIC is public (instance's public
162.0 sir-7f943c02 2010-06-21T10:30:38-0600 2010-06-21T15:33:20+0000
200.0 sir-a5909a02 2010-06-21T11:57:01-0600 2010-06-21T17:00:21+0000
136.0 sir-2d70e603 2010-06-22T09:36:54-0600 2010-06-22T14:39:10+0000
162.0 sir-837d2a02 2010-06-25T11:28:50-0600 2010-06-25T16:31:32+0000
110.0 sir-f52c8a03 2010-06-28T10:37:25-0600 2010-06-28T15:39:15+0000
120.0 sir-9a16d804 2010-06-28T10:37:16-0600 2010-06-28T15:39:16+0000
137.0 sir-72b2ea04 2010-06-28T14:03:02-0600 2010-06-28T19:05:19+0000
129.0 sir-de8b8602 2010-06-28T14:03:12-0600 2010-06-28T19:05:21+0000
105.0 sir-4ba2a402 2010-07-07T12:13:33-0600 2010-07-07T17:15:18+0000
115.0 sir-a46b6604 2010-07-08T10:29:13-0600 2010-07-08T15:31:08+0000
@somic
somic / ec2dipr.py
Created August 31, 2010 17:32
Scrape AWS EC2 forums to obtain ranges of public IP addresses for each EC2 region
#!/usr/bin/env python
#
# ec2dipr.py - ec2_describe_ipaddress_ranges
#
from BeautifulSoup import BeautifulSoup
import re, urllib2, socket, boto.ec2
try:
import boto
#!/usr/bin/ruby -I/usr/local/qpid-svn/qpid/ruby
#
#
__doc__ = %q(
disttailf.rb - distributed "tail -f"
Aggregates "tail -f" output from multiple machines and multiple files
into a single RabbitMQ pubsub queue (kind of splunk's log consolidation
function)