Mr.

My Random Walk by Martin Ruiz

JDRF Ride for a Cure

My 100 bike ride through Death Valley to help raise money for the Juvenile Diabetes Research Foundation (JDRF) is quickly approaching.

Want to virtually ride along with me?

I created the video above of the Death Valley course using Google Streets, Hyperlapse and a little hacking.

10 million children and adults live with Type 1 diabetes in the US alone. For many years my wife and I have been helping JDRF fight this terrible disease. We’ve never worked with a more passionate and dedicated group of people. My wife and I aren’t cyclists… and you don’t have to be. We simply want to inspire others to help.

Please donate to my campaign

The music accompanying the video is from my daughter’s band, Petal War.

It’s Black and White

28th August 2013

http://www.youtube.com/watch?v=HRIF4_WzU1w

I just read about Yolanda Spivey, a Black job applicant who received more responses with an identical resume under a fake white profile, “Bianca White”. Surprised?

It’s been 50 years since Martin Luther King Jr’s, “I have a Dream” speech and sadly we continue to struggle with racism.

Sidebar… some anecdotes

While in college in the early 90’s I took a few courses on race and recall the confusion and profound sadness I felt as I studied the history. The concept of “white privilege” was really hard to accept. I took these courses shortly after 2 incidences I experienced within 6 months of starting studies at Cornell.

The first was during a night out with friends where racial slurs were hurled at us from a distance. It was too far to make out the faces and besides my instincts were to quickly move away from the problem.

The second happened as I visited my mother at the hospital. There were young white males at the hospital at the time, but a white doctor had me searched and detained by hospital security because his wallet was missing. Incidentally, I was wearing a Cornell jacket. Not that this should make any difference, except that I can’t help assume that if the doctor had considered the other young males present, he would have certainly discounted any wearing a CU jacket. He found his wallet. I could tell he felt terrible about making the accusation. He apologized profusely and offered to let me observe his surgeries as consolation.

Both situations left me thinking about how deep racism runs. In one case, some kids felt safe enough to fling slurs, in the second the doctor appeared to not be aware of what he was doing - and - everyone played along, including me. At the time, I felt that resisting would cause more trouble and make me appear guilty. Looking back, I probably should have protested.

Hardly a year goes by where I don’t experience or read something that reminds me of how far we still have to go.

Protest

Back to Yolanda Spivey… In her own way she protested. Perhaps in the best way possible. By proving her point.

Specifically what she found was that

Identifying as White is more favorable than identifying as a minority OR not identifying at all.

It’s subtle, but ‘not identifying’ her race and ethnicity was a very important part of her experiment. It strongly rules out chance and shows that race is a factor. It also accounts for other factors like percent of white applicants to non-whites etc.

However, there are some important questions not addressed by Yolanda. What were the profiles of the candidates that were contacted when she was not contacted. Were they non-white, more qualified? Unlikely.

This reminds of an episode of the talk show Phil Donahue I saw while in High School about a White male who was suing his city for preferential treatment of non-white applicants by the police academy. Apparently he had received a perfect score on the police entrance exam but was not accepted. His claim was that less qualified non-white applicants had taken his spot. The obvious point that struck me as I watched it but that no one addressed was the fact that not all white applicants had received a perfect score. It would seem then that less qualified whites were selected above him, and yet he felt the need to target non-whites. I’ve observed this phenomenon again and again since.

So does this happen to non-whites, particularly in Yolanda’s case?

We can’t know for sure but the random nature of her experiment suggests otherwise. You see it would be less likely that race was not a factor - and - more qualified non-white’s were contacted instead of her - and - that callbacks increased by chance when she identified as white.

Progress

We’re also forced to speculate about the profile of hiring managers and candidates that got callbacks.

  • Are non-whites more or less likely to hire non-whites than whites are? Does this matter?

What’s clear is

  • there are less non-white hiring managers than white hiring managers
  • less non-white applicants than white applicants

I wonder whether we’ll make progress as more non-whites enter the workforce and eventually make it to the management ranks. I think so.

But what about Barack Obama?

