This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
====================================================== | |
Setting up Django using Apache/mod_wsgi on Ubuntu 8.10 | |
====================================================== | |
This article will cover setting up Django using Apache/mod_wsgi on Ubuntu | |
8.10. The article is targeted at a production environment, but keep in mind | |
this is a more generalized environment. You may have different requirements, | |
but this article should at least provide the stepping stones. | |
The article will use distribution packages where nesscary. As of 8.10 the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.http import HttpResponse | |
from decorator import decorator | |
import simplejson as json | |
@decorator | |
def json_response(f, *args, **kwargs): | |
try: | |
status_code = 200 | |
response = { | |
'status': True, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import datetime | |
from django.http import HttpResponse | |
from django.utils import simplejson | |
from django.shortcuts import render_to_response | |
from django.template import RequestContext | |
class DateTimeJSONEncoder(simplejson.JSONEncoder): | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IterableCollection = Backbone.Collection.extend({ | |
initialize: function() { | |
//_.bindAll(this, ) | |
this._resetIndexes(); | |
}, | |
_resetIndexes: function() { | |
this.currentIndex = 0; | |
this.hasSelection = false; | |
}, | |
parse: function(response) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
if (!Modernizr.input.placeholder) { | |
$('input[placeholder], textarea[placeholder]').each(function(index, elem) { | |
elem = $(elem); | |
placeholder = elem.attr('placeholder'); | |
elem_id = elem.attr('id'); | |
elem_name = elem.attr('name'); | |
clone = elem.clone(); | |
clone.hide(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// execute callback only after a pause in user input; the function returned | |
// can be used to handle an event type that tightly repeats (such as typing | |
// or scrolling events); it will execute the callback only if the given timout | |
// period has passed since the last time the same event fired | |
function createOnPause(callback, timeout, _this) { | |
return function(e) { | |
var _that = this; | |
if (arguments.callee.timer) | |
clearTimeout(arguments.callee.timer); | |
arguments.callee.timer = setTimeout(function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Straight Include template tag by @HenrikJoreteg | |
Django templates don't give us any way to escape template tags. | |
So if you ever need to include client side templates for ICanHaz.js (or anything else that | |
may confuse django's templating engine) You can is this little snippet. | |
Just use it as you would a normal {% include %} tag. It just won't process the included text. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Setting up a local solr instance on a mac | |
# install solr with homebrew | |
brew install solr | |
# create the base solr index directory | |
mkdir -p /data/solr | |
# make sure you can write to the solr logs | |
sudo chown -R `whoami` /usr/local/Cellar/solr/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
find . -name '*.pyc' -print0|xargs -0 rm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PROJ_DIR=$1 | |
PROJ_NAME=$2 | |
easy_install virtualenv pip; | |
mkdir -p $PROJ_DIR; | |
virtualenv $PROJ_DIR | |
source $PROJ_DIR/bin/activate |
OlderNewer