Thursday, November 20, 2014

Add date and time to a Google spreadsheet document with one click

There is a keyboard shortcut to add the current date to a cell in a Google spreadsheet. But it will not enter the current time. Here's my solution. It adds a simple menu item in your spreadsheet that enables you to enter the current date and time with one click.

  1. Open the Tools menu and choose Script Editor
  2. Copy and paste the following text:
  3. function onOpen() {
      var spreadsheet = SpreadsheetApp.getActive();
      var menuItems = [
        {name: 'Add date and time', functionName: 'addDateTime'}
      spreadsheet.addMenu('AddDateTime', menuItems);
    function addDateTime() {
      var ss = SpreadsheetApp.getActiveSpreadsheet();
      var sheet = ss.getSheets()[0];
      var cell = ss.getActiveCell().setValue(new Date());
  4. Click the save button to save your script, then reload your document for the changes to take effect.
  5. Select the row or the cell in your spreadsheet where you want to add your data. From the Format menu, choose Number and then choose Date/Time. If you omit this step, it will only show the date without the time.
  6. Now select the cell where you want to add the current date. In the menu bar, look for a menu on the right that says AddDateTime. Click Add date and time to add the current date and time.

Sunday, June 16, 2013

When to use <b>, <strong>, <i> and <em>, and how to use them correctly

With the newest HTML 5 specification, there are lots of tags to format and mark portions of inline text to choose from. This sure causes some confusion, such as for the <bold> and <emphasis> tags. Which tag should you use, when should you use it and why? In the following lines, I will address the issue of <b> vs. <strong> vs. <i> vs. <em>.

Saturday, June 15, 2013

Log out from Google search, but stay logged in on YouTube at the same time

Do you want to stay logged out on Google search for privacy reasons, while staying logged in on other Google services such as YouTube, Blogger or Gmail? It seems to be impossible because when you log on to any Google account, Google will automatically log you on for all its services at the same time, and when you log out, you're logged out everywhere. You can overcome this with a little trick:

Tuesday, April 9, 2013

Static HTML vs JavaScript dynamic generation - which is faster?

Say you have a page containing a huge amount of data - a list of 1000 customers or products. Such a list may take a long time to render. I always wondered if it's actually faster to render the page using a clever JavaScript loop instead of one big chunk of static HTML. So I did a small benchmark to determine which method renders faster.

Monday, April 8, 2013

Run js-beautify, css-beautify and html-beautify from Notepad++

I discovered a way to integrate js-beautify with Notepad++. This way, you can beautify your HTML, CSS and JavaScript directly in Notepad++. There are other plugins for beautifying web code for Notepad++, but js-beautify is the best in my opinion. Since it has no plugin available for Notepad++, we'll have to kludge together our own solution.

Sunday, April 7, 2013

Very simple pure CSS collapsible list without JavaScript

Lately, I stumbled upon this great article on The CSS Ninja. It shows a technique for pure CSS collapsible lists, without any JavaScript. It works for all modern browsers. With Internet Explorer 8 or older though, it's not possible with pure CSS. These browsers need to emulate CSS pseudo-classes by adding a small JavaScript fix to the page, which I demonstrate at the bottom of this article.