Skip to content

Instantly share code, notes, and snippets.

View btrott's full-sized avatar

Benjamin Trott btrott

  • The Arena Group
  • San Francisco, CA
View GitHub Profile
sub get_best_avatar_uri {
my $class = shift;
my( $links ) = @_;
return unless $links && @$links;
# Look first for a 50px width avatar...
my $link = first { $_->{rel} eq 'avatar' && $_->{width} == 50 } @$links;
# ... and if we can't find one, grab the largest available avatar,
# which will by definition be less than 50px width, I think?
#!/usr/bin/perl -w
use strict;
use Plack::Builder;
use Plack::Request;
use Plack::Response;
use Text::MicroTemplate qw( render_mt );
use WWW::TypePad;
# These should be set to the Consumer Key and Consumer Secret
diff --git a/lib/WWW/TypePad.pm b/lib/WWW/TypePad.pm
index a9ca6a3..4433d7c 100644
--- a/lib/WWW/TypePad.pm
+++ b/lib/WWW/TypePad.pm
@@ -5,6 +5,9 @@ use 5.008_001;
our $VERSION = '0.009_01';
use Any::Moose;
+use Carp qw( croak );
+use HTTP::Request::Common;
my $syntaxer = Snowflake->new( __FILE__, 'perl' );
print $syntaxer->colorize;
GET /users/btrott.json
Host: api.typepad.com
#!/usr/bin/perl -w
use strict;
use IO::Prompt;
use Try::Tiny;
use WWW::TypePad;
use WWW::TypePad::CmdLine;
my $tp = WWW::TypePad::CmdLine->initialize( requires_auth => 1 );
@btrott
btrott / gist:358553
Created April 7, 2010 05:13
Sample code for embedding TypePad blog posts in a page
<ul id="blog-widget"></ul>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
var blogId = '6a00d83455876069e200d83455876369e2';
$( '#blog-widget' ).ready( function() {
$.getJSON(
'http://api.typepad.com/blogs/' + blogId + '/post-assets/@published/@recent.js?callback=?',
{ 'max-results': 5 },
function( data ) {
var ul = $( '#blog-widget' );
@btrott
btrott / gist:362805
Created April 11, 2010 15:14
Sample code for using WWW::TypePad::CmdLine
#!/usr/bin/perl -w
use strict;
use IO::Prompt;
use WWW::TypePad::CmdLine;
my $tp = WWW::TypePad::CmdLine->initialize( requires_auth => 1 );
# Fetch the list of the authenticated user's blogs, then put up a prompt
# asking the user to choose a blog.
@btrott
btrott / gist:383106
Created April 29, 2010 03:52
Demo of Captcha::reCAPTCHA using Plack
#!/usr/bin/perl
# Simple demonstration of Captcha::reCAPTCHA,
# using Plack and other simple & modern tools
# (port of examples/captcha.pl to Plack)
use strict;
use warnings;
use Captcha::reCAPTCHA;
use Data::Section::Simple qw( get_data_section );
@btrott
btrott / gist:383188
Created April 29, 2010 05:28
Activity widget combining comments, favorites, and reblogs
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Activity widget</title>
<style type="text/css">
body { font-family: Helvetica; font-size: 12px; }
#note-list li { list-style: none; margin-bottom: 5px; padding-bottom: 5px; border-bottom: 1px dotted #999; }
#note-list li span.avatar { padding-right: 10px; }