Wednesday, December 13, 2017

Overrun Inbox? Not today. Bulk Gmail Management from the Command Line

Every so often an errant program (often powered by cron) will flood my inbox with messages. I use Google to manage my e-mail, so this isn't typically a difficult problem to solve. I run a search like this:

label:inbox subject:(cron /usr/local/bin/badscript)

While Google only shows me the first hundred messages there's an option to select all messages, even those not visible. I click this option, hit the archive button, and bam! my inbox is back to usable.

There's a catch to this: the 'select all' option does not exist in Google's Mail app. This means that if I find myself with a overrun inbox and I'm away from a desktop computer, I'm out of luck.

This happened to me after my last vacation. I found myself on an airplane with the chance to respond to e-mail, but an inbox so overwhelmed with cruft that navigating it was painful. While I made do in that scenario, I promised myself I'd come back to this problem and solve it for good. Here's that solution.

I give you: gmail_tool. gmail_tool is inspired by youtube_tool, a command line program for managing YouTube playlists, but with an emphasis on Gmail. In the same way youtube_tool is a curl command line wrapper around Google's YouTube API, gmail_tool connects up curl and the Gmail API.

Here's some examples of it in use:

# Get a list of all messages from John that talk about Linux
# Note that the -q option takes in any valid search that works
# inside of the GMail Search Box. This is powerful stuff.
$ gmail_tool -a list -q "from:john subject:(linux)" 

# Google wants label changes to reference IDs, so get this list of IDs
$ gmail_tool -a labels  | head 
Label_11:designer request
Label_3:foo stuff

# Remove a message from my inbox 
$ gmail_tool -a update -i 1604fdca6faf6497  -r INBOX

# Loop through all messages that meet some search criteria,
# file them under a label and remove them from the inbox.
# The -p insures that all pages of the results will be retrieved,
# not just the first page.
./gmail_tool -p -a list -q 'label:inbox subject:(cron update-foo)' | \
   sed 's/:.*//' | \
  while read id ; do gmail_tool -a update -i $id -l Label_9 -r INBOX ; done

That last recipe is the one I need to rescue my inbox from an exploding script.

I can't tell you how psyched I am to add this tool to my toolbox. I'm actually looking forward to the next time I SPAM myself by accident. There's nothing quite like that feeling of kicking off a single command that replaces tedious work.

You can grab the scripts that power the above here. Feel free to use and customize them as you see fit.

Tuesday, December 12, 2017

Good Friends, Good Hiking and an Epic Simcha

Man, what a weekend.

It started with a delicious lunch with my college buddy Jen in NYC. She works in Times Square, and after lunch, we took a stroll through the surrounding streets. I've been to the area a number of times now, but I still stand in amazement at the diversity and energy in the area.

