Thursday, February 26, 2009

Data from Google Checkout

So I recently started selling things using Google Checkout and wanted an easy way to check my sales metrics. I thought it would be simple, after all, this is Google, they do gdata for most of their products. Turns out I'm wrong. gcheckout does not have a gdata API and as a result I could not use the existing google-gdata-python API to do my queries. In fact, until recently you couldn't even get an nice report of your sales using any API. Never-the-less, the available API implementations are not of much use to me, a python programmer guy. There aren't any python api examples either. So, I ended up using a Google provided RUBY implementation, some awk and some shell to get the information I needed.
Having never written Ruby this took much longer than I had wanted to spend on it. I still don't know any ruby even though I wrote ten line... heh. I also had to learn a bit of awk. I bet there are better ways of doing what I'm doing but I was in a rush.
Nasty Awk
  voided_total = 0
  voided_orders = 0

  charged_total = 0
  charged_orders = 0

  new_total = 0
  new_orders = 0

  total = 0
  total_orders = 0

  raw = 0
  raw_orders = 0

  raw += $6

  if ($8 == "CHARGED") {
 charged_total += $7

    total += $6

  if ($8 != "PAYMENT_DECLINED" && $9 == "NEW") {
 new_total += $6

    total += $6

  if ($8 == "CANCELLED" || $8 == "PAYMENT_DECLINED") {
 voided_total += $6

  print "Voided:\t\t" voided_total "\t(" voided_orders ")"
  print "Charged:\t" charged_total "\t(" charged_orders ")"
  print "New:\t\t" new_total "\t(" new_orders ")"
  print "Raw:\t\t" raw "\t(" raw_orders ")"
  print ""
  print "Valid:\t\t" total "\t(" total_orders ")"
Nasty Ruby
require "google4r/checkout"

class Test
  def myorders
    # Use your own merchant ID and Key, set use_sandbox to false for production
    configuration = { :merchant_id => '675887550112686', :merchant_key => 'AAsdffRGSgGSSHFDDAsfghj', :use_sandbox => false }
    @frontend =
    checkout_command = @frontend.create_order_report_command(Time.local(2009,"feb",2,10,15,1),
    response = checkout_command.send_to_google_checkout    
    puts response
    # puts response.redirect_url    

t =
Nasty Shell
ruby -I /var/lib/gems/1.8/gems/money-2.1.3/lib/ -I ~/src/google-checkout-ruby-sample-code/lib ~/get_order_info.rb |\
  awk --field-separator=',' --exec ~/get_order_info.awk
Nasty Data Sample
Google Order Number,Merchant Order Number,Order Creation Date,Currency of Transaction,Order Amount,Amount Charged,Financial Status,Fulfillment Status
328708331237305,328708331237408,"Feb 20, 2009 3:35:32 AM",USD,0.99,0.00,CANCELLED,WILL_NOT_DELIVER
521483258992859,521481258996859,"Feb 20, 2009 4:38:07 PM",USD,0.99,0.99,CHARGED,DELIVERED
141649937446182,145649937456182,"Feb 20, 2009 10:07:17 PM",USD,0.99,0.00,PAYMENT_DECLINED,NEW
211001643228570,148041643218570,"Feb 21, 2009 2:05:02 PM",USD,0.99,0.00,CHARGEABLE,NEW

Tuesday, February 24, 2009

Started out strong....

I started out this year strong; three books, three weeks. In the following three weeks though, I've dawdled through three books; not completing any of them; one of them I even threw out. So what am I to do?
  1. Wikinomics (Can't read it. Threw it out.)
  2. The Art of Strategy (Sounds interesting but haven't started it.)
  3. Anathem (Too much gobbly gook. I think I'm over Neal Stephenson)
  4. The Maltese Falcon (I'd like to see the movie(s) first.)
  5. The Satanic Verses (I'm 20% finished and having a hard time understanding what is going on).
  6. Insert your suggestion here

So there we have it. Five books that I can think of, off the top of my head that I haven't started reading or am having trouble getting through not to mention the countless

Sunday, February 15, 2009

Vegas, on the Run

Two weeks ago, at the behest of my friend Kevin the both of us along with six others embarked on a last-minute trip to Las Vegas. We started planning at 7:30pm on Friday and less than 12 hours later we were all on a plane headed to the Sin City. Carrie, John, Bill, Liz, Christina, Abbey, Kevin and I were the troopers who went. The trip was fantastic. From the all night drinking session we had Friday night (probably the worst idea of the weekend) and the "GET IN THE VAN. GET IN THE VAN!" super shuttle ride at 5am to the airport all the way through to Champaign brunch at the hotel Sunday morning, airplane cocktails and then finally Italian Beef sandwiches in the Mission that staved off both the end of our trip and an early bedtime there was just never ending amazingness. Props have to be given to Kevin for his dedication to the cause and being unrelenting in getting people (including myself) to go. Condolences must also be given to John for the Devil Sandwich caper that caused his ill health the entire weekend. Arriving Saturday morning required that we steer clear of Abbey's "Lets walk from the Airport" nonsense advice. At the hotel some of use were in zombie mode and required a nap.

So we had zee naps. Then we went out for lunch. Where should we go to lunch? I wouldn't have known; nobody else would have but the call of free Margaritas answered that question for us -- a nice woman handing out fliers for a cheezy tex-mex restaurant provided us with such free things. Lunch was fantastic. To have food, and not booze in my stomach was incredible though only the Salsas were of note. Afterwards we went to New York and I saw the first of my friends (Kevin, John, Bill) doing the gambling thing at the single-deck Blackjack tables. Not quite into the cards thing the remainder of us walked around a bit and found ourselves accosted with small playing cards. Not of baseball players or golfers but rather of blinding flashlights and stars that covered the more private parts of the prostitutes that advertised their services. Walking through throngs of people shoving these in your general direction was quite disquieting and would have likely errupted in violence if the advertisers, at last possible moment, had not retracted their outstretched arms. We continued walking. At the Bellagio fountain the most appropriate music provided a soundtrack for a dancing water display and, the only down point of the weekend, a disgruntled phone conversation between someone and someone else. "My Heart Will Go On!" it proclaimed to the animated motion of pyrotechnic water displays and frustrated gestures of the phone conversationalist.

From there all the way to Paris we traveled with a western stop at Bill's saloon where the most sugary more-than-a-slushy 99 cent Margaritas provided a sugar coma to the few of us who consumed them (not me... I'm not one for sugary drinks; especially those ones). Onward! Forward! We continued on our journey stopping underneath the 5/8ths scale Eiffel Tower, studdering past a midget leprechaun offering cheap bud light and stopping (by way of an outstreched heel at an intersection) a pink Be-Be tracksuit outfitted crazy woman. No, "Excuse me," was not, to her, a suitable request for our slight relocation out of her way. Instead, pushing a dog-laden children's stroller she stuck her tounge out: "Thhhhhbbbbbbbbbttttttt." No sooner did we make way for her was she stopped by another onlooker and bothered for a photo op. Little did we know our brush with a Las Vegas Strip brush with fame. We never did find out who that woman was -- the desire to consult the camera-laden fan never really piqued our interest to cross that intersection; but she will remain famous to us. Headlines: "Pink-track-suited Dog Pusher Raspberries Strangers!" "Tourist with Camera Disappointed by crazy-lady photo op! Says she was not the crazy person they were looking for." "Residents outraged: Woman Pushes Stroller into Stranger. Onlookers Confused"

Forthright we continued on pace to welcome the unknown that was about to confront us. From afar the ever gazing eyes of the Wizard Donnie (Osmond) mocked us from the flamenco themed hotel near our heads. Distracted by the omnipresent eyes we threw money to the wind in exchange for plastic wristbands that went unused. Damn that Donnie Osmund and his confusing ways. In Vegas, money floats through the air but you must offer some to the gods of the winds for the chance (less than 50%, even with the best logic) to paw at the squandered presidential leaves of green that riddle the air currents above your reach.

The Venetian housed a wax Whoopie Goldberg, a faux Nick Cage and imitation Blue Men as the landscape surrounding rolling hills of moving walkways. Only a twitchy arm captured our group's worn photograph; mimicking the dream one of us exclaimed that we were a part of. Through a mall we squandered time none of in the lead but all of us following. Escaping the blue skies of the mall we found a Treasure Island and here it was that I had my first taste of Vegas free booze; It was the most expensive free booze; I'd ever consumed. From $45 dollars ahead of the curve to 45 below I ordered, waited for, then consumed my drink. Cashing in my chips for far less than I had offered for them in the first place, I set my drink down on a building column before we wound our way back down the strip to a Burger Bar.

But no, the draw of food does nothing to hold back the urges of a gravel parking lot "club wear" store. The polution smothered and sooted maniquins outside were ample warning to the scummyness inside. Later we found "Burger Bar" and within it a beer list thicker than the burger-only menu with any topping you could want was the food setting for our Las Vegas dinner. Food was consumed. I had a "Kobe" beef burger with blue cheese, peppered bacon and prosciutto burger. Great burger and beer; sub-par fries.

Full and content we stumbled to our temporary home at the Monte Carlo and it was then that disaster nearly struck. Tired from a day's activities and a night's lack of sleep some of us crashed. Others though could not sleep and with a great insight they went to purchase beer. Even beer did not awaken the sleeping folk but there was someone who would not let this disappointment; someone who dressed the part and made us awaken. Christina was the tour-de-force that got all of us out of that hotel room at a bit past midnight to get to the clubs. From Ceaser's Palace to the Bellagio we moved as the clubs there were holding lines hours long. In the bar right nearby we consumed great drinks and while the music was good a giant table stood in the way of dancing; Kevin, as he is known to do, contacted a friend that was in the city and we were redirected to the Hard Rock Hotel where a great DJ and fun atmosphere led the way for hyjinx. Abbey, Kevin, Liz, Carrie and I were the five AM rockstars that got asked to leave the club when the lights were up and we realized where the hell we were at that ungodly hour (Hard Rock Hotel's Club) but it was Kevin and Liz who stayed the course and did not take to sleep. There was gambling to be done and Kevin would not waver in that efort.

Sunday morning saw the invisible departures of a portion of our crew as life back in the city (Bill was moving) and other travel arrangements (Abbey was flying to New York later that afternoon!) required an painfully early 10am flight out of Vegas. The remaining members of our group still had several hours to kill and took it at a Champaign Buffet where many Mimosa were had by all (except Carrie, whom as we understand it now, prefers Bloody Marys to the delicious Orange Juice and "White Label Andre," champaign.

But this was still not the end of our journey. Through two flights and a layover we continued our journey, sleep coming briefly but dismissed with an excitement that was still not fully depleted. Even after landing in SFO we continued our travels. To the mission we went; some of us consuming the first Itallian Beef we'd had in months; for others it was their first. We consumed or food with zeal washing them down with delicious beers and soon it was time to part ways. Some went North, some went South, others ventured East and the remainder headed west. Dispersing through our city I can hardly recal and as we all reached our homes we welcomed the sleep that we had been ignoring for days -- dreamless from exhaustion and the dream that had been the haze of our recent adventure days.