He got the top job.

Sure there’s progress, albeit not enough, but some none the less. However, this is the argument we’ve heard and we’ll hear at every step of the way.

But what about…

  • they read
  • they’re free
  • they vote
  • civil rights
  • mlk
  • affirmative action
  • in college
  • and more…

All steps in the right direction, but what about a basic job? What about Yolanda? Few things bring more freedom to an individual as does a basic job. We have work to do.

Let MLK remind you of where we need to be.

Easier iPad and iPhone Keyboard Shortcuts

25th August 2013

iphone keyboard shortcuts

I use keyboard shortcuts on my ipad/iphone. I also use a bluetooth keyboard with my ipad. However, over time my shortcuts have gotten out of control. There are so many, I can’t remember them all, which brought be back to the beginning.

I’ll show you how I use repeating characters to simplify my shortcuts.

1. Reboot

Start fresh… and delete them all.

Like Email Hell sometimes the best thing to do is to purge and start over.

2. Use repeating characters… hmmm!

Use repeating character rather than character combinations. They’re easier to remember.

For instance… I’ve been using qq for my contact info/email signature.

qq resolves to @MartinRuiz | 212.920.6404 | http://martinruiz.com

3. Leverage keyboard auto-correct/shortcuts suggestions… ahhh!

Notice the popup suggesting the correct spelling as you type.

iphone repeating character shortcuts

You can combine this feature with repeating characters to walk through a series of suggestions. cool?

For instance, I don’t always want to give the long version of my contact info. So I’ve expanded qq for more options.

qq @MartinRuiz | 212.920.6404 | http://martinruiz.com
qqq Martin Ruiz
qqqq @MartinRuiz
qqqqq 212.920.6404
qqqqqq http://martinruiz.com

I’ve also used it for writing markdown documents.

hh #
hhh ##

and my common hash tags

ll #mailbox 
lll #work 
llll #dev 
lllll #salsa 
llllll #band 
lllllll #javascript 
llllllll #hft 

and for snippets I txt my wife as i’m coming home from work

dd Coming home
ddd Crossing bridge
dddd On Lincoln

4. Advanced usage: alternate characters for menus… aha!

You can alternate 2 characters to get a cascading menu effect.

It takes some setting up but it could be really helpful.

Consider markdown, if I haven’t written a post in a while, I forget some detail about markdown syntax.

I repeat t to walk through menu then type y when I want to drop into that menu.

