Skip to content

Instantly share code, notes, and snippets.

View cescoferraro's full-sized avatar
🏠
Working from home

cesco cescoferraro

🏠
Working from home
View GitHub Profile
@cescoferraro
cescoferraro / __init__.py
Last active August 29, 2015 14:21 — forked from anonymous/__init__.py
Flask (with factory_app) + Celery integration
# Empty
if __name__ == '__main__':
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex(('127.0.0.1', 8080))
if result == 0:
from flask.ext.migrate import Migrate, MigrateCommand
from app import db
migrate = Migrate(app, db)

This is a quick guide on installing HTTPie for Mac OS X systems. This is also useful if you want the python package management utility pip. An installed copy of Homebrew is a prerequisite.

HTTPie

# install the python package provided with homebrew
brew install python

# install HTTPie with the pip utility
pip install httpie
@cescoferraro
cescoferraro / gist:dd5318a2085fb10f5254
Last active August 29, 2015 14:27
FLASK SOCKETIO V1.0 APP FACTORY PROBLEM
websocket/socket_controllers
SAME AS THE EXAMPLE, APART FROM THE OBJECT NAME (CESCO)
websocket/__init__.py
from flask import Blueprint
websocketio = Blueprint('websocket', __name__, url_prefix="/socket")
import app.websocket.socket_controllers
@cescoferraro
cescoferraro / Multiple PhotoSwipe galleries on pagea.markdown
Created November 9, 2015 10:28
Multiple PhotoSwipe galleries on pagea
@cescoferraro
cescoferraro / How to create a Vagrant Box to run Ansible against on OSX
Last active January 7, 2016 15:14
nearly empty playbook to trigger vagrant to create a valid Ansible inventory and keys
* create a folder, here we call it /tmp/ansible-vagrant
* paste this two files inside
run:
$ vagrant up && vagrant provisioning
* this will create those both files that you will need to run ansible againt the box
/tmp/ansible-vagrant.vagrant/machines/default/virtualbox/private_key
/tmp/ansible-vagrant.vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory
ansible-playbook --private-key=.vagrant/machines/default/virtualbox/private_key \
-u vagrant \
@cescoferraro
cescoferraro / __init__.py
Created January 18, 2016 16:55
Import all files inside a package
import importlib
import os
for module in os.listdir(os.path.dirname(__file__)):
if module != '__init__.py':
if not str(module).endswith('.pyc'):
path= "scripts.%s"% module
# This is doing "import `file`" instead of "from `file` import *"
importlib.import_module(str(os.path.splitext(path)[0]))
@cescoferraro
cescoferraro / docker-compose.yml
Last active January 28, 2016 13:53
docker-compose rc2
version: 2
services:
web:
build: webapp
depends_on: [postgres]
volumes:
- ${PWD}/webapp:/srv/app
- ${PWD}/webapp/supervisor/:/etc/supervisor/
postgres:
build: psql
#cloud-config
coreos:
etcd2:
# generate a new token for each unique cluster from https://discovery.etcd.io/new:
discovery: https://discovery.etcd.io/XXXXX
# multi-region deployments, multi-cloud deployments, and Droplets without
# private networking need to use $public_ipv4:
advertise-client-urls: http://$private_ipv4:2379,http://$private_ipv4:4001
initial-advertise-peer-urls: http://$private_ipv4:2380
@cescoferraro
cescoferraro / README.md
Created March 15, 2016 15:38 — forked from andyshinn/README.md
CoreOS on Digital Ocean using Terraform

Terraform, CoreOS, and Digital Ocean

Let's use Terraform to easily get a CoreOS cluster up on Digital Ocean. In this example we will get a 5 node CoreOS cluster up and running on the Digital Ocean 8GB size.

Install Terraform

Grab a copy of Terraform for your platform from http://www.terraform.io/downloads.html. Follow the instructions at http://www.terraform.io/intro/getting-started/install.html by getting Terraform in your PATH and testing that it works.

Digital Ocean API Key