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
# | |
# xorg.conf @ black | |
# | |
#Section "Device" | |
# Identifier "aticonfig-Device[0]" | |
# Driver "fglrx" | |
## Driver / Performance Options | |
# Option "XAANoOffscreenPixmaps" "true" | |
# Option "TexturedVideo" "On" |
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
# make query string | |
return '?' + '&'.join([u'%s=%s' % (urllib.quote(str(k)), urllib.quote(str(v))) for k, v in p.items()]).replace(' ', '%20') |
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
""" | |
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), | |
}) |
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
// 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 { |
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
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) |
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
#!/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) |
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
# 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) |
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 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] |
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 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) |
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
[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 |
OlderNewer