tt {header-#}
tty #
ttyy ##
ttyyy ###
ttt {list-*,-,1.}
ttty *
tttyy -
tttyyy 1.
tttt {bold-** **}
tttty ** **
ttttt {italics-__ __}
ttttty __ __
tttttt {link-[](http://)}
tttttty [ ](http:// )
ttttttt {photo-![]()}
ttttttty ![ ](http:// )
tttttttt {blockquote->}
tttttttty >

The series of ts looks a little long and messy, but it’s surprisingly easy to set up.

Let me know if you find other uses for repeating char keyboard shortcuts.

20 Good Years

Today marks 20 years since my wife and I were married.  We’re just getting started!

20 things…

Married Friday 13th of August 1993.
We still occasionally celebrate our month-a-versary, the 16th.
We met at Cornell… at the campus bookstore.
First date… on first day we met was at the dining hall:)
We remember our first kiss.
We’ve had many songs, but our first was “Heaven” by Brian Adams.
Another early song was “Love Bites” by Def Leppard.
Her first gift to me was a record by the Mexican Balladeer, Emmanuel.
We were married in city hall…  too broke for a fancy wedding.
The few bucks we did have, we spent on a honeymoon to Spain.
Our Honeymoon in Spain was a bus tour with folks 3 times our age.
We have 2 awesome kids…
Our daughter is almost as old as we were when we met.
My wife lost a bet over 20 years ago that’s she’s yet to repay:)
Since married, we’ve never been apart for more than a week.
However, One year, we both forgot our anniversary. 
The past 5 years may be the best so far.
I’m proud of my marriage.
I love my wife.
I know the secret to a happy marriage!
20 Good Years

Today marks 20 years since my wife and I were married.  We’re just getting started!

20 things…

Married Friday 13th of August 1993.
We still occasionally celebrate our month-a-versary, the 16th.
We met at Cornell… at the campus bookstore.
First date… on first day we met was at the dining hall:)
We remember our first kiss.
We’ve had many songs, but our first was “Heaven” by Brian Adams.
Another early song was “Love Bites” by Def Leppard.
Her first gift to me was a record by the Mexican Balladeer, Emmanuel.
We were married in city hall…  too broke for a fancy wedding.
The few bucks we did have, we spent on a honeymoon to Spain.
Our Honeymoon in Spain was a bus tour with folks 3 times our age.
We have 2 awesome kids…
Our daughter is almost as old as we were when we met.
My wife lost a bet over 20 years ago that’s she’s yet to repay:)
Since married, we’ve never been apart for more than a week.
However, One year, we both forgot our anniversary. 
The past 5 years may be the best so far.
I’m proud of my marriage.
I love my wife.
I know the secret to a happy marriage!

20 Good Years

Today marks 20 years since my wife and I were married. We’re just getting started!

20 things…

  1. Married Friday 13th of August 1993.
  2. We still occasionally celebrate our month-a-versary, the 16th.
  3. We met at Cornell… at the campus bookstore.
  4. First date… on first day we met was at the dining hall:)
  5. We remember our first kiss.
  6. We’ve had many songs, but our first was “Heaven” by Brian Adams.
  7. Another early song was “Love Bites” by Def Leppard.
  8. Her first gift to me was a record by the Mexican Balladeer, Emmanuel.
  9. We were married in city hall… too broke for a fancy wedding.
  10. The few bucks we did have, we spent on a honeymoon to Spain.
  11. Our Honeymoon in Spain was a bus tour with folks 3 times our age.
  12. We have 2 awesome kids…
  13. Our daughter is almost as old as we were when we met.
  14. My wife lost a bet over 20 years ago that’s she’s yet to repay:)
  15. Since married, we’ve never been apart for more than a week.
  16. However, One year, we both forgot our anniversary.
  17. The past 5 years may be the best so far.
  18. I’m proud of my marriage.
  19. I love my wife.
  20. I know the secret to a happy marriage!

Wunderlist Tags Hack

5th May 2013

Wunderlist is a task management tool. I’ve been using it for a bit to manage my tasks. I love it’s simplicity, interface, and that it’s available for mobile and browswer.

I have also been using GQueues. The one feature I love about GQueues is the ability to tag tasks. For the moment this feature is missing from Wunderlist. Enter the Tags Hack.

Quick #Tags Hack

To work around this short coming I use a combination of hash tags in the task description and the search facility within Wunderlist.

Suppose I enter a task to buy plantains at the local bodega that I want to tag “groceries”, I might create a task with description “buy dozen plantains #groceries”. I could similar tasks to a “grocery” list, but with the “#groceries” hash tag, we can simply search for “#groceries”. ()Note that the mobile apps do not have a search feature, however, browser version on the ipad appears to work pretty well.)

Bonus: For quick access to #groceries you can bookmark the url of the search query, i.e., http://www.wunderlist.com/#/search/#groceries.

The Matrix - Bullet Time in Analog, Slinky, and Edgerton

26th April 2013

The Matrix - Bullet Time - Homemade

The video is an “Analog” version of The Matrix - Bullet Scene. It took a fair amount of creativity to figure out the effects without CGI. Almost as much creativity as it took to make it with CGI!

It’s purely coincidental that The Slinky was invented around 1940, near the time MIT professor Doc Edgerton used strobe lights to capture the iconic photos of bullets. Watch the video for the connection…

Slinky circa 1946

Slinky circa 1946

Professor Edgerton’s Iconic Bullet Photos

Edgerton Bullet Photo

More Edgerton Photos

Mothers and the Sound of the Big Bang

