About Kent Cowgill
Articles filed under...
.vimrc 9-11 acme aging algorithm andylester array attitude autocomplete baggyshorts BEGIN bestpractices big bike bikeshop bilk birthday blog bmi body_composition botanicgardens broken bugs bulge bumbo burnout bus butterscotch buzz cache calculator camera catalyst catnip cgi chart chin chinups chiropracter claim clog cloud code codger comics community commute complaint confusion constant coo cooking coworker cpan css dad database datamodel datatypes dbi deal debugging design devin docs documentation dsl ebook error exercise exhaustion Exporter feature_creep filecache firstpost fitness flattire flat_tire formatting fundraising funny google google_maps gravatar grilling groceries harness hash helmet highlight history home houston html humor identity ie imager indirect internet ipod journal kate kettlebell keynote kids ladder launch lazy legacy lisa lisanne list logarithmic lolcat macbook-pro maintenance map maps matthew memories meta michaelmckenna modules mom money monger mongers montreal motivation movie mvc mysql nasty notation objects offroad old oops optimize orm ouch outrage ownership park patrick paw pdf perl perlcritic phb photos pictures pinch presentation presentations principles programming progress push pushups rabbits racecondition rain rant reader recipes refactor requirements review ribs ride route run_on_sentences shadow shake site sitting slides sneaky soda sony sore soreness sorting spacebar speed spike spring sprint sql sqlite squeaky squeal statistics subversion syntax tag tags talk talks tap tasteofchicago tasty teachers technorati test testing tests text textile tire trac traffic trail training treats trick tricks tweak tweets twitter twitterpated updates ups vandalism versioncontrol video vim vimrc walk warren weather weblog welfare wikipedia winter wisconsin wishlist work workaround workouts xkcd yapc yapcna2007 youtube yummy zap

A R C H I V E S

