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 | |
from django.conf import settings | |
class EmailVerificationTokenGenerator(object): | |
""" | |
Strategy object used to generate and check tokens for the email | |
verification mechanism. | |
""" |
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 push_notifications.models import GCMDevice | |
device = GCMDevice.objects.get(registration_id='...') | |
device.send_message('This is a message', extra={"title": "This is a title"}) |
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.core.mail import EmailMessage | |
msg = EmailMessage(to=['[email protected]', ]) | |
msg.template_name = 'template' | |
msg.global_merge_vars = { | |
'var1': 'value1', | |
'var2': 'value2', | |
} |
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 SomeViewSet(mixins.UpdateModelMixin, viewsets.GenericViewSet): | |
def update(self, request, *args, **kwargs): | |
if request.data: | |
request._full_data = request._full_data.copy() | |
request._full_data['some key'] = 'some new value' | |
return super(SomeViewSet, self).update(request, *args, **kwargs) |
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 Trie(object): | |
""" | |
Trie with End marker | |
""" | |
END = '_end_' | |
current = dict() | |
def add(self, word): | |
""" | |
Adds a word to Trie |
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 FenwickTreeMax(object): | |
""" | |
Fenwick Tree for Max | |
""" | |
def __init__(self, nums): | |
""" | |
Initialize tree | |
""" | |
self.n = len(nums) | |
self.left = [0] * (self.n + 1) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer