Skip to content

Instantly share code, notes, and snippets.

<<class 'requests.cookies.RequestsCookieJar'>[<Cookie centralauth_Session=*** for .wikipedia.org/>, <Cookie centralauth_Token=*** for .wikipedia.org/>, <Cookie centralauth_User=Michaelhelmick for .wikipedia.org/>, <Cookie enwikiUserID=17018417 for en.wikipedia.org/>, <Cookie enwikiUserName=Michaelhelmick for en.wikipedia.org/>, <Cookie enwiki_session=*** for en.wikipedia.org/>]>
{'query': {'normalized': [{'to': 'Stone Cold Steve Austin', 'from': 'Stone_Cold_Steve_Austin'}], 'pages': {'356167': {'lastrevid': 498254288, 'pageid': 356167, 'title': 'Stone Cold Steve Austin', 'starttimestamp': '2012-06-18T23:45:37Z', 'counter': '', 'edittoken': '+\\', 'length': 98448, 'touched': '2012-06-18T23:07:58Z', 'ns': 0, 'revisions': [{'comment': "Reverted 2 edits by [[Special:Contributions/82.12.76.225|82.12.76.225]] ([[User talk:82.12.76.225|talk]]): Linked article on sister project doesn't exist. ([[WP:TW|TW]])", 'timestamp': '2012-06-18T23:07:58Z', 'user': 'Suriel1981', 'revid': 498254288, 'parentid': 498220891}]}}}}
{
"keys": ["shift+super+r"],
"command": "show_panel", "args": {"panel": "replace"}
}
params = {
'message': 'Hi dude.',
'source': open('filepath.jpg', 'rb')
}
files = {}
for k, v in params.items():
if isinstance(v, file):
files[k] = v
params.pop(k)
except (facebook.GraphAPIError, DrundWorkerError, urllib2.HTTPError), e:
error = 'Unable to retrieve feed.'
if isinstance(e, urllib2.HTTPError):
try:
fb_error = json.loads(e.read())
error = fb_error['error']['message']
if fb_error['error']['type'] == 'OAuthException':
error += ' Please unauthorize Facebook via Settings > Manage Applications and then authenticate again.'
except ValueError:
import requests
from requests.auth import OAuth1
url = 'https://upload.twitter.com/1/statuses/update_with_media.json'
auth = OAuth1(app_key, app_secret,
oauth_token, oauth_secret,
signature_type='auth_header')
data = {'status': 'Testing status with images'}
<span id=\"video_player_3411854767\">[<a href=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" target=\"_blank\">Flash 10</a> is required to watch video.]</span><script type=\"text/javascript\">renderVideo(\"video_player_3411854767\",'http://api.tumblr.com/video_file/3411854767/tumblr_lgxv3ghjVH1qfkzra',500,281,'poster=http%3A%2F%2Fmedia.tumblr.com%2Ftumblr_lgxv3ghjVH1qfkzra_r1_frame1.jpg,http%3A%2F%2Fmedia.tumblr.com%2Ftumblr_lgxv3ghjVH1qfkzra_r1_frame2.jpg,http%3A%2F%2Fmedia.tumblr.com%2Ftumblr_lgxv3ghjVH1qfkzra_r1_frame3.jpg,http%3A%2F%2Fmedia.tumblr.com%2Ftumblr_lgxv3ghjVH1qfkzra_r1_frame4.jpg,http%3A%2F%2Fmedia.tumblr.com%2Ftumblr_lgxv3ghjVH1qfkzra_r1_frame5.jpg')</script>
@michaelhelmick
michaelhelmick / fix.py
Created April 23, 2012 14:57
Fix SSL Error in urllib
import httplib
import ssl
import socket
import sys
import urllib2
class HTTPSConnectionV3(httplib.HTTPSConnection):
def __init__(self, *args, **kwargs):
httplib.HTTPSConnection.__init__(self, *args, **kwargs)
@michaelhelmick
michaelhelmick / check_ssl.py
Created April 16, 2012 19:21
Update SSL certs
import os.path
import ssl
import sys
import urlparse
import urllib
def check_ssl(hostname, port=443):
'''Check that an SSL certificate is valid
def get_authentication_tokens(self):
"""
get_auth_url(self)
Returns an authorization URL for a user to hit.
"""
callback_url = self.callback_url or 'oob'
request_args = {}
method = 'get'