Login

Snippets by johnnoone

Snippet List

Generate QR Code image for a string

Generate QR Code image from a string with the Google charts API http://code.google.com/intl/fr-FR/apis/chart/types.html#qrcodes Exemple usage in a template {{ my_string|qrcode:"my alt" }} will return the image tag with * src: http://chart.apis.google.com/chart?chs=150x150&cht=qr&chl=my_string&choe=UTF-8 * alt: my alt"

  • filter
  • template-filter
  • filters
  • template-filters
  • qr-code
  • qr-codes
Read More

Execute a signal once

Decorates signals for executing only one time Exemple usage : from django.core.mail import EmailMultiAlternatives from django.template.loader import render_to_string from django.contrib.auth.models import User @one def user_welcome(sender, instance, created, **kwargs): # Send a welcome email if created == True and isinstance(instance, User): instance.message_set.create(message=_(u"Ho, Welcome %s!" % instance)) subject, from_email, to = 'Welcome !', '[email protected]', instance.email text_content = render_to_string('mail/welcome.html', { 'user': instance }) msg = EmailMultiAlternatives(subject, text_content, from_email, [to]) msg.send()

  • decorator
  • signals
  • once
Read More

Script factory for monitoring django-sphinx with Nagios

This snippet is used to create a script for monitoring sphinx status with Nagios via [django-sphinx](http://code.google.com/p/django-sphinx/). It returns 0 (OK) or 2 (CRITICAL). Remember to change this strings `ModelToMonitor` and `app_name`. Usage : `./manage your-controls-command --log` > /your/script/name.py

  • sphinx
  • script
  • management
  • nagios
  • monitoring
  • django-sphinx
  • factory
Read More

Monitoring django-sphinx for Nagios

This snippet is used to monitor sphinx status via [django-sphinx](http://code.google.com/p/django-sphinx/). It returns 0 (OK) or 2 (CRITICAL). Remember to change this strings `ModelToMonitor` and `app_name`. Usage : `./manage your-controls-command --log`

  • sphinx
  • management
  • nagios
  • monitoring
  • django-sphinx
Read More

NonceField for disabling autocompletion

For disabling autocomplete and security purpose, this snippet defines a CharField with a randomness name for each request of the form. This is useful for turning off autocomplete for credit card input in all browsers, without breaking the xhtml validation. * [https://wiki.mozilla.org/The_autocomplete_attribute_and_web_documents_using_XHTML#Security](https://wiki.mozilla.org/The_autocomplete_attribute_and_web_documents_using_XHTML#Security) * [http://en.wikipedia.org/wiki/Cryptographic_nonce](http://en.wikipedia.org/wiki/Cryptographic_nonce)

  • fields
  • forms
  • validation
  • security
  • form
  • field
  • autocomplete
  • formfield
  • nonce
Read More

johnnoone has posted 6 snippets.