Skip to content

Instantly share code, notes, and snippets.

View marcoceppi's full-sized avatar
.

Marco Ceppi marcoceppi

.
View GitHub Profile
@marcoceppi
marcoceppi / fetch.py
Last active October 2, 2015 20:21
Charm fetcher
#!/usr/bin/env python
import os
import yaml
import shutil
import urllib
import zipfile
from theblues.charmstore import CharmStore
@marcoceppi
marcoceppi / wee.py
Created August 7, 2015 16:53
Find all bugs opened against a distribution
from launchpadlib.launchpad import Launchpad
lp = Launchpad.login_anonymously('mc', 'production')
ppl = lp.people['ibmcharmers']
charm = lp.distributions['charms']
tasks = []
for p in ppl.members:
tasks = tasks + [t for t in charm.searchTasks(bug_reporter=p)]
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeInstances",
"ec2:DescribeImages",
"ec2:DescribeSecurityGroups",
"ec2:DescribeAvailabilityZones",
@marcoceppi
marcoceppi / action.sh
Created June 11, 2015 20:19
How to prompt the user on which service to take an action on
#!/bin/bash
to_siege=`action-get service` # could be unit instead, but service seems better
siege_rid=""
rids="$(relation-ids website)"
if [ $(echo $rids | wc -l ) -eq 0 ]; then
action-fail "Siege is not related to anything, can not benchmark nothing"
fi
@marcoceppi
marcoceppi / am-i-idle.py
Created June 3, 2015 19:03
Find if environment is idle
#!/usr/bin/env python
import sys
import yaml
status = yaml.load(sys.stdin)
j = {'idle': [], 'busy': []}
def is_agent_idle(data):
if 'agent-status' not in data:
@marcoceppi
marcoceppi / foo.yaml
Created April 30, 2015 16:06
annotations
kubernetes-cluster:
services:
"kubernetes-master":
charm: cs:~kubernetes/trusty/kubernetes-master-5
expose: true
docker:
charm: cs:trusty/docker-2
num_units: 2
flannel-docker:
charm: cs:trusty/flannel-docker-1
#!/bin/bash
proxy=10.0.1.2:8000
if [ "$1" == "disable" ]; then
rm -f ~/.ecorc
sudo rm -f /etc/apt/apt.conf.d/99-eco-sprint
sed -i -e 's/\. \$HOME\/\.ecorc//' ~/.profile ~/.bashrc
exit 0
fi

I love making things. I love making things so much I will sometimes neglect basic life sustaining measures in order to squeeze more time in to creating things. Whether it's creating more software or hacking on things in meatspace - creating is just something I can't stop doing. So, as a result of this, I'm always looking for things to help ramp up my ability to create. Sometimes this is creating a jig or buying a tool, other times it's learning a new programming language or using a new framework.

I recently started working on such a side project, something I plan on releasing soon publically, but what I want to write about is how I built this application using tools to help plan for scaling issues without having them cramp my development time. In order to really highlight the ease and simplicity of this let me quickly outline what I do when I normally embark on a new software project.

The ways of yesterday

The plan

The first thing I do is figure out what technology I want to use, or at least try, in

@marcoceppi
marcoceppi / install-nodejs.sh
Last active August 29, 2015 14:10
nodesouce repository
#!/bin/sh
wget -qO- https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt-key add -
echo "deb https://deb.nodesource.com/node $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/nodesource.list
echo "deb-src https://deb.nodesource.com/node $(lsb_release -cs) main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list
sudo apt-get update
sudo apt-get install nodejs
#!/bin/bash
relids=`juju-run "relation-ids <peer-relation-name>"`
for i in "$relids"; do
units=`juju-run "relation-list $i"
for unit in "$units"; do
juju-run "relation-set -r $i key=val key1=val $unit"
done
done