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
def distance(a,b): | |
c = {} | |
n = len(a); m = len(b) | |
for i in range(0, n+1): | |
c[i, 0] = i | |
for j in range(0, m+1): | |
c[0, j] = j | |
for i in range(1, n+1): | |
for j in range(1, m+1): | |
x = c[i-1, j]+1 |
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
## common/models.py | |
from django.contrib.contenttypes.models import ContentType | |
from django.contrib.contenttypes import generic | |
class CommonFile(models.Model): | |
""" Model for common files. """ | |
content_type = models.ForeignKey(ContentType) | |
object_id = models.PositiveIntegerField() | |
content_object = generic.GenericForeignKey('content_type', 'object_id') | |
order = PositionField(unique_for_field='object_id') |
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
{% for model1 in model1s %} | |
{{ model1}} | |
{% endfor %} |
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 | |
# This hook is run after every virtualenv is activated. | |
PS1="$_OLD_VIRTUAL_PS1" | |
_OLD_RPROMPT="$RPROMPT" | |
# RPROMPT="%{${fg_bold[white]}%}(env: %{${fg[green]}%}`basename \"$VIRTUAL_ENV\"`%{${fg_bold[white]}%})%{${reset_color}%}" | |
RPROMPT='%{$reset_color%}%{$fg[white]%}⮂%{$fg[black]$bg[white]%} `basename "$VIRTUAL_ENV"` %{$fg[black]%}⮂%{$fg[white]$bg[black]%} %t %{$reset_color%}' |
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 Deferedorator = function(col, func) { | |
_.extend(this, Backbone.Events); | |
this.collection_ = col; | |
this.function_ = func; | |
}; | |
Deferedorator.prototype.start = function() { | |
this.doItem_(0); | |
}; |
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
""" | |
TODO | |
""" | |
__author__ = "Chris Jones, Kenneth Love" | |
__version__ = "0.8.5" | |
__license__ = "MIT" | |
from flask import Flask, render_template, request, session | |
from flask.views import MethodView |
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
extends ../../../views/layout | |
block content | |
form(action="/sessions", method="post") | |
label Username | |
input(type="text", name="user") | |
label Password | |
input(type="password", name="password") | |
input(type="submit", name="Submit") |
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
{% for area in areas %} | |
<h1>{{ area.name }}</h1> | |
<ul> | |
{% for computer in area.computers.all %} | |
<li>{{ computer.name }}</li> | |
{% endfor %} | |
</ul> | |
{% endfor % |
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 SomeForm(forms.Form): | |
name = forms.CharField(max_length=200) | |
def __init__(self, *args, **kwargs): | |
super(SomeForm, self).__init__(*args, **kwargs) | |
self.fields["name"].max_length = 300 | |
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 django.core.urlresolvers import reverse | |
from django.template.defaultfilters import force_escap | |
from django.test import TestCase | |
from myapp.models import MyModel | |
class MyViewTests(TestCase): | |
fixtures = ["users"] |
OlderNewer