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 Model = function(attrs) | |
{ | |
this.attrs = attrs; | |
for (var attr in attrs) | |
var tmp = function(name) { | |
this[attr] = function(x) { | |
if (arguments.length) { | |
this.attrs[name] = x; | |
return this; |
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
<!DOCTYPE html> | |
<script src="http://mbostock.github.com/d3/d3.v2.js"></script> | |
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script> | |
<style>path { stroke: steelblue; stroke-width: 1; fill: none; }</style> | |
<body> | |
<script> | |
$(window).load(function() { | |
// Animate between these two straight lines. | |
var d0 = [[ |
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
<?php | |
function dict2xml($d, $root_node=null, $use_attr=true) | |
{ | |
$wrap = (null == $root_node or is_plain_array($d)) ? false : true; | |
$root = (null == $root_node) ? 'objects' : $root_node; | |
$root_singular = ('s' == $root[strlen($root) - 1] and null == $root_node) | |
? substr($root, 0, strlen($root) - 1) | |
: $root; | |
$xml = ''; | |
$end_tag = ''; |
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
""" | |
Simple xml serializer. | |
@author Reimund Trost 2013 | |
Example: | |
mydict = { | |
'name': 'The Andersson\'s', | |
'size': 4, |
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
""" settings.py """ | |
import sys, os | |
from zettings.base import * | |
sys.path.append(os.getcwd() + '/../') | |
ENV = os.environ.get('DJANGO_ENV', 'localdev') | |
# Import the right settings for this environment. | |
# DJANGO_ENV should be set to the name of a module which contains a |
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.views.generic.list import ListView | |
class UsefulListView(ListView): | |
""" Allows passing extra_context to ListView.as_view(). """ | |
extra_context = {} | |
def get_context_data(self, **kwargs): | |
context = super(UsefulListView, self).get_context_data(**kwargs) | |
context.update(self.extra_context) |