Skip to content

Instantly share code, notes, and snippets.

Benjamin Trott btrott

Block or report user

Report or block btrott

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@btrott
btrott / gist:764398
Created Jan 4, 2011
Prompt for OS X voice input
View gist:764398
#!/usr/bin/env python
from subprocess import call
while 1:
say = raw_input('say? ')
call(['say', say])
@btrott
btrott / list2str.pl
Created Nov 2, 2010
Perl implementations of the list2str functions at http://www.python.org/doc/essays/list2str.html.
View list2str.pl
#!/usr/bin/perl -w
use strict;
use Benchmark qw( timethese cmpthese );
use List::Util qw( reduce );
my $list = rand_chars( 256 );
cmpthese( shift || 1, {
f1 => sub { f1( $list ) },
View gist:444317
<!DOCTYPE html>
<html><head>
<meta charset="utf-8">
<title>Gallery</title>
</head><body>
<div id="gallery-widget"></div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
@btrott
btrott / gist:383106
Created Apr 29, 2010
Demo of Captcha::reCAPTCHA using Plack
View gist:383106
#!/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 Apr 29, 2010
Activity widget combining comments, favorites, and reblogs
View gist:383188
<!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; }
@btrott
btrott / gist:362805
Created Apr 11, 2010
Sample code for using WWW::TypePad::CmdLine
View gist:362805
#!/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:358553
Created Apr 7, 2010
Sample code for embedding TypePad blog posts in a page
View gist:358553
<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' );
View gist:350788
#!/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 );
View gist:349571
my $syntaxer = Snowflake->new( __FILE__, 'perl' );
print $syntaxer->colorize;
View gist:349856
GET /users/btrott.json
Host: api.typepad.com
You can’t perform that action at this time.