Skip to content

Instantly share code, notes, and snippets.

View matclayton's full-sized avatar
🚀
Focusing

Mat Clayton matclayton

🚀
Focusing
View GitHub Profile
0xF63Eb5d5F60eB66Da323516a7EfF40d8d389400c
@matclayton
matclayton / gist:1609009
Created January 13, 2012 22:11
Simple Facebook Open Graph App
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# climbingapp: http://ogp.me/ns/fb/climbingapp#">
<!-- Open Graph Meta tags -->
<meta property="og:type" content="climbingapp:mountain" />
<meta property="og:url" content="http://example.com/" />
<meta property="og:title" content="Snowdon" />
<meta property="og:description" content="Snowdon is the highest mountain in Wales" />
<meta property="og:image" content="http://farm8.staticflickr.com/7172/6622506511_3f6a78e781_z.jpg" />
<meta property="og:locale" content="en_GB" />
@matclayton
matclayton / FB check
Created October 22, 2011 16:18
Is Facebook Connect for me?
<div id=”fb-root”></div>
<script>
window.fbAsyncInit = function(){
FB.init({ appId:‘YOUR ID’, status:true, cookie:true, xfbml:true});
FB.getLoginStatus(function(response){
_gaq.push([‘_trackEvent’, ’FB’, ‘status’, response.status]);
});
};
// Load the SDK Asynchronously
(function(d){
@matclayton
matclayton / FB Like
Created May 17, 2011 04:11
Tracking FB social actions
<div id="fb-root"></div>
<script>
(function() {
window.fbAsyncInit = function() {
FB.Event.subscribe('edge.create', function(response) {
_gaq.push(['_trackSocial', 'facebook', 'like', response]);
});
FB.Event.subscribe('edge.remove', function(response) {
_gaq.push(['_trackSocial', 'facebook', 'unlike', response]);
});
from datetime import datetime, timedelta
from dateutil.parser import parse as iso8601
from celery.task.base import Task
from celery.utils import timedelta_seconds
class ExpireTask(Task):
"""Task with an expiration time.
"""
Thread-safe Django cache backend for pylibmc.
Tested on Python 2.6, should work on 2.5 as well.
Use it by setting CACHE_BACKEND in settings.py, e.g.:
CACHE_BACKEND = 'projdir.utils.pylibmcd://127.0.0.1:11211/'
"""
from __future__ import with_statement
from django.core.cache.backends.base import BaseCache, InvalidCacheBackendError
"libMemcached cache backend"
from django.core.cache.backends.base import (BaseCache,
InvalidCacheBackendError)
from django.utils.encoding import smart_unicode, smart_str
try:
import pylibmc as memcache
is_pylibmc = True
except ImportError: