Writing My Own Travel Agent in C#

Jul
30
2008

Yesterday, Garrick was describing the difference between a "search result" and "find". His short answer was:

Search Results Listings say, 'The answer might be here'. Find says, 'Here you are, get on with your day.'”

That distinction is something that has always struck me as irritating about using every travel site I've ever seen (later discussion revealed that, ironically, this distinction is talked about obsessively at Orbitz). That irritation is because every search I've made started out as something that doesn't fit in their search boxes: "Find me a cheap coach flight and a hotel near the conference center in Austin, TX for SXSW", "I'd like to go to San Francisco for a long weekend some time this fall; is there a way to do that for under $500?" or "Which one of these cities and which weekend will be cheapest in October for a 5 day weekend?".

Those aren't questions which naturally get answered by a search results page. You don't get to pose those questions to travel sites. What you are asked on every one of them is to choose specific dates and, in many cases, both airports. The sites don't even so much as hold on to the fact that 99% of my travel is based out of Minneapolis/St. Paul International Airport.

Rather, I get a constant flow of emails from the travel engines telling me about great deals to Miami/Las Vegas/New York for $89. Of course, if you are flying out of Minneapolis, that deal suddenly becomes $327 instead.

There is a place you could and can ask those questions and get your "find" satisfied. Travel agents pick up the phone, listen to just such a question and call you back later in the day with the results of your find. Unfortunately, they also are professionals who need to make a living. That means they're not entirely thrilled to, for instance, check daily for weeks at a time for a very specific set of criteria for a vacation I may take if the deal is good enough.

That does, however, smell of the kind of thing that I like sling a bit of code to solve. And, it's something I've wanted to solve for a very long time. Every couple of months, I go looking for a way to write code that searches for flights and hotels and have always come up empty.

Then, this weekend, I did it again and ran across the Kayak API, which looks like what I've been looking for all along. The API allows 1000 searches per day, per developer key. While that wouldn't let me create much of a public service or commercial application, it's a really roomy number if you're looking to do lots of permutations for your own travel needs.

Personally, I'd like to do things like have a list of cities I've never been to and have software grind away on it, finding a good deal for a "fall long weekend" or a "week-long summer vacation", etc. for one of those locations. Similarly, I'd like to be able to say, "I've got $300. Is there somewhere I can go and get a hotel for a 3 day weekend that's on my list?".

Software can easily handle digging through the tedious crap like seeing whether leaving on Thursday and coming back on Sunday is cheaper or more expensive than leaving on Friday and coming back on Monday. As a person, trying those combinations on the existing search results-oriented sites is tedious. Tedious is what software does best.

Before I start dreaming too big for what might be possible, I threw together a quick POC app to see how easy it might be to search and grab results. I created a really basic class library for doing the actual searches and a tiny console app to try out a single search.

I have to say, I like what I see and think that there are some real possibilities for coding up my own travel agent with Kayak.

The sample, half-finished POC code is available in PDF form if you want to look at it. It's got gaping holes all over (hard-coded, read-only properties, unused properties, concatenated strings, etc), but shows the basic idea for how to hit the service. This doesn't do anything to take advantage of any of the polling cycle that the API documentation describes, so the results are incomplete.

However, it proved what I wanted from the POC. I'm now pretty sure that I'll be able to get what I want out of that API. If you're interested in travel and writing software, it might be worth a look for you as well.

HTML as Page Layout Language

Dec
28
2007

Off and on over the last 6-8 months, I've been working on a project that needs PDF as its final output format. The plan has been to use DocBook and the toolchain attached to it. However, that's been more frustrating than it first looked when it comes to integrating into the whole system I'm designing.

Then, earlier today, someone posted a link to this YouTube video, which demo's the functionality of the Prince engine. That revealed a system for really nice page layout using HTML and CSS (with CSS3 handling the page breaks and other stuff like it was designed to, making Prince the only implementation of CSS3 out there that works as far as I know).

Given how my project is web-based, being able to just keep it all HTML from end to end and still get really nice PDF's out the other end would be a huge benefit. And, given how this project will be commercial and how much time I've already spent trying to do all of the conversions back and forth, even the steep pricetag for a server license will likely be a net bargain.

Fortunately, the version that puts a little logo in the top, right corner of the PDF (only for display, not printing) is free for development/personal use. So, I messed around with that a bit tonight and got a feel for it. There are versions for pretty much all of the platforms (Windows, Mac, Linux, BSD, etc.) and integration with code for automatic generation is fairly easy.

