Skip to content

Instantly share code, notes, and snippets.

View maxp's full-sized avatar

Maxim Penzin maxp

View GitHub Profile
# http://softwaremaniacs.org/blog/2009/09/21/trees-in-django-templates/
class TreeNode(template.Node):
def __init__(self, tree, node_list):
self.tree = tree
self.node_list = node_list
def render(self, context):
tree = self.tree.resolve(context)
#!/usr/bin/env python
import dbus, gobject
import pynotify
from lxml import etree
from dbus.mainloop.glib import DBusGMainLoop
def my_func(account, sender, message, conversation, flags):
xml_data = message
root = etree.fromstring(xml_data)
import os
from django.db import models
def get_image_path(instance, filename):
return os.path.join('photos', instance.id, filename)
class Photo(models.Model):
image = models.ImageField(upload_to=get_image_path)
// use enums to implement an interface.
public interface Room {
public Room north();
public Room south();
public Room east();
public Room west();
}
public enum Rooms implements Room {
"""
Example usage:
class ArticleView(RestView):
def GET(request, article_id):
return render_to_response("article.html", {
'article': get_object_or_404(Article, pk = article_id),
})
# make query string
return '?' + '&'.join([u'%s=%s' % (urllib.quote(str(k)), urllib.quote(str(v))) for k, v in p.items()]).replace(' ', '%20')
@maxp
maxp / xorg.conf
Created May 24, 2009 13:54
xorg.conf
#
# xorg.conf @ black
#
#Section "Device"
# Identifier "aticonfig-Device[0]"
# Driver "fglrx"
## Driver / Performance Options
# Option "XAANoOffscreenPixmaps" "true"
# Option "TexturedVideo" "On"