Skip to content

Instantly share code, notes, and snippets.

View jcleblanc's full-sized avatar

Jonathan LeBlanc jcleblanc

View GitHub Profile
@jcleblanc
jcleblanc / index.py
Created April 2, 2012 15:48
PayPal Access OAuth 2 Python Sample: Main File
import cgi
import urllib
import urllib2
import json
#client OAuth keys
key = 'YOUR KEY HERE'
secret = 'YOUR SECRET HERE'
#PayPal URIs and application callbacks
@jcleblanc
jcleblanc / app.yaml
Created April 2, 2012 15:46
PayPal Access OAuth 2 Python Sample: yaml Config File
application: oauth2-paypal
version: 1
runtime: python
api_version: 1
handlers:
- url: /.*
script: index.py
@jcleblanc
jcleblanc / pin.js
Created February 22, 2012 03:54
pin js
(function () {
function m() {
return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)
}
function w() {
return /Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent)
}
function x() {
return navigator.userAgent.match(/iPad/i) != null || navigator.userAgent.match(/iPhone/i) != null || navigator.userAgent.match(/iPod/i) != null
}
@jcleblanc
jcleblanc / complete.php
Created February 7, 2012 18:15
complete file for PP Access OAuth 2 sample
<?php
require_once "common.php";
//capture code from auth
$code = $_GET["code"];
//construct POST object for access token fetch request
$postvals = sprintf("client_id=%s&client_secret=%s&grant_type=authorization_code&code=%s&redirect_uri=%s", KEY, SECRET, $code, urlencode(CALLBACK_URL));
//get JSON access token object (with refresh_token parameter)
@jcleblanc
jcleblanc / common.php
Created February 7, 2012 18:15
common file for PP Access OAuth 2 sample
<?php
define('KEY', 'YOUR APPLICATION ID');
define('SECRET', 'YOUR APPLICATION SECRET');
define('CALLBACK_URL', 'YOUR CALLBACK PATH - TO COMPLETE.PHP');
define('AUTHORIZATION_ENDPOINT', 'https://identity.x.com/xidentity/resources/authorize');
define('ACCESS_TOKEN_ENDPOINT', 'https://identity.x.com/xidentity/oauthtokenservice');
define('PROFILE_ENDPOINT', 'https://identity.x.com/xidentity/resources/profile/me');
/***************************************************************************
@jcleblanc
jcleblanc / index.php
Created February 7, 2012 18:14
index file for PP Access OAuth 2 sample
<?php
require_once "common.php";
$auth_url = sprintf("%s?scope=%s&response_type=code&redirect_uri=%s&client_id=%s",
AUTHORIZATION_ENDPOINT,
urlencode("https://identity.x.com/xidentity/resources/profile/me"),
urlencode(CALLBACK_URL),
KEY);
//forward user to PayPal auth page
@jcleblanc
jcleblanc / htaccess
Created December 14, 2011 19:56 — forked from dave1010/htaccess
HTTP Status Cats Apache (htaccess) config
# HTTP Status Cats
# Apache (htaccess) config created by @dave1010
# Licensed CC BY 2.0
# Images CC BY 2.0, from GirlieMac's photostream:
# http://www.flickr.com/photos/girliemac/sets/72157628409467125/with/6508023065/
# Usage: copy save this file as .htaccess or add it to your httpd.conf
ErrorDocument 404 '<a href="http://www.flickr.com/photos/girliemac/6508022985/" title="404 - Not Found by GirlieMac, on Flickr"><img src="http://farm8.staticflickr.com/7172/6508022985_b22200ced0.jpg" width="500" height="400" alt="404 - Not Found"></a>'
@jcleblanc
jcleblanc / reddit_php_sdk_sample.php
Created December 11, 2011 20:01
Reddit PHP SDK Sample to Submit New Story
<?php
require_once("reddit.php");
//initialize logged-in connection
$reddit = new reddit("USERNAME", "PASSWORD");
//submit new story
$title = "British coffee-powered car breaks world record";
$link = "http://www.extremetech.com/extreme/97287-british-coffee-powered-car-breaks-world-record";
$response = $reddit->createStory($title, $link);
@jcleblanc
jcleblanc / DropDownHandler.java
Created December 7, 2011 18:25
Sample Eclipse Plugin: DropDownHandler.java file
package com.x.sampleplugin.handlers;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.jface.dialogs.MessageDialog;
/**
@jcleblanc
jcleblanc / plugin_commands.xml
Created December 6, 2011 21:56
plugin.xml file: Commands
<!-- Toolbar Dropdown Menu -->
<extension point="org.eclipse.ui.commands">
<category id="com.x.sampleplugin.dropdown.category" name="Sample Plugin DropDown"></category>
<command categoryId="com.x.sampleplugin.dropdown.category" id="com.x.sampleplugin.dropdown.command" name="DropDown">
<commandParameter id="com.x.sampleplugin.dropdown.msg" name="DropDown Options" optional="true"></commandParameter>
</command>
<command categoryId="com.x.sampleplugin.dropdown.category" id="com.x.sampleplugin.dropdown.commandProfile" name="Profile">
<commandParameter id="com.x.sampleplugin.dropdown.msg" name="DropDown Options" optional="true"></commandParameter>
</command>
<command categoryId="com.x.sampleplugin.dropdown.category" id="com.x.sampleplugin.dropdown.commandLoadSite" name="LoadSite">