Really basic conversion using C# only took 3 lines of code. I just grabbed the normal Windows version, also downloaded the DLL and added that DLL to a basic console app.

Then, these 3 lines work to dump out a PDF of the page in question. I just threw together a quick HTML document to test with a few H1, paragraphs, etc.

IPrince pr = new Prince(@"C:\Program Files\Prince\Engine\bin\prince.exe");
pr.AddStyleSheet(@"C:\Program Files\Prince\Engine\style\xhtml.css");
pr.Convert("demo.html", "demo.pdf");

Pretty easy startup as far as I'm concerned. The video is worth watching, despite being somewhat irritating to watch. Like many presentations to a room full of geeks, there's quite a bit of not seeing the forest for the trees. Lots of people shooting it down by saying, "this is would be REALLY great if it supported my one pet feature" kind of stuff. They got a bit hung up on those little nit-picking details and I wonder how much of their presentation ended up left out as a result.

Based on what I've seen so far, I definitely think it's worth tinkering with a bit more and doing the math on that license fee as part of my project budget.

My Eyes Bigger Than My Stomach? Really?

Dec
17
2007

Photo: Théo

All my life, I've heard people talking about how their "eyes were bigger than their stomach" or warning their children against such a misjudgment. I always had to guess at what they meant. That's because for as long as I can remember, it never really applied to me. If it could fit on a plate, I could finish it.

