Automating Android with … Automate

Stumbled on this fantastic app yesterday. It allows you to easily automate many tasks on your Android. I’ll give an example of how simple it is to use – at least for someone with programming experience.

For some time now, I’ve struggled with reading Thai and Chinese. While I can understand spoken Thai and Chinese, reading them had been somewhat a challenge. My previous solution, on receiving such text, was to:

  1. copy the Thai/Chinese text
  2. paste into Google Translate
  3. select the source language (TH or ZH)
  4. click on the audio button to listen

Using, Automate, I’m able to automate that tedious process with the following flow in about half a day’s work:

Read-Foreign-Language languages

The automation flow works as follows:

  1. Create a variable listing all supported languages
  2. Read/watch the clipboard for changes
  3. Ask for desired language: : th, zh, en (see image above)
  4. Send the clipboard content to Google Translate
  5. Listen to the output

A very powerful app indeed.


  1. Download Automate here.
  2. Download Read Foreign Language here.




Better error messages

When programming, I tend to quickly dash off error messages such as: Invalid date: '28-Ap' which is hardly useful from a user’s perspective. The user may not know what do to fix the problem

A better error message should give the user enough information to fix the error. A message like the one below should be more appropriate:
Error: Invalid date format
Change to DD-MMM format: '28-Ap'

A better error message has two parts: 1) state the error precisely and 2) describe how the user can correct the error.

Better error messages, happier users…

musical chairs queue

Was at Klongchan Credit Union (CUKJ) as part of a massive exercise to file a lawsuit against the previous management for embezzlement. The hall was converted for the purpose of streamlining people to the various checkpoints along the route to submit their individual case.

To give a clearer picture, CUKJ has more than 50,000 members, most of them with under 50,000 Bt assets. However, other credit unions in the country also invested with CUKJ due to the fantastic returns (10%). Thus the embezzlement case has massive impact on a broad swath of the lower income segment in this country.

Back to the hall, imagine this – after making copies of documents that you need, you make your way into the hall. At the front of the hall, a row of officers are checking the documents for completeness, explaining things to the elderly and so on. Slightly to the back are rows and rows of chairs occupied with members waiting to submit their documents to be checked. However, there’s no visible queue system – how does it all work?

Standing there for a few minutes, the mystery is revealed. Every now and then, when an officer completed processing a case, someone waiting in the front row get up and walks up to the available officer leaving behind a vacant seat. This vacant seat is filled by the person adjacent to it, leaving behind an empty seat in turn. This is then filled by the next person and so on and so forth until everyone has shifted exactly one seat.

This musical chairs version of a queue is rather amusing. While in the queue, sitting and getting up, it occurred to me that a less strenuous and probably less amusing way to do this is simply to add two flags to the system – one flag labeled HEAD and the other TAIL. When an officer is available, the person holding the HEAD flag gets up and hands the flag to the person next in the queue. When a new person joins the queue, he ends up holding the TAIL queue.

No getting up and down but also less musical. Oh well…

simple programming interfaces documentation

Background: Was helping my brother-in-law with some adobe illustrator scripting yesterday and we happily discovered Javascript scripting in AI. In the comments of this post, gdav provided some links to AI documentation (thanks gdav). The links are reproduced below mostly for my own reference.

1. Scripting Guide:

2. The JavaScript Reference:

The JavaScript Reference is of particular interest. It has a nice clean format to it which I find very suitable for JSON API documentation (something i’ve been meaning to get to for some services I’ve written). Below is a screenshot from the document:


First, the header specifies the object : Artboards – with a short description of what it is. Followed by the properties of the object: Artboards properties; which is documented in a table listing the properties, value type and a short description of the properties. Then the section on methods follow with an equally relevant set of documentation – method signature, parameter type, type of return object and a short description of what the method does.

Nice and neat.