Skip to content

Instantly share code, notes, and snippets.

@michaelhelmick
michaelhelmick / gist:1630068
Created January 18, 2012 00:47
Linkedin Update Status params
{'comment':'testing Python-Linkedin',
'share':{'visibility':
{'code':'anyone'}
}
}
@michaelhelmick
michaelhelmick / grab_ya_tweets.py
Created February 21, 2012 01:45
Scan your Twitter timeline for all of your tweets
#!/usr/bin/env python
'''
This script originated at http://pastebin.com/zK3ZYaS8
I've modified it... just a `little` bit. ;P
I only reached to page 161 and Twitter stopped giving me
tweets. :( Let me know if you get further!
- Mike Helmick
<!doctype html>
<head>
</head>
<body>
</body>
</html>
def get_profile(self):
"""
Returns site-specific profile for this user. Raises
SiteProfileNotAvailable if this site does not allow profiles.
"""
if not hasattr(self, '_profile_cache'):
from django.conf import settings
if not getattr(settings, 'AUTH_PROFILE_MODULE', False):
raise SiteProfileNotAvailable('You need to set AUTH_PROFILE_MO'
#requests-oauth header produces:
{
'Authorization': 'OAuth realm="", oauth_nonce="50997118", oauth_timestamp="1331135338", oauth_consumer_key="********", oauth_signature_method="HMAC-SHA1", oauth_version="1.0", oauth_token="********", oauth_signature="IT1qsDRpc0wHXxo0q9IscLSpGaU%3D"'
}
#faux_req.to_header() produces:
{
'Authorization': u 'OAuth realm="", oauth_body_hash="2jmj7l5rSw0yVb%2FvlWAYkK%2FYBwk%3D", oauth_nonce="74348031731097571737250753271922149182231", oauth_timestamp="1331078125", oauth_consumer_key="********", oauth_signature_method="HMAC-SHA1", oauth_version="1.0", oauth_token="********", oauth_signature="jv7TI4Xg3VK3x0IqrpRpL1u10z0%3D"'
}
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'
@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
@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)
<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>
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'}