Other than on days like Thanksgiving (and maybe one or two other days a year) I don't manage to approach that "full" feeling everyone else seems to experience at most meals until a half hour after I'm done eating, if at all. Unfortunately, I also get REALLY hungry (think "willing to walk miles to get food) fairly often, no matter how much I eat.

That, of course, coupled with a move from farming to sitting on my butt all day pretty much guaranteed that I would top 300 pounds, which I did a few years ago. That's when I went to a weight loss doctor and spent nearly a year on a weight loss program resulting in a loss of 60 pounds.

The thing that made that program work for me was the included an appetite suppressant you probably know from countless spam emails: phentermine. When I took those pills, it was amazing. It was as though rational decision-making was returned to my interactions with food. Instead of *needing* that food, I was just *wanting* that food: an impulse I had some control over.

Unfortunately, that doctor turned out to be a bit flaky. She went on "vacation" and didn't come back for MONTHS. That, of course, derailed my progress and eventually I gained about 10 pounds back. A few months later, I tried to start back up with this doctor only to have her disappear again after a couple of months.

Then, this summer, I decided to try to find another doctor and get back on the prescription. It's clearly the only thing that's worked for me. I headed in for a couple of appointments only to have the reality of keeping clients happy collide with getting to appointments.

When I missed my last one, I sat back to do some reflection. See, while the phentermine worked for me, it has always bothered me that I needed to be on a prescription in order to have control over my weight and appetite. I was never quite sure what the final exit strategy would be when I reached my target weight.

Obviously, I can't stay on that kind of prescription as a long term solution. That's why the last few days have been so exciting for me. I have been unable to finish any of my last 4 meals without any surgery or other drastic measures. The results I'm getting have every possibility of being permanent and for the rest of my life.

Read the rest of this entry »

Obsession with the Superlative

Sep
04
2007

For the past week, I've been on vacation here at home. We've been helping Laurin ease into American society, exposing him to our favorite foods, showing him around, etc. As part of that, we spent a day at the Minnesota State Fair. We had a good time, but I couldn't help but notice something that bothers me. Everywhere I turned, there was this deep obsession with the superlative.

Vendors had staked out their territories and all were drawing lines in the sand to show in exactly what ways they were the first, best, only, biggest, fastest, smallest, lightest, heaviest, etc. In some way, every one of them was trying to plant their flag at the top of some heap, even if they had to pile the heap themselves.

Decades of marketing books and programs (as well as consuming the results of said marketing) have taught everyone that you need to be number 1 in some way or you should just go home. And, if you aren't number 1 in some natural way, you need to redefine the criteria. If you can't actually be the first to market, you can be the first in the state or the first at the state fair.

We see this everywhere. If your hamburgers can't win in taste tests, but still sell well, you can't advertise them as "best tasting", but you sure can market them as "America's Favorite*" (*based on number sold). That fine print next to a claim is a sure sign that someone has redefined the criteria.

On the stock markets and in nearly every discussion of business, there's an assumption that if you can't be the market leader in your niche, you're a failure.

The thing is that I don't think that number 1 is necessarily the optimal place to be. My favorite recent example is in watching the aftermath of each of the finales for The Apprentice. After those final shows, there were 2 people out doing interviews about the result.

One of those people was the winner, who received a job working for Donald Trump on one of a handful of projects. The other came in 2nd and many of the interviews focused on how it must feel to not be the winner.

Then, in the middle of those interviews, you'd hear a question about what the "loser" was going to do after the show. The answer was telling. They pretty much all talked about the piles of job offers coming in from around the country.

In other words, the person who "won" got a job working for Donald Trump (a prospect that would require far more compensation for me than the "prize" offers) while the "loser" was offered a buffet of choice jobs. That person could choose to work for their ideal boss in their ideal job. As far as I'm concerned, coming in 2nd on that show is the ideal game plan.

Actually, we all do this all the time. It's highly unlikely that for someone like me who participates in a collection of hobbies like: playing guitar, writing fiction, keeping fish, drawing, photography, collecting movie memorabilia etc. will ever perform or possess a collection that is genuinely world class. That doesn't mean that pursuing those interests is futile or that I couldn't reach an admirable level, even make a living with some of them.

We all decide a level of effort that (to some degree or other) matches our expected return on that effort. And, for most of us, that mechanism works extremely efficiently for nearly everything in our lives. However, at some point, nearly all of us fall victim to the sales pitch that an endeavor is only worth pursuing if we can devote our entire pool of resources to it.

Horse pucky. I'm not the world's best software developer. However, I believe my track record points to me being a *good* software consultant. Because I am not killing myself in pursuit of being good enough that the entire software world beats a path to my door, I have time to write, play music, draw and enjoy spending time with my family.

It's a pretty good balance as far as I'm concerned. It may not be for everyone, but I think the obsession with the superlative is just hollow to me.

Home Alone For The Weekend

Jun
02
2007

Yesterday, Shelly left for Cedar Rapids to spend some time with her extended family and attend her cousin's graduation, which leaves just me and the dogs to hold down the fort this weekend.

I'm a Myers-Briggs introvert. Lots of people are surprised by that because I'm loud and enjoy talking. However, much of the reading I've done on the difference is more about whether being with other people recharges or drains you.

I'm married to an extrovert (we balance each other well). When we go out and spend time with 10-12 friends, she comes home energized and talking about it. I need some time alone to recharge.

At any rate, that means that, while I would never volunteer to spend *all* of my time alone, a weekend here and there is just what the doctor ordered. So, it's me, the home theater, the grill and my laptop and maybe a meal with a friend until Sunday night.

I'm working on a CakePHP project that holds some promise as a commercial product/service. It combines 2 of the things I love: writing and technology. It also targets a potentially lucrative target market: retiring baby boomers. It has no real start up costs other than time building the software and writing the content and the results of the service would be a net gain society (do no evil). I really think this could work.

This is not a billion dollar idea or even necessarily a million dollar idea, but then again, a mere extra $215,000 over the next 10 years would pay off my house. An extra $5000 a year would mean a fabulous vacation. An extra $10,000 a year could mean taking a couple of months off.

The last time I took a stab at the product/service market directly, I was too focused on trying to make a $60,000+ living out of the idea. As a result, a product that was making $30,000/year was a "failure". This time around, I'm not going to do that. I *never* want this thing to be my fulltime job. Just think of the difference between winning $10,000 in the lottery this year and making $10,000 this year as your job. One feels like a lot of money, the other is poverty.

I'm holding back the details of the project itself until I'm a little further along, but I'm really excited about this particular project. If you want to know more about it, send me an email or talk to me offline.

« Older Entries  

J Wynia

For better or worse, I'm the guy who runs things here. I'm a web consultant, software developer, writer and geek from Minneapolis, MN. This site is a fairly wide cross-section of the things I'm interested in and enjoy writing about.

Oh, and if you happen to be looking for hosting for your Subversion repositories or just web hosting in general, take a look at Dreamhost. It's what I use for Subversion and your signup helps me out.

Latest Microposts

Follow Microposts on Twitter | Subscribe to Microposts

My Attendance At the Gym

Feeds and Links


www.flickr.com
This is a Flickr badge showing public photos from J Wynia. Make your own badge here.

Search


Pages

Archives

Computers Blog Directory
© 2003-2008 J Wynia. All original content is licensed under the terms of the Creative Commons Attribution license unless otherwise noted. Content from other sources is licensed under its original terms.