I’m a father of two wonderful kids, always sharp and inquisitive.  The kids that is.  Unfortunately, they have homework and a knack for tapping into life’s vast well of unanswered questions.  So as a dad, I try desperately to stay one step ahead of them.  That’s all likely to change some day.  In the meantime, with a little Google juice I can usually find the answer I need and retain my crown as Champ of “whatever the subject may be”… at least to my kids.

We’ll Google doesn’t always have what you’re looking for.  So what does a dad do when he can’t find what he’s looking? Not sure. But kids are resourceful, they escalate and ultimately go to Google’s toughest competition, Mom.

Mom’s

When 11 year old Daniel asked “What did the Big Bang sound like?”, his mom went to guy who made a big stink about the thing but never produced the Universe’s Epic Soundtrack.

Enter Professor John G. Cramer of the University of Washington.  When a “Mom” asks for something, you best deliver it.  And that’s what John did.  So now you have it, the sound of the first 760,000 years of evolution of the universe.  Thanks to a Mom, or a Dad who fell a little short:)  Maybe Daniel get’s some credit for asking.

The Big Bang Soundtrack



More about it here.

And if you’re kid asks, “How did the Big Bang make that sound?”, Prof Cramer has your back.  Here’s what he said…


  The Big Bang Sound in the simulation is derived from the sound propagating as compression waves through the plasma/hydrogen medium of the early universe some 100 to 700 thousand years after the initial Big Bang. The density of this medium was changing as the universe expanded, but should have been considerably more dense than air on our little planet. One does NOT need air to have sound, only some medium in which compression/rarefaction waves can propagate. The sound waves were very low in frequency and had wavelengths comparable to some fraction of the size of the universe. For the convenience of humans, who could not hear such low frequencies, I have increased them to the audio range of the human ear. - John G. Cramer - Analog Science Fiction and Fact


Good luck at the Science Fair.

(Photo includes my son, Lucas at his science fair) Mothers and the Sound of the Big Bang

I’m a father of two wonderful kids, always sharp and inquisitive.  The kids that is.  Unfortunately, they have homework and a knack for tapping into life’s vast well of unanswered questions.  So as a dad, I try desperately to stay one step ahead of them.  That’s all likely to change some day.  In the meantime, with a little Google juice I can usually find the answer I need and retain my crown as Champ of “whatever the subject may be”… at least to my kids.

We’ll Google doesn’t always have what you’re looking for.  So what does a dad do when he can’t find what he’s looking? Not sure. But kids are resourceful, they escalate and ultimately go to Google’s toughest competition, Mom.

Mom’s

When 11 year old Daniel asked “What did the Big Bang sound like?”, his mom went to guy who made a big stink about the thing but never produced the Universe’s Epic Soundtrack.

Enter Professor John G. Cramer of the University of Washington.  When a “Mom” asks for something, you best deliver it.  And that’s what John did.  So now you have it, the sound of the first 760,000 years of evolution of the universe.  Thanks to a Mom, or a Dad who fell a little short:)  Maybe Daniel get’s some credit for asking.

The Big Bang Soundtrack



More about it here.

And if you’re kid asks, “How did the Big Bang make that sound?”, Prof Cramer has your back.  Here’s what he said…


  The Big Bang Sound in the simulation is derived from the sound propagating as compression waves through the plasma/hydrogen medium of the early universe some 100 to 700 thousand years after the initial Big Bang. The density of this medium was changing as the universe expanded, but should have been considerably more dense than air on our little planet. One does NOT need air to have sound, only some medium in which compression/rarefaction waves can propagate. The sound waves were very low in frequency and had wavelengths comparable to some fraction of the size of the universe. For the convenience of humans, who could not hear such low frequencies, I have increased them to the audio range of the human ear. - John G. Cramer - Analog Science Fiction and Fact


Good luck at the Science Fair.

(Photo includes my son, Lucas at his science fair)

Mothers and the Sound of the Big Bang

I’m a father of two wonderful kids, always sharp and inquisitive. The kids that is. Unfortunately, they have homework and a knack for tapping into life’s vast well of unanswered questions. So as a dad, I try desperately to stay one step ahead of them. That’s all likely to change some day. In the meantime, with a little Google juice I can usually find the answer I need and retain my crown as Champ of “whatever the subject may be”… at least to my kids.

