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
raph = Raphael([..]); | |
chart = raph.g.linechart([..]); | |
var labels = ["first variable", "second variable", "third variable"]; | |
chart.labels = raph.set(); | |
var x = 15; var h = 5; | |
for( var i = 0; i < labels.length; ++i ) { | |
var clr = chart.lines[i].attr("stroke"); | |
chart.labels.push(raph.set()); | |
chart.labels[i].push(raph.g["disc"](x + 5, h, 5) |
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
class AbstractMixin(object): | |
_classcache = {} | |
@classmethod | |
def contribute(cls): | |
return {} | |
@classmethod | |
def construct(cls, *args, **kwargs): | |
attrs = cls.contribute(*args, **kwargs) |
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
var express = require('express'); | |
var app = express.createServer(); | |
app.configure(function(){ | |
app.use(express.methodOverride()); | |
app.use(express.bodyDecoder()); | |
app.use(express.logger()); | |
}); |
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.conf import settings | |
import django.core.mail | |
class MissingConnectionException(Exception): | |
pass | |
def get_connection(label=None, **kwargs): | |
if label is None: | |
label = getattr(settings, 'EMAIL_CONNECTION_DEFAULT', None) |
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.contrib.auth.models import User | |
# from tastypie.authentication import ApiKeyAuthentication | |
from tastypie.authorization import DjangoAuthorization | |
from tastypie import fields | |
from tastypie.resources import ModelResource, ALL, ALL_WITH_RELATIONS | |
from core.api.authentication import OpenReadApiKeyAuthentication | |
class UserResource(ModelResource): | |
bio = fields.CharField(attribute='profile__bio', null=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
from django.db import models | |
class TimeAwareModel(models.Model): | |
created_on = models.DateTimeField(editable=False, auto_now_add=True) | |
updated_at = models.DateTimeField(editable=False, auto_now=True) | |
class Meta: | |
abstract = 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
# Detailed explanation at http://hitesh.in/2011/running-a-bottle-py-app-on-dreamhost/ | |
#1. Add current directory to path, if isn't already | |
import os, sys | |
cmd_folder = os.path.dirname(os.path.abspath(__file__)) | |
if cmd_folder not in sys.path: | |
sys.path.insert(0, cmd_folder) | |
import bottle | |
from bottle import route, run |
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
class GoogleMapMarker(object): | |
def __init__(self, latitude, longitude): | |
self.latitude = latitude | |
self.longitude = longitude | |
def __unicode__(self): | |
return '%f,%f'%(self.latitude, self.longitude) | |
def __len__(self): | |
return len(self.__unicode__()) |
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.db import models | |
from django.contrib.auth import User | |
from mycompany.models import Client | |
from userprofiles.models import Profile | |
class External(Profile): | |
#External-specific models | |
client = models.ForeignKey(Client) | |
def __unicode__(self): |
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
import re | |
import simplejson | |
from django.http import HttpResponse | |
from django.conf import settings | |
class JSONResponse(HttpResponse): | |
def __init__(self, request, data): | |
indent = 2 if settings.DEBUG else None |
OlderNewer