Skip to content

Instantly share code, notes, and snippets.

source "http://rubygems.org"
source "http://dist/rubygems"
gem 'rake'
gem 'thor'
gem 'lchadwick-grape', :require => 'grape' # We needed a patch that has been applied to grape master but not yet released
gem 'rabl'
gem 'yajl-ruby'
require 'aws'
require 'pry'
require 'awesome_print'
REGIONS = ['us-east-1','ap-southeast-2']
REGIONS.each do |region|
puts "Fetching volumes for #{region}"
ec2 = AWS::EC2.new(access_key_id: ENV['AWS_ACCESS_KEY_ID'], secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'], region: region)
class Greeting
def initialize(greeting="Hello")
@greeting = greeting
end
def hello(name, options={})
puts "#{@greeting} #{name}"
end
end
puts Greeting.new.hello("Luke")
m = Greeting.new.method(:hello)
DOGE_WOW = 'wow'
DOGE_SO_PROGRAM = 'so program'
DOGE_MANY_BRAIN = 'many brain'
# Serf Agent
description "Serf Agent"
start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [06]
kill signal INT # Use SIGINT instead of SIGTERM so serf can depart the cluster.
respawn # Restart the process if it dies and GOAL was not 'stopping'.
kill timeout 90 # Allow 90 seconds for serf to die before sending SIGKILL.
env SERF=/usr/local/bin/serf
#!/usr/bin/env python
import sys
from netaddr import IPNetwork
from subprocess import call
cidr = len(sys.argv) == 3 and sys.argv[2] or '24'
if sys.argv[1]:
ips = list(IPNetwork(sys.argv[1] + '/' + cidr))[1:-1]
commands:
01_fix_owner:
command: "mv /tmp/10_fixing_permission.sh /opt/elasticbeanstalk/hooks/appdeploy/pre/10_fixing_permission.sh"
files:
/tmp/10_fixing_permission.sh:
content: |
#!/usr/bin/env bash
. /opt/elasticbeanstalk/support/envvars
# AWS Sydney
traceroute bb-m.rubygems.org
traceroute to bb-m.rubygems.org (199.91.171.93), 30 hops max, 60 byte packets
1 ec2-54-252-0-8.ap-southeast-2.compute.amazonaws.com (54.252.0.8) 15.612 ms 15.604 ms 15.582 ms
2 54.240.192.106 (54.240.192.106) 1.588 ms 1.603 ms 1.585 ms
3 54.240.192.76 (54.240.192.76) 1.552 ms 1.542 ms 1.537 ms
4 202.68.70.5 (202.68.70.5) 1.861 ms 1.892 ms 1.844 ms
5 xe-5-1-0.r05.sydnau01.au.bb.gin.ntt.net (202.68.64.162) 1.929 ms 1.941 ms 1.643 ms
6 as-0.r02.lsanca03.us.bb.gin.ntt.net (129.250.3.18) 139.494 ms p16-1-2-0.r02.lsanca03.us.bb.gin.ntt.net (129.250.3.192) 138.444 ms 138.632 ms
7 xe-2-1-9.r20.lsanca03.us.bb.gin.ntt.net (129.250.2.141) 138.544 ms xe-0-1-3.r21.lsanca03.us.bb.gin.ntt.net (129.250.2.189) 139.774 ms xe-2-1-9.r20.lsanca03.us.bb.gin.ntt.net (129.250.2.141) 138.746 ms
#!/bin/bash
# node.js using PPA (for statsd)
sudo apt-get --yes install python-software-properties
sudo apt-add-repository --yes ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get --yes install nodejs npm
# Install git to get statsd
sudo apt-get --yes install git
@vertis
vertis / guessing_game.rb
Created June 26, 2014 12:45
This is a very basic example of a genetic algorithm for guessing the the correct word(s). Run with: ruby guessing_game.rb "My Word"
require 'pry'
class GuessOrganism
attr_accessor :guess
def initialize(word)
@guess = word
end
def fitness(target_word)
target = target_word