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
| from celery import celery | |
| @celery.task | |
| def fetch(): | |
| """ | |
| Download files from FTP server | |
| This tasks could be trigger by a cronjob to start the processing pipeline. | |
| When file(s) downloaded successfully, create a set of partner_prepare jobs |
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
| class Notification(models.Model): | |
| sender = models.ForeignKey('auth.User', null=True) | |
| recipient = models.ForeignKey('auth.User', related_name='notifications') | |
| subject = models.CharField(max_length=255) | |
| body = models.TextField() | |
| # Some projects may want to categorise their notifications. You may want | |
| # to use this field to show a different icons next to the notification. | |
| category = models.CharField(max_length=255, null=True) |
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
| class Notification(models.Model): | |
| recipient = models.ForeignKey('auth.User', related_name='notifications') | |
| # HTML is allowed in this field as it can contain links | |
| text = models.CharField(max_length=255) | |
| # Some projects may want to categorise their notifications. You may want | |
| # to use this field to show a different icons next to the notification. | |
| category = models.CharField(max_length=255, null=True) |
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
| from django.db import models | |
| from django.utils.translation import ugettext_lazy as _ | |
| class WeekdayOpeningPeriod(models.Model): | |
| store = models.ForeignKey('stores.Store', related_name='opening_periods') | |
| SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY = range(7) | |
| weekday_choices = ( |
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
| from django.db import models | |
| class Ledger(models.Model): | |
| # There can only be one 'Labour' and 'Shop' ledger but lots of 'Budget' | |
| # ledgers. | |
| LABOUR, BUDGET, SHOP = 'Labour', 'Budget', 'Shop' | |
| LEDGER_CHOICES = ( | |
| (LABOUR, LABOUR), | |
| (BUDGET, BUDGET), |
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 re | |
| from xml.dom.minidom import parseString | |
| def format_xml(xml_str): | |
| xml_str = re.sub(r'\s*\n\s*', '', xml_str) | |
| ugly = parseString(xml_str).toprettyxml(indent=' ') | |
| regex = re.compile(r'>\n\s+([^<>\s].*?)\n\s+</', re.DOTALL) |
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
| Front Side: | |
| Oscar - Bad-ass e-commerce for ninjas | |
| Back side: | |
| Oscar is a new e-commerce framework for generating electric synergy between your development rockstars and your marketing weasels | |
| Features? No features, just endless possibilities: | |
| * A fully recursive stack-driven, reverse-proxying domain generator | |
| * Strict adherance to sandwich-driven development |
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 random | |
| import time | |
| def pick_winners(candidates, num_winners): | |
| for i in range(num_winners): | |
| time.sleep(1) | |
| winner = random.choice(candidates) | |
| print "Winner %d: %s" % (i+1, winner) | |
| candidates.remove(winner) | |
| print "\nSorry %s\n" % ", ".join(candidates) |
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 requests | |
| from someurllib import URL | |
| # 1. Build request URL | |
| url = URL(host='maps.google.com') | |
| url.path('/geocoding/xml/') | |
| .param('q', 'Some address string') | |
| .param('sensor', 'False') | |
| .fragment('something') |
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
| # Hacky script for downloading videos from PyVideo and converting them to m4v | |
| # format so they can be synced onto your apple device. Useful if you | |
| # want to see everything that happened at PyCon while commuting. | |
| # | |
| # Requirements: | |
| # * pip install requests BeautifulSoup | |
| # * youtube-dl (from https://github.com/rg3/youtube-dl/) - add this to the | |
| # directory where this script runs and ensure its execute bit is set. | |
| # This was the only YouTube downloader I found that worked. It doesn't | |
| # really have a good Python API so I call it through os.system. |