We’ll Google doesn’t always have what you’re looking for. So what does a dad do when he can’t find what he’s looking? Not sure. But kids are resourceful, they escalate and ultimately go to Google’s toughest competition, Mom.

Mom’s

When 11 year old Daniel asked “What did the Big Bang sound like?”, his mom went to guy who made a big stink about the thing but never produced the Universe’s Epic Soundtrack.

Enter Professor John G. Cramer of the University of Washington. When a “Mom” asks for something, you best deliver it. And that’s what John did. So now you have it, the sound of the first 760,000 years of evolution of the universe. Thanks to a Mom, or a Dad who fell a little short:) Maybe Daniel get’s some credit for asking.

The Big Bang Soundtrack

More about it here.

And if you’re kid asks, “How did the Big Bang make that sound?”, Prof Cramer has your back. Here’s what he said…

The Big Bang Sound in the simulation is derived from the sound propagating as compression waves through the plasma/hydrogen medium of the early universe some 100 to 700 thousand years after the initial Big Bang. The density of this medium was changing as the universe expanded, but should have been considerably more dense than air on our little planet. One does NOT need air to have sound, only some medium in which compression/rarefaction waves can propagate. The sound waves were very low in frequency and had wavelengths comparable to some fraction of the size of the universe. For the convenience of humans, who could not hear such low frequencies, I have increased them to the audio range of the human ear. - John G. Cramer - Analog Science Fiction and Fact

Good luck at the Science Fair.

(Photo includes my son, Lucas at his science fair)

Bike Fitting for JDRF Ride to Cure Diabetes

Next October I’ll be riding 100 miles through Death Valley for the JDRF - Juvenile Diabetes Research Foundation.

10 million children and adults live with Type 1 diabetes in the US alone.  For many years my wife and I have been helping JDRF fight this terrible disease.  We’ve never worked with a more passionate and dedicated group of people.  My wife and I aren’t cyclists… and you don’t have to be.  We simply want to inspire others to help.

The Bike

I have a few friends who are very serious cyclists.  They told me 100 miles through Death Valley will be grueling.  The 2 pieces of advice they’ve all given are;

Get the best bike you can - make sure it’s right for you.
Ride Forest, Ride… You got to put in the miles.
I can’t do the second(ride) without the first(bike) so I went for a fitting.  Based on my goals, weight, height, flexibility, power, alignment and more, Blake at http://signaturecycles.com measured me for the ideal bike.  It took about 2 hours.  And I’ll have to go back for tweaks once I’ve found the right bike.

They boiled it down to 3 bikes…

Parlee Z5 Small Tall @parlee_z1
Specialized Roubaix 53cm @iAmSpecialized
Trek Domane 5/6 Series 52cm @TrekBikes
Any of these will fit me just right.  But these engineering marvels are not cheap, so I’m looking for a used one.  Please, Please, Please let me know if you know of one.

Email or Tweet Me with your recommendation.

I’ll keep you posted on my training.  Follow me @MartinRuiz

There was one more piece of advice I’ve heard time and time again… Spare no expense on extremely well padded shorts.  Makes sense.

Good luck to us:)

Please donate to my personal Fund Raising Campaign

Go to http://www2.jdrf.org/goto/MartinRuiz

About JDRF Ride to Cure Diabetes

http://www.youtube.com/watch?v=SwX5xOZwbiw

For more about the JDRF Rides check out http://ride.jdrf.org Bike Fitting for JDRF Ride to Cure Diabetes

Next October I’ll be riding 100 miles through Death Valley for the JDRF - Juvenile Diabetes Research Foundation.

10 million children and adults live with Type 1 diabetes in the US alone.  For many years my wife and I have been helping JDRF fight this terrible disease.  We’ve never worked with a more passionate and dedicated group of people.  My wife and I aren’t cyclists… and you don’t have to be.  We simply want to inspire others to help.

