Skip to content

Instantly share code, notes, and snippets.

View mehdimehdi's full-sized avatar

Mehdi Ait Oufkir mehdimehdi

View GitHub Profile
$(document).ready(function(){
_ptq.push(["subscribe","1"]);
});
@mehdimehdi
mehdimehdi / gist:1259451
Created October 3, 2011 16:00
Comment for brian
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-comments" data-href="http://www.facebook.com/freedomofcreation?sk=app_152045414852131" data-num-posts="60" data-width="500"></div>
@mehdimehdi
mehdimehdi / gist:1263413
Created October 5, 2011 01:48
Show earning map only for for authenticated users
$(document).ready(function(){
var show_pt_earning_map = function() {
$('.pt_earning_map').show();
};
PT.events.bind("authenticated",show_pt_earning_map);
});
@mehdimehdi
mehdimehdi / gist:1263416
Created October 5, 2011 01:50
HTML element for the earning map
<img class="pt_earning_map" style="display:none;" src="https://static.punchtab.com/img/ribbon_earning_map.png"/>
@mehdimehdi
mehdimehdi / models.py
Created October 26, 2011 00:09
User query
class FoursquareUserToken(models.Model):
key = models.CharField(max_length=200,null=True)
secret = models.CharField(max_length=200)
status = models.CharField(max_length=10,default="ACT")
user = models.ForeignKey(User,null=True)
date_updated = models.DateTimeField(auto_now=True,null=True)
date_created = models.DateTimeField(auto_now_add=True)
def query(self):
@mehdimehdi
mehdimehdi / backends.py
Created October 26, 2011 00:17
Backend for authentication
class FacebookBackend:
def authenticate(self, token=None):
facebook_session,created = models.FacebookSession.objects.get_or_create(access_token=token,)
try:
profile = facebook_session.query('me')
except models.FacebookSessionError,e:
raise e
@mehdimehdi
mehdimehdi / views.py
Created October 26, 2011 00:18
logging the user in
auth = FacebookBackend()
user = auth.authenticate(token=token)
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=295556227126830";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-comments" data-href="https://www.facebook.com/freedomofcreation?sk=app_152045414852131/1836" data-num-posts="2" data-width="500"></div>
function hello(data) {
alert("hello");
}
var i=document.createElement("script");
i.src=unescape("http://127.0.0.1:8000/api/v1/user?token="+PT.token+"&key="+PT.options.key+"&callback=hello&r="+Math.random()*11);
i.async=true;
i.charset="UTF-8";
document.getElementsByTagName("head")[0].appendChild(i);
@mehdimehdi
mehdimehdi / gist:1346550
Created November 7, 2011 23:37
sales form backend
from django.core.mail import send_mail
def sales_form(request):
content = request.POST.get("content",None)
subject, from_email, to = 'subject', request.POST.get("from",None), ['sales@punchtab.com']
send_mail(subject, content, from_email, to)