Jan 30, 2015

On App Building Solutions

Facebook's answer to cross platform app development:

A Deep Dive on React Native

I dragged through the whole presentation, still some good ideas caught my attention.

  1. Make use of platform tool kit instead of emulating them with HTML5.
  2. Use a custom layout engine to build the view tree.
  3. Incremental tree rebuild.

Happy to see the industry looking for more pleasant ways of building apps. I have also been thinking on the problem for quite a while.

My wish list for an ultimate solution (at least for the next 30 years):

  1. App can be inspected and changed on the fly, no need to relaunch for non-primitive modifications. Think of how sculptors work, or even better, gardeners.
  2. Built-in revision control. git still feels too heavy.
  3. One source and can be adapted to different platforms. Think of how we use CSS prefixes for different platforms. Not pretty, but useful.
  4. Auto recalculation, connection between state and display elements should be seemless. Think of Excel.
  5. Text editors are no longer our primary tools.
  6. Stay close to metal.

One more thing, javascript won't be fundamental in my solution, because it's just not simple enough.

Jan 26, 2015

Migration from Wordpress

Finally made the move.

This site as you see now is hosted on Amazon S3, statically. It is always reachable, and no spike is going to bring it down. In short, one less thing to worry.

Google will show dozens of how-tos on Wordpress migration. Any way let's document the process. One more success story doesn't hurt.

The Migration

1) Convert Wordpress exported xml file into markdown formats. We use the tool wp4md. The output is a folder containing pages and posts. Every markdown file has tags in beginning, including critical information like the original link, created date. They are very easy to parse.

wp4md -d myblog  <wordpress-dump.xml>

2) It's up to you to convert those markdown files into html. Everyone has unique taste, and it shouldn't be hard to build customized one, given so many powerful script languages and packages.

3) Register a Disqus account. We are not going into details, but basically what you need to do is:

  1. Import that same xml dump;
  2. Provide a csv file to map old urls to new urls. This could be done programatically using the tags in markdown files. When you're done, upload that file to the Disqus website.

4) Redirect the old links. You don't want Google search results pointing to an unusable link, so you need to map those old links to new locations. Normally you should do that with a web server like nginx, but we are now on a static host. It may be possible to use redirect rules provided by Amazon S3, however, I don't really have the time to learn those rules, when we could simply do it with javascript.

Suppose a page was at

Now it's changed to

Then in index.html, we only need to do a check:

var urlmap = {
var pathQuery = window.location.pathname +;
if (urlmap[pathQuery]) {
    window.location = urlmap[pathQuery];

That's it.

Aug 17, 2014

Update: AEMULA 2.0 for Android

AEMULA 2.0 for android is now available on Google Play.

When we built the first version of AEMULA for Android, it's more like of a proof of concept. We just wanted to make sure the emulation engine works on the platform. Although we had some updates since then, they were mostly engine related improvements.

Still I always felt that we need to improve its usability as well. Recently I finally got the ideas of how to improve it, and the time to actually do it. Here are the results of recent effort:

Apr 25, 2014

New Dropbox sync for TeX Writer

Once I worked on a project, I spotted a code section like this:

[text replaceOccurrencesOfString:@"&" withString:@"&amp;"
    options:NSLiteralSearch range:NSMakeRange(0, text.length)];
[text replaceOccurrencesOfString:@"<" withString:@"&lt;"
    options:NSLiteralSearch range:NSMakeRange(0, text.length)];
[text replaceOccurrencesOfString:@">" withString:@"&gt;"
    options:NSLiteralSearch range:NSMakeRange(0, text.length)];

Then I thought -- without much thinking -- that we should get rid of repetitious code, so it became

NSRange fullRange = NSMakeRange(0, text.length);
[text replaceOccurrencesOfString:@"&" withString:@"&amp;"
    options:NSLiteralSearch range:fullRange];
[text replaceOccurrencesOfString:@"<" withString:@"&lt;"
    options:NSLiteralSearch range:fullRange];
[text replaceOccurrencesOfString:@">" withString:@"&gt;"
    options:NSLiteralSearch range:fullRange];

Of course this is a horrible mistake, because the length of text changes over  time. It's basically like saying because x + x = 2x, so that 1 + 1 = 21. Carelessly refactoring working code is both dangerous and expensive, let alone code rewriting. I was fully aware of the cost, at the beginning of April, when I decided to rewrite Dropbox sync code in TeX Writer from scratch. It's a tough decision to make, because you had to throw away all the tests and fixes that went along with the original code. However, two negative reviews in the App Store (they lost changes after sync) helped me make the final decision. We need a solution that will never overwrite people's work no matter what happens, and the previous solution just isn't strong enough. Today, the rewrite is finished and we have done various tests, especially when conflict happens. We hope to release it soon, but at the same time, if you want to help beta test, please let us know!

Jan 30, 2014

TeX Writer and TeX Equation Release Notes

Recently we have updated both TeX Writer and TeX Equation. Now they share a same compilation core. This will make our future update much easier. For TeX Writer, we add a spell checker. You can enable it from TeX Writer settings by selecting a spell dictionary. Instead of putting all dictionaries in the app, we have a list of dictionaries on the cloud so you can pick the ones you need and install in your device. In this way, we can keep the app package as small as possible. The philosophy behind is that the users should not be forced to download anything he/she doesn't need. The TeX editor inside TeX Writer also highlights formulas between a pair of $, such as $x_1$. By default it is shown in red, but you can use the following command in twinit.l to redefine:

(set-string-color <red> <green> <blue> 1)

red/green/blue are numbers in range 0 to 1.0. TeX Equation now offers three ways to get the equation images out:

  1. Copy as PDF. Most recommended way. Keeps high resolution.
  2. Copy as PNG. Retina resolution, transparent background.
  3. Export to album as JPEG. Retina resolution, no transparency. Too bad iOS doesn't offer a way to save PNG to album.