Skip to content

Instantly share code, notes, and snippets.

import mimetypes
import pprint
import requests # pip install requests
import simplejson as json
from os.path import basename, expanduser
base_url = 'https://alpha-api.app.net/stream/0'
token = 'USER ACCESS TOKEN'
image_path = 'PATH TO FILE'
@soundTricker
soundTricker / main.js
Created June 12, 2012 05:28
Google Apps 2 legged OAuth of Google Calendar API with Google Apps Script. Please import oauth.js and sha1.js from http://code.google.com/p/oauth/. if you happen any problem,Please modify oauth.js to below oauth.js code.
function twoleggedOAuth() {
var action = "https://www.google.com/calendar/feeds/default/private/full?xoauth_requestor_id={user mail address}";
var accessor = { consumerSecret: '{consumerSecret}' };
var message = { method: 'get', action: action, parameters: {}, };
OAuth.setParameter(message, 'oauth_version', '1.0');
OAuth.setParameter(message, 'oauth_nonce', OAuth.nonce(32));
OAuth.setParameter(message, 'oauth_timestamp', OAuth.timestamp());
OAuth.setParameter(message, 'oauth_consumer_key', '{your domain}');
OAuth.SignatureMethod.sign(message, accessor);
@soundTricker
soundTricker / calendar.js
Created April 26, 2012 02:10
google apps scriptで直接Google Calendar API(v2)を呼ぶ(Call Google Calendar API with Google Apps Script in direct)
function myFunction() {
//oauth の設定
var oauth = UrlFetchApp.addOAuthService(Session.getActiveUser().getEmail());
oauth.setConsumerKey("anonymous"); //ちゃんとしたのを使ったほうがいいとおもふ
oauth.setConsumerSecret("anonymous"); //ちゃんとしたのを使ったほうがいいとおもふ
oauth.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope=https%3A%2F%2Fwww.google.com%2Fcalendar%2Ffeeds%2F");
oauth.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken");
oauth.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");
@kirbysayshi
kirbysayshi / mass-aggregation-change.sh
Created November 23, 2011 17:14
quick examples of how to change many many wsp (graphite/whisper) files settings
for f in $(find $1 -iname "*.wsp"); do
if [ -a $f ];
then /opt/graphite/bin/whisper-set-aggregation-method.py $f max;
fi;
done