Skip to content

Instantly share code, notes, and snippets.

@fcurella
fcurella / django_postgis_on_os_x.md
Created July 27, 2012 15:22
Django and Postgis on OS X

Django and Postgis on OS X

Install Homebrew

Install a few things with homebrew:

Notice that some packages give you information at the end, read it carefully. To recall that info use brew info like this: $ brew info postgresql

$ brew install python --universal
@fcurella
fcurella / bootstrap_python_django.py
Created September 9, 2011 20:01
django_bootstrap installation script
#!/usr/bin/env python
import os
import urllib
URL = 'https://raw.github.com/gist/1207150'
INSTALL_DIR = '/usr/local/bin/'
COMMAND_NAME = 'django_bootstrap'
command_path = "%s%s" % (INSTALL_DIR, COMMAND_NAME)
fh = urllib.urlopen(URL)
@fcurella
fcurella / bootstrap_python_django.sh
Created September 9, 2011 19:47
This script installs virtualenv and pip, and create a virtualenv with django and your project
#!/bin/bash
PROJ_DIR=$1
PROJ_NAME=$2
easy_install virtualenv pip;
mkdir -p $PROJ_DIR;
virtualenv $PROJ_DIR
source $PROJ_DIR/bin/activate
@fcurella
fcurella / clean_pyc
Created August 25, 2011 21:17
command to clean stale *.pyc files
#!/bin/sh
find . -name '*.pyc' -print0|xargs -0 rm
@fcurella
fcurella / gist:976625
Created May 17, 2011 14:56 — forked from putermancer/gist:591964
Set up a local solr instance on mac
# 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/
"""
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.
// 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() {
@fcurella
fcurella / placeholders.js
Created January 15, 2011 21:44
Add 'placeholder' attribute support to inputs and textareas. Requires jQuery and Modernizr.
$(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();
@fcurella
fcurella / IterableCollection.js
Created January 9, 2011 18:06
A Backbone.js collection class with utility methods for iterating and picking
IterableCollection = Backbone.Collection.extend({
initialize: function() {
//_.bindAll(this, )
this._resetIndexes();
},
_resetIndexes: function() {
this.currentIndex = 0;
this.hasSelection = false;
},
parse: function(response) {
# -*- 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):
"""