About Kent Cowgill
Articles filed under...
abs ab_ripper andylester arms back baggyshorts bestpractices bike blog bugs bus calculator cardio catalyst cgi chart chest chinups code cpan datamodel dbi doctor documentation exercise exhaustion fitness flattire flat_tire google gps heart_rate helmet history houston html humor journal kate kenpo_x kettlebell knees lazy legs lisa lisanne maps math matthew michaelmckenna mom montreal motivation movie mysql oops orm P90X pain park patellar_tendonitis patrick perl phb photos physical_therapy plyometrics poor_gait presentation procrastination pullups pushups pyramid rabbits racecondition rant refactor rest ribs ride route running shoulders situps slides sore spike sql statistics syntax test testing textile timex training triceps ups versioncontrol video vim vimrc walk warren work workouts yapc yapcna2007 yoga youtube

A R C H I V E S

(5)
(15)
(16)
(25)
(3)
(4)
(2)
(4)
(11)
(1)
(1)
(3)
(2)
(2)
(10)
(5)
(2)
(3)
(4)
(9)
(21)
(3)
(3)
(1)
(6)
(4)
(1)
(4)
(3)
(2)
(1)

    Is Kent Cowgill Online?
    View Kent Cowgill's profile on LinkedIn
    Add to Technorati Favorites

    Recent Entries...

    On track so far...

    The week is about half way over, and so far I haven't skippe...

    My pants are on fire!

    I lied. Friday evening I didn't do anything. Saturday ...

    Playing catch-up

    It's been a while since I've updated my P90X progress. A ...

    Re: Yoga kicks my butt

    You should try a different yoga mat. I highly recommend the...

    Yoga kicks my butt

    It's time for a confession. I haven't done an entire Yoga...

    Recovery week comes in the nick of time

    Since it's been a few days, and I know I've rearranged my in...

    Early to Bed, Early to Rise

    So I'm not exceptionally healthier, wealthier, or wiser. Bu...

    Chest and Back, week 3

    Sure, the date that's listed for this post is 10/28, but it'...

    No Procrastination, Some Pain, Some Gain

    After much cajoling and self-flagellation, I convinced mysel...

    Odd Math

    I must be counting something wrong. Granted, I haven't be...

    weblog | `web·lôg -läg |
    noun
    Another term for BLOG
    ORIGIN 1990s: from web in the sense [World Wide Web] and log in the sense [regular record of incidents.]
    blog | bläg |
    noun
    A web site on which an individual or group of users produces an ongoing narrative.
    ORIGIN a shortening of WEBLOG.

    Easy way to copy code to Keynote

    Kent Cowgill

    So I'm working on a new presentation for my local Perl Mongers group, and (indirectly) thanks to Ricardo Signes, I've got a cool way to get properly syntax colored code into my slides.

    Ricardo has been working on an easy way to get syntax colored code into Keynote presentations. I wondered why he was bothering to convert the syntax colored code to RTF - then I realized why - I think because TextEdit.app on Mac OSX is a cocoa application, the font coloring is preserved through copying and pasting the code into Keynote, another cocoa application.

    A little later on, I was creating some other presentation, and was copying some code out of my blog and happened to notice that the code I copied and pasted from Safari, my web browser, also retained its coloring information.

    Problem solved, right? Anything I want to put into a Keynote slide, I should blog about first. Right?

    Wrong.

    That's too much blogging.

    Instead, I wrote a teeny tiny little CGI to post up the syntax colored source of anything sitting around on my server, using the same Text::VimColor module on the backend.

    This is that CGI:

    
    #!/usr/bin/perl -T
    
    use strict;
    use warnings;
    use Text::VimColor;
    use CGI qw/:standard/;
    use CGI::Carp qw/fatalsToBrowser/;
    
    $ENV{'PATH'} = '/bin';
    
    my $file = param('f') || 'photos/photoblog';
    my $lang = param('l') || 'perl';
    
    die "Bad file" if $file =~ /^[^a-z]/i;
    die "Bad file" if $file =~ /[^a-z\/._-]/i;
    die "Bad file" unless -f $file;
    
    die "Bad type" unless $lang =~ /(?:perl|php|xml)/;
    
    open my $in, '<', $file;
    my $text = do { local $/; <$in> };
    
    my $vim = Text::VimColor->new(
      string      => $text,
      filetype    => $lang,
      vim_options
        => [qw(-RXZ -i NONE -u NONE -N -T xterm)],
      vim_command => '/usr/local/bin/vim',
    )->html;
    
    
    

    ... and then a little HTML to display it in the right font, font size, and using my standard code stylesheet - which is left as an exercise for the reader.

    Related Photos: code keynote

    Main Page | Login

    Do you want to buy me ? Find more gift ideas at my wishlist