Skip to content

Instantly share code, notes, and snippets.

@josephglanville
josephglanville / 0001-Add-abstract-create_-config-option-to-create-arbitar.patch
Created May 20, 2012 08:35
Patch to OpenRC iproute2.sh to support abstract interfaces
From c6802bcf9f23007e573f2655e9d57c177e1279b5 Mon Sep 17 00:00:00 2001
From: Joseph Glanville <[email protected]>
Date: Sun, 20 May 2012 16:30:11 +0000
Subject: [PATCH] Add abstract create_ config option to create arbitary interfaces.
This patch allows the creation of any interface supported by the
underlying NETLINK interface of iproute2.
To create an interface simply supply a create_${iface} line in
your /etc/conf.d/net file.
@josephglanville
josephglanville / master.rb
Last active December 26, 2015 20:58
Simple atomic locks and Master Election with RethinkDB and Celluloid
require 'rethinkdb'
require 'celluloid'
include RethinkDB::Shortcuts
LOCK_TIMEOUT = 15
UPDATE_TIMEOUT = 5
r.connect.repl
@josephglanville
josephglanville / master.py
Last active December 29, 2015 03:49
Simple master election using RethinkDB and gevent
#!/usr/bin/env python
import rethinkdb as r
import gevent
import gevent.monkey
gevent.monkey.patch_all()
LOCK_TIMEOUT = 15
UPDATE_TIMEOUT = 5
@josephglanville
josephglanville / get_local_bind_addr.rb
Last active August 29, 2015 13:57
Gets the local bind address given a network to look for.
require 'netaddr'
require 'socket'
network = NetAddr::CIDR.create(ARGV[0])
ips = Socket.ip_address_list.map {|a| a.ip_address}
ips.each do |ip|
if network.contains?(ip)
puts ip
exit
end
end
@josephglanville
josephglanville / ruby_image.sh
Created October 21, 2014 11:26
Create bare Ruby docker image
#!/bin/bash
TARGET=$1
mkdir -p $TARGET
files=$(
dpkg -L ruby | grep '/usr/bin/'
dpkg -L ruby1.9.1 | grep '/usr/bin/'
echo '/usr/lib/ruby'
)
@josephglanville
josephglanville / scan_elbs_sslv3.rb
Created October 21, 2014 22:48
Scan ELBs for SSLv3 being enabled.
#!/usr/bin/env ruby
require 'aws'
elb = AWS::ELB.new
elb.load_balancers.each do |lb|
vuln = false
lb.policies.each do |pol|
if pol.attributes.include?('Protocol-SSLv3')
if pol.attributes['Protocol-SSLv3']
vuln = true
bios.bootorder = "hdd,CDROM"
checkpoint.vmstate = ""
cleanshutdown = "FALSE"
config.version = "8"
displayname = "flynn: default"
ehci.pcislotnumber = "-1"
ehci.present = "FALSE"
ethernet0.addresstype = "generated"
ethernet0.connectiontype = "nat"
ethernet0.present = "TRUE"
amazon-ebs: The following packages have unmet dependencies:
amazon-ebs: linux-image-generic-lts-vivid : Depends: linux-image-extra-3.19.0-25-generic but it is not going to be installed
amazon-ebs: Recommends: thermald but it is not installable
@josephglanville
josephglanville / commands.txt
Last active August 28, 2015 21:18 — forked from lmars/commands.txt
Flynn Dedicated Postgres
# create new app as your custom postgres provider
flynn create --remote "" custompg
# create a release using the latest postgresql image from /etc/flynn/bootstrap-manifest.json
flynn -a custompg release add -t docker -f config.json "https://dl.flynn.io/tuf?name=flynn/postgresql&id=30f08003a029c5d5958263bf923d0377c958b313d417ba49489ff9c5940a388b"
# modify the app deployment strategy to "postgres"
flynn -a controller pg psql <<< "UPDATE apps SET strategy = 'postgres' WHERE name = 'custompg';"
# scale postgres and web to 3 and 2 processes respectively
@josephglanville
josephglanville / git receive log
Created September 1, 2015 19:01
gitrecieve debugging
rant@flynn:~/go/src/github.com/flynn/flynn$ flynn -a gitreceive log
2015-09-01T18:51:47.337323Z app[app.flynn-1a5e958e-8762-4185-8dab-070d2a5eefe8]: t=2015-09-01T18:51:47+0000 lvl=info msg="request started" component=gitreceive req_id=fd4f1271-7157-49ea-94c4-511491c2b1c0 method=GET path=/.well-known/status client_ip=100.100.49.11
2015-09-01T18:51:47.341201Z app[app.flynn-1a5e958e-8762-4185-8dab-070d2a5eefe8]: t=2015-09-01T18:51:47+0000 lvl=info msg="request completed" component=gitreceive req_id=fd4f1271-7157-49ea-94c4-511491c2b1c0 status=200 duration=3.351599ms
2015-09-01T18:53:59.165330Z app[app.flynn-1a5e958e-8762-4185-8dab-070d2a5eefe8]: t=2015-09-01T18:53:59+0000 lvl=info msg="request started" req_id=2d30b32a-a3ae-480b-a767-34d40adc7ab3 component=gitreceive method=GET path=/testapp.git/info/refs client_ip=192.0.2.100
2015-09-01T18:53:59.165536Z app[app.flynn-1a5e958e-8762-4185-8dab-070d2a5eefe8]: t=2015-09-01T18:53:59+0000 lvl=info msg="request completed" req_id=2d30b32a-a3ae-480b-a767-34d40adc7ab3 compo