Skip to content

Instantly share code, notes, and snippets.

View jedie's full-sized avatar

Jens Diemer jedie

View GitHub Profile
def upper_case_name(obj):
raise AttributeError # ignored!
class PersonAdmin(admin.ModelAdmin):
list_display = (upper_case_name,)
@jedie
jedie / python_test.py
Created September 1, 2011 16:51
Detect web handler: mod_wsgi, fast_CGI, mod_python or CGI and display many informations
#!/usr/bin/env python
# coding: utf-8
"""
Python web handler test
~~~~~~~~~~~~~~~~~~~~~~~
Detect web handler: mod_wsgi, fast_CGI, mod_python or CGI and display many informations
You should check if the shebang is ok for your environment!
@jedie
jedie / gist:1231898
Created September 21, 2011 12:21
temporaty disable auto_now and auto_now_add for overwrite...
for field in new_entry._meta.local_fields:
if field.name == "lastupdatetime":
field.auto_now = False
elif field.name == "createtime":
field.auto_now_add = False
new_entry.createtime = date
new_entry.lastupdatetime = date
new_entry.save()
# coding: utf-8
import time
import Tkinter as tkinter
WIDTH = 320
HEIGHT = 240
LEFT = -2
RIGHT = 0.5
TOP = 1.25
@jedie
jedie / gist:1601490
Created January 12, 2012 16:36
add this to your local_settings.py to "hide" the info string
from django_processinfo import app_settings as PROCESSINFO
PROCESSINFO.INFO_FORMATTER = "<!-- django-processinfo: %(own).1f ms of %(total).1f ms (%(perc).1f%%) -->"
@jedie
jedie / BackfaceCullOff.ms
Created April 15, 2012 13:14
maxscript to turn off backface cull on all objects
--
-- copyleft (c) 2012 by htFX, Jens Diemer - http://www.htFX.de
--
-- https://gist.github.com/2392735
-- http://www.scriptspot.com/3ds-max/scripts/maxscript-to-turn-off-backface-cull-on-all-objects
--
actionMan.executeAction 0 "40472" -- MAX Script: MAXScript Listener
clearListener()
actionMan.executeAction 0 "40472" -- MAX Script: MAXScript Listener
clearListener()
trackIndex = 1
m = trackViewNodes[trackIndex]
while (m != undefined) do
(
print trackIndex
windows.processPostedMessages()
#!/bin/sh
# more info here: http://www.pylucid.org/permalink/410/runserversh
# use the local django packages
export PYTHONPATH=${PWD}
PORT='8000'
"""
http://www.python-forum.de/viewtopic.php?f=1&t=29222
"""
import difflib
from itertools import izip_longest, tee
def compare(first, second):
class PersonModel(models.Model):
name = models.CharField(max_length=128)
friends = models.ManyToManyField("self", blank=True, null=True)
def __unicode__(self):
return "Person '%s'" % self.name
# ------------------------------------------------------------
p1 = PersonModel(name="paul")
p1.save()