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: 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 ...

    Re: Library Woes on OSX

    Have you considered changing your hosts file so it connects ...

    Re: Library Woes on OSX

    Right now the tests for Device::USB are failing. I've turne...

    Re: Library Woes on OSX

    What's the USB device you are trying to connect?...

    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.

    More updates

    Kent Cowgill

    You've probably already noticed, but I've added some additional organizational capabilities in the form of categories that each post is filed under. To the right, you'll see a little "cloud" of topics I've posted about - and the more often I post about something, the bigger the topic appears in the cloud :)

    Also, I've gone ahead and tagged all my articles. Thank goodness I'm doing this now, because I'd hate to have to go back and do it after hundreds of posts :)

    I've also done a lot of tweaking and refactoring of the Catalyst code that powers this thing - I started noticing a lot of repeated code for doing things like formatting posts, obfuscating email addresses, etc. So I'm doing what I can to get rid of that duplication. The only visible effect you'll see from this is that from time to time, you'll probably get an error message - that just means I'm right in the middle of fixing something :)

    (Maybe I should have a prettier error message?)

    Related Photos: tweak

    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

    History in the making

    Kent Cowgill

    Ever wonder what my earlier posts were?

    Ever wish you could read more than just the last 10 entries?

    Wonder and wish no more, there are now links at the bottom of each page for reading older articles.

    Though I should really fix it so it doesn't use the old school ?start=blah style of navigation. But I didn't feel like reading the Catalyst documentation just right now.

    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

    Kate doesn't do VIM

    Kent Cowgill

    I guess I shouldn't be surprised.

    I was hoping to post up bits and pieces of my .vimrc file - after all, Text::VimColor displays .vimrc syntax just fine. Naturally.

    Unfortunately, Kate doesn't appear to support .vimrc files.

    At least not yet.

    Until I write Syntax::Highlight::Engine::Kate::Vim, I'll have to make due with using the 'LPC' syntax file, which at least colors comments differently from non-comments , and somewhat reliably.

    Here's a snippet from my .vimrc for some new (to me) features that I've been playing with lately:

    " auto indenting, dealing with tabs
    " how to deal with tabs. indent of two
    set tabstop=2
    " expand tabs to spaces
    set expandtab
    " number of spaces to use for autoindenting
    set shiftwidth=2
    " auto indenting features
    set autoindent
    set smartindent
    "make tab in visual mode indent code
    vmap <tab> >gv
    vmap <s-tab> <gv


    Enjoy!

    (Note, due to difficulties and annoyances beyond my control, I've manually edited the above snippet using Text::Textile formatting.) Figured it out.

    Related Photos: kate

    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

    Syntax highlighting

    Kent Cowgill

    Always looking for inspiration, I happened upon Jonathan Rockway's blog and noticed that he makes use of syntax highlighting in his Angerwhale blog. After a few aborted attempts to use Text::VimColor, I broke down and decided to try out Syntax::Highlight::Engine::Kate.

    I'm pretty pleased, after I finally figured out enough of how it formats bits of code and how to translate that to my vim colorscheme of choice.

    All it takes is the following modifications to your text:

    <pre class="Language">
        # your code here
      

    And if Kate recognizes your 'Language', it'll format your text.

    N.B. -- I can't quite figure out how to show a closing 'pre' tag inside a 'pre' block. Hope that doesn't offend you.

    Related Photos: kate

    Pardon my dust

    Kent Cowgill

    Please forgive me - I'm working on updating this. "This", of course, can mean different things. But what I mean is that I'm working on finishing my Grand Unification Project. What's that? Well, I'm finally bringing everything together. And finally making my blog public. It's done in Catalyst, everything else is plain CGI.

    All this means is that you might find some things that don't work from time to time. If you encounter this, please excuse me. I'm only human. I can't know about every single bug. Yet.

    So far, most of my blog has been updated. I even have a new version of my photos up and running. Even my resume has been somewhat updated... :)

    Related Photos: photos

    Catalyst wins again

    Kent Cowgill

    So I'm in love with catalyst all over again.

    I got tired of trying to figure out all these fancy-schmancy Object Relational Mapping database classes and trying to massage them to be able to understand my simplified database - which is a single table which is joined to itself for attaching a comment to a particular entry. I really didn't see any need for a separate table, since the structure of a comment doesn't really differ from the structure of a root post. Other than the fact that a root post doesn't have a parent.

    Thinking that restructuring the database was just too much work, I just ripped out the ORM and created a model class that simply ran queries and returned the results.

    Also, I added support for running my blog as a CGI and found that it was a really simple conversion, and only needed to update a few methods that I wasn't properly using before.

    Related Photos: None

    Finally figured it out!

    Kent Cowgill

    So, I'm a moron.

    Seems I'm not making proper use of the Model:: modules. I had originally found an old out of date tutorial making use of the Class::DBI helper scripts, so that's what I used in making this blog. Problem is, the tutorial was woefully incomplete, AND CDBI seems to work - at the surface - without any additional configuration.

    Except when you have a stupid datamodel that requires you join a table to itself and get a count of child rows for each parent row.

    These days, using Class::DBI seems frowned upon by the catalyst community, so I think instead of trying to fix what's broken, I'll just use a different model to access my data - HOPEfully one that isn't woefully broken, lets me write some of my own nasty SQL and actually reference the correct results to stuff into TemplateToolkit.

    Too bad I'm busy working on my wishlist, otherwise I'd tackle this issue straight away.

    Related Photos: None

    A little more detail on using a new model

    kent Cowgill

    The first time around, I was using a flat(ish) SQLite file, which worked just fine from my development platform, i.e. running the server as myself, connecting to it on port 3000.

    All well and good, but once I moved the application over to running under mod_perl, I kept getting errors like "Can't open readonly file" "Can't open any file" etc. I was sure it was permissions, so I chown'd the database file to nobody, and iteratively worked up to chmod'ing it to 777 - even moved it to a more publicly accessible location.

    I still don't know what it was. Instead, I moved my database schema over to a mysql database, regenerated my Model modules with the helper script, changed the Model module's references (before I refered to the Model module as blog::Model::CDBI::Blog, but I had to change that to blog::Model::CDBI::mysql::Blog in two places in my Controller - but other than that, *every*thing else worked flawlessly, including the ability to add new posts :-)

    Related Photos: None

    Main Page | Login

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