About Kent Cowgill
Articles filed under...
abs ab_ripper andylester arms back baggyshorts bestpractices biceps bike birthday 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 home houston html humor journal kate kenpo 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 pdf perl phb photos physical_therapy plyometrics poor_gait presentation procrastination progress 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

(3)
(1)
(3)
(2)
(7)
(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...

    Re: Re: Yoga kicks my butt

    Chris @ 46: Tatyana @ 21 – at best its a stop gap measure...

    Re: Vibram FiveFingers FTW

    Hats off to whoever wrote this up and potesd it....

    Re: A little more detail on using a new model

    百度 [url=http://www.sina.com]sina[/url] ...

    Re: Catching up through week 7

    testing video ...

    Re: Porting a non-Moose object to Moose

    Wow, look what I found, greedy genius ...

    Re: Porting a non-Moose object to Moose

    Kevin, You're right, that does seem a little confusing. ...

    Re: Porting a non-Moose object to Moose

    Wait. I'm confused. Moose isn't the tool to reach for. So...

    Re: Porting a non-Moose object to Moose

    You should switch to MooseX::Types to declare your Typed and...

    Porting a non-Moose object to Moose

    I'm currently working with a lot of legacy code in an envi...

    Testing strategy for mocking code

    I keep finding myself using the following idiom for writing ...

    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.

    Bad at blogging

    Kent Cowgill

    So, I'm really bad at blogging.

    But it seems I'm OK at microblogging.

    Starting tonight, I'll be posting my daily tweets from twitter.

    With any luck, I'll be embarrassed by having my only blog postings be from my daily microblogging.

    Yeah, right.

    Related Photos: None

    New term coined

    Kent Cowgill

    Someone on #perl on irc.perl.org complained of someone else "blogging on IRC".

    Well, blogging (as you can see above) is the short form of weblog.

    On IRC, there is no web.

    So, IRC logging (of events happening in one's life) is now known as "clogging". Instead of weblog, it's irclog, shortened to clog.

    Enjoy.

    Related Photos: None

    Slow no more

    Kent Cowgill

    Hooray!

    Shortly after complaining about how long my main page was taking to load, I started thinking up ways to make it go faster. As far as I could see, one option would be to try to parse the perl with perl - but just borrow all the ideas and regexes from the perl.vim vim syntax file. Easy enough - just figure out what the metacharacters in vim map to in perl, etc etc and so forth.

    About a third of the way through my translation, I realized it was going to be harder than I was expecting/hoping, because there are some conventions in vim's syntax files that makes that sort of thing somewhat easy.

    Plus, I wasn't even sure how good the translations were, or whether or not they'd even do anything useful:

    my( $I, $i )
      = ( qr/[A-Za-z_]/, qr/[0-9A-Za-z_]/ );

    my $packageRef = qr/(?:$I$i*)?(::|')$i/;

    my $varPlain
      = qr/\\?(?:[@%\$]|\$#)\$*(?:
    $I$i)?(?:(?:::|')$I$i*)*\b/x;

    my $functionName
      = qr/\\?&\$*(?:$I$i*)?(?:
    (?:::|')$I$i*)*\b/x;

    Yuck.

    I toyed with the idea of doing something with PPI, but quickly dismissed that.

    I then thought I might've remembered reading something about creating some kind of "vim server" with Text::VimColor - so a quick read of that yielded nothing. But I noticed the link in SEE ALSO to Apache::VimColor, which thank goodness mentions Cache::Cache (and sibling Cache::FileCache).

    What was I thinking?

    So the solution was exceedingly simple:

    use Cache::FileCache;

    # to create a key for the cache
    use Digest::MD5;

    sub vimformat {
      my( $self, $text ) = @_;
      my $key = Digest::MD5::md5_hex( $text );
      my $cache = new Cache::FileCache;
      my $return = $cache->get( $key );
      if( ! defined $return ){
        # do hugely time-expensive formatting, set
        # the value of $return to desired text
        # set the cache key at the end
        $cache->set( $key, $return );
      }
      return $return;

    And just like that, the page is back to being under 2 tenths of a second to create. Even with (as of this post) more than 10 hunks of syntax colored code.

    Yay!

    Related Photos: None

    Claiming my blog

    Kent Cowgill

    Just a quick post claiming my blog by posting a link to my Technorati Profile.

    Please drive through.

    Related Photos: None

    Testing with vim

    Kent Cowgill

    Wrote a quick little perl wrapper around vim to automate posting entries to my blog.

    Really threw it together pretty quickly, but wanted to save myself the trouble of opening a web browser, typing in the site name, scrolling down, clicking on "login", logging in, etc. Just a whole lot of work. Quite honestly, no one should have to put up with that.

    Maybe I should see about writing a plugin for vim, since the perl wrapper is a little hackish.

    Related Photos: perl

    Tags, topics, categories... Photos!

    Kent Cowgill

    I've already revamped my photo gallery to use the same look and feel as everything else on my site now.

    But there's a small problem - now I want to add tags (topics) to my photos, and have pretty much the same functionality as I now have with my blog.

    While the primary CGI that drives the main display was completely re-written, the interface I use to add captions to the photos is pretty much still the same old code, and might be a little harder to work with.

    But I think I'll give it a go anyhow.

    Related Photos: photos

    More updates

    Kent Cowgill

    So, it's nothing particularly earth shattering, but I've made a few updates.

    1. I've added an "archives" section, so it's a lot easier to jump to older posts if you're looking for something I wrote in a given month and year. Granted, there's not a lot to choose from at this point, and it's pretty obvious where I took a few breaks from posting (the first break was pretty long, and in fact was due to some of my misunderstandings).
    2. I decided that making the links for newer/older posts to be like /start/blah/ instead of like ?start=blah really wouldn't be that tough, so I just went ahead and did it. I'm wondering if this is a good way to go about it though, since the "start" links are fairly ephemeral - for each and every post, those numbers shift.
    3. I also broke some of the uglier code out to separate subroutines. The following seemed to clutter things up in index:Local:
    map {
          my $hashref = $_;
          my $entry = $hashref->{blog_entry};
          $entry = $c->textile->process( $entry );
          if( $entry =~ m/(<pre.*<\/pre>)/s ){
            $entry =~ s/(<pre.*?<\/pre>)/
    blog::View::Code->vimformat($1)/xseg;
          }
          $hashref->{blog_entry} = $entry;
          $hashref;
        }
      blog::Model::BlogDB->get_roots( $startrow );


    Also of note is that most of the temporary variables above are leftover from when I was using Kate for code syntax highlighting - the "format" method clobbered (didn't localize) $_, so I had to assign $_ to something else. I could probably take that part out and condense it a bit, but I'm not yet sure if that would interfere with readability.

    Related Photos: None

    Text::VimColor works!

    Kent Cowgill

    Turns out I was able to get Text::VimColor to work after all - seems I wasn't quite reading the documentation properly. See, vim needed a little help to figure out what's what - in this case, what kind of terminal it's attached to (which it isn't in this case, which is running as a CGI under apache).

    According to the documentation for vim:

    -T {terminal}
            Tells Vim the name of the terminal
            you are using. Only required when the
            automatic way doesn't work. Should be
            a terminal known to Vim (builtin) or
            defined in the termcap or terminfo file.

    So all I really needed to do was give it a hint so it wouldn't complain about not being attached to a terminal. Therefore, the solution is:

    my $vim = Text::VimColor->new(
      string => $code,
      filetype => $filetype,
      vim_options => [qw(-RXZ -i NONE -u NONE -N -T xterm) ],
    );

    Unfortunately, it's slow.

    It's a known issue - this is why Apache::VimColor uses caching to speed up the HTML generation. In fact, with five code snippets on the main page (just prior to this current time of writing) case the page generation speed to go from about 0.07 seconds to nearly 1.1 seconds. That's quite an order of magnitude increase. And that's not counting adding these two snippets in a single post5, nor the posts in the future that will undoubtedly have more code and other syntax colored snippets.

    5 Adds another 0.4 seconds for a total run time of nearly 1.5 seconds.

    Related Photos: None

    Trying to display pre tags inside a pre block

    Kent Cowgill

    I think I know why I can't show HTML pre tags inside a pre block, and it's not Kate's fault, and it's not Textile's fault.

    It's my fault.

    if( $text =~ m/<pre class="([^"]+)"/s ){
        $lang = $1;
        $text =~ s/<pre[^>]+>(.*)<\/pre>/$1/s;
      }

    See the problem?

    I'll probably have a few more posts about this until I figure it out.

    But it's not like you were doing anything better than reading this :)

    Related Photos: perl

    What days do I post?

    Kent Cowgill

    As a follow-on to my last statistical post, I thought I'd also create a graph that tracks what days I generally post on.

    The SQL is amazingly the same, but only slightly different. In fact, nearly everything is exactly the same -- I should just generalize the code.

    Related Photos: None

    When do I post?

    Kent Cowgill

    I ran across some guys' blog recently where he decided that for every 100 posts to his blog, he should figure out some of his blogging statistics. Or something like that.

    One of which was to see what time of day he generally posted. He explained some procedure for doing a database query from the shell, piping the output through some command line utilities, and then running some commands or somesuch to feed into some graphing program (gnuplot) to produce a chart.

    Seemed like a terribly manual process.

    Inspired by that, I created the following:

    Which is pretty much what I stated, but it updates automatically. As in every time it gets displayed. What you see above is current, even now. However long ago this was actually written.

    For the morbidly curious, the SQL to create the data looks like this:


        select count(*) as posts,
          substring(blog_date,12,2) as hour
          from blog
          group by hour;


    Related Photos: None

    Main Page | Login

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