We will use official box "ubuntu/xenial64" and modify it to work with Vagrant.
- Vagrantfile
| __author__ = 'fbaldo' | |
| import psycopg2 | |
| import pprint | |
| configuration = { 'dbname': 'database_name', | |
| 'user':'user_name', | |
| 'pwd':'user_password', | |
| 'host':'redshift_endpoint', |
| #! /usr/bin/env python | |
| # | |
| # Mixpanel, Inc. -- http://mixpanel.com/ | |
| # | |
| # Python API client library to consume mixpanel.com analytics data. | |
| import hashlib | |
| import urllib | |
| import time | |
| try: |
| package main | |
| import ( | |
| "net/http" | |
| "database/sql" | |
| "fmt" | |
| "log" | |
| "os" | |
| ) |
| ====================================== | |
| Setting up Nginx, uWSGI and Python3 | |
| ====================================== | |
| First off, I'm traditionally a PHP developer, but am looking at moving across to Python. I really struggled to find decent documentation on how to get a server up and running for deploying Python web applications from the point of view of someone coming from PHP. The main problems I came across with documentation were: | |
| 1) Only showed you how to run the server for a single web application. | |
| 2) Only showed you how to configure the app, not the server it was running on. | |
| My preferred workflow for development is by setting up a new VM in VMware Fusion and then forwarding through all requests to that VM via /etc/hosts. This might not be the optimal way to get things up and running, but it works for me. |
| from time import sleep | |
| from tornado.httpserver import HTTPServer | |
| from tornado.ioloop import IOLoop | |
| from tornado.web import Application, asynchronous, RequestHandler | |
| from multiprocessing.pool import ThreadPool | |
| _workers = ThreadPool(10) | |
| def run_background(func, callback, args=(), kwds={}): | |
| def _callback(result): |
| #!/usr/bin/env python | |
| #coding=utf-8 | |
| import socket | |
| import os | |
| import errno | |
| from tornado.ioloop import IOLoop | |
| from tornado.platform.auto import set_close_exec | |
| class UDPServer(object): | |
| def __init__(self, io_loop=None): |
| import time, sys, os, pkg_resources | |
| import SocketServer | |
| from twisted.python import log | |
| from twisted.internet import reactor | |
| from twisted.application import service | |
| from twisted.internet.protocol import DatagramProtocol, Protocol, Factory | |
| from twisted.web.server import Site |
I spent a lot of time trying to find a pretty optimal (for me) setup for Clojure… at the same time I was trying to dive in and learn it. This is never optimal; you shouldn't be fighting the environment while trying to learn something.
I feel like I went through a lot of pain searching Google, StackOverflow, blogs, and other sites for random tidbits of information and instructions.
This is a comprehensive "what I learned and what I ended up doing" that will hopefully be of use to others and act as a journal for myself if I ever have to do it again. I want to be very step-by-step and explain what's happening (and why) at each step.
I appreciate the effort you've put into documenting this, but there are a number of inaccuracies here that need to be addressed. We get