Tuesday, December 6, 2011

Calendrify your GMail!

Calendrify is not a word, but it should be as it aptly expresses what the following script will do to your Gmail.

It basically allows new mail to be put to sleep until a more appropriate time.  My implementation mirrors the calendrical file system advocated by Merlin Mann of 43 folders.  Whereas any mail can be attached to 1 of 43 different time triggers.  The first 31 signifying the days of the month, the remaining 12 for months of the year.

This actual script is a modification of the Gmail Snooze script written by Corey Goldfeder that I found referenced on LifeHacker.

var MARK_UNREAD = false;
var ADD_REACTIVATED_LABEL = true;
var DAYS_IN_MONTH = 31;
var THREADS_PER_PAGE = 100;
var BACKLOG_ITEM_TOTAL = 43;
var REACTIVATED = "Reactivated"
var BACKLOG = "Backlog";
var BUFFER = "Buffer";
var ENABLE_BUFFER = true;

var monthNames = [ "01-January", "02-February", "03-March", "04-April", "05-May", "06-June",
    "07-July", "08-August", "09-September", "10-October", "11-November", "12-December" ];
 
function getLabelName(i) {
  return BACKLOG + "/" + ((i <= DAYS_IN_MONTH) ? "Day/" + i : "Month/" + monthNames[i-DAYS_IN_MONTH-1]);
}

function setup() {
  // Create the labels we'll need for backlogging
  GmailApp.createLabel(BACKLOG);
  GmailApp.createLabel(BACKLOG + "/Day");
  GmailApp.createLabel(BACKLOG + "/Month");
  
  for (var i = 1; i <= BACKLOG_ITEM_TOTAL; i++) {
    GmailApp.createLabel(getLabelName(i));
  }
  
  if (ADD_REACTIVATED_LABEL) {GmailApp.createLabel(REACTIVATED)}
  if (ENABLE_BUFFER) {GmailApp.createLabel(BUFFER)}
}

function reactivateBacklog() {
 var day = new Date().getDate();
 var label = GmailApp.getUserLabelByName(getLabelName(day));
 reactivateLabel(label);
 
 switch(day) {
  //Check month label on first day
  case 1:
   var month = new Date().getMonth();
   var monthLabel = GmailApp.getUserLabelByName(getLabelName(month + DAYS_IN_MONTH));
   reactivateLabel(monthLabel);
   break;
  //Check for last day, if last, check for threads in remaining label to the 31st
  case 28:
  case 29:
  case 30: 
   function isTodayTheLastDayOfTheMonth() {
    var currentDate = new Date();
    return currentDate.getDate() == new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0).getDate();
   }
   if(isTodayTheLastDayOfTheMonth())
    for(i=day;day <= DAYS_IN_MONTH;i++)
     reactivateLabel(getLabelName(i));
   break;
 }
  
 if (ENABLE_BUFFER) reactivateLabel(GmailApp.getUserLabelByName(BUFFER));
}

function reactivateLabel(label) {
 var page = null;     
 while(!page || page.length == THREADS_PER_PAGE) {
  page = label.getThreads(0, THREADS_PER_PAGE);
  if (page.length > 0) {
   // Unless it's time to reactivate it
   GmailApp.moveThreadsToInbox(page);
   if (MARK_UNREAD) {
    GmailApp.markThreadsUnread(page);
   }
   if (ADD_REACTIVATED_LABEL) {
    GmailApp.getUserLabelByName(REACTIVATED)
      .addToThreads(page);
   }
  } 
  // Move the threads out of label
  label.removeFromThreads(page);
 }
}

Follow the same instructions listed below from Goldfeder's post on how to install Gmail Snooze to install Calendrify.  With the exception of replacing "moveSnoozes" with "reactivateBacklog".
If you don't know how to setup a script, it's pretty simple. Create a new Google Spreadsheet, and choose "Script Editor" from the "Tools" menu. Paste in all of the code from above and then click the “Save” button and give it a name. In the dropdown labeled "Select a function to run," choose "setup" and click the blue run arrow to the left of it. This will ask you to authorize the script, and will create the necessary labels in your Gmail. Then go to the "Triggers" menu and choose "current script's triggers." Click the link to set up a new trigger, choosing the "moveSnoozes" function, a "time-driven" event, "day timer," and then "midnight to 1am." Click save and you are done. 

Monday, October 3, 2011

McDonald's Monopoly

As mentioned in the post about Dannon's yogurt sweepstakes, ole Mickey D's is at again.

If you so choose chase the dangling McCarrot then here are a couple of sites for to let you know your odds, and any strategies you may want to take.

Try bargaineering for the most comprehensive info.

Click here for a less exhaustive entry.

Friday, August 12, 2011

Dannon Rewards 2011: Winning Letters!

Whether it's collecting 'Monopoly' property from McDonald's, or lids with letters atop Dannon yogurt containers, it's all the same game.

I can't deny that I fall for this gimmick every time as I believe that I have somehow coincidently gathered most of the required tokens. It's just that last one that seems to allude me every time. But not only is it always out of my reach, but the corporation behind it's existence (or non-existence) is intentionally jerking me around. Much like extending the carrot to control the ass.

So what are the carrots of this year's Dannon's Collect, Spell & Win sweepstakes. Well there is one for every winning word.

P-U-R-I-S-T (Caribbean trip)
S-W-I-R-L-E-R (Cooking set)
S-A-V-O-R-E-R (Book Reader)
D-I-G-G-E-R (GPS)
M-I-X-E-R (Music Gift card)

That's right the winning letters are P, W, V, D and X. And chances are that you do not have either of them, no matter where you bought your yogurt.

If you do have any of them, then you have assuredly won, and need to make arrangements to get the letters. Trust me, there plenty of the others out there. I think I have most of them.

If nothing else, at least the yogurt's good.