Skip to content

Instantly share code, notes, and snippets.

@k1000
k1000 / fabfile.py
Created November 21, 2009 11:55
deploy django fabfile
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
fabfile for Django
------------------
see http://morethanseven.net/2009/07/27/fabric-django-git-apache-mod_wsgi-virtualenv-and-p/
modified for fabric 0.9/1.0 by Hraban (fiëé visuëlle)
several additions, corrections and customizations, too
@k1000
k1000 / django snippets 4 kate
Created April 4, 2010 09:43
kate django model snippet
<snippets license="BSD" filetypes="Python" authors="Kamil Selwa" name="Django1.2 snippets based on Texmate http://svn.textmate.org/trunk/Bundles/Python%20Django.tmbundle/Snippets/">
<item>
<displayprefix></displayprefix>
<match>m2m</match>
<displaypostfix></displaypostfix>
<displayarguments>FIELDNAME</displayarguments>
<fillin>${1:FIELDNAME} = models.ManyToManyField(${RELATED_MODEL}, related_name=${RELATED_NAME}, ${limit_choices_to={'pub_date__lte': datetime.now}} )</fillin>
</item>
<item>
<displayprefix></displayprefix>
@k1000
k1000 / CSS prepare 4 IE
Created April 11, 2010 21:44
build CSS 4 IE
# -*- coding: utf-8 -*-
import sys, re, time
#based on http://stackoverflow.com/questions/222581/python-script-for-minifying-css
#css = open( sys.argv[1] , 'r' ).read()
myfile = "style.css"
css = open( "style.css" , 'r' ).read()
css = re.sub( r'\s+', ' ', css )
print "/* ---------------------------------------------------------------------*/"
print "/* -------------- GENERATED FROM %s AT %s ------------*/" % (myfile, time.strftime( "%d %b %Y %H:%M", time.gmtime()) )
@k1000
k1000 / gist:653175
Created October 29, 2010 08:57
requirements.txt
#requirements
PIL>=1.1.6
MySQL-python>=1.2.2
python-memcached>=1.44
simplejson>=2.0.9
html5lib>=0.10
#fundamental apps
-e svn+http://code.djangoproject.com/svn/django/trunk#egg=Django
-e hg+https://sorl-thumbnail.googlecode.com/hg/#egg=sorl
"""
This fabric file makes setting up and deploying a django application much
easier, but it does make a few assumptions. Namely that you're using Git,
Apache and mod_wsgi and your using Debian or Ubuntu. Also you should have
Django installed on your local machine and SSH installed on both the local
machine and any servers you want to deploy to.
_note that I've used the name project_name throughout this example. Replace
this with whatever your project is called._
@k1000
k1000 / ajax_form.py
Created February 17, 2011 12:31
ajax form using partials taking advantage of class views (new in django 1.3)
# -*- coding: utf-8 -*-
from django import forms
from django.views.generic.edit import FormView
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import force_unicode
from ajax import JSONResponseMixin, JSONResponsePartialMixin
class HoneySpotMixin(object):
error_css_class = 'error'
required_css_class = 'required'
@k1000
k1000 / jquery.rater.js
Created February 17, 2011 12:38
another jquery star rating plugin
// JavaScript Document
/*************************************************
Star Rating System
First Version: 23 June 2010
Author: Kamil Selwa
Inspriation: http://php.scripts.psu.edu/rja171/widgets/rating.php
Usage: $('#rating').rating( {url:'www.url.to.post.com', curvalue:3});
options
@k1000
k1000 / jquery.validate.js
Created February 17, 2011 12:46
simple and extensible jquery validation based on class name of the input element
/* ------------------------------------------------------
ver: 0.1
Validación de formularios con el soporte para NET
----------------------------------------------------------
autor Kamil Selwa 09.03.2010
----------------------------------------------------------
requiere jquery > 1.2.3 http://jquery.com
-----------------------------------------------------------
soportadas reglas de validación:
required
@k1000
k1000 / jquery.validate.js
Created May 18, 2011 14:16
jquery.validate.js plugin
/* ------------------------------------------------------
ver: 0.2
Validación de formularios con el soporte para NET
----------------------------------------------------------
autor Kamil Selwa 09.03.2010
----------------------------------------------------------
requiere jquery > 1.2.3 http://jquery.com
-----------------------------------------------------------
incorporadas reglas de validación:
required
@k1000
k1000 / countries.py
Created July 26, 2011 07:43
countries list
# -*- coding: utf-8 -*-
# Nicely titled (and translatable) country names.
COUNTRIES = (
('AF', u'Afghanistan'),
('AX', u'\xc5land Islands'),
('AL', u'Albania'),
('DZ', u'Algeria'),
('AS', u'American Samoa'),
('AD', u'Andorra'),
('AO', u'Angola'),