Dec 26, 2010

Google Spreadsheet + Apps Script = Best Task System Ever

Probably it's same for a lot of people out there.  I always have a lot of chores to do by certain date and I always wanted to have a good program which keeps track of my task list with deadline.  Also it should notify me a daily or weekly summary, preferably via email.

So I've tried a bunch of different things, including GMail Tasks, Google Calendar and some mobile apps.  But neither of those satisfied me. For example, with GMail Tasks, you can't set up email notification, so you will have to remember to open your task list regularly to see if you have anything due this week.  (and trust me, you will always forget it..... well at least I did) With Google Calendar, you can set up email notification, but it makes your Google Calendar looks so messy if you also use it for your personal calendar and you can't easily get a nice list of all the TODO list which you can easily sort in any way you want.  With mobile apps, .... uh..... I'm just not so much mobile phone person and I hate to enter anything on mobile phone.  Gimme a nice full-size keyboard. Then my chubby fingers will be happy...

So with all this failure, I actually gave up.  And I decided to put all my tasks in Google Spreadsheet, instead.  If I had to regularly open a webpage to see my tasks, I wanted it to be just a Google Spreadsheet: I was ready to suck it up.  But later I found there's something called Google Apps Script which allows you to write a JavaScript code with Google API Accessibility.  With this, you can access any of your google docs and do whatever you want to do.  You can even run the script on scheduled time.  So I just made my own script which goes through all the tasks in my TODOs spreadsheet, and emails me the list of tasks which are due in 7 days(or already due in the past).  I get only one email per week, but I can easily change it to daily notification if I see the need.

This is the most efficient personal task program(?) I have had used so far.  It doesn't require me to open a program or go to a webpage to see my task list: all I need is just my webmail account open, which is the case most of the time anyways.

Sometimes, it feels so good to be a programmer lol


Update:
Steve asked for the script.  So here it is.  First, the spreadsheet looks like this:

Note: you can put "done" for tasks you've finished.  These tasks won't be included in your digest email.  Or just delete the row once you are done.


Now the script:


function todoAlert() {
  // tasks due in these days will be shown
  var days = 14;  


  var date = new Date();
  date.setDate(date.getDate()+days);


  var key = "YOUR_SPREAD_SHEET_KEY";
  var docLink = "https://spreadsheets.google.com/ccc?key=" + key;
  var sheet = SpreadsheetApp.openById(key );
  sheet.sort(2, true);
  
  var range = sheet.getDataRange();
  var data = range.getValues();


  var upcoming = "<h3>In " + days + " Days</h3><ul>";
  var nodate = "<h3>No Dates</h3><ul>";
  var sendNodate = false;
  var sendUpcoming = false;
  
  for ( i = 1; i < range.getLastRow(); ++i )
  {
    var task = data[i][0];
    var deadline = data[i][1];
    var status = data[i][2];
    
    var deadlineDate = new Date(deadline);
    // empty
    if ( status != "done" )
    {
      if ( deadline <= 0 )
      {
        sendNodate = true;
        nodate += "<li>" + task + "</li>";
      }
      else if ( deadlineDate <= date )
      {
        sendUpcoming = true;
        upcoming += "<li><b>(" + (deadlineDate.getMonth() + 1) + "/" + deadlineDate.getDate()+ ")</b> - " + task + "</li>";
      }
    }
  } 


  upcoming += "</ul>";
  nodate += "</ul>";
  
  var text = "";
  if ( sendUpcoming )
  { 
    text += upcoming + "<br/>";
  }
  if ( sendNodate )
  {
    text += nodate;
  }
    
  // if set to true, only logger message
  var debug = false;
  if ( text.length > 0 )
  {
    text += "<a href='" + docLink + "'>See TODO List</a>";
    if ( debug )
    {
      Logger.log(text);
    }
    else
    {
      MailApp.sendEmail("YOUR_EMAIL_ADDRESS@gmail.com", "TODOs", text, {htmlBody: text});
    }
  }
}



You need to fill in YOUR_SPREAD_SHEET_KEY and YOUR_EMAIL_ADDRESS.  You can find the key from your spreadsheet's URL look for "&key=blaablaablaa".  Once you add this script in the script editor, you just need to set the trigger.  That's it.


Dec 17, 2010

Merged 2 Blogs Together

I have been maintaining my professional and personal blogs separately for a while.  The main motivation behind this decision was to prevent people from thinking I'm unprofessional after reading my personal blog because I don't live up to other people's fake professionalism.  Also I'm a bit of emo which people don't expect from a professional software engineer.  I was not really afraid of what other people think: I just didn't wanna waste my time to explain.

But I found it was more time-wasting to keep two blogs.  So I merged those two into one, so this blog won't be only focused on game coding anymore.  At least I made new categories called Coding and Personal, so use them to filter out what you are not interested in.

Capice?

Dec 12, 2010

Opening Questrade Account



So I've finally decided to open an account with the cheapest online broker in Canada: Questrade and I was really surprised how easy it was.  (one of the reasons why I finally did it was to shuffle around my TFSA as suggested by this article) It was 2 years ago when I opened an online brokerage account last time with etrade.ca ( now scotiaitrade.com ) and it involved mailing of an application form and a void cheque.  With Questtrade, I was able to use e-signature and online banking bill payment service, instead.  I still had to send my photo ID, but Questrade accepts any document through their file upload system, so I didn't have to send anything via mail!  It is definitely the kind of service I love to use!  (I prefer to deal with business through email and web than in-person... too much hassle, you know)

So I was able to open my account in 15 mins without dropping anything to the red post box! That's exciting.  I'm not sure how I would like Questrade compared to ScotiaiTrade, but according to MillionDallarJourney, it seems promising.  (Oh also there is $50 coupon on that web page, so if you want to sign up, make sure you take advantage of it).

I'll keep you posted how I like Questrade.  (well, I can't help but ranting here if any company sucks, anyways :P )

p.s. btw, don't get confused.  This is not QTrade.

Dec 10, 2010

Coincidental Agreement

It always surprises me how multiple people can come up with same idea independently.  I've always thought that I think independently free from other people's or media's influence.  For that reason, I have very different moral standards from other people.  For that reason, I have very different views on a lot of things.  I think I'm right, but I don't necessarily think other people are wrong: it's right for me, and I don't care what it's for other people.  After all, I'm very individualistic.

The book I'm reading, or listening to, nowadays is Atlas Shrugged. And I'm very surprised to see there was someone (read it as author) who shared same thoughts with me 55 years ago.

Seeing people can come up with the same idea independently, current patent system doesn't sound right...