Skip to content

Instantly share code, notes, and snippets.

View maxcountryman's full-sized avatar
🦀

Max Countryman maxcountryman

🦀
View GitHub Profile
from rauth.service import OAuth2Service
import re
import webbrowser
# Get a real consumer key & secret from:
# https://developers.facebook.com/apps
facebook = OAuth2Service(
client_id='440483442642551',
# -*- coding: utf-8 -*-
'''
rauth.test_service
------------------
Test suite for rauth.service.
'''
from datetime import datetime
# -*- coding: utf-8 -*-
'''
rauth.test_service
------------------
Test suite for rauth.service.
'''
from base import RauthTestCase
@maxcountryman
maxcountryman / closures.py
Last active December 14, 2015 05:29
Some notes on closures in Python.
>>> foo = []
>>> for i in range(10):
... foo.append(lambda: i)
>>> bar = []
>>> for i in range(10):
... # `bar.append(lambda j=i: j)` may be easier to see
... bar.append(lambda i=i: i)
(defn get-access-token
"Retrieves an access token."
[this & [req]]
(let [client-creds {:client_id (:client-id this)
:client_secret (:client-secret this)}
url (:access-token-url this)
method (or (:method req) "POST") ;; default to "POST"
is-entity-method (in? method entity-methods)
req (merge req (if is-entity-method
{:form-params client-creds}
@maxcountryman
maxcountryman / bar.clj
Last active December 15, 2015 08:08
Assume these files live in a dir `testing`.
(ns testing.bar (:require [baz :refer :all]))
;; should expose the same function as foo, i.e. qux
import foo
foo.qux("test")
@maxcountryman
maxcountryman / reddit.py
Created March 29, 2013 07:11
Reddit OAuth via Python with rauth.
from rauth import OAuth2Service
from hashlib import sha1
from random import random
import re
import json
import webbrowser
# Get a real client id and secret from:
@maxcountryman
maxcountryman / twitter-timeline-cli-py3.py
Created March 30, 2013 15:14
Tweaks to get rauth's Twitter example running on Python 3.
from rauth import OAuth1Service
try:
read_input = raw_input
except NameError:
read_input = input
# Get a real consumer key & secret from https://dev.twitter.com/apps/new
twitter = OAuth1Service(
name='twitter',
@maxcountryman
maxcountryman / facebook-cli-py3.py
Created March 30, 2013 15:21
Tweaks to get rauth's Facebook example working with Python 3.
from rauth import OAuth2Service
import re
import webbrowser
try:
read_input = raw_input
except NameError:
read_input = input