Skip to content

Instantly share code, notes, and snippets.

View arnaldopereira's full-sized avatar

Arnaldo de Moraes Pereira arnaldopereira

View GitHub Profile
@arnaldopereira
arnaldopereira / get_elb_instance_ips.py
Created November 13, 2016 19:50
get aws ELB instance IP addresses
#!/usr/bin/env python
import boto
from boto.ec2 import elb
ACCESS_KEY_ID = 'access-key-id'
SECRET_ACCESS_KEY = 'secret-access-key'
@arnaldopereira
arnaldopereira / fetch_mock_generator.py
Created November 13, 2016 19:48
mock tornado's AsyncHTTPClient().fetch - generator
#!/usr/bin/env python
from tornado import gen
from tornado.ioloop import IOLoop
from tornado.concurrent import Future
from tornado.httpclient import AsyncHTTPClient
from tornado.httpclient import HTTPRequest
from tornado.httpclient import HTTPResponse
import mock
@arnaldopereira
arnaldopereira / fetch_mock_coroutine.py
Created November 13, 2016 19:48
mock tornado's AsyncHTTPClient().fetch - coroutine
#!/usr/bin/env python
from tornado import gen
from tornado.ioloop import IOLoop
from tornado.httpclient import AsyncHTTPClient
from tornado.httpclient import HTTPRequest
from tornado.httpclient import HTTPResponse
import mock
import StringIO
@arnaldopereira
arnaldopereira / asyncreplay.py
Created November 13, 2016 19:44
asyncreplay, python 2 + tornado
#!/usr/bin/env python
from tornado import gen
from tornado.ioloop import IOLoop
from tornado.httpclient import AsyncHTTPClient
from tornado.httpclient import HTTPClient
from tornado.httpclient import HTTPResponse
from tornado.httpclient import HTTPRequest
from tornado.httpclient import HTTPError
import StringIO
@arnaldopereira
arnaldopereira / webserver_random_port.go
Created June 6, 2016 19:50
golang webserver listening on a random port
package main
import (
"fmt"
"log"
"net"
"net/http"
)
func indexHandler(w http.ResponseWriter, r *http.Request) {
pods
Pods are groups of containers that are deployed and scheduled together. Pods form the atomic unit of scheduling in Kubernetes, as opposed to single containers in other systems. A pod will typically include 1 to 5 containers which work together to provide a service. In addition to these user containers, Kubernetes will run other containers to provide logging and monitoring services. Pods are treated as ephemeral in Kubernetes; you should expect them to be created and destoyed continually as the
system evolves.
services
Services are stable endpoints that can be addressed by name. Services can be connected to pods by using label selectors; for example my “cache” service may connect to several “redis” pods identified by the label selector “type”: “redis”. The service will automatically round-robin requests between the pods. In this way, services can be used to connect parts of a system to each other. Using services provides a layer of abstraction that means applications do not need to know interna
@arnaldopereira
arnaldopereira / java.yml
Created February 2, 2016 18:59
Ansible role to install oracle java 7
---
- name: install java 7 dependencies
apt: name=python-software-properties state=latest update_cache=yes
- name: add java repository
apt_repository: repo='ppa:webupd8team/java'
- name: auto accept license for java
action: shell echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
@arnaldopereira
arnaldopereira / run_with_lock.sh
Last active December 11, 2015 19:51
lockfile-utils
#!/bin/bash
LOCKFILE="/tmp/foo.lock"
function atexit {
lockfile-remove $LOCKFILE
echo atexit!
exit
}
@arnaldopereira
arnaldopereira / async_httpclient.py
Created February 11, 2015 15:30
tornado httpclient
#!/usr/bin/env python
# encoding: utf-8
from tornado import gen
from tornado.httpclient import HTTPError
from tornado.httpclient import AsyncHTTPClient
from tornado.httputil import url_concat
from tornado.ioloop import IOLoop
@arnaldopereira
arnaldopereira / gist:c30a02d93e8f8d400f0d
Created August 14, 2014 18:26
ansible tasks to install logstash
- name: install java 7 dependencies
sudo: yes
apt: name=python-software-properties state=latest update_cache=yes
- name: add java repository
sudo: yes
apt_repository: repo='ppa:webupd8team/java'
- name: add elasticsearch/logstash repository
sudo: yes