Trying out ACE as simple touch display (iPad) editor


ACE web editor

When I go coding on the go, I currently have a very basic text field on my mobile devices to code in. There is no code highlighting or code completion or anything like that; just a boring text field like Notepad. Now there are (apparently) hordes of people who like to write code in Notepad, but I am not one of them.

The first step to get productive on iOS or Android devices when writing code  is to download a better keyboard. With the standard keyboard, it is really not possible to do much of anything on either device as far as coding is concerned. For iOS I selected ProType ; despite the bad reviews (which are mostly about the condensed style of the keyboard), I found that after a bit of getting used to, it works really well and much faster than the default keyboard for mostly anything, including chat, but definitely for coding.

For Android I use the Hacker’s keyboard which is great; on tablets it’s brilliant, but on phones it does the trick as well.

With that out of the way i’m capable of writing code relatively ok in a ‘notepad’ like TextView, but it’s of course not optimal. So then you have the options to buy some component which does highlighting and possibly code completion for you; there are a few of those but they are not very complete nor very well done. Writing something myself is an option but it will take too much time and it won’t be very robust for months or even years probably. So I opted to try integrating something open source. While it is not a native solution, ACE is a very complete code editor written in Javascript, which seems to run relatively well on mobile browsers. A native solution would have been a lot better, but I cannot find any which are advanced enough to use; Scintilla definitely is, but it does not work on Android and it would take me quite a bit of time to integrate it properly in iOS.

To properly use ACE I would need to integrate it into a WebView to integrate it into my IDE. And that is where it gets hairy. I used ACE before on the iPad on a site which uses a few tricks to make it work properly on a tablet and it was quite ok to work with. At least more than enough to like this as a solution for my IDE. In theory.

Wrapped in a WebView in Xamarin Forms (Github link) for iOS and Android, I believed I had something ok to work with. Then the issues started; obviously the scrolling in the editor is not related to the scrolling in the WebView and as such didn’t actually work at all.

Things like this should make it possible to get that to work on a touch screen, but you won’t get it to work very well unfortunately. I experimented a bit with connecting the native UIScrollView coordinates to the scrollBy() of the ACE editor but that didn’t help either.

The most stable result I got was using;

  1. public AceWebViewRenderer() {
  2. ((UIWebView)this.NativeView).ScrollView.Bounces = false;
  3. ((UIWebView)this.NativeView).ScrollView.ScrollEnabled = false;
  5. }

However that was very far from perfect as well. Things that are broken and hard to fix (as far as I know):

  • scrolling
  • double cursor when you have text far to the right (CodeMirror always has this)
  • second delay when moving the cursor by tapping
  • completions like () {} [] are very annoying to work with on a touch screen

Because I lack time in experimenting further and the current results are not very positive, I think I will try to find something else to resolve this. The perfect solution, to me, would be an editor (and keyboard additions) like the one used in Codea; it works well and is robust. I believe it to be fully custom made though which, unfortunately, seems the most satisfying route at this moment…

Still hoping for a better solution…

Writing a game without sleep, power or internet at JFK

Desolate JFK

Desolate JFK

I have a small (…) obsession with programming on the go. With that I mean that I want to be able to write software where ever I am and no matter what I might be doing. Or under what circumstances. So if I don’t have any power or internet for 20 hours I still need to be able to code. This has been one of the things I have been trying to achieve over the past 20 years. My biggest issues have been battery life and portability.

The are kind of related in the end, but to start with the former; batteries came a long way since I touched my first laptop somewhere end 80s. I was slightly spoiled mind you; I had a PC-1211 for years already by then which had seemingly infinite battery life. (Not to mention that I still have it and it still works well) That machine was obviously limited in power, but it allowed me to try out some algorithms on the go. Battery life has been somewhat of an issue though; tablets/phones/laptops all have abysmal battery life. I need days, not hours. And ‘day long’ which has been promised for years now, is definitely not for my days nor the work I do. My new Macbook seldom makes 4 hours while coding.

Laptops aren’t very portable either besides the Macbook Air 11 inch that is (and possible the new ‘Macbook’?), so it is also quite annoying to lug them around especially when I’m off for a 2 day hike in the mountains (and yes, I would like to code while walking). That brings us to portability and that has also been getting better (faster than battery life) but I must say my favorite portable devices are, in order: iPad Air 2 because it’s big enough to do ‘real’ work on, but weighs very little and is fast, Samsung s5 for the same reasons but different work and the OpenPandora 1 ghz version. The last one because it’s just ‘complete’; it has Linux, Android and runs everything I need (sometimes with some effort but we decided to find that fun).

