Skip to content

Instantly share code, notes, and snippets.

View katjakarhu's full-sized avatar

Katja Karhu katjakarhu

  • Helsinki, Finland
View GitHub Profile
@katjakarhu
katjakarhu / rxvt.desktop
Created May 6, 2012 13:54
rxvt .desktop file for Unity
[Desktop Entry]
Name=rxvt
Comment=Terminal emulator
TryExec=rxvt
Exec=rxvt
Icon=terminal
Type=Application
Categories=Utility;TerminalEmulator;System;
StartupNotify=true
X-Ayatana-Desktop-Shortcuts=NewWindow;
@katjakarhu
katjakarhu / radiotablerenderer.py
Created January 9, 2012 10:15
Django: render RadioSelect as table
class RadioTableRenderer(RadioSelect.renderer):
def __iter__(self):
choicelist = ""
inputlist = ""
for i, choice in enumerate(self.choices):
id = '%s' % (self.attrs['id'] if 'id' in self.attrs else '')
#label_for = ' for="%s"' % id if id else ''
choicelist = choicelist +"<th>"+choice[1]+"</th>"
@katjakarhu
katjakarhu / ajax.py
Created January 6, 2012 18:58
Realtime Pinax signup validation with jQuery and Dajax
import re
from django.utils import simplejson
from django.contrib.auth.models import User
from django.core.validators import email_re
from dajaxice.decorators import dajaxice_register
from emailconfirmation.models import EmailAddress
@katjakarhu
katjakarhu / views.py
Created January 5, 2012 10:22
Random stuff
from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver
@receiver(post_save, sender=User)
def user_created_callback(sender, instance, created, **kwargs):
if created:
# do stuff
@katjakarhu
katjakarhu / ajax.py
Created December 19, 2011 18:54
Dajax - Save and edit a single form in a formset
# Like the Dajax full form example, but for a form in a formset: http://dajaxproject.com/fullform/
#
# Javascript
# get the css id which surrounds the form you need to variable myformcssid
# var data = $(myformcssid + ' *').serializeObject(); # use serialize() if not jQuery
# id for the instance to be modified
# var mymodelid = "{{ form.instance.id }}"
HTML5 Django DateTimeWidget
See rest of the code and instructions at:
http://copiesofcopies.org/webl/ ( http://copiesofcopies.org/webl/2010/04/26/a-better-datetime-widget-for-django/ )
For localized times, use with django-timezones:
from timezones.forms import LocalizedDateTimeField
date_field = LocalizedDateTimeField(