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 / .bash_prompt
Created March 12, 2012 23:50 — forked from melo/.bash_prompt
uber git PS1
#!/bin/bash
#
# PS1 magic
#
# Mostly copied from YUVAL KOGMAN version, added my own __git_ps1 stuff
# Original: http://gist.github.com/621452
#
# See video demo of this at http://vimeo.com/15789794
#
# To enable save as .bash_prompt in $HOME and add to .bashrc:
#!/bin/sh
setup_brew () {
if ![-f "/usr/local/bin/brew"]; then
/usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"
fi
}
setup_ipython () {
brew install gcc

Docker Cheat Sheet

Why

Why Should I Care (For Developers)

"Docker interests me because it allows simple environment isolation and repeatability. I can create a run-time environment once, package it up, then run it again on any other machine. Furthermore, everything that runs in that environment is isolated from the underlying host (much like a virtual machine). And best of all, everything is fast and simple."

TL;DR, I just want a dev environment

{
"builders": [
{
"boot_command": [
"<tab> linux enforcing=0 ks=http://rpm-ostree.cloud.fedoraproject.org/project-atomic/install/rawhide/fedora-atomic.ks<enter><wait>"
],
"boot_wait": "10s",
"disk_size": 8192,
"guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso",
"guest_os_type": "Fedora_64",

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
package main
import (
"fmt"
"log"
"os/exec"
"runtime"
)
type Worker struct {
@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

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 / 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:
@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?