This file contains hidden or 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
grupy = Grupa.objects.select_related('bank') | |
if settings.DATABASE_ENGINE.startswith('postgresql'): | |
# uwaga, brzydki hack do sortowania w postgresie | |
grupy = grupy.extra(select={'nazwa_lower': 'LOWER(bank_bank.nazwa)'}, order_by=['-bank__aktywny','nazwa_lower']) | |
else: | |
grupy = grupy.extra(order_by=['-bank__aktywny','bank__nazwa']) |
This file contains hidden or 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 sys | |
import hashlib | |
import urllib | |
import time | |
import commands | |
from datetime import datetime | |
def get_url_md5(url): |
This file contains hidden or 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 sys | |
def primes(n): | |
if n < 2: | |
return [] | |
s = range(3, n+1, 2) | |
mroot = n ** 0.5 | |
half = (n+1) / 2 - 1 |
This file contains hidden or 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 re | |
import os | |
import commands | |
import sys | |
EXT = ('js', 'css') | |
JAR = '~/workspace/yuicompressor-2.4.2.jar' | |
re_ext = re.compile(r'.*\.(%s)$' % '|'.join(EXT), re.I) |
This file contains hidden or 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 urllib | |
import libxml2 | |
import sys | |
def product_list(url, kategoria, podkategoria): | |
xml = libxml2.parseDoc(urllib.urlopen(url).read()) | |
products = xml.xpathEval('/oferta/kategoria[@nazwa="%s"]/podkategoria[@nazwa="%s"]/produkt' % (kategoria, podkategoria)) |
This file contains hidden or 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 | |
from urllib import urlencode, urlopen | |
from sys import argv | |
import json | |
def translate(lang1, lang2, text): | |
""" | |
docs: http://code.google.com/intl/pl/apis/ajaxlanguage/documentation/ | |
""" |
This file contains hidden or 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 sys | |
def main(a, b): | |
print 'a = %d, b = %d' % (a, b) | |
b ^= a | |
a ^= b | |
b ^= a |
This file contains hidden or 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 sys | |
from random import randrange | |
def main(digits_no): | |
return ''.join([str(randrange(0, 10)) for x in xrange(digits_no)]) | |
if __name__ == '__main__': |
This file contains hidden or 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 urllib2 | |
import json | |
import sys | |
from pprint import pprint | |
def main(url): | |
return json.load(urllib2.urlopen(url)) |
This file contains hidden or 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
$.post($(this).attr('action'), form.serialize(), function(answear){ | |
form.find('.errorlist').remove(); | |
$.each(answear['errors'], function(key, value){ | |
var errors = ''; | |
$.each(value, function(i,v){ | |
errors += '<li>'+v+'</li>'; | |
}); | |
form.find('#id_'+key).before('<ul class="errorlist">'+errors+'</ul>'); | |
}); | |
if (answear['id']){ |
OlderNewer