Skip to content

Instantly share code, notes, and snippets.

View pyokagan's full-sized avatar

Paul Tan pyokagan

View GitHub Profile
@pyokagan
pyokagan / youtube-plvids.sh
Created October 19, 2012 08:46
Prints URL of all videos in Youtube Playlist. Requires: curl, jshon
#! /bin/bash
if [ -z $1 ]; then
echo "usage: $0 URL" >&2
exit 1
fi
playlistid="$(sed -n 's|https://www\.youtube.com/playlist?list=PL\([A-Z0-9]*\)|\1|p' <<< $1)"
if [ -z "$playlistid" ]; then
echo "Invalid URL" >&2
exit 1
@pyokagan
pyokagan / sshinotifytransfer
Created October 7, 2012 07:06
sshinotifytransfer - Transfers files in one direction
#! /bin/bash
#Transfers files in one direction
usage="$0 remote dest"
if [[ !( -n $1 ) || !( -n $2 ) ]]; then
echo $usage >&2
exit 2
fi
@pyokagan
pyokagan / Island5.vb
Created June 27, 2012 07:08
Bouncy Boar 3 Island Object
Imports BouncyBoar3
Namespace MyGame
Namespace Nodes
''' <summary>
'''
''' </summary>
''' <remarks>
@pyokagan
pyokagan / multiprocessing_fail
Created June 10, 2012 03:13
Pickling in multiprocessing causing bug
---------------------------------------------------------------------------
PicklingError Traceback (most recent call last)
C:\Users\pyokagan\<ipython-input-5-846925efa119> in <module>()
9 #Wrap all Client Credentials!
10 cwrap.wrap_authorization_server_database(context.authorization_servers, client_db)
---> 11 args.func(args)
C:\Users\pyokagan\<ipython-input-2-7bd01ceccacc> in authcode(args)
19 redirect_uri = args.redirect_uri
@pyokagan
pyokagan / gist:2891064
Created June 7, 2012 19:32
tl;dr of usage of pykoauth2
#Add client credentials
pykoauth2 addclient facebook.com CLIENT_ID CLIENT_SECRET
#Make authorization request (starts web server at http://localhost:8080 and prints URL. Point your web browser to this URL)
pykoauth2 authcode facebook.com
#Get access token
pykoauth2 token --server_fqdn facebook.com
#Make authenticated request
pykoauth2curl --data-urlencode 'message=Hello world from pykoauth2!' \
'https://graph.facebook.com/me/feed'
@pyokagan
pyokagan / youtube-sh
Created May 1, 2012 13:24
Prints list of videos in season of Youtube Show. Requires Python 3 for parsing URLs. Requires jshon for parsing JSON. Now, why didn't I write this whole thing in Python in the first place :(
#! /bin/sh
if [ -z "$1" -o -z "$2" ]; then
echo "Usage: $0 URL SEASON" >&2
exit 1
fi
SHOW_ID=`python3 -c 'from urllib.parse import urlparse, parse_qs;from sys import argv;print(parse_qs(urlparse(argv[1]).query)["p"][0])' "$1"`
SHOW_URL="http://gdata.youtube.com/feeds/api/shows/$SHOW_ID/content?v=2&alt=json"
SEASON="$2"