Skip to content

Instantly share code, notes, and snippets.

View include's full-sized avatar
👽
Free Jaffa

Francisco Cabrita include

👽
Free Jaffa
View GitHub Profile
@include
include / System Design.md
Created July 26, 2016 09:27 — forked from vasanthk/System Design.md
System Design Cheatsheet

#System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

##Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@include
include / only-one-active-instance.py
Created June 2, 2016 13:49 — forked from ketzacoatl/only-one-active-instance.py
Proof of Concept - Docker service orchestration via python consul-lock
import sys
from time import sleep
import consul
import consul_lock
from docker import Client
'''
This is a PoC which uses consul's locking mechanism to ensure only
one instance of the named docker container is running. Requires:

Overview

This gist demonstrates how to run a docker container with nomad, using a wrapper script.

Why would you want to use this?

With the wrapper, we can more easily run the container in the way we need to and without being limited by Nomad's docker driver. For example, while Nomad will have great support for volumes in the future, it has no such support right now, and the driver does not expose a config parameter to tune the volumes mounted in the docker container. This is also a great way to use consul to lookup services before starting your app, or to retrieve credentials from Vault. When running legacy applications with nomad, the wrapper script is the place to put that type of look-up logic.

We use a wrapper script and the raw_exec driver to run the container with the parameters we need.

@include
include / start.pl
Last active October 23, 2015 14:55
lol start
root@e5ded7e1593c:/base# cat start.pl
#!/usr/bin/env perl
use strict;
use warnings;
## Move app into place
mkdir('/runtime') unless -d '/runtime';
system(split(/\s+/, "/usr/bin/rsync -a /build/ /runtime/app"));
@include
include / group_vars__users
Last active September 7, 2015 17:19
manage users/groups with ansible
---
# file: group_vars/all_users
mygroups:
admins:
state: present
users:
- name: include
comment: francisco.cabrita@gmail.com
@include
include / learn_apache2
Last active August 29, 2015 14:25
chef-client
[2015-07-18T18:29:00+00:00] WARN: No config file found or specified on command line, using command line options.
[2015-07-18T18:29:00+00:00] INFO: Auto-discovered chef repository at /home/ubuntu/chef-repo
[2015-07-18T18:29:00+00:00] DEBUG: Sleeping for 0 seconds
[2015-07-18T18:29:00+00:00] INFO: Started chef-zero at chefzero://localhost:8889 with repository at /home/ubuntu/chef-repo
One version per cookbook
[2015-07-18T18:29:00+00:00] INFO: Forking chef instance to converge...
[2015-07-18T18:29:00+00:00] DEBUG: Fork successful. Waiting for new chef pid: 3879
[2015-07-18T18:29:00+00:00] DEBUG: Forked instance now converging
[2015-07-18T18:29:00+00:00] INFO: *** Chef 12.3.0 ***
@include
include / script.sh
Last active August 29, 2015 14:19 — forked from adnaan/script.sh
ls -la
echo "hello"
tree
adb devices
adb wait-for-device #example of a long running task
package main
import (
"fmt"
"log"
"os/exec"
"runtime"
)
type Worker struct {
@include
include / plbk_vault.yml
Created October 27, 2014 09:36
Ansible Vault
---
# file: playbooks/plbk_test_vault.yml
- hosts: localhost
user: include
vars_files:
- ../files/vault/ec2/prd/svc_master_key.yml
tasks:
@include
include / boot2docker_shared.txt
Last active August 29, 2015 14:07
boot2docker with shared folders
# Install
brew update && brew upgrade
brew install docker
brew install boot2docker
brew cleanup
brew install caskroom/cask/brew-cask
brew cask install virtualbox