Skip to content

Instantly share code, notes, and snippets.

View venkatesh22's full-sized avatar

Venkatesh venkatesh22

View GitHub Profile
==== SNIP ====
class DistanceSerializer(serializers.Serializer):
km = serializers.FloatField()
m = serializers.FloatField()
mi = serializers.FloatField()
ft = serializers.FloatField()
class SearchResultSerializer(serializers.Serializer):
class MultiFormMixin(ContextMixin):
form_classes = {}
prefixes = {}
success_urls = {}
initial = {}
prefix = None
success_url = None
# API authentication
from social.apps.django_app.utils import strategy
from rest_framework.authtoken.models import Token
from rest_framework.views import APIView
from rest_framework import parsers
from rest_framework import renderers
from rest_framework.authentication import get_authorization_header
from rest_framework.response import Response
from PIL import Image
from django.conf import settings
import S3, mimetypes
THUMBNAIL_SIZE = 70, 70
MEDIUM_SIZE = 150, 150
profile_image_path = settings.MEDIA_ROOT + '/images/roles/'
AWS_ACCESS_KEY_ID = 'YOUR_AWS_KEY'
AWS_SECRET_ACCESS_KEY = 'YOUR_AWS_SECRET'
from django.core.files.uploadhandler import TemporaryFileUploadHandler
from django.core.files.base import File
from dropbox.client import DropboxClient
from dropbox.session import DropboxSession
from django.conf import settings
import os
class DropboxFileUploadHandler(TemporaryFileUploadHandler):
def __init__(self, *args, **kwargs):
super(DropboxFileUploadHandler, self).__init__(*args, **kwargs)
from django.db.models import signals
from haystack.indexes import RealTimeSearchIndex
class ManyAwareRealTimeSearchIndex(RealTimeSearchIndex):
"""Many-to-many aware real-time search index base class
"""
def _on_m2m_changed(self, instance, using=None, **kwargs):

PROPFIND https://caldav.calendar.yahoo.com/

<?xml version="1.0" encoding="UTF-8" ?>

<DAV:multistatus xmlns:AI="http://apple.com/ns/ical/"
              xmlns:CS="http://calendarserver.org/ns/"
              xmlns:DAV="DAV:"
              xmlns="urn:ietf:params:xml:ns:caldav"
              xmlns:ical="http://www.w3.org/2002/12/cal/ical#">
#!/usr/bin/python
A = [1, 8, -3, 0, 1, 3, -2, 4, 5]
def solution(K, A):
contenga = {}
for x in A:
if x not in contenga:
contenga[x] = 0
contenga[x] += 1
@venkatesh22
venkatesh22 / index.html
Last active August 29, 2015 14:10 — forked from elsewhat/index.html
<html>
<head>
<title></title>
<script type="text/javascript" charset="utf-8" src="phonegap/cordova-1.6.0.js"></script>
<script id="sap-ui-bootstrap"
type="text/javascript"
src="sapui5/resources/sap-ui-core.js"
data-sap-ui-theme="sap_platinum"
smtp mail sending in cPython blocks the GIL.
This code is tested on python 2.7.8 and I'm using it with web2py
If you use Google Apps for your domain email and if you have admin access, you can easily use the gmail api.
Because you have admin access, you can create a "service account" in the Google Developer Console.
This makes authentication easy.
There are other authorisation methods when you don't have admin access, but they require interaction from the user via a browser.
To use this, you need to install these modules (From PyPI):
pyOpenSSL