(16)
(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...

    Week 3, day 2 for push ups

    I'm posting a bit more than a day or two per post, hoping I ...

    Chin ups week 1 column 2, push ups week 3

    August 6: Push ups: 27 then 20 (wow these seem tougher than...

    Exhausting chin ups, continuing with push ups

    August 4: I'm really glad I took the opportunity to rest ...

    Logarithmic tag cloud

    It's been a while since I've posted anything technical. Pos...

    Weekend bike rides

    August 2: I got out on my bike today. I had to raise the s...

    Still week 3 for push ups, finishing week 2 for chin ups

    July 31st: Push ups: 27 then 19 then 19 (the last 5 of whic...

    Tough push ups, and easier chin ups? Oh, kettlebell, too!

    July 29th: The push ups day I'm dreading. I'm feeling mostl...

    Push ups exhaustion test, continuing on with the chin ups.

    July 27th: Exhaustion Challenge, push ups. 31. Kind of dis...

    Weekend Respite.... or is it?

    So I ended up buying a kettlebell and getting back on my bik...

    Gotta keep going - on with week 2

    July 25: Super tired today. Woke up very early, had a pedi...

    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.

    Bunnies at the park

    Kent Cowgill

    So I don't have much other excuse for this than to test out a few more capabilities of Text::Textile, my RSS feed, and I guess my vim wrapper for posting entries to my blog.

    Spike and I were walking in the park last night, as we normally do, and again we saw a rabbit. They weren't twitterpated . In fact, there was just one. But I noticed he was fairly bold, and didn't seem to run away as easily.

    In fact, the rabbit didn't seem to want to move at all. So it was fortuitous that I happened to have my cameraphone with me. Granted, I take it with me on every walk, just in case. But I thought it would be a good time to test how the "zoom" feature on my cameraphone actually worked. Also, it seemed in my viewfinder that I could hardly tell that the brown lump in the middle of the frame was supposed to be a rabbit.

    Short story, it doesn't.

    It more or less just "crops" an image. Same resolution, just smaller dimensions.

    I was pretty disappointed.

    The good news is that I can add images to blog posts fairly easily, and the formatting allowed by Text::Textile seems to be close enough to what it purports it ought to do. Also, the images show through just fine in my newsreader of choice, so anyone reading this via the RSS feed ought to see the fluffy bunnies just fine.

    Also, turns out my vim blog post wrapper doesn't mangle intended Textile formatting, at least for images. Woo!

    Related Photos: vim rabbits park spike textile

    Testing Textile

    Kent Cowgill

    Just giving something a quick test.

    The documentation suggests that for centering an image, you should be able to put an "=" inside a set of exclamation marks in order to do it.

    inside a tableanother cell
    short cellthis should be a long cell, hopefully long enough to make this cell be wider than the middle cell in the first row, hopefully so that the above cell will show whether or not its centered. or not.another cell

    If that doesn't work right away, I'll probably fiddle with it a few more times.

    Turns out the solution is to have the vertical bar for the table cell the image is to appear in, followed immediately by an equals sign, a period, and a space - then the image.

    Related Photos: bugs oops textile

    Installed Trac!

    Kent Cowgill

    So after some prompting, I added a few of my configuration files to subversion. In order to do that, though - I had to adjust them so they'd work no matter where they are.

    For example, in my .vimrc file, I had to separate out the bits that makes my Mac happy from the bits that make the account on my server happy. This is what I seemed to settle on, but I'm not 100% sure it's the cleanest way to do it - I'm counting on the fact that my $HOME directory is particularly unique on my mac versus more unixy boxes:

    
    if exists( "$HOME" )
      if $HOME == '/Users/kentcowgill'
        " my mac and terminal settings need this
        " to display color correctly.
        set term=xterm-color
        " etc...
      else
        set term=xterm
        " etc...
      endif
    else
      set term=xterm
      " etc...
    endif
    
    
    

    The good news is that I've also installed Trac, adjusted the templates a bit to match the rest of my look and feel, and the end result can be viewed in the dotfiles section of my site.

    Enjoy browsing around. The rest of my .vimrc is nicely loaded into Trac.

    I'm working on making the rest of my code presentable, so that'll show up soon enough.

    Privacy Invaded?

    Kent Cowgill

    I just watched a news piece about a big news item in Illinois recently.

    It's a story about a DVD that was circulated depicting the principal of a school engaged in sex acts with a teacher of the school, in the office of the principal. Apparently the principal and the teacher have resigned, along with another faculty member. My guess is that the other faculty member was involved in taping the pair.

    The principal was just on the news and said something like:

    I have admitted my wrongdoing, but to denigrate my life, my friends, and a 30 years career is uncalled for. Whoever made this video needs to be held accountable.

    Excuse me?

    Aren't you the one who cheated on your wife?

    Aren't you the one who cheated on your wife with a subordinate?

    Aren't you the one who cheated on your wife with a subordinate in your place of employment?

    Aren't you the one who cheated on your wife with a subordinate in your place of employment, in such a manner as to cause suspicions by other faculty members (or possibly a student?) to prompt them to put a camcorder in your office?

    You, sir. You are to be held accountable for your own actions. You denigrated yourself, your family, your friends, and your 30 year career. You got careless, and you got caught.

    Deal with it.

    Related Photos: outrage teachers principles

    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 vim blog testing

    RING RING

    Kent Cowgill

    HELLO?

    SPRING?

    WINTER CALLED, IT WANTS ITS CRAPPY WEATHER BACK.

    THANKS,

    -KENT

    Related Photos: rant weather spring winter

    ?!@#?

    Kent Cowgill

    So I went to the grocery store last night to pick up a few things for dinner. I breezed through the produce department and picked out a few things to make my impending salad complete - romaine lettuce, spinach, tomatoes, and carrots. No need for a little hand basket, since I have so few items, and surely I'll be able to get out and back home quickly. I speed over to the self service checkout lines, but notice that one is out of service, and there's a line for the rest. Or several lines, even though there's a little sign suggesting that people should line up in a single line. But the self service checkout line is a different story altogether. So I decide to line up in the express lane - no more than 15 items(!) ... since there's only one woman in that line.

    So I line up behind her. She visibly counts her items, I suppose to make sure she doesn't break the "15 items" rule. Good, glad she's a little conscious of ethical actions. But, her groceries are all spread out on the conveyor belt, taking up much more room than they needed to. Fine. A little rude, but I can forgive many things, including slight unintentional rudeness. The person in front of her is taking a while to pay, so I have to stand there, holding all my vegetables, no doubt speeding their eventual spoilage due to holding everything in hand.

    Then it's her turn. But she produces a packet of papers or something. Interesting. Especially with that gold ankle bracelet she's wearing. But her groceries are mainly stuff for kids, or at least seemingly appropriate for a household with lots of kids in it - 3 gallons of milk, several jugs of fruit juice, eggs, etc.

    Then I notice the cashier rings up three items, writes something on one of the slips of paper from the packet, punches in a long series of numbers into the register, opens the drawer, and puts the slip of paper in the drawer. Cashier rings up three more items, writes something on another slip of paper, punches in a long series of numbers into the register, and puts the slip in the drawer. I longingly look to the self service lanes, and notice the person I would've been behind in the primary line is using the self service machine. I would've been next, assuming no one decided to form their own line and cut me off.

    The cashier rings up three more items, writes something on the next slip of paper, punches a long series of numbers into the register, and puts the slip in the drawer.

    By this time, I've already gotten out my money, and my Jewel card, just to go as fast as absolutely possible. Did I mention I'm trying to get home to eat?

    The cashier rings up three more items, writes something on the next slip of paper, punches a long series of numbers into the register, and puts the slip in the drawer.

    I again longingly look to the self service lanes, and notice the person I would've been behind in the primary line is done. I would've been ringing up my own items, assuming no one decided to form their own line and cut me off.

    The cashier rings up three more items, writes something on the next slip of paper, punches a long series of numbers into the register, and puts the slip in the drawer.

    Finally, she's done - 15 items! The cashier asks her if the groceries behind the grocery divider are hers (no, they're mine, that's what the grocery divider is there for!), of course she says no. The cashier performs a little more bookkeeping caused by the slips of paper she "paid" with, and then the woman in front of me (and I assume her husband) finish bagging their groceries, and finally it's my turn.

    I'm out in record time! Jewel card, four items, cash at the ready, bing bang boom - I'm done! I rush out to my car, and notice that the car I parked next to was in fact owned by the woman (and what I still assume to be her husband) - and they're finishing loading their groceries into their SUV. Er. Their SUV?

    I get a little closer. The woman puts her cart in the cart corral as I pass by, close enough to see what kind of SUV it is. It's a Lincoln Navigator.

    You know, a Lincoln Navigator. Hailed thusly: "Navigator set the bar as the premier luxury SUV". MSRP apparently starts at $46,575.

    I'm absolutely floored.

    Can anyone very kindly explain to me what method of payment this woman and her husband were using to buy their groceries, three items at a time, no other money exchanging hands, no paper, no plastic?

    Can anyone explain to me what lottery these people have won to pay for their groceries? Is it the grocery lotto? "Congratulations, winners - you get free groceries, but you can only pay for them three at a time with these special coupons!"

    I have a sneaking suspicion that in fact these slips of paper that required the purchase of three groceries at a time that requires a lot of extra time and bookkeeping on the part of the cashier and that restricts the groceries to basic necessities etc. are actually either welfare, LINK, or some other government subsidized financial assistance.

    A show of hands please. What kind of government subsidized financial assistance gives people groceries for free, and yet lets them have enough money to drive around in a Lincoln Navigator?

    Related Photos: bilk welfare rant groceries money
    Comment on '?!@#?' [ no replies - permalink ]

    Del.icio.usly Optimized

    Kent Cowgill

    Wow.

    Never stop looking for ways to improve existing code.

    I had noticed that after I added tagging capability to my photo gallery that:

    1. Page loads seemed sluggish.
    2. Tagging 300 or so photos produced a large list of tags.
    3. Drawing the tags seemed the slowest, as I could watch them appear in the tag cloud.

    I actually started going through about 150-200 of my photos and re-tagged them to remove silly and/or superfluous tags.

    But then on Sunday I was browsing my del.icio.us network and saw an article that caught my eye about optimizing MySQL. Since MySQL is the database that powers much of what you see here, I figured I'd take a look to see if I could help shave off any execution time for my database access, in case it mentioned anything that I didn't already know.

    One of the items near the end mentioned a tool called mytop. I downloaded and installed it and quickly learned two things.

    1. My database is pretty low traffic.
    2. Unless I'm hitting my photo gallery.

    I used the qps(Queries per Second) mode and saw that when I hit the first page of the main gallery (which only shows 10 thumbnails with their captions in the href title by default), I had an astouding 500+ queries run in a single second! Meaning that every time through a page load, I was querying my database for captions for all (currently) 500+ images.

    That's insane.

    I already had some code in place that conditionally added the pictures I've looped through to my Template Toolkit $vars variable, but I was performing the caption lookup outside that condition - in essence running it for each and every picture, even though I'm only displaying 10.

    I moved the caption query inside the condition, and noticed an immediate improvement - page generation time went from a half a second to a tenth of a second. Really, a fairly simple fix for an 80% speed increase.

    Old code review

    Kent Cowgill

    Going through some old code reviews, I found the following in some of my notes.

    The idea was that there's a hunk of code that needs to produce a sorted and unique list of items. That description immediately brings to mind a few data types - an array and a hash - and a sort of some kind or another.

    The code I encountered looked like this:

    
      my @pre_sorted = $s->arrayOfArrays;
      my $unsorted = \@pre_sorted;
      my @key_list = ();
      my @sorted = ();
      my %hash;
      # make the AoA into a hash, keyed on [1], the name
      foreach(@$unsorted){
        $hash{$_->[1]} = $_->[0];
      }
      # copy the keys into a sorted array
      @key_list = sort( keys(%hash));
      # build the sorted AoA
      foreach(@key_list){
        my @temp_array = ( $hash{$_} , $_ );
        push @sorted, \@temp_array;
      }
    
    
    

    Don't get me wrong - that does do what it's supposed to do. But does it do it efficiently? Not really - that can all be replaced by the following:

    
      my %unique_items = ();
      my @sorted = sort { $a->[1] cmp $b->[1] }
                   grep { ! $unique_items{$_->[1]}++ }
                   $s->arrayOfArrays;
    
    
    

    Which has the following benefits:

    1. Much more succint.
    2. Many fewer temporary variables.
    3. More perlish.
    4. Quite a bit faster.

    How much faster? It depends a little on the size of the data passed to it. I found that most of the time, the data coming to it was very very small, but occasionally would have much larger data sets to sort. I recall having some spare time and more curiousity then is likely good for me, so I set up some benchmarks:

    First, results from running the routines
    500000 times on a tiny data set:
                    Rate    Original New version
    Original     98232/s          --        -71%
    New version 342466/s        249%          --
    
    Next, results from running the routines
    200000 times on a small data set:
                    Rate    Original New version
    Original     61920/s          --        -69%
    New version 200000/s        223%          --
    
    Now running them 10000 times on a
    larger data set:
                  Rate    Original New version
    Original    4032/s          --        -49%
    New version 7937/s         97%          --
    

    Squeaky Spacebar

    Kent Cowgill

    I just noticed during that last post that I was really getting irritated by the little squeaking noise my MacBook Pro makes every time I hit the spacebar.

    I seem to recall being annoyed by this when I first got it back in September or August - I don't quite remember which, but I have a distinct lack of being annoyed by it up until very recently.

    Was I not typing that much?

    Was I just tuning it out?

    Seems that now that I'm again aware of it, I am now painfully aware of it - it grates on my very last nerve.

    It also seems I'm not alone. Teddy Hwang writes about it. So does someone at nnforums. And there are other random smatterings of people complaining about it 'round the net.

    Fortunately, my work office is about 4 blocks from an Apple store, so getting it fixed shouldn't be too terribly painful. But annoying.

    Related Photos: rant spacebar squeaky macbook-pro

    Newer articles | Main Page | Login | Older articles

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