The Bike

I have a few friends who are very serious cyclists.  They told me 100 miles through Death Valley will be grueling.  The 2 pieces of advice they’ve all given are;

Get the best bike you can - make sure it’s right for you.
Ride Forest, Ride… You got to put in the miles.
I can’t do the second(ride) without the first(bike) so I went for a fitting.  Based on my goals, weight, height, flexibility, power, alignment and more, Blake at http://signaturecycles.com measured me for the ideal bike.  It took about 2 hours.  And I’ll have to go back for tweaks once I’ve found the right bike.

They boiled it down to 3 bikes…

Parlee Z5 Small Tall @parlee_z1
Specialized Roubaix 53cm @iAmSpecialized
Trek Domane 5/6 Series 52cm @TrekBikes
Any of these will fit me just right.  But these engineering marvels are not cheap, so I’m looking for a used one.  Please, Please, Please let me know if you know of one.

Email or Tweet Me with your recommendation.

I’ll keep you posted on my training.  Follow me @MartinRuiz

There was one more piece of advice I’ve heard time and time again… Spare no expense on extremely well padded shorts.  Makes sense.

Good luck to us:)

Please donate to my personal Fund Raising Campaign

Go to http://www2.jdrf.org/goto/MartinRuiz

About JDRF Ride to Cure Diabetes

http://www.youtube.com/watch?v=SwX5xOZwbiw

For more about the JDRF Rides check out http://ride.jdrf.org

Bike Fitting for JDRF Ride to Cure Diabetes

Next October I’ll be riding 100 miles through Death Valley for the JDRF - Juvenile Diabetes Research Foundation.

10 million children and adults live with Type 1 diabetes in the US alone. For many years my wife and I have been helping JDRF fight this terrible disease. We’ve never worked with a more passionate and dedicated group of people. My wife and I aren’t cyclists… and you don’t have to be. We simply want to inspire others to help.

The Bike

I have a few friends who are very serious cyclists. They told me 100 miles through Death Valley will be grueling. The 2 pieces of advice they’ve all given are;

  1. Get the best bike you can - make sure it’s right for you.
  2. Ride Forest, Ride… You got to put in the miles.

I can’t do the second(ride) without the first(bike) so I went for a fitting. Based on my goals, weight, height, flexibility, power, alignment and more, Blake at http://signaturecycles.com measured me for the ideal bike. It took about 2 hours. And I’ll have to go back for tweaks once I’ve found the right bike.

They boiled it down to 3 bikes…

  1. Parlee Z5 Small Tall @parlee_z1
  2. Specialized Roubaix 53cm @iAmSpecialized
  3. Trek Domane 5/6 Series 52cm @TrekBikes

Any of these will fit me just right. But these engineering marvels are not cheap, so I’m looking for a used one. Please, Please, Please let me know if you know of one.

Email or Tweet Me with your recommendation.

I’ll keep you posted on my training. Follow me @MartinRuiz

There was one more piece of advice I’ve heard time and time again… Spare no expense on extremely well padded shorts. Makes sense.

Good luck to us:)

Please donate to my personal Fund Raising Campaign

Go to http://www2.jdrf.org/goto/MartinRuiz

About JDRF Ride to Cure Diabetes

http://www.youtube.com/watch?v=SwX5xOZwbiw

For more about the JDRF Rides check out http://ride.jdrf.org

Better Mailboxapp GMail Integration

9th April 2013

Mailboxapp

I love the Mailboxapp mobile email client. It’s simple, clean and very effective. But it’s missing a few things for me. With a little Google Apps Scripting I was able to make a few improvements.

What’s Missing in Mailboxapp? (for me)

  • Robust GMail Labeling
    Currently Mailboxapp only allows you to use sublabels under the [Mailbox] label.
  • Marking as SPAM I want to move messages in [Mailbox]/Spam to Spam label.
  • Easy forwarding
    I want to create tasks in Wunderlist and forward emails to work.

Google App Script

Google App Script allows you to write javascript apps and hook into Google APIs like Gmail.

