This document has now been incorporated into the uWSGI documentation:
http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html
Steps with explanations to set up a server using:
from flask.ext.sqlalchemy import SQLAlchemy | |
def get_model(self, name): | |
return self.Model._decl_class_registry.get(name, None) | |
SQLAlchemy.get_model = get_model | |
def get_model_by_tablename(self, tablename): | |
for c in self.Model._decl_class_registry.values(): | |
if hasattr(c, '__tablename__') and c.__tablename__ == tablename: | |
return c |
$ = jQuery | |
$.fn.lineHeight or= -> | |
if height = @data('lineHeight') | |
return height | |
# Create a hidden div with the same font | |
# properties, then measure its height | |
$shadow = $('<span />') | |
$shadow.css({ |
class App extends Spine.Controller | |
@extend(Spine.Events) | |
constructor: -> | |
super | |
# Initialize cache object | |
App.cache = {} unless App.cache? |
var user = { | |
validateCredentials: function (username, password) { | |
return ( | |
(!(username += '') || username === '') ? { error: "No Username Given.", field: 'name' } | |
: (!(username += '') || password === '') ? { error: "No Password Given.", field: 'pass' } | |
: (username.length < 3) ? { error: "Username is less than 3 Characters.", field: 'name' } | |
: (password.length < 4) ? { error: "Password is less than 4 Characters.", field: 'pass' } | |
: (!/^([a-z0-9_-]+)$/i.test(username)) ? { error: "Username contains invalid characters.", field: 'name' } | |
: false | |
); |
This code is a suggested answer to question asked on Stackoverflow: | |
http://stackoverflow.com/questions/4827965/can-i-change-djangos-auth-user-username-field-to-be-100-chars-long-without-break/ |
namespace.views.MyWizard = Backbone.Views.extend({ | |
initialize: function() { | |
_.bindAll(this, 'render', 'wizardMethod'); | |
} | |
render: function() { | |
this.wizardMethod(); | |
return this; | |
}, |
// includes bindings for fetching/fetched | |
var PaginatedCollection = Backbone.Collection.extend({ | |
initialize: function() { | |
_.bindAll(this, 'parse', 'url', 'pageInfo', 'nextPage', 'previousPage', 'filtrate', 'sort_by'); | |
typeof(options) != 'undefined' || (options = {}); | |
typeof(this.limit) != 'undefined' || (this.limit = 20); | |
typeof(this.offset) != 'undefined' || (this.offset = 0); | |
typeof(this.filter_options) != 'undefined' || (this.filter_options = {}); | |
typeof(this.sort_field) != 'undefined' || (this.sort_field = ''); |