Figured I would slowly pour out some source code that was created during my stint at my last startup. The code ranges from really simple to very complex. Some still might not see the light of day until I try again. ;-)

Basic CoffeeScript keygen: https://gist.github.com/2410489

Simple Python password generator: https://gist.github.com/2410498

I just forked and pushed a quick hack patch out. It adds Django 1.3 compatibility with 1.2 fallback to the Nexus Memcache module (developed and used by Disqus). I am slightly worried that 1.4 will probably shift things again regarding cache backends. Will have to wait and see before I turn this hack in to something more stable.

https://github.com/JasonGiedymin/nexus-memcache

While evaluating Flask for my current project I had the need to map subdomains to a sub app. Here is a complete Fabric, Flask, Flask-Script (like Django manage.py) scaffold template that you can use. The script will install a virtualenv environment and pip install requirements into that virtual environment.

https://github.com/JasonGiedymin/Flask-Module-Scaffold

Here is the readme:

== What is this? ==
Use this scaffold / template as a basis for a Subapp / Module based Flask 
application using subdomains and subapps content. There is also an example
of using a subapp / module to extend root app space.

The application relies on Fabric to start, and includes staging
functionality to auto install all required dependencies.

== How To Use this? ==
First you'll need to edit your hosts file to direct the 'dummy' subdomain to localhost.
1. Edit /etc/hosts
2. Add an entry for "127.0.0.1  dummy.localhost"

Start installing dependencies and run the app:
1. Clone this repo
2. pip install fabric
3. cd Flask-Module-Scaffold/src
4. fab -l #Lists all commands
5. fab staging_local #Creates virtualenv and pip installs
6. fab start_dev_server #Starts the dev server

== The app is running, now what? ==
Navigate to these pages:
    # Served from the 'frontend' subapp/module
    # Templates and CSS served from frontend/[static,templates]
    http://localhost:8080
    http://localhost:8080/template
    
    # Served from the 'dummy' subbapp/module
    # Templates and CSS served from dummy/[static,templates]
    http://dummy.localhost:8080/
    http://dummy.localhost:8080/template
    
    # Served from the 'root' subapp/module using the main apps static/template
    # directories.
    # Templates and CSS served from root myapp/[static,templates]
    # To prove this, apps/root/ is devoid of the static and templates directories.
    http://localhost:8080/hello
    http://localhost:8080/root-template

== References ==
Flask:  http://flask.pocoo.org/
        "Flask is a microframework for Python based on Werkzeug, Jinja 2
        and good intentions. And before you ask: It's BSD licensed!"

Fabric: http://docs.fabfile.org/en/1.0.1/index.html
        "Fabric is a Python (2.5 or higher) library and command-line 
        tool for streamlining the use of SSH for application deployment
        or systems administration tasks."
        
== Noob? ==
This is a python repo using python tools and frameworks.

Yup, It’s official. I went and uninstalled MacPorts for HomeBrew.

Here are the MacPorts uninstall instructions.

So far so good! :-)

Note: What made the move easier was I had installed Mac Python and RVM (Ruby) outside of MacPorts.

I tried to install gevent today but had some issues on OSX 10.6.7 and Python 2.7.1. This version of python is a pretty safe bet with wide support for various libs. As always you should be using virtualenv.

Lets get started (at this point you should have already setup a virtualenv environment). You’ll note that I like to build each package separately as any number of issues could arrise in the build process. With less noise I’m able to debug the issues, I recommend you do the same unless you know for sure your setup is ready to go and expect no issues ;-) 

Libevent

First I like to grab libevent via macports. Ignore this if you’ve already done it on your system.

sudo ports install libevent

Alternatively you could build it yourself or use Homebrew. By the way, both MacPorts and Homebrew do use the newer Libevent2.X.X branch.

Install cython

pip install cython

Install greenlet (optional as gevent will build this).

pip install greenlet

Clone, Build, Install gevent.

hg clone https://bitbucket.org/denis/gevent

I like to first build gevent to see if everything went right. Change to the gevent directory first and then:

python setup.py build

If all went well go ahead and install:

python setup.py install

Note on MacPorts

If you installed Python 2.7 from MacPorts, you’ll be happy to see they’ve already got a gevent port for you. Install like so:

sudo port install py27-gevent

Django 1.3 was just released and I wanted to integrate RFC 2822, Python’s TimedRotatingFileHandler and WatchedFileHandler in Django’s new Logging settings.

Here you go, a snippet/gist of how to get these handlers implemented. 

https://gist.github.com/887364

Pip does not yet have an ‘upgrade all’ command, but you can do the following until then. The command below issues a freeze and uses cut to strip the version numbers so that you can pipe xargs on pip with the install and upgrade directives.



Printing on screen what will run:

pip freeze | cut -d = -f 1  | xargs echo pip install -U



Running the command:

pip freeze | cut -d = -f 1  | xargs pip install -U



Alternative (same as the first but with the back ticks):

`pip freeze | cut -d = -f 1  | xargs echo pip install -U`