Skip to content

Instantly share code, notes, and snippets.

@jorilallo
jorilallo / gist:3686737
Created September 9, 2012 19:33
Google Contacts API authentication with gdata and OAuth2
import gdata
import json
import requests
# More examples:
# https://github.com/millioner/Python-contact-importer/blob/master/contact_importer/providers/google.py
# https://github.com/jtauber/django-friends/blob/master/friends/importer.py
# GData with access token
token = gdata.gauth.OAuth2Token(
@jorilallo
jorilallo / twitter.com.js
Created February 25, 2012 04:03
Twitter.com sans useless UI fluff (dot.js script)
setInterval(function(){
// Hide "#Discover" from the topnav
$("#global-actions").find("[data-global-action='discover']").hide();
// Inverse timeline column (tweets left, other things right)
$(".dashboard").css("float", "right");
$(".content-main").css("float", "left");
$(".module .chev-right").hide(); // Small arrows to right
// Removed wrapper background (could use detailed styling)
$(".wrapper").css("background", "none");
@jorilallo
jorilallo / note_create
Created February 10, 2012 19:11
Samples from Pivotal Tracker's webhook
<?xml version="1.0" encoding="UTF-8"?>
<activity>
<id type="integer">160540935</id>
<version type="integer">276</version>
<event_type>note_create</event_type>
<occurred_at type="datetime">2012/02/10 18:35:54 UTC</occurred_at>
<author>Jori Lallo</author>
<project_id type="integer">76939</project_id>
<description>Jori Lallo added comment: &quot;Woot&quot;</description>
<stories type="array">
class Service::Grove < Service
string :channel_token
def receive_push
raise_config_error "Missing channel token" if data['channel_token'].to_s.empty?
token = data['channel_token'].to_s
res = http_post "https://grove.io/api/services/github/#{token}",
:payload => JSON.generate(payload)
@jorilallo
jorilallo / gist:1775440
Created February 8, 2012 23:35
BitBucket
import urllib
from brokers import BaseBroker
from django.utils import simplejson as sj
class URLOpener(urllib.FancyURLopener):
version = 'bitbucket.org'
class Post(BaseBroker):
def handle(self, payload):
api_key = payload['service']['channel_token']
app grovebot
git_log * Jori Lallo: chjange
head e8ba042
head_long e8ba0429637eeb89a3df5b822192207bb49a6371
prev_head deb9f72
url http://grovebot.herokuapp.com
user [email protected]
@jorilallo
jorilallo / json-response.py
Created February 2, 2012 02:20 — forked from leah/json-response.py
JSONResponse classes
import re
import simplejson
from django.http import HttpResponse
from django.conf import settings
class JSONResponse(HttpResponse):
def __init__(self, request, data):
indent = 2 if settings.DEBUG else None
@jorilallo
jorilallo / gist:1701845
Created January 30, 2012 01:38
Tastypie paginated search for Haystack
from django.conf.urls.defaults import *
from tastypie.paginator import Paginator
from tastypie.exceptions import BadRequest
from tastypie.resources import ModelResource
from tastypie.utils import trailing_slash
from haystack.query import SearchQuerySet, EmptySearchQuerySet
from clips.models import Clip
@jorilallo
jorilallo / gist:1577837
Created January 8, 2012 09:28
Hook to desktop notifications
document.getElementById('groveNotificationEventDiv').addEventListener('groveNotificationEvent', function() {
var eventData = document.getElementById('groveNotificationEventDiv').innerText;
console.log(JSON.parse(eventData)); // Show data for notifications
// Do notification here
});
@jorilallo
jorilallo / grove.io.js
Created January 7, 2012 11:36
GitHub'fy Grove.io with dot.js
/*
** GitHub'fy Grove.io with dot.js
**
** source: http://github.github.com/github-flavored-markdown/scripts/showdown.js
** dotjs: http://defunkt.io/dotjs/
*/
var repo = 'Organization/repo';
setInterval(function(){