This file contains 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
<html> | |
<head> | |
<script type="text/javascript" src="raphael-1.2.5.js"></script> | |
<script type="text/javascript" src="raphael.path.methods.js"></script> | |
<script type="text/javascript" src="raphael.primitives.js"></script> | |
<script type="text/javascript" src="g.raphael-0.4.js"></script> | |
<script type="text/javascript" src="g.analytics.js"></script> | |
<script type="text/javascript"> | |
$(function () { | |
$("#data").css({ |
This file contains 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 pyactiveresource.activeresource import ActiveResource | |
from pyactiveresource.connection import UnauthorizedAccess | |
#### CONFIGURATION #### | |
from_ip = 'xxx.xxx.xxx.xxx' | |
to_ip = 'xxx.xxx.xxx.xxx' | |
update_domains = ('domain1.com.','domain2.net.','otherdomain.org.') | |
api_key = 'xxxxx_YOUR_API_KEY_HERE_xxxxx' | |
api_url = 'https://%[email protected]/' % api_key |
This file contains 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 pyactiveresource.activeresource import ActiveResource | |
from biscuit.api import APIHandler | |
ip_translations = {'aaa.bbb.ccc.ddd': 'xxx.yyy.zzz.qqq', | |
'eee.fff.ggg.hhh': 'ppp.qqq.rrr.sss'} | |
slice_api_key = 'xxxxx_YOUR_SLICEHOST_API_KEY_HERE_xxxxx' | |
slice_api_url = 'https://%[email protected]/' % slice_api_key |
This file contains 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
"""This is just an example of how to provide permissions on a per-object basis in the admin""" | |
from django.contrib import admin | |
from django.contrib.auth.models import Permission | |
from django.contrib.contenttypes import generic | |
from django.contrib.contenttypes.models import ContentType | |
from account.models import ObjectGroupPermission, ObjectUserPermission | |
from myapp.models import MyModel | |
This file contains 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.contrib.sessions.backends.base import SessionBase, CreateError | |
from django.conf import settings | |
from django.utils.encoding import force_unicode | |
import redis | |
class SessionStore(SessionBase): | |
""" Redis store for sessions""" | |
def __init__(self, session_key=None): | |
self.redis = redis.Redis( |
This file contains 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 search_list(term, words, deep): | |
result = [] | |
idx = 0 | |
while idx < len(words): | |
try: | |
idx = words.index(term, idx) | |
result.append(idx) | |
idx += 1 # Start from the next element | |
if not deep: | |
break |
This file contains 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
""" | |
This is for a case where I was accessing the database connection/cursors directly, | |
and had need to mock up a result from a database call. The real trick here is | |
returning the cursor MagicMock object as a side effect of the initial patch. | |
""" | |
from unittest import mock | |
cursor = mock.MagicMock( |
This file contains 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 re | |
import time | |
from datetime import datetime, timedelta | |
import django_filters | |
from django.utils import timezone | |
from .lookups import Now | |
This file contains 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 messages %} | |
{% for message in messages %} | |
<div class="alert{% if message.tags %}{% if message.tags == "error" %} alert-danger{% else %} alert-{{ message.tags }}{% endif %}{% endif %}" role="alert"> | |
<button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
<span aria-hidden="true">×</span> | |
</button> | |
{{ message }} | |
</div> | |
{% endfor %} | |
{% endif %} |
This file contains 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 json | |
from django import template | |
from pygments import highlight | |
from pygments.formatters import HtmlFormatter | |
from pygments.lexers import get_lexer_by_name | |
register = template.Library() |
OlderNewer