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 hashlib | |
import hmac | |
def bazaar_voice_token(encoding_key, parameters): | |
secret = bytes(encoding_key, 'utf-8') | |
message = bytes(parameters, 'utf-8') | |
hash = hmac.new(secret, message, hashlib.sha256) | |
return hash.hexdigest() + message.hex() |
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
#!/usr/bin/env ruby | |
require 'net/http' | |
require 'net/smtp' | |
require 'logger' | |
# Set up logging | |
file = File.open('/path/to/the/logs/http_response.log', File::WRONLY | File::APPEND) | |
log = Logger.new(file) | |
message = <<EOF |
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 link_tweet(tweet): | |
""" | |
This method takes the text attribute from a tweet object and returns it with | |
user_mentions and hashtags linked | |
""" | |
tweet = re.sub(r'(\A|\s)@(\w+)', r'\1@<a href="http://www.twitter.com/\2">\2</a>', str(tweet)) | |
return re.sub(r'(\A|\s)#(\w+)', r'\1#<a href="http://search.twitter.com/search?q=%23\2">\2</a>', str(tweet)) |
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 locale | |
from django.template import Library | |
register = Library() | |
@register.filter(name='currency') | |
def currency(value): | |
try: |
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.auth.models import User | |
from django.contrib.auth.backends import ModelBackend | |
class FoursquareBackend(ModelBackend): | |
def authenticate(self, username=None, password=None): | |
try: | |
user = User.objects.get(username=username) | |
return user | |
except User.DoesNotExist: |
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
''' | |
Copyright 2013 Pontiflex, Inc. | |
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at: | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | |
''' |