/var/log

Titanium, Backbone and Promises

An easy way to let Backbone work with Promises in Titanium: Get the bluebird Promise library. Now you can add a fetchAsPromise to the Backbone.Model.Prototype and Backbone.Collection.prototype objects: Backbone.Model.prototype.fetchAsPromise = function(options) { var me = this; return new Promise(function(resolve, reject) { options.success = resolve; options.error = reject; me.fetch(options); }); }; The same can be done […]

UTC date in javascript, php, mysql and sqlite

It can be very challenging to work with dates and times across different timezones. In this post I explain some of the things I do to make this work. I focus on Javascript, PHP, MySQL and SQLite development. MySQL The most important action first - put the connection session in UTC mode: set time_zone = […]

TiShadow

TiShadow enables you to test faster on multiple devices at once. This is a step by step article to use it. If you want to use it on Android Genymotion emulators, you first have to install Google Apps on these emulators. TiShadow consists of 3 elements: The server that pushes apps and updates to the […]

Node.js installation and npm prefix

Some things regarding Node.js installation and setup: When installing Node.js with the installer, it will install the npm inside the Node.js location. So if you've set another prefix, you have to delete the npm packages from within the Node.js location, so they won't shadow the one in the prefix location. The npm prefix variable is […]

Find sqlite location

Te find the sqlite location for your iOS simulator, you first have to know the simulators uid. To see all available simulators and their device UIDS: /Applications/Xcode.app/Contents/Developer/usr/bin/simctl list The sqlite location is: ~/Library/Developer/CoreSimulator/Devices/<device-id>/data/Containers/Data/Application/<application-id>/Library/Private Documents/<db>.sql Unfortunately it's (as far as I know) not possible to get the application id. If you know the name of the […]

Backbone in Titanium

Using Backbone in Titanium Alloy is a very powerful mechanism but it can backfire on you if you don't take into account how it works. Remove event listeners from singletons A common pattern is to create a singleton when a window opens and attach a change event handler to the model so the views will update when […]

Store mcrypt values from PHP in MySQL

The mcrypt functions return a binary string, so you can store it in a VARBINARY or BLOB field or as VARCHAR or TEXT if you first base64 encode it. When using the CBC (Cipher Block Chaining) mode, the input is divided into blocks of X bytes. The last block is then padded with NULL bytes […]

Android UI thread

I wanted to query a database on the onCreate method, but I ran into issues when doing this from another thread. First I tried to do it with the View.post() method, but it seems like the View is not always attached to the window, so the run() method of the Runnable was never called. Another […]