This file contains hidden or 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 MyInline(admin.TabularInline): | |
model = MyModel | |
extra = 0 | |
template = 'admin/edit_inline/list.html' | |
def get_formset(self, request, obj=None, **kwargs): | |
FormSet = super(ActivationKeyInline, self).get_formset(request, obj, **kwargs) | |
class NewFormSet(FormSet): | |
def _construct_forms(self, *args, **kwargs): | |
qs = self.get_queryset() |
This file contains hidden or 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 StringIO import StringIO | |
tree1 = ("Root", ("Child 1", ("Child 2", None))) | |
get_label1 = lambda x: x[0] | |
def get_children1(node): | |
if node[1] is not None: | |
yield node[1] | |
class Node(object): | |
This file contains hidden or 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.models import base | |
from django.conf import settings | |
class ModelBase(base.ModelBase): | |
def __new__(cls, name, bases, attrs): | |
parents = [b for b in bases if isinstance(b, ModelBase)] | |
if not parents: | |
# Don't run our fixup on the model base class itself. | |
return super(ModelBase, cls).__new__(cls, name, bases, attrs) | |
This file contains hidden or 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 __future__ import absolute_import | |
import os | |
import sys | |
import webbrowser | |
from django.conf import settings | |
from django.core.management import setup_environ | |
from django.core.management.commands import test | |
from django.utils.importlib import import_module | |
from django.db.models.loading import cache |
This file contains hidden or 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 os | |
def walkfiles(d): | |
for base, dirnames, filenames in os.walk(d): | |
for name in filenames: | |
yield os.path.join(base, name) |
This file contains hidden or 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
// ==UserScript== | |
// @name Lifetime blues | |
// @namespace http://startrekonline.com/ | |
// @include http://forums.startrekonline.com/showthread.php* | |
// ==/UserScript== | |
var snapAlt2 = document.evaluate("//table//td[@class='alt2']//span", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); | |
for (var i = snapAlt2.snapshotLength - 1; i >= 0; i--) { | |
var elm = snapAlt2.snapshotItem(i); | |
NewerOlder