Skip to content

Instantly share code, notes, and snippets.

View maxp's full-sized avatar

Maxim Penzin maxp

View GitHub Profile
@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"
# make query string
return '?' + '&'.join([u'%s=%s' % (urllib.quote(str(k)), urllib.quote(str(v))) for k, v in p.items()]).replace(' ', '%20')
"""
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),
})
// 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 {
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)
#!/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)
# 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)
def plural( n, s ):
'''returns one of three s[] depends on number
[1-час,234-часа,5-часов,]
'''
n = abs(n)
if n in (11,12,13,14):
return s[2]
n = n % 10
if n == 1:
return s[0]
def get_object_or_none(klass, *args, **kwargs):
if isinstance(klass, Manager):
manager = klass
klass = manager.model
else:
manager = klass._default_manager
try:
return manager.get(*args, **kwargs)
[alias]
s = status
b = branch
ba = branch -a -v -v
bs = !git-branch-status
bsi = !git-branch-status -i
ci = commit
co = checkout
d = diff -C