Skip to content

Instantly share code, notes, and snippets.

View codingjester's full-sized avatar
🙊
Focusing

codingjester

🙊
Focusing
View GitHub Profile
@codingjester
codingjester / yaythreads.py
Created July 31, 2012 21:18
Python threading really fast
#!/usr/bin/env python
import threading
import Queue
import time
class Blarg(threading.Thread):
def run(self):
print time.time()
@codingjester
codingjester / gist:3343272
Created August 13, 2012 19:03
Sample Payload of API Key Authorized /posts Request
{
"meta":{
"status":200,
"msg":"OK"
},
"response":{
"blog":{
"title":"\/geek",
"posts":979,
"name":"codingjester",
@codingjester
codingjester / xauth_request.py
Last active May 14, 2020 23:40
Python xAuth Example
#!/usr/bin/env python
import urllib
import urlparse
import oauth2 as oauth
import json
consumer_key="consumer_key"
consumer_secret="consumer_secret"
access_token_url = 'https://www.tumblr.com/oauth/access_token'
@codingjester
codingjester / three_legged_oauth.py
Last active December 9, 2018 02:34
Tumblr 3 Legged OAuth using Python lib OAuth2
import urlparse
import oauth2 as oauth
consumer_key = 'consumer_key'
consumer_secret = 'consumer_secret'
request_token_url = 'https://www.tumblr.com/oauth/request_token'
access_token_url = 'https://www.tumblr.com/oauth/access_token'
authorize_url = 'https://www.tumblr.com/oauth/authorize'
@codingjester
codingjester / payload.json
Created November 9, 2012 21:13
Sample Blog Info Gist
{
"meta":{
"status":200,
"msg":"OK"
},
"response":{
"blog":{
"title":"\/geek",
"posts":1160,
"name":"codingjester",
@codingjester
codingjester / ajax_jsonp.js
Last active August 6, 2020 15:28
User JQuery with the Tumblr API & JSONP
$.ajax(
'http://api.tumblr.com/v2/blog/codingjester.tumblr.com/posts?api_key=<your_key>',
{
dataType: 'jsonp',
success: function (d) {
console.log(d); // On success log the data to the console
},
}
);
@codingjester
codingjester / curl.php
Created March 7, 2013 16:14
Extremely basic working PHP script for the /posts route
<?php
function get_posts($url, $params) {
$params = http_build_query($params);
$client = curl_init($url . "?" . $params);
curl_setopt($client, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($client, CURLOPT_FAILONERROR, 1);
try {
$content = curl_exec($client);
} catch (Exception $e) {
@codingjester
codingjester / file_cache.py
Last active December 15, 2015 05:19
Simple to disk filecache for python. Why? Because I needed it now.
import json
import stat
DEBUG = True
def debug_cache_data(fn):
def cache_data(*args):
if DEBUG and os.path.exists(fn.__name__):
return json.loads(open(fn.__name__, 'r').read())
else:
jQuery.getJSON(
'http://api.tumblr.com/v2/blog/codingjester.tumblr.com/posts?api_key=<api_key>&jsonp=?',
function(d) {
console.log(d);
});
@codingjester
codingjester / etrade.rb
Created August 28, 2013 13:55
Scraping the totalMarketValue of your E*Trade account. Probably could be better. You pass in your username/password as arguments to the script.
require 'mechanize'
a = Mechanize.new
a.get('https://us.etrade.com/home') do |page|
mypage = page.form_with(:action => '/login.fcc') do |f|
f.USER = ARGV[0]
f.PASSWORD = ARGV[1]
end.click_button