After lunch, we made our way to White Plains, NY, where we would be celebrating Ariella's Bat Mitzvah! This was a momentous occasion for us, as this was the Bat Mitzvah of the daughter of Shira's oldest friend. Literally, oldest friend (they've known each other since they were born). Shabbat Morning, Ariella just killed it. She lead services, read from the Torah and did a masterful job with her Haftarah. Services were held at Bet Am Shalom, a Reconstructionist shul. I can't recall ever having attended a Reconstructionist service, and I have to admit I was expecting it to be wildly different from the Conservative shul I attend. Instead, I found that the services were nearly an exact match.

Ariella and Keith, both of whom spoke about the weekly Torah portion, had an additional challenge to deal with. Mainly that the topic of the reading was the story of Tamar. As Keith deftly put it, the story of Tamar has less in common with the folksy bible stories you may recall, and more in common with Game of Thrones (and I don't even watch Game of Thrones). Both of them found powerful lessons in this R-rated story.

The Rabbi who conducted Ariella's Bat Miztvah, not only officiated at Becky and Keith's wedding, but officiated at Becky's Bat Mitzvah. With all four grandparents in attendance, and with a set of great grandparents there, one couldn't help but be amazed at the connections on display in front of us. Truly, l'dor v'dor.

Saturday night, we tore up the dance floor and partied as best as a bunch of old folks could (though, can you really call yourself old when Ariella's great-grandparents, who have been married for *74 years* were in attendance?). Mostly we couldn't stop being amazed how the itty bitty bundle of joy we still remember had turned into the young woman in front of us, dancing with her friends. The night, like the service earlier in the day, was just perfect.

As I told Becky, if we ever get a foster placement that needs a Bar/Bat Miztvah planned, our first phone call is going to be to her. What an amazing job she did!

Sunday morning, the responsible thing to do would have been to pack up and head home. But thanks to a friendly salesman at Westchester Road Runner, I had got my hands on a map of the Rockefeller State Park Preserve. The trails were just too enticing not to explore. And so with a couple of inches of snow on the ground, we made our way through this winter wonderland. Sure, it was 35°F, but the perfect snow covered scenery more than made up for the chill in the air.

After a couple of hours of hiking, it was time to call it a trip. I definitely feel like there's more to explore at the Preserve, so I'll be lobbying to get back if we find ourselves in the area.

Monday, December 11, 2017

Weekly Discoveries x3

As a rule, I don't put entire albums in my Weekly Discoveries. Instead, I try to restrict myself to a single song by a given artist. But after watching Odeza perform live on KEXP, and hearing them talk about the best way to appreciate their work, I decided to listening to the entire album a try. And man, does their album A Moment Apart deliver. They take you on quite the diverse musical journey with that album. So pick an hour long task, put on the headphones, and lose yourself in A Moment Apart.

Sure, the music video behind Walk on Water is cheesy. But it's patriotic American cheese. And while some of the faces and scenes in the video are cliche, I give them points for trying to capture our diverse country in a meaningful way.

The visuals in Mr. Probz's Fine Ass Mess feel more like an episode of criminal minds than a music video. But man, there's no denying that he can sing. Sooooooo, smooth. And it looks like our sultry murderer gets hers in the end.

Banner's Someone To You is the high school redemption song I didn't know I needed. If only I had collected up my Trapezoid editing friends to bust some serious moves at Prom, I could have had the same victory as our heroes in this song. And best of all, the video ends with a slight twist that makes for a better than perfect outcome.

Benjamin Booker's Believe has to be seen, to well, be believed. Picture it, a young man in boot camp, trying to make it through a critical training exercise, only to have it interrupted by his younger self dancing his way to victory. Trust me, the video works.

For Shira's birthday, I had visions of a romantic movie date night. Alas, her birthday fell on a packed Monday and my plans of snuggling up to watch a movie would have to wait. Luckily, YouTube delivered a mini version of what I had in mind with 20 Best Romantic Movie Moments. Why watch the whole movie when you can just zip through to watch the good part? And of the scenes in that video what's the most romantic? Why, the When Harry Met Sally scene, of course.

When I first started listening to Saturn by Sleeping at Last I assumed that it was strictly an instrumental piece. The visuals combined with the music totally worked and I was glad to add it to my list. Then the lyrics kicked in and I was more impressed. Then I actually read the lyrics and was even *more* impressed. What a remarkable song about losing someone you love. Any song that contains the lyric: How rare and beautiful it is to even exist is a winner in my book. Definitely worth a listen.

Listen to all the songs: 2017-11-12, 2017-11-26, 2017-12-03.

Thursday, December 07, 2017

Caribbean Cruise Adventure - Day 7 and 8 (The End)

[Composed 11/27/2017]

While there may have been 3,969 passengers aboard the ship, it's not unusual to run into the same folks and strike up a rapport. And so it was with two 'kids' from Iowa that we affectionately called the plank brothers. Technically, they weren't brothers, just friends. And technically they weren't kids, one was 18 and the other was 21, but when you've been married longer than someone is alive, you can safely use the term 'kid.' In fact, they asked us "if we'd been together long." The plank part comes from the way we met them: on the first day of the cruise we were in the weight room working out and they setup next to us. While I was blasting my quads with kettlebells, they pulled up to us to crank out 5 minutes of 'plank.' We continued to see and chat with them around the ship until our last day, when we found ourselves again in the gym.

By now we knew each other and Shira asked if we could join them for their 5 minute ab busting session. And so the timer was set and 'go' was announced. After about a minute and a half I collapsed. After nearly 3 minutes, one of the brothers went down. At 5 minutes, Shira and a young man half her age, were still going strong. Score one for the old people!

Along with our gym time, we caught a talk by the captain and chief engineer, ate the cupcake that Shira decorated during the cupcake decorating "class" (which was mostly a free for all) and generally kicked around the ship remarking just how fast our vacay had flown by. We also tried our hardest to be a contestant on the Perfect Couple game show, but thankfully that didn't work out.

And before we knew it, it was time to catch one last gorgeous sunset, one more soft serve ice cream cone and call it a night. When we awoke the next morning we were docked in Miami. We opted to walk off the ship with our luggage, and spent almost no time waiting in any lines. It was our easiest ship exit to date.

While I was bummed that our cruise was over, we weren't flying out till the next day, so we had the chance to squeeze in one more adventure. While I had visions of hiking through the massive green space on the map that is the Everglades, we settled on a slightly more refined destination: Fairchild Tropical Botanic Garden. The gardens did not disappoint, with remarkable plants, trees and wildlife to keep things interesting. While in the rare plant house we struck up a conversation with a volunteer. He turned out to be a retired biology professor from DC and took us on mini-tour of the greenhouse, showing us his favorite specimens. What a treat!

After the gardens, we met good friends at the Yard House Restaurant, where I drank way too beer thanks to the local sampler they offer. The menu was packed full of tasty vegetarian options. Though given how much alcohol I consumed, I'm not sure how much you should trust me on this.

The next morning, we made our way to the airport where we had an uneventful trip home.

Perhaps I'm showing my age, or maybe it's from staring into the sea, but I've been more aware this trip then ever about the impact of choice while traveling. Take a cruise, for example. Go on a cruise, and you get to see a number of destinations and do so in luxury. But you don't spend enough time in any one place to take it all in. Want to squeeze in as much Cozumel as possible? Then you better skip the party the night before so you can wake up bright and early. I found myself even pondering this on our days at sea: should I step out of my comfort zone by hitting the rock climbing wall or grab a drink and chat it up by the pool? Or, is this perfect time to savor my comfort zone, and sit quietly with my wife while I draw and work on a programming idea. Of course, this balancing act isn't limited to travel, it's at the very core of life itself. For every door you open, there are doors you necessarily close.

Heavy stuff, right?

I don't know what the right answer is. Other than to appreciate the doors you've opened, and respect that you can't open them all.

And I can tell you, we found plenty of great doors to open this trip!


Related Posts with Thumbnails