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
| import hashlib | |
| def payu_rounder(value): | |
| u"""value is a unicode, returns the round according to Payu documentation | |
| to be used by confirmationUrl | |
| >>> payu_rounder(u'150.25') | |
| u'150.2' | |
| >>> payu_rounder(u'150.35') | |
| u'150.4' | |
| >>> payu_rounder(u'150.34') |
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
| import time | |
| import httplib | |
| from datetime import datetime | |
| from collections import OrderedDict | |
| from django.conf import settings | |
| from constance import config | |
| # You can use soap_call(prepare_data()) |
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/python2.7 | |
| import argparse | |
| import gspread # Pip install it | |
| def print_spreadsheet(email, password, key): | |
| """print_spreadsheet(email, password, key) | |
| Prints out a Google spreadsheet | |
| """ |
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
| import unicodecsv # pip install unicodecsv | |
| import urllib2 | |
| def loadfile(url, delimiter=","): | |
| """Loads a file from a URL (a csv one), separated with delimiter | |
| returns an array with the contents of the file. | |
| """ | |
| reader = unicodecsv.reader( | |
| urllib2.urlopen(url), | |
| encoding='utf-8', |
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
| iconv -f iso-8859-1 -t utf-8 INPUTFILE | sed 's%^.*<table>%%g;s%</table>%%g;s% x:str%%g' | sed 's%<tr><td>%%g;s%</td><td>%|%g;s%</td></tr>%\n%g' > OUTPUTFILE |
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
| pkgver=1.2.17 | |
| mkdir -p $VIRTUAL_ENV/src && cd $VIRTUAL_ENV/src | |
| curl -O http://oligarchy.co.uk/xapian/$pkgver/xapian-core-$pkgver.tar.xz && tar xf xapian-core-$pkgver.tar.xz | |
| curl -O http://oligarchy.co.uk/xapian/$pkgver/xapian-bindings-$pkgver.tar.xz && tar xf xapian-bindings-$pkgver.tar.xz | |
| cd $VIRTUAL_ENV/src/xapian-core-$pkgver | |
| ./configure --prefix=$VIRTUAL_ENV && make && make install | |
| export LD_LIBRARY_PATH=$VIRTUAL_ENV/lib |
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
| def weekly(query, weeks, initial, final): | |
| u"""Returns a partitioned result grouped by 7 days. | |
| query: Initial query | |
| weeks: Max Number of weeks | |
| initial: initial part of the week | |
| final: end part of the week | |
| You can use like the following: | |
| previous = weekly( | |
| my_query, 8, 'validated_at__gt', 'validated_at__lte', |
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
| """With the Gmail API is easy to download all your messages or filter them, | |
| is a good practice to have filters and put them in your own messages, so later you | |
| can get some statistics. | |
| You need to make all the auth dance in order to connect to the API, for development | |
| purposes you'll be ok with the instructions provided by Gmail | |
| https://developers.google.com/gmail/api/v1/reference/users/messages | |
| """ | |
| # Path to the output filename |
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
| UPDATE cms_base_page SET content=replace(content, 'Á', 'Á'); | |
| UPDATE cms_base_page SET content=replace(content, 'É', 'É'); | |
| UPDATE cms_base_page SET content=replace(content, 'Í', 'Í'); | |
| UPDATE cms_base_page SET content=replace(content, 'Ó', 'Ó'); | |
| UPDATE cms_base_page SET content=replace(content, 'Ú', 'Ú'); | |
| UPDATE cms_base_page SET content=replace(content, 'Ü', 'Ü'); | |
| UPDATE cms_base_page SET content=replace(content, 'Ñ', 'Ñ'); | |
| UPDATE cms_base_page SET content=replace(content, 'á', 'á'); | |
| UPDATE cms_base_page SET content=replace(content, 'é', 'é'); | |
| UPDATE cms_base_page SET content=replace(content, 'í', 'í'); |
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
| // Make sure you have this in a file invoked from the admin templating system | |
| grp.jQuery(function(){ | |
| grp.jQuery.fn.preventDoubleSubmission = function() { | |
| grp.jQuery(this).on('submit',function(e){ | |
| var the_form = grp.jQuery(this); | |
| if (the_form.data('submitted') === true) { | |
| // Previously submitted - don't submit again | |
| e.preventDefault(); | |
| } else { |