The OpenPandora and the S5 allow me to swap batteries, giving me around 25 hours on the Pandora without any power outlet and around 20 hours on the S5. All that fits easily in a light bag still. For the iPad I bring an external battery which makes everything a lot heavier which is the reason the iPad only comes when I know I need to work on spreadsheets or documents a lot.

Last year around this time I went to the US on vacation; to Orlando to see if Disney World was still fun (it was) and, to get cheaper tickets we had a stopover at JFK from 11 PM to 8 AM. We were a bit naive being from Europe in thinking that JFK is a big airport so there must be stuff open all night and 11 to 8 is not enough time to go into NYC.

After landing we got into a little food court where we thought we would browse the web a bit and have some snacks and coffee until the morning. Unfortunately that was not going to happen. Everything closed at midnight. I still am flabbergasted by that fact and don’t really understand it, but it happened and there was nothing we could do about it. A bit worse; internet wasn’t working on our devices for some reason. So we had no internet, no power and after a while, no lights(!).

I brought my iPhone 5s, OpenPandora and my Macbook Air 11 (I did not have an iPad yet) to watch movies in the hotel or something. As there were no public power outlets, I knew I could not work on my Macbook too much because it would shut down after 2-3 hours (I opened it in the airplane…). Without internet I was a bit lost as I didn’t feel like reading at that time and we started to get tired (different timezone).

By then (around 00:30) I remembered some swiping game a friend told me to try. I did not download it yet, but I played it. Looking it up in the Appstore now I think it was Dots. And because I don’t actually like playing games (I only like making them; I don’t nearly make enough of them though), I decided to recreate that game from just my short interaction with it.


Squares screenshot

On my Macbook I only had Corona for games and because that is LUA I knew on the OpenPandora I could only use Load81 (as I had nothing else for LUA but a basic installation, and, still, no internet). Load81 is a great tool for teaching people to code as it has no no setup times; you just start it and start programming. Antirez of Redis fame wrote it so it’s like a C=64 from the 80s so people can, again, jump straight in as they could back then, without all the dll hell and compiling, linking etc. Just something to play around. I wrote the basic generators and game algorithms on the OpenPandora; aka, most of the code you see in this file was written in Load81.

After I was happy with how all of that worked in Load81, I used an USB stick to move the code to my Macbook and created the working version in Corona from the demo project. That took only a very short amount of time luckily. My wife and I played it in the Disney World queues most of the time. It’s addictive 🙂

Things that this experience taught me are:

  1. Train your brain; without internet you’d be surprised how much you don’t remember; I was anyway
  2. Downloading and setting up/updating development dependencies is actually far more annoying and time consuming than previously I realized; this was actually one of the smoothest dev experiences in years, despite the constraints
  3. You can finish something nice and addictive in a few hours, so don’t let lack of time stop you; just start coding already
  4. Battery life is indeed great on the OpenPandora
  5. Pulling an all nighter once in a while will focus you
  6. I should (and have been) pursue on-the-go coding like never before (I can code now without internet on the iPad & 5S & S5; more about that soon)

Link to the project in Github. Requires Corona.

HTML5: Fetching videos (etc.) and storing them in Localstorage to play them later offline.

We write a lot of mobile apps and web apps; they both serve their purpose. Usually mobile apps need to also work offline and sync to the server later while web apps have usually an online requirement; aka they won’t work when you have no internet.

A client recently asked to build a web application which could fully work offline. Meaning that all the assets, including quite heavy videos, need to be loaded the first time the app loads and after that should be available to the user even though there is bad or no internet. The logic should be on the client side and the data should be synced when the browser detects internet again.

For the data side of things, we decided to use PouchDB, but for the video side of things I had to make a little demonstration if it was even possible to get this working on modern browsers.

I know it’s theoretically possible to fetch videos and then store them in HTML5 Localstorage and then play them. I did not know it was that easy (using a few external libraries). I combined a few examples and libraries from the web, namely this and LargeLocalStorage and created a working version using Google I/O 2014 MP4 videos.

See the code here.

Tested on Safari desktop, Chrome desktop, Android browser.

Physics Body Editor Java 7 – Mac OS X

Because the downloads and binaries for the Physics Body Editor / Box2D editor do not work on modern versions of Mac OS X / Java 7.x, here is the recompiled binary.

Run with:

java -jar physics-body-editor.jar



This does not yet work with Java 8 (issue with Java 8 and LibGDK). If you have Java 8 installed, here is a version which includes the Java 6 runtime so it will work always.


Using Physics body editor files in actual games;