All posts by Keith Garner

FFI for Ruby and an mp4v2 example

Previously on my blog: In my TiVo2Podcast stuff I automated the process of putting chapters around commercials, but had to call out to a small C++ app I wrote to put the chapters in using libmp4v2.

A few weeks ago I was looking at some ruby gems for a project I was working on and stumbled across ffi, a foreign function interface gem for ruby, or as its docs put it: “a ruby extension for programmatically loading dynamic libraries, binding functions within them, and calling those functions from Ruby code.”  As long as you know the function signatures that you need, its pretty trivial to make the calls from Ruby. You do need to be aware of memory management stuff sometimes, but overall its pretty easy, especially for basic use. If you’re only going to be working in Ruby and need access to a C library, this is much easier than mucking with swig, that’s for sure.

The mind-blowing part for me is that the authors of the gem have made it smart enough to know what flavor of ruby vm and platform the code is running in and it does the right thing, no matter if its JRuby or on Windows or whatever. While I haven’t had a chance to use it yet, I suspect this property will be useful with JRuby at work in the future.
Continue reading FFI for Ruby and an mp4v2 example

Using Ruby with Viewpoint unhork an Exchange mailbox

(It’s been awhile since I’ve done a technical post, so I may do that on the next few.)

Through some craziness we haven’t figured out, a user at work managed to get over *pinky to mouth* one million items in their Deleted Items folder in Outlook which is hooked up to our Exchange server. This turned into an interesting problem.

Needless to say, that is a stupid amount of items that Outlook had issues with processing. Telling Outlook to empty the trash would send it out into la-la land as a hung process. I’m thinking it was trying to pull all million items into memory to do a delete on them. I’m sure if we let it sit long enough it may have done something, but it just really didn’t like that volume of stuff.  Similarly, using another Exchange or IMAP client like Mail.app, Thunderbird, and mutt had similar issues as they needed to retrieve the million headers before they would do anything. Deleting it batches at a time by hand worked, but was slow and required someone to do it by hand which…we can see the issue there.

As is often the case, the solution to the problem could be had by creating a small script to do the pain in the butt stuff for you. Actually, the big reason a script works here is that it could be smart and just snag small batches and work on those. Luckily, a few months back I had played with Viewpoint, a “ruby client access library for Microsoft Exchange Web Services. Previously, I had used Viewpoint to read mail in a certain folder and generate stats for it, so using it to identify and delete messages would be a snap.

The first go around I was grabbing the messages in a batch and deleting them one by one.  That works, but was a bit slow.  I figured out how to do something that hasn’t been written into Viewpoint yet: a batch delete.  That sped up the operation by 4.5 times or so.  This still took over a day to run.  It also couldn’t delete everything.  For some reason it seemed to not be able to delete calendar invites.  After the script was running entirely, we were left with about 30,000 items left behind, but Outlook could handle wiping the rest of them out if we left it alone for 20 minutes or so.
Continue reading Using Ruby with Viewpoint unhork an Exchange mailbox

One mo post

[I know I posted yesterday, but I didn’t really define Movember nor some of my motivations.  I was more eloquent in mail I sent to some family and friends, so I repost it here. Also, a monster shout out to g0ff, Dave, and Lena who donated already!]

After doing a photo a day last year and losing 40lbs earlier this year, I needed something new to attack. At the same time, I wanted to be lazy, so what could I do?

As many of you may know, I’ve never had facial hair in my life. It fits my “something new” category and also hits laziness as I just have to sit still and let it happen. But there was still something missing about this challenge. Then I saw someone on the morning news talking about Movember.

Movember is a project that, through the growth of a mustache, hopes to raise awareness and funds to help better men’s health such as support prostate cancer and testicular cancer initiatives. A list of the programs they fund are at http://us.movember.com/about/funding-overview/ and it includes Prostate Cancer Foundation and the LIVESTRONG Foundation.

So using Movember as a motivator and goal, I will start 1/1 clean shaven and try to grow a mustache through November. There are a number of challenges, besides my lack of ability to grow facial hair quickly: my wife and children’s antipathy, Thanksgiving gatherings, and work’s annual convention.

If you’d like to support my attempt to grow facial hair and track my progress, you can visit my “mo space” at http://mobro.co/ktgeek

Thanks!

Mo-stache, mo problems

So, I have decided that I’m having a midlife crisis. The good news to my wife and family is that this midlife crisis is taking the form of losing weight (which is good for me) and a desire to grow facial hair. Having lost 40 lbs or so, I’ve taken care of the first item.

To satisfy the impulse for the second item, I think I’m going to participate in movember. I can grow hair AND help raise money for men’s health. Because if there’s anything I love more than my family, its my body parts, especially the man bits.

To learn more about movember visit http://us.movember.com/ and to help me raise money visit http://mobro.co/ktgeek

Trib Nation – Life Lessons: Photographing Chicago

Jason, Lena, and I took a class with two Chicago Tribune photographers. It was a good walking tour of downtown near our office, but more valuable was the quick photo review the photographers did after the walk. Having professionals look and comment was very cool and having a large group of people taking shots in the exact same area was great as you could see how different people approached where we were and caught things I hadn’t thought of.

It’s a jelly!

I took the kids to the Shedd Aquarium on Friday. The Jellies exhibit is still set up and this is set up for photography. All the jellyfish are set up in colored tanks to offset their color and lit well enough that you can easily get some spectacular shots.

You also get a bonus seahorse in there that wasn’t part of the Jellies exhibit, but I really liked the shot and wanted to share it.

If you don’t have flash, you can go to flickr

Fireworks 2012

I wanted to experiment with capturing fireworks because you don’t often get a chance to do it and its a difficult subject. I took about 200 shots and got these 19, of which I think 15 are worthwhile and 4 I kept for whimsey or color. I’m not sure when I’ll do this again, but I learned what works and what doesn’t work for future reference.

For those who can’t see flash, here’s the set on flickr.