Check out https://developers.google.com/apps-script/your_first_script for documentation and a video tutorial.

Before using Google App Script, I tried to do some of this using ifttt… It almost did the trick but I couldn’t quite get it to work.

Using Google App Script I was able to leverage the Gmail Script API. I was also able to schedule the script to run once every minute.

Robust GMail Labeling

Now I’ll show you how I handled GMail Labeling, i.e., moving messages from [Mailbox]/>labelName to labelName. Note the script creates labelName if it doesn’t already exist.

First I set some variables like where to forward emails and some regex to identify which folders to label/archive. I also create a simple Gmailapp API wrapper to reduce API calls.

var WORK_EMAIL = 'martin.ruiz@wellsfargo.com';
var WORK_LABEL = 'Fwd To Work';
var MAILBOX = '[Mailbox]';
var ARCHIVE_PREFIX = '>';
var MAILBOX_ARCHIVE_REGEX = new RegExp('^\\[Mailbox\\]/' + ARCHIVE_PREFIX);
var MAILBOX_REGEX = new RegExp(/^\[Mailbox\]\/\>/);
var TODO_LABEL = 'Todo';
var TODO_EMAIL = 'me@wunderlist.com';
var MESSAGE_URL_BASE = 'https://mail.google.com/mail/u/0/#all/';
var SPAM_LABEL = 'Spam';
/**
 * A simple wrapper for GmailApp API so I can minimize the
 * number of API calls and keep it below the service limit.
 * 10,000 calls is the limit.  Using this wrapper I cache
 * the results and reuse across function calls.
 * https://developers.google.com/apps-script/class_gmailapp
 */
var Gmail = (function () {
  var labels = GmailApp.getUserLabels();
  var labelMap = {};

  for (var i in labels) {
    var label = labels[i];
    labelMap[label.getName()] = label;
  }

  var getLabelByName = function (labelName) {
    return labelMap[labelName];
  };

  return {
    getUserLabels: function () { return labelMap; },
    getUserLabelByName: getLabelByName
  };
})();

The following code moves messages in [Mailbox]/>labelName to labelName. I use the prefix, >, to identify labels I want to archive. Every minute messages are archived and cleared.

/**
 * archives messages in [Mailbox]/>labelName to
 * labelName.  It also sets the message as read.
 * Note that I use '>' to signal which labels to
 * archive.
 */
function archiveMessages(labelName) {
  var label, archiveLabel, page, mailboxLabel;

  mailboxLabel = MAILBOX + '/' + ARCHIVE_PREFIX + labelName;

  label = Gmail.getUserLabelByName(mailboxLabel);
  archiveLabel = Gmail.getUserLabelByName(labelName);
  // create labelName if it doesn't exist
  if (!archiveLabel) {
    archiveLabel = GmailApp.createLabel(labelName);
  }

  page = null;

  while(!page || page.length == 100) {
    page = label.getThreads(0, 100);
    if (page.length > 0) {
      archiveLabel.addToThreads(page);
      label.removeFromThreads(page);
      GmailApp.markThreadsRead(page);
    }
  }
}

function doArchive() {
  var labelName, labels;

  labels = Gmail.getUserLabels();

  // find and archive all labels in [Mailbox] with '>' prefix
  for (labelName in labels) {
    if (MAILBOX_ARCHIVE_REGEX.test(labelName)) {
      labelName = labelName.replace(MAILBOX_ARCHIVE_REGEX,'');
      archiveMessages(labelName);
    }
  }
}

You can find the rest of the code here.

To install, cut-n-paste-modify code in a new script @ script.google.com. Click on clock to schedule runMailboxCompanion every minute.

Email me at mr.ruiz@gmail.com if you have any questions

Next Steps

  • add simple UI to configure.
  • make available as installable plugin/script.
  • add some new features like auto-filter creator for scheduling. There are some emails I only want to read on weekends or evenings etc. I want to write a script that creates a filter for emails labeled [Mailbox]/Weekend that skips inbox and moves messages back to inbox on weekends. This way I don’t have to do manually everytime.
Load More