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
| ''' | |
| A quick and dirty redirect, preserving params and path info | |
| ''' | |
| # urls.py | |
| urlpatterns = patterns('', | |
| (r'', 'tce.views.redirect_req'), | |
| ) | |
| # views.py |
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
| num = range(1,101) | |
| for n in num: | |
| if n % 15 == 0: | |
| print 'FizzBuzz' | |
| elif n % 5 == 0: | |
| print 'Buzz' | |
| elif n % 3 == 0: | |
| print 'Fizz' | |
| else: |
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 remove_none_elements_from_list(list): | |
| return [e for e in list if e != None] |
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
| """ | |
| The problem is caused by the client terminating the call before the job is processed. To fix, add in the ThreadingMixIn as recommended here by Edward Samson (for a different, but related problem) here https://bitbucket.org/edu/woof/issue/1/errno-32-broken-pipe-upon-accessing-woof | |
| ---------------------------------------- | |
| Exception happened during processing of request from ('127.0.0.1', 41598) | |
| Traceback (most recent call last): | |
| File "/usr/lib/python2.7/SocketServer.py", line 284, in _handle_request_noblock | |
| self.process_request(request, client_address) | |
| File "/usr/lib/python2.7/SocketServer.py", line 310, in process_request | |
| self.finish_request(request, client_address) |
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
| # if your getting errors about DJANGO_SETTINGS_MODULE not being set make sure you have the following two variables set | |
| export PYTHONPATH=/some/path:/another/path:$PYTHONPATH | |
| export DJANGO_SETTINGS_MODULE=www.settings |
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
| """ | |
| Gets the name of the active Git branch as a string. | |
| Depends on GitPython | |
| pip install GitPython | |
| """ | |
| from git import Repo | |
| repo = Repo('/path/to/your/repo') | |
| branch = repo.active_branch |
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
| python -m smtpd -n -c DebuggingServer localhost:1025 | |
| # then add the following to your Django settings | |
| # EMAIL_HOST = 'localhost' | |
| # EMAIL_PORT = 1025 |
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 redis | |
| import time | |
| import sys | |
| def producer(): | |
| r = redis.Redis() | |
| i = 0 | |
| while True: | |
| r.rpush('queue', 'Message %d' % 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
| # add your rules | |
| /etc/iptables.rules | |
| # update the rules | |
| iptables-restore < /etc/iptables.rules |
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
| # see the queue | |
| rabbitmqctl list_queues |