Friday, January 9, 2015

Insert the date and time into the google docs

This is how you insert the date and time to the google docs

1. Go to the Google document/new document.
2. Go to the Tools/Script Editor, and insert the following script at the bottom of the scripts.
This will create a new menu. You can modify the code to change the appearance of the month/date.
3. See the end note to add automated date entry!

The code is available below/ at pastebin.
http://pastebin.com/QFpTRQ3h




function onOpen() {
  var ui = DocumentApp.getUi();
  // Or FormApp or SpreadsheetApp.
  ui.createMenu('Insert Date')
      .addItem('Insert Date', 'insertDate')
      .addToUi();

}

function insertDate() {
  var cursor = DocumentApp.getActiveDocument().getCursor();
  if (cursor) {
      // Attempt to insert text at the cursor position. If insertion returns null,
      // then the cursor's containing element doesn't allow text insertions.
      var d = new Date();
      var dd = d.getDate();
      var hrs = d.getHours();
      var min = d.getMinutes();
      dd = pad(dd, 2)
      var mm = d.getMonth() + 1; //Months are zero based
      mm = pad(mm, 2)
      var yyyy = d.getFullYear();
    var date =  "Date: "+mm + "-" +dd + "-" + yyyy+ "::"+hrs+":"+min +"\n";
      var element = cursor.insertText(date);
      if (element) {
        element.setBold(true);
      } else {
        DocumentApp.getUi().alert('Cannot insert text at this cursor location.');
      }
    } else {
      DocumentApp.getUi().alert('Cannot find a cursor in the document.');
  }

}
function pad (str, max) {
  str = str.toString();
  return str.length < max ? pad("0" + str, max) : str;
}


---
-->

Note:
If you add the following function call inside the onOpen() function:
  insertDate();
Then you will get automated insertion of date and time. Great for logging the daily notes!!!




function onOpen() {
  var ui = DocumentApp.getUi();
  // Or FormApp or SpreadsheetApp.
  ui.createMenu('Insert Date')
      .addItem('Insert Date', 'insertDate')
      .addToUi();

  insertDate();

}

Monday, December 1, 2014

CA welcomes much needed rain

Finally the rain is here in California!
California has seen the worst drought in history (ask @JayFamiglietti, for example!).

I would be interested to see how the map is updated after these rainy couple of days:
http://droughtmonitor.unl.edu/MapsAndData/WeeklyComparison.aspx

Howver, this weekend and through few of the weekdays, we will see some rain. Below I have copied snapshots of weather by NOAA.



The situation is almost like a welcome a song from the Bollywood movie "Lagaan" where they sing to the incoming rain.



Watch the beautiful GOES west view here:
http://www.goes.noaa.gov/goes-w.html
---
-->

Friday, November 21, 2014

How to make interacting robots loveable: allow them to make small harmless mistakes

The other day I was chatting on a chat service to solve some issue. These days the websites offer "instant help" with live agents. Chat bots have become very smart and progress in machine learning for symantics and ontological reasoning has progressed by leaps and bounds. An example: cleverbots
http://www.cleverbot.com/

Anyways, to begin with, I was greeted by a chat bot, which tried best to mimic humanly possible replies: with empathy and dutyfully. What I found to be cute was a typo it was making.
I think allowing the robots make small--harmless mistakes: such as a typo in this case, would make them more personable.

We expect the machines and robots to perform flawlessly. In critical sector that can be highly important. You want to avoid mistakes at 100% and be precise 100% of the time. But, think of interactive machines... so that people are not bored, it would make sense. Don't you love the sound of child making minor mistakes and going "Oh, oo!".  That kind of mistakes.

However, it has to be within the limit of being annoyed though. For example, the first mistake in the chat was OK. The second becomes kind of weird.



---
-->